How does the gerund function in the following sentence?

Spending all day at the mall is not my idea of fun.
subject
subject complement
object of the preposition
direct object