import type {WebpackConfiguration} from '@remotion/bundler';
import type {
	BrowserExecutable,
	ChromeMode,
	CodecOrUndefined,
	ColorSpace,
	Crf,
	DeleteAfter,
	FrameRange,
	NumberOfGifLoops,
	StillImageFormat,
	VideoImageFormat,
} from '@remotion/renderer';
import type {HardwareAccelerationOption} from '@remotion/renderer/client';
import {BrowserSafeApis} from '@remotion/renderer/client';
import {StudioServerInternals} from '@remotion/studio-server';
import {getBrowser} from './browser';
import {
	getBufferStateDelayInMilliseconds,
	setBufferStateDelayInMilliseconds,
} from './buffer-state-delay-in-milliseconds';
import {getConcurrency} from './concurrency';
import type {Concurrency} from './concurrency';
import {getEntryPoint, setEntryPoint} from './entry-point';
import {getDotEnvLocation} from './env-file';
import {
	getFfmpegOverrideFunction,
	setFfmpegOverrideFunction,
} from './ffmpeg-override';
import {getShouldOutputImageSequence} from './image-sequence';
import {getMetadata, setMetadata} from './metadata';
import {getOutputLocation} from './output-location';
import {setOutputLocation} from './output-location';
import {
	defaultOverrideFunction,
	getWebpackOverrideFn,
} from './override-webpack';
import type {WebpackOverrideFn} from './override-webpack';
import {overrideWebpackConfig} from './override-webpack';
import {
	getRendererPortFromConfigFile,
	getRendererPortFromConfigFileAndCliFlag,
	getStudioPort,
} from './preview-server';
import {setPort, setRendererPort, setStudioPort} from './preview-server';
import {getStillFrame, setStillFrame} from './still-frame';
import {getWebpackCaching} from './webpack-caching';
import {getWebpackPolling} from './webpack-poll';

export type {Concurrency, WebpackConfiguration, WebpackOverrideFn};

const {
	benchmarkConcurrenciesOption,
	concurrencyOption,
	offthreadVideoCacheSizeInBytesOption,
	x264Option,
	audioBitrateOption,
	videoBitrateOption,
	scaleOption,
	crfOption,
	jpegQualityOption,
	enforceAudioOption,
	overwriteOption,
	chromeModeOption,
	mutedOption,
	videoCodecOption,
	colorSpaceOption,
	disallowParallelEncodingOption,
	deleteAfterOption,
	folderExpiryOption,
	enableMultiprocessOnLinuxOption,
	glOption,
	headlessOption,
	numberOfGifLoopsOption,
	beepOnFinishOption,
	encodingMaxRateOption,
	encodingBufferSizeOption,
	reproOption,
	enableLambdaInsights,
	logLevelOption,
	delayRenderTimeoutInMillisecondsOption,
	publicDirOption,
	binariesDirectoryOption,
	preferLosslessOption,
	framesOption,
	forSeamlessAacConcatenationOption,
	audioCodecOption,
	publicPathOption,
	hardwareAccelerationOption,
	audioLatencyHintOption,
	enableCrossSiteIsolationOption,
	imageSequencePatternOption,
	darkModeOption,
	askAIOption,
	publicLicenseKeyOption,
	experimentalClientSideRenderingOption,
	experimentalVisualModeOption,
	keyboardShortcutsOption,
	forceNewStudioOption,
	numberOfSharedAudioTagsOption,
	ipv4Option,
	pixelFormatOption,
	browserExecutableOption,
	everyNthFrameOption,
	proResProfileOption,
	stillImageFormatOption,
	videoImageFormatOption,
	userAgentOption,
	disableWebSecurityOption,
	ignoreCertificateErrorsOption,
	overrideHeightOption,
	overrideWidthOption,
	overrideFpsOption,
	overrideDurationOption,
	rspackOption,
	outDirOption,
	webpackPollOption,
	imageSequenceOption,
	bundleCacheOption,
	envFileOption,
	runsOption,
	noOpenOption,
} = BrowserSafeApis.options;

