High resolution spectroscopy of GRB 021004 revealed a wealth of absorption lines from several intermediate ionization species. The velocity structure of the absorber is complex and material with velocity up to >3000 km/s is observed. Since only the blueshifted component is observed, the absorber is very likely to be material closely surrounding the gamma-ray burst. We use a time-dependent photoionization code to track the abundance of the ions over time. Thanks to the presence of absorption from intermediate ionization states at long times, we can estimate the location and mass of the components of the absorber. We interpret those constraints within the hypernova scenario showing that the mass loss rate of the progenitor must have been ~10^{-4} solar masses per year, suggestive of a very massive star. In addition, the wind termination shock must lie at a distance of at least 100 pc, implying a low density environment. The velocity structure of the absorber also requires clumping of the wind at those large distances.