import * as _shival99_z_ui_utils from '@shival99/z-ui/utils';
import { ZEvent, ZEmojiCategory } from '@shival99/z-ui/utils';
import * as _angular_core from '@angular/core';
import { Signal, OnInit } from '@angular/core';
import { ControlValueAccessor } from '@angular/forms';
import { ZIcon } from '@shival99/z-ui/components/z-icon';
import { ZInputValidator } from '@shival99/z-ui/components/z-input';
import { ZPopoverControl } from '@shival99/z-ui/components/z-popover';
import { Content, Editor, Extension } from '@tiptap/core';
import { ClassValue } from 'clsx';
import { LinkOptions } from '@tiptap/extension-link';
import { MentionOptions } from '@tiptap/extension-mention';
import { PlaceholderOptions } from '@tiptap/extension-placeholder';
import { StarterKitOptions } from '@tiptap/starter-kit';
import * as class_variance_authority_types from 'class-variance-authority/types';
import { VariantProps } from 'class-variance-authority';

type ZEditorSize = 'sm' | 'default' | 'lg';
type ZEditorContentType = 'html' | 'json' | 'markdown';
type ZEditorToolbarCommand = 'bold' | 'italic' | 'underline' | 'strike' | 'code' | 'blockStyle' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'small' | 'paragraph' | 'bulletList' | 'orderedList' | 'blockquote' | 'codeBlock' | 'horizontalRule' | 'link' | 'image' | 'emoji' | 'textColor' | 'backgroundColor' | 'align' | 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify' | 'undo' | 'redo' | 'clearFormatting';
interface ZEditorToolbarItem {
    id: ZEditorToolbarCommand;
    icon: ZIcon;
    label: string;
}
interface ZEditorSlashCommandItem {
    id: string;
    command: ZEditorToolbarCommand;
    icon: ZIcon;
    label: string;
    description: string;
    group: string;
    aliases: readonly string[];
}
interface ZEditorSlashCommandViewItem extends ZEditorSlashCommandItem {
    showGroupLabel: boolean;
}
interface ZEditorResolvedToolbarItem extends ZEditorToolbarItem {
    active: boolean;
    disabled: boolean;
}
interface ZEditorControl {
    /** Focus the editor */
    focus: () => void;
    /** Blur the editor */
    blur: () => void;
    /** Clear the editor content */
    clear: () => void;
    /** Set content programmatically */
    setContent: (content: Content) => void;
    /** Get current serialized content */
    getContent: () => string | Content;
    /** Get current HTML content */
    getHTML: () => string;
    /** Get current JSON content */
    getJSON: () => Content;
    /** Get current Markdown content when markdown mode is enabled */
    getMarkdown: () => string;
    /** Get plain text content */
    getText: () => string;
    /** Get content length */
    getLength: () => number;
    /** Access the TipTap editor instance */
    getEditor: () => Editor | null;
    /** Trigger validation and return true if valid */
    valid: () => boolean;
    /**
     * Trigger validation and return true if has error.
     * @deprecated Use `valid()` for boolean form-submit checks.
     */
    validate: () => boolean;
    /** Reset component to initial state */
    reset: () => void;
    /** Set value programmatically (alias for setContent) */
    setValue: (content: Content) => void;
    /** Set custom error message (useful for server-side validation). Pass null to clear. */
    setErrorMessage: (message: string | null) => void;
    /** Signal indicating if component has validation error */
    hasError: Signal<boolean>;
    /** Signal with current serialized value */
    value: Signal<string | Content>;
    /** Signal with current error message */
    errorMessage: Signal<string>;
}
interface ZEditorValidator {
    error: string;
    message: string;
    pattern?: RegExp;
    minLength?: number;
    maxLength?: number;
}
interface ZEditorPlaceholderOptions extends Partial<PlaceholderOptions> {
    mode?: 'firstLine' | 'everyLine';
}
interface ZEditorTipTapOptions {
    starterKit?: Partial<StarterKitOptions>;
    placeholder?: string | ZEditorPlaceholderOptions;
    image?: boolean | Record<string, unknown>;
    link?: Partial<LinkOptions>;
    mention?: boolean | Partial<Omit<MentionOptions, 'suggestion' | 'suggestions'>>;
    extensions?: Extension[];
}

