import { callWithText as callArkWithText, type LlmCallOptions as ArkCallOptions } from './llmService'; import { resolvePrompt } from './promptRegistryService'; export function sanitizeMenuGroupIconSvg(raw: string): string | null { const match = raw.match(//i); if (!match) return null; let svg = match[0] .replace(//gi, '') .replace(//gi, '') .replace(/\son[a-z]+\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi, '') .replace(/xlink:href\s*=\s*("[^"]*"|'[^']*'|[^\s>]+)/gi, '') .replace(/href\s*=\s*("https?:[^"]*"|'https?:[^']*')/gi, ''); if (!/^]/i.test(svg)) return null; if (!/viewBox\s*=\s*["']0\s+0\s+24\s+24["']/i.test(svg)) { svg = svg.replace(/^ { const name = String(label || '').trim(); if (!name) return null; const prompt = await resolvePrompt('menu.group.icon_svg', { branchCode: options?.branchCode }); const content = await callArkWithText(prompt.systemPrompt, name, options); if (!content?.trim()) return null; return sanitizeMenuGroupIconSvg(content); }