declare global {
	interface RemotionBundlingOptions {
		/**
		 * Specify the entry point so you don't have to specify it in the
		 * CLI command
		 */
		readonly setEntryPoint: (src: string) => void;

		/**
		 * Whether Webpack bundles should be cached to make
		 * subsequent renders faster. Default: true
		 */
		readonly setCachingEnabled: (flag: boolean) => void;
		/**
		 * @deprecated
		 * Use `setStudioPort()` and `setRendererPort()` instead.
		 */
		readonly setPort: (port: number | undefined) => void;

		/**
		 * Set the HTTP port used by the Studio.
		 * By default, Remotion will try to find a free port.
		 * If you specify a port, but it's not available, Remotion will throw an error.
		 */
		readonly setStudioPort: (port: number | undefined) => void;

		/**
		 * Set the HTTP port used to host the Webpack bundle.
		 * By default, Remotion will try to find a free port.
		 * If you specify a port, but it's not available, Remotion will throw an error.
		 */
		readonly setRendererPort: (port: number | undefined) => void;
		/**
		 * Define the location of the public/ directory.
		 * By default it is a folder named "public" inside the current working directory.
		 * You can set an absolute path or a relative path that will be resolved from the closest package.json location.
		 */
		readonly setPublicDir: (publicDir: string | null) => void;
		readonly overrideWebpackConfig: (f: WebpackOverrideFn) => void;
	}
	// Legacy config format: New options to not need to be added here.
	interface RemotionConfigObject {
		/**
		 * Change the maximum amount of tracks that are shown in the timeline.
		 * @param maxTracks The maximum amount of timeline tracks that you would like to show.
		 * @default 15
		 */
		readonly setMaxTimelineTracks: (maxTracks: number) => void;
		/**
		 * Enable Keyboard shortcuts in the Remotion Studio.
		 * @param enabled Boolean whether to enable the keyboard shortcuts
		 * @default true
		 */
		readonly setKeyboardShortcutsEnabled: (enableShortcuts: boolean) => void;
		/**
		 * Enable WIP client-side rendering in the Remotion Studio.
		 * See https://www.remotion.dev/docs/client-side-rendering/ for notes.
		 * @param enabled Boolean whether to enable client-side rendering
		 * @default false
		 */
		readonly setExperimentalClientSideRenderingEnabled: (
			enabled: boolean,
		) => void;
		/**
		 * Enable experimental Rspack bundler instead of Webpack.
		 * @param enabled Boolean whether to enable the Rspack bundler
		 * @default false
		 */
		readonly setExperimentalRspackEnabled: (enabled: boolean) => void;
		/**
		 * Nothing here yet, but this is our playground for experiments.
		 * @param enabled Boolean whether to enable experimental visual mode
		 * @default false
		 */
		readonly setExperimentalVisualMode: (enabled: boolean) => void;
		/**
		 * Set number of shared audio tags. https://www.remotion.dev/docs/player/autoplay#using-the-numberofsharedaudiotags-prop
		 * @param numberOfAudioTags
		 * @default 0
		 */
		readonly setNumberOfSharedAudioTags: (numberOfAudioTags: number) => void;
		/**
		 * Enable Webpack polling instead of file system listeners for hot reloading in the Studio.
		 * This is useful if you are using a remote directory or a virtual machine.
		 * @param interval
		 * @default null
		 */
		readonly setWebpackPollingInMilliseconds: (interval: number | null) => void;
		/**
		 * Whether Remotion should open a browser when starting the Studio.
		 * @param should
		 * @default true
		 */
		readonly setShouldOpenBrowser: (should: boolean) => void;
		/**
		 * Set the log level.
		 * Acceptable values: 'error' | 'warning' | 'info' | 'verbose' | 'trace'
		 * Default value: 'info'
		 *
		 * Set this to 'verbose' to get browser logs and other IO.
		 */
		readonly setLevel: (
			newLogLevel: 'trace' | 'verbose' | 'info' | 'warn' | 'error',
		) => void;
		/**
		 * Specify executable path for the browser to use.
		 * Default: null, which will make Remotion find or download a version of said browser.
		 */
		readonly setBrowserExecutable: (
			newBrowserExecutablePath: BrowserExecutable,
		) => void;
		/**
		 * Set how many milliseconds a frame may take to render before it times out.
		 * Default: `30000`
		 */
		readonly setDelayRenderTimeoutInMilliseconds: (
			newPuppeteerTimeout: number,
		) => void;
		/**
		 * @deprecated Renamed to `setDelayRenderTimeoutInMilliseconds`.
		 * Set how many milliseconds a frame may take to render before it times out.
		 * Default: `30000`
		 */
		readonly setTimeoutInMilliseconds: (newPuppeteerTimeout: number) => void;
		/**
		 * Setting deciding whether to disable CORS and other Chrome security features.
		 * Default: false
		 */
		readonly setChromiumDisableWebSecurity: (should: boolean) => void;
		/**
		 * Setting whether to ignore any invalid SSL certificates, such as self-signed ones.
		 * Default: false
		 */
		readonly setChromiumIgnoreCertificateErrors: (should: boolean) => void;
		/**
		 * If false, will open an actual browser during rendering to observe progress.
		 * Default: true
		 */
		readonly setChromiumHeadlessMode: (should: boolean) => void;
		/**
		 * Set whether to use dark mode for Chrome.
		 * Default: false
		 */
		readonly setChromiumDarkMode: (should: boolean) => void;
		/**
		 * Set the OpenGL rendering backend for Chrome. Possible values: 'egl', 'angle', 'swiftshader', 'swangle', 'vulkan' and 'angle-egl'.
		 * Default: 'swangle' in Lambda, null elsewhere.
		 */
		readonly setChromiumOpenGlRenderer: (
			renderer:
				| 'swangle'
				| 'angle'
				| 'egl'
				| 'swiftshader'
				| 'vulkan'
				| 'angle-egl',
		) => void;
		/**
		 * Set the user agent for Chrome. Only works during rendering.
		 * Default is the default user agent for Chrome
		 */
		readonly setChromiumUserAgent: (userAgent: string | null) => void;
		/**
		 * Set a custom location for a .env file.
		 * Default: `.env`
		 */
		readonly setDotEnvLocation: (file: string) => void;
		/**
		 * Sets how many Puppeteer instances will work on rendering your video in parallel.
		 * Default: `null`, meaning half of the threads available on your CPU.
		 */
		readonly setConcurrency: (newConcurrency: Concurrency) => void;
		/**
		 * @deprecated Renamed to `setJpegQuality`.
		 */
		readonly setQuality: (q: never) => void;
		/**
		 * @deprecated Separated into `setStillImageFormat()` and `setVideoImageFormat()`.
		 */
		readonly setImageFormat: (q: never) => void;
		/**
		 * Set the JPEG quality for the frames.
		 * Must be between 0 and 100.
		 * Default: 80
		 */
		readonly setJpegQuality: (q: number | undefined) => void;
		/** Decide the image format for still renders.
		 */
		readonly setStillImageFormat: (format: StillImageFormat) => void;
		/** Decide in which image format to render. Can be either 'jpeg' or 'png'.
		 * PNG is slower, but supports transparency.
		 */
		readonly setVideoImageFormat: (format: VideoImageFormat) => void;
		/**
		 * Render only a subset of a video.
		 * Pass in a tuple [20, 30] to only render frames 20-30 into a video.
		 * Pass in a single number `20` to only render a single frame as an image.
		 * The frame count starts at 0.
		 */
		readonly setFrameRange: (newFrameRange: FrameRange | null) => void;
		/**
		 * Scales the output dimensions by a factor.
		 * Default: 1.
		 */
		readonly setScale: (newScale: number) => void;
		/**
		 * Specify which frames should be picked for rendering a GIF
		 * Default: 1, which means every frame
		 * https://remotion.dev/docs/render-as-gif
		 */
		readonly setEveryNthFrame: (frame: number) => void;
		/**
		 * Specify the number of Loop a GIF should have.
		 * Default: null (means GIF will loop infinite)
		 */
		readonly setNumberOfGifLoops: (newLoop: NumberOfGifLoops) => void;
		/**
		 * Disable audio output.
		 * Default: false
		 */
		readonly setMuted: (muted: boolean) => void;
		/**
		 * Don't render an audio track if it would be silent.
		 * Default: true
		 */
		readonly setEnforceAudioTrack: (enforceAudioTrack: boolean) => void;

		/**
		 * Prepare a video for later seamless audio concatenation.
		 * Default: false
		 */
		readonly setForSeamlessAacConcatenation: (
			forSeamlessAacConcatenation: boolean,
		) => void;

		/**
		 * Set the output file location string. Default: `out/{composition}.{codec}`
		 */
		readonly setOutputLocation: (newOutputLocation: string) => void;
		/**
		 * If the video file already exists, should Remotion overwrite
		 * the output? Default: true
		 */
		readonly setOverwriteOutput: (newOverwrite: boolean) => void;
		/**
		 * Sets the pixel format in FFmpeg.
		 * See https://trac.ffmpeg.org/wiki/Chroma%20Subsampling for an explanation.
		 * You can override this using the `--pixel-format` Cli flag.
		 */
		readonly setPixelFormat: (
			format:
				| 'yuv420p'
				| 'yuva420p'
				| 'yuv422p'
				| 'yuv444p'
				| 'yuv420p10le'
				| 'yuv422p10le'
				| 'yuv444p10le'
				| 'yuva444p10le',
		) => void;
		/**
		 * Specify the codec for stitching the frames into a video.
		 * Can be `h264` (default), `h265`, `vp8` or `vp9`
		 */
		readonly setCodec: (newCodec: CodecOrUndefined) => void;
		/**
		 * Set the Constant Rate Factor to pass to FFmpeg.
		 * Lower values mean better quality, but be aware that the ranges of
		 * possible values greatly differs between codecs.
		 */
		readonly setCrf: (newCrf: Crf) => void;
		/**
		 * Set to true if don't want a video but an image sequence as the output.
		 */
		readonly setImageSequence: (newImageSequence: boolean) => void;
		/**
		 * Overrides the height of a composition
		 */
		readonly overrideHeight: (newHeight: number) => void;
		/**
		 * Overrides the width of a composition
		 */
		readonly overrideWidth: (newWidth: number) => void;
		/**
		 * Overrides the FPS of a composition
		 */
		readonly overrideFps: (newFps: number) => void;
		/**
		 * Overrides the duration in frames of a composition
		 */
		readonly overrideDuration: (newDuration: number) => void;
		/**
		 * Set the ProRes profile.
		 * This method is only valid if the codec has been set to 'prores'.
		 * Possible values: 4444-xq, 4444, hq, standard, light, proxy. Default: 'hq'
		 * See https://avpres.net/FFmpeg/im_ProRes.html for meaning of possible values.
		 */
		readonly setProResProfile: (
			profile:
				| '4444-xq'
				| '4444'
				| 'hq'
				| 'standard'
				| 'light'
				| 'proxy'
				| undefined,
		) => void;

		readonly setX264Preset: (
			profile:
				| 'ultrafast'
				| 'superfast'
				| 'veryfast'
				| 'faster'
				| 'fast'
				| 'medium'
				| 'slow'
				| 'slower'
				| 'veryslow'
				| 'placebo'
				| null,
		) => void;
		/**
		 * Override the arguments that Remotion passes to FFmpeg.
		 * Consult https://remotion.dev/docs/renderer/render-media#ffmpegoverride before using this feature.
		 */
		readonly overrideFfmpegCommand: (
			command: (info: {
				type: 'pre-stitcher' | 'stitcher';
				args: string[];
			}) => string[],
		) => void;

		/**
		 * Set a target audio bitrate to be passed to FFmpeg.
		 */
		readonly setAudioBitrate: (bitrate: string | null) => void;

		/**
		 * Set a target video bitrate to be passed to FFmpeg.
		 * Mutually exclusive with setCrf().
		 */
		readonly setVideoBitrate: (bitrate: string | null) => void;

		/**
		 * Set the audio latency hint that the Studio will
		 * use when playing back audio
		 * Default: 'interactive'
		 */
		readonly setAudioLatencyHint: (
			audioLatencyHint: AudioContextLatencyCategory | null,
		) => void;

		/**
		 * Set a maximum bitrate to be passed to FFmpeg.
		 */
		readonly setEncodingMaxRate: (bitrate: string | null) => void;

		/**
		 * Set a buffer size to be passed to FFmpeg.
		 */
		readonly setEncodingBufferSize: (bitrate: string | null) => void;

		/**
		 * Opt into bt709 rendering.
		 */
		readonly setColorSpace: (colorSpace: ColorSpace) => void;

		/**
		 * Disallows the renderer from doing rendering frames and encoding at the same time.
		 * This makes the rendering process more memory-efficient, but possibly slower.
		 * Default: false
		 */
		readonly setDisallowParallelEncoding: (
			disallowParallelEncoding: boolean,
		) => void;

		/**
		 * Enables or disables the Ask AI Modal in Studio
		 */
		readonly setAskAIEnabled: (askAIEnabled: boolean) => void;

		/**
		 * Removes the --single-process flag that gets passed to
			Chromium on Linux by default. This will make the render faster because
			multiple processes can be used, but may cause issues with some Linux
			distributions or if window server libraries are missing.
		 */
		readonly setChromiumMultiProcessOnLinux: (
			multiProcessOnLinux: boolean,
		) => void;

		/**
		 * Whether the Remotion Studio should play a beep sound when a render has finished.
		 */
		readonly setBeepOnFinish: (beepOnFinish: boolean) => void;

		/**
		 * Enable Cross-Site Isolation in the Studio (Sets Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy HTTP headers)
		 */
		readonly setEnableCrossSiteIsolation: (
			enableCrossSiteIsolation: boolean,
		) => void;

		/**
		 * Collect information that you can submit to Remotion if asked for a reproduction.
		 */
		readonly setRepro: (enableRepro: boolean) => void;
		/**
		 * The directory where the platform-specific binaries and libraries needed
			for Remotion are located.
		 */
		readonly setBinariesDirectory: (directory: string | null) => void;
		/**
		 * Prefer lossless audio encoding. Default: false
		 */
		readonly setPreferLosslessAudio: (lossless: boolean) => void;
		/**
		 * Prefer lossless audio encoding. Default: false
		 */
		readonly setPublicPath: (publicPath: string | null) => void;
		/**
		 * Set the pattern for naming image sequence files. Supports [frame] and [ext] replacements.
		 * @param pattern The pattern string, e.g. 'frame_[frame].[ext]'.
		 */
		readonly setImageSequencePattern: (pattern: string | null) => void;
		/**
		 * Set the public license key for your company license.
		 * Obtain it from the "Usage" tab on https://remotion.pro
		 * Pass "free-license" if you are eligible for the free license.
		 */
		readonly setPublicLicenseKey: (key: string | null) => void;
	}
}

