import { PRESENTATION_AI_ACTION_PRICING_TYPE } from '../../constants'; import { PresentationAiActionPricingRules } from '../../models'; export function calculatePresentationAiActionPrice( pricingRules: PresentationAiActionPricingRules, selectionText: string, ): number { switch (pricingRules.type) { case PRESENTATION_AI_ACTION_PRICING_TYPE.PER_CHARACTER: const characterCount = selectionText.length; const price = characterCount * pricingRules.price; return Math.max(1, Math.ceil(price)); case PRESENTATION_AI_ACTION_PRICING_TYPE.FLAT: return Math.max(1, Math.ceil(pricingRules.price)); default: throw new Error(`Unknown pricing type`); } }