import requests
from typing import Literal, Optional

# Định nghĩa các hàm vMix và tham số yêu cầu
VMIX_FUNCTIONS = {
    "ActivatorRefresh": [],
    "CallManagerShowHide": [],
    "KeyPress": ['Value'],
    "SendKeys": ['Value'],
    "SetDynamicValue1": ['Value'],
    "SetDynamicValue2": ['Value'],
    "SetDynamicValue3": ['Value'],
    "SetDynamicValue4": ['Value'],
    "Undo": [],
    "Audio": ['Input'],
    "AudioAuto": ['Input'],
    "AudioAutoOff": ['Input'],
    "AudioAutoOn": ['Input'],
    "AudioBus": ['Value', 'Input'],
    "AudioBusOff": ['Value', 'Input'],
    "AudioBusOn": ['Value', 'Input'],
    "AudioChannelMatrixApplyPreset": ['Value', 'Input'],
    "AudioMixerShowHide": [],
    "AudioOff": ['Input'],
    "AudioOn": ['Input'],
    "AudioPluginOff": ['Value', 'Input'],
    "AudioPluginOn": ['Value', 'Input'],
    "AudioPluginOnOff": ['Value', 'Input'],
    "AudioPluginShow": ['Value', 'Input'],
    "BusAAudio": [],
    "BusAAudioOff": [],
    "BusAAudioOn": [],
    "BusAAudioPluginOff": ['Value'],
    "BusAAudioPluginOn": ['Value'],
    "BusAAudioPluginOnOff": ['Value'],
    "BusAAudioPluginShow": ['Value'],
    "BusBAudio": [],
    "BusBAudioOff": [],
    "BusBAudioOn": [],
    "BusBAudioPluginOff": ['Value'],
    "BusBAudioPluginOn": ['Value'],
    "BusBAudioPluginOnOff": ['Value'],
    "BusBAudioPluginShow": ['Value'],
    "BusXAudio": ['Value'],
    "BusXAudioOff": ['Value'],
    "BusXAudioOn": ['Value'],
    "BusXAudioPluginOff": ['Value'],
    "BusXAudioPluginOn": ['Value'],
    "BusXAudioPluginOnOff": ['Value'],
    "BusXAudioPluginShow": ['Value'],
    "BusXSendToMaster": ['Value'],
    "BusXSendToMasterOff": ['Value'],
    "BusXSendToMasterOn": ['Value'],
    "BusXSolo": ['Value'],
    "BusXSoloOff": ['Value'],
    "BusXSoloOn": ['Value'],
    "MasterAudio": [],
    "MasterAudioOff": [],
    "MasterAudioOn": [],
    "MasterAudioPluginOff": ['Value'],
    "MasterAudioPluginOn": ['Value'],
    "MasterAudioPluginOnOff": ['Value'],
    "MasterAudioPluginShow": ['Value'],
    "SetBalance": ['Value', 'Input'],
    "SetBusAVolume": ['Value'],
    "SetBusBVolume": ['Value'],
    "SetBusCVolume": ['Value'],
    "SetBusDVolume": ['Value'],
    "SetBusEVolume": ['Value'],
    "SetBusFVolume": ['Value'],
    "SetBusGVolume": ['Value'],
    "SetGain": ['Value', 'Input'],
    "SetGainChannel1": ['Value', 'Input'],
    "SetGainChannel2": ['Value', 'Input'],
    "SetHeadphonesVolume": ['Value'],
    "SetMasterVolume": ['Value'],
    "SetVolume": ['Value', 'Input'],
    "SetVolumeBusMixer": ['Value', 'Input'],
    "SetVolumeBusMixerA": ['Value', 'Input'],
    "SetVolumeBusMixerB": ['Value', 'Input'],
    "SetVolumeBusMixerC": ['Value', 'Input'],
    "SetVolumeBusMixerD": ['Value', 'Input'],
    "SetVolumeBusMixerE": ['Value', 'Input'],
    "SetVolumeBusMixerF": ['Value', 'Input'],
    "SetVolumeBusMixerG": ['Value', 'Input'],
    "SetVolumeBusMixerM": ['Value', 'Input'],
    "SetVolumeChannel1": ['Value', 'Input'],
    "SetVolumeChannel2": ['Value', 'Input'],
    "SetVolumeChannelMixer": ['Value', 'Input'],
    "SetVolumeChannelMixer1": ['Value', 'Input'],
    "SetVolumeChannelMixer10": ['Value', 'Input'],
    "SetVolumeChannelMixer11": ['Value', 'Input'],
    "SetVolumeChannelMixer12": ['Value', 'Input'],
    "SetVolumeChannelMixer13": ['Value', 'Input'],
    "SetVolumeChannelMixer14": ['Value', 'Input'],
    "SetVolumeChannelMixer15": ['Value', 'Input'],
    "SetVolumeChannelMixer16": ['Value', 'Input'],
    "SetVolumeChannelMixer2": ['Value', 'Input'],
    "SetVolumeChannelMixer3": ['Value', 'Input'],
    "SetVolumeChannelMixer4": ['Value', 'Input'],
    "SetVolumeChannelMixer5": ['Value', 'Input'],
    "SetVolumeChannelMixer6": ['Value', 'Input'],
    "SetVolumeChannelMixer7": ['Value', 'Input'],
    "SetVolumeChannelMixer8": ['Value', 'Input'],
    "SetVolumeChannelMixer9": ['Value', 'Input'],
    "SetVolumeFade": ['Value', 'Input'],
    "Solo": ['Input'],
    "SoloAllOff": [],
    "SoloOff": ['Input'],
    "SoloOn": ['Input'],
    "SoloPFL": ['Input'],
    "SoloPFLOff": ['Input'],
    "SoloPFLOn": ['Input'],
    "Transition": [],
    "CutDirect": ['Input'],
    "FadeToBlack": [],
    "QuickPlay": ['Input'],
    "SetFader": ['Value'],
    "SetTransitionDuration1": ['Value'],
    "SetTransitionDuration2": ['Value'],
    "SetTransitionDuration3": ['Value'],
    "SetTransitionDuration4": ['Value'],
    "SetTransitionEffect1": ['Value'],
    "SetTransitionEffect2": ['Value'],
    "SetTransitionEffect3": ['Value'],
    "SetTransitionEffect4": ['Value'],
    "Stinger1": ['Input'],
    "Stinger2": ['Input'],
    "Stinger3": ['Input'],
    "Stinger4": ['Input'],
    "Transition1": [],
    "Transition2": [],
    "Transition3": [],
    "Transition4": [],
    "Output": [],
    "Fullscreen": [],
    "FullscreenOff": [],
    "FullscreenOn": [],
    "SetOutput2": ['Value', 'Input'],
    "SetOutput3": ['Value', 'Input'],
    "SetOutput4": ['Value', 'Input'],
    "SetOutputExternal2": ['Value', 'Input'],
    "SetOutputFullscreen": ['Value', 'Input'],
    "SetOutputFullscreen2": ['Value', 'Input'],
    "Snapshot": ['Value'],
    "SnapshotInput": ['Value', 'Input'],
    "StartExternal": [],
    "StartMultiCorder": [],
    "StartRecording": [],
    "StartSRTOutput": ['Value'],
    "StartStopExternal": [],
    "StartStopMultiCorder": [],
    "StartStopRecording": [],
    "StartStopSRTOutput": ['Value'],
    "StartStopStreaming": ['Value'],
    "StartStreaming": ['Value'],
    "StopExternal": [],
    "StopMultiCorder": [],
    "StopRecording": [],
    "StopSRTOutput": ['Value'],
    "StopStreaming": ['Value'],
    "StreamingSetKey": ['Value'],
    "StreamingSetPassword": ['Value'],
    "StreamingSetURL": ['Value'],
    "StreamingSetUsername": ['Value'],
    "WriteDurationToRecordingLog": ['Value'],
    "Title": [],
    "AdjustCountdown": ['Value', 'Input'],
    "ChangeCountdown": ['Value', 'Input'],
    "NextTitlePreset": ['Input'],
    "PauseCountdown": ['Input'],
    "PauseRender": ['Input'],
    "PreviousTitlePreset": ['Input'],
    "ResumeRender": ['Input'],
    "SelectTitlePreset": ['Value', 'Input'],
    "SetColor": ['Value', 'Input'],
    "SetCountdown": ['Value', 'Input'],
    "SetImage": ['Value', 'Input'],
    "SetImageVisible": ['Input'],
    "SetImageVisibleOff": ['Input'],
    "SetImageVisibleOn": ['Input'],
    "SetText": ['Value', 'Input'],
    "SetTextColour": ['Value', 'Input'],
    "SetTextVisible": ['Input'],
    "SetTextVisibleOff": ['Input'],
    "SetTextVisibleOn": ['Input'],
    "SetTickerSpeed": ['Value', 'Input'],
    "StartCountdown": ['Input'],
    "StopCountdown": ['Input'],
    "SuspendCountdown": ['Input'],
    "TitleBeginAnimation": ['Value', 'Input'],
    "Input": [],
    "ActiveInput": ['Input'],
    "AddInput": ['Value'],
    "AutoPauseOff": ['Input'],
    "AutoPauseOn": ['Input'],
    "AutoPlayFirst": ['Input'],
    "AutoPlayFirstOff": ['Input'],
    "AutoPlayFirstOn": ['Input'],
    "AutoPlayNext": ['Input'],
    "AutoPlayNextOff": ['Input'],
    "AutoPlayNextOn": ['Input'],
    "AutoPlayOff": ['Input'],
    "AutoPlayOn": ['Input'],
    "AutoRestartOff": ['Input'],
    "AutoRestartOn": ['Input'],
    "ColourCorrectionAuto": ['Input'],
    "ColourCorrectionReset": ['Input'],
    "CreateVirtualInput": ['Input'],
    "DeinterlaceOff": ['Input'],
    "DeinterlaceOn": ['Input'],
    "Effect1": ['Input'],
    "Effect1Off": ['Input'],
    "Effect1On": ['Input'],
    "Effect2": ['Input'],
    "Effect2Off": ['Input'],
    "Effect2On": ['Input'],
    "Effect3": ['Input'],
    "Effect3Off": ['Input'],
    "Effect3On": ['Input'],
    "Effect4": ['Input'],
    "Effect4Off": ['Input'],
    "Effect4On": ['Input'],
    "InputPreviewHide": ['Input'],
    "InputPreviewShow": ['Input'],
    "InputPreviewShowHide": ['Input'],
    "LayerOff": ['Value', 'Input'],
    "LayerOn": ['Value', 'Input'],
    "LayerOnOff": ['Value', 'Input'],
    "ListAdd": ['Value', 'Input'],
    "ListExport": ['Value', 'Input'],
    "ListPlayOut": ['Input'],
    "ListRemove": ['Value', 'Input'],
    "ListRemoveAll": ['Input'],
    "ListShowHide": ['Input'],
    "ListShuffle": ['Input'],
    "LivePlayPause": ['Input'],
    "Loop": ['Input'],
    "LoopOff": ['Input'],
    "LoopOn": ['Input'],
    "MarkIn": ['Input'],
    "MarkOut": ['Input'],
    "MarkReset": ['Input'],
    "MarkResetIn": ['Input'],
    "MarkResetOut": ['Input'],
    "MirrorOff": ['Input'],
    "MirrorOn": ['Input'],
    "MoveInput": ['Value', 'Input'],
    "MoveLayer": ['Value', 'Input'],
    "NextItem": ['Input'],
    "NextPicture": ['Input'],
    "Pause": ['Input'],
    "Play": ['Input'],
    "PlayPause": ['Input'],
    "PreviewInput": ['Input'],
    "PreviewInputNext": [],
    "PreviewInputPrevious": [],
    "PreviousItem": ['Input'],
    "PreviousPicture": ['Input'],
    "RemoveInput": ['Input'],
    "ResetInput": ['Input'],
    "Restart": ['Input'],
    "SaveVideoDelay": ['Input', 'Duration'],
    "SelectCategory": ['Value'],
    "SelectIndex": ['Value', 'Input'],
    "SetAlpha": ['Value', 'Input'],
    "SetCCGainB": ['Value', 'Input'],
    "SetCCGainG": ['Value', 'Input'],
    "SetCCGainR": ['Value', 'Input'],
    "SetCCGainRGB": ['Value', 'Input'],
    "SetCCGainY": ['Value', 'Input'],
    "SetCCGammaB": ['Value', 'Input'],
    "SetCCGammaG": ['Value', 'Input'],
    "SetCCGammaR": ['Value', 'Input'],
    "SetCCGammaRGB": ['Value', 'Input'],
    "SetCCGammaY": ['Value', 'Input'],
    "SetCCHue": ['Value', 'Input'],
    "SetCCLiftB": ['Value', 'Input'],
    "SetCCLiftG": ['Value', 'Input'],
    "SetCCLiftR": ['Value', 'Input'],
    "SetCCLiftRGB": ['Value', 'Input'],
    "SetCCLiftY": ['Value', 'Input'],
    "SetCCSaturation": ['Value', 'Input'],
    "SetCrop": ['Value', 'Input'],
    "SetCropX1": ['Value', 'Input'],
    "SetCropX2": ['Value', 'Input'],
    "SetCropY1": ['Value', 'Input'],
    "SetCropY2": ['Value', 'Input'],
    "SetDynamicInput1": ['Value'],
    "SetDynamicInput2": ['Value'],
    "SetDynamicInput3": ['Value'],
    "SetDynamicInput4": ['Value'],
    "SetEffect1Strength": ['Value', 'Input'],
    "SetEffect2Strength": ['Value', 'Input'],
    "SetEffect3Strength": ['Value', 'Input'],
    "SetEffect4Strength": ['Value', 'Input'],
    "SetFrameDelay": ['Value', 'Input'],
    "SetInputName": ['Value', 'Input'],
    "SetLayer": ['Value', 'Input'],
    "SetLayer10Crop": ['Value', 'Input'],
    "SetLayer10CropX1": ['Value', 'Input'],
    "SetLayer10CropX2": ['Value', 'Input'],
    "SetLayer10CropY1": ['Value', 'Input'],
    "SetLayer10CropY2": ['Value', 'Input'],
    "SetLayer10Height": ['Value', 'Input'],
    "SetLayer10PanX": ['Value', 'Input'],
    "SetLayer10PanY": ['Value', 'Input'],
    "SetLayer10Rectangle": ['Value', 'Input'],
    "SetLayer10Width": ['Value', 'Input'],
    "SetLayer10X": ['Value', 'Input'],
    "SetLayer10Y": ['Value', 'Input'],
    "SetLayer10Zoom": ['Value', 'Input'],
    "SetLayer1Crop": ['Value', 'Input'],
    "SetLayer1CropX1": ['Value', 'Input'],
    "SetLayer1CropX2": ['Value', 'Input'],
    "SetLayer1CropY1": ['Value', 'Input'],
    "SetLayer1CropY2": ['Value', 'Input'],
    "SetLayer1Height": ['Value', 'Input'],
    "SetLayer1PanX": ['Value', 'Input'],
    "SetLayer1PanY": ['Value', 'Input'],
    "SetLayer1Rectangle": ['Value', 'Input'],
    "SetLayer1Width": ['Value', 'Input'],
    "SetLayer1X": ['Value', 'Input'],
    "SetLayer1Y": ['Value', 'Input'],
    "SetLayer1Zoom": ['Value', 'Input'],
    "SetLayer2Crop": ['Value', 'Input'],
    "SetLayer2CropX1": ['Value', 'Input'],
    "SetLayer2CropX2": ['Value', 'Input'],
    "SetLayer2CropY1": ['Value', 'Input'],
    "SetLayer2CropY2": ['Value', 'Input'],
    "SetLayer2Height": ['Value', 'Input'],
    "SetLayer2PanX": ['Value', 'Input'],
    "SetLayer2PanY": ['Value', 'Input'],
    "SetLayer2Rectangle": ['Value', 'Input'],
    "SetLayer2Width": ['Value', 'Input'],
    "SetLayer2X": ['Value', 'Input'],
    "SetLayer2Y": ['Value', 'Input'],
    "SetLayer2Zoom": ['Value', 'Input'],
    "SetLayer3Crop": ['Value', 'Input'],
    "SetLayer3CropX1": ['Value', 'Input'],
    "SetLayer3CropX2": ['Value', 'Input'],
    "SetLayer3CropY1": ['Value', 'Input'],
    "SetLayer3CropY2": ['Value', 'Input'],
    "SetLayer3Height": ['Value', 'Input'],
    "SetLayer3PanX": ['Value', 'Input'],
    "SetLayer3PanY": ['Value', 'Input'],
    "SetLayer3Rectangle": ['Value', 'Input'],
    "SetLayer3Width": ['Value', 'Input'],
    "SetLayer3X": ['Value', 'Input'],
    "SetLayer3Y": ['Value', 'Input'],
    "SetLayer3Zoom": ['Value', 'Input'],
    "SetLayer4Crop": ['Value', 'Input'],
    "SetLayer4CropX1": ['Value', 'Input'],
    "SetLayer4CropX2": ['Value', 'Input'],
    "SetLayer4CropY1": ['Value', 'Input'],
    "SetLayer4CropY2": ['Value', 'Input'],
    "SetLayer4Height": ['Value', 'Input'],
    "SetLayer4PanX": ['Value', 'Input'],
    "SetLayer4PanY": ['Value', 'Input'],
    "SetLayer4Rectangle": ['Value', 'Input'],
    "SetLayer4Width": ['Value', 'Input'],
    "SetLayer4X": ['Value', 'Input'],
    "SetLayer4Y": ['Value', 'Input'],
    "SetLayer4Zoom": ['Value', 'Input'],
    "SetLayer5Crop": ['Value', 'Input'],
    "SetLayer5CropX1": ['Value', 'Input'],
    "SetLayer5CropX2": ['Value', 'Input'],
    "SetLayer5CropY1": ['Value', 'Input'],
    "SetLayer5CropY2": ['Value', 'Input'],
    "SetLayer5Height": ['Value', 'Input'],
    "SetLayer5PanX": ['Value', 'Input'],
    "SetLayer5PanY": ['Value', 'Input'],
    "SetLayer5Rectangle": ['Value', 'Input'],
    "SetLayer5Width": ['Value', 'Input'],
    "SetLayer5X": ['Value', 'Input'],
    "SetLayer5Y": ['Value', 'Input'],
    "SetLayer5Zoom": ['Value', 'Input'],
    "SetLayer6Crop": ['Value', 'Input'],
    "SetLayer6CropX1": ['Value', 'Input'],
    "SetLayer6CropX2": ['Value', 'Input'],
    "SetLayer6CropY1": ['Value', 'Input'],
    "SetLayer6CropY2": ['Value', 'Input'],
    "SetLayer6Height": ['Value', 'Input'],
    "SetLayer6PanX": ['Value', 'Input'],
    "SetLayer6PanY": ['Value', 'Input'],
    "SetLayer6Rectangle": ['Value', 'Input'],
    "SetLayer6Width": ['Value', 'Input'],
    "SetLayer6X": ['Value', 'Input'],
    "SetLayer6Y": ['Value', 'Input'],
    "SetLayer6Zoom": ['Value', 'Input'],
    "SetLayer7Crop": ['Value', 'Input'],
    "SetLayer7CropX1": ['Value', 'Input'],
    "SetLayer7CropX2": ['Value', 'Input'],
    "SetLayer7CropY1": ['Value', 'Input'],
    "SetLayer7CropY2": ['Value', 'Input'],
    "SetLayer7Height": ['Value', 'Input'],
    "SetLayer7PanX": ['Value', 'Input'],
    "SetLayer7PanY": ['Value', 'Input'],
    "SetLayer7Rectangle": ['Value', 'Input'],
    "SetLayer7Width": ['Value', 'Input'],
    "SetLayer7X": ['Value', 'Input'],
    "SetLayer7Y": ['Value', 'Input'],
    "SetLayer7Zoom": ['Value', 'Input'],
    "SetLayer8Crop": ['Value', 'Input'],
    "SetLayer8CropX1": ['Value', 'Input'],
    "SetLayer8CropX2": ['Value', 'Input'],
    "SetLayer8CropY1": ['Value', 'Input'],
    "SetLayer8CropY2": ['Value', 'Input'],
    "SetLayer8Height": ['Value', 'Input'],
    "SetLayer8PanX": ['Value', 'Input'],
    "SetLayer8PanY": ['Value', 'Input'],
    "SetLayer8Rectangle": ['Value', 'Input'],
    "SetLayer8Width": ['Value', 'Input'],
    "SetLayer8X": ['Value', 'Input'],
    "SetLayer8Y": ['Value', 'Input'],
    "SetLayer8Zoom": ['Value', 'Input'],
    "SetLayer9Crop": ['Value', 'Input'],
    "SetLayer9CropX1": ['Value', 'Input'],
    "SetLayer9CropX2": ['Value', 'Input'],
    "SetLayer9CropY1": ['Value', 'Input'],
    "SetLayer9CropY2": ['Value', 'Input'],
    "SetLayer9Height": ['Value', 'Input'],
    "SetLayer9PanX": ['Value', 'Input'],
    "SetLayer9PanY": ['Value', 'Input'],
    "SetLayer9Rectangle": ['Value', 'Input'],
    "SetLayer9Width": ['Value', 'Input'],
    "SetLayer9X": ['Value', 'Input'],
    "SetLayer9Y": ['Value', 'Input'],
    "SetLayer9Zoom": ['Value', 'Input'],
    "SetLayerAnimated": ['Value', 'Input'],
    "SetLayerDynamicCrop": ['Value', 'Input'],
    "SetLayerDynamicCropX1": ['Value', 'Input'],
    "SetLayerDynamicCropX2": ['Value', 'Input'],
    "SetLayerDynamicCropY1": ['Value', 'Input'],
    "SetLayerDynamicCropY2": ['Value', 'Input'],
    "SetLayerDynamicHeight": ['Value', 'Input'],
    "SetLayerDynamicPanX": ['Value', 'Input'],
    "SetLayerDynamicPanY": ['Value', 'Input'],
    "SetLayerDynamicRectangle": ['Value', 'Input'],
    "SetLayerDynamicWidth": ['Value', 'Input'],
    "SetLayerDynamicX": ['Value', 'Input'],
    "SetLayerDynamicY": ['Value', 'Input'],
    "SetLayerDynamicZoom": ['Value', 'Input'],
    "SetPanX": ['Value', 'Input'],
    "SetPanY": ['Value', 'Input'],
    "SetPictureEffect": ['Value', 'Input'],
    "SetPictureEffectDuration": ['Value', 'Input'],
    "SetPictureTransition": ['Value', 'Input'],
    "SetPosition": ['Value', 'Input'],
    "SetRate": ['Value', 'Input'],
    "SetRateSlowMotion": ['Value', 'Input'],
    "SetZoom": ['Value', 'Input'],
    "SharpenOff": ['Input'],
    "SharpenOn": ['Input'],
    "SwapLayerAnimated": ['Value', 'Input'],
    "VideoCallAudioSource": ['Value', 'Input'],
    "VideoCallVideoSource": ['Value', 'Input'],
    "VideoDelayStartRecording": ['Input', 'Duration'],
    "VideoDelayStartStopRecording": ['Input', 'Duration'],
    "VideoDelayStopRecording": ['Input', 'Duration'],
    "WaitForCompletion": ['Input', 'Duration'],
    "ZoomMuteSelf": ['Input'],
    "ZoomSelectParticipantByName": ['Value', 'Input'],
    "ZoomUnMuteSelf": ['Input'],
    "Overlay": [],
    "MoveMultiViewOverlay": ['Value', 'Input'],
    "MultiViewOverlay": ['Value', 'Input'],
    "MultiViewOverlayOff": ['Value', 'Input'],
    "MultiViewOverlayOn": ['Value', 'Input'],
    "OverlayInput1": ['Input'],
    "OverlayInput1In": ['Input'],
    "OverlayInput1Last": [],
    "OverlayInput1Off": [],
    "OverlayInput1Out": [],
    "OverlayInput1Zoom": [],
    "OverlayInput2": ['Input'],
    "OverlayInput2In": ['Input'],
    "OverlayInput2Last": [],
    "OverlayInput2Off": [],
    "OverlayInput2Out": [],
    "OverlayInput2Zoom": [],
    "OverlayInput3": ['Input'],
    "OverlayInput3In": ['Input'],
    "OverlayInput3Last": [],
    "OverlayInput3Off": [],
    "OverlayInput3Out": [],
    "OverlayInput3Zoom": [],
    "OverlayInput4": ['Input'],
    "OverlayInput4In": ['Input'],
    "OverlayInput4Last": [],
    "OverlayInput4Off": [],
    "OverlayInput4Out": [],
    "OverlayInput4Zoom": [],
    "OverlayInputAllOff": [],
    "PreviewOverlayInput1": ['Input'],
    "PreviewOverlayInput2": ['Input'],
    "PreviewOverlayInput3": ['Input'],
    "PreviewOverlayInput4": ['Input'],
    "SetMultiViewOverlay": ['Value', 'Input'],
    "PlayList": [],
    "NextPlayListEntry": [],
    "PreviousPlayListEntry": [],
    "SelectPlayList": ['Value'],
    "StartPlayList": [],
    "StopPlayList": [],
    "Scripting": [],
    "ScriptStart": ['Value'],
    "ScriptStartDynamic": ['Value'],
    "ScriptStop": ['Value'],
    "ScriptStopAll": [],
    "ScriptStopDynamic": [],
    "Replay": [],
    "ReplayACamera1": [],
    "ReplayACamera2": [],
    "ReplayACamera3": [],
    "ReplayACamera4": [],
    "ReplayACamera5": [],
    "ReplayACamera6": [],
    "ReplayACamera7": [],
    "ReplayACamera8": [],
    "ReplayBCamera1": [],
    "ReplayBCamera2": [],
    "ReplayBCamera3": [],
    "ReplayBCamera4": [],
    "ReplayBCamera5": [],
    "ReplayBCamera6": [],
    "ReplayBCamera7": [],
    "ReplayBCamera8": [],
    "ReplayCamera1": [],
    "ReplayCamera2": [],
    "ReplayCamera3": [],
    "ReplayCamera4": [],
    "ReplayCamera5": [],
    "ReplayCamera6": [],
    "ReplayCamera7": [],
    "ReplayCamera8": [],
    "ReplayChangeDirection": ['Channel'],
    "ReplayChangeSpeed": ['Value', 'Channel'],
    "ReplayCopyLastEvent": ['Value'],
    "ReplayCopySelectedEvent": ['Value'],
    "ReplayDeleteLastEvent": ['Channel'],
    "ReplayDeleteSelectedEvent": ['Channel'],
    "ReplayDuplicateLastEvent": ['Channel'],
    "ReplayDuplicateSelectedEvent": ['Channel'],
    "ReplayExportLastEvent": ['Value', 'Channel'],
    "ReplayFastBackward": ['Value', 'Channel'],
    "ReplayFastForward": ['Value', 'Channel'],
    "ReplayJumpFrames": ['Value', 'Channel'],
    "ReplayJumpFramesFastOff": ['Channel'],
    "ReplayJumpFramesFastOn": ['Channel'],
    "ReplayJumpToNow": ['Channel'],
    "ReplayLastEventCameraOff": ['Value'],
    "ReplayLastEventCameraOn": ['Value'],
    "ReplayLastEventSingleCameraOn": ['Value'],
    "ReplayLive": [],
    "ReplayLiveToggle": [],
    "ReplayMarkCancel": [],
    "ReplayMarkIn": [],
    "ReplayMarkInLive": [],
    "ReplayMarkInOut": ['Value'],
    "ReplayMarkInOutLive": ['Value'],
    "ReplayMarkInOutLiveFuture": ['Value'],
    "ReplayMarkInOutRecorded": ['Value'],
    "ReplayMarkInRecorded": [],
    "ReplayMarkInRecordedNow": [],
    "ReplayMarkOut": [],
    "ReplayMoveLastEvent": ['Value'],
    "ReplayMoveSelectedEvent": ['Value'],
    "ReplayMoveSelectedEventDown": [],
    "ReplayMoveSelectedEventUp": [],
    "ReplayMoveSelectedInPoint": ['Value', 'Channel'],
    "ReplayMoveSelectedOutPoint": ['Value', 'Channel'],
    "ReplayPause": ['Channel'],
    "ReplayPlay": ['Channel'],
    "ReplayPlayAllEvents": ['Channel'],
    "ReplayPlayAllEventsToOutput": ['Channel'],
    "ReplayPlayBackward": ['Channel'],
    "ReplayPlayEvent": ['Value', 'Channel'],
    "ReplayPlayEventsByID": ['Value', 'Channel'],
    "ReplayPlayEventsByIDToOutput": ['Value', 'Channel'],
    "ReplayPlayEventToOutput": ['Value', 'Channel'],
    "ReplayPlayForward": ['Channel'],
    "ReplayPlayLastEvent": ['Channel'],
    "ReplayPlayLastEventToOutput": ['Channel'],
    "ReplayPlayNext": ['Channel'],
    "ReplayPlayPause": ['Channel'],
    "ReplayPlayPrevious": ['Channel'],
    "ReplayPlaySelectedEvent": ['Channel'],
    "ReplayPlaySelectedEventToOutput": ['Channel'],
    "ReplayRecorded": [],
    "ReplayScrollSelectedEvent": ['Value'],
    "ReplaySelectAllEvents": [],
    "ReplaySelectChannelA": [],
    "ReplaySelectChannelAB": [],
    "ReplaySelectChannelB": [],
    "ReplaySelectedEventCameraOff": ['Value'],
    "ReplaySelectedEventCameraOn": ['Value'],
    "ReplaySelectedEventSingleCameraOn": ['Value'],
    "ReplaySelectEvents1": ['Channel'],
    "ReplaySelectEvents10": ['Channel'],
    "ReplaySelectEvents11": ['Channel'],
    "ReplaySelectEvents12": ['Channel'],
    "ReplaySelectEvents13": ['Channel'],
    "ReplaySelectEvents14": ['Channel'],
    "ReplaySelectEvents15": ['Channel'],
    "ReplaySelectEvents16": ['Channel'],
    "ReplaySelectEvents17": ['Channel'],
    "ReplaySelectEvents18": ['Channel'],
    "ReplaySelectEvents19": ['Channel'],
    "ReplaySelectEvents2": ['Channel'],
    "ReplaySelectEvents20": ['Channel'],
    "ReplaySelectEvents3": ['Channel'],
    "ReplaySelectEvents4": ['Channel'],
    "ReplaySelectEvents5": ['Channel'],
    "ReplaySelectEvents6": ['Channel'],
    "ReplaySelectEvents7": ['Channel'],
    "ReplaySelectEvents8": ['Channel'],
    "ReplaySelectEvents9": ['Channel'],
    "ReplaySelectFirstEvent": ['Channel'],
    "ReplaySelectLastEvent": ['Channel'],
    "ReplaySelectNextEvent": ['Channel'],
    "ReplaySelectPreviousEvent": ['Channel'],
    "ReplaySetAudioSource": ['Value'],
    "ReplaySetChannelAToBTimecode": [],
    "ReplaySetChannelBToATimecode": [],
    "ReplaySetDirectionBackward": ['Channel'],
    "ReplaySetDirectionForward": ['Channel'],
    "ReplaySetLastEventText": ['Value'],
    "ReplaySetLastEventTextCamera": ['Value'],
    "ReplaySetSelectedEventText": ['Value'],
    "ReplaySetSelectedEventTextCamera": ['Value'],
    "ReplaySetSpeed": ['Value', 'Channel'],
    "ReplaySetTimecode": ['Value', 'Channel'],
    "ReplayShowHide": [],
    "ReplayStartRecording": [],
    "ReplayStartStopRecording": [],
    "ReplayStopEvents": ['Channel'],
    "ReplayStopRecording": [],
    "ReplaySwapChannels": [],
    "ReplayToggleLastEventCamera1": [],
    "ReplayToggleLastEventCamera2": [],
    "ReplayToggleLastEventCamera3": [],
    "ReplayToggleLastEventCamera4": [],
    "ReplayToggleLastEventCamera5": [],
    "ReplayToggleLastEventCamera6": [],
    "ReplayToggleLastEventCamera7": [],
    "ReplayToggleLastEventCamera8": [],
    "ReplayToggleSelectedEventCamera1": [],
    "ReplayToggleSelectedEventCamera2": [],
    "ReplayToggleSelectedEventCamera3": [],
    "ReplayToggleSelectedEventCamera4": [],
    "ReplayToggleSelectedEventCamera5": [],
    "ReplayToggleSelectedEventCamera6": [],
    "ReplayToggleSelectedEventCamera7": [],
    "ReplayToggleSelectedEventCamera8": [],
    "ReplayUpdateSelectedInPoint": ['Channel'],
    "ReplayUpdateSelectedOutPoint": ['Channel'],
    "ReplayUpdateSelectedSpeed": ['Channel'],
    "ReplayUpdateSelectedSpeedDefault": ['Channel'],
    "NDI": [],
    "NDICommand": ['Value', 'Input'],
    "NDISelectSourceByIndex": ['Value', 'Input'],
    "NDISelectSourceByName": ['Value', 'Input'],
    "NDIStartRecording": ['Input'],
    "NDIStopRecording": ['Input'],
    "PTZ": [],
    "PTZCreateVirtualInput": ['Input'],
    "PTZFocusAuto": ['Input'],
    "PTZFocusFar": ['Value', 'Input'],
    "PTZFocusManual": ['Input'],
    "PTZFocusNear": ['Value', 'Input'],
    "PTZFocusStop": ['Input'],
    "PTZHome": ['Input'],
    "PTZMoveDown": ['Value', 'Input'],
    "PTZMoveDownLeft": ['Value', 'Input'],
    "PTZMoveDownRight": ['Value', 'Input'],
    "PTZMoveLeft": ['Value', 'Input'],
    "PTZMoveRight": ['Value', 'Input'],
    "PTZMoveStop": ['Input'],
    "PTZMoveToVirtualInputPosition": ['Input'],
    "PTZMoveToVirtualInputPositionByIndex": ['Value', 'Input'],
    "PTZMoveUp": ['Value', 'Input'],
    "PTZMoveUpLeft": ['Value', 'Input'],
    "PTZMoveUpRight": ['Value', 'Input'],
    "PTZUpdateVirtualInput": ['Input'],
    "PTZZoomIn": ['Value', 'Input'],
    "PTZZoomOut": ['Value', 'Input'],
    "PTZZoomStop": ['Input'],
    "Preset": [],
    "LastPreset": [],
    "OpenPreset": ['Value'],
    "SavePreset": ['Value'],
    "DataSources": [],
    "DataSourceAutoNextOff": ['Value'],
    "DataSourceAutoNextOn": ['Value'],
    "DataSourceAutoNextOnOff": ['Value'],
    "DataSourceNextRow": ['Value'],
    "DataSourcePause": ['Value'],
    "DataSourcePlay": ['Value'],
    "DataSourcePlayPause": ['Value'],
    "DataSourcePreviousRow": ['Value'],
    "DataSourceSelectRow": ['Value'],
    "Browser": [],
    "BrowserBack": ['Input'],
    "BrowserForward": ['Input'],
    "BrowserKeyboardDisabled": ['Input'],
    "BrowserKeyboardEnabled": ['Input'],
    "BrowserMouseDisabled": ['Input'],
    "BrowserMouseEnabled": ['Input'],
    "BrowserNavigate": ['Value', 'Input'],
    "BrowserReload": ['Input'],
}

