import { default as default_2 } from 'react';
import { NiceBaseProps } from '@nice2dev/ui-core';

declare interface ActionParam {
    id: string;
    name: string;
    type: FieldType;
    required?: boolean;
}

declare interface APIEndpoint {
    id: string;
    name: string;
    description?: string;
    method: HTTPMethod;
    path: string;
    tags?: string[];
    pathParams?: ParamDefinition[];
    queryParams?: ParamDefinition[];
    headers?: ParamDefinition[];
    body?: BodyDefinition;
    responses: ResponseDefinition[];
    retry?: RetryConfig;
    cache?: EndpointCacheConfig;
    timeout?: number;
    mock?: MockResponse;
}

declare interface APIFlowDefinition {
    id: string;
    name: string;
    description?: string;
    baseUrl: string;
    version?: string;
    endpoints: APIEndpoint[];
    auth?: AuthConfig;
    globalHeaders?: Record<string, string>;
    errorHandling?: ErrorHandlingConfig;
    cacheConfig?: CacheConfig;
}

declare interface Assertion {
    matcher: AssertionMatcher;
    expected?: unknown;
    not?: boolean;
}

declare type AssertionMatcher = 'toEqual' | 'toBe' | 'toBeTruthy' | 'toBeFalsy' | 'toBeNull' | 'toBeUndefined' | 'toContain' | 'toHaveLength' | 'toBeInTheDocument' | 'toHaveTextContent' | 'toHaveAttribute' | 'toHaveClass' | 'toHaveStyle' | 'toHaveBeenCalled' | 'toHaveBeenCalledWith' | 'toHaveBeenCalledTimes' | 'toThrow' | 'toMatchSnapshot';

declare interface AuthConfig {
    type: 'none' | 'bearer' | 'basic' | 'api-key' | 'oauth2';
    tokenSource?: string;
    headerName?: string;
    prefix?: string;
}

declare interface BodyDefinition {
    contentType: 'application/json' | 'multipart/form-data' | 'application/x-www-form-urlencoded' | 'text/plain';
    schema?: SchemaDefinition;
}

declare interface CacheConfig {
    enabled: boolean;
    storage: 'memory' | 'localStorage' | 'sessionStorage';
    defaultTTL: number;
}

declare interface CodeTemplate {
    id: string;
    name: string;
    description: string;
    category: string;
    icon?: string;
    engine: TemplateEngine;
    variables: TemplateVariable[];
    files: TemplateFile[];
    hooks?: {
        beforeGenerate?: string;
        afterGenerate?: string;
    };
    metadata?: {
        author?: string;
        version?: string;
        tags?: string[];
        framework?: string;
    };
}

declare interface ComponentDefinition {
    id: string;
    name: string;
    category: string;
    icon?: string;
    defaultProps?: Record<string, unknown>;
}

declare interface ComponentInstance {
    id: string;
    type: string;
    props: Record<string, unknown>;
    children?: ComponentInstance[];
}

declare interface ComponentSchema {
    name: string;
    displayName?: string;
    description?: string;
    props: PropDefinition[];
    state?: StateDefinition[];
    hooks?: string[];
    children?: 'none' | 'single' | 'multiple';
}

declare interface ComputedField {
    id: string;
    name: string;
    expression: string;
    dependencies: string[];
}

declare interface ConfigField {
    name: string;
    label: string;
    type: 'string' | 'number' | 'boolean' | 'select' | 'code' | 'json';
    options?: {
        value: string;
        label: string;
    }[];
    required?: boolean;
    default?: unknown;
}

declare interface ConfigField_2 {
    name: string;
    label: string;
    type: 'string' | 'number' | 'boolean' | 'select' | 'code' | 'json';
    options?: {
        value: string;
        label: string;
    }[];
    required?: boolean;
    default?: unknown;
}

declare interface DataSource {
    id: string;
    name: string;
    type: 'state' | 'prop' | 'context' | 'constant';
    path: string;
}

declare type DataType = 'string' | 'number' | 'boolean' | 'date' | 'array' | 'object' | 'any';

declare interface DesignState {
    components: ComponentInstance[];
    layout: LayoutConfig;
    styles: Record<string, unknown>;
}

declare interface DevToolsConfig {
    enabled: boolean;
    name?: string;
    anonymousActionType?: string;
    trace?: boolean;
}

