File size: 626 Bytes
ef4c36f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// ponytail: ~150 wpm speech → ~500 chars lands in the 25-30s window
export const MAX_SCRIPT_CHARS = 500;
export const MIN_SCRIPT_CHARS = 380;
export const TARGET_SECONDS = "25-30";
export const MIN_VIDEO_SECONDS = 25;

export function enforceScriptLimit(script: string): string {
  const cleaned = script.trim().replace(/\s+/g, " ");
  if (cleaned.length <= MAX_SCRIPT_CHARS) return cleaned;

  const truncated = cleaned.slice(0, MAX_SCRIPT_CHARS);
  const lastSpace = truncated.lastIndexOf(" ");
  if (lastSpace > MAX_SCRIPT_CHARS * 0.6) {
    return truncated.slice(0, lastSpace).trim();
  }
  return truncated.trim();
}