kordoc 3.15.0 → 3.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +20 -0
  2. package/dist/{-EYPKRLMN.js → -H7N62NZU.js} +17 -12
  3. package/dist/{chunk-734GJLXH.js → chunk-5RHRQ7HK.js} +10 -176
  4. package/dist/chunk-5RHRQ7HK.js.map +1 -0
  5. package/dist/{chunk-DMBTOJK4.cjs → chunk-BIP4JAVG.cjs} +2 -2
  6. package/dist/{chunk-DMBTOJK4.cjs.map → chunk-BIP4JAVG.cjs.map} +1 -1
  7. package/dist/chunk-FGL7BH4P.js +1019 -0
  8. package/dist/chunk-FGL7BH4P.js.map +1 -0
  9. package/dist/{chunk-SCFFABCT.js → chunk-IC56KHBL.js} +2 -2
  10. package/dist/chunk-JFNWJFKP.js +185 -0
  11. package/dist/chunk-JFNWJFKP.js.map +1 -0
  12. package/dist/{chunk-Q5ZPWQID.js → chunk-LYL4IL3E.js} +2 -2
  13. package/dist/{chunk-ZRNYYEE6.js → chunk-Q7EGGW3H.js} +2 -2
  14. package/dist/{chunk-Q3IHI3E6.js → chunk-WD5NUUU6.js} +267 -705
  15. package/dist/chunk-WD5NUUU6.js.map +1 -0
  16. package/dist/cli.js +63 -11
  17. package/dist/cli.js.map +1 -1
  18. package/dist/index.cjs +856 -304
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.cts +65 -1
  21. package/dist/index.d.ts +65 -1
  22. package/dist/index.js +682 -130
  23. package/dist/index.js.map +1 -1
  24. package/dist/mcp.js +65 -7
  25. package/dist/mcp.js.map +1 -1
  26. package/dist/{parser-SNBQZO5E.js → parser-5G247XYD.js} +2 -2
  27. package/dist/{parser-O2SD4DFR.cjs → parser-6V7F3GET.cjs} +14 -14
  28. package/dist/{parser-O2SD4DFR.cjs.map → parser-6V7F3GET.cjs.map} +1 -1
  29. package/dist/{parser-76JSTEP3.js → parser-HBHCD7TE.js} +3 -3
  30. package/dist/render-VA4NHROW.js +10 -0
  31. package/dist/seal-UVDRGHEF.js +10 -0
  32. package/dist/seal-UVDRGHEF.js.map +1 -0
  33. package/dist/{watch-LEK5U5P6.js → watch-HIYNOSFD.js} +7 -5
  34. package/dist/{watch-LEK5U5P6.js.map → watch-HIYNOSFD.js.map} +1 -1
  35. package/package.json +1 -1
  36. package/dist/chunk-734GJLXH.js.map +0 -1
  37. package/dist/chunk-Q3IHI3E6.js.map +0 -1
  38. package/dist/render-LDI3LO2P.js +0 -9
  39. /package/dist/{-EYPKRLMN.js.map → -H7N62NZU.js.map} +0 -0
  40. /package/dist/{chunk-SCFFABCT.js.map → chunk-IC56KHBL.js.map} +0 -0
  41. /package/dist/{chunk-Q5ZPWQID.js.map → chunk-LYL4IL3E.js.map} +0 -0
  42. /package/dist/{chunk-ZRNYYEE6.js.map → chunk-Q7EGGW3H.js.map} +0 -0
  43. /package/dist/{parser-SNBQZO5E.js.map → parser-5G247XYD.js.map} +0 -0
  44. /package/dist/{parser-76JSTEP3.js.map → parser-HBHCD7TE.js.map} +0 -0
  45. /package/dist/{render-LDI3LO2P.js.map → render-VA4NHROW.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -19,7 +19,7 @@
19
19
 
20
20
 
21
21
 
22
- var _chunkDMBTOJK4cjs = require('./chunk-DMBTOJK4.cjs');
22
+ var _chunkBIP4JAVGcjs = require('./chunk-BIP4JAVG.cjs');
23
23
 
24
24
 
25
25
  var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
@@ -405,7 +405,7 @@ function createSectionShared() {
405
405
  function createXmlParser(warnings) {
406
406
  return new (0, _xmldom.DOMParser)({
407
407
  onError(level, msg2) {
408
- if (level === "fatalError") throw new (0, _chunkDMBTOJK4cjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
408
+ if (level === "fatalError") throw new (0, _chunkBIP4JAVGcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
409
409
  _optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warn" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
410
410
  }
411
411
  });
@@ -460,10 +460,10 @@ async function extractHwpxStyles(zip, decompressed) {
460
460
  const xml = await file.async("text");
461
461
  if (decompressed) {
462
462
  decompressed.total += xml.length * 2;
463
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDMBTOJK4cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
463
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
464
464
  }
465
465
  const parser = createXmlParser();
466
- const doc = parser.parseFromString(_chunkDMBTOJK4cjs.stripDtd.call(void 0, xml), "text/xml");
466
+ const doc = parser.parseFromString(_chunkBIP4JAVGcjs.stripDtd.call(void 0, xml), "text/xml");
467
467
  if (!doc.documentElement) continue;
468
468
  parseCharProperties(doc, result.charProperties);
469
469
  parseStyleElements(doc, result.styles);
@@ -615,9 +615,9 @@ function detectHwpxHeadings(blocks, styleMap) {
615
615
  let level = 0;
616
616
  if (baseFontSize > 0 && _optionalChain([block, 'access', _7 => _7.style, 'optionalAccess', _8 => _8.fontSize])) {
617
617
  const ratio = block.style.fontSize / baseFontSize;
618
- if (ratio >= _chunkDMBTOJK4cjs.HEADING_RATIO_H1) level = 1;
619
- else if (ratio >= _chunkDMBTOJK4cjs.HEADING_RATIO_H2) level = 2;
620
- else if (ratio >= _chunkDMBTOJK4cjs.HEADING_RATIO_H3) level = 3;
618
+ if (ratio >= _chunkBIP4JAVGcjs.HEADING_RATIO_H1) level = 1;
619
+ else if (ratio >= _chunkBIP4JAVGcjs.HEADING_RATIO_H2) level = 2;
620
+ else if (ratio >= _chunkBIP4JAVGcjs.HEADING_RATIO_H3) level = 3;
621
621
  }
622
622
  const compactText = text.replace(/\s+/g, "");
623
623
  if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
@@ -1183,7 +1183,7 @@ function resolveParaHeading(paraEl, ctx) {
1183
1183
 
1184
1184
  // src/hwpx/table-build.ts
1185
1185
  function buildTableWithCellMeta(state) {
1186
- const table = _chunkDMBTOJK4cjs.buildTable.call(void 0, state.rows);
1186
+ const table = _chunkBIP4JAVGcjs.buildTable.call(void 0, state.rows);
1187
1187
  if (state.caption) table.caption = state.caption;
1188
1188
  const anchors = [];
1189
1189
  {
@@ -1253,7 +1253,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1253
1253
  const cell = parentTable.cell;
1254
1254
  (cell.blocks ??= []).push(block);
1255
1255
  cell.hasStructure = true;
1256
- let flat = _chunkDMBTOJK4cjs.convertTableToText.call(void 0, newTable.rows);
1256
+ let flat = _chunkBIP4JAVGcjs.convertTableToText.call(void 0, newTable.rows);
1257
1257
  if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
1258
1258
  if (flat) cell.text += (cell.text ? "\n" : "") + flat;
1259
1259
  } else {
@@ -1265,7 +1265,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1265
1265
  // src/hwpx/section-walker.ts
1266
1266
  function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
1267
1267
  const parser = createXmlParser(warnings);
1268
- const doc = parser.parseFromString(_chunkDMBTOJK4cjs.stripDtd.call(void 0, xml), "text/xml");
1268
+ const doc = parser.parseFromString(_chunkBIP4JAVGcjs.stripDtd.call(void 0, xml), "text/xml");
1269
1269
  if (!doc.documentElement) return [];
1270
1270
  const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
1271
1271
  ctx.shared.track.deleteDepth = 0;
@@ -1356,8 +1356,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
1356
1356
  const cs = isNaN(rawCs) ? 1 : rawCs;
1357
1357
  const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
1358
1358
  const rs = isNaN(rawRs) ? 1 : rawRs;
1359
- tableCtx.cell.colSpan = clampSpan(cs, _chunkDMBTOJK4cjs.MAX_COLS);
1360
- tableCtx.cell.rowSpan = clampSpan(rs, _chunkDMBTOJK4cjs.MAX_ROWS);
1359
+ tableCtx.cell.colSpan = clampSpan(cs, _chunkBIP4JAVGcjs.MAX_COLS);
1360
+ tableCtx.cell.rowSpan = clampSpan(rs, _chunkBIP4JAVGcjs.MAX_ROWS);
1361
1361
  }
1362
1362
  break;
1363
1363
  case "p": {
@@ -1579,7 +1579,7 @@ function extractHyperlinkHref(fieldBegin) {
1579
1579
  let url = (ch.textContent || "").trim();
1580
1580
  if (!url) continue;
1581
1581
  url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
1582
- const safe = _chunkDMBTOJK4cjs.sanitizeHref.call(void 0, url);
1582
+ const safe = _chunkBIP4JAVGcjs.sanitizeHref.call(void 0, url);
1583
1583
  if (safe) return safe;
1584
1584
  }
1585
1585
  return void 0;
@@ -1714,7 +1714,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
1714
1714
  case "hyperlink": {
1715
1715
  const url = child.getAttribute("url") || child.getAttribute("href") || "";
1716
1716
  if (url) {
1717
- const safe = _chunkDMBTOJK4cjs.sanitizeHref.call(void 0, url);
1717
+ const safe = _chunkBIP4JAVGcjs.sanitizeHref.call(void 0, url);
1718
1718
  if (safe) href = safe;
1719
1719
  }
1720
1720
  walk(child);
@@ -1900,13 +1900,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
1900
1900
  }
1901
1901
  const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
1902
1902
  for (const path of allCandidates) {
1903
- if (_chunkDMBTOJK4cjs.isPathTraversal.call(void 0, path)) continue;
1903
+ if (_chunkBIP4JAVGcjs.isPathTraversal.call(void 0, path)) continue;
1904
1904
  const file = zip.file(path);
1905
1905
  if (!file) continue;
1906
1906
  try {
1907
1907
  const data = await file.async("uint8array");
1908
1908
  decompressed.total += data.length;
1909
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDMBTOJK4cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1909
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1910
1910
  const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
1911
1911
  const mimeType = imageExtToMime(ext);
1912
1912
  imageIndex++;
@@ -1915,7 +1915,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
1915
1915
  images.push(img);
1916
1916
  break;
1917
1917
  } catch (err) {
1918
- if (err instanceof _chunkDMBTOJK4cjs.KordocError) throw err;
1918
+ if (err instanceof _chunkBIP4JAVGcjs.KordocError) throw err;
1919
1919
  }
1920
1920
  }
1921
1921
  if (!img) _optionalChain([warnings, 'optionalAccess', _38 => _38.push, 'call', _39 => _39({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
@@ -1977,7 +1977,7 @@ function extractFromBrokenZip(buffer) {
1977
1977
  }
1978
1978
  const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
1979
1979
  const name = new TextDecoder().decode(nameBytes);
1980
- if (_chunkDMBTOJK4cjs.isPathTraversal.call(void 0, name)) {
1980
+ if (_chunkBIP4JAVGcjs.isPathTraversal.call(void 0, name)) {
1981
1981
  pos = fileStart + compSize;
1982
1982
  continue;
1983
1983
  }
@@ -1995,16 +1995,16 @@ function extractFromBrokenZip(buffer) {
1995
1995
  continue;
1996
1996
  }
1997
1997
  totalDecompressed += content.length * 2;
1998
- if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDMBTOJK4cjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
1998
+ if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
1999
1999
  sectionNum++;
2000
2000
  blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
2001
2001
  } catch (e13) {
2002
2002
  continue;
2003
2003
  }
2004
2004
  }
2005
- if (blocks.length === 0) throw new (0, _chunkDMBTOJK4cjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
2005
+ if (blocks.length === 0) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
2006
2006
  applyPageText(blocks, shared);
2007
- const markdown = _chunkDMBTOJK4cjs.blocksToMarkdown.call(void 0, blocks);
2007
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, blocks);
2008
2008
  return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
2009
2009
  }
2010
2010
  async function resolveSectionPaths(zip) {
@@ -2018,18 +2018,18 @@ async function resolveSectionPaths(zip) {
2018
2018
  if (paths.length > 0) return paths;
2019
2019
  }
2020
2020
  const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
2021
- return sectionFiles.map((f) => f.name).sort(_chunkDMBTOJK4cjs.compareSectionPaths);
2021
+ return sectionFiles.map((f) => f.name).sort(_chunkBIP4JAVGcjs.compareSectionPaths);
2022
2022
  }
2023
2023
  function parseSectionPathsFromManifest(xml) {
2024
2024
  const parser = createXmlParser();
2025
- const doc = parser.parseFromString(_chunkDMBTOJK4cjs.stripDtd.call(void 0, xml), "text/xml");
2025
+ const doc = parser.parseFromString(_chunkBIP4JAVGcjs.stripDtd.call(void 0, xml), "text/xml");
2026
2026
  const items = doc.getElementsByTagName("opf:item");
2027
2027
  const spine = doc.getElementsByTagName("opf:itemref");
2028
2028
  const idToHref = /* @__PURE__ */ new Map();
2029
2029
  for (let i = 0; i < items.length; i++) {
2030
2030
  const item = items[i];
2031
2031
  const id = item.getAttribute("id") || "";
2032
- const href = _chunkDMBTOJK4cjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
2032
+ const href = _chunkBIP4JAVGcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
2033
2033
  if (id && href) idToHref.set(id, href);
2034
2034
  }
2035
2035
  if (spine.length > 0) {
@@ -2040,7 +2040,7 @@ function parseSectionPathsFromManifest(xml) {
2040
2040
  }
2041
2041
  if (ordered.length > 0) return ordered;
2042
2042
  }
2043
- return Array.from(idToHref.values()).sort(_chunkDMBTOJK4cjs.compareSectionPaths);
2043
+ return Array.from(idToHref.values()).sort(_chunkBIP4JAVGcjs.compareSectionPaths);
2044
2044
  }
2045
2045
 
2046
2046
  // src/hwpx/metadata.ts
@@ -2053,7 +2053,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
2053
2053
  const xml = await file.async("text");
2054
2054
  if (decompressed) {
2055
2055
  decompressed.total += xml.length * 2;
2056
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDMBTOJK4cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2056
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2057
2057
  }
2058
2058
  parseDublinCoreMetadata(xml, metadata);
2059
2059
  if (metadata.title || metadata.author) return;
@@ -2063,7 +2063,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
2063
2063
  }
2064
2064
  function parseDublinCoreMetadata(xml, metadata) {
2065
2065
  const parser = createXmlParser();
2066
- const doc = parser.parseFromString(_chunkDMBTOJK4cjs.stripDtd.call(void 0, xml), "text/xml");
2066
+ const doc = parser.parseFromString(_chunkBIP4JAVGcjs.stripDtd.call(void 0, xml), "text/xml");
2067
2067
  if (!doc.documentElement) return;
2068
2068
  const getText = (tagNames) => {
2069
2069
  for (const tag of tagNames) {
@@ -2088,7 +2088,7 @@ function parseDublinCoreMetadata(xml, metadata) {
2088
2088
 
2089
2089
  // src/hwpx/parser.ts
2090
2090
  async function parseHwpxDocument(buffer, options) {
2091
- _chunkDMBTOJK4cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
2091
+ _chunkBIP4JAVGcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
2092
2092
  let zip;
2093
2093
  try {
2094
2094
  zip = await _jszip2.default.loadAsync(buffer);
@@ -2097,7 +2097,7 @@ async function parseHwpxDocument(buffer, options) {
2097
2097
  }
2098
2098
  const actualEntryCount = Object.keys(zip.files).length;
2099
2099
  if (actualEntryCount > MAX_ZIP_ENTRIES) {
2100
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2100
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2101
2101
  }
2102
2102
  const manifestFile = zip.file("META-INF/manifest.xml");
2103
2103
  if (manifestFile) {
@@ -2109,7 +2109,7 @@ async function parseHwpxDocument(buffer, options) {
2109
2109
  return comResultToParseResult(pages, pageCount, warnings2);
2110
2110
  }
2111
2111
  }
2112
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
2112
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
2113
2113
  }
2114
2114
  }
2115
2115
  const decompressed = { total: 0 };
@@ -2118,7 +2118,7 @@ async function parseHwpxDocument(buffer, options) {
2118
2118
  const styleMap = await extractHwpxStyles(zip, decompressed);
2119
2119
  const warnings = [];
2120
2120
  const sectionPaths = await resolveSectionPaths(zip);
2121
- if (sectionPaths.length === 0) throw new (0, _chunkDMBTOJK4cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
2121
+ if (sectionPaths.length === 0) throw new (0, _chunkBIP4JAVGcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
2122
2122
  metadata.pageCount = sectionPaths.length;
2123
2123
  const pageFilter = _optionalChain([options, 'optionalAccess', _45 => _45.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
2124
2124
  const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
@@ -2132,12 +2132,12 @@ async function parseHwpxDocument(buffer, options) {
2132
2132
  try {
2133
2133
  const xml = await file.async("text");
2134
2134
  decompressed.total += xml.length * 2;
2135
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDMBTOJK4cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2135
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2136
2136
  blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
2137
2137
  parsedSections++;
2138
2138
  _optionalChain([options, 'optionalAccess', _46 => _46.onProgress, 'optionalCall', _47 => _47(parsedSections, totalTarget)]);
2139
2139
  } catch (secErr) {
2140
- if (secErr instanceof _chunkDMBTOJK4cjs.KordocError) throw secErr;
2140
+ if (secErr instanceof _chunkBIP4JAVGcjs.KordocError) throw secErr;
2141
2141
  warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
2142
2142
  }
2143
2143
  }
@@ -2145,7 +2145,7 @@ async function parseHwpxDocument(buffer, options) {
2145
2145
  const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
2146
2146
  detectHwpxHeadings(blocks, styleMap);
2147
2147
  const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
2148
- const markdown = _chunkDMBTOJK4cjs.blocksToMarkdown.call(void 0, blocks);
2148
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, blocks);
2149
2149
  return { markdown, blocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
2150
2150
  }
2151
2151
 
@@ -2212,7 +2212,7 @@ function decompressStream(data) {
2212
2212
  return _zlib.inflateRawSync.call(void 0, data, opts);
2213
2213
  }
2214
2214
  function parseFileHeader(data) {
2215
- if (data.length < 40) throw new (0, _chunkDMBTOJK4cjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
2215
+ if (data.length < 40) throw new (0, _chunkBIP4JAVGcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
2216
2216
  const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
2217
2217
  return {
2218
2218
  signature: sig,
@@ -3745,7 +3745,7 @@ function parseHwp5Document(buffer, options) {
3745
3745
  lenientCfb = parseLenientCfb(buffer);
3746
3746
  warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
3747
3747
  } catch (e21) {
3748
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
3748
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
3749
3749
  }
3750
3750
  }
3751
3751
  const findStream = (path) => {
@@ -3756,11 +3756,11 @@ function parseHwp5Document(buffer, options) {
3756
3756
  return lenientCfb.findStream(path);
3757
3757
  };
3758
3758
  const headerData = findStream("/FileHeader");
3759
- if (!headerData) throw new (0, _chunkDMBTOJK4cjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
3759
+ if (!headerData) throw new (0, _chunkBIP4JAVGcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
3760
3760
  const header = parseFileHeader(headerData);
3761
- if (header.signature !== "HWP Document File") throw new (0, _chunkDMBTOJK4cjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
3762
- if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkDMBTOJK4cjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3763
- if (header.flags & FLAG_DRM) throw new (0, _chunkDMBTOJK4cjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3761
+ if (header.signature !== "HWP Document File") throw new (0, _chunkBIP4JAVGcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
3762
+ if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3763
+ if (header.flags & FLAG_DRM) throw new (0, _chunkBIP4JAVGcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3764
3764
  const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
3765
3765
  const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
3766
3766
  const metadata = {
@@ -3769,7 +3769,7 @@ function parseHwp5Document(buffer, options) {
3769
3769
  if (cfb) extractHwp5Metadata(cfb, metadata);
3770
3770
  const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
3771
3771
  const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
3772
- if (sections.length === 0) throw new (0, _chunkDMBTOJK4cjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3772
+ if (sections.length === 0) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3773
3773
  metadata.pageCount = sections.length;
3774
3774
  const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
3775
3775
  const totalTarget = pageFilter ? pageFilter.size : sections.length;
@@ -3783,25 +3783,25 @@ function parseHwp5Document(buffer, options) {
3783
3783
  const sectionData = sections[si];
3784
3784
  const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
3785
3785
  totalDecompressed += data.length;
3786
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDMBTOJK4cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3786
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3787
3787
  const records = readRecords(data);
3788
3788
  const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
3789
3789
  bodyBlocks.push(...sectionBlocks);
3790
3790
  parsedSections++;
3791
3791
  _optionalChain([options, 'optionalAccess', _52 => _52.onProgress, 'optionalCall', _53 => _53(parsedSections, totalTarget)]);
3792
3792
  } catch (secErr) {
3793
- if (secErr instanceof _chunkDMBTOJK4cjs.KordocError) throw secErr;
3793
+ if (secErr instanceof _chunkBIP4JAVGcjs.KordocError) throw secErr;
3794
3794
  warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
3795
3795
  }
3796
3796
  }
3797
3797
  const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
3798
3798
  const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
3799
- const flatBlocks = _chunkDMBTOJK4cjs.flattenLayoutTables.call(void 0, blocks);
3799
+ const flatBlocks = _chunkBIP4JAVGcjs.flattenLayoutTables.call(void 0, blocks);
3800
3800
  if (docInfo) {
3801
3801
  detectHwp5Headings(flatBlocks, docInfo);
3802
3802
  }
3803
3803
  const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
3804
- const markdown = _chunkDMBTOJK4cjs.blocksToMarkdown.call(void 0, flatBlocks);
3804
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, flatBlocks);
3805
3805
  return { markdown, blocks: flatBlocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
3806
3806
  }
3807
3807
  function parseDocInfoStream(cfb, compressed) {
@@ -3861,9 +3861,9 @@ function detectHwp5Headings(blocks, docInfo) {
3861
3861
  let level = 0;
3862
3862
  if (_optionalChain([block, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]) && baseFontSize > 0) {
3863
3863
  const ratio = block.style.fontSize / baseFontSize;
3864
- if (ratio >= _chunkDMBTOJK4cjs.HEADING_RATIO_H1) level = 1;
3865
- else if (ratio >= _chunkDMBTOJK4cjs.HEADING_RATIO_H2) level = 2;
3866
- else if (ratio >= _chunkDMBTOJK4cjs.HEADING_RATIO_H3) level = 3;
3864
+ if (ratio >= _chunkBIP4JAVGcjs.HEADING_RATIO_H1) level = 1;
3865
+ else if (ratio >= _chunkBIP4JAVGcjs.HEADING_RATIO_H2) level = 2;
3866
+ else if (ratio >= _chunkBIP4JAVGcjs.HEADING_RATIO_H3) level = 3;
3867
3867
  }
3868
3868
  if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
3869
3869
  if (level === 0) level = 2;
@@ -3948,7 +3948,7 @@ function findSectionsLenient(lcfb, compressed) {
3948
3948
  if (!raw) break;
3949
3949
  const content = compressed ? decompressStream(raw) : raw;
3950
3950
  totalDecompressed += content.length;
3951
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDMBTOJK4cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3951
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3952
3952
  sections.push({ idx: i, content });
3953
3953
  }
3954
3954
  if (sections.length === 0) {
@@ -3960,7 +3960,7 @@ function findSectionsLenient(lcfb, compressed) {
3960
3960
  if (raw) {
3961
3961
  const content = compressed ? decompressStream(raw) : raw;
3962
3962
  totalDecompressed += content.length;
3963
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDMBTOJK4cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3963
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3964
3964
  sections.push({ idx, content });
3965
3965
  }
3966
3966
  }
@@ -3977,7 +3977,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
3977
3977
  try {
3978
3978
  const content = decryptViewText(raw, compressed);
3979
3979
  totalDecompressed += content.length;
3980
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkDMBTOJK4cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3980
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3981
3981
  sections.push({ idx: i, content });
3982
3982
  } catch (e26) {
3983
3983
  break;
@@ -4080,7 +4080,7 @@ function parseParagraph(records, start, end, ctx) {
4080
4080
  const ctrl = ctrls[r.ctrlIdx];
4081
4081
  if (!_optionalChain([ctrl, 'optionalAccess', _66 => _66.href]) || r.end <= r.start) continue;
4082
4082
  if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
4083
- const href = _chunkDMBTOJK4cjs.sanitizeHref.call(void 0, ctrl.href);
4083
+ const href = _chunkBIP4JAVGcjs.sanitizeHref.call(void 0, ctrl.href);
4084
4084
  if (!href) continue;
4085
4085
  const anchor = text.slice(r.start, r.end);
4086
4086
  if (!anchor.trim()) continue;
@@ -4313,8 +4313,8 @@ function parseTableControl(ctrl, records, ctx) {
4313
4313
  let tableIdx = -1;
4314
4314
  for (let i2 = childStart; i2 < childEnd; i2++) {
4315
4315
  if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
4316
- rows = Math.min(records[i2].data.readUInt16LE(4), _chunkDMBTOJK4cjs.MAX_ROWS);
4317
- cols = Math.min(records[i2].data.readUInt16LE(6), _chunkDMBTOJK4cjs.MAX_COLS);
4316
+ rows = Math.min(records[i2].data.readUInt16LE(4), _chunkBIP4JAVGcjs.MAX_ROWS);
4317
+ cols = Math.min(records[i2].data.readUInt16LE(6), _chunkBIP4JAVGcjs.MAX_COLS);
4318
4318
  tableIdx = i2;
4319
4319
  break;
4320
4320
  }
@@ -4363,7 +4363,7 @@ function parseTableControl(ctrl, records, ctx) {
4363
4363
  return table2;
4364
4364
  }
4365
4365
  const cellRows = arrangeCells(rows, cols, cells);
4366
- const table = _chunkDMBTOJK4cjs.buildTable.call(void 0, cellRows);
4366
+ const table = _chunkBIP4JAVGcjs.buildTable.call(void 0, cellRows);
4367
4367
  if (caption && table.rows > 0) table.caption = caption;
4368
4368
  return table.rows > 0 ? table : null;
4369
4369
  }
@@ -4380,8 +4380,8 @@ function parseCell(records, lhIdx, end, ctx) {
4380
4380
  rowAddr = rec.data.readUInt16LE(10);
4381
4381
  const cs = rec.data.readUInt16LE(12);
4382
4382
  const rs = rec.data.readUInt16LE(14);
4383
- if (cs > 0) colSpan = Math.min(cs, _chunkDMBTOJK4cjs.MAX_COLS);
4384
- if (rs > 0) rowSpan = Math.min(rs, _chunkDMBTOJK4cjs.MAX_ROWS);
4383
+ if (cs > 0) colSpan = Math.min(cs, _chunkBIP4JAVGcjs.MAX_COLS);
4384
+ if (rs > 0) rowSpan = Math.min(rs, _chunkBIP4JAVGcjs.MAX_ROWS);
4385
4385
  }
4386
4386
  const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
4387
4387
  const parts = [];
@@ -4391,7 +4391,7 @@ function parseCell(records, lhIdx, end, ctx) {
4391
4391
  parts.push(`![image](hwp5bin:${b.text})`);
4392
4392
  hasStructure = true;
4393
4393
  } else if (b.type === "table" && b.table) {
4394
- const flat = _chunkDMBTOJK4cjs.convertTableToText.call(void 0, b.table.cells);
4394
+ const flat = _chunkBIP4JAVGcjs.convertTableToText.call(void 0, b.table.cells);
4395
4395
  if (flat) parts.push(flat);
4396
4396
  hasStructure = true;
4397
4397
  } else if (b.text) {
@@ -16828,7 +16828,7 @@ function getTextContent(el) {
16828
16828
  return _nullishCoalesce(_optionalChain([el, 'access', _81 => _81.textContent, 'optionalAccess', _82 => _82.trim, 'call', _83 => _83()]), () => ( ""));
16829
16829
  }
16830
16830
  function parseXml(text) {
16831
- return new (0, _xmldom.DOMParser)().parseFromString(_chunkDMBTOJK4cjs.stripDtd.call(void 0, text), "text/xml");
16831
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunkBIP4JAVGcjs.stripDtd.call(void 0, text), "text/xml");
16832
16832
  }
16833
16833
  function parseSharedStrings(xml) {
16834
16834
  const doc = parseXml(xml);
@@ -16972,7 +16972,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
16972
16972
  cellRows.push(row);
16973
16973
  }
16974
16974
  if (cellRows.length > 0) {
16975
- const table = _chunkDMBTOJK4cjs.buildTable.call(void 0, cellRows);
16975
+ const table = _chunkBIP4JAVGcjs.buildTable.call(void 0, cellRows);
16976
16976
  if (table.rows > 0) {
16977
16977
  blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
16978
16978
  }
@@ -16980,12 +16980,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
16980
16980
  return blocks;
16981
16981
  }
16982
16982
  async function parseXlsxDocument(buffer, options) {
16983
- _chunkDMBTOJK4cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
16983
+ _chunkBIP4JAVGcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
16984
16984
  const zip = await _jszip2.default.loadAsync(buffer);
16985
16985
  const warnings = [];
16986
16986
  const workbookFile = zip.file("xl/workbook.xml");
16987
16987
  if (!workbookFile) {
16988
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
16988
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
16989
16989
  }
16990
16990
  let sharedStrings = [];
16991
16991
  const ssFile = zip.file("xl/sharedStrings.xml");
@@ -16994,7 +16994,7 @@ async function parseXlsxDocument(buffer, options) {
16994
16994
  }
16995
16995
  const sheets = parseWorkbook(await workbookFile.async("text"));
16996
16996
  if (sheets.length === 0) {
16997
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
16997
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
16998
16998
  }
16999
16999
  let relsMap = /* @__PURE__ */ new Map();
17000
17000
  const relsFile = zip.file("xl/_rels/workbook.xml.rels");
@@ -17066,7 +17066,7 @@ async function parseXlsxDocument(buffer, options) {
17066
17066
  } catch (e27) {
17067
17067
  }
17068
17068
  }
17069
- const markdown = _chunkDMBTOJK4cjs.blocksToMarkdown.call(void 0, blocks);
17069
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, blocks);
17070
17070
  return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
17071
17071
  }
17072
17072
 
@@ -17473,11 +17473,11 @@ function processGlobals(records) {
17473
17473
  let encrypted = false;
17474
17474
  const firstBof = records[0];
17475
17475
  if (!firstBof || firstBof.opcode !== OP_BOF) {
17476
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
17476
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
17477
17477
  }
17478
17478
  const bof = decodeBof(firstBof.data);
17479
17479
  if (!bof || bof.dt !== DT_GLOBALS) {
17480
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
17480
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
17481
17481
  }
17482
17482
  let i = 1;
17483
17483
  while (i < records.length) {
@@ -17592,7 +17592,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
17592
17592
  cellRows.push(row);
17593
17593
  }
17594
17594
  if (cellRows.length > 0) {
17595
- const table = _chunkDMBTOJK4cjs.buildTable.call(void 0, cellRows);
17595
+ const table = _chunkBIP4JAVGcjs.buildTable.call(void 0, cellRows);
17596
17596
  if (table.rows > 0) {
17597
17597
  blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
17598
17598
  }
@@ -17605,21 +17605,21 @@ async function parseXlsDocument(buffer, options) {
17605
17605
  try {
17606
17606
  cfb = parseLenientCfb(buf);
17607
17607
  } catch (e) {
17608
- throw new (0, _chunkDMBTOJK4cjs.KordocError)(
17608
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)(
17609
17609
  `XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
17610
17610
  );
17611
17611
  }
17612
17612
  const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
17613
17613
  if (!wb) {
17614
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
17614
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
17615
17615
  }
17616
17616
  const records = readRecords2(wb);
17617
17617
  if (records.length === 0) {
17618
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
17618
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
17619
17619
  }
17620
17620
  const firstBof = decodeBof(records[0].data);
17621
17621
  if (firstBof && firstBof.vers !== 1536) {
17622
- throw new (0, _chunkDMBTOJK4cjs.KordocError)(
17622
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)(
17623
17623
  `XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
17624
17624
  );
17625
17625
  }
@@ -17679,7 +17679,7 @@ async function parseXlsDocument(buffer, options) {
17679
17679
  pageCount: totalSheets
17680
17680
  };
17681
17681
  return {
17682
- markdown: _chunkDMBTOJK4cjs.blocksToMarkdown.call(void 0, allBlocks),
17682
+ markdown: _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, allBlocks),
17683
17683
  blocks: allBlocks,
17684
17684
  metadata,
17685
17685
  warnings: warnings.length > 0 ? warnings : void 0
@@ -18117,7 +18117,7 @@ function getAttr(el, localName2) {
18117
18117
  return null;
18118
18118
  }
18119
18119
  function parseXml2(text) {
18120
- return new (0, _xmldom.DOMParser)().parseFromString(_chunkDMBTOJK4cjs.stripDtd.call(void 0, text), "text/xml");
18120
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunkBIP4JAVGcjs.stripDtd.call(void 0, text), "text/xml");
18121
18121
  }
18122
18122
  function parseStyles(xml) {
18123
18123
  const doc = parseXml2(xml);
@@ -18402,7 +18402,7 @@ ${cell.text}` : cell.text;
18402
18402
  return { text: cell.text, colSpan: cell.colSpan, rowSpan, colAddr: cell.col, rowAddr: r };
18403
18403
  })
18404
18404
  );
18405
- const table = _chunkDMBTOJK4cjs.buildTable.call(void 0, cellRows);
18405
+ const table = _chunkBIP4JAVGcjs.buildTable.call(void 0, cellRows);
18406
18406
  if (table.rows === 0 || table.cols === 0) return null;
18407
18407
  return { type: "table", table };
18408
18408
  }
@@ -18469,12 +18469,12 @@ async function extractImages(zip, rels, doc, warnings) {
18469
18469
  return { blocks, images };
18470
18470
  }
18471
18471
  async function parseDocxDocument(buffer, options) {
18472
- _chunkDMBTOJK4cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
18472
+ _chunkBIP4JAVGcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
18473
18473
  const zip = await _jszip2.default.loadAsync(buffer);
18474
18474
  const warnings = [];
18475
18475
  const docFile = zip.file("word/document.xml");
18476
18476
  if (!docFile) {
18477
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
18477
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
18478
18478
  }
18479
18479
  let rels = /* @__PURE__ */ new Map();
18480
18480
  const relsFile = zip.file("word/_rels/document.xml.rels");
@@ -18521,7 +18521,7 @@ async function parseDocxDocument(buffer, options) {
18521
18521
  const doc = parseXml2(docXml);
18522
18522
  const body = findElements(doc, "body");
18523
18523
  if (body.length === 0) {
18524
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
18524
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
18525
18525
  }
18526
18526
  const blocks = [];
18527
18527
  const bodyEl = body[0];
@@ -18566,7 +18566,7 @@ async function parseDocxDocument(buffer, options) {
18566
18566
  }
18567
18567
  }
18568
18568
  const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
18569
- const markdown = _chunkDMBTOJK4cjs.blocksToMarkdown.call(void 0, blocks);
18569
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, blocks);
18570
18570
  return {
18571
18571
  markdown,
18572
18572
  blocks,
@@ -18589,7 +18589,7 @@ function parseHwpmlDocument(buffer, options) {
18589
18589
  }
18590
18590
  const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
18591
18591
  const normalized = text.replace(/&nbsp;/g, "&#160;");
18592
- const xml = _chunkDMBTOJK4cjs.stripDtd.call(void 0, normalized);
18592
+ const xml = _chunkBIP4JAVGcjs.stripDtd.call(void 0, normalized);
18593
18593
  const warnings = [];
18594
18594
  const parser = new (0, _xmldom.DOMParser)({
18595
18595
  onError: (_level, msg2) => {
@@ -18629,7 +18629,7 @@ function parseHwpmlDocument(buffer, options) {
18629
18629
  parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
18630
18630
  }
18631
18631
  const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
18632
- const markdown = _chunkDMBTOJK4cjs.blocksToMarkdown.call(void 0, blocks);
18632
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, blocks);
18633
18633
  return {
18634
18634
  markdown,
18635
18635
  blocks,
@@ -18787,7 +18787,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
18787
18787
  const cellRows = grid.map(
18788
18788
  (row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
18789
18789
  );
18790
- const table = _chunkDMBTOJK4cjs.buildTable.call(void 0, cellRows);
18790
+ const table = _chunkBIP4JAVGcjs.buildTable.call(void 0, cellRows);
18791
18791
  const caption = extractShapeCaption(el);
18792
18792
  if (caption.text && caption.before) {
18793
18793
  blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
@@ -20090,19 +20090,19 @@ function parseCentralDirectory(buf) {
20090
20090
  }
20091
20091
  }
20092
20092
  }
20093
- if (eocdOffset < 0) throw new (0, _chunkDMBTOJK4cjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
20093
+ if (eocdOffset < 0) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
20094
20094
  const totalEntries = view.getUint16(eocdOffset + 10, true);
20095
20095
  const cdSize = view.getUint32(eocdOffset + 12, true);
20096
20096
  const cdOffset = view.getUint32(eocdOffset + 16, true);
20097
- if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkDMBTOJK4cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
20097
+ if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
20098
20098
  if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
20099
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
20099
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
20100
20100
  }
20101
20101
  const decoder = new TextDecoder("utf-8");
20102
20102
  const entries = [];
20103
20103
  let pos = cdOffset;
20104
20104
  for (let i = 0; i < totalEntries; i++) {
20105
- if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkDMBTOJK4cjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
20105
+ if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
20106
20106
  const flags = view.getUint16(pos + 8, true);
20107
20107
  const method = view.getUint16(pos + 10, true);
20108
20108
  const crc = view.getUint32(pos + 16, true);
@@ -20113,7 +20113,7 @@ function parseCentralDirectory(buf) {
20113
20113
  const commentLen = view.getUint16(pos + 32, true);
20114
20114
  const localOffset = view.getUint32(pos + 42, true);
20115
20115
  if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
20116
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
20116
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
20117
20117
  }
20118
20118
  const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
20119
20119
  const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
@@ -20138,11 +20138,16 @@ function crc32(data) {
20138
20138
  }
20139
20139
  return (crc ^ 4294967295) >>> 0;
20140
20140
  }
20141
- function patchZipEntries(original, replacements) {
20141
+ function patchZipEntries(original, replacements, additions) {
20142
20142
  const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
20143
20143
  const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
20144
20144
  for (const name of replacements.keys()) {
20145
- if (!entries.some((e) => e.name === name)) throw new (0, _chunkDMBTOJK4cjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
20145
+ if (!entries.some((e) => e.name === name)) throw new (0, _chunkBIP4JAVGcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
20146
+ }
20147
+ if (additions) {
20148
+ for (const name of additions.keys()) {
20149
+ if (entries.some((e) => e.name === name)) throw new (0, _chunkBIP4JAVGcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
20150
+ }
20146
20151
  }
20147
20152
  const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
20148
20153
  const segments = [];
@@ -20160,7 +20165,7 @@ function patchZipEntries(original, replacements) {
20160
20165
  offset += seg.length;
20161
20166
  continue;
20162
20167
  }
20163
- if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkDMBTOJK4cjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
20168
+ if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
20164
20169
  const nameLen = view.getUint16(e.localOffset + 26, true);
20165
20170
  const extraLen = view.getUint16(e.localOffset + 28, true);
20166
20171
  const headerLen = 30 + nameLen + extraLen;
@@ -20178,6 +20183,34 @@ function patchZipEntries(original, replacements) {
20178
20183
  offset += headerLen + compData.length;
20179
20184
  newMeta.set(e, { crc, compSize: compData.length, uncompSize: newData.length, flags });
20180
20185
  }
20186
+ const added = [];
20187
+ if (additions) {
20188
+ const encoder = new TextEncoder();
20189
+ for (const [name, data] of additions) {
20190
+ const nameBytes = encoder.encode(name);
20191
+ const deflated = new Uint8Array(_zlib.deflateRawSync.call(void 0, data));
20192
+ const method = deflated.length < data.length ? 8 : 0;
20193
+ const compData = method === 8 ? deflated : data;
20194
+ const crc = crc32(data);
20195
+ const header = new Uint8Array(30 + nameBytes.length);
20196
+ const hv = new DataView(header.buffer);
20197
+ hv.setUint32(0, LOCAL_SIG, true);
20198
+ hv.setUint16(4, 20, true);
20199
+ hv.setUint16(6, 2048, true);
20200
+ hv.setUint16(8, method, true);
20201
+ hv.setUint16(10, 0, true);
20202
+ hv.setUint16(12, 33, true);
20203
+ hv.setUint32(14, crc, true);
20204
+ hv.setUint32(18, compData.length, true);
20205
+ hv.setUint32(22, data.length, true);
20206
+ hv.setUint16(26, nameBytes.length, true);
20207
+ hv.setUint16(28, 0, true);
20208
+ header.set(nameBytes, 30);
20209
+ added.push({ nameBytes, crc, compSize: compData.length, uncompSize: data.length, method, localOffset: offset });
20210
+ segments.push(header, compData);
20211
+ offset += header.length + compData.length;
20212
+ }
20213
+ }
20181
20214
  const newCdOffset = offset;
20182
20215
  for (const e of entries) {
20183
20216
  const cd = copyBytes(original, e.cdStart, e.cdEnd);
@@ -20193,9 +20226,32 @@ function patchZipEntries(original, replacements) {
20193
20226
  segments.push(cd);
20194
20227
  offset += cd.length;
20195
20228
  }
20229
+ for (const a of added) {
20230
+ const cd = new Uint8Array(46 + a.nameBytes.length);
20231
+ const cv = new DataView(cd.buffer);
20232
+ cv.setUint32(0, CD_SIG, true);
20233
+ cv.setUint16(4, 20, true);
20234
+ cv.setUint16(6, 20, true);
20235
+ cv.setUint16(8, 2048, true);
20236
+ cv.setUint16(10, a.method, true);
20237
+ cv.setUint16(12, 0, true);
20238
+ cv.setUint16(14, 33, true);
20239
+ cv.setUint32(16, a.crc, true);
20240
+ cv.setUint32(20, a.compSize, true);
20241
+ cv.setUint32(24, a.uncompSize, true);
20242
+ cv.setUint16(28, a.nameBytes.length, true);
20243
+ cv.setUint32(42, a.localOffset, true);
20244
+ cd.set(a.nameBytes, 46);
20245
+ segments.push(cd);
20246
+ offset += cd.length;
20247
+ }
20196
20248
  const newCdSize = offset - newCdOffset;
20197
20249
  const eocd = copyBytes(original, eocdOffset);
20198
20250
  const eview = new DataView(eocd.buffer, eocd.byteOffset, eocd.byteLength);
20251
+ if (added.length > 0) {
20252
+ eview.setUint16(8, view.getUint16(eocdOffset + 8, true) + added.length, true);
20253
+ eview.setUint16(10, view.getUint16(eocdOffset + 10, true) + added.length, true);
20254
+ }
20199
20255
  eview.setUint32(12, newCdSize, true);
20200
20256
  eview.setUint32(16, newCdOffset, true);
20201
20257
  segments.push(eocd);
@@ -20215,7 +20271,7 @@ async function fillHwpx(hwpxBuffer, values) {
20215
20271
  const zip = await _jszip2.default.loadAsync(hwpxBuffer);
20216
20272
  const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
20217
20273
  if (sectionPaths.length === 0) {
20218
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
20274
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
20219
20275
  }
20220
20276
  const normalizedValues = normalizeValues(values);
20221
20277
  const cursor = new ValueCursor(normalizedValues);
@@ -21142,12 +21198,14 @@ function generateContainerXml() {
21142
21198
  </ocf:rootfiles>
21143
21199
  </ocf:container>`;
21144
21200
  }
21145
- function generateManifest() {
21201
+ function generateManifest(chartParts = []) {
21202
+ const chartItems = chartParts.map((p, i) => `
21203
+ <opf:item id="chart${i + 1}" href="${p.name}" media-type="application/xml"/>`).join("");
21146
21204
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
21147
21205
  <opf:package xmlns:opf="${NS_OPF}" xmlns:hpf="${NS_HPF}" xmlns:hh="${NS_HEAD}">
21148
21206
  <opf:manifest>
21149
21207
  <opf:item id="header" href="Contents/header.xml" media-type="application/xml"/>
21150
- <opf:item id="section0" href="Contents/section0.xml" media-type="application/xml"/>
21208
+ <opf:item id="section0" href="Contents/section0.xml" media-type="application/xml"/>${chartItems}
21151
21209
  </opf:manifest>
21152
21210
  <opf:spine>
21153
21211
  <opf:itemref idref="header" linear="no"/>
@@ -21587,7 +21645,7 @@ function escapeGfm(text) {
21587
21645
  }
21588
21646
  var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
21589
21647
  function sanitizeText(text) {
21590
- let result = _chunkDMBTOJK4cjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
21648
+ let result = _chunkBIP4JAVGcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
21591
21649
  if (result.length <= 30 && result.includes(" ")) {
21592
21650
  const tokens = result.split(" ");
21593
21651
  const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-힯ㄱ-ㆎ]/.test(t)).length;
@@ -22194,6 +22252,210 @@ function generateEquationParagraph(input, zOrder = 0) {
22194
22252
  return `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${generateEquationXml(script, zOrder)}</hp:run></hp:p>`;
22195
22253
  }
22196
22254
 
22255
+ // src/hwpx/chart-gen.ts
22256
+ var XML_ESC = { "&": "&amp;", "<": "&lt;", ">": "&gt;" };
22257
+ var xmlEscape = (s) => s.replace(/[&<>]/g, (c) => XML_ESC[c]);
22258
+ var CHART_TYPES = {
22259
+ 0: { el: "barChart", dir: "col", grp: "clustered" },
22260
+ 1: { el: "barChart", dir: "col", grp: "stacked", overlap: 100 },
22261
+ 2: { el: "lineChart", grp: "standard", marker: true },
22262
+ 3: { el: "barChart", dir: "bar", grp: "clustered" },
22263
+ 4: { el: "barChart", dir: "bar", grp: "stacked", overlap: 100 },
22264
+ 5: { el: "scatterChart", scatter: true },
22265
+ 6: { el: "pieChart", pie: true },
22266
+ 7: { el: "pieChart", pie: true, explode: true },
22267
+ 8: { el: "doughnutChart", pie: true, hole: 50 },
22268
+ 9: { el: "areaChart", grp: "standard" },
22269
+ 10: { el: "areaChart", grp: "stacked" },
22270
+ 11: { el: "radarChart", radar: true },
22271
+ 12: { el: "bar3DChart", dir: "col", grp: "clustered" },
22272
+ 13: { el: "bar3DChart", dir: "col", grp: "stacked", overlap: 100 },
22273
+ 14: { el: "bar3DChart", dir: "bar", grp: "clustered" },
22274
+ 15: { el: "bar3DChart", dir: "bar", grp: "stacked", overlap: 100 },
22275
+ 16: { el: "pie3DChart", pie: true },
22276
+ 17: { el: "pie3DChart", pie: true, explode: true },
22277
+ 18: { el: "area3DChart", grp: "standard" },
22278
+ 19: { el: "area3DChart", grp: "stacked" }
22279
+ };
22280
+ var CHART_ALIAS = {
22281
+ column: 0,
22282
+ col: 0,
22283
+ \uC138\uB85C\uB9C9\uB300: 0,
22284
+ \uB9C9\uB300: 0,
22285
+ column_stacked: 1,
22286
+ \uC138\uB85C\uB9C9\uB300_\uB204\uC801: 1,
22287
+ line: 2,
22288
+ \uC120: 2,
22289
+ \uAEBE\uC740\uC120: 2,
22290
+ bar: 3,
22291
+ \uAC00\uB85C\uB9C9\uB300: 3,
22292
+ bar_stacked: 4,
22293
+ scatter: 5,
22294
+ \uBD84\uC0B0: 5,
22295
+ pie: 6,
22296
+ \uC6D0: 6,
22297
+ \uD30C\uC774: 6,
22298
+ pie_explode: 7,
22299
+ doughnut: 8,
22300
+ donut: 8,
22301
+ \uB3C4\uB11B: 8,
22302
+ area: 9,
22303
+ \uC601\uC5ED: 9,
22304
+ area_stacked: 10,
22305
+ radar: 11,
22306
+ \uBC29\uC0AC\uD615: 11,
22307
+ bar3d: 12,
22308
+ column3d: 12,
22309
+ pie3d: 16
22310
+ };
22311
+ function chartSpec(t) {
22312
+ if (!t) return CHART_TYPES[0];
22313
+ const key = _nullishCoalesce(CHART_ALIAS[t.toLowerCase()], () => ( Number(t)));
22314
+ return _nullishCoalesce(CHART_TYPES[key], () => ( CHART_TYPES[0]));
22315
+ }
22316
+ var HU_PER_MM = 7200 / 25.4;
22317
+ var RESERVED_KEYS = /* @__PURE__ */ new Set(["type", "cat", "size", "colors", "point_colors", "title"]);
22318
+ function parseChartFence(text) {
22319
+ let type;
22320
+ let cat = null;
22321
+ let widthMm = 32250 / HU_PER_MM;
22322
+ let heightMm = 18750 / HU_PER_MM;
22323
+ let colors = null;
22324
+ let pointColors = null;
22325
+ const series = [];
22326
+ for (const rawLine of text.split("\n")) {
22327
+ const line = rawLine.trim();
22328
+ if (!line || line.startsWith("#")) continue;
22329
+ const colon = line.search(/[::]/);
22330
+ if (colon <= 0) continue;
22331
+ const key = line.slice(0, colon).trim();
22332
+ const value = line.slice(colon + 1).trim();
22333
+ const keyLower = key.toLowerCase();
22334
+ if (keyLower === "type") {
22335
+ type = value;
22336
+ } else if (keyLower === "cat") {
22337
+ cat = value.split(",").map((s) => s.trim()).filter(Boolean);
22338
+ } else if (keyLower === "size") {
22339
+ const m = value.match(/^(\d+(?:\.\d+)?)\s*[x×]\s*(\d+(?:\.\d+)?)$/i);
22340
+ if (m) {
22341
+ widthMm = Number(m[1]);
22342
+ heightMm = Number(m[2]);
22343
+ }
22344
+ } else if (keyLower === "colors") {
22345
+ colors = value.split(",").map((s) => s.trim()).filter(Boolean);
22346
+ } else if (keyLower === "point_colors") {
22347
+ pointColors = value.split(",").map((s) => s.trim()).filter(Boolean);
22348
+ } else if (keyLower === "title") {
22349
+ } else if (!RESERVED_KEYS.has(keyLower)) {
22350
+ const nums = value.split(",").map((s) => Number(s.trim()));
22351
+ if (nums.length > 0 && nums.every((n) => Number.isFinite(n))) {
22352
+ series.push({ name: key, values: nums });
22353
+ }
22354
+ }
22355
+ }
22356
+ if (series.length === 0) return null;
22357
+ const spec = chartSpec(type);
22358
+ const catFinal = _nullishCoalesce(cat, () => ( series[0].values.map((_, i) => `\uD56D\uBAA9 ${i + 1}`)));
22359
+ let finalSeries = spec.pie ? [series[0]] : series;
22360
+ finalSeries = finalSeries.map((s) => ({ ...s }));
22361
+ if (spec.pie) {
22362
+ const slice = _nullishCoalesce(colors, () => ( pointColors));
22363
+ if (slice) finalSeries[0].pointColors = slice;
22364
+ } else {
22365
+ if (colors) finalSeries.forEach((s, i) => {
22366
+ s.color = colors[i % colors.length];
22367
+ });
22368
+ if (pointColors && finalSeries[0]) finalSeries[0].pointColors = pointColors;
22369
+ }
22370
+ return {
22371
+ spec,
22372
+ cat: catFinal,
22373
+ series: finalSeries,
22374
+ widthHu: Math.round(widthMm * HU_PER_MM),
22375
+ heightHu: Math.round(heightMm * HU_PER_MM)
22376
+ };
22377
+ }
22378
+ var colLetter = (i) => String.fromCharCode(66 + i);
22379
+ function strCachePts(vals) {
22380
+ return `<c:ptCount val="${vals.length}"/>` + vals.map((v, i) => `<c:pt idx="${i}"><c:v>${xmlEscape(v)}</c:v></c:pt>`).join("");
22381
+ }
22382
+ function numCachePts(vals) {
22383
+ return `<c:formatCode>General</c:formatCode><c:ptCount val="${vals.length}"/>` + vals.map((v, i) => `<c:pt idx="${i}"><c:v>${Number(v) || 0}</c:v></c:pt>`).join("");
22384
+ }
22385
+ function chartColorFill(color) {
22386
+ if (color == null) return null;
22387
+ const c = color.trim();
22388
+ if (/^accent[1-6]$/i.test(c)) return `<a:solidFill><a:schemeClr val="${c.toLowerCase()}"/></a:solidFill>`;
22389
+ const hex = c.replace(/^#/, "").toUpperCase();
22390
+ if (/^[0-9A-F]{6}$/.test(hex)) return `<a:solidFill><a:srgbClr val="${hex}"/></a:solidFill>`;
22391
+ return null;
22392
+ }
22393
+ function serSpPr(color, stroke) {
22394
+ const f = chartColorFill(color);
22395
+ if (!f) return "<c:spPr/>";
22396
+ return stroke ? `<c:spPr><a:ln w="28575" cap="flat" cmpd="sng" algn="ctr">${f}<a:prstDash val="solid"/><a:round/></a:ln></c:spPr>` : `<c:spPr>${f}</c:spPr>`;
22397
+ }
22398
+ function dPtXml(pointColors, pie) {
22399
+ if (!_optionalChain([pointColors, 'optionalAccess', _188 => _188.length])) return "";
22400
+ return pointColors.map((col, i) => {
22401
+ const f = chartColorFill(col);
22402
+ if (!f) return "";
22403
+ const mid = pie ? '<c:invertIfNegative val="0"/><c:bubble3D val="0"/><c:explosion val="0"/>' : '<c:bubble3D val="0"/>';
22404
+ return `<c:dPt><c:idx val="${i}"/>${mid}<c:spPr>${f}</c:spPr></c:dPt>`;
22405
+ }).join("");
22406
+ }
22407
+ function stdSer(idx, name, cat, values, explode, color, pointColors, stroke, pie) {
22408
+ const cl = colLetter(idx);
22409
+ return `<c:ser><c:idx val="${idx}"/><c:order val="${idx}"/><c:tx><c:strRef><c:f>Sheet1!$${cl}$1</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>${xmlEscape(name)}</c:v></c:pt></c:strCache></c:strRef></c:tx>${serSpPr(color, stroke)}<c:invertIfNegative val="0"/>` + (explode ? `<c:explosion val="25"/>` : "") + dPtXml(pointColors, pie) + `<c:cat><c:strRef><c:f>Sheet1!$A$2:$A$${cat.length + 1}</c:f><c:strCache>${strCachePts(cat)}</c:strCache></c:strRef></c:cat><c:val><c:numRef><c:f>Sheet1!$${cl}$2:$${cl}$${values.length + 1}</c:f><c:numCache>${numCachePts(values)}</c:numCache></c:numRef></c:val></c:ser>`;
22410
+ }
22411
+ function scatterSer(idx, name, xvals, yvals) {
22412
+ const cl = colLetter(idx);
22413
+ return `<c:ser><c:idx val="${idx}"/><c:order val="${idx}"/><c:tx><c:strRef><c:f>Sheet1!$${cl}$1</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>${xmlEscape(name)}</c:v></c:pt></c:strCache></c:strRef></c:tx><c:spPr><a:ln w="28575"><a:noFill/></a:ln></c:spPr><c:marker><c:symbol val="circle"/><c:size val="7"/></c:marker><c:xVal><c:numRef><c:f>Sheet1!$A$2:$A$${xvals.length + 1}</c:f><c:numCache>${numCachePts(xvals)}</c:numCache></c:numRef></c:xVal><c:yVal><c:numRef><c:f>Sheet1!$${cl}$2:$${cl}$${yvals.length + 1}</c:f><c:numCache>${numCachePts(yvals)}</c:numCache></c:numRef></c:yVal></c:ser>`;
22414
+ }
22415
+ function catAxXml(id, pos, cross) {
22416
+ return `<c:catAx><c:axId val="${id}"/><c:scaling><c:orientation val="minMax"/></c:scaling><c:axPos val="${pos}"/><c:crossAx val="${cross}"/><c:delete val="0"/><c:majorTickMark val="out"/><c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/><c:crosses val="autoZero"/><c:auto val="1"/><c:lblAlgn val="ctr"/><c:lblOffset val="100"/><c:noMultiLvlLbl val="0"/></c:catAx>`;
22417
+ }
22418
+ function valAxXml(id, pos, cross) {
22419
+ return `<c:valAx><c:axId val="${id}"/><c:scaling><c:orientation val="minMax"/></c:scaling><c:axPos val="${pos}"/><c:majorGridlines/><c:numFmt formatCode="General" sourceLinked="1"/><c:crossAx val="${cross}"/><c:delete val="0"/><c:majorTickMark val="out"/><c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/><c:crosses val="autoZero"/><c:crossBetween val="between"/></c:valAx>`;
22420
+ }
22421
+ function buildChartSpaceXml(fence) {
22422
+ const { spec, cat, series } = fence;
22423
+ const NS = 'xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"';
22424
+ const ax1 = "111111111";
22425
+ const ax2 = "222222222";
22426
+ let plot;
22427
+ if (spec.scatter) {
22428
+ const n = Math.max(0, ...series.map((s) => s.values.length));
22429
+ const xs = Array.from({ length: n }, (_, i) => {
22430
+ const c = cat[i];
22431
+ const v = Number(c);
22432
+ return c !== void 0 && c !== "" && Number.isFinite(v) ? v : i + 1;
22433
+ });
22434
+ const sers = series.map((s, i) => scatterSer(i, s.name, xs, s.values)).join("");
22435
+ plot = `<c:scatterChart><c:scatterStyle val="lineMarker"/><c:varyColors val="0"/>${sers}<c:axId val="${ax1}"/><c:axId val="${ax2}"/></c:scatterChart>` + valAxXml(ax1, "b", ax2) + valAxXml(ax2, "l", ax1);
22436
+ } else if (spec.pie) {
22437
+ const s0 = series[0];
22438
+ plot = `<c:${spec.el}><c:varyColors val="1"/>${stdSer(0, s0.name, cat, s0.values, !!spec.explode, s0.color, s0.pointColors, false, true)}<c:firstSliceAng val="0"/>` + (spec.hole != null ? `<c:holeSize val="${spec.hole}"/>` : "") + `</c:${spec.el}>`;
22439
+ } else {
22440
+ const stroke = spec.el === "lineChart" || spec.el === "radarChart" || !!spec.radar;
22441
+ const sers = series.map((s, i) => stdSer(i, s.name, cat, s.values, false, s.color, s.pointColors, stroke, false)).join("");
22442
+ const horiz = spec.dir === "bar";
22443
+ let inner = "";
22444
+ if (spec.dir) inner += `<c:barDir val="${spec.dir}"/>`;
22445
+ if (spec.grp) inner += `<c:grouping val="${spec.grp}"/>`;
22446
+ if (spec.radar) inner += `<c:radarStyle val="standard"/>`;
22447
+ inner += `<c:varyColors val="0"/>${sers}`;
22448
+ if (spec.marker) inner += `<c:marker val="1"/>`;
22449
+ if (spec.el.startsWith("bar")) inner += `<c:gapWidth val="150"/><c:overlap val="${_nullishCoalesce(spec.overlap, () => ( 0))}"/>`;
22450
+ inner += `<c:axId val="${ax1}"/><c:axId val="${ax2}"/>`;
22451
+ plot = `<c:${spec.el}>${inner}</c:${spec.el}>` + catAxXml(ax1, horiz ? "l" : "b", ax2) + valAxXml(ax2, horiz ? "b" : "l", ax1);
22452
+ }
22453
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><c:chartSpace ${NS}><c:date1904 val="0"/><c:roundedCorners val="0"/><c:chart><c:autoTitleDeleted val="0"/><c:plotArea><c:layout/>${plot}</c:plotArea><c:legend><c:legendPos val="r"/><c:overlay val="0"/></c:legend><c:plotVisOnly val="1"/><c:dispBlanksAs val="gap"/></c:chart></c:chartSpace>`;
22454
+ }
22455
+ function buildChartElementXml(partName, widthHu, heightHu, id) {
22456
+ return `<hp:chart id="${id}" zOrder="0" numberingType="PICTURE" textWrap="TOP_AND_BOTTOM" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" chartIDRef="${partName}"><hp:sz width="${widthHu}" widthRelTo="ABSOLUTE" height="${heightHu}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="1" affectLSpacing="0" flowWithText="1" allowOverlap="0" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="PARA" vertAlign="TOP" horzAlign="LEFT" vertOffset="0" horzOffset="0"/><hp:outMargin left="709" right="709" top="709" bottom="709"/></hp:chart>`;
22457
+ }
22458
+
22197
22459
  // src/hwpx/gen-section.ts
22198
22460
  function generateSecPr(gongmun) {
22199
22461
  const m = gongmun ? {
@@ -22206,7 +22468,7 @@ function generateSecPr(gongmun) {
22206
22468
  } : { top: 8504, bottom: 4252, left: 5670, right: 4252, header: 2835, footer: 2835 };
22207
22469
  return `<hp:secPr textDirection="HORIZONTAL" spaceColumns="1134" tabStop="8000" outlineShapeIDRef="1" memoShapeIDRef="0" textVerticalWidthHead="0" masterPageCnt="0"><hp:grid lineGrid="0" charGrid="0" wonggojiFormat="0"/><hp:startNum pageStartsOn="BOTH" page="0" pic="0" tbl="0" equation="0"/><hp:visibility hideFirstHeader="0" hideFirstFooter="0" hideFirstMasterPage="0" border="SHOW_ALL" fill="SHOW_ALL" hideFirstPageNum="0" hideFirstEmptyLine="0" showLineNumber="0"/><hp:pagePr landscape="WIDELY" width="59528" height="84188" gutterType="LEFT_ONLY"><hp:margin header="${m.header}" footer="${m.footer}" gutter="0" left="${m.left}" right="${m.right}" top="${m.top}" bottom="${m.bottom}"/></hp:pagePr><hp:footNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="-1" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="283" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="EACH_COLUMN" beneathText="0"/></hp:footNotePr><hp:endNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="14692344" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="0" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="END_OF_DOCUMENT" beneathText="0"/></hp:endNotePr></hp:secPr>`;
22208
22470
  }
22209
- function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null) {
22471
+ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null, chartParts = null) {
22210
22472
  const paraXmls = [];
22211
22473
  let isFirst = true;
22212
22474
  const orderedCounters = {};
@@ -22237,6 +22499,21 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
22237
22499
  break;
22238
22500
  }
22239
22501
  case "code_block": {
22502
+ if (chartParts !== null && (block.lang || "").toLowerCase() === "chart") {
22503
+ const fence = parseChartFence(block.text || "");
22504
+ if (fence) {
22505
+ const partName = `Chart/chart${chartParts.length + 1}.xml`;
22506
+ chartParts.push({ name: partName, xml: buildChartSpaceXml(fence) });
22507
+ const chartEl = buildChartElementXml(partName, fence.widthHu, fence.heightHu, 91e5 + blockIdx);
22508
+ if (isFirst) {
22509
+ const secRun = `<hp:run charPrIDRef="0">${generateSecPr(gongmun)}<hp:t></hp:t></hp:run>`;
22510
+ paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0">${secRun}</hp:p>`);
22511
+ isFirst = false;
22512
+ }
22513
+ xml = `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${chartEl}</hp:run></hp:p>`;
22514
+ break;
22515
+ }
22516
+ }
22240
22517
  const codeLines = (block.text || "").split("\n");
22241
22518
  xml = codeLines.map((line) => generateParagraph(line || " ", PARA_CODE)).join("\n ");
22242
22519
  break;
@@ -22260,8 +22537,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
22260
22537
  case "list_item": {
22261
22538
  if (gongmun && gongmunList) {
22262
22539
  const info = gongmunList.get(blockIdx);
22263
- const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _188 => _188.depth]), () => ( 0));
22264
- const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _189 => _189.marker]), () => ( ""));
22540
+ const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _189 => _189.depth]), () => ( 0));
22541
+ const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _190 => _190.marker]), () => ( ""));
22265
22542
  const content = block.text || "";
22266
22543
  const text = marker2 ? `${marker2} ${content}` : content;
22267
22544
  const listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
@@ -22341,18 +22618,20 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
22341
22618
 
22342
22619
  // src/hwpx/generator.ts
22343
22620
  async function markdownToHwpx(markdown, options) {
22344
- const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _190 => _190.theme]));
22345
- const gongmun = _optionalChain([options, 'optionalAccess', _191 => _191.gongmun]) ? resolveGongmun(options.gongmun) : null;
22621
+ const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _191 => _191.theme]));
22622
+ const gongmun = _optionalChain([options, 'optionalAccess', _192 => _192.gongmun]) ? resolveGongmun(options.gongmun) : null;
22346
22623
  const blocks = parseMarkdownToBlocks(markdown);
22347
22624
  const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
22348
22625
  const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
22349
- const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit);
22626
+ const chartParts = [];
22627
+ const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit, chartParts);
22350
22628
  const zip = new (0, _jszip2.default)();
22351
22629
  zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
22352
22630
  zip.file("META-INF/container.xml", generateContainerXml());
22353
- zip.file("Contents/content.hpf", generateManifest());
22354
- zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess', _192 => _192.variants]), () => ( []))));
22631
+ zip.file("Contents/content.hpf", generateManifest(chartParts));
22632
+ zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess', _193 => _193.variants]), () => ( []))));
22355
22633
  zip.file("Contents/section0.xml", sectionXml);
22634
+ for (const part of chartParts) zip.file(part.name, part.xml);
22356
22635
  zip.file("Preview/PrvText.txt", buildPrvText(blocks));
22357
22636
  return await zip.generateAsync({ type: "arraybuffer" });
22358
22637
  }
@@ -22491,6 +22770,392 @@ function diffTableCells(a, b) {
22491
22770
  return result;
22492
22771
  }
22493
22772
 
22773
+ // src/form/seal.ts
22774
+
22775
+
22776
+ // src/render/head-styles.ts
22777
+ var DEFAULT_PARA_GEOM = {
22778
+ lineSpacingType: "PERCENT",
22779
+ lineSpacingValue: 160,
22780
+ marginLeft: 0,
22781
+ marginRight: 0,
22782
+ marginIntent: 0,
22783
+ spaceBefore: 0,
22784
+ spaceAfter: 0
22785
+ };
22786
+ var DEFAULT_CHAR = { height: 1e3, bold: false, italic: false, underline: false, ratio: 100, spacing: 0 };
22787
+ function borderWidthPt(v) {
22788
+ const n = parseFloat(_nullishCoalesce(v, () => ( "")));
22789
+ if (!Number.isFinite(n)) return 0.34;
22790
+ return n * 2.834645;
22791
+ }
22792
+ function parseEdge(el) {
22793
+ if (!el) return void 0;
22794
+ const type = _nullishCoalesce(el.getAttribute("type"), () => ( "NONE"));
22795
+ if (type === "NONE") return void 0;
22796
+ return { type, widthPt: borderWidthPt(el.getAttribute("width")), color: _nullishCoalesce(el.getAttribute("color"), () => ( "#000000")) };
22797
+ }
22798
+ function findDeep(el, name, depth = 0) {
22799
+ if (depth > 32) return null;
22800
+ const children = el.childNodes;
22801
+ if (!children) return null;
22802
+ for (let i = 0; i < children.length; i++) {
22803
+ const ch = children[i];
22804
+ if (ch.nodeType !== 1) continue;
22805
+ const e = ch;
22806
+ if ((e.tagName || "").replace(/^[^:]+:/, "") === name) return e;
22807
+ const found = findDeep(e, name, depth + 1);
22808
+ if (found) return found;
22809
+ }
22810
+ return null;
22811
+ }
22812
+ function parseParaGeom(el) {
22813
+ const g = { ...DEFAULT_PARA_GEOM };
22814
+ const ls = findDeep(el, "lineSpacing");
22815
+ if (ls) {
22816
+ g.lineSpacingType = _nullishCoalesce(ls.getAttribute("type"), () => ( "PERCENT"));
22817
+ g.lineSpacingValue = Number(ls.getAttribute("value")) || 160;
22818
+ }
22819
+ const margin = findDeep(el, "margin");
22820
+ if (margin) {
22821
+ const v = (n) => {
22822
+ const c = findDeep(margin, n);
22823
+ return c ? Number(c.getAttribute("value")) || 0 : 0;
22824
+ };
22825
+ g.marginLeft = v("left");
22826
+ g.marginRight = v("right");
22827
+ g.marginIntent = v("intent");
22828
+ g.spaceBefore = v("prev");
22829
+ g.spaceAfter = v("next");
22830
+ }
22831
+ return g;
22832
+ }
22833
+ function parseRenderStyles(headXml) {
22834
+ const styles = { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
22835
+ const doc = createXmlParser().parseFromString(headXml, "text/xml");
22836
+ const root = doc.documentElement;
22837
+ if (!root) return styles;
22838
+ const walk = (el) => {
22839
+ const tag = (el.tagName || "").replace(/^[^:]+:/, "");
22840
+ if (tag === "charPr") {
22841
+ const id = el.getAttribute("id");
22842
+ if (id != null) {
22843
+ const ratioEl = findChildByLocalName(el, "ratio");
22844
+ const spacingEl = findChildByLocalName(el, "spacing");
22845
+ const underlineEl = findChildByLocalName(el, "underline");
22846
+ const textColor = el.getAttribute("textColor");
22847
+ styles.charPr.set(id, {
22848
+ height: Number(el.getAttribute("height")) || 1e3,
22849
+ bold: findChildByLocalName(el, "bold") != null,
22850
+ italic: findChildByLocalName(el, "italic") != null,
22851
+ underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
22852
+ color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
22853
+ ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _194 => _194.getAttribute, 'call', _195 => _195("hangul")])) || 100,
22854
+ spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _196 => _196.getAttribute, 'call', _197 => _197("hangul")])) || 0
22855
+ });
22856
+ }
22857
+ } else if (tag === "paraPr") {
22858
+ const id = el.getAttribute("id");
22859
+ if (id != null) {
22860
+ const align = findChildByLocalName(el, "align");
22861
+ styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _198 => _198.getAttribute, 'call', _199 => _199("horizontal")]) || "JUSTIFY");
22862
+ styles.paraGeom.set(id, parseParaGeom(el));
22863
+ }
22864
+ } else if (tag === "borderFill") {
22865
+ const id = el.getAttribute("id");
22866
+ if (id != null) {
22867
+ const bf = {
22868
+ left: parseEdge(findChildByLocalName(el, "leftBorder")),
22869
+ right: parseEdge(findChildByLocalName(el, "rightBorder")),
22870
+ top: parseEdge(findChildByLocalName(el, "topBorder")),
22871
+ bottom: parseEdge(findChildByLocalName(el, "bottomBorder"))
22872
+ };
22873
+ const fillBrush = findChildByLocalName(el, "fillBrush");
22874
+ const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
22875
+ const face = _optionalChain([winBrush, 'optionalAccess', _200 => _200.getAttribute, 'call', _201 => _201("faceColor")]);
22876
+ if (face && face.toLowerCase() !== "none") bf.fill = face;
22877
+ styles.borderFill.set(id, bf);
22878
+ }
22879
+ }
22880
+ const children = el.childNodes;
22881
+ for (let i = 0; i < children.length; i++) {
22882
+ const ch = children[i];
22883
+ if (ch.nodeType === 1) walk(ch);
22884
+ }
22885
+ };
22886
+ walk(root);
22887
+ return styles;
22888
+ }
22889
+
22890
+ // src/form/seal.ts
22891
+ var HU_PER_MM2 = 7200 / 25.4;
22892
+ var mm2hu = (mm) => Math.round(mm * HU_PER_MM2);
22893
+ var MIME = {
22894
+ png: "image/png",
22895
+ jpg: "image/jpeg",
22896
+ jpeg: "image/jpeg",
22897
+ bmp: "image/bmp",
22898
+ gif: "image/gif"
22899
+ };
22900
+ function glyphEm(code) {
22901
+ if (code < 32) return 0;
22902
+ if (code <= 126) return 0.5;
22903
+ if (code >= 65377 && code <= 65500) return 0.5;
22904
+ return 1;
22905
+ }
22906
+ function measureMm(text, emMm) {
22907
+ let w = 0;
22908
+ for (const ch of text) w += glyphEm(_nullishCoalesce(ch.codePointAt(0), () => ( 0))) * emMm;
22909
+ return w;
22910
+ }
22911
+ function collectSites(scan) {
22912
+ const sites = [];
22913
+ for (const p of scan.bodyParagraphs) sites.push({ para: p });
22914
+ const walkTables = (tables, depth) => {
22915
+ if (depth > 16) return;
22916
+ for (const t of tables) {
22917
+ for (const row of t.rows) {
22918
+ for (const cell of row) {
22919
+ for (const p of cell.paragraphs) sites.push({ para: p, cell, table: t });
22920
+ walkTables(cell.tables, depth + 1);
22921
+ }
22922
+ }
22923
+ }
22924
+ };
22925
+ walkTables(scan.tables, 0);
22926
+ walkTables(scan.orphanTables, 0);
22927
+ sites.sort((a, b) => a.para.start - b.para.start);
22928
+ return sites;
22929
+ }
22930
+ function attrOf(openTag, name) {
22931
+ const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
22932
+ return _optionalChain([m, 'optionalAccess', _202 => _202[1]]);
22933
+ }
22934
+ function paraOpenTag(xml, para) {
22935
+ const end = xml.indexOf(">", para.start);
22936
+ return end === -1 ? "" : xml.slice(para.start, end + 1);
22937
+ }
22938
+ function anchorRunInfo(xml, para, anchor) {
22939
+ let tr = para.tRanges.find((r) => !r.selfClosing && xml.slice(r.contentStart, r.contentEnd).includes(anchor));
22940
+ if (!tr) tr = para.tRanges[para.tRanges.length - 1];
22941
+ if (!tr) return null;
22942
+ const before = xml.slice(Math.max(0, para.start), tr.contentStart);
22943
+ const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
22944
+ const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _203 => _203[1]]), () => ( tr.prefix)), () => ( "hp"));
22945
+ const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
22946
+ const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
22947
+ if (close === -1) return null;
22948
+ return { charPr: charPr2, prefix, insertAt: close + `</${prefix}:run>`.length };
22949
+ }
22950
+ function cellAddrWindow(xml, cell) {
22951
+ if (!cell.addrTagRange) return null;
22952
+ return xml.slice(cell.addrTagRange.end, cell.addrTagRange.end + 400);
22953
+ }
22954
+ function cellSzWidthHu(xml, cell) {
22955
+ const win = cellAddrWindow(xml, cell);
22956
+ if (win) {
22957
+ const m = win.match(/<[A-Za-z0-9]+:cellSz\b[^>]*\bwidth="(\d+)"/);
22958
+ if (m) return Number(m[1]);
22959
+ }
22960
+ const firstPara = cell.paragraphs[0];
22961
+ if (!firstPara) return null;
22962
+ const upto = xml.slice(0, firstPara.start);
22963
+ const szMatch = [...upto.matchAll(/<[A-Za-z0-9]+:cellSz\b[^>]*\bwidth="(\d+)"[^>]*>/g)].pop();
22964
+ return szMatch ? Number(szMatch[1]) : null;
22965
+ }
22966
+ function cellContentWidthMm(xml, cell) {
22967
+ const width = cellSzWidthHu(xml, cell);
22968
+ if (width === null) return null;
22969
+ let content = width;
22970
+ const win = cellAddrWindow(xml, cell);
22971
+ const mg = _optionalChain([win, 'optionalAccess', _204 => _204.match, 'call', _205 => _205(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
22972
+ if (mg) {
22973
+ content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
22974
+ }
22975
+ return content > 0 ? content / HU_PER_MM2 : null;
22976
+ }
22977
+ function cellLeftOffsetMm(xml, table, cell) {
22978
+ if (cell.colAddr === void 0) return 0;
22979
+ const row = table.rows.find((r) => r.includes(cell));
22980
+ if (!row) return 0;
22981
+ let sum = 0;
22982
+ for (const c of row) {
22983
+ if (c === cell || c.colAddr === void 0 || c.colAddr >= cell.colAddr) continue;
22984
+ const w = cellSzWidthHu(xml, c);
22985
+ if (w) sum += w;
22986
+ }
22987
+ return sum / HU_PER_MM2;
22988
+ }
22989
+ function bodyColumnWidthMm(xml) {
22990
+ const page = xml.match(/<[A-Za-z0-9]+:pagePr\b[^>]*\bwidth="(\d+)"[^>]*>/);
22991
+ const margin = xml.match(/<[A-Za-z0-9]+:margin\b[^>]*\bleft="(\d+)"[^>]*\bright="(\d+)"[^>]*>/);
22992
+ if (!page) return 150;
22993
+ const w = Number(page[1]) - (margin ? Number(margin[1]) + Number(margin[2]) : 0);
22994
+ return w > 0 ? w / HU_PER_MM2 : 150;
22995
+ }
22996
+ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
22997
+ const w = sizeHu;
22998
+ const h = sizeHu;
22999
+ return `<hp:pic xmlns:hc="http://www.hancom.co.kr/hwpml/2011/core" id="${ids.id}" zOrder="0" numberingType="PICTURE" textWrap="IN_FRONT_OF_TEXT" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" href="" groupLevel="0" instid="${ids.instid}" reverse="0"><hp:offset x="0" y="0"/><hp:orgSz width="${w}" height="${h}"/><hp:curSz width="${w}" height="${h}"/><hp:flip horizontal="0" vertical="0"/><hp:rotationInfo angle="0" centerX="${Math.round(w / 2)}" centerY="${Math.round(h / 2)}" rotateimage="1"/><hp:renderingInfo><hc:transMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:scaMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:rotMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/></hp:renderingInfo><hp:imgRect><hc:pt0 x="0" y="0"/><hc:pt1 x="${w}" y="0"/><hc:pt2 x="${w}" y="${h}"/><hc:pt3 x="0" y="${h}"/></hp:imgRect><hp:imgClip left="0" right="${w}" top="0" bottom="${h}"/><hp:inMargin left="0" right="0" top="0" bottom="0"/><hp:imgDim dimwidth="${w}" dimheight="${h}"/><hc:img binaryItemIDRef="${itemId}" bright="0" contrast="0" effect="REAL_PIC" alpha="0"/><hp:effects/><hp:sz width="${w}" widthRelTo="ABSOLUTE" height="${h}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="0" affectLSpacing="0" flowWithText="0" allowOverlap="1" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="COLUMN" vertAlign="TOP" horzAlign="LEFT" vertOffset="${posYHu}" horzOffset="${posXHu}"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:shapeComment>kordoc seal</hp:shapeComment></hp:pic>`;
23000
+ }
23001
+ async function placeSealHwpx(hwpxBuffer, ops) {
23002
+ if (ops.length === 0) throw new (0, _chunkBIP4JAVGcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
23003
+ const u8 = new Uint8Array(hwpxBuffer);
23004
+ const zip = await _jszip2.default.loadAsync(hwpxBuffer);
23005
+ const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
23006
+ if (sectionPaths.length === 0) throw new (0, _chunkBIP4JAVGcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
23007
+ const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
23008
+ const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
23009
+ const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
23010
+ const sectionXmls = [];
23011
+ const scans = [];
23012
+ for (let si = 0; si < sectionPaths.length; si++) {
23013
+ const xml = await zip.file(sectionPaths[si]).async("text");
23014
+ sectionXmls.push(xml);
23015
+ scans.push(scanSectionXml(xml, si));
23016
+ }
23017
+ const sitesBySection = scans.map(collectSites);
23018
+ const usedIds = /* @__PURE__ */ new Set();
23019
+ let manifestXml = "";
23020
+ if (manifestPath) {
23021
+ manifestXml = await zip.file(manifestPath).async("text");
23022
+ for (const m of manifestXml.matchAll(/<opf:item\b[^>]*\bid="([^"]+)"/g)) usedIds.add(m[1]);
23023
+ }
23024
+ const usedImageNums = /* @__PURE__ */ new Set();
23025
+ for (const name of Object.keys(zip.files)) {
23026
+ const m = name.match(/^BinData\/(?:image|img)(\d+)\./i);
23027
+ if (m) usedImageNums.add(Number(m[1]));
23028
+ }
23029
+ const nextImageNum = () => {
23030
+ let n = 1;
23031
+ while (usedImageNums.has(n) || usedIds.has(`image${n}`)) n++;
23032
+ usedImageNums.add(n);
23033
+ return n;
23034
+ };
23035
+ let maxId = 1e6;
23036
+ for (const xml of sectionXmls) {
23037
+ for (const m of xml.matchAll(/\b(?:id|instid)="(\d+)"/g)) {
23038
+ const v = Number(m[1]);
23039
+ if (Number.isFinite(v) && v > maxId) maxId = v;
23040
+ }
23041
+ }
23042
+ const splicesBySection = sectionPaths.map(() => []);
23043
+ const additions = /* @__PURE__ */ new Map();
23044
+ const manifestItems = [];
23045
+ const placed = [];
23046
+ for (const op of ops) {
23047
+ if (!op.anchor) throw new (0, _chunkBIP4JAVGcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
23048
+ if (!op.image || op.image.length === 0) throw new (0, _chunkBIP4JAVGcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
23049
+ const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
23050
+ if (!MIME[ext]) throw new (0, _chunkBIP4JAVGcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
23051
+ const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
23052
+ let found = null;
23053
+ let total = 0;
23054
+ for (let si2 = 0; si2 < scans.length && !found; si2++) {
23055
+ for (const site2 of sitesBySection[si2]) {
23056
+ let from = 0;
23057
+ for (; ; ) {
23058
+ const idx = site2.para.text.indexOf(op.anchor, from);
23059
+ if (idx === -1) break;
23060
+ if (total === wantOcc) {
23061
+ found = { si: si2, site: site2, idxInText: idx };
23062
+ break;
23063
+ }
23064
+ total++;
23065
+ from = idx + op.anchor.length;
23066
+ }
23067
+ if (found) break;
23068
+ }
23069
+ }
23070
+ if (!found) {
23071
+ total = 0;
23072
+ for (let si2 = 0; si2 < scans.length; si2++) {
23073
+ for (const site2 of sitesBySection[si2]) {
23074
+ let from = 0;
23075
+ for (; ; ) {
23076
+ const idx = site2.para.text.indexOf(op.anchor, from);
23077
+ if (idx === -1) break;
23078
+ total++;
23079
+ from = idx + op.anchor.length;
23080
+ }
23081
+ }
23082
+ }
23083
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)(
23084
+ `place_seal: \uC575\uCEE4 "${op.anchor}" ${wantOcc}\uBC88\uC9F8 \uB4F1\uC7A5\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4 (\uBCF8\uBB38 \uB0B4 ${total}\uD68C \uB4F1\uC7A5 \u2014 occurrence 0..${Math.max(0, total - 1)})`
23085
+ );
23086
+ }
23087
+ const { si, site, idxInText } = found;
23088
+ const xml = sectionXmls[si];
23089
+ const run = anchorRunInfo(xml, site.para, op.anchor);
23090
+ if (!run) {
23091
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
23092
+ }
23093
+ const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _206 => _206.charPr, 'access', _207 => _207.get, 'call', _208 => _208(run.charPr), 'optionalAccess', _209 => _209.height]), () => ( 1e3));
23094
+ const fontPt = charPrHeight / 100;
23095
+ const emMm = fontPt * 25.4 / 72;
23096
+ const lineHMm = emMm;
23097
+ const startXMm = measureMm(site.para.text.slice(0, idxInText), emMm);
23098
+ const anchorWMm = measureMm(op.anchor, emMm);
23099
+ const sizeMm = _nullishCoalesce(op.sizeMm, () => ( Math.max(7, Math.min(18, lineHMm * 1.6))));
23100
+ const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
23101
+ const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
23102
+ const align = _optionalChain([styles, 'optionalAccess', _210 => _210.paraAlign, 'access', _211 => _211.get, 'call', _212 => _212(paraPrId)]);
23103
+ let alignShiftMm = 0;
23104
+ if (align === "CENTER" || align === "RIGHT") {
23105
+ const paraWMm = measureMm(site.para.text, emMm);
23106
+ alignShiftMm = align === "CENTER" ? (availMm - paraWMm) / 2 : availMm - paraWMm;
23107
+ if (!Number.isFinite(alignShiftMm) || alignShiftMm < 0) alignShiftMm = 0;
23108
+ }
23109
+ let mode = _nullishCoalesce(op.mode, () => ( "auto"));
23110
+ if (mode === "auto") {
23111
+ mode = availMm - (alignShiftMm + startXMm + anchorWMm) >= sizeMm + 2 ? "right" : "overlap";
23112
+ }
23113
+ const cellShiftMm = site.cell && site.table ? cellLeftOffsetMm(xml, site.table, site.cell) : 0;
23114
+ const posXMm = (mode === "right" ? startXMm + anchorWMm + 2 : startXMm + anchorWMm / 2 - sizeMm / 2) + alignShiftMm + cellShiftMm + (_nullishCoalesce(op.dxMm, () => ( 0)));
23115
+ const posYMm = -(sizeMm - lineHMm) / 2 + (_nullishCoalesce(op.dyMm, () => ( 0)));
23116
+ const n = nextImageNum();
23117
+ const entry = `BinData/image${n}.${ext}`;
23118
+ const itemId = `image${n}`;
23119
+ usedIds.add(itemId);
23120
+ additions.set(entry, op.image);
23121
+ manifestItems.push(`<opf:item id="${itemId}" href="${entry}" media-type="${MIME[ext]}" isEmbeded="1"/>`);
23122
+ const pic = buildFloatPicXml(itemId, mm2hu(sizeMm), mm2hu(posXMm), mm2hu(posYMm), {
23123
+ id: ++maxId,
23124
+ instid: ++maxId
23125
+ });
23126
+ splicesBySection[si].push({
23127
+ start: run.insertAt,
23128
+ end: run.insertAt,
23129
+ replacement: `<${run.prefix}:run charPrIDRef="${run.charPr}">${pic}</${run.prefix}:run>`
23130
+ });
23131
+ placed.push({
23132
+ anchor: op.anchor,
23133
+ occurrence: wantOcc,
23134
+ sectionIndex: si,
23135
+ mode,
23136
+ posXMm: Math.round(posXMm * 100) / 100,
23137
+ posYMm: Math.round(posYMm * 100) / 100,
23138
+ sizeMm: Math.round(sizeMm * 100) / 100,
23139
+ entry
23140
+ });
23141
+ }
23142
+ const encoder = new TextEncoder();
23143
+ const replacements = /* @__PURE__ */ new Map();
23144
+ for (let si = 0; si < sectionPaths.length; si++) {
23145
+ if (splicesBySection[si].length === 0) continue;
23146
+ replacements.set(sectionPaths[si], encoder.encode(applySplices(sectionXmls[si], splicesBySection[si])));
23147
+ }
23148
+ if (manifestPath && manifestItems.length > 0) {
23149
+ const patched = manifestXml.includes("</opf:manifest>") ? manifestXml.replace("</opf:manifest>", `${manifestItems.join("")}</opf:manifest>`) : manifestXml;
23150
+ if (patched !== manifestXml) replacements.set(manifestPath, encoder.encode(patched));
23151
+ }
23152
+ const out = patchZipEntries(u8, replacements, additions);
23153
+ return {
23154
+ buffer: out.buffer.slice(out.byteOffset, out.byteOffset + out.byteLength),
23155
+ placed
23156
+ };
23157
+ }
23158
+
22494
23159
  // src/roundtrip/patcher.ts
22495
23160
 
22496
23161
 
@@ -22499,7 +23164,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
22499
23164
  var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
22500
23165
  function patchTableRows(input) {
22501
23166
  const { table, scanTable, ctx, skip, origKeys, editedKeys } = input;
22502
- const xml = _optionalChain([ctx, 'access', _193 => _193.scans, 'access', _194 => _194[scanTable.sectionIndex], 'optionalAccess', _195 => _195.xml]);
23167
+ const xml = _optionalChain([ctx, 'access', _213 => _213.scans, 'access', _214 => _214[scanTable.sectionIndex], 'optionalAccess', _215 => _215.xml]);
22503
23168
  if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
22504
23169
  const numRows = table.rows;
22505
23170
  if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
@@ -22666,7 +23331,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
22666
23331
  const rr = scanTable.rowRanges[template];
22667
23332
  const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
22668
23333
  const scan = scanSectionXml(wrapped, 0);
22669
- const row = _optionalChain([scan, 'access', _196 => _196.tables, 'access', _197 => _197[0], 'optionalAccess', _198 => _198.rows, 'access', _199 => _199[0]]);
23334
+ const row = _optionalChain([scan, 'access', _216 => _216.tables, 'access', _217 => _217[0], 'optionalAccess', _218 => _218.rows, 'access', _219 => _219[0]]);
22670
23335
  if (!row || row.length !== cells.length) return null;
22671
23336
  const splices = allLinesegRemovalSplices(wrapped);
22672
23337
  for (let i = 0; i < cells.length; i++) {
@@ -22709,7 +23374,7 @@ function rowHeightOf(fragment) {
22709
23374
  }
22710
23375
  function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
22711
23376
  const from = scanTable.start + tblOpenLen;
22712
- const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _200 => _200.rowRanges, 'access', _201 => _201[0], 'optionalAccess', _202 => _202.start]), () => ( from));
23377
+ const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _220 => _220.rowRanges, 'access', _221 => _221[0], 'optionalAccess', _222 => _222.start]), () => ( from));
22713
23378
  const slice = xml.slice(from, to);
22714
23379
  const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
22715
23380
  if (!szM || szM.index === void 0) return null;
@@ -22898,9 +23563,9 @@ function patchHtmlTableRows(table, scanTable, replica, editedRows, ctx, skip, de
22898
23563
  });
22899
23564
  }
22900
23565
  function patchNestedTables(table, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
22901
- const irCell = _optionalChain([table, 'access', _203 => _203.cells, 'access', _204 => _204[oc.gridR], 'optionalAccess', _205 => _205[oc.gridC]]);
23566
+ const irCell = _optionalChain([table, 'access', _223 => _223.cells, 'access', _224 => _224[oc.gridR], 'optionalAccess', _225 => _225[oc.gridC]]);
22902
23567
  const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
22903
- const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _206 => _206.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
23568
+ const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _226 => _226.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
22904
23569
  if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
22905
23570
  return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
22906
23571
  }
@@ -22968,7 +23633,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
22968
23633
  };
22969
23634
  const cell = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
22970
23635
  if (!cell) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
22971
- const irCell = _optionalChain([table, 'access', _207 => _207.cells, 'access', _208 => _208[gridR], 'optionalAccess', _209 => _209[gridC]]);
23636
+ const irCell = _optionalChain([table, 'access', _227 => _227.cells, 'access', _228 => _228[gridR], 'optionalAccess', _229 => _229[gridC]]);
22972
23637
  const scanJoined = cell.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
22973
23638
  if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
22974
23639
  if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
@@ -22991,7 +23656,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
22991
23656
  if (newLines.length === 0) return 0;
22992
23657
  const target = cell.paragraphs[0];
22993
23658
  if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
22994
- const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _210 => _210.scans, 'access', _211 => _211[target.sectionIndex], 'optionalAccess', _212 => _212.xml]));
23659
+ const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _230 => _230.scans, 'access', _231 => _231[target.sectionIndex], 'optionalAccess', _232 => _232.xml]));
22995
23660
  if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
