import { Plugin } from 'vite';

/**
 * Dev-server endpoint that exposes and accepts the list of registered
 * {@link HashtagCommands} handlers as {@link InkHashtagCommandInfo} objects.
 *
 * - `GET  /__pixi-vn-ink/hashtag-commands` – returns the stored `InkHashtagCommandInfo[]` as JSON.
 * - `POST /__pixi-vn-ink/hashtag-commands` – replaces the stored list with the JSON body
 *   (`InkHashtagCommandInfo[]`). Called automatically by {@link setupInkHmrListener} on
 *   startup and after each HMR update.
 * - `InkHashtagCommandInfo.validation` serializes the original validation rule:
 *   - `{ type: "regexp", source, flags }`
 *   - `{ type: "zod", schema }` (JSON Schema generated from Zod)
 *   - `{ type: "literal", value }`
 *
 * @example
 * // VS Code extension reading the registered handlers
 * const res = await fetch("http://localhost:5173/__pixi-vn-ink/hashtag-commands");
 * const commands: InkHashtagCommandInfo[] = await res.json();
 */
declare const INK_DEV_API_HASHTAG_COMMANDS = "/__pixi-vn-ink/hashtag-commands";
/**
 * Dev-server endpoint that exposes and accepts the list of registered
 * {@link TextReplaces} handlers as {@link InkTextReplaceInfo} objects.
 *
 * - `GET  /__pixi-vn-ink/text-replaces` – returns the stored `InkTextReplaceInfo[]` as JSON.
 * - `POST /__pixi-vn-ink/text-replaces` – replaces the stored list with the JSON body
 *   (`InkTextReplaceInfo[]`). Called automatically by {@link setupInkHmrListener} on
 *   startup and after each HMR update.
 * - `InkTextReplaceInfo.validation` serializes the original validation rule:
 *   - `{ type: "regexp", source, flags }`
 *   - `{ type: "zod", schema }` (JSON Schema generated from Zod)
 *   - `{ type: "literal", value }` for string modes like `"all"` / `"characterId"`
 *
 * @example
 * // VS Code extension reading the registered text-replace handlers
 * const res = await fetch("http://localhost:5173/__pixi-vn-ink/text-replaces");
 * const replaces: InkTextReplaceInfo[] = await res.json();
 */
declare const INK_DEV_API_TEXT_REPLACES = "/__pixi-vn-ink/text-replaces";

/**
 * Serializable representation of a handler `validation` rule used by
 * {@link HashtagCommands} and {@link TextReplaces}.
 */
type InkValidationInfo = {
    /**
     * Validation based on regular expression.
     */
    type: "regexp";
    /**
     * The regex source pattern.
     */
    source: string;
    /**
     * Regex flags (for example `"i"` or `"gi"`).
     */
    flags: string;
} | {
    /**
     * Validation based on a Zod schema serialized to JSON Schema.
     */
    type: "zod";
    /**
     * JSON Schema representation of the original Zod validation.
     */
    schema: Record<string, unknown>;
} | {
    /**
     * Validation represented by a string literal value
     * (e.g. `"all"` or `"characterId"`).
     */
    type: "literal";
    /**
     * The original literal validation value.
     */
    value: string;
};
/**
 * Serializable representation of a registered {@link HashtagCommands} handler,
 * as exposed by the pixi-vn-ink Vite dev-server API.
 *
 * Instances of this type are returned by
 * `GET /__pixi-vn-ink/hashtag-commands`
 * and accepted by
 * `POST /__pixi-vn-ink/hashtag-commands`.
 *
 * @see https://pixi-vn.web.app/ink#vite-plugin
 */
interface InkHashtagCommandInfo {
    /**
     * Unique name that identifies the handler.
     * Matches {@link HashtagHandlerOptions.name}.
     */
    name: string;
    /**
     * Human-readable description of what the handler does.
     * Matches {@link HashtagHandlerOptions.description}.
     */
    description?: string;
    /**
     * Serializable form of {@link HashtagHandlerOptions.validation}.
     */
    validation: InkValidationInfo;
}
/**
 * Serializable representation of a registered {@link TextReplaces} handler,
 * as exposed by the pixi-vn-ink Vite dev-server API.
 *
 * Instances of this type are returned by
 * `GET /__pixi-vn-ink/text-replaces`
 * and accepted by
 * `POST /__pixi-vn-ink/text-replaces`.
 *
 * @see https://pixi-vn.web.app/ink#vite-plugin
 */
interface InkTextReplaceInfo {
    /**
     * Unique name that identifies the handler.
     * Matches {@link ReplaceHandlerOptions.name}.
     */
    name: string;
    /**
     * Human-readable description of what the handler does.
     * Matches {@link ReplaceHandlerOptions.description}.
     */
    description?: string;
    /**
     * Serializable form of {@link ReplaceHandlerOptions.validation}.
     */
    validation: InkValidationInfo;
    /**
     * When the handler runs relative to the translation step.
     * Matches {@link ReplaceHandlerOptions.type}.
     * @default "before-translation"
     */
    type?: "before-translation" | "after-translation";
}

/**
 * Options for {@link vitePluginInk}.
 */
interface VitePluginInkOptions {
    /**
     * Glob pattern specifying which `.ink` files to scan and load automatically.
     *
     * When provided, a virtual module `virtual:pixi-vn-ink` is generated and can be imported
     * anywhere in your app. It exports, as its default export, an array of strings (`string[]`)
     * containing the raw text of every matched `.ink` file.
     *
     * This eliminates the need to manually write a glob-import helper such as `getInkText`.
     *
     * The pattern follows the standard glob format used by
     * [Vite's `import.meta.glob`](https://vite.dev/guide/features#glob-import).
     * The plugin resolves it from Vite `root` and internally normalizes it to a root-absolute
     * pattern for the generated virtual module.
     *
     * @example "./ink/**\/*.ink"
     * @example "/src/stories/**\/*.ink"
     */
    inkGlob?: string;
    /**
     * Output pattern for generated JSON files from matched `.ink` sources.
     *
     * When provided together with {@link VitePluginInkOptions.inkGlob}, each matched `.ink` file is
     * converted with `convertInkToJson` and written to the rendered destination.
     *
     * Placeholders:
     * - `[name]`: filename without extension
     * - `[ext]`: source extension without dot
     * - `[extname]`: source extension with dot
     * - `[file]`: source path relative to the `inkGlob` static base
     * - `[path]`: source directory relative to the `inkGlob` static base (with trailing slash)
     * - `[dir]`: source directory relative to Vite `root` (with trailing slash)
     *
     * Relative values are resolved from Vite `root`.
     *
     * @example "./public/ink-json/[path][name].json"
     * @example "/absolute/output/[dir][name].json"
     */
    inkJsonOutputPattern?: string;
    /**
     * Custom path (including filename) for the manifest file generated alongside the exported JSON
     * files.
     *
     * When {@link VitePluginInkOptions.inkJsonOutputPattern} is set, a `manifest.json` file listing
     * all exported JSON URLs is written into the output base directory by default. Use this option
     * to override the manifest file location and/or its name.
     *
     * Relative values are resolved from Vite `root`.
     *
     * @example "./public/ink-json/index.json"
     * @example "./generated/manifest.json"
     */
    inkJsonManifestPath?: string;
}
declare function vitePluginInk(options?: VitePluginInkOptions): Plugin;

export { INK_DEV_API_HASHTAG_COMMANDS, INK_DEV_API_TEXT_REPLACES, type InkHashtagCommandInfo, type InkTextReplaceInfo, type VitePluginInkOptions, vitePluginInk as noHmrInkPlugin, vitePluginInk };
