business vehicle - basis, depreciation, gain convert to personal use & sale

What is my business cost basis for this vehicle so I can calculate gain/loss?

 

50,000 FMV the year i put into business service (2017)

Varied business % use each year

.099 overall business % use 2017-2023  (all business miles/total miles) 

Used standard mileage deduction each year and total depreciation included in standard mileage is $1,780.

Converted to personal use in 2023

Sold in 2023 for $17,500 (business % .099 x 17,500= $1,732)

 

What is my basis?

What is my total depreciation?

Do I have a gain or loss?  (or just the $1,780 depreciation from standard mileage is taxed/recaptured?)

 

Thank you