/* ============================================================================= * B06_Section_UI_Cross_FillSlope_Notice.ts * 성토사면 5m 초과 **경고 줄** — 횡단 카드 목록 위 요약 한 줄 + 펼치면 측점 목록 * (2026-09-14 브레인 승인 (나)). 판정은 `_Cross_FillSlope_Warn`, 여기는 그리기만. * 측점을 누르면 그 카드로 간다. 경고만 — 구조물을 세우거나 값을 바꾸지 않는다. * ========================================================================== */ import type { CrossSection } from "./B06_Section_Api_Fetch"; import { fillSlopeLengths } from "./B06_Section_UI_Cross_Fit"; import { FILL_SLOPE_WARN_TEXT, fillSlopeWarnings } from "./B06_Section_UI_Cross_FillSlope_Warn"; import { L, stationLabel } from "./B06_Section_UI_Section_Common"; export interface FillSlopeNotice { root: HTMLDetailsElement; /** 측점 설계가 바뀔 때마다 부른다 — 펼침 상태는 그대로 둔다. */ update: (sections: ReadonlyArray, stationInterval: number) => void; } export function createFillSlopeNotice(onPick: (stationId: string) => void): FillSlopeNotice { const root = document.createElement("details"); root.className = "b06-section__notice"; root.hidden = true; const summary = document.createElement("summary"); const list = document.createElement("div"); list.className = "b06-section__notice-list"; root.append(summary, list); return { root, update(sections, stationInterval) { const warnings = fillSlopeWarnings(sections, fillSlopeLengths); root.hidden = !warnings.length; summary.textContent = `⚠ ${FILL_SLOPE_WARN_TEXT} · ${warnings.length}측점`; list.replaceChildren( ...warnings.map(({ section, sides }) => { const button = document.createElement("button"); button.type = "button"; const parts = sides.map(({ side, lengthM, open }) => { const label = L(side === "left" ? "B06_Design_Ditch_Left" : "B06_Design_Ditch_Right"); return `${label} ${open ? "≥" : ""}${lengthM.toFixed(2)}m`; }); button.textContent = `${stationLabel(section.chainage_m, stationInterval)} ${parts.join(" · ")}`; button.addEventListener("click", () => onPick(section.station_id)); return button; }), ); }, }; }