/**
 * Utility for handling symbol rendering in PDFs.
 * Manages detection and segmentation of text containing special symbols.
 * Enforces use of NotoSymbols font for specific characters.
 */

const SYMBOLS = ['☐', '☑', '☒', '✓', '✔', '•', '◦', '▪', '–', '—', '●', '○', '■'];
const SYMBOL_REGEX = new RegExp(`(${SYMBOLS.join('|')})`, 'g');

export const detectSymbols = (text) => {
  if (!text) return false;
  return SYMBOLS.some(symbol => text.includes(symbol));
};

export const splitTextBySymbols = (text) => {
  if (!text) return [];
  
  const parts = text.split(SYMBOL_REGEX);
  
  return parts
    .filter(part => part !== '')
    .map(part => ({
      text: part,
      isSymbol: SYMBOLS.includes(part)
    }));
};

export const getFontForSegment = (isSymbol, defaultFont = 'Helvetica') => {
  return isSymbol ? 'NotoSymbols' : defaultFont;
};

export const getSymbolSpacing = (symbol, fontSize) => {
  return 1.0; 
};