22996
23661
  splices.push(...sp);
22997
23662
  sectionIndex = target.sectionIndex;
@@ -23014,7 +23679,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
23014
23679
  }
23015
23680
  for (let i = 0; i < nonEmpty.length; i++) {
23016
23681
  if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
23017
- const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _213 => _213.scans, 'access', _214 => _214[nonEmpty[i].sectionIndex], 'optionalAccess', _215 => _215.xml]));
23682
+ const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _233 => _233.scans, 'access', _234 => _234[nonEmpty[i].sectionIndex], 'optionalAccess', _235 => _235.xml]));
23018
23683
  if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
23019
23684
  splices.push(...sp);
23020
23685
  sectionIndex = nonEmpty[i].sectionIndex;
@@ -23095,7 +23760,7 @@ async function resolveSectionEntryNames(zip) {
23095
23760
  const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
23096
23761
  if (paths.length > 0) return paths;
23097
23762
  }
23098
- return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkDMBTOJK4cjs.compareSectionPaths);
23763
+ return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkBIP4JAVGcjs.compareSectionPaths);
23099
23764
  }
23100
23765
  function sectionPathsFromManifest(xml) {
23101
23766
  const attr = (tag, name) => {
@@ -23105,7 +23770,7 @@ function sectionPathsFromManifest(xml) {
23105
23770
  const idToHref = /* @__PURE__ */ new Map();
23106
23771
  for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
23107
23772
  const id = attr(m[1], "id");
23108
- const href = _chunkDMBTOJK4cjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
23773
+ const href = _chunkBIP4JAVGcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
23109
23774
  if (id && href) idToHref.set(id, href);
23110
23775
  }
23111
23776
  const ordered = [];
@@ -23114,7 +23779,7 @@ function sectionPathsFromManifest(xml) {
23114
23779
  if (href) ordered.push(href);
23115
23780
  }
23116
23781
  if (ordered.length > 0) return ordered;
23117
- return Array.from(idToHref.values()).sort(_chunkDMBTOJK4cjs.compareSectionPaths);
23782
+ return Array.from(idToHref.values()).sort(_chunkBIP4JAVGcjs.compareSectionPaths);
23118
23783
  }
23119
23784
 
23120
23785
  // src/roundtrip/patcher.ts
@@ -23206,7 +23871,7 @@ async function patchHwpx(original, editedMarkdown, options) {
23206
23871
  }
23207
23872
  }
