import { CREDITS_ARTICLE_IMAGE, formatCredits } from '../../lib/credit-costs'; /** * What publishing with images adds to the bill: one picture for every image * the article suggests that has none yet, since the ones already made are * reused rather than drawn again. * * @param {number} suggested - Images the article suggests. * @param {number} ready - Suggestions that already have a picture. * @returns {string} The sentence the publish dialog prints. */ export const blogImagesCost = (suggested: number, ready: number): string => { const missing = Math.max(0, suggested - ready); const each = formatCredits(CREDITS_ARTICLE_IMAGE); if (suggested === 0) return `Each image costs ${each}.`; if (missing === 0) { return suggested === 1 ? 'Its image is already made, so this costs nothing more.' : `Its ${suggested} images are already made, so this costs nothing more.`; } const count = missing === 1 ? 'the 1 image' : `the ${missing} images`; return `It draws ${count} still missing at ${each} each, ${formatCredits( missing * CREDITS_ARTICLE_IMAGE )} in all.`; };