import { IClip, ITransitionInfo } from './clips';
import { ColorAdjustment } from './utils/color-adjustment';
import { ShapeType } from '@openvideo/core';
export interface ClipTimingJSON {
    display: {
        from: number;
        to: number;
    };
    trim?: {
        from: number;
        to: number;
    };
    duration: number;
    playbackRate: number;
    fadeIn?: {
        duration: number;
        curve?: "linear" | "ease-in" | "ease-out" | "ease-in-out";
    };
    fadeOut?: {
        duration: number;
        curve?: "linear" | "ease-in" | "ease-out" | "ease-in-out";
    };
}
export interface ClipTransformJSON {
    x: number;
    y: number;
    width: number;
    height: number;
    angle: number;
    opacity: number;
    zIndex: number;
    flip?: {
        x: boolean;
        y: boolean;
    } | null;
}
interface BaseClipJSON {
    id?: string;
    name?: string;
    metadata?: Record<string, any>;
    effects?: Array<{
        id: string;
        key: string;
        startTime: number;
        duration: number;
        targets?: number[];
    }>;
    src?: string;
    timing?: ClipTimingJSON;
    transform?: ClipTransformJSON;
    display?: {
        from: number;
        to: number;
    };
    playbackRate?: number;
    duration?: number;
    trim?: {
        from: number;
        to: number;
    };
    transition?: ITransitionInfo;
    style?: any;
    locked?: boolean;
    colorAdjustment?: ColorAdjustment;
    animation?: {
        keyFrames: Record<string, Partial<{
            x: number;
            y: number;
            w: number;
            h: number;
            angle: number;
            opacity: number;
        }>>;
        options: {
            duration: number;
            delay?: number;
            iterCount?: number;
        };
    };
    animations?: Array<{
        type: string;
        options: any;
        params?: any;
    }>;
    main?: boolean;
}
export interface ClipVisualStyleJSON {
    borderRadius?: number;
    stroke?: {
        color: string;
        width: number;
    };
    shadow?: {
        color?: string;
        alpha?: number;
        blur?: number;
        offsetX?: number;
        offsetY?: number;
    };
}
export interface VideoJSON extends BaseClipJSON {
    type: "Video";
    audio?: boolean;
    volume?: number;
    style?: ClipVisualStyleJSON;
}
export interface AudioJSON extends BaseClipJSON {
    type: "Audio";
    loop?: boolean;
    volume?: number;
    style?: ClipVisualStyleJSON;
}
export interface ImageJSON extends BaseClipJSON {
    type: "Image";
    style?: ClipVisualStyleJSON;
}
export interface TextStyleJSON {
    fontSize?: number;
    fontFamily?: string;
    fontWeight?: string | number;
    fontStyle?: string;
    color?: string | number | {
        type: "gradient";
        x0: number;
        y0: number;
        x1: number;
        y1: number;
        colors: Array<{
            ratio: number;
            color: string | number;
        }>;
    };
    align?: "left" | "center" | "right";
    fontUrl?: string;
    stroke?: {
        color: string | number;
        width: number;
        join?: "miter" | "round" | "bevel";
        cap?: "butt" | "round" | "square";
        miterLimit?: number;
    };
    shadow?: {
        color?: string | number;
        alpha?: number;
        blur?: number;
        offsetX?: number;
        offsetY?: number;
    };
    wordWrap?: boolean;
    wordWrapWidth?: number;
    lineHeight?: number;
    letterSpacing?: number;
    textCase?: "none" | "uppercase" | "lowercase" | "title";
    wordsPerLine?: "single" | "multiple";
    verticalAlign?: "top" | "center" | "bottom";
    wordAnimation?: ICaptionWordAnimation;
    textBoxStyle?: TextBoxStyleJSON;
    appeared?: string;
    active?: string;
    activeFill?: string;
    background?: string;
    keyword?: string;
}
export interface ICaptionWordAnimation {
    type: "scale" | "opacity";
    application: "active" | "keyword" | "none";
    value: number;
    mode?: "static" | "dynamic";
}
export interface TextBoxStyleJSON {
    style?: "tiktok" | "none";
    textAlign?: "left" | "center" | "right" | "";
    maxLines?: number;
    borderRadius?: number;
    horizontalPadding?: number;
    verticalPadding?: number;
}
export interface TextJSON extends BaseClipJSON {
    type: "Text";
    text: string;
    style?: TextStyleJSON;
}
export interface CaptionColorsJSON {
    appeared?: string;
    active?: string;
    activeFill?: string;
    background?: string;
    keyword?: string;
}
export interface CaptionPositioningJSON {
    bottomOffset?: number;
    videoWidth?: number;
    videoHeight?: number;
}
export interface CaptionDataJSON {
    words?: Array<{
        text: string;
        from: number;
        to: number;
        isKeyWord?: boolean;
        paragraphIndex?: number;
    }>;
    colors?: CaptionColorsJSON;
    preserveKeywordColor?: boolean;
    positioning?: CaptionPositioningJSON;
    wordAnimation?: ICaptionWordAnimation;
    textBoxStyle?: TextBoxStyleJSON;
}
export interface CaptionJSON extends BaseClipJSON {
    type: "Caption";
    text: string;
    style?: TextStyleJSON;
    caption?: CaptionDataJSON;
    fontUrl?: string;
    mediaId?: string;
    wordsPerLine?: "single" | "multiple";
    textBoxStyle?: TextBoxStyleJSON;
}
export interface EffectJSON extends BaseClipJSON {
    type: "Effect";
    effectKey: string;
    values?: Record<string, any>;
}
export interface TransitionJSON extends BaseClipJSON {
    type: "Transition";
    transitionKey: string;
    fromClipId?: string | null;
    toClipId?: string | null;
}
export interface PlaceholderJSON extends BaseClipJSON {
    type: "Placeholder";
}
export interface ShapeJSON extends BaseClipJSON {
    type: "Shape";
    shapeType: ShapeType;
}
export interface GlobalTransitionJSON {
    key: string;
    duration: number;
    clips: string[];
}
export type ClipJSON = VideoJSON | AudioJSON | ImageJSON | TextJSON | CaptionJSON | EffectJSON | TransitionJSON | PlaceholderJSON | ShapeJSON;
export interface StudioTrackJSON {
    id: string;
    name: string;
    type: string;
    clipIds: string[];
}
export interface ProjectJSON {
    tracks?: StudioTrackJSON[];
    clips: Record<string, ClipJSON>;
    transition?: GlobalTransitionJSON[];
    transitions?: GlobalTransitionJSON[];
    globalEffects?: Array<{
        id: string;
        key: string;
        startTime: number;
        duration: number;
    }>;
    settings?: {
        width?: number;
        height?: number;
        fps?: number;
        duration?: number;
        backgroundColor?: string;
        format?: string;
        videoCodec?: string;
        bitrate?: number;
        audio?: boolean;
        audioCodec?: string;
        audioSampleRate?: number;
        metaDataTags?: Record<string, string>;
    };
}
/**
 * Normalize a clip's JSON structure to ensure compatibility and migrate old property structures
 */
export declare function normalizeClipJSON(json: ClipJSON): ClipJSON;
export declare function normalizeClipStyleJSON(style: any, type: string): any;
/**
 * Serialize a clip to JSON format
 * @param clip The clip to serialize
 * @param main Whether this is the main clip (for Compositor)
 */
export declare function clipToJSON(clip: IClip, main?: boolean): ClipJSON;
/**
 * Deserialize JSON to a clip instance
 * Uses fromObject static method if available (fabric.js pattern), otherwise falls back to manual construction
 */
export declare function jsonToClip(json: ClipJSON): Promise<IClip>;
export {};