23208
23873
  let verification;
23209
- if (_optionalChain([options, 'optionalAccess', _216 => _216.verify]) !== false) {
23874
+ if (_optionalChain([options, 'optionalAccess', _236 => _236.verify]) !== false) {
23210
23875
  try {
23211
23876
  const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
23212
23877
  verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
@@ -23224,17 +23889,17 @@ function buildOrigUnits(blocks) {
23224
23889
  let chunk;
23225
23890
  if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
23226
23891
  const next = blocks[i + 1];
23227
- if (_optionalChain([next, 'optionalAccess', _217 => _217.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
23228
- chunk = _chunkDMBTOJK4cjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
23892
+ if (_optionalChain([next, 'optionalAccess', _237 => _237.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
23893
+ chunk = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
23229
23894
  } else {
23230
- chunk = _chunkDMBTOJK4cjs.blocksToMarkdown.call(void 0, [block]);
23895
+ chunk = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, [block]);
23231
23896
  }
23232
23897
  if (chunk) {
23233
23898
  const subUnits = splitMarkdownUnits(chunk);
23234
23899
  const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
23235
23900
  for (let s = 0; s < subUnits.length; s++) {
23236
23901
  const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
23237
- if (block.type === "table" && _optionalChain([block, 'access', _218 => _218.table, 'optionalAccess', _219 => _219.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
23902
+ if (block.type === "table" && _optionalChain([block, 'access', _238 => _238.table, 'optionalAccess', _239 => _239.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
23238
23903
  u.role = "caption";
23239
23904
  }
23240
23905
  units.push(u);
@@ -23345,7 +24010,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
23345
24010
  const ti = ctx.tableInsert;
23346
24011
  if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
23347
24012
  const mapping = ctx.paraMap.get(orig.blockIdx);
23348
- if (!_optionalChain([mapping, 'optionalAccess', _220 => _220.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED) \u2014 \uD45C \uBCC0\uD658 \uBD88\uAC00");
24013
+ if (!_optionalChain([mapping, 'optionalAccess', _240 => _240.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED) \u2014 \uD45C \uBCC0\uD658 \uBD88\uAC00");
23349
24014
  const para = mapping.para;
23350
24015
  if (para.kind !== "body") return skip("\uBCF8\uBB38 \uC678 \uC601\uC5ED(\uD45C \uC140/\uAE00\uC0C1\uC790) \uBB38\uB2E8\uC758 \uD45C \uBCC0\uD658\uC740 \uBBF8\uC9C0\uC6D0");
23351
24016
  const scan = ctx.scans[para.sectionIndex];
@@ -23373,7 +24038,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
23373
24038
  }
23374
24039
  function patchParagraphUnit(block, orig, edited, ctx, skip) {
23375
24040
  const mapping = ctx.paraMap.get(orig.blockIdx);
23376
- if (!_optionalChain([mapping, 'optionalAccess', _221 => _221.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
24041
+ if (!_optionalChain([mapping, 'optionalAccess', _241 => _241.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
23377
24042
  if (block.text && block.text.includes("\n")) {
23378
24043
  return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
23379
24044
  }
@@ -23404,7 +24069,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
23404
24069
  if (sanitizeText(newPlain) !== newPlain) {
23405
24070
  return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
23406
24071
  }
23407
- const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _222 => _222.scans, 'access', _223 => _223[mapping.para.sectionIndex], 'optionalAccess', _224 => _224.xml]));
24072
+ const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _242 => _242.scans, 'access', _243 => _243[mapping.para.sectionIndex], 'optionalAccess', _244 => _244.xml]));
23408
24073
  if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
23409
24074
  ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
23410
24075
  return 1;
@@ -23590,7 +24255,7 @@ var Surgeon = (_class4 = class {
23590
24255
  /** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
23591
24256
  findEntry(path) {
23592
24257
  const parts = path.replace(/^\//, "").split("/");
23593
- let scope = _nullishCoalesce(_optionalChain([this, 'access', _225 => _225.entries, 'access', _226 => _226[0], 'optionalAccess', _227 => _227.child]), () => ( -1));
24258
+ let scope = _nullishCoalesce(_optionalChain([this, 'access', _245 => _245.entries, 'access', _246 => _246[0], 'optionalAccess', _247 => _247.child]), () => ( -1));
23594
24259
  let current;
23595
24260
  for (const part of parts) {
23596
24261
  const search = (idx) => {
@@ -23803,8 +24468,8 @@ function serializeRecords(recs, repl, inserts) {
23803
24468
  parts.push(header, data);
23804
24469
  };
23805
24470
  for (let i = 0; i < recs.length; i++) {
23806
- for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _228 => _228.get, 'call', _229 => _229(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
23807
- push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _230 => _230.get, 'call', _231 => _231(i)]), () => ( recs[i].data)));
24471
+ for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _248 => _248.get, 'call', _249 => _249(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
24472
+ push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _250 => _250.get, 'call', _251 => _251(i)]), () => ( recs[i].data)));
23808
24473
  }
23809
24474
  return Buffer.concat(parts);
23810
24475
  }
@@ -23922,7 +24587,7 @@ async function patchHwp(original, editedMarkdown, options) {
23922
24587
  return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
23923
24588
  }
23924
24589
  const fhEntry = CFB2.find(cfb, "/FileHeader");
23925
- if (!_optionalChain([fhEntry, 'optionalAccess', _232 => _232.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
24590
+ if (!_optionalChain([fhEntry, 'optionalAccess', _252 => _252.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
23926
24591
  let flags;
23927
24592
  try {
23928
24593
  flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
@@ -23944,7 +24609,7 @@ async function patchHwp(original, editedMarkdown, options) {
23944
24609
  const scans = [];
23945
24610
  for (let i = 0; i < sectionPaths.length; i++) {
23946
24611
  const entry = CFB2.find(cfb, sectionPaths[i]);
23947
- if (!_optionalChain([entry, 'optionalAccess', _233 => _233.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
24612
+ if (!_optionalChain([entry, 'optionalAccess', _253 => _253.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
23948
24613
  let stream;
23949
24614
  try {
23950
24615
  stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
@@ -23995,7 +24660,7 @@ async function patchHwp(original, editedMarkdown, options) {
23995
24660
  }
23996
24661
  }
23997
24662
  let verification;
23998
- if (_optionalChain([options, 'optionalAccess', _234 => _234.verify]) !== false) {
24663
+ if (_optionalChain([options, 'optionalAccess', _254 => _254.verify]) !== false) {
23999
24664
  try {
24000
24665
  const reparsed = parseHwp5Document(Buffer.from(data));
24001
24666
  verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
@@ -24084,7 +24749,7 @@ function tableContentScore(irTable, scanTable) {
24084
24749
  for (const [key, scanCell] of scanTable.cells) {
24085
24750
  const comma = key.indexOf(",");
24086
24751
  const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
24087
- const irCell = _optionalChain([irTable, 'access', _235 => _235.cells, 'access', _236 => _236[r], 'optionalAccess', _237 => _237[c]]);
24752
+ const irCell = _optionalChain([irTable, 'access', _255 => _255.cells, 'access', _256 => _256[r], 'optionalAccess', _257 => _257[c]]);
24088
24753
  if (!irCell) continue;
24089
24754
  const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
24090
24755
  const b = normForMatch(stripCellTokens(irCell.text));
@@ -24120,7 +24785,7 @@ function handleModified(orig, edited, ctx) {
24120
24785
  }
24121
24786
  function patchParagraph(block, orig, edited, ctx, skip) {
24122
24787
  const mapping = ctx.paraMap.get(orig.blockIdx);
24123
- if (!_optionalChain([mapping, 'optionalAccess', _238 => _238.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
24788
+ if (!_optionalChain([mapping, 'optionalAccess', _258 => _258.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
24124
24789
  const restoreBr = (s) => s.replace(/\s*<br\s*\/?\s*>\s*/gi, "\n");
24125
24790
  let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
24126
24791
  if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
@@ -24319,7 +24984,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
24319
24984
  };
24320
24985
  const cell = scanTable.cells.get(`${gridR},${gridC}`);
24321
24986
  if (!cell) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
24322
- const irCell = _optionalChain([table, 'access', _239 => _239.cells, 'access', _240 => _240[gridR], 'optionalAccess', _241 => _241[gridC]]);
24987
+ const irCell = _optionalChain([table, 'access', _259 => _259.cells, 'access', _260 => _260[gridR], 'optionalAccess', _261 => _261[gridC]]);
24323
24988
  const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
24324
24989
  if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
24325
24990
  if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
@@ -24711,7 +25376,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24711
25376
  const block = st.blocks[blockIndex];
24712
25377
  if (!block) return void 0;
24713
25378
  if (block.type === "paragraph" || block.type === "heading") {
24714
- const para = _optionalChain([st, 'access', _242 => _242.paraMap, 'access', _243 => _243.get, 'call', _244 => _244(blockIndex), 'optionalAccess', _245 => _245.para]);
25379
+ const para = _optionalChain([st, 'access', _262 => _262.paraMap, 'access', _263 => _263.get, 'call', _264 => _264(blockIndex), 'optionalAccess', _265 => _265.para]);
24715
25380
  if (!para) return void 0;
24716
25381
  return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
24717
25382
  }
@@ -24736,7 +25401,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24736
25401
  if (block.text && block.text.includes("\n")) {
24737
25402
  return { capability: "locked", reason: "\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)" };
24738
25403
  }
24739
- if (!_optionalChain([st, 'access', _246 => _246.paraMap, 'access', _247 => _247.get, 'call', _248 => _248(blockIndex), 'optionalAccess', _249 => _249.para])) {
25404
+ if (!_optionalChain([st, 'access', _266 => _266.paraMap, 'access', _267 => _267.get, 'call', _268 => _268(blockIndex), 'optionalAccess', _269 => _269.para])) {
24740
25405
  return { capability: "locked", reason: "\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)" };
24741
25406
  }
24742
25407
  return { capability: "text" };
@@ -24802,7 +25467,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24802
25467
  continue;
24803
25468
  }
24804
25469
  if (block.type === "table" && block.table) {
24805
- if (!_optionalChain([edit, 'access', _250 => _250.cells, 'optionalAccess', _251 => _251.length])) {
25470
+ if (!_optionalChain([edit, 'access', _270 => _270.cells, 'optionalAccess', _271 => _271.length])) {
24806
25471
  skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
24807
25472
  continue;
24808
25473
  }
@@ -24822,7 +25487,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24822
25487
  skipped.push({ reason: "\uAC19\uC740 \uC140\uC5D0 \uC911\uBCF5 \uD3B8\uC9D1 \u2014 \uBA3C\uC800 \uC801\uC6A9\uB41C \uD3B8\uC9D1 \uC720\uC9C0", after: summarize(cellEdit.text) });
24823
25488
  continue;
24824
25489
  }
24825
- const irCell = _optionalChain([block, 'access', _252 => _252.table, 'access', _253 => _253.cells, 'access', _254 => _254[cellEdit.row], 'optionalAccess', _255 => _255[cellEdit.col]]);
25490
+ const irCell = _optionalChain([block, 'access', _272 => _272.table, 'access', _273 => _273.cells, 'access', _274 => _274[cellEdit.row], 'optionalAccess', _275 => _275[cellEdit.col]]);
24826
25491
  if (!irCell) {
24827
25492
  skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
24828
25493
  continue;
@@ -24878,7 +25543,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24878
25543
  }
24879
25544
  if (replacements.size === 0) {
24880
25545
  let changes2;
24881
- if (_optionalChain([options, 'optionalAccess', _256 => _256.verify]) !== false) {
25546
+ if (_optionalChain([options, 'optionalAccess', _276 => _276.verify]) !== false) {
24882
25547
  const units = splitMarkdownUnits(st.markdown);
24883
25548
  changes2 = diffUnitLists(units, units);
24884
25549
  }
@@ -24899,7 +25564,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24899
25564
  }
24900
25565
  this.state = newState;
24901
25566
  let changes;
24902
- if (_optionalChain([options, 'optionalAccess', _257 => _257.verify]) !== false) {
25567
+ if (_optionalChain([options, 'optionalAccess', _277 => _277.verify]) !== false) {
24903
25568
  changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
24904
25569
  }
24905
25570
  return { success: true, data: new Uint8Array(data), applied, skipped, changes };
@@ -24919,7 +25584,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24919
25584
  return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
24920
25585
  }
24921
25586
  const mapping = st.paraMap.get(blockIndex);
24922
- if (!_optionalChain([mapping, 'optionalAccess', _258 => _258.para])) {
25587
+ if (!_optionalChain([mapping, 'optionalAccess', _278 => _278.para])) {
24923
25588
  return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
24924
25589
  }
24925
25590
  let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
@@ -24939,14 +25604,14 @@ var HwpxSession = (_class5 = class _HwpxSession {
24939
25604
  if (sanitizeText(newPlain) !== newPlain) {
24940
25605
  return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
24941
25606
  }
24942
- const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _259 => _259.scans, 'access', _260 => _260[mapping.para.sectionIndex], 'optionalAccess', _261 => _261.xml]));
25607
+ const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _279 => _279.scans, 'access', _280 => _280[mapping.para.sectionIndex], 'optionalAccess', _281 => _281.xml]));
24943
25608
  if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
24944
25609
  sectionSplices[mapping.para.sectionIndex].push(...splices);
24945
25610
  return 1;
24946
25611
  }
24947
25612
  }, _class5);
24948
25613
  function cellStaticCheck(table, scanTable, r, c) {
24949
- const irCell = _optionalChain([table, 'access', _262 => _262.cells, 'access', _263 => _263[r], 'optionalAccess', _264 => _264[c]]);
25614
+ const irCell = _optionalChain([table, 'access', _282 => _282.cells, 'access', _283 => _283[r], 'optionalAccess', _284 => _284[c]]);
24950
25615
  if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
24951
25616
  const cell = scanTable.cellByAnchor.get(`${r},${c}`);
24952
25617
  if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
@@ -25030,11 +25695,11 @@ var md = new (0, _markdownit2.default)({
25030
25695
  breaks: false
25031
25696
  });
25032
25697
  function renderHtml(markdown, options) {
25033
- const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _265 => _265.preset]), () => ( "default"));
25034
- const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _266 => _266.extraCss]), () => ( "")));
25698
+ const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _285 => _285.preset]), () => ( "default"));
25699
+ const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _286 => _286.extraCss]), () => ( "")));
25035
25700
  const body = md.render(markdown);
25036
- const watermark = _optionalChain([options, 'optionalAccess', _267 => _267.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
25037
- const watermarkCss = _optionalChain([options, 'optionalAccess', _268 => _268.watermark]) ? `
25701
+ const watermark = _optionalChain([options, 'optionalAccess', _287 => _287.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
25702
+ const watermarkCss = _optionalChain([options, 'optionalAccess', _288 => _288.watermark]) ? `
25038
25703
  .watermark {
25039
25704
  position: fixed;
25040
25705
  top: 50%; left: 50%;
@@ -25065,13 +25730,13 @@ async function htmlToPdf(html, options) {
25065
25730
  try {
25066
25731
  puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
25067
25732
  } catch (e30) {
25068
- throw new (0, _chunkDMBTOJK4cjs.KordocError)(
25733
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)(
25069
25734
  "PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
25070
25735
  );
25071
25736
  }
25072
25737
  const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
25073
25738
  if (!executablePath) {
25074
- throw new (0, _chunkDMBTOJK4cjs.KordocError)(
25739
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)(
25075
25740
  "Chromium \uC2E4\uD589 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. PUPPETEER_EXECUTABLE_PATH \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694."
25076
25741
  );
25077
25742
  }
@@ -25083,10 +25748,10 @@ async function htmlToPdf(html, options) {
25083
25748
  try {
25084
25749
  const page = await browser.newPage();
25085
25750
  await page.setContent(html, { waitUntil: "networkidle0" });
25086
- const margin = _optionalChain([options, 'optionalAccess', _269 => _269.margin]);
25751
+ const margin = _optionalChain([options, 'optionalAccess', _289 => _289.margin]);
25087
25752
  const pdf = await page.pdf({
25088
- format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _270 => _270.pageSize]), () => ( "A4")),
25089
- landscape: _optionalChain([options, 'optionalAccess', _271 => _271.orientation]) === "landscape",
25753
+ format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _290 => _290.pageSize]), () => ( "A4")),
25754
+ landscape: _optionalChain([options, 'optionalAccess', _291 => _291.orientation]) === "landscape",
25090
25755
  printBackground: true,
25091
25756
  margin: margin ? {
25092
25757
  top: toCss(margin.top),
@@ -25094,9 +25759,9 @@ async function htmlToPdf(html, options) {
25094
25759
  bottom: toCss(margin.bottom),
25095
25760
  left: toCss(margin.left)
25096
25761
  } : void 0,
25097
- displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _272 => _272.header]) || _optionalChain([options, 'optionalAccess', _273 => _273.footer])),
25098
- headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _274 => _274.header]), () => ( "<div></div>")),
25099
- footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _275 => _275.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
25762
+ displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _292 => _292.header]) || _optionalChain([options, 'optionalAccess', _293 => _293.footer])),
25763
+ headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _294 => _294.header]), () => ( "<div></div>")),
25764
+ footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _295 => _295.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
25100
25765
  });
