import { Folder, FolderOpen } from "@phosphor-icons/react";
import { getIcon } from "material-file-icons";
import type { IconThemeDefinition } from "../types";

export const materialIconTheme: IconThemeDefinition = {
  id: "material",
  name: "Material Icons",
  description: "Material Design file icons",
  getFileIcon: (fileName: string, isDir: boolean, isExpanded = false, _isSymlink = false) => {
    if (isDir) {
      const Icon = isExpanded ? FolderOpen : Folder;
      return {
        component: <Icon />,
      };
    }

    const icon = getIcon(fileName);
    const svgContent = icon.svg
      .replace(/fill="[^"]*"/g, 'fill="currentColor"')
      .replace(/stroke="[^"]*"/g, 'stroke="currentColor"');

    return { svg: svgContent };
  },
};
