import * as _angular_core from '@angular/core';
import { InjectionToken, ElementRef } from '@angular/core';
import * as _codemirror_autocomplete from '@codemirror/autocomplete';
import * as _codemirror_state from '@codemirror/state';
import { Extension } from '@codemirror/state';
import { MXValueComponent } from '@acorex/cdk/common';
import * as i1 from '@angular/common';

/**
 * Base interface for all code editor plugins
 */
interface AXCodeEditorPlugin {
    /** Unique identifier for the plugin */
    readonly id: string;
    /** Human-readable name */
    readonly name: string;
    /** Plugin version */
    readonly version?: string;
}
/**
 * Language plugin provides syntax highlighting and language-specific features
 */
interface AXCodeEditorLanguagePlugin extends AXCodeEditorPlugin {
    /** Language identifiers this plugin supports (e.g., 'javascript', 'js') */
    readonly languages: ReadonlyArray<string>;
    /** Load and return the CodeMirror extension for this language */
    getExtension(): Promise<Extension>;
}
/**
 * Theme plugin provides visual styling for the editor
 */
interface AXCodeEditorThemePlugin extends AXCodeEditorPlugin {
    /** Whether this is a dark theme */
    readonly dark: boolean;
    /** Load and return the CodeMirror theme extension */
    getExtension(): Promise<Extension>;
}
/**
 * Formatter plugin provides code formatting capabilities
 */
interface AXCodeEditorFormatterPlugin extends AXCodeEditorPlugin {
    /** Languages this formatter supports */
    readonly languages: ReadonlyArray<string>;
    /** Format the given text */
    format(text: string, language: string): Promise<string | null>;
}
/**
 * Extension plugin provides additional CodeMirror extensions
 */
interface AXCodeEditorExtensionPlugin extends AXCodeEditorPlugin {
    /** Get the CodeMirror extension */
    getExtension(): Promise<Extension>;
}
/**
 * Plugin configuration for the code editor
 */
interface AXCodeEditorPluginConfig {
    /** Language plugins */
    languages?: ReadonlyArray<AXCodeEditorLanguagePlugin>;
    /** Theme plugins */
    themes?: ReadonlyArray<AXCodeEditorThemePlugin>;
    /** Formatter plugins */
    formatters?: ReadonlyArray<AXCodeEditorFormatterPlugin>;
    /** Additional extension plugins */
    extensions?: ReadonlyArray<AXCodeEditorExtensionPlugin>;
}

/**
 * Injection token for providing code editor plugin configuration
 */
declare const AX_CODE_EDITOR_PLUGIN_CONFIG: InjectionToken<AXCodeEditorPluginConfig>;

/**
 * Registry service for managing code editor plugins
 */
declare class AXCodeEditorPluginRegistry {
    private config;
    private languagePlugins;
    private themePlugins;
    private formatterPlugins;
    private extensionPlugins;
    constructor();
    private initializePlugins;
    /**
     * Get language extension for the specified language
     */
    getLanguageExtension(language: string): Promise<Extension>;
    /**
     * Get theme extension by theme ID
     */
    getThemeExtension(themeId: string): Promise<Extension>;
    /**
     * Format text using the appropriate formatter for the language
     */
    format(text: string, language: string): Promise<string | null>;
    /**
     * Get all registered extension plugins
     */
    getExtensionPlugins(): Promise<Extension[]>;
    /**
     * Check if a language is supported
     */
    hasLanguage(language: string): boolean;
    /**
     * Check if a theme is available
     */
    hasTheme(themeId: string): boolean;
    /**
     * Check if a formatter is available for a language
     */
    hasFormatter(language: string): boolean;
    /**
     * Get all available language identifiers
     */
    getAvailableLanguages(): string[];
    /**
     * Get all available theme identifiers
     */
    getAvailableThemes(): string[];
    /**
     * Register a language plugin at runtime
     */
    registerLanguagePlugin(plugin: AXCodeEditorLanguagePlugin): void;
    /**
     * Register a theme plugin at runtime
     */
    registerThemePlugin(plugin: AXCodeEditorThemePlugin): void;
    /**
     * Register a formatter plugin at runtime
     */
    registerFormatterPlugin(plugin: AXCodeEditorFormatterPlugin): void;
    /**
     * Register an extension plugin at runtime
     */
    registerExtensionPlugin(plugin: AXCodeEditorExtensionPlugin): void;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXCodeEditorPluginRegistry, never>;
    static ɵprov: _angular_core.ɵɵInjectableDeclaration<AXCodeEditorPluginRegistry>;
}

