import type { PlimiPlugin } from "../../core/plugins/plugin-types";
import { runColorConverter } from "./run";

export interface ColorConverterOptions {
  format: "hex" | "rgb" | "hsl";
}

export const colorConverterPlugin: PlimiPlugin<ColorConverterOptions> = {
  manifest: {
    id: "dev-color",
    name: "Color Converter",
    description: "Convert colors between HEX, RGB, and HSL formats.",
    category: "developer",
    version: "1.0.0",
    tags: ["color", "hex", "rgb", "hsl", "converter"],
    input: { type: "text", placeholder: "#ff0000 or rgb(255,0,0) or hsl(0,100%,50%)", multiline: false },
    output: { type: "json" },
    example: "#3b82f6",
    offlineReady: true,
  },

  optionsSchema: {
    fields: [
      {
        type: "select",
        key: "format",
        label: "Output Format",
        defaultValue: "hex",
        options: [
          { label: "HEX", value: "hex" },
          { label: "RGB", value: "rgb" },
          { label: "HSL", value: "hsl" },
        ],
      },
    ],
  },

  capabilities: {
    cancelable: false,
    worker: false,
  },

  run: runColorConverter,
};
