/* ============================================================================= * B07_DesignDetail_Scale_Check.ts * ⚙ 축척 칸(485-2) 판정 — 칸 글 → 분모(정수 · 범위 안) · 자동 = null · 틀리면 까닭 글. * 서버 `checked_scales`(`_Router_Support_Scale.py`)와 같은 규칙 — 범위는 서버가 내려 줌. * ========================================================================== */ /** 칸 하나 읽기 — 숫자 · null(자동) · 까닭 글(틀림). */ export function readScaleAxis( raw: string, auto: boolean, [low, high]: [number, number], ): number | null | string { if (auto) return null; const text = raw.trim().replace(/,/g, ""); const value = Number(text); if (text === "" || !Number.isInteger(value) || value < low || value > high) { return `1/${low.toLocaleString()}~1/${high.toLocaleString()} 사이 정수`; } return value; } /** 보낼 값 — 기본값과 같으면 null(파일엔 기본 그대로 남김). */ export const scaleToSend = (value: number | null, fallback: number | null): number | null => value === fallback ? null : value;