declare class JavaScriptLanguagePlugin implements AXCodeEditorLanguagePlugin {
    readonly id = "javascript";
    readonly name = "JavaScript";
    readonly version = "1.0.0";
    readonly languages: readonly ["javascript", "js"];
    getExtension(): Promise<Extension>;
}

declare class TypeScriptLanguagePlugin implements AXCodeEditorLanguagePlugin {
    readonly id = "typescript";
    readonly name = "TypeScript";
    readonly version = "1.0.0";
    readonly languages: readonly ["typescript", "ts"];
    getExtension(): Promise<Extension>;
}

declare class JSONLanguagePlugin implements AXCodeEditorLanguagePlugin {
    readonly id = "json";
    readonly name = "JSON";
    readonly version = "1.0.0";
    readonly languages: readonly ["json"];
    getExtension(): Promise<Extension>;
}

declare class HTMLLanguagePlugin implements AXCodeEditorLanguagePlugin {
    readonly id = "html";
    readonly name = "HTML";
    readonly version = "1.0.0";
    readonly languages: readonly ["html"];
    getExtension(): Promise<Extension>;
}

declare class CSSLanguagePlugin implements AXCodeEditorLanguagePlugin {
    readonly id = "css";
    readonly name = "CSS";
    readonly version = "1.0.0";
    readonly languages: readonly ["css"];
    getExtension(): Promise<Extension>;
}

declare class SassLanguagePlugin implements AXCodeEditorLanguagePlugin {
    readonly id = "sass";
    readonly name = "Sass/SCSS";
    readonly version = "1.0.0";
    readonly languages: readonly ["sass", "scss"];
    getExtension(): Promise<Extension>;
}

declare class SQLLanguagePlugin implements AXCodeEditorLanguagePlugin {
    readonly id = "sql";
    readonly name = "SQL";
    readonly version = "1.0.0";
    readonly languages: readonly ["sql"];
    getExtension(): Promise<Extension>;
}

declare class XMLLanguagePlugin implements AXCodeEditorLanguagePlugin {
    readonly id = "xml";
    readonly name = "XML";
    readonly version = "1.0.0";
    readonly languages: readonly ["xml"];
    getExtension(): Promise<Extension>;
}

declare class MarkdownLanguagePlugin implements AXCodeEditorLanguagePlugin {
    readonly id = "markdown";
    readonly name = "Markdown";
    readonly version = "1.0.0";
    readonly languages: readonly ["markdown"];
    getExtension(): Promise<Extension>;
}

type AXCodeEditorDefaultLanguage = 'javascript' | 'js' | 'typescript' | 'ts' | 'json' | 'html' | 'css' | 'scss' | 'sass' | 'sql' | 'xml' | 'markdown';

declare class OneDarkThemePlugin implements AXCodeEditorThemePlugin {
    readonly id = "one-dark";
    readonly name = "One Dark";
    readonly version = "1.0.0";
    readonly dark = true;
    getExtension(): Promise<Extension>;
}

declare class LightThemePlugin implements AXCodeEditorThemePlugin {
    readonly id = "light";
    readonly name = "Light";
    readonly version = "1.0.0";
    readonly dark = false;
    getExtension(): Promise<Extension>;
}

declare class GitHubLightThemePlugin implements AXCodeEditorThemePlugin {
    readonly id = "github-light";
    readonly name = "GitHub Light";
    readonly version = "1.0.0";
    readonly dark = false;
    getExtension(): Promise<Extension>;
}

