export const normalizeCitationDigits = (text: string) => { if (!text) return text; return text.replace(/[٠-٩۰-۹]/g, (char) => { const code = char.charCodeAt(0); if (code >= 0x0660 && code <= 0x0669) { return String.fromCharCode(code - 0x0660 + 0x30); } if (code >= 0x06f0 && code <= 0x06f9) { return String.fromCharCode(code - 0x06f0 + 0x30); } return char; }); }; export const parseCitationIndex = (value: string) => { const normalized = normalizeCitationDigits(value); const markerMatch = normalized.match(/\[(?:ID:)?(\d+)\]/); if (markerMatch) return Number(markerMatch[1]); if (/^\d+$/.test(normalized)) return Number(normalized); return Number.NaN; }; export const citationMarkerReg = /\[(?:ID:)?([0-9\u0660-\u0669\u06F0-\u06F9]+)\]/g;