declare interface DraggableComponent {
    id: string;
    name: string;
    icon?: string;
    category: string;
}

declare interface EndpointCacheConfig {
    enabled: boolean;
    ttl: number;
    strategy: 'cache-first' | 'network-first' | 'stale-while-revalidate';
}

declare interface ErrorHandlingConfig {
    globalErrorHandler?: boolean;
    retryOnNetworkError?: boolean;
    transformError?: boolean;
}

declare interface EventCondition {
    field: string;
    operator: 'eq' | 'neq' | 'gt' | 'lt' | 'gte' | 'lte' | 'contains' | 'exists';
    value: unknown;
}

declare interface EventFilter {
    field?: string;
    value?: unknown;
    expression?: string;
}

declare interface EventFlow {
    id: string;
    name: string;
    description?: string;
    enabled: boolean;
    source: EventSource_2;
    handlers: EventHandler[];
    errorHandler?: EventHandler;
}

declare interface EventHandler {
    id: string;
    type: EventHandlerType;
    config: Record<string, unknown>;
    modifiers?: EventModifier[];
    condition?: EventCondition;
    next?: string;
}

declare interface EventHandlerDefinition {
    type: EventHandlerType;
    label: string;
    icon: string;
    color: string;
    configSchema: ConfigField[];
}

declare type EventHandlerType = 'action' | 'transform' | 'dispatch' | 'api-call' | 'state-update' | 'notification' | 'log' | 'delay' | 'branch';

declare interface EventModifier {
    type: 'debounce' | 'throttle' | 'delay' | 'retry' | 'once';
    value: number;
    unit?: 'ms' | 's';
}

declare interface EventSource_2 {
    id: string;
    type: EventSourceType;
    config: Record<string, unknown>;
    filter?: EventFilter;
}

declare interface EventSourceDefinition {
    type: EventSourceType;
    label: string;
    icon: string;
    color: string;
    configSchema: ConfigField[];
}

declare type EventSourceType = 'ui-event' | 'api-response' | 'websocket' | 'timer' | 'custom' | 'state-change' | 'broadcast';

declare interface ExpectedResult {
    type: 'value' | 'element' | 'state' | 'call' | 'error' | 'snapshot';
    assertion: Assertion;
}

declare type ExportFormat = 'zustand' | 'redux-toolkit' | 'jotai' | 'recoil' | 'mobx';

declare interface FieldDefinition {
    id: string;
    name: string;
    path: string;
    type: DataType;
    nullable?: boolean;
    children?: FieldDefinition[];
    description?: string;
}

declare interface FieldMapping {
    id: string;
    sourceField: string;
    targetField: string;
    transform?: string;
    condition?: string;
    defaultValue?: unknown;
}

declare type FieldType = 'string' | 'number' | 'boolean' | 'array' | 'object' | 'date' | 'enum' | 'custom';

declare interface FrameworkPreset {
    id: string;
    name: string;
    icon: string;
    description: string;
    templates: CodeTemplate[];
}

declare interface GeneratedFile {
    path: string;
    content: string;
    language?: string;
}

declare interface GridSettings {
    columns: number;
    gap: number;
    padding: number;
}

declare type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';

declare interface LayoutColumn {
    id: string;
    width: number;
    components: PlacedComponent[];
}

declare interface LayoutConfig {
    type: 'flex' | 'grid' | 'absolute';
    direction?: 'row' | 'column';
    gap?: number;
}

declare interface LayoutRow {
    id: string;
    columns: LayoutColumn[];
    height?: string;
}

declare interface MappingDefinition {
    id: string;
    name: string;
    description?: string;
    sourceSchema: SchemaDefinition_2;
    targetSchema: SchemaDefinition_2;
    fieldMappings: FieldMapping[];
    transformations: Transformation[];
    validationRules: ValidationRule_2[];
}

declare interface MiddlewareConfig {
    type: 'logger' | 'persist' | 'devtools' | 'immer' | 'custom';
    enabled: boolean;
    options?: Record<string, unknown>;
}

declare interface MockConfig {
    name: string;
    type: MockType;
    implementation?: string;
    returnValue?: unknown;
}

declare interface MockDefinition {
    name: string;
    type: MockType;
    description?: string;
    configSchema?: ConfigField_2[];
}

declare interface MockResponse {
    enabled: boolean;
    delay?: number;
    status?: number;
    body?: unknown;
}

