import * as _angular_core from '@angular/core';
import { OnDestroy, QueryList } from '@angular/core';
import * as i1 from '@angular/common';
import { NXEvent, NXComponent } from '@acorex/cdk/common';
import { Subscription } from 'rxjs';
import * as gridstack from 'gridstack';

interface AXGridLayoutPosition {
    /** widget position x (default?: 0) */
    x?: number;
    /** widget position y (default?: 0) */
    y?: number;
    /** widget dimension width (default?: 1) */
    width?: number;
    /** widget dimension height (default?: 1) */
    height?: number;
    /** maximum width of widget in columns (default?: undefined = un-constrained) */
    maxWidth?: number;
    /** maximum height of widget in rows (default?: undefined = un-constrained) */
    maxHeight?: number;
    /** minimum width of widget in columns (default?: undefined = un-constrained) */
    minWidth?: number;
    /** minimum height of widget in rows (default?: undefined = un-constrained) */
    minHeight?: number;
}
interface AXGridLayoutWidget extends AXGridLayoutPosition {
    id?: string;
    /** prevent direct resizing by the user (default?: undefined = un-constrained) */
    disableResize?: boolean;
    /** prevents direct moving by the user (default?: undefined = un-constrained) */
    disableDrag?: boolean;
}
interface AXGridLayoutNode extends AXGridLayoutWidget {
    element?: AXGridLayoutWidgetElement;
}
type AXGridLayout = gridstack.GridStack;
interface AXGridLayoutOptions {
    /** number of columns (default?: 12)
     * Note: for nested grids, it is recommended to use 'auto' which will always match the container grid-item current width (in column) to keep inside and outside
     * items always to same. flag is not supported for regular non-nested grids.
     */
    column?: number | 'auto';
    /** disallows dragging of widgets (default?: false) */
    disableDrag?: boolean;
    /** disallows resizing of widgets (default?: false). */
    disableResize?: boolean;
    /**
     * gap between grid item and content (default?: 10). This will set all 4 sides and support the CSS formats below
     *  an integer (px)
     *  a string with possible units (ex: '2em', '20px', '2rem')
     *  string with space separated values (ex: '5px 10px 0 20px' for all 4 sides, or '5em 10em' for top/bottom and left/right pairs like CSS).
     * Note: all sides must have same units (last one wins, default px)
     */
    gap?: number | string;
    /**
     * one cell height (default?: 'auto'). Can be:
     *  an integer (px)
     *  a string (ex: '100px', '10em', '10rem'). Note: % doesn't work right - see demo/cell-height.html
     *  0, in which case the library will not generate styles for rows. Everything must be defined in your own CSS files.
     *  'auto' - height will be calculated for square cells (width / column) and updated live as you resize the window - also see `cellHeightThrottle`
     *  'initial' - similar to 'auto' (start at square cells) but stay that size during window resizing.
     */
    cellHeight?: number | string;
    /**
     * if true turns grid to RTL. Possible values are true, false, 'auto' (default?: 'auto')
     */
    rtl?: boolean | 'auto';
    /** maximum rows amount. Default? is 0 which means no maximum rows */
    maxRow?: number;
    /** minimum rows amount. Default is `0`. You can also do this with `min-height` CSS attribute
     * on the grid div in pixels, which will round to the closest row.
     */
    minRow?: number;
    /** fix grid number of rows. This is a shortcut of writing `minRow:N, maxRow:N`. (default `0` no constrain) */
    row?: number;
    /**
     * if true widgets could be removed by dragging outside of the grid. It could also be a selector string (ex: ".trash"),
     * in this case widgets will be removed by dropping them there (default?: false)
     */
    removableSelector?: string;
    /** does it has option to remove widgets */
    /** does it has option to remove widgets */
    removable?: boolean;
    /**
     * accept widgets dragged from other grids or from outside (default: `false`). Can be: `true` or `false`,
     */
    acceptWidgets?: boolean;
    /** enable floating widgets (default?: false) */
    float?: boolean;
    /** draggable handle selector (default?: '.grid-stack-item-content') */
    dragHandlerSelector?: string;
    /** responsive column layout for width:column behavior */
    responsiveLayout?: {
        /** <= width for the breakpoint to trigger */
        width?: number;
        /** column count */
        column: number;
    }[];
}
interface AXGridLayoutContainerElement extends HTMLElement {
    gridstack?: AXGridLayout;
}
interface AXGridLayoutWidgetElement extends HTMLElement {
    gridstackNode?: AXGridLayoutNode;
}
interface AXGridLayoutEvent extends NXEvent<AXGridLayoutContainerComponent> {
    nodes: AXGridLayoutNode[];
}

