export const TARGET_MODE_SELECTED = "selected";
export const TARGET_MODE_ALL = "all";
export const TARGET_MODE_FULL_FLUSH = "full_flush";
export const TARGET_MODE_CONFIGURED_POST_TYPES = "configured_post_types";

export const ALLOWED_TARGET_MODES = [
    TARGET_MODE_SELECTED,
    TARGET_MODE_ALL,
    TARGET_MODE_FULL_FLUSH,
];

export const ALLOWED_TIMED_TARGET_MODES = [
    ...ALLOWED_TARGET_MODES,
    TARGET_MODE_CONFIGURED_POST_TYPES,
];

export function normalizeTargetMode(
    value,
    fallback = TARGET_MODE_SELECTED,
    allowedModes = ALLOWED_TARGET_MODES,
) {
    return allowedModes.includes(value) ? value : fallback;
}

export function isFullFlushTargetMode(value) {
    return normalizeTargetMode(value) === TARGET_MODE_FULL_FLUSH;
}
