/** * Internal dispatch/batch codes (e.g. "AUTO22-20260717 PILOT-04", "SOP-LG-001") * come from seeding/request keys and must never surface to employees. */ const CODE_TOKEN = /^[A-Za-z][A-Za-z0-9]*(?:[-_][A-Za-z0-9]+)+$/; const isCodeToken = (token: string) => CODE_TOKEN.test(token) && /\d/.test(token); /** True when the whole line is just an internal code (used to drop list items). */ export const isInternalCode = (text = '') => isCodeToken(text.trim()); /** Remove leading internal code tokens, keeping the human-readable remainder. */ export const stripInternalCodes = (text = '') => { const value = text.trim(); if (!value) return ''; const parts = value.split(/\s+/); let index = 0; while (index < parts.length && isCodeToken(parts[index])) index += 1; if (index === 0) return value; const rest = parts.slice(index).join(' ').trim(); return rest || value; };