declare type MockType = 'function' | 'module' | 'api' | 'timer' | 'storage';

export declare const NiceAPIFlow: default_2.FC<NiceAPIFlowProps>;

export declare interface NiceAPIFlowProps extends NiceBaseProps {
    /** API flow definition */
    flow?: APIFlowDefinition;
    /** Available data sources */
    dataSources?: DataSource[];
    onFlowChange?: (flow: APIFlowDefinition) => void;
    onExport?: (code: string) => void;
    onTest?: (endpointId: string) => void;
    onSave?: (flow: APIFlowDefinition) => void;
}

/**
 * NiceCodePreview - Live code preview with syntax highlighting and diff
 *
 * Features:
 * - Syntax highlighting for multiple languages
 * - Line numbers
 * - Live preview for React/HTML
 * - Side-by-side diff view
 * - Copy to clipboard
 */
export declare const NiceCodePreview: default_2.FC<NiceCodePreviewProps>;

export declare interface NiceCodePreviewProps {
    /** Code to display */
    code: string;
    /** Programming language */
    language?: string;
    /** Show line numbers */
    lineNumbers?: boolean;
    /** Enable live preview (for React/HTML) */
    livePreview?: boolean;
    /** Show diff view */
    showDiff?: boolean;
    /** Previous code for diff comparison */
    previousCode?: string;
    /** Theme */
    theme?: 'light' | 'dark';
    /** Copy to clipboard enabled */
    copyable?: boolean;
    /** Called when code is copied */
    onCopy?: () => void;
    /** Additional class name */
    className?: string;
}

export declare const NiceCodeTemplate: default_2.FC<NiceCodeTemplateProps>;

export declare interface NiceCodeTemplateProps extends NiceBaseProps {
    /** Available templates */
    templates: CodeTemplate[];
    /** Framework presets */
    presets?: FrameworkPreset[];
    /** Currently selected template */
    selectedTemplate?: string;
    /** Template engine */
    defaultEngine?: TemplateEngine;
    /** Show template library */
    showLibrary?: boolean;
    onTemplateSelect?: (template: CodeTemplate) => void;
    onTemplateCreate?: (template: CodeTemplate) => void;
    onTemplateUpdate?: (template: CodeTemplate) => void;
    onTemplateDelete?: (templateId: string) => void;
    onGenerate?: (files: GeneratedFile[], variables: Record<string, unknown>) => void;
    onExport?: (template: CodeTemplate, format: 'json' | 'zip') => void;
    onImport?: (template: CodeTemplate) => void;
}

/**
 * NiceComponentDesigner - Visual React component designer
 *
 * Features:
 * - Define props with types and defaults
 * - Configure component state
 * - Add React hooks
 * - Set children behavior
 */
export declare const NiceComponentDesigner: default_2.FC<NiceComponentDesignerProps>;

export declare interface NiceComponentDesignerProps {
    /** Component being edited */
    component?: ComponentSchema;
    /** Available props types */
    propTypes?: PropTypeDefinition[];
    /** Called when component changes */
    onChange?: (component: ComponentSchema) => void;
    /** Theme */
    theme?: 'light' | 'dark';
    /** Additional class name */
    className?: string;
}

export declare const NiceDataMapper: default_2.FC<NiceDataMapperProps>;

export declare interface NiceDataMapperProps extends NiceBaseProps {
    /** Mapping definition */
    mapping?: MappingDefinition;
    /** Available source schemas */
    sourceSchemas?: SchemaInfo[];
    /** Available target schemas */
    targetSchemas?: SchemaInfo[];
    onMappingChange?: (mapping: MappingDefinition) => void;
    onExport?: (code: string) => void;
    onTest?: (input: unknown) => void;
    onSave?: (mapping: MappingDefinition) => void;
}

export declare const NiceEventOrchestrator: default_2.FC<NiceEventOrchestratorProps>;

export declare interface NiceEventOrchestratorProps extends NiceBaseProps {
    /** Initial event flows */
    flows?: EventFlow[];
    /** Available event sources */
    eventSources?: EventSourceDefinition[];
    /** Available event handlers */
    eventHandlers?: EventHandlerDefinition[];
    onFlowsChange?: (flows: EventFlow[]) => void;
    onExport?: (code: string) => void;
    onTest?: (flowId: string) => void;
}