declare class AXGridLayoutWidgetComponent {
    #private;
    private readonly elementRef;
    options: _angular_core.InputSignal<AXGridLayoutNode>;
    /**
     * Locks or unlocks the widget (prevents dragging and resizing).
     *
     * @param state - If true, the widget will be locked.
     * @returns void - No return value. The widget lock state is updated.
     */
    setLockable(state: boolean): void;
    /**
     * Enables or disables resizing of the widget.
     *
     * @param state - If true, resizing will be enabled.
     * @returns void - No return value. The widget resize state is updated.
     */
    setResizable(state: boolean): void;
    /**
     * Updates the widget options.
     *
     * @param options - The new options for the widget.
     * @returns void - No return value. The widget options are updated.
     */
    setOptions(options: AXGridLayoutWidget): void;
    /**
     * Returns the current options of the widget.
     *
     * @returns AXGridLayoutNode - The current widget options.
     */
    getOptions(): AXGridLayoutNode;
    /**
     * Returns the widget options from the Angular input binding (stored/desired positions),
     * bypassing the live gridstackNode which may have been auto-reflowed.
     * Used by the container to load correct per-breakpoint layouts after column changes.
     *
     * @returns AXGridLayoutNode - The widget options from the input signal.
     */
    getInputOptions(): AXGridLayoutNode;
    /**
     * Returns the native DOM element of the widget.
     *
     * @returns AXGridLayoutWidgetElement - The native element.
     */
    get element(): AXGridLayoutWidgetElement;
    /**
     * Updates the widget options and triggers a grid update.
     * @param options - The partial options to update.
     */
    private updateWidgetOptions;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXGridLayoutWidgetComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXGridLayoutWidgetComponent, "ax-grid-layout-widget", never, { "options": { "alias": "options"; "required": false; "isSignal": true; }; }, {}, never, ["*"], true, never>;
}