type FlatConfig = RemotionConfigObject &
	RemotionBundlingOptions & {
		/**
		 * Set the audio codec to use for the output video.
		 * See the Encoding guide in the docs for defaults and available options.
		 */
		setAudioCodec: (codec: 'pcm-16' | 'aac' | 'mp3' | 'opus') => void;
		setOffthreadVideoCacheSizeInBytes: (size: number | null) => void;
		/**
		 * Forces starting a new Studio instance even if one is already running on the same port for the same project.
		 * Default: false
		 */
		setForceNewStudioEnabled: (forceNew: boolean) => void;

		setDeleteAfter: (day: DeleteAfter | null) => void;
		/**
		 * Set whether S3 buckets should be allowed to expire.
		 */
		setEnableFolderExpiry: (value: boolean | null) => void;
		/**
		 * Set whether Lambda Insights should be enabled when deploying a function.
		 */
		setLambdaInsights: (value: boolean) => void;
		/**
		 * Set the amount of milliseconds after which the Player in the Studio will display a buffering UI after the Player has entered a buffer state.
		 */
		setBufferStateDelayInMilliseconds: (delay: number | null) => void;

		/**
		 * Metadata to be embedded into the output video file.
		 */
		setMetadata: (metadata: Record<string, string>) => void;
		/**
		 *
		 */
		setHardwareAcceleration: (
			hardwareAccelerationOption: HardwareAccelerationOption,
		) => void;
		/**
		 * Forces Remotion to bind to an IPv4 interface for the Studio server.
		 * Default: false
		 */
		setIPv4: (ipv4: boolean) => void;
		/**
		 * Define the output directory for `npx remotion bundle`.
		 * Default: `build` in the Remotion root.
		 */
		setBundleOutDir: (outDir: string | null) => void;
		/**
		 * Choose between using Chrome Headless Shell or Chrome for Testing
		 */
		setChromeMode: (chromeMode: ChromeMode) => void;
		/**
		 * Set how many times the video should be rendered during a benchmark.
		 * Default: 3
		 */
		setBenchmarkRuns: (runs: number) => void;
		/**
		 * Set which concurrency values should be used during a benchmark.
		 * Pass a comma-separated string of numbers, e.g. "1,4,8".
		 * Default: null (uses the --concurrency value)
		 */
		setBenchmarkConcurrencies: (concurrencies: string | null) => void;
		/**
		 * @deprecated 'The config format has changed. Change `Config.Bundling.*()` calls to `Config.*()` in your config file.'
		 */
		Bundling: void;
		/**
		 * @deprecated 'The config format has changed. Change `Config.Preview.*()` calls to `Config.*()` in your config file.'
		 */
		Preview: void;
		/**
		 * @deprecated 'The config format has changed. Change `Config.Log.*()` calls to `Config.*()` in your config file.'
		 */
		Log: void;
		/**
		 * @deprecated 'The config format has changed. Change `Config.Puppeteer.*()` calls to `Config.*()` in your config file.'
		 */
		Puppeteer: void;
		/**
		 * @deprecated 'The config format has changed. Change `Config.Rendering.*()` calls to `Config.*()` in your config file.'
		 */
		Rendering: void;
		/**
		 * @deprecated 'The config format has changed. Change `Config.Output.*()` calls to `Config.*()` in your config file.'
		 */
		Output: void;
	};

