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

export interface JsonOptions {
  indent: "2 spaces" | "4 spaces" | "tabs" | "minified";
}

export const jsonFormatterPlugin: PlimiPlugin<JsonOptions> = {
  manifest: {
    id: "dev-json",
    name: "JSON Formatter",
    description: "Format, minify, and validate JSON strings.",
    category: "developer",
    version: "1.0.0",
    tags: ["json", "format", "minify", "validate"],
    input: { type: "text" },
    output: { type: "text" },
    example: '{"name":"Plimi","version":1,"tools":["base64","hash"],"offline":true}',
    offlineReady: true,
  },

  optionsSchema: {
    fields: [
      {
        type: "select",
        key: "indent",
        label: "Indent",
        defaultValue: "2 spaces",
        options: [
          { label: "2 Spaces", value: "2 spaces" },
          { label: "4 Spaces", value: "4 spaces" },
          { label: "Tabs", value: "tabs" },
          { label: "Minified", value: "minified" },
        ],
      },
    ],
  },

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

  run: runJsonFormatter,
};
