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: {
      app_settings: {
        Row: {
          created_at: string
          key: string
          updated_at: string
          value: Json
        }
        Insert: {
          created_at?: string
          key: string
          updated_at?: string
          value: Json
        }
        Update: {
          created_at?: string
          key?: string
          updated_at?: string
          value?: Json
        }
        Relationships: []
      }
      audit_logs: {
        Row: {
          action: string
          actor_id: string | null
          created_at: string
          details: Json | null
          entity: string | null
          entity_id: string | null
          id: string
        }
        Insert: {
          action: string
          actor_id?: string | null
          created_at?: string
          details?: Json | null
          entity?: string | null
          entity_id?: string | null
          id?: string
        }
        Update: {
          action?: string
          actor_id?: string | null
          created_at?: string
          details?: Json | null
          entity?: string | null
          entity_id?: string | null
          id?: string
        }
        Relationships: []
      }
      bookings: {
        Row: {
          address: string
          assigned_to: string | null
          company_id: string | null
          created_at: string
          email: string
          full_name: string
          gps_location: string | null
          id: string
          inspector_name: string | null
          notes: string | null
          phone: string
          photo_urls: string[]
          preferred_date: string | null
          preferred_time: string | null
          property_id: string | null
          property_type: string | null
          rooms: number | null
          service_id: string | null
          service_name: string
          status: Database["public"]["Enums"]["booking_status"]
          updated_at: string
          user_id: string | null
        }
        Insert: {
          address: string
          assigned_to?: string | null
          company_id?: string | null
          created_at?: string
          email: string
          full_name: string
          gps_location?: string | null
          id?: string
          inspector_name?: string | null
          notes?: string | null
          phone: string
          photo_urls?: string[]
          preferred_date?: string | null
          preferred_time?: string | null
          property_id?: string | null
          property_type?: string | null
          rooms?: number | null
          service_id?: string | null
          service_name: string
          status?: Database["public"]["Enums"]["booking_status"]
          updated_at?: string
          user_id?: string | null
        }
        Update: {
          address?: string
          assigned_to?: string | null
          company_id?: string | null
          created_at?: string
          email?: string
          full_name?: string
          gps_location?: string | null
          id?: string
          inspector_name?: string | null
          notes?: string | null
          phone?: string
          photo_urls?: string[]
          preferred_date?: string | null
          preferred_time?: string | null
          property_id?: string | null
          property_type?: string | null
          rooms?: number | null
          service_id?: string | null
          service_name?: string
          status?: Database["public"]["Enums"]["booking_status"]
          updated_at?: string
          user_id?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "bookings_company_id_fkey"
            columns: ["company_id"]
            isOneToOne: false
            referencedRelation: "companies"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "bookings_property_id_fkey"
            columns: ["property_id"]
            isOneToOne: false
            referencedRelation: "properties"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "bookings_service_id_fkey"
            columns: ["service_id"]
            isOneToOne: false
            referencedRelation: "services"
            referencedColumns: ["id"]
          },
        ]
      }
      buildings: {
        Row: {
          address: string | null
          created_at: string
          id: string
          name: string
          property_id: string
          updated_at: string
        }
        Insert: {
          address?: string | null
          created_at?: string
          id?: string
          name: string
          property_id: string
          updated_at?: string
        }
        Update: {
          address?: string | null
          created_at?: string
          id?: string
          name?: string
          property_id?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "buildings_property_id_fkey"
            columns: ["property_id"]
            isOneToOne: false
            referencedRelation: "properties"
            referencedColumns: ["id"]
          },
        ]
      }
      companies: {
        Row: {
          bank_account_name: string | null
          bank_account_number: string | null
          bank_name: string | null
          city: string | null
          country: Database["public"]["Enums"]["country_code"]
          created_at: string
          currency: string
          description: string | null
          email: string | null
          id: string
          lga: string | null
          logo_url: string | null
          name: string
          owner_id: string
          phone: string | null
          postcode: string | null
          rating: number | null
          review_count: number
          service_areas: string[]
          services_offered: string[]
          slug: string
          state_region: string | null
          status: Database["public"]["Enums"]["company_status"]
          street_address: string | null
          updated_at: string
        }
        Insert: {
          bank_account_name?: string | null
          bank_account_number?: string | null
          bank_name?: string | null
          city?: string | null
          country?: Database["public"]["Enums"]["country_code"]
          created_at?: string
          currency?: string
          description?: string | null
          email?: string | null
          id?: string
          lga?: string | null
          logo_url?: string | null
          name: string
          owner_id: string
          phone?: string | null
          postcode?: string | null
          rating?: number | null
          review_count?: number
          service_areas?: string[]
          services_offered?: string[]
          slug: string
          state_region?: string | null
          status?: Database["public"]["Enums"]["company_status"]
          street_address?: string | null
          updated_at?: string
        }
        Update: {
          bank_account_name?: string | null
          bank_account_number?: string | null
          bank_name?: string | null
          city?: string | null
          country?: Database["public"]["Enums"]["country_code"]
          created_at?: string
          currency?: string
          description?: string | null
          email?: string | null
          id?: string
          lga?: string | null
          logo_url?: string | null
          name?: string
          owner_id?: string
          phone?: string | null
          postcode?: string | null
          rating?: number | null
          review_count?: number
          service_areas?: string[]
          services_offered?: string[]
          slug?: string
          state_region?: string | null
          status?: Database["public"]["Enums"]["company_status"]
          street_address?: string | null
          updated_at?: string
        }
        Relationships: []
      }
      company_members: {
        Row: {
          active: boolean
          company_id: string
          created_at: string
          full_name: string | null
          id: string
          role: Database["public"]["Enums"]["company_role"]
          updated_at: string
          user_id: string
        }
        Insert: {
          active?: boolean
          company_id: string
          created_at?: string
          full_name?: string | null
          id?: string
          role?: Database["public"]["Enums"]["company_role"]
          updated_at?: string
          user_id: string
        }
        Update: {
          active?: boolean
          company_id?: string
          created_at?: string
          full_name?: string | null
          id?: string
          role?: Database["public"]["Enums"]["company_role"]
          updated_at?: string
          user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "company_members_company_id_fkey"
            columns: ["company_id"]
            isOneToOne: false
            referencedRelation: "companies"
            referencedColumns: ["id"]
          },
        ]
      }
      inspection_reports: {
        Row: {
          ai_assessment: string | null
          areas_inspected: string[]
          booking_id: string | null
          company_id: string | null
          created_at: string
          customer_signature: string | null
          humidity_level: string | null
          humidity_value: number | null
          id: string
          inspection_date: string
          inspector_comments: string | null
          inspector_name: string
          likely_causes: string[]
          moisture_reading: string | null
          normal_image_url: string | null
          property_info: string | null
          published: boolean
          recommendations: string[]
          reference: string
          severity: string | null
          signature_name: string | null
          temperature_level: string | null
          temperature_value: number | null
          thermal_image_url: string | null
          thermal_notes: string | null
          treatment_performed: string | null
          updated_at: string
          user_id: string
          water_detector: string | null
          water_leakage_assessment: string | null
        }
        Insert: {
          ai_assessment?: string | null
          areas_inspected?: string[]
          booking_id?: string | null
          company_id?: string | null
          created_at?: string
          customer_signature?: string | null
          humidity_level?: string | null
          humidity_value?: number | null
          id?: string
          inspection_date?: string
          inspector_comments?: string | null
          inspector_name: string
          likely_causes?: string[]
          moisture_reading?: string | null
          normal_image_url?: string | null
          property_info?: string | null
          published?: boolean
          recommendations?: string[]
          reference?: string
          severity?: string | null
          signature_name?: string | null
          temperature_level?: string | null
          temperature_value?: number | null
          thermal_image_url?: string | null
          thermal_notes?: string | null
          treatment_performed?: string | null
          updated_at?: string
          user_id: string
          water_detector?: string | null
          water_leakage_assessment?: string | null
        }
        Update: {
          ai_assessment?: string | null
          areas_inspected?: string[]
          booking_id?: string | null
          company_id?: string | null
          created_at?: string
          customer_signature?: string | null
          humidity_level?: string | null
          humidity_value?: number | null
          id?: string
          inspection_date?: string
          inspector_comments?: string | null
          inspector_name?: string
          likely_causes?: string[]
          moisture_reading?: string | null
          normal_image_url?: string | null
          property_info?: string | null
          published?: boolean
          recommendations?: string[]
          reference?: string
          severity?: string | null
          signature_name?: string | null
          temperature_level?: string | null
          temperature_value?: number | null
          thermal_image_url?: string | null
          thermal_notes?: string | null
          treatment_performed?: string | null
          updated_at?: string
          user_id?: string
          water_detector?: string | null
          water_leakage_assessment?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "inspection_reports_booking_id_fkey"
            columns: ["booking_id"]
            isOneToOne: false
            referencedRelation: "bookings"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "inspection_reports_company_id_fkey"
            columns: ["company_id"]
            isOneToOne: false
            referencedRelation: "companies"
            referencedColumns: ["id"]
          },
        ]
      }
      invoice_items: {
        Row: {
          created_at: string
          description: string
          id: string
          invoice_id: string
          quantity: number
          unit_price: number
        }
        Insert: {
          created_at?: string
          description: string
          id?: string
          invoice_id: string
          quantity?: number
          unit_price?: number
        }
        Update: {
          created_at?: string
          description?: string
          id?: string
          invoice_id?: string
          quantity?: number
          unit_price?: number
        }
        Relationships: [
          {
            foreignKeyName: "invoice_items_invoice_id_fkey"
            columns: ["invoice_id"]
            isOneToOne: false
            referencedRelation: "invoices"
            referencedColumns: ["id"]
          },
        ]
      }
      invoices: {
        Row: {
          amount_paid: number
          bank_account_name: string | null
          bank_account_number: string | null
          bank_name: string | null
          company_id: string | null
          country: Database["public"]["Enums"]["country_code"]
          created_at: string
          currency: string
          customer_email: string | null
          customer_name: string | null
          customer_phone: string | null
          discount: number
          due_date: string
          id: string
          invoice_no: string
          notes: string | null
          pdf_path: string | null
          property_address: string | null
          quotation_id: string | null
          status: Database["public"]["Enums"]["invoice_status"]
          subtotal: number
          total: number
          updated_at: string
          user_id: string
          vat_amount: number
          vat_rate: number
        }
        Insert: {
          amount_paid?: number
          bank_account_name?: string | null
          bank_account_number?: string | null
          bank_name?: string | null
          company_id?: string | null
          country?: Database["public"]["Enums"]["country_code"]
          created_at?: string
          currency?: string
          customer_email?: string | null
          customer_name?: string | null
          customer_phone?: string | null
          discount?: number
          due_date?: string
          id?: string
          invoice_no: string
          notes?: string | null
          pdf_path?: string | null
          property_address?: string | null
          quotation_id?: string | null
          status?: Database["public"]["Enums"]["invoice_status"]
          subtotal?: number
          total?: number
          updated_at?: string
          user_id: string
          vat_amount?: number
          vat_rate?: number
        }
        Update: {
          amount_paid?: number
          bank_account_name?: string | null
          bank_account_number?: string | null
          bank_name?: string | null
          company_id?: string | null
          country?: Database["public"]["Enums"]["country_code"]
          created_at?: string
          currency?: string
          customer_email?: string | null
          customer_name?: string | null
          customer_phone?: string | null
          discount?: number
          due_date?: string
          id?: string
          invoice_no?: string
          notes?: string | null
          pdf_path?: string | null
          property_address?: string | null
          quotation_id?: string | null
          status?: Database["public"]["Enums"]["invoice_status"]
          subtotal?: number
          total?: number
          updated_at?: string
          user_id?: string
          vat_amount?: number
          vat_rate?: number
        }
        Relationships: [
          {
            foreignKeyName: "invoices_company_id_fkey"
            columns: ["company_id"]
            isOneToOne: false
            referencedRelation: "companies"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "invoices_quotation_id_fkey"
            columns: ["quotation_id"]
            isOneToOne: false
            referencedRelation: "quotations"
            referencedColumns: ["id"]
          },
        ]
      }
      mold_scans: {
        Row: {
          air_circulation: string | null
          analysis: Json | null
          condensation_risk: string | null
          confidence: number
          created_at: string
          customer_name: string | null
          dampness_level: string | null
          factors: string[]
          frames_analyzed: number | null
          humidity_level: string | null
          humidity_risk: string | null
          humidity_score: number | null
          humidity_value: number | null
          id: string
          image_url: string | null
          inspector_comments: string | null
          leakage_risk: string | null
          leakage_signs: string[]
          leakage_verdict: string | null
          media_type: string
          moisture_reading: string | null
          moisture_score: number | null
          overall_risk: string | null
          overall_risk_note: string | null
          pdf_path: string | null
          property_address: string | null
          recommendations: string[]
          report_no: string | null
          severity: string
          summary: string | null
          temperature_level: string | null
          temperature_score: number | null
          temperature_value: number | null
          thermal_image_url: string | null
          thermal_notes: string | null
          user_id: string
          ventilation_risk: string | null
          verdict: string
          video_duration: number | null
          video_url: string | null
          water_detector: string | null
        }
        Insert: {
          air_circulation?: string | null
          analysis?: Json | null
          condensation_risk?: string | null
          confidence?: number
          created_at?: string
          customer_name?: string | null
          dampness_level?: string | null
          factors?: string[]
          frames_analyzed?: number | null
          humidity_level?: string | null
          humidity_risk?: string | null
          humidity_score?: number | null
          humidity_value?: number | null
          id?: string
          image_url?: string | null
          inspector_comments?: string | null
          leakage_risk?: string | null
          leakage_signs?: string[]
          leakage_verdict?: string | null
          media_type?: string
          moisture_reading?: string | null
          moisture_score?: number | null
          overall_risk?: string | null
          overall_risk_note?: string | null
          pdf_path?: string | null
          property_address?: string | null
          recommendations?: string[]
          report_no?: string | null
          severity?: string
          summary?: string | null
          temperature_level?: string | null
          temperature_score?: number | null
          temperature_value?: number | null
          thermal_image_url?: string | null
          thermal_notes?: string | null
          user_id: string
          ventilation_risk?: string | null
          verdict: string
          video_duration?: number | null
          video_url?: string | null
          water_detector?: string | null
        }
        Update: {
          air_circulation?: string | null
          analysis?: Json | null
          condensation_risk?: string | null
          confidence?: number
          created_at?: string
          customer_name?: string | null
          dampness_level?: string | null
          factors?: string[]
          frames_analyzed?: number | null
          humidity_level?: string | null
          humidity_risk?: string | null
          humidity_score?: number | null
          humidity_value?: number | null
          id?: string
          image_url?: string | null
          inspector_comments?: string | null
          leakage_risk?: string | null
          leakage_signs?: string[]
          leakage_verdict?: string | null
          media_type?: string
          moisture_reading?: string | null
          moisture_score?: number | null
          overall_risk?: string | null
          overall_risk_note?: string | null
          pdf_path?: string | null
          property_address?: string | null
          recommendations?: string[]
          report_no?: string | null
          severity?: string
          summary?: string | null
          temperature_level?: string | null
          temperature_score?: number | null
          temperature_value?: number | null
          thermal_image_url?: string | null
          thermal_notes?: string | null
          user_id?: string
          ventilation_risk?: string | null
          verdict?: string
          video_duration?: number | null
          video_url?: string | null
          water_detector?: string | null
        }
        Relationships: []
      }
      notifications: {
        Row: {
          body: string | null
          created_at: string
          id: string
          read: boolean
          title: string
          user_id: string
        }
        Insert: {
          body?: string | null
          created_at?: string
          id?: string
          read?: boolean
          title: string
          user_id: string
        }
        Update: {
          body?: string | null
          created_at?: string
          id?: string
          read?: boolean
          title?: string
          user_id?: string
        }
        Relationships: []
      }
      organization_members: {
        Row: {
          created_at: string
          id: string
          organization_id: string
          role: Database["public"]["Enums"]["organization_role"]
          user_id: string
        }
        Insert: {
          created_at?: string
          id?: string
          organization_id: string
          role?: Database["public"]["Enums"]["organization_role"]
          user_id: string
        }
        Update: {
          created_at?: string
          id?: string
          organization_id?: string
          role?: Database["public"]["Enums"]["organization_role"]
          user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "organization_members_organization_id_fkey"
            columns: ["organization_id"]
            isOneToOne: false
            referencedRelation: "organizations"
            referencedColumns: ["id"]
          },
        ]
      }
      organizations: {
        Row: {
          country: Database["public"]["Enums"]["country_code"]
          created_at: string
          currency: string
          id: string
          name: string
          organization_type: string
          owner_id: string
          timezone: string
          updated_at: string
        }
        Insert: {
          country?: Database["public"]["Enums"]["country_code"]
          created_at?: string
          currency?: string
          id?: string
          name: string
          organization_type?: string
          owner_id: string
          timezone?: string
          updated_at?: string
        }
        Update: {
          country?: Database["public"]["Enums"]["country_code"]
          created_at?: string
          currency?: string
          id?: string
          name?: string
          organization_type?: string
          owner_id?: string
          timezone?: string
          updated_at?: string
        }
        Relationships: []
      }
      payments: {
        Row: {
          admin_note: string | null
          amount: number
          consumed_at: string | null
          created_at: string
          currency: string
          id: string
          payer_name: string | null
          proof_url: string | null
          purpose: string
          reference: string
          reviewed_at: string | null
          reviewed_by: string | null
          scan_id: string | null
          status: Database["public"]["Enums"]["payment_status"]
          updated_at: string
          user_id: string
        }
        Insert: {
          admin_note?: string | null
          amount?: number
          consumed_at?: string | null
          created_at?: string
          currency?: string
          id?: string
          payer_name?: string | null
          proof_url?: string | null
          purpose?: string
          reference?: string
          reviewed_at?: string | null
          reviewed_by?: string | null
          scan_id?: string | null
          status?: Database["public"]["Enums"]["payment_status"]
          updated_at?: string
          user_id: string
        }
        Update: {
          admin_note?: string | null
          amount?: number
          consumed_at?: string | null
          created_at?: string
          currency?: string
          id?: string
          payer_name?: string | null
          proof_url?: string | null
          purpose?: string
          reference?: string
          reviewed_at?: string | null
          reviewed_by?: string | null
          scan_id?: string | null
          status?: Database["public"]["Enums"]["payment_status"]
          updated_at?: string
          user_id?: string
        }
        Relationships: []
      }
      profiles: {
        Row: {
          address: string | null
          city: string | null
          country: Database["public"]["Enums"]["country_code"]
          created_at: string
          full_name: string | null
          id: string
          lga: string | null
          phone: string | null
          postcode: string | null
          state_region: string | null
          street_address: string | null
          updated_at: string
        }
        Insert: {
          address?: string | null
          city?: string | null
          country?: Database["public"]["Enums"]["country_code"]
          created_at?: string
          full_name?: string | null
          id: string
          lga?: string | null
          phone?: string | null
          postcode?: string | null
          state_region?: string | null
          street_address?: string | null
          updated_at?: string
        }
        Update: {
          address?: string | null
          city?: string | null
          country?: Database["public"]["Enums"]["country_code"]
          created_at?: string
          full_name?: string | null
          id?: string
          lga?: string | null
          phone?: string | null
          postcode?: string | null
          state_region?: string | null
          street_address?: string | null
          updated_at?: string
        }
        Relationships: []
      }
      properties: {
        Row: {
          city: string | null
          country: Database["public"]["Enums"]["country_code"]
          created_at: string
          currency: string
          id: string
          measurement_system: string
          name: string
          notes: string | null
          organization_id: string | null
          owner_id: string
          postcode: string | null
          property_type: string
          state_region: string | null
          street_address: string
          timezone: string
          updated_at: string
        }
        Insert: {
          city?: string | null
          country?: Database["public"]["Enums"]["country_code"]
          created_at?: string
          currency?: string
          id?: string
          measurement_system?: string
          name: string
          notes?: string | null
          organization_id?: string | null
          owner_id: string
          postcode?: string | null
          property_type?: string
          state_region?: string | null
          street_address: string
          timezone?: string
          updated_at?: string
        }
        Update: {
          city?: string | null
          country?: Database["public"]["Enums"]["country_code"]
          created_at?: string
          currency?: string
          id?: string
          measurement_system?: string
          name?: string
          notes?: string | null
          organization_id?: string | null
          owner_id?: string
          postcode?: string | null
          property_type?: string
          state_region?: string | null
          street_address?: string
          timezone?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "properties_organization_id_fkey"
            columns: ["organization_id"]
            isOneToOne: false
            referencedRelation: "organizations"
            referencedColumns: ["id"]
          },
        ]
      }
      quotation_events: {
        Row: {
          actor_id: string | null
          created_at: string
          from_status: string | null
          id: string
          note: string | null
          quotation_id: string
          to_status: string
        }
        Insert: {
          actor_id?: string | null
          created_at?: string
          from_status?: string | null
          id?: string
          note?: string | null
          quotation_id: string
          to_status: string
        }
        Update: {
          actor_id?: string | null
          created_at?: string
          from_status?: string | null
          id?: string
          note?: string | null
          quotation_id?: string
          to_status?: string
        }
        Relationships: [
          {
            foreignKeyName: "quotation_events_quotation_id_fkey"
            columns: ["quotation_id"]
            isOneToOne: false
            referencedRelation: "quotations"
            referencedColumns: ["id"]
          },
        ]
      }
      quotation_items: {
        Row: {
          created_at: string
          description: string
          id: string
          quantity: number
          quotation_id: string
          unit_price: number
        }
        Insert: {
          created_at?: string
          description: string
          id?: string
          quantity?: number
          quotation_id: string
          unit_price?: number
        }
        Update: {
          created_at?: string
          description?: string
          id?: string
          quantity?: number
          quotation_id?: string
          unit_price?: number
        }
        Relationships: [
          {
            foreignKeyName: "quotation_items_quotation_id_fkey"
            columns: ["quotation_id"]
            isOneToOne: false
            referencedRelation: "quotations"
            referencedColumns: ["id"]
          },
        ]
      }
      quotations: {
        Row: {
          accepted_at: string | null
          booking_id: string | null
          company_id: string | null
          country: Database["public"]["Enums"]["country_code"]
          created_at: string
          currency: string
          customer_email: string | null
          customer_name: string | null
          customer_phone: string | null
          discount: number
          expired_at: string | null
          id: string
          notes: string | null
          property_address: string | null
          reference: string
          rejected_at: string | null
          scan_id: string | null
          sent_at: string | null
          status: Database["public"]["Enums"]["quote_status"]
          subtotal: number
          total: number
          updated_at: string
          user_id: string
          valid_until: string | null
          vat_amount: number
          vat_rate: number
          viewed_at: string | null
        }
        Insert: {
          accepted_at?: string | null
          booking_id?: string | null
          company_id?: string | null
          country?: Database["public"]["Enums"]["country_code"]
          created_at?: string
          currency?: string
          customer_email?: string | null
          customer_name?: string | null
          customer_phone?: string | null
          discount?: number
          expired_at?: string | null
          id?: string
          notes?: string | null
          property_address?: string | null
          reference?: string
          rejected_at?: string | null
          scan_id?: string | null
          sent_at?: string | null
          status?: Database["public"]["Enums"]["quote_status"]
          subtotal?: number
          total?: number
          updated_at?: string
          user_id: string
          valid_until?: string | null
          vat_amount?: number
          vat_rate?: number
          viewed_at?: string | null
        }
        Update: {
          accepted_at?: string | null
          booking_id?: string | null
          company_id?: string | null
          country?: Database["public"]["Enums"]["country_code"]
          created_at?: string
          currency?: string
          customer_email?: string | null
          customer_name?: string | null
          customer_phone?: string | null
          discount?: number
          expired_at?: string | null
          id?: string
          notes?: string | null
          property_address?: string | null
          reference?: string
          rejected_at?: string | null
          scan_id?: string | null
          sent_at?: string | null
          status?: Database["public"]["Enums"]["quote_status"]
          subtotal?: number
          total?: number
          updated_at?: string
          user_id?: string
          valid_until?: string | null
          vat_amount?: number
          vat_rate?: number
          viewed_at?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "quotations_booking_id_fkey"
            columns: ["booking_id"]
            isOneToOne: false
            referencedRelation: "bookings"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "quotations_company_id_fkey"
            columns: ["company_id"]
            isOneToOne: false
            referencedRelation: "companies"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "quotations_scan_id_fkey"
            columns: ["scan_id"]
            isOneToOne: false
            referencedRelation: "mold_scans"
            referencedColumns: ["id"]
          },
        ]
      }
      report_photos: {
        Row: {
          caption: string | null
          created_at: string
          id: string
          kind: string
          report_id: string
          url: string
        }
        Insert: {
          caption?: string | null
          created_at?: string
          id?: string
          kind?: string
          report_id: string
          url: string
        }
        Update: {
          caption?: string | null
          created_at?: string
          id?: string
          kind?: string
          report_id?: string
          url?: string
        }
        Relationships: [
          {
            foreignKeyName: "report_photos_report_id_fkey"
            columns: ["report_id"]
            isOneToOne: false
            referencedRelation: "inspection_reports"
            referencedColumns: ["id"]
          },
        ]
      }
      reviews: {
        Row: {
          approved: boolean
          author_name: string
          comment: string | null
          created_at: string
          id: string
          photo_urls: string[]
          rating: number
          user_id: string
        }
        Insert: {
          approved?: boolean
          author_name: string
          comment?: string | null
          created_at?: string
          id?: string
          photo_urls?: string[]
          rating: number
          user_id: string
        }
        Update: {
          approved?: boolean
          author_name?: string
          comment?: string | null
          created_at?: string
          id?: string
          photo_urls?: string[]
          rating?: number
          user_id?: string
        }
        Relationships: []
      }
      services: {
        Row: {
          active: boolean
          benefits: string[]
          category: string
          created_at: string
          description: string
          id: string
          name: string
          price_from: number | null
          price_unit: string | null
          process: string[]
          short_description: string
          slug: string
          sort_order: number
        }
        Insert: {
          active?: boolean
          benefits?: string[]
          category: string
          created_at?: string
          description: string
          id?: string
          name: string
          price_from?: number | null
          price_unit?: string | null
          process?: string[]
          short_description: string
          slug: string
          sort_order?: number
        }
        Update: {
          active?: boolean
          benefits?: string[]
          category?: string
          created_at?: string
          description?: string
          id?: string
          name?: string
          price_from?: number | null
          price_unit?: string | null
          process?: string[]
          short_description?: string
          slug?: string
          sort_order?: number
        }
        Relationships: []
      }
      subscriptions: {
        Row: {
          amount: number
          company_id: string
          created_at: string
          currency: string
          current_period_end: string | null
          id: string
          plan: Database["public"]["Enums"]["subscription_plan"]
          status: Database["public"]["Enums"]["subscription_status"]
          testing_mode: boolean
          trial_ends_at: string
          updated_at: string
        }
        Insert: {
          amount?: number
          company_id: string
          created_at?: string
          currency?: string
          current_period_end?: string | null
          id?: string
          plan?: Database["public"]["Enums"]["subscription_plan"]
          status?: Database["public"]["Enums"]["subscription_status"]
          testing_mode?: boolean
          trial_ends_at?: string
          updated_at?: string
        }
        Update: {
          amount?: number
          company_id?: string
          created_at?: string
          currency?: string
          current_period_end?: string | null
          id?: string
          plan?: Database["public"]["Enums"]["subscription_plan"]
          status?: Database["public"]["Enums"]["subscription_status"]
          testing_mode?: boolean
          trial_ends_at?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "subscriptions_company_id_fkey"
            columns: ["company_id"]
            isOneToOne: true
            referencedRelation: "companies"
            referencedColumns: ["id"]
          },
        ]
      }
      units: {
        Row: {
          building_id: string
          created_at: string
          id: string
          name: string
          unit_type: string
          updated_at: string
        }
        Insert: {
          building_id: string
          created_at?: string
          id?: string
          name: string
          unit_type?: string
          updated_at?: string
        }
        Update: {
          building_id?: string
          created_at?: string
          id?: string
          name?: string
          unit_type?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "units_building_id_fkey"
            columns: ["building_id"]
            isOneToOne: false
            referencedRelation: "buildings"
            referencedColumns: ["id"]
          },
        ]
      }
      user_roles: {
        Row: {
          id: string
          role: Database["public"]["Enums"]["app_role"]
          user_id: string
        }
        Insert: {
          id?: string
          role: Database["public"]["Enums"]["app_role"]
          user_id: string
        }
        Update: {
          id?: string
          role?: Database["public"]["Enums"]["app_role"]
          user_id?: string
        }
        Relationships: []
      }
    }
    Views: {
      [_ in never]: never
    }
    Functions: {
      has_company_role: {
        Args: {
          _company_id: string
          _role: Database["public"]["Enums"]["company_role"]
          _user_id: string
        }
        Returns: boolean
      }
      has_role: {
        Args: {
          _role: Database["public"]["Enums"]["app_role"]
          _user_id: string
        }
        Returns: boolean
      }
      is_company_member: {
        Args: { _company_id: string; _user_id: string }
        Returns: boolean
      }
      notify_admins: {
        Args: { _body: string; _title: string }
        Returns: undefined
      }
      user_company_ids: { Args: { _user_id: string }; Returns: string[] }
    }
    Enums: {
      app_role: "admin" | "customer" | "super_admin"
      booking_status:
        | "requested"
        | "confirmed"
        | "inspector_assigned"
        | "inspection_completed"
        | "treatment_scheduled"
        | "completed"
        | "cancelled"
      company_role: "company_admin" | "inspector" | "technician" | "agent"
      company_status: "pending" | "approved" | "suspended"
      country_code: "NG" | "US" | "GB"
      invoice_status: "unpaid" | "partially_paid" | "paid" | "overdue" | "void"
      organization_role:
        | "owner"
        | "administrator"
        | "facility_manager"
        | "viewer"
      payment_status:
        | "awaiting_payment"
        | "proof_submitted"
        | "approved"
        | "rejected"
      quote_status:
        | "draft"
        | "sent"
        | "accepted"
        | "declined"
        | "viewed"
        | "expired"
      subscription_plan: "free_trial" | "monthly" | "yearly"
      subscription_status:
        | "trialing"
        | "active"
        | "past_due"
        | "canceled"
        | "expired"
    }
    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: {
      app_role: ["admin", "customer", "super_admin"],
      booking_status: [
        "requested",
        "confirmed",
        "inspector_assigned",
        "inspection_completed",
        "treatment_scheduled",
        "completed",
        "cancelled",
      ],
      company_role: ["company_admin", "inspector", "technician", "agent"],
      company_status: ["pending", "approved", "suspended"],
      country_code: ["NG", "US", "GB"],
      invoice_status: ["unpaid", "partially_paid", "paid", "overdue", "void"],
      organization_role: [
        "owner",
        "administrator",
        "facility_manager",
        "viewer",
      ],
      payment_status: [
        "awaiting_payment",
        "proof_submitted",
        "approved",
        "rejected",
      ],
      quote_status: [
        "draft",
        "sent",
        "accepted",
        "declined",
        "viewed",
        "expired",
      ],
      subscription_plan: ["free_trial", "monthly", "yearly"],
      subscription_status: [
        "trialing",
        "active",
        "past_due",
        "canceled",
        "expired",
      ],
    },
  },
} as const
