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

export interface HtmlEntityOptions {
  mode: "encode" | "decode";
}

export const htmlEntityPlugin: PlimiPlugin<HtmlEntityOptions> = {
  manifest: {
    id: "dev-htmlentity",
    name: "HTML Entity Encoder",
    description: "Encode special characters to HTML entities or decode them back.",
    category: "developer",
    version: "1.0.0",
    tags: ["html", "entity", "encode", "decode", "escape"],
    input: { type: "text", placeholder: "Enter text with < > & \" characters..." },
    output: { type: "text" },
    example: '<div class="hero">Hello & "World"</div>',
    offlineReady: true,
  },

  optionsSchema: {
    fields: [
      {
        type: "select",
        key: "mode",
        label: "Mode",
        defaultValue: "encode",
        options: [
          { label: "Encode", value: "encode" },
          { label: "Decode", value: "decode" },
        ],
      },
    ],
  },

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

  run: runHtmlEntity,
};