export const Config: FlatConfig = {
	get Bundling() {
		throw new Error(
			'The config format has changed. Change `Config.Bundling.*()` calls to `Config.*()` in your config file.',
		);
	},
	get Rendering() {
		throw new Error(
			'The config format has changed. Change `Config.Rendering.*()` calls to `Config.*()` in your config file.',
		);
	},
	get Output() {
		throw new Error(
			'The config format has changed. Change `Config.Output.*()` calls to `Config.*()` in your config file.',
		);
	},
	get Log() {
		throw new Error(
			'The config format has changed. Change `Config.Log.*()` calls to `Config.*()` in your config file.',
		);
	},
	get Preview() {
		throw new Error(
			'The config format has changed. Change `Config.Preview.*()` calls to `Config.*()` in your config file.',
		);
	},
	get Puppeteer() {
		throw new Error(
			'The config format has changed. Change `Config.Puppeteer.*()` calls to `Config.*()` in your config file.',
		);
	},
	setMaxTimelineTracks: StudioServerInternals.setMaxTimelineTracks,
	setKeyboardShortcutsEnabled: keyboardShortcutsOption.setConfig,
	setExperimentalClientSideRenderingEnabled:
		experimentalClientSideRenderingOption.setConfig,
	setExperimentalRspackEnabled: rspackOption.setConfig,
	setExperimentalVisualMode: experimentalVisualModeOption.setConfig,
	setNumberOfSharedAudioTags: numberOfSharedAudioTagsOption.setConfig,
	setWebpackPollingInMilliseconds: webpackPollOption.setConfig,
	setShouldOpenBrowser: noOpenOption.setConfig,
	setBufferStateDelayInMilliseconds,
	overrideWebpackConfig,
	setCachingEnabled: bundleCacheOption.setConfig,
	setPort,
	setStudioPort,
	setRendererPort,
	setPublicDir: publicDirOption.setConfig,
	setEntryPoint,
	setLevel: logLevelOption.setConfig,
	setBrowserExecutable: browserExecutableOption.setConfig,
	setTimeoutInMilliseconds: delayRenderTimeoutInMillisecondsOption.setConfig,
	setDelayRenderTimeoutInMilliseconds:
		delayRenderTimeoutInMillisecondsOption.setConfig,
	setChromiumDisableWebSecurity: disableWebSecurityOption.setConfig,
	setChromiumIgnoreCertificateErrors: ignoreCertificateErrorsOption.setConfig,
	setChromiumHeadlessMode: headlessOption.setConfig,
	setChromiumOpenGlRenderer: glOption.setConfig,
	setChromiumUserAgent: userAgentOption.setConfig,
	setDotEnvLocation: envFileOption.setConfig,
	setConcurrency: concurrencyOption.setConfig,
	setChromiumMultiProcessOnLinux: enableMultiprocessOnLinuxOption.setConfig,
	setChromiumDarkMode: darkModeOption.setConfig,
	setQuality: () => {
		throw new Error(
			'setQuality() has been renamed - use setJpegQuality() instead.',
		);
	},
	setImageFormat: () => {
		throw new Error(
			'Config.setImageFormat() has been renamed - use Config.setVideoImageFormat() instead (default "jpeg"). For rendering stills, use Config.setStillImageFormat() (default "png")',
		);
	},
	setJpegQuality: jpegQualityOption.setConfig,
	setStillImageFormat: stillImageFormatOption.setConfig,
	setVideoImageFormat: videoImageFormatOption.setConfig,
	setMetadata,
	setEncodingMaxRate: encodingMaxRateOption.setConfig,
	setEncodingBufferSize: encodingBufferSizeOption.setConfig,
	setFrameRange: framesOption.setConfig,
	setScale: scaleOption.setConfig,
	setEveryNthFrame: everyNthFrameOption.setConfig,
	setNumberOfGifLoops: numberOfGifLoopsOption.setConfig,
	setMuted: mutedOption.setConfig,
	setEnforceAudioTrack: enforceAudioOption.setConfig,
	setOutputLocation,
	setOverwriteOutput: overwriteOption.setConfig,
	setChromeMode: chromeModeOption.setConfig,
	setPixelFormat: pixelFormatOption.setConfig,
	setCodec: videoCodecOption.setConfig,
	setCrf: crfOption.setConfig,
	setImageSequence: imageSequenceOption.setConfig,
	setProResProfile: proResProfileOption.setConfig,
	setX264Preset: x264Option.setConfig,
	setAudioBitrate: audioBitrateOption.setConfig,
	setVideoBitrate: videoBitrateOption.setConfig,
	setAudioLatencyHint: audioLatencyHintOption.setConfig,
	setForSeamlessAacConcatenation: forSeamlessAacConcatenationOption.setConfig,
	overrideHeight: overrideHeightOption.setConfig,
	overrideWidth: overrideWidthOption.setConfig,
	overrideFps: overrideFpsOption.setConfig,
	overrideDuration: overrideDurationOption.setConfig,
	overrideFfmpegCommand: setFfmpegOverrideFunction,
	setAudioCodec: audioCodecOption.setConfig,
	setOffthreadVideoCacheSizeInBytes:
		offthreadVideoCacheSizeInBytesOption.setConfig,
	setDeleteAfter: deleteAfterOption.setConfig,
	setColorSpace: colorSpaceOption.setConfig,
	setDisallowParallelEncoding: disallowParallelEncodingOption.setConfig,
	setBeepOnFinish: beepOnFinishOption.setConfig,
	setEnableFolderExpiry: folderExpiryOption.setConfig,
	setRepro: reproOption.setConfig,
	setLambdaInsights: enableLambdaInsights.setConfig,
	setBinariesDirectory: binariesDirectoryOption.setConfig,
	setPreferLosslessAudio: preferLosslessOption.setConfig,
	setPublicPath: publicPathOption.setConfig,
	setImageSequencePattern: imageSequencePatternOption.setConfig,
	setHardwareAcceleration: hardwareAccelerationOption.setConfig,
	setEnableCrossSiteIsolation: enableCrossSiteIsolationOption.setConfig,
	setAskAIEnabled: askAIOption.setConfig,
	setPublicLicenseKey: publicLicenseKeyOption.setConfig,
	setForceNewStudioEnabled: forceNewStudioOption.setConfig,
	setIPv4: ipv4Option.setConfig,
	setBundleOutDir: outDirOption.setConfig,
	setBenchmarkRuns: runsOption.setConfig,
	setBenchmarkConcurrencies: benchmarkConcurrenciesOption.setConfig,
};

export const ConfigInternals = {
	getBrowser,
	getStudioPort,
	getRendererPortFromConfigFile,
	getRendererPortFromConfigFileAndCliFlag,
	getConcurrency,
	getStillFrame,
	getShouldOutputImageSequence,
	getDotEnvLocation,
	getWebpackOverrideFn,
	getWebpackCaching,
	getOutputLocation,
	setStillFrame,
	getMaxTimelineTracks: StudioServerInternals.getMaxTimelineTracks,
	defaultOverrideFunction,
	getFfmpegOverrideFunction,
	getMetadata,
	getEntryPoint,
	getWebpackPolling,
	getBufferStateDelayInMilliseconds,
	getOutputCodecOrUndefined: BrowserSafeApis.getOutputCodecOrUndefined,
};