/**
 * NiceLowCodeStudio - Visual no-code development environment
 *
 * Central hub integrating all no-code tools:
 * - Component Designer
 * - Page Builder
 * - State Designer
 * - API Flow
 * - Event Orchestrator
 */
export declare const NiceLowCodeStudio: default_2.FC<NiceLowCodeStudioProps>;

export declare interface NiceLowCodeStudioProps {
    /** Current project identifier */
    projectId?: string;
    /** Available components palette */
    components?: ComponentDefinition[];
    /** Theme configuration */
    theme?: 'light' | 'dark';
    /** Called when design changes */
    onChange?: (design: DesignState) => void;
    /** Called when save is requested */
    onSave?: (design: DesignState) => void;
    /** Additional class name */
    className?: string;
}

/**
 * NicePageBuilder - Drag-drop page builder with responsive layouts
 *
 * Features:
 * - Drag-drop component placement
 * - Responsive 12-column grid
 * - Desktop/tablet/mobile preview
 * - Component property editing
 */
export declare const NicePageBuilder: default_2.FC<NicePageBuilderProps>;

export declare interface NicePageBuilderProps {
    /** Initial page layout */
    initialLayout?: PageLayout;
    /** Available components for drag-drop */
    components?: DraggableComponent[];
    /** Grid settings */
    grid?: GridSettings;
    /** Called when layout changes */
    onChange?: (layout: PageLayout) => void;
    /** Called on save */
    onSave?: (layout: PageLayout) => void;
    /** Theme */
    theme?: 'light' | 'dark';
    /** Responsive preview mode */
    previewMode?: 'desktop' | 'tablet' | 'mobile';
    /** Additional class name */
    className?: string;
}

export declare const NiceStateDesigner: default_2.FC<NiceStateDesignerProps>;

export declare interface NiceStateDesignerProps extends NiceBaseProps {
    /** Initial store definition */
    store?: StoreDefinition;
    /** Available state templates */
    templates?: StoreTemplate[];
    onStoreChange?: (store: StoreDefinition) => void;
    onExport?: (code: string, format: ExportFormat) => void;
    onSave?: (store: StoreDefinition) => void;
}

export declare const NiceTestBuilder: default_2.FC<NiceTestBuilderProps>;

export declare interface NiceTestBuilderProps extends NiceBaseProps {
    /** Target component name */
    componentName?: string;
    /** Test suites */
    testSuites?: TestSuite[];
    /** Available mock definitions */
    availableMocks?: MockDefinition[];
    onSuitesChange?: (suites: TestSuite[]) => void;
    onExport?: (code: string) => void;
    onRun?: (suiteId: string) => void;
    onRunAll?: () => void;
}

declare interface PageLayout {
    id: string;
    name: string;
    rows: LayoutRow[];
    styles?: Record<string, string>;
}

declare interface ParamDefinition {
    id: string;
    name: string;
    type: 'string' | 'number' | 'boolean' | 'array' | 'object';
    required?: boolean;
    defaultValue?: unknown;
    description?: string;
    validation?: ValidationRule[];
}

declare interface PersistConfig {
    enabled: boolean;
    key: string;
    storage: 'localStorage' | 'sessionStorage' | 'indexedDB' | 'custom';
    whitelist?: string[];
    blacklist?: string[];
    version?: number;
    migrate?: boolean;
}

declare interface PlacedComponent {
    id: string;
    type: string;
    props: Record<string, unknown>;
}

declare interface PropDefinition {
    name: string;
    type: string;
    required?: boolean;
    defaultValue?: unknown;
    description?: string;
}

declare interface PropTypeDefinition {
    name: string;
    type: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'function';
}

declare interface ProviderConfig {
    name: string;
    props?: Record<string, unknown>;
}

declare interface ReducerStep {
    id: string;
    type: 'set' | 'update' | 'push' | 'remove' | 'reset' | 'custom';
    field: string;
    value?: string;
    condition?: string;
}

declare interface ResponseDefinition {
    status: number;
    description?: string;
    schema?: SchemaDefinition;
    headers?: Record<string, string>;
}

declare interface RetryConfig {
    enabled: boolean;
    maxAttempts: number;
    backoff: 'linear' | 'exponential';
    retryOn?: number[];
}

declare interface SchemaDefinition {
    type: 'object' | 'array' | 'string' | 'number' | 'boolean';
    properties?: Record<string, SchemaDefinition>;
    items?: SchemaDefinition;
    required?: string[];
}