25101
25766
  return Buffer.from(pdf);
25102
25767
  } finally {
@@ -25130,7 +25795,7 @@ async function markdownToPdf(markdown, options) {
25130
25795
  return htmlToPdf(html, options);
25131
25796
  }
25132
25797
  async function blocksToPdf(blocks, options) {
25133
- const markdown = _chunkDMBTOJK4cjs.blocksToMarkdown.call(void 0, blocks);
25798
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, blocks);
25134
25799
  return markdownToPdf(markdown, options);
25135
25800
  }
25136
25801
 
@@ -25211,120 +25876,6 @@ function solveRowHeights(cells, rowCount) {
25211
25876
  return h;
25212
25877
  }
25213
25878
 
25214
- // src/render/head-styles.ts
25215
- var DEFAULT_PARA_GEOM = {
25216
- lineSpacingType: "PERCENT",
25217
- lineSpacingValue: 160,
25218
- marginLeft: 0,
25219
- marginRight: 0,
25220
- marginIntent: 0,
25221
- spaceBefore: 0,
25222
- spaceAfter: 0
25223
- };
25224
- var DEFAULT_CHAR = { height: 1e3, bold: false, italic: false, underline: false, ratio: 100, spacing: 0 };
25225
- function borderWidthPt(v) {
25226
- const n = parseFloat(_nullishCoalesce(v, () => ( "")));
25227
- if (!Number.isFinite(n)) return 0.34;
25228
- return n * 2.834645;
25229
- }
25230
- function parseEdge(el) {
25231
- if (!el) return void 0;
25232
- const type = _nullishCoalesce(el.getAttribute("type"), () => ( "NONE"));
25233
- if (type === "NONE") return void 0;
25234
- return { type, widthPt: borderWidthPt(el.getAttribute("width")), color: _nullishCoalesce(el.getAttribute("color"), () => ( "#000000")) };
25235
- }
25236
- function findDeep(el, name, depth = 0) {
25237
- if (depth > 32) return null;
25238
- const children = el.childNodes;
25239
- if (!children) return null;
25240
- for (let i = 0; i < children.length; i++) {
25241
- const ch = children[i];
25242
- if (ch.nodeType !== 1) continue;
25243
- const e = ch;
25244
- if ((e.tagName || "").replace(/^[^:]+:/, "") === name) return e;
25245
- const found = findDeep(e, name, depth + 1);
25246
- if (found) return found;
25247
- }
25248
- return null;
25249
- }
25250
- function parseParaGeom(el) {
25251
- const g = { ...DEFAULT_PARA_GEOM };
25252
- const ls = findDeep(el, "lineSpacing");
25253
- if (ls) {
25254
- g.lineSpacingType = _nullishCoalesce(ls.getAttribute("type"), () => ( "PERCENT"));
25255
- g.lineSpacingValue = Number(ls.getAttribute("value")) || 160;
25256
- }
25257
- const margin = findDeep(el, "margin");
25258
- if (margin) {
25259
- const v = (n) => {
25260
- const c = findDeep(margin, n);
25261
- return c ? Number(c.getAttribute("value")) || 0 : 0;
25262
- };
25263
- g.marginLeft = v("left");
25264
- g.marginRight = v("right");
25265
- g.marginIntent = v("intent");
25266
- g.spaceBefore = v("prev");
25267
- g.spaceAfter = v("next");
25268
- }
25269
- return g;
25270
- }
25271
- function parseRenderStyles(headXml) {
25272
- const styles = { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
25273
- const doc = createXmlParser().parseFromString(headXml, "text/xml");
25274
- const root = doc.documentElement;
25275
- if (!root) return styles;
25276
- const walk = (el) => {
25277
- const tag = (el.tagName || "").replace(/^[^:]+:/, "");
25278
- if (tag === "charPr") {
25279
- const id = el.getAttribute("id");
25280
- if (id != null) {
25281
- const ratioEl = findChildByLocalName(el, "ratio");
25282
- const spacingEl = findChildByLocalName(el, "spacing");
25283
- const underlineEl = findChildByLocalName(el, "underline");
25284
- const textColor = el.getAttribute("textColor");
25285
- styles.charPr.set(id, {
25286
- height: Number(el.getAttribute("height")) || 1e3,
25287
- bold: findChildByLocalName(el, "bold") != null,
25288
- italic: findChildByLocalName(el, "italic") != null,
25289
- underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
25290
- color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
25291
- ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _276 => _276.getAttribute, 'call', _277 => _277("hangul")])) || 100,
25292
- spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _278 => _278.getAttribute, 'call', _279 => _279("hangul")])) || 0
25293
- });
25294
- }
25295
- } else if (tag === "paraPr") {
25296
- const id = el.getAttribute("id");
25297
- if (id != null) {
25298
- const align = findChildByLocalName(el, "align");
25299
- styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _280 => _280.getAttribute, 'call', _281 => _281("horizontal")]) || "JUSTIFY");
25300
- styles.paraGeom.set(id, parseParaGeom(el));
25301
- }
25302
- } else if (tag === "borderFill") {
25303
- const id = el.getAttribute("id");
25304
- if (id != null) {
25305
- const bf = {
25306
- left: parseEdge(findChildByLocalName(el, "leftBorder")),
25307
- right: parseEdge(findChildByLocalName(el, "rightBorder")),
25308
- top: parseEdge(findChildByLocalName(el, "topBorder")),
25309
- bottom: parseEdge(findChildByLocalName(el, "bottomBorder"))
25310
- };
25311
- const fillBrush = findChildByLocalName(el, "fillBrush");
25312
- const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
25313
- const face = _optionalChain([winBrush, 'optionalAccess', _282 => _282.getAttribute, 'call', _283 => _283("faceColor")]);
25314
- if (face && face.toLowerCase() !== "none") bf.fill = face;
25315
- styles.borderFill.set(id, bf);
25316
- }
25317
- }
25318
- const children = el.childNodes;
25319
- for (let i = 0; i < children.length; i++) {
25320
- const ch = children[i];
25321
- if (ch.nodeType === 1) walk(ch);
25322
- }
25323
- };
25324
- walk(root);
25325
- return styles;
25326
- }
25327
-
25328
25879
  // src/render/reflow.ts