declare class GitHubDarkThemePlugin implements AXCodeEditorThemePlugin {
    readonly id = "github-dark";
    readonly name = "GitHub Dark";
    readonly version = "1.0.0";
    readonly dark = true;
    getExtension(): Promise<Extension>;
}

declare class PrettierFormatterPlugin implements AXCodeEditorFormatterPlugin {
    readonly id = "prettier";
    readonly name = "Prettier";
    readonly version = "1.0.0";
    readonly languages: readonly ["javascript", "js", "typescript", "ts", "json", "html", "css", "markdown"];
    format(text: string, language: string): Promise<string | null>;
}

/**
 * Default plugin configuration with all built-in plugins
 */
declare function provideDefaultCodeEditorPlugins(): AXCodeEditorPluginConfig;

type AXCodeEditorExtensionLike = _codemirror_state.Extension;
type AXCodeEditorCompletionLike = _codemirror_autocomplete.Completion;
type AXCodeEditorCompletionSourceLike = _codemirror_autocomplete.CompletionSource;
declare class AXCodeEditorComponent extends MXValueComponent<string> {
    /** Active language identifier from default plugins. Default: 'javascript'. */
    language: _angular_core.InputSignal<AXCodeEditorDefaultLanguage>;
    /** When true, the editor becomes readonly (non-editable). */
    editorReadonly: _angular_core.InputSignal<boolean>;
    /** Placeholder text shown when the document is empty. */
    placeholder: _angular_core.InputSignal<string>;
    /** Toggle rendering of line numbers in the gutter. */
    lineNumbers: _angular_core.InputSignal<boolean>;
    /** Soft-wrap long lines when true. */
    lineWrapping: _angular_core.InputSignal<boolean>;
    /** Tab size (spaces per indent level). */
    tabSize: _angular_core.InputSignal<number>;
    /** When true, the Tab key indents instead of moving focus. */
    indentWithTab: _angular_core.InputSignal<boolean>;
    /** Theme identifier. If null, uses platform theme mode (dark/light). */
    theme: _angular_core.InputSignal<string>;
    /** Additional CodeMirror extensions to apply. Reconfigures at runtime. */
    extensions: _angular_core.InputSignal<readonly _codemirror_state.Extension[]>;
    /** ARIA label for accessibility. */
    ariaLabel: _angular_core.InputSignal<string>;
    /** Focus the editor after first render. */
    focusOnReady: _angular_core.InputSignal<boolean>;
    /** If true, format the document via Prettier before emitting save. */
    formatOnSave: _angular_core.InputSignal<boolean>;
    /** Minimum number of rows (lines) to display. Controls the minimum height of the editor. */
    minRow: _angular_core.InputSignal<number>;
    /**
     * Custom autocompletion options: either a static array of Completion items
     * or a CodeMirror CompletionSource function.
     */
    customCompletions: _angular_core.InputSignal<_codemirror_autocomplete.CompletionSource | readonly _codemirror_autocomplete.Completion[]>;
    /** Emits when the editor is fully initialized and ready. */
    ready: _angular_core.OutputEmitterRef<void>;
    /** Emits when the user triggers save (Ctrl/Cmd+S). Payload is the current text. */
    save: _angular_core.OutputEmitterRef<string>;
    host: _angular_core.Signal<ElementRef<HTMLDivElement>>;
    private platformId;
    private destroyRef;
    private platformService;
    private pluginRegistry;
    private editorViewSig;
    private languageCompartment;
    private readonlyCompartment;
    private themeCompartment;
    private placeholderCompartment;
    private wrappingCompartment;
    private keymapExtrasCompartment;
    private tabSizeCompartment;
    private lineNumbersCompartment;
    private cm;
    private isBrowser;
    /** Computed minimum height based on minRow (excluding gutter/line numbers). */
    getMinHeight(): string | null;
    constructor();
    private initializeEditor;
    private reconfigure;
    /**
     * Handles Ctrl/Cmd+S on the host. If formatOnSave is enabled, attempts
     * to format the document first, then emits the saved text.
     */
    onSaveShortcut(event: Event): Promise<void>;
    private loadCodeMirrorModules;
    private createCompartments;
    private buildKeymaps;
    private resolveThemeExtension;
    private buildCustomCompletionSources;
    /** Programmatically focus the editor. */
    focus(): void;
    /** Select all text in the current document. */
    selectAll(): void;
    format(affect?: boolean): Promise<string | null>;
    /** Returns the total number of characters in the current document. */
    getTotalCharacters(): number;
    /** Returns the total number of lines in the current document. */
    getTotalLines(): number;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXCodeEditorComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXCodeEditorComponent, "ax-code-editor", never, { "disabled": { "alias": "disabled"; "required": false; }; "value": { "alias": "value"; "required": false; }; "state": { "alias": "state"; "required": false; }; "name": { "alias": "name"; "required": false; }; "id": { "alias": "id"; "required": false; }; "language": { "alias": "language"; "required": false; "isSignal": true; }; "editorReadonly": { "alias": "readonly"; "required": false; "isSignal": true; }; "placeholder": { "alias": "placeholder"; "required": false; "isSignal": true; }; "lineNumbers": { "alias": "lineNumbers"; "required": false; "isSignal": true; }; "lineWrapping": { "alias": "lineWrapping"; "required": false; "isSignal": true; }; "tabSize": { "alias": "tabSize"; "required": false; "isSignal": true; }; "indentWithTab": { "alias": "indentWithTab"; "required": false; "isSignal": true; }; "theme": { "alias": "theme"; "required": false; "isSignal": true; }; "extensions": { "alias": "extensions"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "focusOnReady": { "alias": "focusOnReady"; "required": false; "isSignal": true; }; "formatOnSave": { "alias": "formatOnSave"; "required": false; "isSignal": true; }; "minRow": { "alias": "minRow"; "required": false; "isSignal": true; }; "customCompletions": { "alias": "customCompletions"; "required": false; "isSignal": true; }; }, { "onValueChanged": "onValueChanged"; "valueChange": "valueChange"; "stateChange": "stateChange"; "readonlyChange": "readonlyChange"; "disabledChange": "disabledChange"; "ready": "ready"; "save": "save"; }, never, ["ax-validation-rule"], true, never>;
}

declare class AXCodeEditorModule {
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXCodeEditorModule, never>;
    static ɵmod: _angular_core.ɵɵNgModuleDeclaration<AXCodeEditorModule, never, [typeof i1.CommonModule, typeof AXCodeEditorComponent], [typeof AXCodeEditorComponent]>;
    static ɵinj: _angular_core.ɵɵInjectorDeclaration<AXCodeEditorModule>;
}

export { AXCodeEditorComponent, AXCodeEditorModule, AXCodeEditorPluginRegistry, AX_CODE_EDITOR_PLUGIN_CONFIG, CSSLanguagePlugin, GitHubDarkThemePlugin, GitHubLightThemePlugin, HTMLLanguagePlugin, JSONLanguagePlugin, JavaScriptLanguagePlugin, LightThemePlugin, MarkdownLanguagePlugin, OneDarkThemePlugin, PrettierFormatterPlugin, SQLLanguagePlugin, SassLanguagePlugin, TypeScriptLanguagePlugin, XMLLanguagePlugin, provideDefaultCodeEditorPlugins };
export type { AXCodeEditorCompletionLike, AXCodeEditorCompletionSourceLike, AXCodeEditorDefaultLanguage, AXCodeEditorExtensionLike, AXCodeEditorExtensionPlugin, AXCodeEditorFormatterPlugin, AXCodeEditorLanguagePlugin, AXCodeEditorPlugin, AXCodeEditorPluginConfig, AXCodeEditorThemePlugin };
