public function map(array $requested, array $supported): array
    {
        $index = [];
        foreach ($supported as $tag) {
            $key = strtolower(preg_replace('/_-\./', '', $tag));
            $index[$key] = $tag;
        }

        $result = [];
        foreach ($requested as $source) {
            if (array_key_exists($source, $this->preferred)) {
                $preferred = $this->preferred[$source];
                foreach ($preferred as $tag) {
                    if (in_array($tag, $supported, true)) {
                        $result[] = $tag;
                        continue 2;
                    }
                }
            }

            if (in_array($source, $supported, true)) {
                $result[] = $source;
                continue;
            }

            $tag = strtolower(preg_replace('/_-\./', '', $source));
            foreach ($index as $key => $target) {
                if (strpos($key, $tag) === 0) {
                    $result[] = $target;
                    break;
                }
            }
        }

        return $result;
    }