kordoc 3.8.4 → 3.10.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 (38) hide show
  1. package/README.md +39 -0
  2. package/dist/{-ZAIG6FWT.js → -3B5FDXW2.js} +18 -12
  3. package/dist/{chunk-2UDAEQPW.js → chunk-5DL6VCIJ.js} +4 -120
  4. package/dist/chunk-5DL6VCIJ.js.map +1 -0
  5. package/dist/{chunk-6EDNKPXQ.js → chunk-5TK4X4JQ.js} +373 -315
  6. package/dist/chunk-5TK4X4JQ.js.map +1 -0
  7. package/dist/chunk-FU25KFFZ.js +938 -0
  8. package/dist/chunk-FU25KFFZ.js.map +1 -0
  9. package/dist/chunk-MZA7AXHN.js +124 -0
  10. package/dist/chunk-MZA7AXHN.js.map +1 -0
  11. package/dist/{chunk-T4SGNVVS.js → chunk-PNXOUDS7.js} +2 -2
  12. package/dist/{chunk-T4SGNVVS.js.map → chunk-PNXOUDS7.js.map} +1 -1
  13. package/dist/{chunk-Z3O36LBJ.cjs → chunk-ZQOGTAT5.cjs} +2 -2
  14. package/dist/{chunk-Z3O36LBJ.cjs.map → chunk-ZQOGTAT5.cjs.map} +1 -1
  15. package/dist/cli.js +33 -6
  16. package/dist/cli.js.map +1 -1
  17. package/dist/index.cjs +1136 -173
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.cts +40 -1
  20. package/dist/index.d.ts +40 -1
  21. package/dist/index.js +1018 -55
  22. package/dist/index.js.map +1 -1
  23. package/dist/mcp.js +8 -5
  24. package/dist/mcp.js.map +1 -1
  25. package/dist/{parser-ZVKCFXR3.cjs → parser-6B7BUSX3.cjs} +14 -14
  26. package/dist/{parser-ZVKCFXR3.cjs.map → parser-6B7BUSX3.cjs.map} +1 -1
  27. package/dist/{parser-2THIF623.js → parser-DKIA66MN.js} +2 -2
  28. package/dist/{parser-PR7CPMM4.js → parser-VCJTQVAH.js} +8 -6
  29. package/dist/{parser-PR7CPMM4.js.map → parser-VCJTQVAH.js.map} +1 -1
  30. package/dist/render-4I72JOAR.js +9 -0
  31. package/dist/render-4I72JOAR.js.map +1 -0
  32. package/dist/{watch-2HYPNMOB.js → watch-MQTMNUSB.js} +6 -4
  33. package/dist/{watch-2HYPNMOB.js.map → watch-MQTMNUSB.js.map} +1 -1
  34. package/package.json +2 -2
  35. package/dist/chunk-2UDAEQPW.js.map +0 -1
  36. package/dist/chunk-6EDNKPXQ.js.map +0 -1
  37. /package/dist/{-ZAIG6FWT.js.map → -3B5FDXW2.js.map} +0 -0
  38. /package/dist/{parser-2THIF623.js.map → parser-DKIA66MN.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -19,7 +19,7 @@
19
19
 
20
20
 
21
21
 
22
- var _chunkZ3O36LBJcjs = require('./chunk-Z3O36LBJ.cjs');
22
+ var _chunkZQOGTAT5cjs = require('./chunk-ZQOGTAT5.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, _chunkZ3O36LBJcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
408
+ if (level === "fatalError") throw new (0, _chunkZQOGTAT5cjs.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, _chunkZ3O36LBJcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
463
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZQOGTAT5cjs.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(_chunkZ3O36LBJcjs.stripDtd.call(void 0, xml), "text/xml");
466
+ const doc = parser.parseFromString(_chunkZQOGTAT5cjs.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);
@@ -481,9 +481,9 @@ async function extractHwpxStyles(zip, decompressed) {
481
481
  function parseCharProperties(doc, map) {
482
482
  const tagNames = ["hh:charPr", "charPr", "hp:charPr"];
483
483
  for (const tagName of tagNames) {
484
- const elements = doc.getElementsByTagName(tagName);
485
- for (let i = 0; i < elements.length; i++) {
486
- const el = elements[i];
484
+ const elements2 = doc.getElementsByTagName(tagName);
485
+ for (let i = 0; i < elements2.length; i++) {
486
+ const el = elements2[i];
487
487
  const id = el.getAttribute("id") || el.getAttribute("IDRef") || "";
488
488
  if (!id) continue;
489
489
  const prop = {};
@@ -517,9 +517,9 @@ function parseCharProperties(doc, map) {
517
517
  function parseStyleElements(doc, map) {
518
518
  const tagNames = ["hh:style", "style", "hp:style"];
519
519
  for (const tagName of tagNames) {
520
- const elements = doc.getElementsByTagName(tagName);
521
- for (let i = 0; i < elements.length; i++) {
522
- const el = elements[i];
520
+ const elements2 = doc.getElementsByTagName(tagName);
521
+ for (let i = 0; i < elements2.length; i++) {
522
+ const el = elements2[i];
523
523
  const id = el.getAttribute("id") || el.getAttribute("IDRef") || String(i);
524
524
  const name = el.getAttribute("name") || el.getAttribute("engName") || "";
525
525
  const charPrId = el.getAttribute("charPrIDRef") || void 0;
@@ -531,9 +531,9 @@ function parseStyleElements(doc, map) {
531
531
  function parseNumberings(doc, map) {
532
532
  const tagNames = ["hh:numbering", "numbering"];
533
533
  for (const tagName of tagNames) {
534
- const elements = doc.getElementsByTagName(tagName);
535
- for (let i = 0; i < elements.length; i++) {
536
- const el = elements[i];
534
+ const elements2 = doc.getElementsByTagName(tagName);
535
+ for (let i = 0; i < elements2.length; i++) {
536
+ const el = elements2[i];
537
537
  const id = el.getAttribute("id") || "";
538
538
  if (!id) continue;
539
539
  const def = { heads: /* @__PURE__ */ new Map() };
@@ -560,9 +560,9 @@ function parseNumberings(doc, map) {
560
560
  function parseBullets(doc, map) {
561
561
  const tagNames = ["hh:bullet", "bullet"];
562
562
  for (const tagName of tagNames) {
563
- const elements = doc.getElementsByTagName(tagName);
564
- for (let i = 0; i < elements.length; i++) {
565
- const el = elements[i];
563
+ const elements2 = doc.getElementsByTagName(tagName);
564
+ for (let i = 0; i < elements2.length; i++) {
565
+ const el = elements2[i];
566
566
  const id = el.getAttribute("id") || "";
567
567
  const char = el.getAttribute("char") || "";
568
568
  if (id && char) map.set(id, char);
@@ -573,9 +573,9 @@ function parseBullets(doc, map) {
573
573
  function parseParaHeadings(doc, map) {
574
574
  const tagNames = ["hh:paraPr", "paraPr"];
575
575
  for (const tagName of tagNames) {
576
- const elements = doc.getElementsByTagName(tagName);
577
- for (let i = 0; i < elements.length; i++) {
578
- const el = elements[i];
576
+ const elements2 = doc.getElementsByTagName(tagName);
577
+ for (let i = 0; i < elements2.length; i++) {
578
+ const el = elements2[i];
579
579
  const id = el.getAttribute("id") || "";
580
580
  if (!id) continue;
581
581
  const heading = findChildByLocalName(el, "heading");
@@ -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 >= _chunkZ3O36LBJcjs.HEADING_RATIO_H1) level = 1;
619
- else if (ratio >= _chunkZ3O36LBJcjs.HEADING_RATIO_H2) level = 2;
620
- else if (ratio >= _chunkZ3O36LBJcjs.HEADING_RATIO_H3) level = 3;
618
+ if (ratio >= _chunkZQOGTAT5cjs.HEADING_RATIO_H1) level = 1;
619
+ else if (ratio >= _chunkZQOGTAT5cjs.HEADING_RATIO_H2) level = 2;
620
+ else if (ratio >= _chunkZQOGTAT5cjs.HEADING_RATIO_H3) level = 3;
621
621
  }
622
622
  const compactText = text.replace(/\s+/g, "");
623
623
  if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
@@ -667,8 +667,10 @@ var CONVERT_MAP = {
667
667
  SUCC: "\\succ",
668
668
  UPLUS: "\\uplus",
669
669
  "\xB1": "\\pm",
670
+ "+-": "\\pm",
670
671
  "-+": "\\mp",
671
672
  "\xF7": "\\div",
673
+ cdot: "\\cdot",
672
674
  CIRC: "\\circ",
673
675
  BULLET: "\\bullet",
674
676
  DEG: " ^\\circ",
@@ -1057,6 +1059,10 @@ function hmlToLatex(hmlEqStr) {
1057
1059
  const t = tokens[i];
1058
1060
  if (t in CONVERT_MAP) tokens[i] = CONVERT_MAP[t];
1059
1061
  else if (t in MIDDLE_CONVERT_MAP) tokens[i] = MIDDLE_CONVERT_MAP[t];
1062
+ else {
1063
+ const quoted = /^"(.+)"$/.exec(t);
1064
+ if (quoted) tokens[i] = `\\text{${quoted[1]}}`;
1065
+ }
1060
1066
  }
1061
1067
  tokens = tokens.filter((tok) => tok.length !== 0);
1062
1068
  tokens = replaceBracket(tokens);
@@ -1165,7 +1171,7 @@ function resolveParaHeading(paraEl, ctx) {
1165
1171
 
1166
1172
  // src/hwpx/table-build.ts
1167
1173
  function buildTableWithCellMeta(state) {
1168
- const table = _chunkZ3O36LBJcjs.buildTable.call(void 0, state.rows);
1174
+ const table = _chunkZQOGTAT5cjs.buildTable.call(void 0, state.rows);
1169
1175
  if (state.caption) table.caption = state.caption;
1170
1176
  const anchors = [];
1171
1177
  {
@@ -1235,7 +1241,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1235
1241
  const cell = parentTable.cell;
1236
1242
  (cell.blocks ??= []).push(block);
1237
1243
  cell.hasStructure = true;
1238
- let flat = _chunkZ3O36LBJcjs.convertTableToText.call(void 0, newTable.rows);
1244
+ let flat = _chunkZQOGTAT5cjs.convertTableToText.call(void 0, newTable.rows);
1239
1245
  if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
1240
1246
  if (flat) cell.text += (cell.text ? "\n" : "") + flat;
1241
1247
  } else {
@@ -1247,7 +1253,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1247
1253
  // src/hwpx/section-walker.ts
1248
1254
  function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
1249
1255
  const parser = createXmlParser(warnings);
1250
- const doc = parser.parseFromString(_chunkZ3O36LBJcjs.stripDtd.call(void 0, xml), "text/xml");
1256
+ const doc = parser.parseFromString(_chunkZQOGTAT5cjs.stripDtd.call(void 0, xml), "text/xml");
1251
1257
  if (!doc.documentElement) return [];
1252
1258
  const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
1253
1259
  ctx.shared.track.deleteDepth = 0;
@@ -1338,8 +1344,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
1338
1344
  const cs = isNaN(rawCs) ? 1 : rawCs;
1339
1345
  const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
1340
1346
  const rs = isNaN(rawRs) ? 1 : rawRs;
1341
- tableCtx.cell.colSpan = clampSpan(cs, _chunkZ3O36LBJcjs.MAX_COLS);
1342
- tableCtx.cell.rowSpan = clampSpan(rs, _chunkZ3O36LBJcjs.MAX_ROWS);
1347
+ tableCtx.cell.colSpan = clampSpan(cs, _chunkZQOGTAT5cjs.MAX_COLS);
1348
+ tableCtx.cell.rowSpan = clampSpan(rs, _chunkZQOGTAT5cjs.MAX_ROWS);
1343
1349
  }
1344
1350
  break;
1345
1351
  case "p": {
@@ -1561,7 +1567,7 @@ function extractHyperlinkHref(fieldBegin) {
1561
1567
  let url = (ch.textContent || "").trim();
1562
1568
  if (!url) continue;
1563
1569
  url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
1564
- const safe = _chunkZ3O36LBJcjs.sanitizeHref.call(void 0, url);
1570
+ const safe = _chunkZQOGTAT5cjs.sanitizeHref.call(void 0, url);
1565
1571
  if (safe) return safe;
1566
1572
  }
1567
1573
  return void 0;
@@ -1696,7 +1702,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
1696
1702
  case "hyperlink": {
1697
1703
  const url = child.getAttribute("url") || child.getAttribute("href") || "";
1698
1704
  if (url) {
1699
- const safe = _chunkZ3O36LBJcjs.sanitizeHref.call(void 0, url);
1705
+ const safe = _chunkZQOGTAT5cjs.sanitizeHref.call(void 0, url);
1700
1706
  if (safe) href = safe;
1701
1707
  }
1702
1708
  walk(child);
@@ -1882,13 +1888,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
1882
1888
  }
1883
1889
  const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
1884
1890
  for (const path of allCandidates) {
1885
- if (_chunkZ3O36LBJcjs.isPathTraversal.call(void 0, path)) continue;
1891
+ if (_chunkZQOGTAT5cjs.isPathTraversal.call(void 0, path)) continue;
1886
1892
  const file = zip.file(path);
1887
1893
  if (!file) continue;
1888
1894
  try {
1889
1895
  const data = await file.async("uint8array");
1890
1896
  decompressed.total += data.length;
1891
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1897
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZQOGTAT5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1892
1898
  const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
1893
1899
  const mimeType = imageExtToMime(ext);
1894
1900
  imageIndex++;
@@ -1897,7 +1903,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
1897
1903
  images.push(img);
1898
1904
  break;
1899
1905
  } catch (err) {
1900
- if (err instanceof _chunkZ3O36LBJcjs.KordocError) throw err;
1906
+ if (err instanceof _chunkZQOGTAT5cjs.KordocError) throw err;
1901
1907
  }
1902
1908
  }
1903
1909
  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" })]);
@@ -1959,7 +1965,7 @@ function extractFromBrokenZip(buffer) {
1959
1965
  }
1960
1966
  const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
1961
1967
  const name = new TextDecoder().decode(nameBytes);
1962
- if (_chunkZ3O36LBJcjs.isPathTraversal.call(void 0, name)) {
1968
+ if (_chunkZQOGTAT5cjs.isPathTraversal.call(void 0, name)) {
1963
1969
  pos = fileStart + compSize;
1964
1970
  continue;
1965
1971
  }
@@ -1977,16 +1983,16 @@ function extractFromBrokenZip(buffer) {
1977
1983
  continue;
1978
1984
  }
1979
1985
  totalDecompressed += content.length * 2;
1980
- if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
1986
+ if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZQOGTAT5cjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
1981
1987
  sectionNum++;
1982
1988
  blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
1983
1989
  } catch (e13) {
1984
1990
  continue;
1985
1991
  }
1986
1992
  }
1987
- if (blocks.length === 0) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
1993
+ if (blocks.length === 0) throw new (0, _chunkZQOGTAT5cjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
1988
1994
  applyPageText(blocks, shared);
1989
- const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
1995
+ const markdown = _chunkZQOGTAT5cjs.blocksToMarkdown.call(void 0, blocks);
1990
1996
  return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
1991
1997
  }
1992
1998
  async function resolveSectionPaths(zip) {
@@ -2000,18 +2006,18 @@ async function resolveSectionPaths(zip) {
2000
2006
  if (paths.length > 0) return paths;
2001
2007
  }
2002
2008
  const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
2003
- return sectionFiles.map((f) => f.name).sort(_chunkZ3O36LBJcjs.compareSectionPaths);
2009
+ return sectionFiles.map((f) => f.name).sort(_chunkZQOGTAT5cjs.compareSectionPaths);
2004
2010
  }
2005
2011
  function parseSectionPathsFromManifest(xml) {
2006
2012
  const parser = createXmlParser();
2007
- const doc = parser.parseFromString(_chunkZ3O36LBJcjs.stripDtd.call(void 0, xml), "text/xml");
2013
+ const doc = parser.parseFromString(_chunkZQOGTAT5cjs.stripDtd.call(void 0, xml), "text/xml");
2008
2014
  const items = doc.getElementsByTagName("opf:item");
2009
2015
  const spine = doc.getElementsByTagName("opf:itemref");
2010
2016
  const idToHref = /* @__PURE__ */ new Map();
2011
2017
  for (let i = 0; i < items.length; i++) {
2012
2018
  const item = items[i];
2013
2019
  const id = item.getAttribute("id") || "";
2014
- const href = _chunkZ3O36LBJcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
2020
+ const href = _chunkZQOGTAT5cjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
2015
2021
  if (id && href) idToHref.set(id, href);
2016
2022
  }
2017
2023
  if (spine.length > 0) {
@@ -2022,7 +2028,7 @@ function parseSectionPathsFromManifest(xml) {
2022
2028
  }
2023
2029
  if (ordered.length > 0) return ordered;
2024
2030
  }
2025
- return Array.from(idToHref.values()).sort(_chunkZ3O36LBJcjs.compareSectionPaths);
2031
+ return Array.from(idToHref.values()).sort(_chunkZQOGTAT5cjs.compareSectionPaths);
2026
2032
  }
2027
2033
 
2028
2034
  // src/hwpx/metadata.ts
@@ -2035,7 +2041,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
2035
2041
  const xml = await file.async("text");
2036
2042
  if (decompressed) {
2037
2043
  decompressed.total += xml.length * 2;
2038
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2044
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZQOGTAT5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2039
2045
  }
2040
2046
  parseDublinCoreMetadata(xml, metadata);
2041
2047
  if (metadata.title || metadata.author) return;
@@ -2045,7 +2051,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
2045
2051
  }
2046
2052
  function parseDublinCoreMetadata(xml, metadata) {
2047
2053
  const parser = createXmlParser();
2048
- const doc = parser.parseFromString(_chunkZ3O36LBJcjs.stripDtd.call(void 0, xml), "text/xml");
2054
+ const doc = parser.parseFromString(_chunkZQOGTAT5cjs.stripDtd.call(void 0, xml), "text/xml");
2049
2055
  if (!doc.documentElement) return;
2050
2056
  const getText = (tagNames) => {
2051
2057
  for (const tag of tagNames) {
@@ -2070,7 +2076,7 @@ function parseDublinCoreMetadata(xml, metadata) {
2070
2076
 
2071
2077
  // src/hwpx/parser.ts
2072
2078
  async function parseHwpxDocument(buffer, options) {
2073
- _chunkZ3O36LBJcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
2079
+ _chunkZQOGTAT5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
2074
2080
  let zip;
2075
2081
  try {
2076
2082
  zip = await _jszip2.default.loadAsync(buffer);
@@ -2079,7 +2085,7 @@ async function parseHwpxDocument(buffer, options) {
2079
2085
  }
2080
2086
  const actualEntryCount = Object.keys(zip.files).length;
2081
2087
  if (actualEntryCount > MAX_ZIP_ENTRIES) {
2082
- throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2088
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2083
2089
  }
2084
2090
  const manifestFile = zip.file("META-INF/manifest.xml");
2085
2091
  if (manifestFile) {
@@ -2091,7 +2097,7 @@ async function parseHwpxDocument(buffer, options) {
2091
2097
  return comResultToParseResult(pages, pageCount, warnings2);
2092
2098
  }
2093
2099
  }
2094
- throw new (0, _chunkZ3O36LBJcjs.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.");
2100
+ throw new (0, _chunkZQOGTAT5cjs.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.");
2095
2101
  }
2096
2102
  }
2097
2103
  const decompressed = { total: 0 };
@@ -2100,7 +2106,7 @@ async function parseHwpxDocument(buffer, options) {
2100
2106
  const styleMap = await extractHwpxStyles(zip, decompressed);
2101
2107
  const warnings = [];
2102
2108
  const sectionPaths = await resolveSectionPaths(zip);
2103
- if (sectionPaths.length === 0) throw new (0, _chunkZ3O36LBJcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
2109
+ if (sectionPaths.length === 0) throw new (0, _chunkZQOGTAT5cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
2104
2110
  metadata.pageCount = sectionPaths.length;
2105
2111
  const pageFilter = _optionalChain([options, 'optionalAccess', _45 => _45.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
2106
2112
  const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
@@ -2114,12 +2120,12 @@ async function parseHwpxDocument(buffer, options) {
2114
2120
  try {
2115
2121
  const xml = await file.async("text");
2116
2122
  decompressed.total += xml.length * 2;
2117
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2123
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZQOGTAT5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2118
2124
  blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
2119
2125
  parsedSections++;
2120
2126
  _optionalChain([options, 'optionalAccess', _46 => _46.onProgress, 'optionalCall', _47 => _47(parsedSections, totalTarget)]);
2121
2127
  } catch (secErr) {
2122
- if (secErr instanceof _chunkZ3O36LBJcjs.KordocError) throw secErr;
2128
+ if (secErr instanceof _chunkZQOGTAT5cjs.KordocError) throw secErr;
2123
2129
  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" });
2124
2130
  }
2125
2131
  }
@@ -2127,7 +2133,7 @@ async function parseHwpxDocument(buffer, options) {
2127
2133
  const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
2128
2134
  detectHwpxHeadings(blocks, styleMap);
2129
2135
  const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
2130
- const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
2136
+ const markdown = _chunkZQOGTAT5cjs.blocksToMarkdown.call(void 0, blocks);
2131
2137
  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 };
2132
2138
  }
2133
2139
 
@@ -2194,7 +2200,7 @@ function decompressStream(data) {
2194
2200
  return _zlib.inflateRawSync.call(void 0, data, opts);
2195
2201
  }
2196
2202
  function parseFileHeader(data) {
2197
- if (data.length < 40) throw new (0, _chunkZ3O36LBJcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
2203
+ if (data.length < 40) throw new (0, _chunkZQOGTAT5cjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
2198
2204
  const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
2199
2205
  return {
2200
2206
  signature: sig,
@@ -2502,11 +2508,11 @@ function formatRoman(n, upper) {
2502
2508
  const values = [1e3, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
2503
2509
  const symbols = upper ? ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"] : ["m", "cm", "d", "cd", "c", "xc", "l", "xl", "x", "ix", "v", "iv", "i"];
2504
2510
  let result = "";
2505
- let num = n;
2511
+ let num2 = n;
2506
2512
  for (let i = 0; i < values.length; i++) {
2507
- while (num >= values[i]) {
2513
+ while (num2 >= values[i]) {
2508
2514
  result += symbols[i];
2509
- num -= values[i];
2515
+ num2 -= values[i];
2510
2516
  }
2511
2517
  }
2512
2518
  return result;
@@ -2514,11 +2520,11 @@ function formatRoman(n, upper) {
2514
2520
  function formatLatin(n, upper) {
2515
2521
  if (n <= 0) return "";
2516
2522
  let result = "";
2517
- let num = n;
2518
- while (num > 0) {
2519
- num--;
2520
- result = String.fromCharCode((upper ? 65 : 97) + num % 26) + result;
2521
- num = Math.floor(num / 26);
2523
+ let num2 = n;
2524
+ while (num2 > 0) {
2525
+ num2--;
2526
+ result = String.fromCharCode((upper ? 65 : 97) + num2 % 26) + result;
2527
+ num2 = Math.floor(num2 / 26);
2522
2528
  }
2523
2529
  return result;
2524
2530
  }
@@ -2526,15 +2532,15 @@ function formatEastAsianNumber(n, digits, units, zero) {
2526
2532
  if (n === 0) return zero;
2527
2533
  if (n < 0 || n > 99999) return String(n);
2528
2534
  let result = "";
2529
- let num = n;
2535
+ let num2 = n;
2530
2536
  let unit = 0;
2531
- while (num > 0) {
2532
- const d = num % 10;
2537
+ while (num2 > 0) {
2538
+ const d = num2 % 10;
2533
2539
  if (d > 0) {
2534
2540
  const digitStr = d === 1 && unit > 0 ? "" : digits[d];
2535
2541
  result = digitStr + units[unit] + result;
2536
2542
  }
2537
- num = Math.floor(num / 10);
2543
+ num2 = Math.floor(num2 / 10);
2538
2544
  unit++;
2539
2545
  }
2540
2546
  return result;
@@ -2581,8 +2587,8 @@ function expandNumberingFormat(formatStr, counters, numbering) {
2581
2587
  const idx = levelRef - 1;
2582
2588
  const counterVal = _nullishCoalesce(counters[idx], () => ( 0));
2583
2589
  const start = _nullishCoalesce(numbering.startNumbers[idx], () => ( 1));
2584
- const num = counterVal > 0 ? start - 1 + counterVal : start;
2585
- result += formatNumber(num, headFormatToNumFmt(_nullishCoalesce(numbering.numberFormats[idx], () => ( 0))));
2590
+ const num2 = counterVal > 0 ? start - 1 + counterVal : start;
2591
+ result += formatNumber(num2, headFormatToNumFmt(_nullishCoalesce(numbering.numberFormats[idx], () => ( 0))));
2586
2592
  i += 2;
2587
2593
  continue;
2588
2594
  }
@@ -3728,7 +3734,7 @@ function parseHwp5Document(buffer, options) {
3728
3734
  lenientCfb = parseLenientCfb(buffer);
3729
3735
  warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
3730
3736
  } catch (e21) {
3731
- throw new (0, _chunkZ3O36LBJcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
3737
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
3732
3738
  }
3733
3739
  }
3734
3740
  const findStream = (path) => {
@@ -3739,11 +3745,11 @@ function parseHwp5Document(buffer, options) {
3739
3745
  return lenientCfb.findStream(path);
3740
3746
  };
3741
3747
  const headerData = findStream("/FileHeader");
3742
- if (!headerData) throw new (0, _chunkZ3O36LBJcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
3748
+ if (!headerData) throw new (0, _chunkZQOGTAT5cjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
3743
3749
  const header = parseFileHeader(headerData);
3744
- if (header.signature !== "HWP Document File") throw new (0, _chunkZ3O36LBJcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
3745
- if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3746
- if (header.flags & FLAG_DRM) throw new (0, _chunkZ3O36LBJcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3750
+ if (header.signature !== "HWP Document File") throw new (0, _chunkZQOGTAT5cjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
3751
+ if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkZQOGTAT5cjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3752
+ if (header.flags & FLAG_DRM) throw new (0, _chunkZQOGTAT5cjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3747
3753
  const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
3748
3754
  const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
3749
3755
  const metadata = {
@@ -3752,7 +3758,7 @@ function parseHwp5Document(buffer, options) {
3752
3758
  if (cfb) extractHwp5Metadata(cfb, metadata);
3753
3759
  const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
3754
3760
  const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
3755
- if (sections.length === 0) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3761
+ if (sections.length === 0) throw new (0, _chunkZQOGTAT5cjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3756
3762
  metadata.pageCount = sections.length;
3757
3763
  const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
3758
3764
  const totalTarget = pageFilter ? pageFilter.size : sections.length;
@@ -3766,25 +3772,25 @@ function parseHwp5Document(buffer, options) {
3766
3772
  const sectionData = sections[si];
3767
3773
  const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
3768
3774
  totalDecompressed += data.length;
3769
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3775
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkZQOGTAT5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3770
3776
  const records = readRecords(data);
3771
3777
  const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
3772
3778
  bodyBlocks.push(...sectionBlocks);
3773
3779
  parsedSections++;
3774
3780
  _optionalChain([options, 'optionalAccess', _52 => _52.onProgress, 'optionalCall', _53 => _53(parsedSections, totalTarget)]);
3775
3781
  } catch (secErr) {
3776
- if (secErr instanceof _chunkZ3O36LBJcjs.KordocError) throw secErr;
3782
+ if (secErr instanceof _chunkZQOGTAT5cjs.KordocError) throw secErr;
3777
3783
  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" });
3778
3784
  }
3779
3785
  }
3780
3786
  const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
3781
3787
  const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
3782
- const flatBlocks = _chunkZ3O36LBJcjs.flattenLayoutTables.call(void 0, blocks);
3788
+ const flatBlocks = _chunkZQOGTAT5cjs.flattenLayoutTables.call(void 0, blocks);
3783
3789
  if (docInfo) {
3784
3790
  detectHwp5Headings(flatBlocks, docInfo);
3785
3791
  }
3786
3792
  const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
3787
- const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, flatBlocks);
3793
+ const markdown = _chunkZQOGTAT5cjs.blocksToMarkdown.call(void 0, flatBlocks);
3788
3794
  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 };
3789
3795
  }
3790
3796
  function parseDocInfoStream(cfb, compressed) {
@@ -3844,9 +3850,9 @@ function detectHwp5Headings(blocks, docInfo) {
3844
3850
  let level = 0;
3845
3851
  if (_optionalChain([block, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]) && baseFontSize > 0) {
3846
3852
  const ratio = block.style.fontSize / baseFontSize;
3847
- if (ratio >= _chunkZ3O36LBJcjs.HEADING_RATIO_H1) level = 1;
3848
- else if (ratio >= _chunkZ3O36LBJcjs.HEADING_RATIO_H2) level = 2;
3849
- else if (ratio >= _chunkZ3O36LBJcjs.HEADING_RATIO_H3) level = 3;
3853
+ if (ratio >= _chunkZQOGTAT5cjs.HEADING_RATIO_H1) level = 1;
3854
+ else if (ratio >= _chunkZQOGTAT5cjs.HEADING_RATIO_H2) level = 2;
3855
+ else if (ratio >= _chunkZQOGTAT5cjs.HEADING_RATIO_H3) level = 3;
3850
3856
  }
3851
3857
  if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
3852
3858
  if (level === 0) level = 2;
@@ -3931,7 +3937,7 @@ function findSectionsLenient(lcfb, compressed) {
3931
3937
  if (!raw) break;
3932
3938
  const content = compressed ? decompressStream(raw) : raw;
3933
3939
  totalDecompressed += content.length;
3934
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3940
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkZQOGTAT5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3935
3941
  sections.push({ idx: i, content });
3936
3942
  }
3937
3943
  if (sections.length === 0) {
@@ -3943,7 +3949,7 @@ function findSectionsLenient(lcfb, compressed) {
3943
3949
  if (raw) {
3944
3950
  const content = compressed ? decompressStream(raw) : raw;
3945
3951
  totalDecompressed += content.length;
3946
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3952
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkZQOGTAT5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3947
3953
  sections.push({ idx, content });
3948
3954
  }
3949
3955
  }
@@ -3960,7 +3966,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
3960
3966
  try {
3961
3967
  const content = decryptViewText(raw, compressed);
3962
3968
  totalDecompressed += content.length;
3963
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3969
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkZQOGTAT5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3964
3970
  sections.push({ idx: i, content });
3965
3971
  } catch (e26) {
3966
3972
  break;
@@ -4063,7 +4069,7 @@ function parseParagraph(records, start, end, ctx) {
4063
4069
  const ctrl = ctrls[r.ctrlIdx];
4064
4070
  if (!_optionalChain([ctrl, 'optionalAccess', _66 => _66.href]) || r.end <= r.start) continue;
4065
4071
  if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
4066
- const href = _chunkZ3O36LBJcjs.sanitizeHref.call(void 0, ctrl.href);
4072
+ const href = _chunkZQOGTAT5cjs.sanitizeHref.call(void 0, ctrl.href);
4067
4073
  if (!href) continue;
4068
4074
  const anchor = text.slice(r.start, r.end);
4069
4075
  if (!anchor.trim()) continue;
@@ -4150,11 +4156,11 @@ function applyCtrlEffect(ctrl, records, ctx) {
4150
4156
  const attr = ctrl.data.readUInt32LE(4);
4151
4157
  const type = attr & 15;
4152
4158
  const format = attr >>> 4 & 255;
4153
- const num = _nullishCoalesce(ctx.doc.autoCounters.get(type), () => ( 1));
4154
- ctx.doc.autoCounters.set(type, num + 1);
4159
+ const num2 = _nullishCoalesce(ctx.doc.autoCounters.get(type), () => ( 1));
4160
+ ctx.doc.autoCounters.set(type, num2 + 1);
4155
4161
  const prefix = ctrl.data.length >= 14 ? wcharAt(ctrl.data, 12) : "";
4156
4162
  const suffix = ctrl.data.length >= 16 ? wcharAt(ctrl.data, 14) : "";
4157
- ctrl.inlineText = `${prefix}${formatNumber(num, shapeFormatToNumFmt(format))}${suffix}`;
4163
+ ctrl.inlineText = `${prefix}${formatNumber(num2, shapeFormatToNumFmt(format))}${suffix}`;
4158
4164
  }
4159
4165
  return;
4160
4166
  }
@@ -4162,8 +4168,8 @@ function applyCtrlEffect(ctrl, records, ctx) {
4162
4168
  if (ctrl.data.length >= 10) {
4163
4169
  const attr = ctrl.data.readUInt32LE(4);
4164
4170
  const type = attr & 15;
4165
- const num = ctrl.data.readUInt16LE(8);
4166
- if (num > 0) ctx.doc.autoCounters.set(type, num);
4171
+ const num2 = ctrl.data.readUInt16LE(8);
4172
+ if (num2 > 0) ctx.doc.autoCounters.set(type, num2);
4167
4173
  }
4168
4174
  return;
4169
4175
  }
@@ -4225,7 +4231,7 @@ function blocksPlainText(blocks, sep) {
4225
4231
  return parts.join(sep).trim();
4226
4232
  }
4227
4233
  function applyNoteEffect(ctrl, records, ctx, autoType) {
4228
- const num = _nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1));
4234
+ const num2 = _nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1));
4229
4235
  let before = "";
4230
4236
  let after = "";
4231
4237
  let shape = 0;
@@ -4236,11 +4242,11 @@ function applyNoteEffect(ctrl, records, ctx, autoType) {
4236
4242
  if (ctrl.data.length >= 16) {
4237
4243
  shape = ctrl.data.readUInt32LE(12) & 255;
4238
4244
  }
4239
- const formatted = formatNumber(num, shapeFormatToNumFmt(shape));
4245
+ const formatted = formatNumber(num2, shapeFormatToNumFmt(shape));
4240
4246
  const marker = before || after ? `${before}${formatted}${after}` : `${formatted})`;
4241
4247
  const content = blocksPlainText(parseListHeaderParagraphs(ctrl, records, ctx), " ");
4242
- if ((_nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1))) <= num) {
4243
- ctx.doc.autoCounters.set(autoType, num + 1);
4248
+ if ((_nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1))) <= num2) {
4249
+ ctx.doc.autoCounters.set(autoType, num2 + 1);
4244
4250
  }
4245
4251
  ctrl.inlineText = marker;
4246
4252
  if (content) ctrl.footnote = content.startsWith(marker) ? content : `${marker} ${content}`;
@@ -4296,8 +4302,8 @@ function parseTableControl(ctrl, records, ctx) {
4296
4302
  let tableIdx = -1;
4297
4303
  for (let i2 = childStart; i2 < childEnd; i2++) {
4298
4304
  if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
4299
- rows = Math.min(records[i2].data.readUInt16LE(4), _chunkZ3O36LBJcjs.MAX_ROWS);
4300
- cols = Math.min(records[i2].data.readUInt16LE(6), _chunkZ3O36LBJcjs.MAX_COLS);
4305
+ rows = Math.min(records[i2].data.readUInt16LE(4), _chunkZQOGTAT5cjs.MAX_ROWS);
4306
+ cols = Math.min(records[i2].data.readUInt16LE(6), _chunkZQOGTAT5cjs.MAX_COLS);
4301
4307
  tableIdx = i2;
4302
4308
  break;
4303
4309
  }
@@ -4346,7 +4352,7 @@ function parseTableControl(ctrl, records, ctx) {
4346
4352
  return table2;
4347
4353
  }
4348
4354
  const cellRows = arrangeCells(rows, cols, cells);
4349
- const table = _chunkZ3O36LBJcjs.buildTable.call(void 0, cellRows);
4355
+ const table = _chunkZQOGTAT5cjs.buildTable.call(void 0, cellRows);
4350
4356
  if (caption && table.rows > 0) table.caption = caption;
4351
4357
  return table.rows > 0 ? table : null;
4352
4358
  }
@@ -4363,8 +4369,8 @@ function parseCell(records, lhIdx, end, ctx) {
4363
4369
  rowAddr = rec.data.readUInt16LE(10);
4364
4370
  const cs = rec.data.readUInt16LE(12);
4365
4371
  const rs = rec.data.readUInt16LE(14);
4366
- if (cs > 0) colSpan = Math.min(cs, _chunkZ3O36LBJcjs.MAX_COLS);
4367
- if (rs > 0) rowSpan = Math.min(rs, _chunkZ3O36LBJcjs.MAX_ROWS);
4372
+ if (cs > 0) colSpan = Math.min(cs, _chunkZQOGTAT5cjs.MAX_COLS);
4373
+ if (rs > 0) rowSpan = Math.min(rs, _chunkZQOGTAT5cjs.MAX_ROWS);
4368
4374
  }
4369
4375
  const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
4370
4376
  const parts = [];
@@ -4374,7 +4380,7 @@ function parseCell(records, lhIdx, end, ctx) {
4374
4380
  parts.push(`![image](hwp5bin:${b.text})`);
4375
4381
  hasStructure = true;
4376
4382
  } else if (b.type === "table" && b.table) {
4377
- const flat = _chunkZ3O36LBJcjs.convertTableToText.call(void 0, b.table.cells);
4383
+ const flat = _chunkZQOGTAT5cjs.convertTableToText.call(void 0, b.table.cells);
4378
4384
  if (flat) parts.push(flat);
4379
4385
  hasStructure = true;
4380
4386
  } else if (b.text) {
@@ -16778,9 +16784,9 @@ var MAX_ROWS2 = 1e4;
16778
16784
  var MAX_COLS2 = 200;
16779
16785
  function cleanNumericValue(raw) {
16780
16786
  if (!/^-?\d+\.\d+$/.test(raw)) return raw;
16781
- const num = parseFloat(raw);
16782
- if (!isFinite(num)) return raw;
16783
- const cleaned = parseFloat(num.toPrecision(15)).toString();
16787
+ const num2 = parseFloat(raw);
16788
+ if (!isFinite(num2)) return raw;
16789
+ const cleaned = parseFloat(num2.toPrecision(15)).toString();
16784
16790
  return cleaned;
16785
16791
  }
16786
16792
  function parseCellRef(ref) {
@@ -16811,7 +16817,7 @@ function getTextContent(el) {
16811
16817
  return _nullishCoalesce(_optionalChain([el, 'access', _81 => _81.textContent, 'optionalAccess', _82 => _82.trim, 'call', _83 => _83()]), () => ( ""));
16812
16818
  }
16813
16819
  function parseXml(text) {
16814
- return new (0, _xmldom.DOMParser)().parseFromString(_chunkZ3O36LBJcjs.stripDtd.call(void 0, text), "text/xml");
16820
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunkZQOGTAT5cjs.stripDtd.call(void 0, text), "text/xml");
16815
16821
  }
16816
16822
  function parseSharedStrings(xml) {
16817
16823
  const doc = parseXml(xml);
@@ -16955,7 +16961,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
16955
16961
  cellRows.push(row);
16956
16962
  }
16957
16963
  if (cellRows.length > 0) {
16958
- const table = _chunkZ3O36LBJcjs.buildTable.call(void 0, cellRows);
16964
+ const table = _chunkZQOGTAT5cjs.buildTable.call(void 0, cellRows);
16959
16965
  if (table.rows > 0) {
16960
16966
  blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
16961
16967
  }
@@ -16963,12 +16969,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
16963
16969
  return blocks;
16964
16970
  }
16965
16971
  async function parseXlsxDocument(buffer, options) {
16966
- _chunkZ3O36LBJcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
16972
+ _chunkZQOGTAT5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
16967
16973
  const zip = await _jszip2.default.loadAsync(buffer);
16968
16974
  const warnings = [];
16969
16975
  const workbookFile = zip.file("xl/workbook.xml");
16970
16976
  if (!workbookFile) {
16971
- throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
16977
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
16972
16978
  }
16973
16979
  let sharedStrings = [];
16974
16980
  const ssFile = zip.file("xl/sharedStrings.xml");
@@ -16977,7 +16983,7 @@ async function parseXlsxDocument(buffer, options) {
16977
16983
  }
16978
16984
  const sheets = parseWorkbook(await workbookFile.async("text"));
16979
16985
  if (sheets.length === 0) {
16980
- throw new (0, _chunkZ3O36LBJcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
16986
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
16981
16987
  }
16982
16988
  let relsMap = /* @__PURE__ */ new Map();
16983
16989
  const relsFile = zip.file("xl/_rels/workbook.xml.rels");
@@ -17049,7 +17055,7 @@ async function parseXlsxDocument(buffer, options) {
17049
17055
  } catch (e27) {
17050
17056
  }
17051
17057
  }
17052
- const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
17058
+ const markdown = _chunkZQOGTAT5cjs.blocksToMarkdown.call(void 0, blocks);
17053
17059
  return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
17054
17060
  }
17055
17061
 
@@ -17123,17 +17129,17 @@ function decodeRk(rk) {
17123
17129
  const fDiv100 = (rk & 1) !== 0;
17124
17130
  const fInt = (rk & 2) !== 0;
17125
17131
  const val30 = rk >> 2;
17126
- let num;
17132
+ let num2;
17127
17133
  if (fInt) {
17128
- num = val30;
17134
+ num2 = val30;
17129
17135
  } else {
17130
17136
  const high32 = (rk & 4294967292) >>> 0;
17131
17137
  const buf = Buffer.alloc(8);
17132
17138
  buf.writeUInt32LE(0, 0);
17133
17139
  buf.writeUInt32LE(high32, 4);
17134
- num = buf.readDoubleLE(0);
17140
+ num2 = buf.readDoubleLE(0);
17135
17141
  }
17136
- return fDiv100 ? num / 100 : num;
17142
+ return fDiv100 ? num2 / 100 : num2;
17137
17143
  }
17138
17144
  function decodeMulRk(data) {
17139
17145
  if (data.length < 6) return null;
@@ -17456,11 +17462,11 @@ function processGlobals(records) {
17456
17462
  let encrypted = false;
17457
17463
  const firstBof = records[0];
17458
17464
  if (!firstBof || firstBof.opcode !== OP_BOF) {
17459
- throw new (0, _chunkZ3O36LBJcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
17465
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
17460
17466
  }
17461
17467
  const bof = decodeBof(firstBof.data);
17462
17468
  if (!bof || bof.dt !== DT_GLOBALS) {
17463
- throw new (0, _chunkZ3O36LBJcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
17469
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
17464
17470
  }
17465
17471
  let i = 1;
17466
17472
  while (i < records.length) {
@@ -17575,7 +17581,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
17575
17581
  cellRows.push(row);
17576
17582
  }
17577
17583
  if (cellRows.length > 0) {
17578
- const table = _chunkZ3O36LBJcjs.buildTable.call(void 0, cellRows);
17584
+ const table = _chunkZQOGTAT5cjs.buildTable.call(void 0, cellRows);
17579
17585
  if (table.rows > 0) {
17580
17586
  blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
17581
17587
  }
@@ -17588,21 +17594,21 @@ async function parseXlsDocument(buffer, options) {
17588
17594
  try {
17589
17595
  cfb = parseLenientCfb(buf);
17590
17596
  } catch (e) {
17591
- throw new (0, _chunkZ3O36LBJcjs.KordocError)(
17597
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)(
17592
17598
  `XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
17593
17599
  );
17594
17600
  }
17595
17601
  const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
17596
17602
  if (!wb) {
17597
- throw new (0, _chunkZ3O36LBJcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
17603
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
17598
17604
  }
17599
17605
  const records = readRecords2(wb);
17600
17606
  if (records.length === 0) {
17601
- throw new (0, _chunkZ3O36LBJcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
17607
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
17602
17608
  }
17603
17609
  const firstBof = decodeBof(records[0].data);
17604
17610
  if (firstBof && firstBof.vers !== 1536) {
17605
- throw new (0, _chunkZ3O36LBJcjs.KordocError)(
17611
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)(
17606
17612
  `XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
17607
17613
  );
17608
17614
  }
@@ -17662,7 +17668,7 @@ async function parseXlsDocument(buffer, options) {
17662
17668
  pageCount: totalSheets
17663
17669
  };
17664
17670
  return {
17665
- markdown: _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, allBlocks),
17671
+ markdown: _chunkZQOGTAT5cjs.blocksToMarkdown.call(void 0, allBlocks),
17666
17672
  blocks: allBlocks,
17667
17673
  metadata,
17668
17674
  warnings: warnings.length > 0 ? warnings : void 0
@@ -17833,9 +17839,9 @@ function nodeToLatex(el) {
17833
17839
  case "f": {
17834
17840
  const n = firstKid(el, "num");
17835
17841
  const d = firstKid(el, "den");
17836
- const num = n ? childrenToLatex(n) : "";
17842
+ const num2 = n ? childrenToLatex(n) : "";
17837
17843
  const den = d ? childrenToLatex(d) : "";
17838
- return "\\frac" + grp(num) + grp(den);
17844
+ return "\\frac" + grp(num2) + grp(den);
17839
17845
  }
17840
17846
  // 첨자
17841
17847
  case "sSup": {
@@ -18100,7 +18106,7 @@ function getAttr(el, localName2) {
18100
18106
  return null;
18101
18107
  }
18102
18108
  function parseXml2(text) {
18103
- return new (0, _xmldom.DOMParser)().parseFromString(_chunkZ3O36LBJcjs.stripDtd.call(void 0, text), "text/xml");
18109
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunkZQOGTAT5cjs.stripDtd.call(void 0, text), "text/xml");
18104
18110
  }
18105
18111
  function parseStyles(xml) {
18106
18112
  const doc = parseXml2(xml);
@@ -18361,7 +18367,7 @@ function parseTable(tbl, styles, numbering, footnotes, rels) {
18361
18367
  return { text: cell.text, colSpan: cell.colSpan, rowSpan, colAddr: cell.col, rowAddr: r };
18362
18368
  })
18363
18369
  );
18364
- const table = _chunkZ3O36LBJcjs.buildTable.call(void 0, cellRows);
18370
+ const table = _chunkZQOGTAT5cjs.buildTable.call(void 0, cellRows);
18365
18371
  if (table.rows === 0 || table.cols === 0) return null;
18366
18372
  return { type: "table", table };
18367
18373
  }
@@ -18428,12 +18434,12 @@ async function extractImages(zip, rels, doc, warnings) {
18428
18434
  return { blocks, images };
18429
18435
  }
18430
18436
  async function parseDocxDocument(buffer, options) {
18431
- _chunkZ3O36LBJcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
18437
+ _chunkZQOGTAT5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
18432
18438
  const zip = await _jszip2.default.loadAsync(buffer);
18433
18439
  const warnings = [];
18434
18440
  const docFile = zip.file("word/document.xml");
18435
18441
  if (!docFile) {
18436
- throw new (0, _chunkZ3O36LBJcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
18442
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
18437
18443
  }
18438
18444
  let rels = /* @__PURE__ */ new Map();
18439
18445
  const relsFile = zip.file("word/_rels/document.xml.rels");
@@ -18480,7 +18486,7 @@ async function parseDocxDocument(buffer, options) {
18480
18486
  const doc = parseXml2(docXml);
18481
18487
  const body = findElements(doc, "body");
18482
18488
  if (body.length === 0) {
18483
- throw new (0, _chunkZ3O36LBJcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
18489
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
18484
18490
  }
18485
18491
  const blocks = [];
18486
18492
  const bodyEl = body[0];
@@ -18525,7 +18531,7 @@ async function parseDocxDocument(buffer, options) {
18525
18531
  }
18526
18532
  }
18527
18533
  const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
18528
- const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
18534
+ const markdown = _chunkZQOGTAT5cjs.blocksToMarkdown.call(void 0, blocks);
18529
18535
  return {
18530
18536
  markdown,
18531
18537
  blocks,
@@ -18548,7 +18554,7 @@ function parseHwpmlDocument(buffer, options) {
18548
18554
  }
18549
18555
  const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
18550
18556
  const normalized = text.replace(/&nbsp;/g, "&#160;");
18551
- const xml = _chunkZ3O36LBJcjs.stripDtd.call(void 0, normalized);
18557
+ const xml = _chunkZQOGTAT5cjs.stripDtd.call(void 0, normalized);
18552
18558
  const warnings = [];
18553
18559
  const parser = new (0, _xmldom.DOMParser)({
18554
18560
  onError: (_level, msg2) => {
@@ -18588,7 +18594,7 @@ function parseHwpmlDocument(buffer, options) {
18588
18594
  parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
18589
18595
  }
18590
18596
  const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
18591
- const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
18597
+ const markdown = _chunkZQOGTAT5cjs.blocksToMarkdown.call(void 0, blocks);
18592
18598
  return {
18593
18599
  markdown,
18594
18600
  blocks,
@@ -18746,7 +18752,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
18746
18752
  const cellRows = grid.map(
18747
18753
  (row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
18748
18754
  );
18749
- const table = _chunkZ3O36LBJcjs.buildTable.call(void 0, cellRows);
18755
+ const table = _chunkZQOGTAT5cjs.buildTable.call(void 0, cellRows);
18750
18756
  blocks.push({ type: "table", table, pageNumber: sectionNum });
18751
18757
  }
18752
18758
  function extractCellText(cellEl) {
@@ -19935,19 +19941,19 @@ function parseCentralDirectory(buf) {
19935
19941
  }
19936
19942
  }
19937
19943
  }
19938
- if (eocdOffset < 0) throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19944
+ if (eocdOffset < 0) throw new (0, _chunkZQOGTAT5cjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19939
19945
  const totalEntries = view.getUint16(eocdOffset + 10, true);
19940
19946
  const cdSize = view.getUint32(eocdOffset + 12, true);
19941
19947
  const cdOffset = view.getUint32(eocdOffset + 16, true);
19942
- if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19948
+ if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkZQOGTAT5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19943
19949
  if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
19944
- throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19950
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19945
19951
  }
19946
19952
  const decoder = new TextDecoder("utf-8");
19947
19953
  const entries = [];
19948
19954
  let pos = cdOffset;
19949
19955
  for (let i = 0; i < totalEntries; i++) {
19950
- if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
19956
+ if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkZQOGTAT5cjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
19951
19957
  const flags = view.getUint16(pos + 8, true);
19952
19958
  const method = view.getUint16(pos + 10, true);
19953
19959
  const crc = view.getUint32(pos + 16, true);
@@ -19958,7 +19964,7 @@ function parseCentralDirectory(buf) {
19958
19964
  const commentLen = view.getUint16(pos + 32, true);
19959
19965
  const localOffset = view.getUint32(pos + 42, true);
19960
19966
  if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
19961
- throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19967
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19962
19968
  }
19963
19969
  const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
19964
19970
  const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
@@ -19987,7 +19993,7 @@ function patchZipEntries(original, replacements) {
19987
19993
  const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
19988
19994
  const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
19989
19995
  for (const name of replacements.keys()) {
19990
- if (!entries.some((e) => e.name === name)) throw new (0, _chunkZ3O36LBJcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
19996
+ if (!entries.some((e) => e.name === name)) throw new (0, _chunkZQOGTAT5cjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
19991
19997
  }
19992
19998
  const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
19993
19999
  const segments = [];
@@ -20005,7 +20011,7 @@ function patchZipEntries(original, replacements) {
20005
20011
  offset += seg.length;
20006
20012
  continue;
20007
20013
  }
20008
- if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkZ3O36LBJcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
20014
+ if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkZQOGTAT5cjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
20009
20015
  const nameLen = view.getUint16(e.localOffset + 26, true);
20010
20016
  const extraLen = view.getUint16(e.localOffset + 28, true);
20011
20017
  const headerLen = 30 + nameLen + extraLen;
@@ -20060,7 +20066,7 @@ async function fillHwpx(hwpxBuffer, values) {
20060
20066
  const zip = await _jszip2.default.loadAsync(hwpxBuffer);
20061
20067
  const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
20062
20068
  if (sectionPaths.length === 0) {
20063
- throw new (0, _chunkZ3O36LBJcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
20069
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
20064
20070
  }
20065
20071
  const normalizedValues = normalizeValues(values);
20066
20072
  const cursor = new ValueCursor(normalizedValues);
@@ -20476,10 +20482,10 @@ function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "kee
20476
20482
  const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _158 => _158.spacingPct]), () => ( 0));
20477
20483
  const k = height * ratioPct / 100 / 1e3;
20478
20484
  const cwCp = (cp) => (cp === 32 ? spaceEm : charWidthEm1000(cp)) * (1 + spacing / 100) * k;
20479
- const charW = (ch) => cwCp(ch.codePointAt(0));
20485
+ const charW2 = (ch) => cwCp(ch.codePointAt(0));
20480
20486
  const rangeW = (from, to) => {
20481
20487
  let w = 0;
20482
- for (const ch of text.slice(from, to)) w += charW(ch);
20488
+ for (const ch of text.slice(from, to)) w += charW2(ch);
20483
20489
  return w;
20484
20490
  };
20485
20491
  const units = _nullishCoalesce(text.match(mode === "keep" ? / +|[^ ]+/g : / +|[^ ]/g), () => ( []));
@@ -20500,7 +20506,7 @@ function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "kee
20500
20506
  };
20501
20507
  for (const u of units) {
20502
20508
  if (u[0] === " ") {
20503
- lineW += charW(" ") * u.length;
20509
+ lineW += charW2(" ") * u.length;
20504
20510
  pos += u.length;
20505
20511
  continue;
20506
20512
  }
@@ -20513,7 +20519,7 @@ function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "kee
20513
20519
  if (lineW === 0 || w > contWidth + EPS) {
20514
20520
  let sub = 0;
20515
20521
  for (const ch of u) {
20516
- const c = charW(ch);
20522
+ const c = charW2(ch);
20517
20523
  if (lineW + c > avail + EPS && lineW > 0) breakBefore(pos + sub, 0);
20518
20524
  lineW += c;
20519
20525
  sub += ch.length;
@@ -20773,6 +20779,16 @@ function buildPrvText(blocks) {
20773
20779
  }
20774
20780
  return lines.join("\n").slice(0, 1024);
20775
20781
  }
20782
+ function findMathDelim(s, from) {
20783
+ let i = s.indexOf("$$", from);
20784
+ while (i > 0) {
20785
+ let backslashes = 0;
20786
+ for (let j = i - 1; j >= 0 && s[j] === "\\"; j--) backslashes++;
20787
+ if (backslashes % 2 === 0) break;
20788
+ i = s.indexOf("$$", i + 1);
20789
+ }
20790
+ return i;
20791
+ }
20776
20792
  function parseMarkdownToBlocks(md2) {
20777
20793
  const lines = md2.split("\n");
20778
20794
  const blocks = [];
@@ -20783,6 +20799,45 @@ function parseMarkdownToBlocks(md2) {
20783
20799
  i++;
20784
20800
  continue;
20785
20801
  }
20802
+ const mathOpen = /^\s*\$\$/.exec(line);
20803
+ if (mathOpen) {
20804
+ const afterOpen = line.slice(mathOpen[0].length);
20805
+ const closeSame = findMathDelim(afterOpen, 0);
20806
+ if (closeSame >= 0) {
20807
+ const inner = afterOpen.slice(0, closeSame).trim();
20808
+ const trailing2 = afterOpen.slice(closeSame + 2).trim();
20809
+ if (inner) blocks.push({ type: "equation", text: inner });
20810
+ if (trailing2) blocks.push({ type: "paragraph", text: trailing2 });
20811
+ i++;
20812
+ continue;
20813
+ }
20814
+ const mathLines = [];
20815
+ if (afterOpen.trim()) mathLines.push(afterOpen);
20816
+ let closed = false;
20817
+ let trailing = "";
20818
+ let j = i + 1;
20819
+ for (; j < lines.length; j++) {
20820
+ const l = lines[j];
20821
+ if (!l.trim() || /^\s*(`{3,}|~{3,})/.test(l)) break;
20822
+ const end = findMathDelim(l, 0);
20823
+ if (end >= 0) {
20824
+ const before = l.slice(0, end);
20825
+ if (before.trim()) mathLines.push(before);
20826
+ trailing = l.slice(end + 2).trim();
20827
+ closed = true;
20828
+ j++;
20829
+ break;
20830
+ }
20831
+ mathLines.push(l);
20832
+ }
20833
+ if (closed) {
20834
+ const text = mathLines.join("\n").trim();
20835
+ if (text) blocks.push({ type: "equation", text });
20836
+ if (trailing) blocks.push({ type: "paragraph", text: trailing });
20837
+ i = j;
20838
+ continue;
20839
+ }
20840
+ }
20786
20841
  const fenceMatch = line.match(/^(`{3,}|~{3,})(.*)$/);
20787
20842
  if (fenceMatch) {
20788
20843
  const fence = fenceMatch[1];
@@ -21175,6 +21230,7 @@ function precomputeGongmunList(blocks, gongmun) {
21175
21230
  i++;
21176
21231
  continue;
21177
21232
  }
21233
+ const passThrough = (t) => t === "table" || t === "html_table" || t === "equation";
21178
21234
  const run = [];
21179
21235
  while (i < blocks.length) {
21180
21236
  const t = blocks[i].type;
@@ -21183,9 +21239,9 @@ function precomputeGongmunList(blocks, gongmun) {
21183
21239
  i++;
21184
21240
  continue;
21185
21241
  }
21186
- if (t === "table" || t === "html_table") {
21242
+ if (passThrough(t)) {
21187
21243
  let j = i + 1;
21188
- while (j < blocks.length && (blocks[j].type === "table" || blocks[j].type === "html_table")) j++;
21244
+ while (j < blocks.length && passThrough(blocks[j].type)) j++;
21189
21245
  if (j < blocks.length && blocks[j].type === "list_item") {
21190
21246
  i = j;
21191
21247
  continue;
@@ -21381,7 +21437,7 @@ function escapeGfm(text) {
21381
21437
  }
21382
21438
  var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
21383
21439
  function sanitizeText(text) {
21384
- let result = _chunkZ3O36LBJcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
21440
+ let result = _chunkZQOGTAT5cjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
21385
21441
  if (result.length <= 30 && result.includes(" ")) {
21386
21442
  const tokens = result.split(" ");
21387
21443
  const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-힯ㄱ-ㆎ]/.test(t)).length;
@@ -21711,6 +21767,280 @@ function generateHtmlTableXml(rawHtml, theme, totalWidth = 44e3) {
21711
21767
  return `<hp:tbl id="${tblId}" zOrder="0" numberingType="TABLE" pageBreak="CELL" repeatHeader="0" rowCnt="${rowCnt}" colCnt="${colCnt}" cellSpacing="0" borderFillIDRef="2" noShading="0"><hp:sz width="${tblW}" widthRelTo="ABSOLUTE" height="${cellH * rowCnt}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="1" affectLSpacing="0" flowWithText="0" allowOverlap="0" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="PARA" vertAlign="TOP" horzAlign="LEFT" vertOffset="0" horzOffset="0"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:inMargin left="510" right="510" top="141" bottom="141"/>` + trXmls.join("") + `</hp:tbl>`;
21712
21768
  }
21713
21769
 
21770
+ // src/hwpx/equation-generate.ts
21771
+ var MAX_EQUATION_SOURCE = 1e4;
21772
+ var MAX_GROUP_DEPTH = 64;
21773
+ var COMMAND_MAP = {
21774
+ alpha: "alpha",
21775
+ beta: "beta",
21776
+ gamma: "gamma",
21777
+ delta: "delta",
21778
+ epsilon: "epsilon",
21779
+ zeta: "zeta",
21780
+ eta: "eta",
21781
+ theta: "theta",
21782
+ iota: "iota",
21783
+ kappa: "kappa",
21784
+ lambda: "lambda",
21785
+ mu: "mu",
21786
+ nu: "nu",
21787
+ xi: "xi",
21788
+ pi: "pi",
21789
+ rho: "rho",
21790
+ sigma: "sigma",
21791
+ tau: "tau",
21792
+ upsilon: "upsilon",
21793
+ phi: "phi",
21794
+ chi: "chi",
21795
+ psi: "psi",
21796
+ omega: "omega",
21797
+ Gamma: "GAMMA",
21798
+ Delta: "DELTA",
21799
+ Theta: "THETA",
21800
+ Lambda: "LAMBDA",
21801
+ Xi: "XI",
21802
+ Pi: "PI",
21803
+ Sigma: "SIGMA",
21804
+ Upsilon: "UPSILON",
21805
+ Phi: "PHI",
21806
+ Psi: "PSI",
21807
+ Omega: "OMEGA",
21808
+ le: "LEQ",
21809
+ leq: "LEQ",
21810
+ ge: "GEQ",
21811
+ geq: "GEQ",
21812
+ ne: "!=",
21813
+ neq: "!=",
21814
+ pm: "+-",
21815
+ mp: "-+",
21816
+ times: "TIMES",
21817
+ cdot: "cdot",
21818
+ ast: "AST",
21819
+ circ: "CIRC",
21820
+ bullet: "BULLET",
21821
+ in: "IN",
21822
+ notin: "NOTIN",
21823
+ subset: "SUBSET",
21824
+ subseteq: "SUBSETEQ",
21825
+ supset: "SUPERSET",
21826
+ supseteq: "SUPSETEQ",
21827
+ cup: "CUP",
21828
+ cap: "SMALLINTER",
21829
+ emptyset: "EMPTYSET",
21830
+ forall: "FORALL",
21831
+ exists: "EXIST",
21832
+ infinity: "INF",
21833
+ infty: "INF",
21834
+ partial: "Partial",
21835
+ nabla: "NABLA",
21836
+ int: "int",
21837
+ iint: "dint",
21838
+ iiint: "tint",
21839
+ oint: "oint",
21840
+ sum: "sum",
21841
+ prod: "prod",
21842
+ lim: "lim",
21843
+ to: "->",
21844
+ rightarrow: "->",
21845
+ leftarrow: "larrow",
21846
+ leftrightarrow: "<->",
21847
+ Rightarrow: "RARROW",
21848
+ Leftarrow: "LARROW",
21849
+ Leftrightarrow: "LRARROW",
21850
+ cdots: "CDOTS",
21851
+ ldots: "LDOTS",
21852
+ vdots: "VDOTS",
21853
+ ddots: "DDOTS"
21854
+ };
21855
+ var ACCENT_COMMANDS = {
21856
+ bar: "bar",
21857
+ overline: "bar",
21858
+ vec: "vec",
21859
+ overrightarrow: "vec",
21860
+ hat: "hat",
21861
+ widehat: "hat",
21862
+ tilde: "tilde",
21863
+ widetilde: "tilde",
21864
+ dot: "dot",
21865
+ ddot: "ddot",
21866
+ underline: "under"
21867
+ };
21868
+ var RESERVED_WORDS = new Set(
21869
+ [...Object.keys(CONVERT_MAP), ...Object.keys(MIDDLE_CONVERT_MAP), "over", "root", "of"].filter((w) => /^[A-Za-z]+$/.test(w))
21870
+ );
21871
+ function skipSpaces(input, idx) {
21872
+ while (idx < input.length && /\s/.test(input[idx])) idx++;
21873
+ return idx;
21874
+ }
21875
+ function normalizeEqEdit(input) {
21876
+ return input.replace(/\s+/g, " ").trim();
21877
+ }
21878
+ function stripMathDelimiters(input) {
21879
+ let s = input.trim();
21880
+ if (s.startsWith("$$") && s.endsWith("$$")) s = s.slice(2, -2).trim();
21881
+ if (s.startsWith("\\[") && s.endsWith("\\]")) s = s.slice(2, -2).trim();
21882
+ return s;
21883
+ }
21884
+ function readBalanced(input, idx, open, close) {
21885
+ let depth = 1;
21886
+ let cursor = idx + 1;
21887
+ while (cursor < input.length) {
21888
+ const ch = input[cursor];
21889
+ if (ch === "\\") {
21890
+ cursor += 2;
21891
+ continue;
21892
+ }
21893
+ if (ch === open) depth++;
21894
+ else if (ch === close) depth--;
21895
+ if (depth === 0) {
21896
+ return { value: input.slice(idx + 1, cursor), next: cursor + 1 };
21897
+ }
21898
+ cursor++;
21899
+ }
21900
+ return { value: input.slice(idx + 1), next: input.length };
21901
+ }
21902
+ function readGroupOrToken(input, idx, depth) {
21903
+ const start = skipSpaces(input, idx);
21904
+ if (depth > MAX_GROUP_DEPTH) return { value: input.slice(start), next: input.length };
21905
+ if (input[start] === "{") {
21906
+ const group = readBalanced(input, start, "{", "}");
21907
+ return { value: convertLatexFragment(group.value, depth + 1), next: group.next };
21908
+ }
21909
+ if (input[start] === "\\") {
21910
+ const cmd = readCommand(input, start, depth + 1);
21911
+ return { value: cmd.value, next: cmd.next };
21912
+ }
21913
+ return { value: _nullishCoalesce(input[start], () => ( "")), next: Math.min(start + 1, input.length) };
21914
+ }
21915
+ function readCommandName(input, idx) {
21916
+ if (input[idx + 1] === "\\") return { value: "\\", next: idx + 2 };
21917
+ const match = /^[A-Za-z]+/.exec(input.slice(idx + 1));
21918
+ if (match) return { value: match[0], next: idx + 1 + match[0].length };
21919
+ return { value: _nullishCoalesce(input[idx + 1], () => ( "")), next: Math.min(idx + 2, input.length) };
21920
+ }
21921
+ function readCommand(input, idx, depth) {
21922
+ const name = readCommandName(input, idx);
21923
+ const command = name.value;
21924
+ if (command === "\\") return { value: "#", next: name.next };
21925
+ if (command === "frac") {
21926
+ const num2 = readGroupOrToken(input, name.next, depth);
21927
+ const den = readGroupOrToken(input, num2.next, depth);
21928
+ return { value: `{${num2.value}} over {${den.value}}`, next: den.next };
21929
+ }
21930
+ if (command === "sqrt") {
21931
+ let cursor = skipSpaces(input, name.next);
21932
+ let root = null;
21933
+ if (input[cursor] === "[") {
21934
+ const opt = readBalanced(input, cursor, "[", "]");
21935
+ root = { value: convertLatexFragment(opt.value, depth + 1), next: opt.next };
21936
+ cursor = opt.next;
21937
+ }
21938
+ const body = readGroupOrToken(input, cursor, depth);
21939
+ if (root) return { value: `root {${root.value}} of {${body.value}}`, next: body.next };
21940
+ return { value: `sqrt{${body.value}}`, next: body.next };
21941
+ }
21942
+ if (command === "begin") {
21943
+ const env = readGroupOrToken(input, name.next, depth);
21944
+ const endTag = `\\end{${env.value}}`;
21945
+ const endIdx = input.indexOf(endTag, env.next);
21946
+ if (endIdx === -1) return { value: env.value, next: env.next };
21947
+ const body = convertLatexFragment(input.slice(env.next, endIdx), depth + 1);
21948
+ if (env.value === "matrix" || env.value === "pmatrix" || env.value === "bmatrix") {
21949
+ return { value: `{${env.value}{${body}}}`, next: endIdx + endTag.length };
21950
+ }
21951
+ return { value: body, next: endIdx + endTag.length };
21952
+ }
21953
+ if (command === "left" || command === "right") {
21954
+ const kw = command === "left" ? "LEFT" : "RIGHT";
21955
+ const cursor = skipSpaces(input, name.next);
21956
+ let delimiter = _nullishCoalesce(input[cursor], () => ( ""));
21957
+ let next = delimiter ? cursor + 1 : cursor;
21958
+ if (delimiter === "\\") {
21959
+ const escaped = readCommandName(input, cursor);
21960
+ delimiter = escaped.value === "\\" ? "\\" : _nullishCoalesce(COMMAND_MAP[escaped.value], () => ( escaped.value));
21961
+ next = escaped.next;
21962
+ }
21963
+ return { value: delimiter ? `${kw} ${delimiter}` : kw, next };
21964
+ }
21965
+ if (command in ACCENT_COMMANDS) {
21966
+ const body = readGroupOrToken(input, name.next, depth);
21967
+ return { value: `${ACCENT_COMMANDS[command]}{${body.value}}`, next: body.next };
21968
+ }
21969
+ if (command === "mathrm" || command === "text") {
21970
+ const start = skipSpaces(input, name.next);
21971
+ if (input[start] === "{") {
21972
+ const group = readBalanced(input, start, "{", "}");
21973
+ return { value: `"${group.value}"`, next: group.next };
21974
+ }
21975
+ const tok = readGroupOrToken(input, start, depth);
21976
+ return { value: `"${tok.value}"`, next: tok.next };
21977
+ }
21978
+ return { value: _nullishCoalesce(COMMAND_MAP[command], () => ( command)), next: name.next };
21979
+ }
21980
+ function convertLatexFragment(input, depth) {
21981
+ if (depth > MAX_GROUP_DEPTH) return normalizeEqEdit(input);
21982
+ let out = "";
21983
+ let idx = 0;
21984
+ while (idx < input.length) {
21985
+ const ch = input[idx];
21986
+ if (ch === "\\") {
21987
+ const cmd = readCommand(input, idx, depth + 1);
21988
+ out += ` ${cmd.value} `;
21989
+ idx = cmd.next;
21990
+ continue;
21991
+ }
21992
+ if (ch === "{") {
21993
+ const group = readBalanced(input, idx, "{", "}");
21994
+ out += `{${convertLatexFragment(group.value, depth + 1)}}`;
21995
+ idx = group.next;
21996
+ continue;
21997
+ }
21998
+ if (ch === "_" || ch === "^") {
21999
+ const script = readGroupOrToken(input, idx + 1, depth);
22000
+ out += ` ${ch}{${script.value}}`;
22001
+ idx = script.next;
22002
+ continue;
22003
+ }
22004
+ if (ch === "&") {
22005
+ out += " & ";
22006
+ idx++;
22007
+ continue;
22008
+ }
22009
+ out += ch;
22010
+ idx++;
22011
+ }
22012
+ return normalizeEqEdit(out);
22013
+ }
22014
+ function quoteReservedKeywords(latex) {
22015
+ return latex.replace(/([_^])\s*\{\s*([A-Za-z]+)\s*\}/g, (match, op, word) => RESERVED_WORDS.has(word) ? `${op}{"${word}"}` : match);
22016
+ }
22017
+ function latexLikeToEqEdit(input) {
22018
+ const src = stripMathDelimiters(input);
22019
+ if (src.length > MAX_EQUATION_SOURCE) return normalizeEqEdit(src);
22020
+ return convertLatexFragment(quoteReservedKeywords(src), 0);
22021
+ }
22022
+ function estimateEquationMetrics(script) {
22023
+ const cleaned = script.replace(/[{}\\^_]/g, "").replace(/\s+/g, " ").trim();
22024
+ const width = Math.min(Math.max(cleaned.length, 5) * 700 + 2e3, 4e4);
22025
+ const rowCount = Math.max(1, (_nullishCoalesce(script.match(/#/g), () => ( []))).length + 1);
22026
+ if (/\bmatrix\b|#/.test(script)) {
22027
+ if (rowCount >= 4) return { width, height: 5500, baseline: 55 };
22028
+ if (rowCount === 3) return { width, height: 4500, baseline: 60 };
22029
+ return { width, height: 3260, baseline: 63 };
22030
+ }
22031
+ if (/\bover\b|\broot\b|\bsqrt\b/.test(script)) return { width, height: 3010, baseline: 69 };
22032
+ return { width, height: 1450, baseline: 71 };
22033
+ }
22034
+ function generateEquationXml(script, zOrder = 0) {
22035
+ const { width, height, baseline } = estimateEquationMetrics(script);
22036
+ const eqId = 2000000001 + zOrder;
22037
+ return `<hp:equation id="${eqId}" zOrder="${zOrder}" numberingType="EQUATION" textWrap="TOP_AND_BOTTOM" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" version="Equation Version 60" baseLine="${baseline}" textColor="#000000" baseUnit="1200" lineMode="CHAR" font="HYhwpEQ"><hp:sz width="${width}" widthRelTo="ABSOLUTE" height="${height}" 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="56" right="56" top="0" bottom="0"/><hp:shapeComment>\uC218\uC2DD\uC785\uB2C8\uB2E4.</hp:shapeComment><hp:script>${escapeXml(script)}</hp:script></hp:equation>`;
22038
+ }
22039
+ function generateEquationParagraph(input, zOrder = 0) {
22040
+ const script = latexLikeToEqEdit(input);
22041
+ return `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${generateEquationXml(script, zOrder)}</hp:run></hp:p>`;
22042
+ }
22043
+
21714
22044
  // src/hwpx/gen-section.ts
21715
22045
  function generateSecPr(gongmun) {
21716
22046
  const m = gongmun ? {
@@ -21758,6 +22088,15 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
21758
22088
  xml = codeLines.map((line) => generateParagraph(line || " ", PARA_CODE)).join("\n ");
21759
22089
  break;
21760
22090
  }
22091
+ case "equation": {
22092
+ if (isFirst) {
22093
+ const secRun = `<hp:run charPrIDRef="0">${generateSecPr(gongmun)}<hp:t></hp:t></hp:run>`;
22094
+ paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0">${secRun}</hp:p>`);
22095
+ isFirst = false;
22096
+ }
22097
+ xml = generateEquationParagraph(block.text || "", blockIdx);
22098
+ break;
22099
+ }
21761
22100
  case "blockquote":
21762
22101
  xml = generateParagraph(
21763
22102
  block.text || "",
@@ -22603,7 +22942,7 @@ async function resolveSectionEntryNames(zip) {
22603
22942
  const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
22604
22943
  if (paths.length > 0) return paths;
22605
22944
  }
22606
- return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkZ3O36LBJcjs.compareSectionPaths);
22945
+ return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkZQOGTAT5cjs.compareSectionPaths);
22607
22946
  }
22608
22947
  function sectionPathsFromManifest(xml) {
22609
22948
  const attr = (tag, name) => {
@@ -22613,7 +22952,7 @@ function sectionPathsFromManifest(xml) {
22613
22952
  const idToHref = /* @__PURE__ */ new Map();
22614
22953
  for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
22615
22954
  const id = attr(m[1], "id");
22616
- const href = _chunkZ3O36LBJcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
22955
+ const href = _chunkZQOGTAT5cjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
22617
22956
  if (id && href) idToHref.set(id, href);
22618
22957
  }
22619
22958
  const ordered = [];
@@ -22622,7 +22961,7 @@ function sectionPathsFromManifest(xml) {
22622
22961
  if (href) ordered.push(href);
22623
22962
  }
22624
22963
  if (ordered.length > 0) return ordered;
22625
- return Array.from(idToHref.values()).sort(_chunkZ3O36LBJcjs.compareSectionPaths);
22964
+ return Array.from(idToHref.values()).sort(_chunkZQOGTAT5cjs.compareSectionPaths);
22626
22965
  }
22627
22966
 
22628
22967
  // src/roundtrip/patcher.ts
@@ -22733,9 +23072,9 @@ function buildOrigUnits(blocks) {
22733
23072
  if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
22734
23073
  const next = blocks[i + 1];
22735
23074
  if (_optionalChain([next, 'optionalAccess', _217 => _217.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
22736
- chunk = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
23075
+ chunk = _chunkZQOGTAT5cjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
22737
23076
  } else {
22738
- chunk = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, [block]);
23077
+ chunk = _chunkZQOGTAT5cjs.blocksToMarkdown.call(void 0, [block]);
22739
23078
  }
22740
23079
  if (chunk) {
22741
23080
  const subUnits = splitMarkdownUnits(chunk);
@@ -24433,13 +24772,13 @@ async function htmlToPdf(html, options) {
24433
24772
  try {
24434
24773
  puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
24435
24774
  } catch (e30) {
24436
- throw new (0, _chunkZ3O36LBJcjs.KordocError)(
24775
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)(
24437
24776
  "PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
24438
24777
  );
24439
24778
  }
24440
24779
  const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
24441
24780
  if (!executablePath) {
24442
- throw new (0, _chunkZ3O36LBJcjs.KordocError)(
24781
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)(
24443
24782
  "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."
24444
24783
  );
24445
24784
  }
@@ -24498,24 +24837,647 @@ async function markdownToPdf(markdown, options) {
24498
24837
  return htmlToPdf(html, options);
24499
24838
  }
24500
24839
  async function blocksToPdf(blocks, options) {
24501
- const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, blocks);
24840
+ const markdown = _chunkZQOGTAT5cjs.blocksToMarkdown.call(void 0, blocks);
24502
24841
  return markdownToPdf(markdown, options);
24503
24842
  }
24504
24843
 
24844
+ // src/render/svg-render.ts
24845
+
24846
+
24847
+ // src/render/layout.ts
24848
+ function toInt32(v, fallback = 0) {
24849
+ if (v == null || v === "") return fallback;
24850
+ const n = Number(v);
24851
+ if (!Number.isFinite(n)) return fallback;
24852
+ return n > 2147483647 ? n - 4294967296 : n;
24853
+ }
24854
+ function solveBoundaries(constraints, count, total) {
24855
+ const x = new Array(count + 1).fill(void 0);
24856
+ x[0] = 0;
24857
+ if (total != null && total > 0) x[count] = total;
24858
+ let changed = true;
24859
+ let guard = 0;
24860
+ while (changed && guard++ < count + 8) {
24861
+ changed = false;
24862
+ for (const c of constraints) {
24863
+ if (c.a < 0 || c.b > count || c.a >= c.b) continue;
24864
+ const xa = x[c.a];
24865
+ const xb = x[c.b];
24866
+ if (xa != null && xb == null) {
24867
+ x[c.b] = xa + c.size;
24868
+ changed = true;
24869
+ } else if (xb != null && xa == null) {
24870
+ x[c.a] = xb - c.size;
24871
+ changed = true;
24872
+ }
24873
+ }
24874
+ }
24875
+ let i = 0;
24876
+ while (i <= count) {
24877
+ if (x[i] != null) {
24878
+ i++;
24879
+ continue;
24880
+ }
24881
+ let lo = i - 1;
24882
+ let hi = i;
24883
+ while (hi <= count && x[hi] == null) hi++;
24884
+ const loV = x[lo];
24885
+ const hiV = hi <= count ? x[hi] : loV + (hi - lo) * 1e3;
24886
+ const n = hi - lo;
24887
+ for (let k = 1; k < n; k++) x[lo + k] = loV + (hiV - loV) * k / n;
24888
+ if (hi > count) x[count] = hiV;
24889
+ i = hi;
24890
+ }
24891
+ const out = x;
24892
+ for (let k = 1; k <= count; k++) if (out[k] < out[k - 1]) out[k] = out[k - 1];
24893
+ return out;
24894
+ }
24895
+ function solveRowHeights(cells, rowCount) {
24896
+ const h = new Array(rowCount).fill(0);
24897
+ for (const c of cells) {
24898
+ if (c.rowSpan === 1 && c.rowAddr >= 0 && c.rowAddr < rowCount) {
24899
+ h[c.rowAddr] = Math.max(h[c.rowAddr], c.height);
24900
+ }
24901
+ }
24902
+ for (const c of cells) {
24903
+ if (c.rowSpan <= 1) continue;
24904
+ const rows = [];
24905
+ for (let r = c.rowAddr; r < Math.min(c.rowAddr + c.rowSpan, rowCount); r++) rows.push(r);
24906
+ const known = rows.reduce((s, r) => s + h[r], 0);
24907
+ const missing = rows.filter((r) => h[r] === 0);
24908
+ if (missing.length > 0 && c.height > known) {
24909
+ const each = (c.height - known) / missing.length;
24910
+ for (const r of missing) h[r] = each;
24911
+ }
24912
+ }
24913
+ for (const c of cells) {
24914
+ if (c.rowSpan === 1 && c.contentH != null && c.rowAddr >= 0 && c.rowAddr < rowCount) {
24915
+ if (c.contentH > h[c.rowAddr]) h[c.rowAddr] = c.contentH;
24916
+ }
24917
+ }
24918
+ return h;
24919
+ }
24920
+
24921
+ // src/render/head-styles.ts
24922
+ var DEFAULT_CHAR = { height: 1e3, bold: false, italic: false, underline: false, ratio: 100, spacing: 0 };
24923
+ function borderWidthPt(v) {
24924
+ const n = parseFloat(_nullishCoalesce(v, () => ( "")));
24925
+ if (!Number.isFinite(n)) return 0.34;
24926
+ return n * 2.834645;
24927
+ }
24928
+ function parseEdge(el) {
24929
+ if (!el) return void 0;
24930
+ const type = _nullishCoalesce(el.getAttribute("type"), () => ( "NONE"));
24931
+ if (type === "NONE") return void 0;
24932
+ return { type, widthPt: borderWidthPt(el.getAttribute("width")), color: _nullishCoalesce(el.getAttribute("color"), () => ( "#000000")) };
24933
+ }
24934
+ function parseRenderStyles(headXml) {
24935
+ const styles = { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
24936
+ const doc = createXmlParser().parseFromString(headXml, "text/xml");
24937
+ const root = doc.documentElement;
24938
+ if (!root) return styles;
24939
+ const walk = (el) => {
24940
+ const tag = (el.tagName || "").replace(/^[^:]+:/, "");
24941
+ if (tag === "charPr") {
24942
+ const id = el.getAttribute("id");
24943
+ if (id != null) {
24944
+ const ratioEl = findChildByLocalName(el, "ratio");
24945
+ const spacingEl = findChildByLocalName(el, "spacing");
24946
+ const underlineEl = findChildByLocalName(el, "underline");
24947
+ const textColor = el.getAttribute("textColor");
24948
+ styles.charPr.set(id, {
24949
+ height: Number(el.getAttribute("height")) || 1e3,
24950
+ bold: findChildByLocalName(el, "bold") != null,
24951
+ italic: findChildByLocalName(el, "italic") != null,
24952
+ underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
24953
+ color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
24954
+ ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _276 => _276.getAttribute, 'call', _277 => _277("hangul")])) || 100,
24955
+ spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _278 => _278.getAttribute, 'call', _279 => _279("hangul")])) || 0
24956
+ });
24957
+ }
24958
+ } else if (tag === "paraPr") {
24959
+ const id = el.getAttribute("id");
24960
+ if (id != null) {
24961
+ const align = findChildByLocalName(el, "align");
24962
+ styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _280 => _280.getAttribute, 'call', _281 => _281("horizontal")]) || "JUSTIFY");
24963
+ }
24964
+ } else if (tag === "borderFill") {
24965
+ const id = el.getAttribute("id");
24966
+ if (id != null) {
24967
+ const bf = {
24968
+ left: parseEdge(findChildByLocalName(el, "leftBorder")),
24969
+ right: parseEdge(findChildByLocalName(el, "rightBorder")),
24970
+ top: parseEdge(findChildByLocalName(el, "topBorder")),
24971
+ bottom: parseEdge(findChildByLocalName(el, "bottomBorder"))
24972
+ };
24973
+ const fillBrush = findChildByLocalName(el, "fillBrush");
24974
+ const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
24975
+ const face = _optionalChain([winBrush, 'optionalAccess', _282 => _282.getAttribute, 'call', _283 => _283("faceColor")]);
24976
+ if (face && face.toLowerCase() !== "none") bf.fill = face;
24977
+ styles.borderFill.set(id, bf);
24978
+ }
24979
+ }
24980
+ const children = el.childNodes;
24981
+ for (let i = 0; i < children.length; i++) {
24982
+ const ch = children[i];
24983
+ if (ch.nodeType === 1) walk(ch);
24984
+ }
24985
+ };
24986
+ walk(root);
24987
+ return styles;
24988
+ }
24989
+
24990
+ // src/render/svg-render.ts
24991
+ function ln(el) {
24992
+ return (el.tagName || "").replace(/^[^:]+:/, "");
24993
+ }
24994
+ function elements(el) {
24995
+ const out = [];
24996
+ const children = el.childNodes;
24997
+ if (!children) return out;
24998
+ for (let i = 0; i < children.length; i++) {
24999
+ if (children[i].nodeType === 1) out.push(children[i]);
25000
+ }
25001
+ return out;
25002
+ }
25003
+ function num(el, attr, fallback = 0) {
25004
+ return el ? toInt32(_nullishCoalesce(el.getAttribute(attr), () => ( void 0)), fallback) : fallback;
25005
+ }
25006
+ function findFirst(el, name, depth = 0) {
25007
+ if (depth > 64) return null;
25008
+ for (const ch of elements(el)) {
25009
+ if (ln(ch) === name) return ch;
25010
+ const found = findFirst(ch, name, depth + 1);
25011
+ if (found) return found;
25012
+ }
25013
+ return null;
25014
+ }
25015
+ function escapeXml3(s) {
25016
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
25017
+ }
25018
+ var OBJ_TAGS = /* @__PURE__ */ new Set(["tbl", "pic", "container", "equation", "rect", "ellipse", "polygon", "curv", "line", "arc", "ole", "textart"]);
25019
+ var pt = (u) => String(Math.round(u) / 100);
25020
+ function warnOnce(ctx, key, msg2) {
25021
+ if (ctx.warned.has(key)) return;
25022
+ ctx.warned.add(key);
25023
+ ctx.warnings.push(msg2);
25024
+ }
25025
+ function textOfT(t) {
25026
+ let s = "";
25027
+ const walk = (n, d) => {
25028
+ if (d > 32) return;
25029
+ const kids2 = n.childNodes;
25030
+ if (!kids2) return;
25031
+ for (let i = 0; i < kids2.length; i++) {
25032
+ const c = kids2[i];
25033
+ if (c.nodeType === 3) s += _nullishCoalesce(c.textContent, () => ( ""));
25034
+ else if (c.nodeType === 1) walk(c, d + 1);
25035
+ }
25036
+ };
25037
+ walk(t, 0);
25038
+ return s;
25039
+ }
25040
+ function buildPara(p) {
25041
+ const chars = [];
25042
+ const objs = [];
25043
+ let segs = [];
25044
+ for (const runEl of elements(p)) {
25045
+ const tag = ln(runEl);
25046
+ if (tag === "run") {
25047
+ const prId = runEl.getAttribute("charPrIDRef");
25048
+ for (const ch of elements(runEl)) {
25049
+ const cn = ln(ch);
25050
+ if (cn === "t") {
25051
+ for (const c of textOfT(ch)) chars.push({ ch: c, prId });
25052
+ } else if (OBJ_TAGS.has(cn)) {
25053
+ const sz = findChildByLocalName(ch, "sz");
25054
+ const pos = findChildByLocalName(ch, "pos");
25055
+ objs.push({
25056
+ el: ch,
25057
+ tag: cn,
25058
+ index: chars.length,
25059
+ inline: _optionalChain([pos, 'optionalAccess', _284 => _284.getAttribute, 'call', _285 => _285("treatAsChar")]) === "1",
25060
+ width: num(sz, "width"),
25061
+ height: num(sz, "height")
25062
+ });
25063
+ }
25064
+ }
25065
+ } else if (tag === "linesegarray") {
25066
+ segs = elements(runEl).filter((s) => ln(s) === "lineseg").map((s) => ({
25067
+ textpos: num(s, "textpos"),
25068
+ vertpos: num(s, "vertpos"),
25069
+ horzpos: num(s, "horzpos"),
25070
+ horzsize: num(s, "horzsize"),
25071
+ textheight: num(s, "textheight", 1e3),
25072
+ baseline: num(s, "baseline", 850)
25073
+ }));
25074
+ }
25075
+ }
25076
+ return { chars, segs, objs, paraPrId: p.getAttribute("paraPrIDRef") };
25077
+ }
25078
+ function charW(c, styles) {
25079
+ const st = _nullishCoalesce((c.prId != null ? styles.charPr.get(c.prId) : void 0), () => ( DEFAULT_CHAR));
25080
+ return measureTextWidth(c.ch, st.height, st.ratio, { spacingPct: st.spacing });
25081
+ }
25082
+ function lineNaturalWidth(m, styles, start, end) {
25083
+ let text = 0;
25084
+ for (let i = start; i < end && i < m.chars.length; i++) text += charW(m.chars[i], styles);
25085
+ let obj = 0;
25086
+ for (const o of m.objs) if (o.inline && o.index >= start && o.index < end) obj += o.width;
25087
+ return { text, obj };
25088
+ }
25089
+ function planLines(m, styles) {
25090
+ const align = _nullishCoalesce((m.paraPrId != null ? styles.paraAlign.get(m.paraPrId) : void 0), () => ( "JUSTIFY"));
25091
+ const plans = [];
25092
+ for (let i = 0; i < m.segs.length; i++) {
25093
+ const seg = m.segs[i];
25094
+ const start = seg.textpos;
25095
+ const end = i + 1 < m.segs.length ? m.segs[i + 1].textpos : Math.max(m.chars.length, start);
25096
+ const nat = lineNaturalWidth(m, styles, start, end);
25097
+ const isLast = i === m.segs.length - 1;
25098
+ let xoff = 0;
25099
+ let scale = 1;
25100
+ const avail = seg.horzsize - nat.obj;
25101
+ if (nat.text > 0 && (!isLast || align === "DISTRIBUTE" || align === "DISTRIBUTE_SPACE")) {
25102
+ scale = avail > 0 ? avail / nat.text : 1;
25103
+ } else if (nat.text + nat.obj > 0 && isLast) {
25104
+ const w = nat.text + nat.obj;
25105
+ if (align === "CENTER") xoff = Math.max(0, (seg.horzsize - w) / 2);
25106
+ else if (align === "RIGHT") xoff = Math.max(0, seg.horzsize - w);
25107
+ }
25108
+ if (!Number.isFinite(scale) || scale <= 0) scale = 1;
25109
+ scale = Math.min(4, Math.max(0.25, scale));
25110
+ plans.push({ seg, xoff, scale, start, end });
25111
+ }
25112
+ return plans;
25113
+ }
25114
+ function advanceTo(m, styles, plan, upto) {
25115
+ let x = 0;
25116
+ for (let i = plan.start; i < upto && i < m.chars.length; i++) x += charW(m.chars[i], styles) * plan.scale;
25117
+ for (const o of m.objs) if (o.inline && o.index >= plan.start && o.index < upto) x += o.width;
25118
+ return x;
25119
+ }
25120
+ function drawPara(p, ox, oy, areaW, ctx, depth) {
25121
+ if (depth > 16) {
25122
+ warnOnce(ctx, "depth", "\uC911\uCCA9 \uAE4A\uC774 16 \uCD08\uACFC \u2014 \uC774\uD558 \uC0DD\uB7B5");
25123
+ return;
25124
+ }
25125
+ const m = buildPara(p);
25126
+ if (m.segs.length === 0) {
25127
+ for (const o of m.objs) drawObject(o, ox, oy, 0, areaW, ctx, depth);
25128
+ return;
25129
+ }
25130
+ const plans = planLines(m, ctx.styles);
25131
+ const baseV = m.segs[0].vertpos;
25132
+ for (const plan of plans) {
25133
+ const { seg } = plan;
25134
+ let i = plan.start;
25135
+ let cursor = ox + seg.horzpos + plan.xoff;
25136
+ const y = oy + seg.vertpos + seg.baseline;
25137
+ while (i < plan.end && i < m.chars.length) {
25138
+ const prId = m.chars[i].prId;
25139
+ let j = i;
25140
+ let piece = "";
25141
+ while (j < plan.end && j < m.chars.length && m.chars[j].prId === prId) {
25142
+ piece += m.chars[j].ch;
25143
+ j++;
25144
+ }
25145
+ for (const o of m.objs) {
25146
+ if (o.inline && o.index > i && o.index < j) {
25147
+ piece = piece.slice(0, o.index - i);
25148
+ j = o.index;
25149
+ break;
25150
+ }
25151
+ }
25152
+ {
25153
+ const cut = piece.search(/ {2,}/);
25154
+ if (cut > 0) {
25155
+ piece = piece.slice(0, cut);
25156
+ j = i + cut;
25157
+ } else if (cut === 0) {
25158
+ const runEnd = piece.match(/^ +/)[0].length;
25159
+ piece = piece.slice(0, runEnd);
25160
+ j = i + runEnd;
25161
+ }
25162
+ }
25163
+ const st = _nullishCoalesce((prId != null ? ctx.styles.charPr.get(prId) : void 0), () => ( DEFAULT_CHAR));
25164
+ const w = measureTextWidth(piece, st.height, st.ratio, { spacingPct: st.spacing }) * plan.scale;
25165
+ if (piece.trim().length > 0) {
25166
+ const attrs = [`x="${pt(cursor)}"`, `y="${pt(y)}"`, `font-size="${pt(st.height)}"`];
25167
+ if ([...piece].length > 1 && w > 50) {
25168
+ attrs.push(`textLength="${pt(w)}"`, `lengthAdjust="${plan.scale < 1 ? "spacingAndGlyphs" : "spacing"}"`);
25169
+ }
25170
+ if (st.bold) attrs.push(`font-weight="bold"`);
25171
+ if (st.italic) attrs.push(`font-style="italic"`);
25172
+ if (st.underline) attrs.push(`text-decoration="underline"`);
25173
+ if (st.color) attrs.push(`fill="${escapeXml3(st.color)}"`);
25174
+ ctx.svg.push(`<text ${attrs.join(" ")}>${escapeXml3(piece)}</text>`);
25175
+ ctx.stats.texts++;
25176
+ }
25177
+ cursor += w;
25178
+ for (const o of m.objs) if (o.inline && o.index === j) cursor += o.width;
25179
+ i = j;
25180
+ }
25181
+ }
25182
+ for (const o of m.objs) {
25183
+ if (o.inline) {
25184
+ let plan = plans[0];
25185
+ for (const pl of plans) if (pl.start <= o.index && (o.index < pl.end || pl === plans[plans.length - 1])) plan = pl;
25186
+ const x = ox + plan.seg.horzpos + plan.xoff + advanceTo(m, ctx.styles, plan, o.index);
25187
+ const yTop = oy + plan.seg.vertpos + Math.max(0, plan.seg.baseline - o.height);
25188
+ drawObject(o, x, yTop, baseV, areaW, ctx, depth);
25189
+ } else {
25190
+ const { x, y } = anchorObject(o, ox, oy, baseV, areaW, ctx);
25191
+ drawObject(o, x, y, baseV, areaW, ctx, depth);
25192
+ }
25193
+ }
25194
+ }
25195
+ function anchorObject(o, ox, oy, baseV, areaW, ctx) {
25196
+ const { PW, PH, ML, MT, BODY_W, BODY_H } = ctx.geom;
25197
+ const pos = findChildByLocalName(o.el, "pos");
25198
+ const om = findChildByLocalName(o.el, "outMargin");
25199
+ const omT = num(om, "top"), omB = num(om, "bottom");
25200
+ const w = o.width, h = o.height;
25201
+ if (!pos) return { x: ox, y: oy + baseV };
25202
+ const vo = num(pos, "vertOffset");
25203
+ const ho = num(pos, "horzOffset");
25204
+ const vrel = _nullishCoalesce(pos.getAttribute("vertRelTo"), () => ( "PARA"));
25205
+ const hrel = _nullishCoalesce(pos.getAttribute("horzRelTo"), () => ( "PARA"));
25206
+ const va = _nullishCoalesce(pos.getAttribute("vertAlign"), () => ( "TOP"));
25207
+ const ha = _nullishCoalesce(pos.getAttribute("horzAlign"), () => ( "LEFT"));
25208
+ const wrap = _nullishCoalesce(o.el.getAttribute("textWrap"), () => ( "TOP_AND_BOTTOM"));
25209
+ let y;
25210
+ if (vrel === "PAPER") {
25211
+ y = va === "BOTTOM" ? PH - h - vo : va === "CENTER" ? (PH - h) / 2 + vo : vo;
25212
+ } else if (vrel === "PAGE") {
25213
+ y = va === "BOTTOM" ? MT + BODY_H - h - vo : va === "CENTER" ? MT + (BODY_H - h) / 2 + vo : MT + vo;
25214
+ } else if (wrap === "TOP_AND_BOTTOM") {
25215
+ const pushed = baseV - (omT + h + omB);
25216
+ const anchor = pushed >= -100 ? pushed : baseV;
25217
+ y = oy + anchor + omT + vo;
25218
+ } else {
25219
+ y = oy + baseV + vo;
25220
+ }
25221
+ let x;
25222
+ if (hrel === "PAGE") {
25223
+ x = ha === "RIGHT" ? ML + BODY_W - w - ho : ha === "CENTER" ? ML + (BODY_W - w) / 2 + ho : ML + ho;
25224
+ } else if (hrel === "PAPER") {
25225
+ x = ha === "RIGHT" ? PW - w - ho : ha === "CENTER" ? (PW - w) / 2 + ho : ho;
25226
+ } else {
25227
+ x = ha === "RIGHT" ? ox + areaW - w - ho : ha === "CENTER" ? ox + (areaW - w) / 2 + ho : ox + ho;
25228
+ }
25229
+ return { x, y };
25230
+ }
25231
+ function drawObject(o, x, y, baseV, areaW, ctx, depth) {
25232
+ if (o.tag === "tbl") drawTable(o.el, x, y, ctx, depth + 1);
25233
+ else if (o.tag === "pic") drawPic(o.el, x, y, ctx);
25234
+ else if (o.tag === "container") {
25235
+ for (const ch of elements(o.el)) {
25236
+ const tag = ln(ch);
25237
+ if (!OBJ_TAGS.has(tag)) continue;
25238
+ const sz = findChildByLocalName(ch, "sz");
25239
+ const off = findChildByLocalName(ch, "offset");
25240
+ const sub = { el: ch, tag, index: 0, inline: true, width: num(sz, "width"), height: num(sz, "height") };
25241
+ drawObject(sub, x + num(off, "x"), y + num(off, "y"), baseV, areaW, ctx, depth + 1);
25242
+ }
25243
+ } else if (o.tag === "equation") {
25244
+ warnOnce(ctx, "equation", "\uC218\uC2DD \uAC1C\uCCB4\uB294 \uB80C\uB354 \uBBF8\uC9C0\uC6D0 \u2014 \uC0DD\uB7B5");
25245
+ } else {
25246
+ warnOnce(ctx, `shape:${o.tag}`, `\uB3C4\uD615 \uAC1C\uCCB4(${o.tag}) \uB80C\uB354 \uBBF8\uC9C0\uC6D0 \u2014 \uC0DD\uB7B5`);
25247
+ }
25248
+ }
25249
+ function cellContentExtent(cell, ctx) {
25250
+ if (!cell.sub) return 0;
25251
+ let ext = 0;
25252
+ for (const p of elements(cell.sub)) {
25253
+ if (ln(p) !== "p") continue;
25254
+ const m = buildPara(p);
25255
+ for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
25256
+ const baseV = _nullishCoalesce(_optionalChain([m, 'access', _286 => _286.segs, 'access', _287 => _287[0], 'optionalAccess', _288 => _288.vertpos]), () => ( 0));
25257
+ for (const o of m.objs) {
25258
+ if (o.inline) continue;
25259
+ const pos = findChildByLocalName(o.el, "pos");
25260
+ if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _289 => _289.getAttribute, 'call', _290 => _290("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
25261
+ const om = findChildByLocalName(o.el, "outMargin");
25262
+ const pushed = baseV - (num(om, "top") + o.height + num(om, "bottom"));
25263
+ const anchor = pushed >= -100 ? pushed : baseV;
25264
+ ext = Math.max(ext, anchor + num(om, "top") + num(pos, "vertOffset") + o.height);
25265
+ }
25266
+ }
25267
+ return ext;
25268
+ }
25269
+ function edgeLine(x1, y1, x2, y2, e) {
25270
+ const dash = /DASH|DOT/.test(e.type) ? ` stroke-dasharray="${e.type.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
25271
+ return `<line x1="${pt(x1)}" y1="${pt(y1)}" x2="${pt(x2)}" y2="${pt(y2)}" stroke="${escapeXml3(e.color)}" stroke-width="${e.widthPt.toFixed(2)}"${dash}/>`;
25272
+ }
25273
+ function drawTable(tbl, tx, ty, ctx, depth) {
25274
+ if (depth > 16) {
25275
+ warnOnce(ctx, "depth", "\uC911\uCCA9 \uAE4A\uC774 16 \uCD08\uACFC \u2014 \uC774\uD558 \uC0DD\uB7B5");
25276
+ return;
25277
+ }
25278
+ ctx.stats.tables++;
25279
+ const tblSz = findChildByLocalName(tbl, "sz");
25280
+ const inMargin = findChildByLocalName(tbl, "inMargin");
25281
+ const defL = num(inMargin, "left", 141), defR = num(inMargin, "right", 141);
25282
+ const defT = num(inMargin, "top", 141), defB = num(inMargin, "bottom", 141);
25283
+ const cells = [];
25284
+ for (const tr of elements(tbl)) {
25285
+ if (ln(tr) !== "tr") continue;
25286
+ for (const tc of elements(tr)) {
25287
+ if (ln(tc) !== "tc") continue;
25288
+ const addr = findChildByLocalName(tc, "cellAddr");
25289
+ const span = findChildByLocalName(tc, "cellSpan");
25290
+ const csz = findChildByLocalName(tc, "cellSz");
25291
+ const cm = findChildByLocalName(tc, "cellMargin");
25292
+ if (!addr || !csz) continue;
25293
+ cells.push({
25294
+ el: tc,
25295
+ ca: num(addr, "colAddr"),
25296
+ ra: num(addr, "rowAddr"),
25297
+ cs: Math.max(1, num(span, "colSpan", 1)),
25298
+ rs: Math.max(1, num(span, "rowSpan", 1)),
25299
+ w: num(csz, "width"),
25300
+ h: num(csz, "height"),
25301
+ bfId: tc.getAttribute("borderFillIDRef"),
25302
+ sub: findChildByLocalName(tc, "subList"),
25303
+ marginL: cm ? num(cm, "left", defL) : defL,
25304
+ marginR: cm ? num(cm, "right", defR) : defR,
25305
+ marginT: cm ? num(cm, "top", defT) : defT,
25306
+ marginB: cm ? num(cm, "bottom", defB) : defB
25307
+ });
25308
+ }
25309
+ }
25310
+ if (cells.length === 0 || cells.length > 4096) return;
25311
+ const nCols = Math.max(...cells.map((c) => c.ca + c.cs));
25312
+ const nRows = Math.max(...cells.map((c) => c.ra + c.rs));
25313
+ const colCons = cells.map((c) => ({ a: c.ca, b: c.ca + c.cs, size: c.w }));
25314
+ const colX = solveBoundaries(colCons, nCols, num(tblSz, "width") || void 0);
25315
+ const rowH = solveRowHeights(
25316
+ cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: c.h, contentH: c.rs === 1 ? cellContentExtent(c, ctx) : void 0 })),
25317
+ nRows
25318
+ );
25319
+ const rowY = [0];
25320
+ for (let r = 0; r < nRows; r++) rowY.push(rowY[r] + rowH[r]);
25321
+ const geom = cells.map((c) => ({
25322
+ c,
25323
+ x: tx + colX[c.ca],
25324
+ y: ty + rowY[c.ra],
25325
+ w: colX[Math.min(c.ca + c.cs, nCols)] - colX[c.ca],
25326
+ h: rowY[Math.min(c.ra + c.rs, nRows)] - rowY[c.ra]
25327
+ }));
25328
+ for (const g of geom) {
25329
+ const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
25330
+ if (_optionalChain([bf, 'optionalAccess', _291 => _291.fill])) ctx.svg.push(`<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
25331
+ }
25332
+ for (const g of geom) {
25333
+ const { c } = g;
25334
+ if (!c.sub) continue;
25335
+ const innerH = g.h - c.marginT - c.marginB;
25336
+ const extent = cellContentExtent(c, ctx);
25337
+ const va = _nullishCoalesce(c.sub.getAttribute("vertAlign"), () => ( "TOP"));
25338
+ let yoff = 0;
25339
+ if (va === "CENTER") yoff = Math.max(0, (innerH - extent) / 2);
25340
+ else if (va === "BOTTOM") yoff = Math.max(0, innerH - extent);
25341
+ for (const p of elements(c.sub)) {
25342
+ if (ln(p) !== "p") continue;
25343
+ drawPara(p, g.x + c.marginL, g.y + c.marginT + yoff, g.w - c.marginL - c.marginR, ctx, depth + 1);
25344
+ }
25345
+ }
25346
+ for (const g of geom) {
25347
+ const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
25348
+ if (!bf) continue;
25349
+ if (bf.top) ctx.svg.push(edgeLine(g.x, g.y, g.x + g.w, g.y, bf.top));
25350
+ if (bf.bottom) ctx.svg.push(edgeLine(g.x, g.y + g.h, g.x + g.w, g.y + g.h, bf.bottom));
25351
+ if (bf.left) ctx.svg.push(edgeLine(g.x, g.y, g.x, g.y + g.h, bf.left));
25352
+ if (bf.right) ctx.svg.push(edgeLine(g.x + g.w, g.y, g.x + g.w, g.y + g.h, bf.right));
25353
+ }
25354
+ }
25355
+ function drawPic(pic, x, y, ctx) {
25356
+ const sz = findChildByLocalName(pic, "sz");
25357
+ const w = num(sz, "width", 5669), h = num(sz, "height", 5669);
25358
+ const img = findFirst(pic, "img");
25359
+ const ref = _optionalChain([img, 'optionalAccess', _292 => _292.getAttribute, 'call', _293 => _293("binaryItemIDRef")]);
25360
+ const loaded = ref != null ? ctx.images.get(ref) : void 0;
25361
+ if (!loaded) {
25362
+ ctx.svg.push(`<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
25363
+ warnOnce(ctx, `img:${ref}`, `\uC774\uBBF8\uC9C0 \uBC14\uC774\uB108\uB9AC \uB204\uB77D: ${_nullishCoalesce(ref, () => ( "(ref \uC5C6\uC74C)"))}`);
25364
+ return;
25365
+ }
25366
+ ctx.stats.images++;
25367
+ const orgSz = findChildByLocalName(pic, "orgSz");
25368
+ const clip = findChildByLocalName(pic, "imgClip");
25369
+ const orgW = num(orgSz, "width"), orgH = num(orgSz, "height");
25370
+ const cl = num(clip, "left"), ct = num(clip, "top");
25371
+ const cr = num(clip, "right", orgW), cb = num(clip, "bottom", orgH);
25372
+ const cropped = orgW > 0 && orgH > 0 && clip != null && (cl > 0 || ct > 0 || cr < orgW || cb < orgH) && cr > cl && cb > ct;
25373
+ if (cropped) {
25374
+ ctx.svg.push(
25375
+ `<svg x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" viewBox="${pt(cl)} ${pt(ct)} ${pt(cr - cl)} ${pt(cb - ct)}" preserveAspectRatio="none"><image x="0" y="0" width="${pt(orgW)}" height="${pt(orgH)}" preserveAspectRatio="none" href="${loaded.dataUri}"/></svg>`
25376
+ );
25377
+ } else {
25378
+ ctx.svg.push(`<image x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" preserveAspectRatio="none" href="${loaded.dataUri}"/>`);
25379
+ }
25380
+ }
25381
+ function sniffMime(name, bytes) {
25382
+ const lower = name.toLowerCase();
25383
+ if (lower.endsWith(".png") || bytes.length > 4 && bytes[0] === 137 && bytes[1] === 80) return "image/png";
25384
+ if (lower.endsWith(".bmp") || bytes.length > 2 && bytes[0] === 66 && bytes[1] === 77) return "image/bmp";
25385
+ if (lower.endsWith(".gif")) return "image/gif";
25386
+ if (lower.endsWith(".svg")) return "image/svg+xml";
25387
+ return "image/jpeg";
25388
+ }
25389
+ async function renderHwpxToSvg(input, options) {
25390
+ const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _294 => _294.maxImageBytes]), () => ( 40 * 1024 * 1024));
25391
+ let zip;
25392
+ try {
25393
+ zip = await _jszip2.default.loadAsync(input);
25394
+ } catch (e31) {
25395
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
25396
+ }
25397
+ const secFile = _nullishCoalesce(zip.file("Contents/section0.xml"), () => ( zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name))[0]));
25398
+ if (!secFile) throw new (0, _chunkZQOGTAT5cjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
25399
+ const secXml = await secFile.async("string");
25400
+ if (secXml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkZQOGTAT5cjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
25401
+ if (!secXml.includes("linesegarray")) {
25402
+ throw new (0, _chunkZQOGTAT5cjs.KordocError)("\uC870\uD310 \uCE90\uC2DC(linesegarray) \uC5C6\uC74C \u2014 \uD55C\uCEF4\uC5D0\uC11C \uC800\uC7A5\uD55C HWPX\uB9CC \uB80C\uB354 \uAC00\uB2A5");
25403
+ }
25404
+ const warnings = [];
25405
+ const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
25406
+ const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
25407
+ if (!headFile) warnings.push("header.xml \uC5C6\uC74C \u2014 \uAE30\uBCF8 \uC2A4\uD0C0\uC77C\uB85C \uB80C\uB354");
25408
+ const binmap = /* @__PURE__ */ new Map();
25409
+ const hpf = zip.file(/content\.hpf$/i)[0];
25410
+ if (hpf) {
25411
+ const man = await hpf.async("string");
25412
+ for (const m of man.matchAll(/<[^>]*\bid="([^"]+)"[^>]*\bhref="(BinData\/[^"]+)"[^>]*>/g)) binmap.set(m[1], m[2]);
25413
+ for (const m of man.matchAll(/<[^>]*\bhref="(BinData\/[^"]+)"[^>]*\bid="([^"]+)"[^>]*>/g)) binmap.set(m[2], m[1]);
25414
+ }
25415
+ const images = /* @__PURE__ */ new Map();
25416
+ const refs = /* @__PURE__ */ new Set();
25417
+ for (const m of secXml.matchAll(/binaryItemIDRef="([^"]+)"/g)) refs.add(m[1]);
25418
+ for (const ref of refs) {
25419
+ let href = binmap.get(ref);
25420
+ if (!href) {
25421
+ const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
25422
+ href = _optionalChain([cand, 'optionalAccess', _295 => _295.name]);
25423
+ }
25424
+ if (!href) continue;
25425
+ const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
25426
+ if (!f) continue;
25427
+ const bytes = await f.async("uint8array");
25428
+ if (bytes.length > maxImg) {
25429
+ warnings.push(`\uC774\uBBF8\uC9C0 ${href} ${(bytes.length / 1048576).toFixed(1)}MB \u2014 \uD55C\uB3C4 \uCD08\uACFC\uB85C \uC0DD\uB7B5`);
25430
+ continue;
25431
+ }
25432
+ images.set(ref, { dataUri: `data:${sniffMime(href, bytes)};base64,${Buffer.from(bytes).toString("base64")}` });
25433
+ }
25434
+ const doc = createXmlParser().parseFromString(secXml, "text/xml");
25435
+ const root = doc.documentElement;
25436
+ if (!root) throw new (0, _chunkZQOGTAT5cjs.KordocError)("\uC139\uC158 XML \uD30C\uC2F1 \uC2E4\uD328");
25437
+ const pagePr = findFirst(root, "pagePr");
25438
+ const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
25439
+ const PW = num(pagePr, "width", 59528), PH = num(pagePr, "height", 84188);
25440
+ const ML = num(margin, "left", 8504);
25441
+ const MT = num(margin, "top", 5668) + num(margin, "header", 0);
25442
+ const BODY_H = PH - MT - num(margin, "bottom", 4252) - num(margin, "footer", 0);
25443
+ const BODY_W = PW - ML - num(margin, "right", 8504);
25444
+ const ctx = {
25445
+ svg: [],
25446
+ geom: { PW, PH, ML, MT, BODY_W, BODY_H },
25447
+ styles,
25448
+ images,
25449
+ warnings,
25450
+ warned: /* @__PURE__ */ new Set(),
25451
+ stats: { texts: 0, images: 0, tables: 0 }
25452
+ };
25453
+ for (const p of elements(root)) {
25454
+ if (ln(p) !== "p") continue;
25455
+ const segs = findChildByLocalName(p, "linesegarray");
25456
+ const first = segs ? elements(segs)[0] : null;
25457
+ if (first && num(first, "vertpos") > BODY_H) continue;
25458
+ drawPara(p, ML, MT, BODY_W, ctx, 0);
25459
+ }
25460
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${pt(PW)} ${pt(PH)}" width="${pt(PW)}" height="${pt(PH)}" font-family="'HCR Batang','\uD568\uCD08\uB86C\uBC14\uD0D5','Hancom Batang',AppleMyungjo,'Noto Serif CJK KR',serif" xml:space="preserve">
25461
+ <rect width="100%" height="100%" fill="white"/>
25462
+ ${ctx.svg.join("\n")}
25463
+ </svg>`;
25464
+ return { svg, width: Math.round(PW) / 100, height: Math.round(PH) / 100, warnings, stats: ctx.stats };
25465
+ }
25466
+
24505
25467
  // src/index.ts
24506
25468
  async function parse(input, options) {
24507
25469
  let buffer;
24508
- const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _276 => _276.filePath]) ? { ...options, filePath: input } : options;
25470
+ const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _296 => _296.filePath]) ? { ...options, filePath: input } : options;
24509
25471
  if (typeof input === "string") {
24510
25472
  try {
24511
25473
  const buf = await _promises.readFile.call(void 0, input);
24512
- buffer = _chunkZ3O36LBJcjs.toArrayBuffer.call(void 0, buf);
25474
+ buffer = _chunkZQOGTAT5cjs.toArrayBuffer.call(void 0, buf);
24513
25475
  } catch (err) {
24514
25476
  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}`;
24515
25477
  return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
24516
25478
  }
24517
25479
  } else if (Buffer.isBuffer(input)) {
24518
- buffer = _chunkZ3O36LBJcjs.toArrayBuffer.call(void 0, input);
25480
+ buffer = _chunkZQOGTAT5cjs.toArrayBuffer.call(void 0, input);
24519
25481
  } else {
24520
25482
  buffer = input;
24521
25483
  }
@@ -24550,21 +25512,21 @@ async function parseHwp3(buffer, options) {
24550
25512
  const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
24551
25513
  return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
24552
25514
  } catch (err) {
24553
- return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err) };
25515
+ return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZQOGTAT5cjs.classifyError.call(void 0, err) };
24554
25516
  }
24555
25517
  }
24556
25518
  async function parseHwpx(buffer, options) {
24557
25519
  try {
24558
25520
  const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
24559
- return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _277 => _277.length]) ? images : void 0 };
25521
+ return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _297 => _297.length]) ? images : void 0 };
24560
25522
  } catch (err) {
24561
- return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err) };
25523
+ return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZQOGTAT5cjs.classifyError.call(void 0, err) };
24562
25524
  }
24563
25525
  }
24564
25526
  async function parseHwp(buffer, options) {
24565
25527
  try {
24566
25528
  const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
24567
- if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _278 => _278.filePath])) {
25529
+ if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _298 => _298.filePath])) {
24568
25530
  try {
24569
25531
  const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
24570
25532
  if (pages.some((p) => p && p.trim().length > 0)) {
@@ -24578,20 +25540,20 @@ async function parseHwp(buffer, options) {
24578
25540
  warnings: com.warnings
24579
25541
  };
24580
25542
  }
24581
- } catch (e31) {
25543
+ } catch (e32) {
24582
25544
  }
24583
25545
  }
24584
- return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _279 => _279.length]) ? images : void 0 };
25546
+ return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _299 => _299.length]) ? images : void 0 };
24585
25547
  } catch (err) {
24586
- return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err) };
25548
+ return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZQOGTAT5cjs.classifyError.call(void 0, err) };
24587
25549
  }
24588
25550
  }
24589
25551
  async function parsePdf(buffer, options) {
24590
25552
  let parsePdfDocument;
24591
25553
  try {
24592
- const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-ZVKCFXR3.cjs")));
25554
+ const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-6B7BUSX3.cjs")));
24593
25555
  parsePdfDocument = mod.parsePdfDocument;
24594
- } catch (e32) {
25556
+ } catch (e33) {
24595
25557
  return {
24596
25558
  success: false,
24597
25559
  fileType: "pdf",
@@ -24604,7 +25566,7 @@ async function parsePdf(buffer, options) {
24604
25566
  return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
24605
25567
  } catch (err) {
24606
25568
  const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
24607
- return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err), isImageBased };
25569
+ return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZQOGTAT5cjs.classifyError.call(void 0, err), isImageBased };
24608
25570
  }
24609
25571
  }
24610
25572
  async function parseXlsx(buffer, options) {
@@ -24612,7 +25574,7 @@ async function parseXlsx(buffer, options) {
24612
25574
  const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
24613
25575
  return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
24614
25576
  } catch (err) {
24615
- return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err) };
25577
+ return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZQOGTAT5cjs.classifyError.call(void 0, err) };
24616
25578
  }
24617
25579
  }
24618
25580
  async function parseXls(buffer, options) {
@@ -24620,15 +25582,15 @@ async function parseXls(buffer, options) {
24620
25582
  const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
24621
25583
  return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
24622
25584
  } catch (err) {
24623
- return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err) };
25585
+ return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZQOGTAT5cjs.classifyError.call(void 0, err) };
24624
25586
  }
24625
25587
  }
24626
25588
  async function parseDocx(buffer, options) {
24627
25589
  try {
24628
25590
  const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
24629
- return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _280 => _280.length]) ? images : void 0 };
25591
+ return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _300 => _300.length]) ? images : void 0 };
24630
25592
  } catch (err) {
24631
- return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err) };
25593
+ return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZQOGTAT5cjs.classifyError.call(void 0, err) };
24632
25594
  }
24633
25595
  }
24634
25596
  async function parseHwpml(buffer, options) {
@@ -24636,16 +25598,16 @@ async function parseHwpml(buffer, options) {
24636
25598
  const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
24637
25599
  return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
24638
25600
  } catch (err) {
24639
- return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZ3O36LBJcjs.classifyError.call(void 0, err) };
25601
+ return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkZQOGTAT5cjs.classifyError.call(void 0, err) };
24640
25602
  }
24641
25603
  }
24642
25604
  async function fillForm(input, values, outputFormat = "markdown") {
24643
25605
  let buffer;
24644
25606
  if (typeof input === "string") {
24645
25607
  const buf = await _promises.readFile.call(void 0, input);
24646
- buffer = _chunkZ3O36LBJcjs.toArrayBuffer.call(void 0, buf);
25608
+ buffer = _chunkZQOGTAT5cjs.toArrayBuffer.call(void 0, buf);
24647
25609
  } else if (Buffer.isBuffer(input)) {
24648
- buffer = _chunkZ3O36LBJcjs.toArrayBuffer.call(void 0, input);
25610
+ buffer = _chunkZQOGTAT5cjs.toArrayBuffer.call(void 0, input);
24649
25611
  } else {
24650
25612
  buffer = input;
24651
25613
  }
@@ -24671,7 +25633,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
24671
25633
  throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
24672
25634
  }
24673
25635
  const fill = fillFormFields(parsed.blocks, values);
24674
- const markdown = _chunkZ3O36LBJcjs.blocksToMarkdown.call(void 0, fill.blocks);
25636
+ const markdown = _chunkZQOGTAT5cjs.blocksToMarkdown.call(void 0, fill.blocks);
24675
25637
  if (outputFormat === "hwpx") {
24676
25638
  const hwpxBuffer = await markdownToHwpx(markdown);
24677
25639
  return { output: hwpxBuffer, format: "hwpx", fill };
@@ -24729,5 +25691,6 @@ async function fillForm(input, values, outputFormat = "markdown") {
24729
25691
 
24730
25692
 
24731
25693
 
24732
- exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkZ3O36LBJcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkZ3O36LBJcjs.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.fitRatioForFewerLines = fitRatioForFewerLines; 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.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord;
25694
+
25695
+ exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkZQOGTAT5cjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkZQOGTAT5cjs.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.fitRatioForFewerLines = fitRatioForFewerLines; 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;
24733
25696
  //# sourceMappingURL=index.cjs.map