/* 452 헬퍼 — B06 `stationKeysOf` 열쇠를 JSON 으로. * node helper_452_keys.mjs <묶음.mjs> <입력.json> * 입력 = { sections: [{chainage_m, kind}], structures: [{structure_id, chainage_m, start_m, end_m}], interval }. */ import { readFileSync } from "node:fs"; import { pathToFileURL } from "node:url"; const store = () => { const m = new Map(); return { getItem: (k) => (m.has(k) ? m.get(k) : null), setItem: (k, v) => m.set(k, String(v)), removeItem: (k) => m.delete(k), key: (i) => [...m.keys()][i] ?? null, get length() { return m.size; }, clear: () => m.clear(), }; }; globalThis.window = globalThis; globalThis.sessionStorage = store(); globalThis.localStorage = store(); const any = new Proxy(function () {}, { get: (_t, k) => (k === Symbol.toPrimitive ? () => 0 : any), apply: () => any, construct: () => any, }); globalThis.document = any; const [bundlePath, inputPath] = process.argv.slice(2); const m = await import(pathToFileURL(bundlePath).href); const input = JSON.parse(readFileSync(inputPath, "utf8")); m.useStructureIds("p452", input.structures); const sections = input.sections.map((s) => ({ station_id: `s${s.chainage_m}`, samples: [], ...s })); process.stdout.write(JSON.stringify(m.stationKeysOf("p452", sections, input.interval)));