declare class AXGridLayoutContainerComponent extends NXComponent implements OnDestroy {
    #private;
    options: _angular_core.InputSignal<AXGridLayoutOptions>;
    protected onAdded: _angular_core.OutputEmitterRef<AXGridLayoutEvent>;
    protected onRemoved: _angular_core.OutputEmitterRef<AXGridLayoutEvent>;
    protected onWidgetChange: _angular_core.OutputEmitterRef<AXGridLayoutEvent>;
    protected onChange: _angular_core.OutputEmitterRef<AXGridLayoutEvent>;
    protected onRender: _angular_core.OutputEmitterRef<void>;
    protected isEmpty: _angular_core.ModelSignal<boolean>;
    private readonly elementRef;
    private readonly ngZone;
    gridstackItems?: QueryList<AXGridLayoutWidgetComponent>;
    private el;
    private grid?;
    protected _sub: Subscription | undefined;
    private isInitialized;
    ngOnDestroy(): void;
    /**
     * Synchronizes the grid layout with the current widget list.
     *
     * @param useInputValues - When true, reads positions from Angular input bindings
     * (stored per-breakpoint positions). When false, reads from live gridstackNode
     * (preserving user drag/resize state). Use true after column/breakpoint changes.
     */
    private updateAll;
    private checkEmpty;
    private hookEvents;
    private unhookEvents;
    private _dispatchChangeEvent;
    /**
     * Adds a widget to the grid layout.
     *
     * @param w - Widget configuration object.
     * @param withAutoArrange - Whether to compact the grid before adding the widget.
     * @returns AXGridLayoutWidgetElement | undefined - The created widget element or undefined if failed.
     */
    addWidget(w: AXGridLayoutWidget, withAutoArrange?: boolean): AXGridLayoutWidgetElement | undefined;
    /**
     * Compacts the grid layout.
     *
     * @param layout - Layout type for compacting ('list' or 'compact').
     * @param doSort - Whether to sort items while compacting.
     * @returns void - No return value. The grid layout is compacted.
     */
    compact(layout?: 'list' | 'compact', doSort?: boolean): void;
    /**
     * Sets the cell height of the grid.
     *
     * @param val - New cell height value.
     * @param update - Whether to update the grid immediately.
     * @returns void - No return value. The cell height is updated.
     */
    setCellHeight(val: number): void;
    /**
     * Sets the number of columns in the grid.
     *
     * @param column - Number of columns.
     * @param layout - Layout type for the change ('list', 'compact', 'moveScale', 'move', 'scale', or 'none').
     * @returns void - No return value. The column count is updated.
     */
    setColumn(column: number, layout?: 'list' | 'compact' | 'moveScale' | 'move' | 'scale' | 'none'): void;
    /**
     * Destroys the grid instance.
     *
     * @param removeDOM - Whether to remove DOM elements.
     * @returns void - No return value. The grid instance is destroyed.
     */
    destroy(removeDOM?: boolean): void;
    /**
     * Enables or disables moving of widgets.
     *
     * @param state - Whether to enable moving.
     * @param recurse - Whether to apply to all child widgets.
     * @returns void - No return value. The move state is updated.
     */
    setMovable(state: boolean, recurse?: boolean): void;
    /**
     * Enables or disables resizing of widgets.
     *
     * @param state - Whether to enable resizing.
     * @param recurse - Whether to apply to all child widgets.
     * @returns void - No return value. The resize state is updated.
     */
    setResizable(state: boolean, recurse?: boolean): void;
    /**
     * Sets the float property of the grid.
     *
     * @param val - Whether to enable floating widgets.
     * @returns void - No return value. The float state is updated.
     */
    setFloat(val: boolean): void;
    /**
     * Sets the margin between grid items.
     *
     * @param value - Margin value (number in pixels or string with units).
     * @returns void - No return value. The margin is updated.
     */
    setMargin(value: number | string): void;
    /**
     * Removes a specific widget from the grid.
     *
     * @param el - The widget element to remove.
     * @param removeDOM - Whether to remove the DOM element.
     * @param triggerEvent - Whether to trigger removal events.
     * @returns void - No return value. The widget is removed.
     */
    removeWidget(el: AXGridLayoutWidgetElement, removeDOM?: boolean, triggerEvent?: boolean): void;
    /**
     * Removes all widgets from the grid.
     *
     * @param removeDOM - Whether to remove DOM elements.
     * @returns void - No return value. All widgets are removed.
     */
    removeAll(removeDOM?: boolean): void;
    /**
     * Sets the animation state for the grid.
     *
     * @param doAnimate - Whether to enable animations.
     * @returns void - No return value. The animation state is updated.
     */
    setAnimation(doAnimate: boolean): void;
    /**
     * Sets up draggable functionality for external elements.
     *
     * @param dragIn - CSS selector string or array of HTML elements to make draggable.
     * @param widgets - Optional widget configuration for dragged items.
     * @returns Promise<void> - Promise that resolves when drag setup is complete.
     */
    setupDraggable(dragIn?: string | HTMLElement[], widgets?: AXGridLayoutWidget): Promise<void>;
    /**
     * Gets the current grid options.
     *
     * @returns AXGridLayoutOptions - Current grid configuration options.
     */
    getOptions(): AXGridLayoutOptions;
    /**
     * Gets all child widgets in the grid.
     *
     * @returns AXGridLayoutNode[] - Array of all child widget nodes.
     */
    getChildren(): AXGridLayoutNode[];
    /**
     * Finds an empty space in the grid for a widget.
     *
     * @param input - Dimensions of the widget with height and width.
     * @returns { x: number; y: number } - Object containing x and y coordinates of empty space.
     */
    findEmptySpace(input: Required<Pick<AXGridLayoutPosition, 'height' | 'width'>>): Pick<AXGridLayoutPosition, 'x' | 'y'>;
    static ɵfac: _angular_core.ɵɵFactoryDeclaration<AXGridLayoutContainerComponent, never>;
    static ɵcmp: _angular_core.ɵɵComponentDeclaration<AXGridLayoutContainerComponent, "ax-grid-layout-container", never, { "options": { "alias": "options"; "required": false; "isSignal": true; }; "isEmpty": { "alias": "isEmpty"; "required": false; "isSignal": true; }; }, { "onAdded": "onAdded"; "onRemoved": "onRemoved"; "onWidgetChange": "onWidgetChange"; "onChange": "onChange"; "onRender": "onRender"; "isEmpty": "isEmptyChange"; }, ["gridstackItems"], ["*"], true, never>;
}

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

export { AXGridLayoutBuilderModule, AXGridLayoutContainerComponent, AXGridLayoutWidgetComponent };
export type { AXGridLayout, AXGridLayoutContainerElement, AXGridLayoutEvent, AXGridLayoutNode, AXGridLayoutOptions, AXGridLayoutPosition, AXGridLayoutWidget, AXGridLayoutWidgetElement };
