{"version":3,"sources":["../src/utils/index.ts","../src/types/index.ts","../src/index.ts","../src/utils/video-creator.ts","../src/utils/audio-processor.ts","../src/utils/batch-processor.ts"],"names":["utils_exports","__export","AudioProcessor","BatchProcessor","VideoCreator","types_exports","Creatify","options","AvatarApi","apiClientFactory","UrlToVideoApi","TextToSpeechApi","AiEditingApi","CustomTemplatesApi","DyoaApi","AiShortsApi","AiScriptsApi","MusicsApi","WorkspaceApi","LipsyncV2Api","apiIdOrOptions","apiKey","clientFactory","avatars","avatar","voices","voice","name","normalizedName","pollInterval","maxPollingAttempts","aspectRatio","avatarId","voiceId","lipsyncResponse","lipsyncResult","attempts","resolve","error","conversations","backgroundUrl","videoInputs","conversation","multiAvatarResponse","result","script","accentId","waitForCompletion","params","id","maxAttempts","DEFAULT_BATCH_OPTIONS","_clientFactory","tasks","opts","activeTasks","taskIndex","queue","currentIndex","taskPromise","taskResult","lastError","retryCount","retryDelay","p","avatarTasks","task","textToSpeechTasks","aiEditingTasks","aiShortsTasks","aiScriptsTasks","lipsyncV2Tasks"],"mappings":";AAAA,IAAAA,EAAA,GAAAC,CAAAA,CAAAD,EAAA,CAAAE,cAAAA,CAAAA,IAAAA,CAAAA,CAAA,mBAAAC,CAAA,CAAA,YAAA,CAAA,IAAAC,ICAAC,IAAAA,CAAAA,CAAA,GCqBaC,IAAAA,CAAAA,CAAN,KAAe,CAIZ,OAAA,CAKD,OAKA,UAKA,CAAA,YAAA,CAKA,UAKA,eAKA,CAAA,IAAA,CAKA,SAKA,SAKA,CAAA,MAAA,CAKA,UAKA,SAMP,CAAA,WAAA,CAAYC,EAAmC,CAC7C,IAAA,CAAK,QAAUA,CACf,CAAA,IAAA,CAAK,OAAS,IAAIC,CAAAA,CAAUD,EAASE,CAAgB,CAAA,CACrD,KAAK,UAAa,CAAA,IAAIC,CAAcH,CAAAA,CAAAA,CAASE,CAAgB,CAC7D,CAAA,IAAA,CAAK,aAAe,IAAIE,CAAAA,CAAgBJ,EAASE,CAAgB,CAA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EAOA9D,CAAkC,CAAA,GAClC,CACA,IAAM8C,EAAQgB,CAAc,CAAA,GAAA,CAAIH,GACvB,SACE,IAAA,CAAK,IAAI,QAAS,CAAA,wBAAA,CAAyB,CAChD,MAAQA,CAAAA,CAAAA,CAAK,OACb,YAAcA,CAAAA,CAAAA,CAAK,YACnB,eAAiBA,CAAAA,CAAAA,CAAK,cACtB,CAAA,eAAA,CAAiBA,EAAK,cACtB,CAAA,QAAA,CAAUA,EAAK,QACjB,CAAC,CAEJ,CAED,CAAA,OAAO,KAAK,YAAab,CAAAA,CAAAA,CAAO9C,CAAO,CACzC,CAQA,MAAM,qBACJ+D,CAAAA,CAAAA,CAOA/D,EAAkC,EAAC,CACnC,CACA,IAAM8C,CAAAA,CAAQiB,EAAe,GAAIJ,CAAAA,CAAAA,EACxB,SACE,IAAK,CAAA,GAAA,CAAI,UAAU,wBAAyB,CAAA,CACjD,OAAQA,CAAK,CAAA,MAAA,CACb,gBAAiBA,CAAK,CAAA,cAAA,CACtB,gBAAiBA,CAAK,CAAA,cAAA,CACtB,SAAUA,CAAK,CAAA,QAAA,CACf,cAAeA,CAAK,CAAA,YACtB,CAAC,CAEJ,CAAA,CAED,OAAO,IAAK,CAAA,YAAA,CAAab,EAAO9C,CAAO,CACzC,CAQA,MAAM,qBAAA,CACJgE,EACAhE,CAAkC,CAAA,GAClC,CACA,IAAM8C,EAAQkB,CAAe,CAAA,GAAA,CAAIL,GACxB,SACE,IAAA,CAAK,IAAI,SAAU,CAAA,yBAAA,CAA0B,CAClD,YAAcA,CAAAA,CAAAA,CAAK,YACnB,YAAcA,CAAAA,CAAAA,CAAK,WACrB,CAAC,CAEJ,EAED,OAAO,IAAA,CAAK,aAAab,CAAO9C,CAAAA,CAAO,CACzC,CACF","file":"chunk-U6MYYBUL.mjs","sourcesContent":["import { VideoCreator } from './video-creator';\nimport { AudioProcessor } from './audio-processor';\nimport { BatchProcessor, BatchProcessingOptions, BatchResult } from './batch-processor';\n\nexport { VideoCreator, AudioProcessor, BatchProcessor, BatchProcessingOptions, BatchResult };\n","/**\n * Configuration options for the Creatify API client\n */\nexport interface CreatifyApiOptions {\n  /**\n   * The API ID from your Creatify account\n   */\n  apiId: string;\n\n  /**\n   * The API key from your Creatify account\n   */\n  apiKey: string;\n\n  /**\n   * Base URL for the Creatify API (optional, defaults to https://api.creatify.ai)\n   */\n  baseUrl?: string;\n\n  /**\n   * Request timeout in milliseconds (optional, defaults to 30000)\n   */\n  timeout?: number;\n}\n\n/**\n * Base response interface for all API responses\n */\nexport interface ApiResponse {\n  /**\n   * Whether the request was successful\n   */\n  success: boolean;\n\n  /**\n   * Error message if the request failed\n   */\n  error?: string;\n}\n\n/**\n * Standard pagination parameters\n */\nexport interface PaginationParams {\n  /**\n   * Page number (starts from 1)\n   */\n  page?: number;\n\n  /**\n   * Number of items per page\n   */\n  limit?: number;\n}\n\n/**\n * Common aspect ratio options for video generation\n * Note: API accepts both colon format ('16:9') and 'x' format ('16x9')\n */\nexport type AspectRatio =\n  | '1:1'\n  | '16:9'\n  | '9:16'\n  | '4:3'\n  | '3:4'\n  | '1x1'\n  | '16x9'\n  | '9x16'\n  | '4x3'\n  | '3x4';\n\n/**\n * Common status values for tasks\n */\nexport type TaskStatus =\n  | 'pending'\n  | 'in_queue'\n  | 'running'\n  | 'processing'\n  | 'failed'\n  | 'done'\n  | 'error';\n\n/* eslint-disable @typescript-eslint/no-namespace */\nexport namespace Avatar {\n  /**\n   * Avatar information as returned by the /api/personas/ endpoint\n   * @see https://creatify.mintlify.app/api-reference/personas/get-apipersonas\n   */\n  export interface AvatarInfo {\n    /**\n     * Unique identifier for the avatar\n     */\n    id: string;\n\n    /**\n     * Alias for id - used in MultiAvatarLipsyncParams and other API interactions\n     */\n    avatar_id?: string;\n\n    /**\n     * Display name for the avatar\n     */\n    name?: string;\n\n    /**\n     * Creation timestamp\n     */\n    created_at: string;\n\n    /**\n     * Last update timestamp\n     */\n    updated_at: string;\n\n    /**\n     * Gender of the avatar (m = male, f = female, nb = non binary)\n     */\n    gender: 'm' | 'f' | 'nb';\n\n    /**\n     * Age range of the avatar (child, teen, adult, senior)\n     */\n    age_range: 'child' | 'teen' | 'adult' | 'senior';\n\n    /**\n     * Location type (outdoor, fantasy, indoor, other)\n     */\n    location: 'outdoor' | 'fantasy' | 'indoor' | 'other';\n\n    /**\n     * Style (selfie, presenter, other)\n     */\n    style: 'selfie' | 'presenter' | 'other';\n\n    /**\n     * Name of the creator\n     */\n    creator_name: string;\n\n    /**\n     * Video scene description\n     */\n    video_scene: string;\n\n    /**\n     * Keywords associated with the avatar\n     */\n    keywords: string;\n\n    /**\n     * Preview image URL for 16:9 aspect ratio\n     */\n    preview_image_16_9: string;\n\n    /**\n     * Preview image URL for 1:1 aspect ratio\n     */\n    preview_image_1_1: string;\n\n    /**\n     * Preview image URL for 9:16 aspect ratio\n     */\n    preview_image_9_16: string;\n\n    /**\n     * Preview video URL for 16:9 aspect ratio\n     */\n    preview_video_16_9: string;\n\n    /**\n     * Preview video URL for 1:1 aspect ratio\n     */\n    preview_video_1_1: string;\n\n    /**\n     * Preview video URL for 9:16 aspect ratio\n     */\n    preview_video_9_16: string;\n\n    /**\n     * Landscape preview video URL (legacy)\n     */\n    landscape_preview_video: string;\n\n    /**\n     * Squared preview video URL (legacy)\n     */\n    squared_preview_video: string;\n\n    /**\n     * Whether the avatar is active\n     */\n    is_active: boolean;\n\n    /**\n     * Processing status\n     */\n    process_status: string;\n\n    /**\n     * Reason for failure if any\n     */\n    failed_reason: string;\n\n    /**\n     * Avatar type\n     */\n    type: string;\n  }\n\n  /**\n   * Accent information within a voice\n   */\n  export interface AccentInfo {\n    /**\n     * Unique identifier for the accent\n     */\n    id: string;\n\n    /**\n     * Name of the accent\n     */\n    name: string;\n\n    /**\n     * Preview URL for the accent\n     */\n    preview_url?: string;\n  }\n\n  /**\n   * Voice information as returned by the /api/voices/ endpoint\n   */\n  export interface VoiceInfo {\n    /**\n     * Unique identifier for the voice\n     * Note: May be provided as voice_id or id depending on API version\n     */\n    voice_id: string;\n\n    /**\n     * Alternative identifier field\n     */\n    id?: string;\n\n    /**\n     * Name of the voice\n     */\n    name: string;\n\n    /**\n     * Language of the voice (e.g., \"en\", \"fr\")\n     */\n    language?: string;\n\n    /**\n     * Gender of the voice (e.g., \"male\", \"female\")\n     */\n    gender?: string;\n\n    /**\n     * Array of accents available for this voice\n     */\n    accents?: AccentInfo[];\n\n    /**\n     * Preview URL for the voice (may be available directly or through accents)\n     */\n    preview_url?: string;\n  }\n\n  /**\n   * Parameters for creating a lipsync video\n   * @see https://creatify.mintlify.app/api-reference/lipsyncs/post-apilipsyncs\n   */\n  export interface LipsyncParams {\n    /**\n     * Text to be spoken by the avatar\n     */\n    text: string;\n\n    /**\n     * Avatar ID to use for the video\n     */\n    creator: string;\n\n    /**\n     * Aspect ratio of the generated video\n     * Available options: \"1:1\", \"16:9\", \"9:16\"\n     */\n    aspect_ratio?: AspectRatio;\n\n    /**\n     * Voice ID to use (optional)\n     * If not provided, the system will use a default voice\n     */\n    voice_id?: string;\n\n    /**\n     * Background image URL (optional)\n     * If provided, this image will be used as the background\n     */\n    background_url?: string;\n\n    /**\n     * Background color (optional)\n     * CSS color value like \"#FF0000\" or \"rgb(255,0,0)\"\n     */\n    background_color?: string;\n\n    /**\n     * Output in transparent format (optional)\n     * If true, the output video will have transparent background (for compositing)\n     */\n    transparent?: boolean;\n\n    /**\n     * Webhook URL to be called when the video is ready (optional)\n     * The system will POST to this URL when processing is complete\n     */\n    webhook_url?: string;\n\n    /**\n     * Custom metadata for tracking (optional)\n     * This data will be returned in webhook calls\n     */\n    metadata?: Record<string, unknown>;\n  }\n\n  /**\n   * Response when creating a lipsync task\n   */\n  export interface LipsyncResponse extends ApiResponse {\n    /**\n     * ID of the created lipsync task\n     */\n    id: string;\n\n    /**\n     * Status of the lipsync task\n     * API may return: 'pending', 'in_queue', 'running', 'failed', 'done', 'error'\n     */\n    status: 'pending' | 'in_queue' | 'running' | 'processing' | 'failed' | 'done' | 'error';\n  }\n\n  /**\n   * Response when getting a lipsync task\n   */\n  export interface LipsyncResultResponse extends LipsyncResponse {\n    /**\n     * Output URL of the generated video (only available when status is 'done')\n     */\n    output?: string;\n\n    /**\n     * Error message if the task failed\n     */\n    error_message?: string;\n\n    /**\n     * Created timestamp\n     */\n    created_at: string;\n\n    /**\n     * Updated timestamp\n     */\n    updated_at: string;\n\n    /**\n     * Video thumbnail URL\n     */\n    video_thumbnail?: string;\n\n    /**\n     * Number of credits used for this video\n     */\n    credits_used?: number;\n\n    /**\n     * Progress indication (e.g., percentage)\n     */\n    progress?: string;\n\n    /**\n     * Media job ID\n     */\n    media_job?: string;\n\n    /**\n     * Whether the lipsync task is hidden\n     */\n    is_hidden?: boolean;\n  }\n\n  /**\n   * Parameters for creating a multi-avatar lipsync video\n   */\n  export interface MultiAvatarLipsyncParams {\n    /**\n     * Array of video input configurations\n     */\n    video_inputs: {\n      /**\n       * Character configuration\n       */\n      character: {\n        /**\n         * Type of character (always \"avatar\" for now)\n         */\n        type: 'avatar';\n\n        /**\n         * Avatar ID to use\n         */\n        avatar_id: string;\n\n        /**\n         * Avatar style (e.g., \"normal\")\n         */\n        avatar_style: string;\n\n        /**\n         * Position offset of the avatar\n         */\n        offset?: {\n          x: number;\n          y: number;\n        };\n      };\n\n      /**\n       * Voice configuration\n       */\n      voice: {\n        /**\n         * Type of voice input (always \"text\" for now)\n         */\n        type: 'text';\n\n        /**\n         * Text to be spoken\n         */\n        input_text: string;\n\n        /**\n         * Voice ID to use\n         */\n        voice_id: string;\n      };\n\n      /**\n       * Background configuration\n       */\n      background: {\n        /**\n         * Type of background (always \"image\" for now)\n         */\n        type: 'image';\n\n        /**\n         * URL of the background image\n         */\n        url: string;\n      };\n\n      /**\n       * Caption settings\n       */\n      caption_setting?: {\n        /**\n         * Style of the caption\n         */\n        style: string;\n\n        /**\n         * Position offset of the caption\n         */\n        offset?: {\n          x: number;\n          y: number;\n        };\n      };\n    }[];\n\n    /**\n     * Aspect ratio of the generated video\n     */\n    aspect_ratio: AspectRatio;\n\n    /**\n     * Webhook URL to be called when the video is ready (optional)\n     */\n    webhook_url?: string;\n  }\n}\n\n/**\n * URL-to-Video API types\n * @see https://creatify.mintlify.app/api-reference/link-to-video\n */\nexport namespace UrlToVideo {\n  /**\n   * Parameters for creating a link\n   * @see https://creatify.mintlify.app/api-reference/link-to-video\n   */\n  export interface LinkParams {\n    /**\n     * URL to extract content from\n     */\n    url: string;\n  }\n\n  /**\n   * Response when creating a link\n   */\n  export interface LinkResponse {\n    /**\n     * Unique identifier for the link\n     */\n    id: string;\n\n    /**\n     * Original URL\n     */\n    url: string;\n\n    /**\n     * Link data object\n     */\n    link: LinkData;\n  }\n\n  /**\n   * Parameters for creating a link with custom parameters\n   */\n  export interface CustomLinkParams {\n    /**\n     * Title of the content\n     */\n    title: string;\n\n    /**\n     * Description of the content\n     */\n    description: string;\n\n    /**\n     * URLs of images to use in the video\n     */\n    image_urls: string[];\n\n    /**\n     * URLs of videos to use (optional)\n     */\n    video_urls?: string[];\n\n    /**\n     * Customer reviews (optional)\n     */\n    reviews?: Array<{\n      rating: number;\n      text: string;\n      author?: string;\n      date?: string;\n    }>;\n\n    /**\n     * URL of the logo (optional)\n     */\n    logo_url?: string;\n  }\n\n  /**\n   * Link data returned by the API\n   * @see https://creatify.mintlify.app/api-reference/link-to-video\n   */\n  export interface LinkData {\n    /**\n     * Unique identifier for the link\n     */\n    id: string;\n\n    /**\n     * Original URL\n     */\n    url: string;\n\n    /**\n     * Title extracted from the URL\n     */\n    title: string;\n\n    /**\n     * Description extracted from the URL\n     */\n    description: string;\n\n    /**\n     * URLs of images extracted from the URL\n     */\n    image_urls: string[];\n\n    /**\n     * URLs of videos extracted from the URL\n     */\n    video_urls: string[];\n\n    /**\n     * Reviews extracted from the URL (if any)\n     */\n    reviews?: Array<{\n      rating: number;\n      text: string;\n      author?: string;\n      date?: string;\n    }>;\n\n    /**\n     * URL of the logo extracted from the URL\n     */\n    logo_url?: string;\n  }\n\n  /**\n   * Parameters for creating a video from a link\n   * @see https://creatify.mintlify.app/api-reference/link_to_videos/post-apilink_to_videos\n   */\n  export interface VideoFromLinkParams {\n    /**\n     * ID of the link to create a video from\n     */\n    link: string;\n\n    /**\n     * Optional name for the video\n     */\n    name?: string;\n\n    /**\n     * Target platform for the video (e.g., \"Tiktok\", \"Instagram\")\n     */\n    target_platform?: string;\n\n    /**\n     * Target audience description\n     */\n    target_audience?: string;\n\n    /**\n     * Language code for the video (e.g., \"en\", \"es\", \"fr\", \"de\", \"ar\")\n     */\n    language?: string;\n\n    /**\n     * Length of the video in seconds (default: 15)\n     */\n    video_length?: number;\n\n    /**\n     * Aspect ratio of the video (e.g., \"16x9\", \"9x16\", \"1x1\")\n     */\n    aspect_ratio?: string;\n\n    /**\n     * Script style to use for generating the video script\n     */\n    script_style?: string;\n\n    /**\n     * Visual style to use for generating the video\n     */\n    visual_style?: string;\n\n    /**\n     * Override the avatar with a specific avatar ID\n     */\n    override_avatar?: string;\n\n    /**\n     * Override the voice with a specific voice ID\n     */\n    override_voice?: string;\n\n    /**\n     * Override the auto-generated script with a custom script\n     */\n    override_script?: string;\n\n    /**\n     * URL to a background music track\n     */\n    background_music_url?: string;\n\n    /**\n     * Volume level for background music (0.0 - 1.0)\n     */\n    background_music_volume?: number;\n\n    /**\n     * Volume level for voiceover (0.0 - 1.0)\n     */\n    voiceover_volume?: number;\n\n    /**\n     * Webhook URL to be called when the video is ready\n     */\n    webhook_url?: string;\n\n    /**\n     * Disable background music if true\n     */\n    no_background_music?: boolean;\n\n    /**\n     * Disable captions if true\n     */\n    no_caption?: boolean;\n\n    /**\n     * Disable emotional expressions if true\n     */\n    no_emotion?: boolean;\n\n    /**\n     * Disable call-to-action if true\n     */\n    no_cta?: boolean;\n\n    /**\n     * Disable stock b-roll footage if true\n     */\n    no_stock_broll?: boolean;\n\n    /**\n     * Caption style (e.g., \"normal-black\")\n     */\n    caption_style?: string;\n\n    /**\n     * Caption horizontal offset\n     */\n    caption_offset_x?: string | number;\n\n    /**\n     * Caption vertical offset\n     */\n    caption_offset_y?: string | number;\n\n    /**\n     * Detailed caption settings\n     */\n    caption_setting?: {\n      /**\n       * Caption style\n       */\n      style?: string;\n\n      /**\n       * Caption position offset\n       */\n      offset?: {\n        x: number;\n        y: number;\n      };\n\n      /**\n       * Font family\n       */\n      font_family?: string;\n\n      /**\n       * Font size\n       */\n      font_size?: number;\n\n      /**\n       * Font style\n       */\n      font_style?: string;\n\n      /**\n       * Background color\n       */\n      background_color?: string;\n\n      /**\n       * Text color\n       */\n      text_color?: string;\n\n      /**\n       * Highlight text color\n       */\n      highlight_text_color?: string;\n\n      /**\n       * Maximum width\n       */\n      max_width?: number;\n\n      /**\n       * Line height\n       */\n      line_height?: number;\n\n      /**\n       * Text shadow\n       */\n      text_shadow?: string;\n\n      /**\n       * Hide captions if true\n       */\n      hidden?: boolean;\n    };\n  }\n\n  /**\n   * Response when creating a video from a link\n   * @see https://creatify.mintlify.app/api-reference/link_to_videos/post-apilink_to_videos\n   */\n  export interface VideoResponse {\n    /**\n     * ID of the created video task\n     */\n    id: string;\n\n    /**\n     * Status of the video task\n     * API may return: 'pending', 'in_queue', 'running', 'failed', 'done', 'error'\n     */\n    status: 'pending' | 'in_queue' | 'running' | 'failed' | 'done' | 'error';\n\n    /**\n     * Link ID used to create the video\n     */\n    link: string;\n\n    /**\n     * Media job ID\n     */\n    media_job: string;\n\n    /**\n     * Reason for failure if the task failed\n     */\n    failed_reason?: string;\n\n    /**\n     * Other parameters match the input parameters\n     */\n    [key: string]: unknown;\n  }\n\n  /**\n   * Response when getting a video result\n   * @see https://creatify.mintlify.app/api-reference/link_to_videos/get-apilink_to_videos-\n   */\n  export interface VideoResultResponse extends VideoResponse {\n    /**\n     * URL of the generated video (only available when status is 'done')\n     * Note: API may return this as either 'video_output' or 'output'\n     */\n    video_output?: string;\n\n    /**\n     * URL of the generated video (alternative field name)\n     */\n    output?: string;\n\n    /**\n     * URL of the video thumbnail\n     */\n    video_thumbnail?: string;\n\n    /**\n     * Number of credits used for this video\n     */\n    credits_used?: number;\n\n    /**\n     * Progress indication (e.g., percentage)\n     */\n    progress?: string;\n\n    /**\n     * Created timestamp\n     */\n    created_at?: string;\n\n    /**\n     * Updated timestamp\n     */\n    updated_at?: string;\n  }\n}\n\n/**\n * Text to Speech API types\n * @see https://creatify.mintlify.app/api-reference/text-to-speech\n */\nexport namespace TextToSpeech {\n  /**\n   * Voice information\n   */\n  export interface Voice {\n    /**\n     * Unique identifier for the voice\n     */\n    id?: string;\n\n    /**\n     * Alternative identifier field\n     */\n    voice_id?: string;\n\n    /**\n     * Display name of the voice\n     */\n    name: string;\n\n    /**\n     * Language code (e.g., 'en-US')\n     */\n    language_code?: string;\n\n    /**\n     * Language of the voice (e.g., \"en\", \"fr\")\n     */\n    language?: string;\n\n    /**\n     * Gender of the voice ('male' or 'female')\n     */\n    gender?: string;\n\n    /**\n     * Sample audio URL\n     */\n    sample_url?: string;\n\n    /**\n     * Array of accents available for this voice\n     */\n    accents?: Avatar.AccentInfo[];\n  }\n  /**\n   * Parameters for creating a text-to-speech task\n   * @see https://creatify.mintlify.app/api-reference/text-to-speech/post-text-to-speech\n   */\n  export interface TextToSpeechParams {\n    /**\n     * Text script to be converted to speech\n     */\n    script: string;\n\n    /**\n     * Accent/voice ID to use for the speech\n     * You can get the accent id by calling the Get voices endpoint\n     */\n    accent: string;\n\n    /**\n     * Webhook URL to be called when the audio is ready (optional)\n     * The system will POST to this URL when processing is complete\n     */\n    webhook_url?: string;\n  }\n\n  /**\n   * Response when creating a text-to-speech task\n   */\n  export interface TextToSpeechResponse {\n    /**\n     * ID of the created text-to-speech task\n     */\n    id: string;\n\n    /**\n     * Status of the text-to-speech task\n     * API may return: 'pending', 'in_queue', 'running', 'failed', 'done', 'error'\n     */\n    status: 'pending' | 'in_queue' | 'running' | 'failed' | 'done' | 'error';\n\n    /**\n     * The script that was submitted\n     */\n    script: string;\n\n    /**\n     * The accent/voice ID that was used\n     */\n    accent: string;\n\n    /**\n     * The webhook URL that was provided (if any)\n     */\n    webhook_url?: string;\n\n    /**\n     * Media job ID\n     */\n    media_job?: string;\n\n    /**\n     * Whether the TTS task is hidden\n     */\n    is_hidden?: boolean;\n\n    /**\n     * Reason for failure if the task failed\n     */\n    failed_reason?: string;\n  }\n\n  /**\n   * Response when getting a text-to-speech task\n   * @see https://creatify.mintlify.app/api-reference/text-to-speech/get-text-to-speech-\n   */\n  export interface TextToSpeechResultResponse extends TextToSpeechResponse {\n    /**\n     * Output URL of the generated audio (only available when status is 'done')\n     */\n    output?: string;\n\n    /**\n     * Created timestamp\n     */\n    created_at: string;\n\n    /**\n     * Updated timestamp\n     */\n    updated_at: string;\n  }\n}\n\n/**\n * AI Editing API types\n */\nexport namespace AiEditing {\n  /**\n   * Editing styles available for AI editing\n   */\n  export type EditingStyle = 'film' | 'commercial' | 'music' | 'tutorial' | 'vlog' | 'social';\n\n  /**\n   * Parameters for creating an AI editing task\n   */\n  export interface AiEditingParams {\n    /**\n     * URL of the video to be edited\n     */\n    video_url: string;\n\n    /**\n     * Editing style to apply\n     */\n    editing_style: EditingStyle;\n\n    /**\n     * Webhook URL to be called when the edited video is ready (optional)\n     */\n    webhook_url?: string;\n  }\n\n  /**\n   * Response when creating an AI editing task\n   */\n  export interface AiEditingResponse extends ApiResponse {\n    /**\n     * ID of the created AI editing task\n     */\n    id: string;\n\n    /**\n     * Status of the AI editing task\n     */\n    status: 'pending' | 'processing' | 'done' | 'error';\n  }\n\n  /**\n   * Response when getting an AI editing task\n   */\n  export interface AiEditingResultResponse extends AiEditingResponse {\n    /**\n     * Output URL of the edited video (only available when status is 'done')\n     */\n    output?: string;\n\n    /**\n     * Error message if the task failed\n     */\n    error_message?: string;\n\n    /**\n     * Created timestamp\n     */\n    created_at: string;\n\n    /**\n     * Updated timestamp\n     */\n    updated_at: string;\n  }\n}\n\n/**\n * Custom Templates API types\n */\nexport namespace CustomTemplates {\n  /**\n   * Parameters for creating a video using a custom template\n   */\n  export interface CustomTemplateParams {\n    /**\n     * Visual style/template name to use\n     */\n    visual_style: string;\n\n    /**\n     * Custom data to populate the template\n     */\n    data: Record<string, unknown>;\n\n    /**\n     * Webhook URL to be called when the video is ready (optional)\n     */\n    webhook_url?: string;\n  }\n\n  /**\n   * Response when creating a custom template video\n   */\n  export interface CustomTemplateResponse extends ApiResponse {\n    /**\n     * ID of the created custom template task\n     */\n    id: string;\n\n    /**\n     * Status of the custom template task\n     */\n    status: 'pending' | 'processing' | 'done' | 'error';\n  }\n\n  /**\n   * Response when getting a custom template task\n   */\n  export interface CustomTemplateResultResponse extends CustomTemplateResponse {\n    /**\n     * Output URL of the generated video (only available when status is 'done')\n     */\n    output?: string;\n\n    /**\n     * Error message if the task failed\n     */\n    error_message?: string;\n\n    /**\n     * Created timestamp\n     */\n    created_at: string;\n\n    /**\n     * Updated timestamp\n     */\n    updated_at: string;\n  }\n}\n\n/**\n * AI Shorts API types\n * @see https://creatify.mintlify.app/api-reference/ai-shorts\n */\nexport namespace AiShorts {\n  /**\n   * Parameters for creating an AI Shorts task\n   * @see https://creatify.mintlify.app/api-reference/ai-shorts/post-ai-shorts\n   */\n  export interface AiShortsParams {\n    /**\n     * Text prompt for the AI Shorts video\n     */\n    prompt: string;\n\n    /**\n     * Aspect ratio of the generated video\n     */\n    aspect_ratio: AspectRatio;\n\n    /**\n     * Target platform for the video (e.g., \"Tiktok\", \"Instagram\")\n     */\n    target_platform?: string;\n\n    /**\n     * Target audience description\n     */\n    target_audience?: string;\n\n    /**\n     * Language code for the video (e.g., \"en\", \"es\", \"fr\", \"de\", \"ar\")\n     */\n    language?: string;\n\n    /**\n     * Length of the video in seconds\n     */\n    video_length?: number;\n\n    /**\n     * Visual style to use for generating the video\n     */\n    visual_style?: string;\n\n    /**\n     * Webhook URL to be called when the video is ready (optional)\n     */\n    webhook_url?: string;\n  }\n\n  /**\n   * Response when creating an AI Shorts task\n   */\n  export interface AiShortsResponse extends ApiResponse {\n    /**\n     * ID of the created AI Shorts task\n     */\n    id: string;\n\n    /**\n     * Status of the AI Shorts task\n     */\n    status: TaskStatus;\n  }\n\n  /**\n   * Response when getting an AI Shorts task\n   */\n  export interface AiShortsResultResponse extends AiShortsResponse {\n    /**\n     * Output URL of the generated video (only available when status is 'done')\n     */\n    output?: string;\n\n    /**\n     * Error message if the task failed\n     */\n    error_message?: string;\n\n    /**\n     * Created timestamp\n     */\n    created_at: string;\n\n    /**\n     * Updated timestamp\n     */\n    updated_at: string;\n\n    /**\n     * Video thumbnail URL\n     */\n    video_thumbnail?: string;\n\n    /**\n     * Number of credits used for this video\n     */\n    credits_used?: number;\n\n    /**\n     * Progress indication (e.g., percentage)\n     */\n    progress?: string;\n  }\n\n  /**\n   * Parameters for generating a preview of AI Shorts\n   */\n  export interface AiShortsPreviewParams {\n    /**\n     * ID of the AI Shorts task\n     */\n    id: string;\n  }\n\n  /**\n   * Parameters for rendering an AI Shorts video\n   */\n  export interface AiShortsRenderParams {\n    /**\n     * ID of the AI Shorts task\n     */\n    id: string;\n  }\n}\n\n/**\n * AI Scripts API types\n * @see https://creatify.mintlify.app/api-reference/ai-scripts\n */\nexport namespace AiScripts {\n  /**\n   * Parameters for generating AI Scripts\n   * @see https://creatify.mintlify.app/api-reference/ai-scripts/post-ai-scripts\n   */\n  export interface AiScriptsParams {\n    /**\n     * Text prompt for the AI Script\n     */\n    prompt: string;\n\n    /**\n     * Target platform for the script (e.g., \"Tiktok\", \"Instagram\")\n     */\n    target_platform?: string;\n\n    /**\n     * Target audience description\n     */\n    target_audience?: string;\n\n    /**\n     * Language code for the script (e.g., \"en\", \"es\", \"fr\", \"de\", \"ar\")\n     */\n    language?: string;\n\n    /**\n     * Length of the script in seconds\n     */\n    script_length?: number;\n\n    /**\n     * Script style to use\n     */\n    script_style?: string;\n\n    /**\n     * Webhook URL to be called when the script is ready (optional)\n     */\n    webhook_url?: string;\n  }\n\n  /**\n   * Response when creating an AI Scripts task\n   */\n  export interface AiScriptsResponse extends ApiResponse {\n    /**\n     * ID of the created AI Scripts task\n     */\n    id: string;\n\n    /**\n     * Status of the AI Scripts task\n     */\n    status: TaskStatus;\n  }\n\n  /**\n   * Response when getting an AI Scripts task\n   */\n  export interface AiScriptsResultResponse extends AiScriptsResponse {\n    /**\n     * Generated script content (only available when status is 'done')\n     */\n    script?: string;\n\n    /**\n     * Error message if the task failed\n     */\n    error_message?: string;\n\n    /**\n     * Created timestamp\n     */\n    created_at: string;\n\n    /**\n     * Updated timestamp\n     */\n    updated_at: string;\n  }\n}\n\n/**\n * Musics API types\n * @see https://creatify.mintlify.app/api-reference/musics\n */\nexport namespace Musics {\n  /**\n   * Music category information\n   * @see https://creatify.mintlify.app/api-reference/musics/get-api-music-categories\n   */\n  export interface MusicCategory {\n    /**\n     * Name of the music category\n     */\n    name: string;\n  }\n\n  /**\n   * Music track information\n   * @see https://creatify.mintlify.app/api-reference/musics/get-api-musics\n   */\n  export interface MusicTrack {\n    /**\n     * ID of the music track\n     */\n    id: string;\n\n    /**\n     * Name of the music track\n     */\n    name: string;\n\n    /**\n     * URL to the music track\n     */\n    url: string;\n\n    /**\n     * Category of the music track\n     */\n    category: string;\n\n    /**\n     * Duration of the music track in seconds\n     */\n    duration?: number;\n  }\n}\n\n/**\n * Workspace API types\n * @see https://creatify.mintlify.app/api-reference/workspace\n */\nexport namespace Workspace {\n  /**\n   * Response for remaining credits\n   * @see https://creatify.mintlify.app/api-reference/workspace/get-remainingcredits\n   */\n  export interface RemainingCreditsResponse {\n    /**\n     * Number of remaining credits\n     */\n    remaining_credits: number;\n  }\n}\n\n/**\n * Lipsync v2 API types\n * @see https://creatify.mintlify.app/api-reference/lipsyncs_v2\n */\nexport namespace LipsyncV2 {\n  /**\n   * Parameters for creating a lipsync v2 task\n   * @see https://creatify.mintlify.app/api-reference/lipsyncs_v2/post-apilipsyncs\n   */\n  export interface LipsyncV2Params {\n    /**\n     * Array of video input configurations\n     */\n    video_inputs: {\n      /**\n       * Character configuration\n       */\n      character: {\n        /**\n         * Type of character (always \"avatar\" for now)\n         */\n        type: 'avatar';\n\n        /**\n         * Avatar ID to use\n         */\n        avatar_id: string;\n\n        /**\n         * Avatar style (e.g., \"normal\")\n         */\n        avatar_style: string;\n\n        /**\n         * Position offset of the avatar\n         */\n        offset?: {\n          x: number;\n          y: number;\n        };\n      };\n\n      /**\n       * Voice configuration\n       */\n      voice: {\n        /**\n         * Type of voice input (always \"text\" for now)\n         */\n        type: 'text';\n\n        /**\n         * Text to be spoken\n         */\n        input_text: string;\n\n        /**\n         * Voice ID to use\n         */\n        voice_id: string;\n      };\n\n      /**\n       * Background configuration\n       */\n      background: {\n        /**\n         * Type of background (always \"image\" for now)\n         */\n        type: 'image';\n\n        /**\n         * URL of the background image\n         */\n        url: string;\n      };\n\n      /**\n       * Caption settings\n       */\n      caption_setting?: {\n        /**\n         * Style of the caption\n         */\n        style: string;\n\n        /**\n         * Position offset of the caption\n         */\n        offset?: {\n          x: number;\n          y: number;\n        };\n      };\n    }[];\n\n    /**\n     * Aspect ratio of the generated video\n     */\n    aspect_ratio: AspectRatio;\n\n    /**\n     * Webhook URL to be called when the video is ready (optional)\n     */\n    webhook_url?: string;\n  }\n\n  /**\n   * Response when creating a lipsync v2 task\n   */\n  export interface LipsyncV2Response extends ApiResponse {\n    /**\n     * ID of the created lipsync v2 task\n     */\n    id: string;\n\n    /**\n     * Status of the lipsync v2 task\n     */\n    status: TaskStatus;\n  }\n\n  /**\n   * Response when getting a lipsync v2 task\n   */\n  export interface LipsyncV2ResultResponse extends LipsyncV2Response {\n    /**\n     * Output URL of the generated video (only available when status is 'done')\n     */\n    output?: string;\n\n    /**\n     * Error message if the task failed\n     */\n    error_message?: string;\n\n    /**\n     * Created timestamp\n     */\n    created_at: string;\n\n    /**\n     * Updated timestamp\n     */\n    updated_at: string;\n\n    /**\n     * Video thumbnail URL\n     */\n    video_thumbnail?: string;\n\n    /**\n     * Number of credits used for this video\n     */\n    credits_used?: number;\n\n    /**\n     * Progress indication (e.g., percentage)\n     */\n    progress?: string;\n  }\n\n  /**\n   * Parameters for generating a preview of lipsync v2\n   */\n  export interface LipsyncV2PreviewParams {\n    /**\n     * ID of the lipsync v2 task\n     */\n    id: string;\n  }\n\n  /**\n   * Parameters for rendering a lipsync v2 task\n   */\n  export interface LipsyncV2RenderParams {\n    /**\n     * ID of the lipsync v2 task\n     */\n    id: string;\n  }\n}\n\nexport namespace DYOA {\n  /**\n   * Age group options for DYOA\n   */\n  export type AgeGroup = 'young_adult' | 'adult' | 'middle_aged' | 'senior';\n\n  /**\n   * Gender options for DYOA\n   */\n  export type Gender = 'm' | 'f' | 'other';\n\n  /**\n   * Status options for DYOA\n   */\n  export type DyoaStatus =\n    | 'initializing'\n    | 'draft'\n    | 'pending'\n    | 'approved'\n    | 'rejected'\n    | 'done'\n    | 'error';\n\n  /**\n   * Status options for DYOA review\n   */\n  export type DyoaReviewStatus = 'pending' | 'approved' | 'rejected';\n\n  /**\n   * Photo information for DYOA\n   */\n  export interface DyoaPhoto {\n    /**\n     * Unique identifier for the photo\n     */\n    id: string;\n\n    /**\n     * URL to the photo image\n     */\n    image: string;\n\n    /**\n     * Creation timestamp\n     */\n    created_at: string;\n  }\n\n  /**\n   * Review information for DYOA\n   */\n  export interface DyoaReview {\n    /**\n     * Unique identifier for the review\n     */\n    id: string;\n\n    /**\n     * Status of the review\n     */\n    status: DyoaReviewStatus;\n\n    /**\n     * Comment from the reviewer (optional)\n     */\n    comment: string | null;\n\n    /**\n     * Photo being reviewed\n     */\n    photo: DyoaPhoto;\n\n    /**\n     * Avatar creator ID (only available after approval)\n     */\n    creator: string | null;\n\n    /**\n     * Social link for the avatar (optional)\n     */\n    social_link: string | null;\n  }\n\n  /**\n   * Parameters for creating a DYOA\n   */\n  export interface DyoaParams {\n    /**\n     * Name for the avatar\n     */\n    name: string;\n\n    /**\n     * Age group of the avatar\n     */\n    age_group: AgeGroup;\n\n    /**\n     * Gender of the avatar\n     */\n    gender: Gender;\n\n    /**\n     * Detailed description of the avatar's appearance\n     */\n    more_details: string;\n\n    /**\n     * Description of the avatar's outfit\n     */\n    outfit_description: string;\n\n    /**\n     * Description of the avatar's background\n     */\n    background_description: string;\n  }\n\n  /**\n   * Parameters for submitting a DYOA for review\n   */\n  export interface DyoaSubmitParams {\n    /**\n     * ID of the chosen photo to use for the avatar\n     */\n    chosen_photo_id: string;\n  }\n\n  /**\n   * Response containing DYOA information\n   */\n  export interface DyoaResponse {\n    /**\n     * Unique identifier for the DYOA\n     */\n    id: string;\n\n    /**\n     * User ID of the creator\n     */\n    user: number;\n\n    /**\n     * Workspace ID\n     */\n    workspace: string;\n\n    /**\n     * Name of the avatar\n     */\n    name: string;\n\n    /**\n     * Age group of the avatar\n     */\n    age_group: AgeGroup;\n\n    /**\n     * Gender of the avatar\n     */\n    gender: Gender;\n\n    /**\n     * Detailed description of the avatar's appearance\n     */\n    more_details: string;\n\n    /**\n     * Description of the avatar's outfit\n     */\n    outfit_description: string;\n\n    /**\n     * Description of the avatar's background\n     */\n    background_description: string;\n\n    /**\n     * Array of generated photos\n     */\n    photos: DyoaPhoto[];\n\n    /**\n     * Array of reviews\n     */\n    reviews: DyoaReview[];\n\n    /**\n     * Status of the DYOA\n     */\n    status: DyoaStatus;\n\n    /**\n     * Creation timestamp\n     */\n    created_at: string;\n\n    /**\n     * Last update timestamp\n     */\n    updated_at: string;\n  }\n}\n","import { CreatifyApiClient } from './client';\nimport { apiClientFactory } from './client-factory';\nimport {\n  AvatarApi,\n  UrlToVideoApi,\n  TextToSpeechApi,\n  AiEditingApi,\n  CustomTemplatesApi,\n  DyoaApi,\n  AiShortsApi,\n  AiScriptsApi,\n  MusicsApi,\n  WorkspaceApi,\n  LipsyncV2Api,\n} from './api';\nimport * as Types from './types';\nimport * as utils from './utils';\n\n/**\n * Main Creatify API client with all API modules\n */\nexport class Creatify {\n  /**\n   * Client options\n   */\n  private options: Types.CreatifyApiOptions;\n\n  /**\n   * Avatar API module\n   */\n  public avatar: AvatarApi;\n\n  /**\n   * URL-to-Video API module\n   */\n  public urlToVideo: UrlToVideoApi;\n\n  /**\n   * Text-to-Speech API module\n   */\n  public textToSpeech: TextToSpeechApi;\n\n  /**\n   * AI Editing API module\n   */\n  public aiEditing: AiEditingApi;\n\n  /**\n   * Custom Templates API module\n   */\n  public customTemplates: CustomTemplatesApi;\n\n  /**\n   * DYOA (Design Your Own Avatar) API module\n   */\n  public dyoa: DyoaApi;\n\n  /**\n   * AI Shorts API module\n   */\n  public aiShorts: AiShortsApi;\n\n  /**\n   * AI Scripts API module\n   */\n  public aiScripts: AiScriptsApi;\n\n  /**\n   * Musics API module\n   */\n  public musics: MusicsApi;\n\n  /**\n   * Workspace API module\n   */\n  public workspace: WorkspaceApi;\n\n  /**\n   * Lipsync v2 API module\n   */\n  public lipsyncV2: LipsyncV2Api;\n\n  /**\n   * Create a new Creatify API client with all available API modules\n   * @param options Configuration options for the API client\n   */\n  constructor(options: Types.CreatifyApiOptions) {\n    this.options = options;\n    this.avatar = new AvatarApi(options, apiClientFactory);\n    this.urlToVideo = new UrlToVideoApi(options, apiClientFactory);\n    this.textToSpeech = new TextToSpeechApi(options, apiClientFactory);\n    this.aiEditing = new AiEditingApi(options, apiClientFactory);\n    this.customTemplates = new CustomTemplatesApi(options, apiClientFactory);\n    this.dyoa = new DyoaApi(options, apiClientFactory);\n    this.aiShorts = new AiShortsApi(options, apiClientFactory);\n    this.aiScripts = new AiScriptsApi(options, apiClientFactory);\n    this.musics = new MusicsApi(options, apiClientFactory);\n    this.workspace = new WorkspaceApi(options, apiClientFactory);\n    this.lipsyncV2 = new LipsyncV2Api(options, apiClientFactory);\n  }\n}\n\n// Export types\nexport { Types };\n\n// Export individual API classes\nexport {\n  CreatifyApiClient,\n  AvatarApi,\n  UrlToVideoApi,\n  TextToSpeechApi,\n  AiEditingApi,\n  CustomTemplatesApi,\n  DyoaApi,\n  AiShortsApi,\n  AiScriptsApi,\n  MusicsApi,\n  WorkspaceApi,\n  LipsyncV2Api,\n};\n\n// Export client factory\nexport { apiClientFactory, CreatifyApiClientFactory } from './client-factory';\n\n// Export utility classes\nexport { utils };\n","import { Creatify } from '../index';\nimport { AvatarApi } from '../api';\nimport { CreatifyApiOptions, Avatar, TextToSpeech, AspectRatio } from '../types';\nimport { apiClientFactory } from '../client-factory';\nimport { ICreatifyApiClientFactory } from '../types/api-client';\n\n/**\n * A utility class to simplify avatar video creation\n */\nexport class VideoCreator {\n  private creatify: Creatify;\n  private avatarApi: AvatarApi;\n  private avatarCache: Record<string, Avatar.AvatarInfo> = {};\n  private voiceCache: Record<string, TextToSpeech.Voice> = {};\n  private avatarsLoaded = false;\n  private voicesLoaded = false;\n\n  /**\n   * Create a new VideoCreator instance\n   * @param apiIdOrOptions Your Creatify API ID or options object\n   * @param apiKey Your Creatify API Key (optional if options object is used)\n   * @param clientFactory Optional factory for creating API clients (useful for testing)\n   */\n  constructor(\n    apiIdOrOptions: string | CreatifyApiOptions,\n    apiKey?: string,\n    clientFactory: ICreatifyApiClientFactory = apiClientFactory\n  ) {\n    const options: CreatifyApiOptions =\n      typeof apiIdOrOptions === 'string'\n        ? { apiId: apiIdOrOptions, apiKey: apiKey || '' }\n        : apiIdOrOptions;\n\n    this.creatify = new Creatify(options);\n    // Create a separate AvatarApi that uses the provided clientFactory\n    this.avatarApi = new AvatarApi(options, clientFactory);\n  }\n\n  /**\n   * Preload avatars and voices for faster video creation\n   */\n  async preload() {\n    await Promise.all([this.loadAvatars(), this.loadVoices()]);\n\n    return {\n      avatars: Object.keys(this.avatarCache).length,\n      voices: Object.keys(this.voiceCache).length,\n    };\n  }\n\n  /**\n   * Load and cache all available avatars\n   */\n  async loadAvatars() {\n    if (this.avatarsLoaded) return Object.values(this.avatarCache);\n\n    const avatars = await this.avatarApi.getAvatars();\n\n    for (const avatar of avatars) {\n      this.avatarCache[avatar.id] = avatar;\n    }\n\n    this.avatarsLoaded = true;\n    return avatars;\n  }\n\n  /**\n   * Load and cache all available voices\n   */\n  async loadVoices() {\n    if (this.voicesLoaded) return Object.values(this.voiceCache);\n\n    const voices = await this.avatarApi.getVoices();\n\n    for (const voice of voices) {\n      this.voiceCache[voice.voice_id] = voice;\n    }\n\n    this.voicesLoaded = true;\n    return voices;\n  }\n\n  /**\n   * Find an avatar by name (partial match)\n   * @param name Avatar name to search for\n   */\n  async findAvatarByName(name: string) {\n    if (!this.avatarsLoaded) {\n      await this.loadAvatars();\n    }\n\n    const normalizedName = name.toLowerCase();\n\n    return Object.values(this.avatarCache).find(avatar =>\n      avatar.name?.toLowerCase().includes(normalizedName)\n    );\n  }\n\n  /**\n   * Find a voice by name (partial match)\n   * @param name Voice name to search for\n   */\n  async findVoiceByName(name: string) {\n    if (!this.voicesLoaded) {\n      await this.loadVoices();\n    }\n\n    const normalizedName = name.toLowerCase();\n\n    return Object.values(this.voiceCache).find(voice =>\n      voice.name?.toLowerCase().includes(normalizedName)\n    );\n  }\n\n  /**\n   * Create a video with a single avatar speaking\n   * @param options Configuration options for the video\n   * @returns The URL of the generated video\n   */\n  async createVideo(options: {\n    avatarName?: string;\n    avatarId?: string;\n    voiceName?: string;\n    voiceId?: string;\n    script: string;\n    aspectRatio?: string;\n    pollInterval?: number;\n    maxPollingAttempts?: number;\n  }) {\n    try {\n      // Default values\n      const pollInterval = options.pollInterval || 5000;\n      const maxPollingAttempts = options.maxPollingAttempts || 30;\n      const aspectRatio = options.aspectRatio || '16:9';\n\n      // Resolve avatar ID\n      let avatarId = options.avatarId;\n      if (!avatarId && options.avatarName) {\n        const avatar = await this.findAvatarByName(options.avatarName);\n        if (!avatar) {\n          throw new Error(`Avatar with name \"${options.avatarName}\" not found`);\n        }\n        avatarId = avatar.avatar_id;\n      }\n\n      if (!avatarId) {\n        // If no avatar specified, use the first available one\n        const avatars = await this.loadAvatars();\n        if (avatars.length === 0) {\n          throw new Error('No avatars available. Please check your API credentials.');\n        }\n        avatarId = avatars[0].avatar_id;\n      }\n\n      // Resolve voice ID\n      let voiceId = options.voiceId;\n      if (!voiceId && options.voiceName) {\n        const voice = await this.findVoiceByName(options.voiceName);\n        if (!voice) {\n          throw new Error(`Voice with name \"${options.voiceName}\" not found`);\n        }\n        voiceId = voice.voice_id;\n      }\n\n      // Create the lipsync video\n      const lipsyncResponse = await this.avatarApi.createLipsync({\n        text: options.script,\n        creator: avatarId || '',\n        aspect_ratio: aspectRatio as AspectRatio,\n        voice_id: voiceId,\n      });\n\n      // Ensure we have a valid response ID\n      if (!lipsyncResponse || !lipsyncResponse.id) {\n        throw new Error('Failed to create lipsync video: Invalid response from API');\n      }\n\n      // Poll for completion\n      let lipsyncResult = await this.avatarApi.getLipsync(lipsyncResponse.id);\n      let attempts = 0;\n\n      while (\n        lipsyncResult.status !== 'done' &&\n        lipsyncResult.status !== 'error' &&\n        attempts < maxPollingAttempts\n      ) {\n        // Wait between checks\n        await new Promise(resolve => setTimeout(resolve, pollInterval));\n\n        // Check status again\n        lipsyncResult = await this.avatarApi.getLipsync(lipsyncResponse.id);\n        attempts++;\n      }\n\n      // Check final result\n      if (lipsyncResult.status === 'done' && lipsyncResult.output) {\n        return {\n          id: lipsyncResponse.id,\n          status: 'done',\n          url: lipsyncResult.output,\n        };\n      } else {\n        throw new Error(\n          lipsyncResult.error_message ||\n            `Video generation failed or timed out. Status: ${lipsyncResult.status}`\n        );\n      }\n    } catch (error: unknown) {\n      // Ensure the error is properly thrown with the original message\n      if (error instanceof Error) {\n        throw error;\n      } else if (typeof error === 'object' && error !== null && 'message' in error && typeof error.message === 'string') {\n        throw new Error(error.message);\n      } else {\n        throw new Error('An error occurred with the API request');\n      }\n    }\n  }\n\n  /**\n   * Create a video with multiple avatars having a conversation\n   * @param options Configuration options for the conversation\n   * @returns The URL of the generated video\n   */\n  async createConversation(options: {\n    conversation: Array<{\n      avatarName?: string;\n      avatarId?: string;\n      voiceName?: string;\n      voiceId?: string;\n      text: string;\n    }>;\n    backgroundUrl?: string;\n    aspectRatio?: string;\n    pollInterval?: number;\n    maxPollingAttempts?: number;\n  }) {\n    try {\n      const conversations = options.conversation;\n      // Default values\n      const pollInterval = options.pollInterval || 5000;\n      const maxPollingAttempts = options.maxPollingAttempts || 30;\n      const aspectRatio = options.aspectRatio || '16:9';\n      const backgroundUrl = options.backgroundUrl || 'https://video.creatify.ai/bg.jpg';\n\n      // Prepare video inputs\n      const videoInputs = [];\n\n      for (const conversation of conversations) {\n        // Resolve avatar ID\n        let avatarId = conversation.avatarId;\n        if (!avatarId && conversation.avatarName) {\n          const avatar = await this.findAvatarByName(conversation.avatarName);\n          if (!avatar) {\n            throw new Error(`Avatar with name \"${conversation.avatarName}\" not found`);\n          }\n          avatarId = avatar.avatar_id;\n        }\n\n        if (!avatarId) {\n          // If no avatar specified, use the first available one\n          const avatars = await this.loadAvatars();\n          if (avatars.length === 0) {\n            throw new Error('No avatars available. Please check your API credentials.');\n          }\n          avatarId = avatars[0].avatar_id;\n        }\n\n        // Resolve voice ID\n        let voiceId = conversation.voiceId;\n        if (!voiceId && conversation.voiceName) {\n          const voice = await this.findVoiceByName(conversation.voiceName);\n          if (!voice) {\n            throw new Error(`Voice with name \"${conversation.voiceName}\" not found`);\n          }\n          voiceId = voice.voice_id;\n        }\n\n        videoInputs.push({\n          character: {\n            type: 'avatar' as const,\n            avatar_id: avatarId || '',\n            avatar_style: 'normal',\n            offset: { x: -0.23, y: 0.35 },\n          },\n          voice: {\n            type: 'text' as const,\n            input_text: conversation.text,\n            voice_id: voiceId || '',\n          },\n          background: {\n            type: 'image' as const,\n            url: backgroundUrl,\n          },\n          caption_setting: {\n            style: 'normal-black',\n            offset: { x: 0, y: 0.45 },\n          },\n        });\n      }\n\n      // Create the multi-avatar lipsync video\n      const multiAvatarResponse = await this.avatarApi.createMultiAvatarLipsync({\n        video_inputs: videoInputs,\n        aspect_ratio: aspectRatio as AspectRatio,\n      });\n\n      // Ensure we have a valid response ID\n      if (!multiAvatarResponse || !multiAvatarResponse.id) {\n        throw new Error('Failed to create multi-avatar lipsync video: Invalid response from API');\n      }\n\n      // Poll for completion\n      let result = await this.avatarApi.getLipsync(multiAvatarResponse.id);\n      let attempts = 0;\n\n      while (\n        result.status !== 'done' &&\n        result.status !== 'error' &&\n        attempts < maxPollingAttempts\n      ) {\n        // Wait between checks\n        await new Promise(resolve => setTimeout(resolve, pollInterval));\n\n        // Check status again\n        result = await this.avatarApi.getLipsync(multiAvatarResponse.id);\n        attempts++;\n      }\n\n      // Check final result\n      if (result.status === 'done' && result.output) {\n        return {\n          id: multiAvatarResponse.id,\n          status: 'done',\n          url: result.output,\n        };\n      } else {\n        throw new Error(\n          result.error_message || `Video generation failed or timed out. Status: ${result.status}`\n        );\n      }\n    } catch (error: unknown) {\n      // Ensure the error is properly thrown with the original message\n      if (error instanceof Error) {\n        throw error;\n      } else if (typeof error === 'object' && error !== null && 'message' in error && typeof error.message === 'string') {\n        throw new Error(error.message);\n      } else {\n        throw new Error('An error occurred with the API request');\n      }\n    }\n  }\n}\n","import { TextToSpeechApi } from '../api/text-to-speech';\nimport { TextToSpeech, CreatifyApiOptions } from '../types';\n\n/**\n * Utility class for processing audio with the Creatify Text-to-Speech API\n */\nexport class AudioProcessor {\n  private api: TextToSpeechApi;\n\n  /**\n   * Create a new AudioProcessor\n   * @param apiIdOrOptions API ID or full options object\n   * @param apiKey API key (only required if apiIdOrOptions is a string)\n   */\n  constructor(apiIdOrOptions: string | CreatifyApiOptions, apiKey?: string) {\n    // Handle different constructor argument formats\n    const options: CreatifyApiOptions =\n      typeof apiIdOrOptions === 'string'\n        ? { apiId: apiIdOrOptions, apiKey: apiKey! }\n        : apiIdOrOptions;\n\n    this.api = new TextToSpeechApi(options);\n  }\n\n  /**\n   * Generate audio from text\n   * @param script Text to convert to speech\n   * @param accentId Voice/accent ID to use\n   * @param waitForCompletion Whether to wait for the task to complete (default: true)\n   * @returns Promise resolving to the audio task result or response\n   */\n  async generateAudio(\n    script: string,\n    accentId: string,\n    waitForCompletion = true\n  ): Promise<TextToSpeech.TextToSpeechResultResponse | TextToSpeech.TextToSpeechResponse> {\n    const params: TextToSpeech.TextToSpeechParams = {\n      script,\n      accent: accentId,\n    };\n\n    if (waitForCompletion) {\n      return this.api.createAndWaitForTextToSpeech(params);\n    } else {\n      return this.api.createTextToSpeech(params);\n    }\n  }\n\n  /**\n   * Check the status of an audio generation task\n   * @param id ID of the text-to-speech task\n   * @returns Promise resolving to the task status and result\n   */\n  async checkAudioStatus(id: string): Promise<TextToSpeech.TextToSpeechResultResponse> {\n    return this.api.getTextToSpeech(id);\n  }\n\n  /**\n   * Poll for audio generation completion\n   * @param id ID of the text-to-speech task\n   * @param pollInterval Interval in ms between status checks (default: 2000)\n   * @param maxAttempts Maximum number of polling attempts (default: 60)\n   * @returns Promise resolving to the final task result\n   */\n  async waitForAudioCompletion(\n    id: string,\n    pollInterval = 2000,\n    maxAttempts = 60\n  ): Promise<TextToSpeech.TextToSpeechResultResponse> {\n    let attempts = 0;\n    let result = await this.api.getTextToSpeech(id);\n\n    while (attempts < maxAttempts && result.status !== 'done' && result.status !== 'error') {\n      // Wait for the specified interval\n      await new Promise(resolve => setTimeout(resolve, pollInterval));\n\n      // Check the status again\n      result = await this.api.getTextToSpeech(id);\n      attempts++;\n    }\n\n    // Check if we reached max attempts without completion\n    if (attempts >= maxAttempts && result.status !== 'done' && result.status !== 'error') {\n      throw new Error(`Audio generation task ${id} did not complete within the timeout period`);\n    }\n\n    return result;\n  }\n\n  /**\n   * List all audio generation tasks\n   * @returns Promise resolving to an array of tasks\n   */\n  async listAudioTasks(): Promise<TextToSpeech.TextToSpeechResultResponse[]> {\n    return this.api.getTextToSpeechList();\n  }\n}\n","import { Creatify } from '../index';\nimport { CreatifyApiOptions, AspectRatio, AiEditing, LipsyncV2 } from '../types';\nimport { apiClientFactory } from '../client-factory';\n\n/**\n * Batch processing options\n */\nexport interface BatchProcessingOptions {\n  /**\n   * Maximum number of concurrent tasks (default: 3)\n   */\n  concurrency?: number;\n\n  /**\n   * Whether to continue processing if one task fails (default: false)\n   */\n  continueOnError?: boolean;\n\n  /**\n   * Delay between starting new tasks in milliseconds (default: 500)\n   */\n  taskStartDelay?: number;\n\n  /**\n   * Maximum number of retries for failed tasks (default: 0)\n   */\n  maxRetries?: number;\n}\n\n/**\n * Default batch processing options\n */\nconst DEFAULT_BATCH_OPTIONS: Required<BatchProcessingOptions> = {\n  concurrency: 3,\n  continueOnError: false,\n  taskStartDelay: 500,\n  maxRetries: 0,\n};\n\n/**\n * Result of a batch processing operation\n */\nexport interface BatchResult<T> {\n  /**\n   * Array of successful results\n   */\n  successes: T[];\n\n  /**\n   * Array of errors, with the index of the task that failed\n   */\n  errors: Array<{ index: number; error: Error | unknown }>;\n\n  /**\n   * Whether all tasks were successful\n   */\n  allSuccessful: boolean;\n}\n\n/**\n * Utility class for processing multiple API tasks in batch\n */\nexport class BatchProcessor {\n  private api: Creatify;\n\n  /**\n   * Create a new BatchProcessor\n   * @param apiIdOrOptions API ID or full options object\n   * @param apiKey API key (only required if apiIdOrOptions is a string)\n   * @param clientFactory Optional client factory for testing purposes\n   */\n  constructor(\n    apiIdOrOptions: string | CreatifyApiOptions,\n    apiKey?: string,\n    _clientFactory = apiClientFactory\n  ) {\n    // Handle different constructor argument formats\n    const options: CreatifyApiOptions =\n      typeof apiIdOrOptions === 'string'\n        ? { apiId: apiIdOrOptions, apiKey: apiKey! }\n        : apiIdOrOptions;\n\n    this.api = new Creatify(options);\n  }\n\n  /**\n   * Process an array of tasks in batch with controlled concurrency\n   * @param tasks Array of async functions to execute\n   * @param options Batch processing options\n   * @returns Promise resolving to the batch result\n   */\n  async processBatch<T>(\n    tasks: Array<() => Promise<T>>,\n    options: BatchProcessingOptions = {}\n  ): Promise<BatchResult<T>> {\n    // Merge options with defaults\n    const opts: Required<BatchProcessingOptions> = {\n      ...DEFAULT_BATCH_OPTIONS,\n      ...options,\n    };\n\n    const result: BatchResult<T> = {\n      successes: [],\n      errors: [],\n      allSuccessful: true,\n    };\n\n    // Keep track of active tasks\n    let activeTasks = 0;\n    let taskIndex = 0;\n\n    // Create a queue of promises to resolve when all tasks are complete\n    const queue: Promise<void>[] = [];\n\n    // Process tasks\n    while (taskIndex < tasks.length) {\n      // Wait until we have an available slot\n      if (activeTasks >= opts.concurrency) {\n        await Promise.race(queue);\n        continue;\n      }\n\n      // Start a task\n      const currentIndex = taskIndex++;\n      activeTasks++;\n\n      // Define and create the task promise\n      const taskPromise = (async () => {\n        try {\n          // Add delay between task starts if specified\n          if (opts.taskStartDelay > 0 && currentIndex > 0) {\n            await new Promise(resolve => setTimeout(resolve, opts.taskStartDelay));\n          }\n\n          // Execute the task with retries\n          let taskResult;\n          let lastError;\n          let retryCount = 0;\n\n          while (retryCount <= opts.maxRetries) {\n            try {\n              taskResult = await tasks[currentIndex]();\n              break; // Success, exit the retry loop\n            } catch (error) {\n              lastError = error;\n              retryCount++;\n\n              if (retryCount <= opts.maxRetries) {\n                // Wait before retrying (exponential backoff)\n                const retryDelay = Math.min(1000 * Math.pow(2, retryCount - 1), 30000);\n                await new Promise(resolve => setTimeout(resolve, retryDelay));\n                console.warn(`Retrying task ${currentIndex}, attempt ${retryCount} of ${opts.maxRetries}`);\n              }\n            }\n          }\n\n          if (taskResult) {\n            result.successes.push(taskResult);\n          } else {\n            // All retries failed\n            result.errors.push({ index: currentIndex, error: lastError });\n            result.allSuccessful = false;\n\n            // Handle error based on options\n            if (!opts.continueOnError) {\n              throw lastError;\n            }\n          }\n        } catch (error) {\n          // This catch block handles unexpected errors in the retry logic itself\n          result.errors.push({ index: currentIndex, error });\n          result.allSuccessful = false;\n\n          // Handle error based on options\n          if (!opts.continueOnError) {\n            throw error;\n          }\n        } finally {\n          // Decrease active task count\n          activeTasks--;\n\n          // Remove this promise from the queue - find it by filtering instead of using indexOf\n          const taskIndex = queue.findIndex(p => p === taskPromise);\n          if (taskIndex !== -1) {\n            queue.splice(taskIndex, 1);\n          }\n        }\n      })();\n\n      // Add to queue\n      queue.push(taskPromise);\n\n      // If we should stop on error and an error occurs, break out of the loop\n      if (!opts.continueOnError && !result.allSuccessful) {\n        break;\n      }\n    }\n\n    // Wait for all remaining tasks to complete\n    if (queue.length > 0) {\n      await Promise.all(queue).catch(error => {\n        // If continueOnError is false, this error will have already been recorded\n        // But we need to catch it here to prevent it from bubbling up\n        if (opts.continueOnError) {\n          console.error('Unexpected error in batch processing:', error);\n        }\n      });\n    }\n\n    return result;\n  }\n\n  /**\n   * Process an array of avatar video creation tasks in batch\n   * @param avatarTasks Array of avatar tasks with text and avatarId\n   * @param options Batch processing options\n   * @returns Promise resolving to the batch result\n   */\n  async processAvatarBatch(\n    avatarTasks: Array<{ text: string; avatarId: string; voiceId?: string; aspectRatio?: string }>,\n    options: BatchProcessingOptions = {}\n  ) {\n    const tasks = avatarTasks.map(task => {\n      return async () => {\n        return this.api.avatar.createAndWaitForLipsync({\n          text: task.text,\n          creator: task.avatarId,\n          voice_id: task.voiceId,\n          aspect_ratio: task.aspectRatio as AspectRatio,\n        });\n      };\n    });\n\n    return this.processBatch(tasks, options);\n  }\n\n  /**\n   * Process an array of text-to-speech tasks in batch\n   * @param textToSpeechTasks Array of text-to-speech tasks with script and accent\n   * @param options Batch processing options\n   * @returns Promise resolving to the batch result\n   */\n  async processTextToSpeechBatch(\n    textToSpeechTasks: Array<{ script: string; accent: string }>,\n    options: BatchProcessingOptions = {}\n  ) {\n    const tasks = textToSpeechTasks.map(task => {\n      return async () => {\n        return this.api.textToSpeech.createAndWaitForTextToSpeech({\n          script: task.script,\n          accent: task.accent,\n        });\n      };\n    });\n\n    return this.processBatch(tasks, options);\n  }\n\n  /**\n   * Process an array of AI editing tasks in batch\n   * @param aiEditingTasks Array of AI editing tasks with videoUrl and editingStyle\n   * @param options Batch processing options\n   * @returns Promise resolving to the batch result\n   */\n  async processAiEditingBatch(\n    aiEditingTasks: Array<{ videoUrl: string; editingStyle: string }>,\n    options: BatchProcessingOptions = {}\n  ) {\n    const tasks = aiEditingTasks.map(task => {\n      return async () => {\n        return this.api.aiEditing.createAndWaitForAiEditing({\n          video_url: task.videoUrl,\n          editing_style: task.editingStyle as AiEditing.EditingStyle,\n        });\n      };\n    });\n\n    return this.processBatch(tasks, options);\n  }\n\n  /**\n   * Process an array of AI Shorts tasks in batch\n   * @param aiShortsTasks Array of AI Shorts tasks with prompt and aspectRatio\n   * @param options Batch processing options\n   * @returns Promise resolving to the batch result\n   */\n  async processAiShortsBatch(\n    aiShortsTasks: Array<{\n      prompt: string;\n      aspectRatio: string;\n      targetPlatform?: string;\n      targetAudience?: string;\n      language?: string;\n    }>,\n    options: BatchProcessingOptions = {}\n  ) {\n    const tasks = aiShortsTasks.map(task => {\n      return async () => {\n        return this.api.aiShorts.createAndWaitForAiShorts({\n          prompt: task.prompt,\n          aspect_ratio: task.aspectRatio as AspectRatio,\n          target_platform: task.targetPlatform,\n          target_audience: task.targetAudience,\n          language: task.language,\n        });\n      };\n    });\n\n    return this.processBatch(tasks, options);\n  }\n\n  /**\n   * Process an array of AI Scripts tasks in batch\n   * @param aiScriptsTasks Array of AI Scripts tasks with prompt and other optional parameters\n   * @param options Batch processing options\n   * @returns Promise resolving to the batch result\n   */\n  async processAiScriptsBatch(\n    aiScriptsTasks: Array<{\n      prompt: string;\n      targetPlatform?: string;\n      targetAudience?: string;\n      language?: string;\n      scriptLength?: number;\n    }>,\n    options: BatchProcessingOptions = {}\n  ) {\n    const tasks = aiScriptsTasks.map(task => {\n      return async () => {\n        return this.api.aiScripts.createAndWaitForAiScript({\n          prompt: task.prompt,\n          target_platform: task.targetPlatform,\n          target_audience: task.targetAudience,\n          language: task.language,\n          script_length: task.scriptLength,\n        });\n      };\n    });\n\n    return this.processBatch(tasks, options);\n  }\n\n  /**\n   * Process an array of Lipsync v2 tasks in batch\n   * @param lipsyncV2Tasks Array of Lipsync v2 tasks with videoInputs and aspectRatio\n   * @param options Batch processing options\n   * @returns Promise resolving to the batch result\n   */\n  async processLipsyncV2Batch(\n    lipsyncV2Tasks: Array<{ videoInputs: Record<string, unknown>[]; aspectRatio: string }>,\n    options: BatchProcessingOptions = {}\n  ) {\n    const tasks = lipsyncV2Tasks.map(task => {\n      return async () => {\n        return this.api.lipsyncV2.createAndWaitForLipsyncV2({\n          video_inputs: task.videoInputs as LipsyncV2.LipsyncV2Params['video_inputs'],\n          aspect_ratio: task.aspectRatio as AspectRatio,\n        });\n      };\n    });\n\n    return this.processBatch(tasks, options);\n  }\n}\n"]}