headers = {'Content-type': 'application/json'}

def vmix_control(
    ip: str,
    function: Literal["Fade", "Cut", "OverlayInput1", "OverlayInput2", "SetDynamicValue1", "SetDynamicValue2", "SetDynamicValue3", "SetDynamicValue4", "Audio", "AudioAuto", "AudioOff", "AudioOn"],
    port: int = 8088,
    value: Optional[str] = None,
    input: Optional[str] = None,
    duration: Optional[int] = None,
    channel: Optional[int] = None,
    **kwargs
):
    if function not in VMIX_FUNCTIONS:
        return {"status": "error", "message": f"Hàm '{function}' không được hỗ trợ."}
    
    # Kiểm tra các tham số bắt buộc
    required_params = VMIX_FUNCTIONS[function]
    for param in required_params:
        if param not in kwargs:
            return {"status": "error", "message": f"Thiếu tham số bắt buộc: '{param}'."}
    
    # Xây dựng URL với các tham số
    url = f'http://{ip}:{port}/api/?Function={function}'
    if value is not None:
        url += f'&Value={value}'
    if input is not None:
        url += f'&Input={input}'
    if duration is not None:
        url += f'&Duration={duration}'
    if channel is not None:
        url += f'&Channel={channel}'
    
    try:
        # Gửi yêu cầu HTTP đến vMix
        response = requests.get(url, timeout=5)
        if response.status_code == 200:
            return {"status": "success", "message": "Lệnh đã được gửi thành công."}
        else:
            return {"status": "error", "message": f"Lỗi HTTP {response.status_code}."}
    except requests.exceptions.RequestException as e:
        return {"status": "error", "message": str(e)}