declare class ZEditorComponent implements OnInit, ControlValueAccessor {
    private static readonly _bubbleMenuOffset;
    private readonly _injector;
    private readonly _destroyRef;
    private readonly _zTranslate;
    private readonly _editorHost;
    private readonly _floatingToolbar;
    private readonly _slashMenuTrigger;
    private readonly _linkPopoverTrigger;
    private readonly _slashMenuScrollHost;
    readonly zOnChange: _angular_core.OutputEmitterRef<Content>;
    readonly zOnFocus: _angular_core.OutputEmitterRef<FocusEvent>;
    readonly zOnBlur: _angular_core.OutputEmitterRef<FocusEvent>;
    readonly zControl: _angular_core.OutputEmitterRef<ZEditorControl>;
    readonly zEvent: _angular_core.OutputEmitterRef<ZEvent>;
    readonly class: _angular_core.InputSignal<ClassValue>;
    readonly zSize: _angular_core.InputSignal<ZEditorSize>;
    readonly zLabel: _angular_core.InputSignal<string>;
    readonly zLabelClass: _angular_core.InputSignal<string>;
    readonly zPlaceholder: _angular_core.InputSignal<string>;
    readonly zRequired: _angular_core.InputSignalWithTransform<boolean, string | boolean>;
    readonly zDisabled: _angular_core.InputSignalWithTransform<boolean, string | boolean>;
    readonly zReadonly: _angular_core.InputSignalWithTransform<boolean, string | boolean>;
    readonly zContentType: _angular_core.InputSignal<ZEditorContentType>;
    readonly zToolbar: _angular_core.InputSignal<false | readonly ZEditorToolbarItem[]>;
    readonly zTipTap: _angular_core.InputSignal<ZEditorTipTapOptions>;
    readonly zValidators: _angular_core.InputSignal<ZEditorValidator[]>;
    protected readonly editorId: string;
    protected readonly linkInputId: string;
    protected readonly _value: _angular_core.WritableSignal<Content>;
    private readonly _disabled;
    private readonly _formControl;
    private readonly _formStateVersion;
    private readonly _isNgModel;
    private readonly _selectionVersion;
    private readonly _plainText;
    protected readonly slashMenuState: _angular_core.WritableSignal<{
        visible: boolean;
        query: string;
        from: number;
        to: number;
        left: number;
        top: number;
    }>;
    protected readonly slashMenuActiveIndex: _angular_core.WritableSignal<number>;
    protected readonly linkPopoverState: _angular_core.WritableSignal<{
        visible: boolean;
        left: number;
        top: number;
        width: number;
        height: number;
    }>;
    protected readonly linkUrl: _angular_core.WritableSignal<string>;
    protected readonly activeLinkHref: _angular_core.WritableSignal<string>;
    protected readonly linkValidators: ZInputValidator[];
    protected readonly textColorSwatches: readonly string[];
    protected readonly backgroundColorSwatches: readonly string[];
    protected readonly slashCommands: readonly ZEditorSlashCommandItem[];
    protected readonly blockStyleOptions: readonly {
        command: Extract<ZEditorToolbarCommand, 'paragraph' | 'heading1' | 'heading2' | 'heading3' | 'heading4'>;
        icon: ZEditorToolbarItem['icon'];
        label: string;
    }[];
    protected readonly alignOptions: readonly {
        command: Extract<ZEditorToolbarCommand, 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify'>;
        icon: ZEditorToolbarItem['icon'];
        label: string;
    }[];
    private readonly _toolbarShortcutLabels;
    protected readonly uiState: _angular_core.WritableSignal<{
        touched: boolean;
        dirty: boolean;
    }>;
    private readonly _customError;
    private _onChange;
    private _onTouched;
    private _ngControl;
    private _editor;
    private _pendingValue;
    private _linkSelection;
    private _linkAnchorElement;
    private _emojiPopoverControl;
    private _blockStylePopoverControl;
    private _alignPopoverControl;
    private _textColorPopoverControl;
    private _backgroundColorPopoverControl;
    private _slashMenuPopoverControl;
    private _dismissedSlashMenu;
    private _linkPopoverControl;
    private _resizeObserver;
    private _resizeListenerCleanup;
    private _bubbleMenuPositionFrame;
    protected readonly emojiCategories: readonly (Omit<ZEmojiCategory, "icon"> & {
        icon: ZIcon;
    })[];
    protected readonly activeEmojiCategoryId: _angular_core.WritableSignal<string>;
    protected readonly emojiSearch: _angular_core.WritableSignal<string>;
    protected readonly activeEmojiCategory: _angular_core.Signal<Omit<ZEmojiCategory, "icon"> & {
        icon: ZIcon;
    }>;
    protected readonly activeEmojiCategoryLabel: _angular_core.Signal<string>;
    protected readonly emojiSearchQuery: _angular_core.Signal<string>;
    protected readonly activeEmojis: _angular_core.Signal<readonly (string | _shival99_z_ui_utils.ZEmojiEntry)[]>;
    protected readonly hasEmojiResults: _angular_core.Signal<boolean>;
    protected readonly isDisabled: _angular_core.Signal<boolean>;
    protected readonly showToolbar: _angular_core.Signal<boolean>;
    protected readonly normalizedLinkUrl: _angular_core.Signal<string>;
    protected readonly activeTextColor: _angular_core.Signal<string>;
    protected readonly activeBackgroundColor: _angular_core.Signal<string>;
    protected readonly activeBlockStyle: _angular_core.Signal<"heading1" | "heading2" | "heading3" | "heading4" | "paragraph">;
    protected readonly activeBlockStyleLabel: _angular_core.Signal<string>;
    protected readonly activeAlign: _angular_core.Signal<"alignLeft" | "alignCenter" | "alignRight" | "alignJustify">;
    protected readonly activeAlignLabel: _angular_core.Signal<string>;
    protected readonly activeAlignIcon: _angular_core.Signal<ZIcon>;
    protected readonly filteredSlashCommands: _angular_core.Signal<ZEditorSlashCommandViewItem[]>;
    protected readonly canApplyLink: _angular_core.Signal<boolean>;
    protected readonly effectivePlaceholder: _angular_core.Signal<string>;
    protected readonly toolbarItems: _angular_core.Signal<ZEditorResolvedToolbarItem[]>;
    protected readonly floatingToolbarItems: _angular_core.Signal<(ZEditorResolvedToolbarItem & {
        shortcut: string;
        tooltip: string;
    })[]>;
    private readonly _shouldShowValidation;
    private _getValidationErrors;
    protected readonly hasError: _angular_core.Signal<boolean>;
    protected readonly errorMessage: _angular_core.Signal<string>;
    protected readonly currentStatus: _angular_core.Signal<"default" | "disabled" | "readonly" | "error">;
    protected readonly wrapperClasses: _angular_core.Signal<string>;
    protected readonly editorClasses: _angular_core.Signal<string>;
    constructor();
    ngOnInit(): void;
    writeValue(value: string | Content): void;
    registerOnChange(fn: (value: string | Content) => void): void;
    registerOnTouched(fn: () => void): void;
    setDisabledState(isDisabled: boolean): void;
    protected onToolbarClick(command: ZEditorToolbarCommand): void;
    private _createEditor;
    private _handleEditorUpdate;
    private _handleFocus;
    private _handleBlur;
    private _emitControl;
    private _setEditorContent;
    private _validateControl;
    private _getSerializedContent;
    private _getMarkdown;
    private _serializeValueAsText;
    private _refreshEditorState;
    private _searchEmojis;
    private _setupBubbleMenuPositionUpdates;
    private _listenWindowResize;
    private _teardownBubbleMenuPositionUpdates;
    private _requestBubbleMenuPositionUpdate;
    private _isAnyBubbleMenuPopoverOpen;
    private _syncLinkPopoverPosition;
    private _getSelectionFloatingElement;
    private _getFrozenBubbleMenuReferenceRect;
    private _createVirtualElement;
    private _isEditorEmpty;
    private _isCurrentEditorContent;
    private _isToolbarCommandActive;
    private _isToolbarCommandDisabled;
    protected onFloatingToolbarClick(command: ZEditorToolbarCommand): void;
    private _getToolbarTooltip;
    protected applySlashCommand(item: ZEditorSlashCommandItem): void;
    protected applyBlockStyle(command: Extract<ZEditorToolbarCommand, 'paragraph' | 'heading1' | 'heading2' | 'heading3' | 'heading4'>, closePopover?: () => void): void;
    protected applyAlign(command: Extract<ZEditorToolbarCommand, 'alignLeft' | 'alignCenter' | 'alignRight' | 'alignJustify'>, closePopover?: () => void): void;
    protected insertEmoji(emoji: string): void;
    protected setEmojiCategory(categoryId: string): void;
    protected onEmojiPopoverControl(control: ZPopoverControl): void;
    protected onEmojiPopoverShow(): void;
    protected onBlockStylePopoverControl(control: ZPopoverControl): void;
    protected onAlignPopoverControl(control: ZPopoverControl): void;
    protected onTextColorPopoverControl(control: ZPopoverControl): void;
    protected onBackgroundColorPopoverControl(control: ZPopoverControl): void;
    protected onSlashMenuPopoverControl(control: ZPopoverControl): void;
    protected onSlashMenuPopoverHide(): void;
    protected onLinkPopoverControl(control: ZPopoverControl): void;
    protected onLinkPopoverHide(): void;
    protected onFloatingPopoverHide(): void;
    protected setTextColor(color: string, closePopover?: () => void): void;
    protected setTextColorFromEvent(event: Event, closePopover?: () => void): void;
    protected unsetTextColor(closePopover?: () => void): void;
    protected setBackgroundColor(color: string, closePopover?: () => void): void;
    protected setBackgroundColorFromEvent(event: Event, closePopover?: () => void): void;
    protected unsetBackgroundColor(closePopover?: () => void): void;
    private _closePopover;
    private _handleSlashMenuKeyDown;
    private _handleEditorShortcutKeyDown;
    private _getShortcutCommand;
    private _isPrimaryShortcut;
    private _syncSlashMenu;
    private _scrollActiveSlashMenuItemIntoView;
    private _hideSlashMenu;
    private _dismissCurrentSlashMenu;
    private _getCurrentSlashMenuMatch;
    private _isDismissedSlashStillPresent;
    private _toggleLink;
    protected closeLinkPopover(): void;
    protected onLinkUrlChange(value: string | number | null): void;
    protected applyLink(): void;
    private _normalizeUrl;
    protected removeLink(): void;
    protected openActiveLink(): void;
    private _handleEditorClick;
    private _showLinkPopover;
    private _alignFixedTrigger;
    private _getLinkPopoverReferenceRect;
    private _getLinkAnchorRect;
    private _insertImage;
    private _setTextAlign;
    private _collapseSelectionToAnchor;
    private _getTextStyleAttribute;
    private _getActiveBlockStyle;
    private _getActiveAlign;
    private _getActiveAlignFromEditor;
    private _createImageExtension;
    private static _getImageAlignStyle;
    private _placeholderConfig;
    private _placeholderMode;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<ZEditorComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<ZEditorComponent, "z-editor", ["zEditor"], { "class": { "alias": "class"; "required": false; "isSignal": true; }; "zSize": { "alias": "zSize"; "required": false; "isSignal": true; }; "zLabel": { "alias": "zLabel"; "required": false; "isSignal": true; }; "zLabelClass": { "alias": "zLabelClass"; "required": false; "isSignal": true; }; "zPlaceholder": { "alias": "zPlaceholder"; "required": false; "isSignal": true; }; "zRequired": { "alias": "zRequired"; "required": false; "isSignal": true; }; "zDisabled": { "alias": "zDisabled"; "required": false; "isSignal": true; }; "zReadonly": { "alias": "zReadonly"; "required": false; "isSignal": true; }; "zContentType": { "alias": "zContentType"; "required": false; "isSignal": true; }; "zToolbar": { "alias": "zToolbar"; "required": false; "isSignal": true; }; "zTipTap": { "alias": "zTipTap"; "required": false; "isSignal": true; }; "zValidators": { "alias": "zValidators"; "required": false; "isSignal": true; }; }, { "zOnChange": "zOnChange"; "zOnFocus": "zOnFocus"; "zOnBlur": "zOnBlur"; "zControl": "zControl"; "zEvent": "zEvent"; }, never, never, true, never>;
}

declare const Z_EDITOR_DEFAULT_TOOLBAR: readonly ZEditorToolbarItem[];

declare const zEditorVariants: (props?: ({
    zSize?: "sm" | "default" | "lg" | null | undefined;
    zStatus?: "default" | "error" | "disabled" | "readonly" | null | undefined;
    zPlaceholderMode?: "firstLine" | "everyLine" | null | undefined;
} & class_variance_authority_types.ClassProp) | undefined) => string;
type ZEditorVariants = VariantProps<typeof zEditorVariants>;

export { ZEditorComponent, Z_EDITOR_DEFAULT_TOOLBAR, zEditorVariants };
export type { ZEditorContentType, ZEditorControl, ZEditorResolvedToolbarItem, ZEditorSize, ZEditorTipTapOptions, ZEditorToolbarCommand, ZEditorToolbarItem, ZEditorValidator, ZEditorVariants };