25329
25880
  var LINESEG_FLAGS = "393216";
25330
25881
  var BASELINE_RATIO = 0.85;
@@ -25454,7 +26005,7 @@ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
25454
26005
  if (ln(p) !== "p") continue;
25455
26006
  reflowTablesIn(p, doc, styles, mode, counter);
25456
26007
  const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
25457
- const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _284 => _284.spaceBefore]), () => ( 0)));
26008
+ const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _296 => _296.spaceBefore]), () => ( 0)));
25458
26009
  const res = reflowPara(p, doc, styles, areaW, startV, mode);
25459
26010
  if (res) {
25460
26011
  const paraH = res.paraBottom - startV;
@@ -25563,7 +26114,7 @@ function buildPara(p) {
25563
26114
  el: ch,
25564
26115
  tag: cn,
25565
26116
  index: chars.length,
25566
- inline: _optionalChain([pos, 'optionalAccess', _285 => _285.getAttribute, 'call', _286 => _286("treatAsChar")]) === "1",
26117
+ inline: _optionalChain([pos, 'optionalAccess', _297 => _297.getAttribute, 'call', _298 => _298("treatAsChar")]) === "1",
25567
26118
  width: w,
25568
26119
  height: h
25569
26120
  });
@@ -25814,15 +26365,15 @@ function drawShape(o, x, y, ctx, depth) {
25814
26365
  const sx = ow > 0 ? w / ow : 1;
25815
26366
  const sy = oh > 0 ? h / oh : 1;
25816
26367
  const lineShape = findChildByLocalName(el, "lineShape");
25817
- const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _287 => _287.getAttribute, 'call', _288 => _288("style")]), () => ( "SOLID"));
25818
- const strokeCol = _optionalChain([lineShape, 'optionalAccess', _289 => _289.getAttribute, 'call', _290 => _290("color")]) || "#000000";
26368
+ const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _299 => _299.getAttribute, 'call', _300 => _300("style")]), () => ( "SOLID"));
26369
+ const strokeCol = _optionalChain([lineShape, 'optionalAccess', _301 => _301.getAttribute, 'call', _302 => _302("color")]) || "#000000";
25819
26370
  const hasStroke = lstyle !== "NONE";
