import { CaptureMode , CaptureModeList , CaptureSettings , CaptureTriggerMode , CaptureTriggerModeList } from "../types/Mint" ; /**
 * Checks is the trigger settings of a CaptureSettings object matches what's allowed
 * Return true if that's the case, false otherwise
 */ export function validateCaptureTriggerSettings ( settings ) { if ( ! CaptureTriggerModeList . includes ( settings . triggerMode as any ) ) return false ; if ( settings . triggerMode === CaptureTriggerMode . DELAY ) { if ( settings . delay == null ) return false ; if ( isNaN ( settings . delay ) || settings . delay < 0 || settings . delay > 40000 ) { return false ; } } else if ( settings . triggerMode === CaptureTriggerMode . FN_TRIGGER ) { return true ; } return true ; } /**
 * Checks if the preview settings of a CaptureSettings object comply to what the
 * platform is allowing
 */ export function validateCapturePreviewSettings ( settings ) { if ( ! CaptureModeList . includes ( settings . mode as any ) ) { return false ; } if ( settings . mode === CaptureMode . VIEWPORT ) { if ( ! settings . resX || ! settings . resY ) { return false ; } if ( isNaN ( settings . resX ) || isNaN ( settings . resY ) ) { return false ; } if ( settings . resX < 256 || settings . resX > 2048 || settings . resY < 256 || settings . resY > 2048 ) { return false ; } } else if ( settings . mode === CaptureMode . CANVAS ) { if ( ! settings . canvasSelector ) { return false ; } } return true ; } /**
 * Checks if a CaptureSettings object is correct and complies to what the platform
 * is allowing.
 * Wrapper to call all the sub methods responsible for the validaiton of the whole
 * object, grouped in logical validation parts.
 */ export function validateCaptureSettings ( settings ) { return validateCapturePreviewSettings ( settings ) && validateCaptureTriggerSettings ( settings ) ; }