declare interface SchemaDefinition_2 {
    name: string;
    type: 'object' | 'array';
    fields: FieldDefinition[];
}

declare interface SchemaInfo {
    id: string;
    name: string;
    schema: SchemaDefinition_2;
}

declare interface StateAction {
    id: string;
    name: string;
    description?: string;
    params: ActionParam[];
    reducerSteps: ReducerStep[];
    async?: boolean;
    errorHandling?: 'throw' | 'catch' | 'ignore';
}

declare interface StateDefinition {
    name: string;
    type: string;
    initialValue?: unknown;
}

declare interface StateField {
    id: string;
    name: string;
    type: FieldType;
    defaultValue?: unknown;
    nullable?: boolean;
    description?: string;
}

declare interface StateSelector {
    id: string;
    name: string;
    description?: string;
    dependencies: string[];
    expression: string;
    memoized?: boolean;
}

declare interface StateSlice {
    id: string;
    name: string;
    description?: string;
    state: StateField[];
    actions: StateAction[];
    selectors: StateSelector[];
    computed?: ComputedField[];
}

declare interface StoreDefinition {
    id: string;
    name: string;
    description?: string;
    slices: StateSlice[];
    middleware?: MiddlewareConfig[];
    persist?: PersistConfig;
    devtools?: DevToolsConfig;
}

declare interface StoreTemplate {
    id: string;
    name: string;
    description: string;
    icon: string;
    store: Partial<StoreDefinition>;
}

declare type TemplateEngine = 'handlebars' | 'ejs' | 'mustache' | 'simple';

declare interface TemplateFile {
    id: string;
    name: string;
    path: string;
    content: string;
    language?: string;
    condition?: string;
}

declare interface TemplateVariable {
    id: string;
    name: string;
    type: 'string' | 'number' | 'boolean' | 'array' | 'object' | 'select';
    defaultValue?: unknown;
    description?: string;
    required?: boolean;
    options?: string[];
    validation?: {
        pattern?: string;
        minLength?: number;
        maxLength?: number;
        min?: number;
        max?: number;
    };
}

declare type TestAction = 'render' | 'click' | 'type' | 'select' | 'hover' | 'focus' | 'blur' | 'submit' | 'keypress' | 'wait' | 'scroll' | 'drag' | 'assert' | 'snapshot' | 'a11y-check';

declare interface TestCase {
    id: string;
    name: string;
    description?: string;
    type: TestType;
    steps: TestStep[];
    expectedResult?: ExpectedResult;
    timeout?: number;
    skip?: boolean;
    only?: boolean;
}

declare interface TestSetup {
    mocks: MockConfig[];
    providers?: ProviderConfig[];
    props?: Record<string, unknown>;
}

declare interface TestStep {
    id: string;
    action: TestAction;
    target?: string;
    value?: unknown;
    waitFor?: WaitCondition;
}

declare interface TestSuite {
    id: string;
    name: string;
    description?: string;
    componentName: string;
    setup?: TestSetup;
    tests: TestCase[];
    teardown?: TestTeardown;
}

declare interface TestTeardown {
    cleanup?: string[];
}

declare type TestType = 'unit' | 'integration' | 'e2e' | 'snapshot' | 'accessibility';

declare interface Transformation {
    id: string;
    name: string;
    type: TransformType;
    config: TransformConfig;
}

declare interface TransformConfig {
    expression?: string;
    format?: string;
    convertTo?: DataType;
    separator?: string;
    lookupTable?: Record<string, unknown>;
    condition?: string;
    thenValue?: unknown;
    elseValue?: unknown;
}

declare type TransformType = 'direct' | 'format' | 'convert' | 'concat' | 'split' | 'calculate' | 'lookup' | 'conditional' | 'custom';

declare interface ValidationRule {
    type: 'required' | 'min' | 'max' | 'pattern' | 'enum';
    value?: unknown;
    message?: string;
}

declare interface ValidationRule_2 {
    id: string;
    field: string;
    type: ValidationType;
    value?: unknown;
    message?: string;
}

declare type ValidationType = 'required' | 'type' | 'min' | 'max' | 'pattern' | 'enum' | 'custom';

declare interface WaitCondition {
    type: 'timeout' | 'element' | 'text' | 'api' | 'state';
    value: unknown;
    timeout?: number;
}

export { }