25820
26371
  const strokeW = hasStroke ? shapeStrokePt(lineShape ? num2(lineShape, "width") : 33) : 0;
25821
26372
  const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
25822
26373
  const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
25823
26374
  const fillBrush = findChildByLocalName(el, "fillBrush");
25824
26375
  const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
25825
- const face = _optionalChain([winBrush, 'optionalAccess', _291 => _291.getAttribute, 'call', _292 => _292("faceColor")]);
26376
+ const face = _optionalChain([winBrush, 'optionalAccess', _303 => _303.getAttribute, 'call', _304 => _304("faceColor")]);
25826
26377
  const fill = face && face.toLowerCase() !== "none" ? face : "none";
25827
26378
  const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
25828
26379
  if (o.tag === "rect") {
@@ -25854,11 +26405,11 @@ function cellContentExtent(cell) {
25854
26405
  if (ln2(p) !== "p") continue;
25855
26406
  const m = buildPara(p);
25856
26407
  for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
25857
- const baseV = _nullishCoalesce(_optionalChain([m, 'access', _293 => _293.segs, 'access', _294 => _294[0], 'optionalAccess', _295 => _295.vertpos]), () => ( 0));
26408
+ const baseV = _nullishCoalesce(_optionalChain([m, 'access', _305 => _305.segs, 'access', _306 => _306[0], 'optionalAccess', _307 => _307.vertpos]), () => ( 0));
25858
26409
  for (const o of m.objs) {
25859
26410
  if (o.inline) continue;
25860
26411
  const pos = findChildByLocalName(o.el, "pos");
25861
- if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _296 => _296.getAttribute, 'call', _297 => _297("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
26412
+ if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _308 => _308.getAttribute, 'call', _309 => _309("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
25862
26413
  const om = findChildByLocalName(o.el, "outMargin");
25863
26414
  const pushed = baseV - (num2(om, "top") + o.height + num2(om, "bottom"));
25864
26415
  const anchor = pushed >= -100 ? pushed : baseV;
@@ -25944,7 +26495,7 @@ function drawTable(tbl, tx, ty, ctx, depth) {
25944
26495
  }));
25945
26496
  for (const g of geom) {
25946
26497
  const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
25947
- if (_optionalChain([bf, 'optionalAccess', _298 => _298.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
26498
+ if (_optionalChain([bf, 'optionalAccess', _310 => _310.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
25948
26499
  }
25949
26500
  for (const g of geom) {
25950
26501
  const { c } = g;
@@ -25982,7 +26533,7 @@ function drawPic(pic, x, y, ctx) {
25982
26533
  const sz = findChildByLocalName(pic, "sz");
25983
26534
  const w = num2(sz, "width", 5669), h = num2(sz, "height", 5669);
25984
26535
  const img = findFirst(pic, "img");
25985
- const ref = _optionalChain([img, 'optionalAccess', _299 => _299.getAttribute, 'call', _300 => _300("binaryItemIDRef")]);
26536
+ const ref = _optionalChain([img, 'optionalAccess', _311 => _311.getAttribute, 'call', _312 => _312("binaryItemIDRef")]);
25986
26537
  const loaded = ref != null ? ctx.images.get(ref) : void 0;
25987
26538
  if (!loaded) {
25988
26539
  emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
@@ -26018,20 +26569,20 @@ function sniffMime(name, bytes) {
26018
26569
  return "image/jpeg";
26019
26570
  }
26020
26571
  async function renderHwpxToSvg(input, options) {
26021
- const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _301 => _301.maxImageBytes]), () => ( 40 * 1024 * 1024));
26572
+ const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _313 => _313.maxImageBytes]), () => ( 40 * 1024 * 1024));
26022
26573
  let zip;
26023
26574
  try {
26024
26575
  zip = await _jszip2.default.loadAsync(input);
26025
26576
  } catch (e31) {
26026
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
26577
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
26027
26578
  }
26028
26579
  const secFile = _nullishCoalesce(zip.file("Contents/section0.xml"), () => ( zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name))[0]));
26029
- if (!secFile) throw new (0, _chunkDMBTOJK4cjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
26580
+ if (!secFile) throw new (0, _chunkBIP4JAVGcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
26030
26581
  const secXml = await secFile.async("string");
26031
- if (secXml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkDMBTOJK4cjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
26582
+ if (secXml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
26032
26583
  const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
26033
- if (!hasCache && !_optionalChain([options, 'optionalAccess', _302 => _302.reflow])) {
26034
- throw new (0, _chunkDMBTOJK4cjs.KordocError)("\uC870\uD310 \uCE90\uC2DC(linesegarray) \uC5C6\uC74C \u2014 \uD55C\uCEF4\uC5D0\uC11C \uC800\uC7A5\uD55C HWPX\uB9CC \uB80C\uB354 \uAC00\uB2A5 (reflow \uC635\uC158\uC73C\uB85C \uD569\uC131 \uB80C\uB354 \uAC00\uB2A5)");
26584
+ if (!hasCache && !_optionalChain([options, 'optionalAccess', _314 => _314.reflow])) {
26585
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC870\uD310 \uCE90\uC2DC(linesegarray) \uC5C6\uC74C \u2014 \uD55C\uCEF4\uC5D0\uC11C \uC800\uC7A5\uD55C HWPX\uB9CC \uB80C\uB354 \uAC00\uB2A5 (reflow \uC635\uC158\uC73C\uB85C \uD569\uC131 \uB80C\uB354 \uAC00\uB2A5)");
26035
26586
  }
26036
26587
  const warnings = [];
26037
26588
  const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
@@ -26058,7 +26609,7 @@ async function renderHwpxToSvg(input, options) {
26058
26609
  let href = binmap.get(ref);
26059
26610
  if (!href) {
26060
26611
  const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
26061
- href = _optionalChain([cand, 'optionalAccess', _303 => _303.name]);
26612
+ href = _optionalChain([cand, 'optionalAccess', _315 => _315.name]);
26062
26613
  }
26063
26614
  if (!href) continue;
26064
26615
  const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
@@ -26077,7 +26628,7 @@ async function renderHwpxToSvg(input, options) {
26077
26628
  }
26078
26629
  const doc = createXmlParser().parseFromString(secXml, "text/xml");
26079
26630
  const root = doc.documentElement;
26080
- if (!root) throw new (0, _chunkDMBTOJK4cjs.KordocError)("\uC139\uC158 XML \uD30C\uC2F1 \uC2E4\uD328");
26631
+ if (!root) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC139\uC158 XML \uD30C\uC2F1 \uC2E4\uD328");
26081
26632
  const pagePr = findFirst(root, "pagePr");
26082
26633
  const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
26083
26634
  const PW = num2(pagePr, "width", 59528), PH = num2(pagePr, "height", 84188);
@@ -26085,7 +26636,7 @@ async function renderHwpxToSvg(input, options) {
26085
26636
  const MT = num2(margin, "top", 5668) + num2(margin, "header", 0);
26086
26637
  const BODY_H = PH - MT - num2(margin, "bottom", 4252) - num2(margin, "footer", 0);
26087
26638
  const BODY_W = PW - ML - num2(margin, "right", 8504);
26088
- if (!hasCache) reflowSection(root, styles, { BODY_W, BODY_H }, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _304 => _304.reflowMode]), () => ( "keep")));
26639
+ if (!hasCache) reflowSection(root, styles, { BODY_W, BODY_H }, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _316 => _316.reflowMode]), () => ( "keep")));
26089
26640
  const colPr = findFirst(root, "colPr");
26090
26641
  const multiCol = num2(colPr, "colCount", 1) > 1;
26091
26642
  const paraSegPages = /* @__PURE__ */ new Map();
@@ -26120,7 +26671,7 @@ async function renderHwpxToSvg(input, options) {
26120
26671
  styles,
26121
26672
  images,
26122
26673
  defs: [],
26123
- highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _305 => _305.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
26674
+ highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _317 => _317.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
26124
26675
  warnings,
26125
26676
  warned: /* @__PURE__ */ new Set(),
26126
26677
  stats: { texts: 0, images: 0, tables: 0 }
@@ -26147,17 +26698,17 @@ ${pagesSvg}
26147
26698
  // src/index.ts
26148
26699
  async function parse(input, options) {
26149
26700
  let buffer;
26150
- const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _306 => _306.filePath]) ? { ...options, filePath: input } : options;
26701
+ const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _318 => _318.filePath]) ? { ...options, filePath: input } : options;
26151
26702
  if (typeof input === "string") {
26152
26703
  try {
26153
26704
  const buf = await _promises.readFile.call(void 0, input);
26154
- buffer = _chunkDMBTOJK4cjs.toArrayBuffer.call(void 0, buf);
26705
+ buffer = _chunkBIP4JAVGcjs.toArrayBuffer.call(void 0, buf);
26155
26706
  } catch (err) {
26156
26707
  const msg2 = err instanceof Error && "code" in err && err.code === "ENOENT" ? `\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input}` : `\uD30C\uC77C \uC77D\uAE30 \uC2E4\uD328: ${input}`;
26157
26708
  return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
26158
26709
  }
26159
26710
  } else if (Buffer.isBuffer(input)) {
26160
- buffer = _chunkDMBTOJK4cjs.toArrayBuffer.call(void 0, input);
26711
+ buffer = _chunkBIP4JAVGcjs.toArrayBuffer.call(void 0, input);
26161
26712
  } else {
26162
26713
  buffer = input;
26163
26714
  }
@@ -26192,21 +26743,21 @@ async function parseHwp3(buffer, options) {
26192
26743
  const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
26193
26744
  return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
26194
26745
  } catch (err) {
26195
- return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDMBTOJK4cjs.classifyError.call(void 0, err) };
26746
+ return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err) };
26196
26747
  }
26197
26748
  }
