private function prepareFileSelector(ModelIdInterface $modelId, Ajax $ajax = null)
    {
        $inputProvider = $this->itemContainer->getEnvironment()->getInputProvider();
        $propertyName  = $inputProvider->getParameter('field');
        $information   = (array) $GLOBALS['TL_DCA'][$modelId->getDataProviderName()]['fields'][$propertyName];

        if (!isset($information['eval'])) {
            $information['eval'] = [];
        }

        // Merge with the information from the data container.
        $property = $this
            ->itemContainer
            ->getEnvironment()
            ->getDataDefinition()
            ->getPropertiesDefinition()
            ->getProperty($propertyName);
        $extra    = $property->getExtra();

        $information['eval'] = \array_merge($extra, (array) $information['eval']);

        $this->session->set('filePickerRef', Environment::get('request'));

        $combat = new DcCompat($this->itemContainer->getEnvironment(), $this->getActiveModel($modelId), $propertyName);

        /** @var FileSelector $fileSelector */
        $fileSelector = new $GLOBALS['BE_FFL']['fileSelector'](
            Widget::getAttributesFromDca(
                $information,
                $propertyName,
                $this->prepareValuesForFileSelector($propertyName, $modelId, $combat),
                $propertyName,
                $modelId->getDataProviderName(),
                $combat
            ),
            $combat
        );

        // AJAX request.
        if ($ajax) {
            $ajax->executePostActions($combat);
        }

        return $fileSelector;
    }