26198
26749
  async function parseHwpx(buffer, options) {
26199
26750
  try {
26200
26751
  const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
26201
- return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _307 => _307.length]) ? images : void 0 };
26752
+ return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _319 => _319.length]) ? images : void 0 };
26202
26753
  } catch (err) {
26203
- return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDMBTOJK4cjs.classifyError.call(void 0, err) };
26754
+ return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err) };
26204
26755
  }
26205
26756
  }
26206
26757
  async function parseHwp(buffer, options) {
26207
26758
  try {
26208
26759
  const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
26209
- if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _308 => _308.filePath])) {
26760
+ if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _320 => _320.filePath])) {
26210
26761
  try {
26211
26762
  const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
26212
26763
  if (pages.some((p) => p && p.trim().length > 0)) {
@@ -26223,15 +26774,15 @@ async function parseHwp(buffer, options) {
26223
26774
  } catch (e32) {
26224
26775
  }
26225
26776
  }
26226
- return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _309 => _309.length]) ? images : void 0 };
26777
+ return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _321 => _321.length]) ? images : void 0 };
26227
26778
  } catch (err) {
26228
- return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDMBTOJK4cjs.classifyError.call(void 0, err) };
26779
+ return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err) };
26229
26780
  }
26230
26781
  }
26231
26782
  async function parsePdf(buffer, options) {
26232
26783
  let parsePdfDocument;
26233
26784
  try {
26234
- const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-O2SD4DFR.cjs")));
26785
+ const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-6V7F3GET.cjs")));
26235
26786
  parsePdfDocument = mod.parsePdfDocument;
26236
26787
  } catch (e33) {
26237
26788
  return {
@@ -26246,7 +26797,7 @@ async function parsePdf(buffer, options) {
26246
26797
  return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
26247
26798
  } catch (err) {
26248
26799
  const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
26249
- return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDMBTOJK4cjs.classifyError.call(void 0, err), isImageBased };
26800
+ return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err), isImageBased };
26250
26801
  }
26251
26802
  }
26252
26803
  async function parseXlsx(buffer, options) {
@@ -26254,7 +26805,7 @@ async function parseXlsx(buffer, options) {
26254
26805
  const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
26255
26806
  return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
26256
26807
  } catch (err) {
26257
- return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDMBTOJK4cjs.classifyError.call(void 0, err) };
26808
+ return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err) };
26258
26809
  }
26259
26810
  }
26260
26811
  async function parseXls(buffer, options) {
@@ -26262,15 +26813,15 @@ async function parseXls(buffer, options) {
26262
26813
  const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
26263
26814
  return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
26264
26815
  } catch (err) {
26265
- return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDMBTOJK4cjs.classifyError.call(void 0, err) };
26816
+ return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err) };
26266
26817
  }
26267
26818
  }
26268
26819
  async function parseDocx(buffer, options) {
26269
26820
  try {
26270
26821
  const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
26271
- return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _310 => _310.length]) ? images : void 0 };
26822
+ return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _322 => _322.length]) ? images : void 0 };
26272
26823
  } catch (err) {
26273
- return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDMBTOJK4cjs.classifyError.call(void 0, err) };
26824
+ return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err) };
26274
26825
  }
26275
26826
  }
26276
26827
  async function parseHwpml(buffer, options) {
@@ -26278,16 +26829,16 @@ async function parseHwpml(buffer, options) {
26278
26829
  const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
26279
26830
  return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
26280
26831
  } catch (err) {
26281
- return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkDMBTOJK4cjs.classifyError.call(void 0, err) };
26832
+ return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err) };
26282
26833
  }
26283
26834
  }
26284
26835
  async function fillForm(input, values, outputFormat = "markdown") {
26285
26836
  let buffer;
26286
26837
  if (typeof input === "string") {
26287
26838
  const buf = await _promises.readFile.call(void 0, input);
26288
- buffer = _chunkDMBTOJK4cjs.toArrayBuffer.call(void 0, buf);
26839
+ buffer = _chunkBIP4JAVGcjs.toArrayBuffer.call(void 0, buf);
26289
26840
  } else if (Buffer.isBuffer(input)) {
26290
- buffer = _chunkDMBTOJK4cjs.toArrayBuffer.call(void 0, input);
26841
+ buffer = _chunkBIP4JAVGcjs.toArrayBuffer.call(void 0, input);
26291
26842
  } else {
26292
26843
  buffer = input;
26293
26844
  }
@@ -26313,7 +26864,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
26313
26864
  throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
26314
26865
  }
26315
26866
  const fill = fillFormFields(parsed.blocks, values);
26316
- const markdown = _chunkDMBTOJK4cjs.blocksToMarkdown.call(void 0, fill.blocks);
26867
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, fill.blocks);
26317
26868
  if (outputFormat === "hwpx") {
26318
26869
  const hwpxBuffer = await markdownToHwpx(markdown);
26319
26870
  return { output: hwpxBuffer, format: "hwpx", fill };
@@ -26375,5 +26926,6 @@ async function fillForm(input, values, outputFormat = "markdown") {
26375
26926
 
26376
26927
 
26377
26928
 
26378
- exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkDMBTOJK4cjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkDMBTOJK4cjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.charWidthEm1000 = charWidthEm1000; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.fillWithUniqueGuard = fillWithUniqueGuard; exports.fitRatioForFewerLines = fitRatioForFewerLines; exports.formatFillValue = formatFillValue; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.measureTextWidth = measureTextWidth; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.validateHwpx = validateHwpx;
26929
+
26930
+ exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkBIP4JAVGcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkBIP4JAVGcjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.charWidthEm1000 = charWidthEm1000; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.fillWithUniqueGuard = fillWithUniqueGuard; exports.fitRatioForFewerLines = fitRatioForFewerLines; exports.formatFillValue = formatFillValue; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.measureTextWidth = measureTextWidth; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.placeSealHwpx = placeSealHwpx; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.validateHwpx = validateHwpx;
26379
26931
  //# sourceMappingURL=index.cjs.map