kordoc 3.9.0 → 3.10.1

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 +27 -0
  2. package/dist/{-6CLKMLK2.js → -LPEXY73L.js} +18 -12
  3. package/dist/{chunk-VHXUD3PW.cjs → chunk-7UXZTZBJ.cjs} +2 -2
  4. package/dist/{chunk-VHXUD3PW.cjs.map → chunk-7UXZTZBJ.cjs.map} +1 -1
  5. package/dist/chunk-GFS4QWB6.js +124 -0
  6. package/dist/chunk-GFS4QWB6.js.map +1 -0
  7. package/dist/{chunk-EZ5GBTBE.js → chunk-I6CX2RK4.js} +2 -2
  8. package/dist/{chunk-EZ5GBTBE.js.map → chunk-I6CX2RK4.js.map} +1 -1
  9. package/dist/{chunk-ITPZD7XK.js → chunk-RMGYE4LT.js} +32 -313
  10. package/dist/chunk-RMGYE4LT.js.map +1 -0
  11. package/dist/chunk-UR34PYAC.js +938 -0
  12. package/dist/chunk-UR34PYAC.js.map +1 -0
  13. package/dist/{chunk-XKDA4FDM.js → chunk-YXEE3DEQ.js} +4 -120
  14. package/dist/chunk-YXEE3DEQ.js.map +1 -0
  15. package/dist/cli.js +33 -6
  16. package/dist/cli.js.map +1 -1
  17. package/dist/index.cjs +798 -174
  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 +680 -56
  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-NCNME2Z6.js → parser-664URIIW.js} +2 -2
  26. package/dist/{parser-N4G5KQBE.cjs → parser-AT22HMF5.cjs} +14 -14
  27. package/dist/{parser-N4G5KQBE.cjs.map → parser-AT22HMF5.cjs.map} +1 -1
  28. package/dist/{parser-LVI45MVF.js → parser-LJOS7VZM.js} +8 -6
  29. package/dist/{parser-LVI45MVF.js.map → parser-LJOS7VZM.js.map} +1 -1
  30. package/dist/render-XWOEGE3U.js +9 -0
  31. package/dist/render-XWOEGE3U.js.map +1 -0
  32. package/dist/{watch-XSLV62BH.js → watch-CZF6NA2V.js} +6 -4
  33. package/dist/{watch-XSLV62BH.js.map → watch-CZF6NA2V.js.map} +1 -1
  34. package/package.json +2 -2
  35. package/dist/chunk-ITPZD7XK.js.map +0 -1
  36. package/dist/chunk-XKDA4FDM.js.map +0 -1
  37. /package/dist/{-6CLKMLK2.js.map → -LPEXY73L.js.map} +0 -0
  38. /package/dist/{parser-NCNME2Z6.js.map → parser-664URIIW.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -19,7 +19,7 @@
19
19
 
20
20
 
21
21
 
22
- var _chunkVHXUD3PWcjs = require('./chunk-VHXUD3PW.cjs');
22
+ var _chunk7UXZTZBJcjs = require('./chunk-7UXZTZBJ.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, _chunkVHXUD3PWcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
408
+ if (level === "fatalError") throw new (0, _chunk7UXZTZBJcjs.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, _chunkVHXUD3PWcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
463
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk7UXZTZBJcjs.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(_chunkVHXUD3PWcjs.stripDtd.call(void 0, xml), "text/xml");
466
+ const doc = parser.parseFromString(_chunk7UXZTZBJcjs.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 >= _chunkVHXUD3PWcjs.HEADING_RATIO_H1) level = 1;
619
- else if (ratio >= _chunkVHXUD3PWcjs.HEADING_RATIO_H2) level = 2;
620
- else if (ratio >= _chunkVHXUD3PWcjs.HEADING_RATIO_H3) level = 3;
618
+ if (ratio >= _chunk7UXZTZBJcjs.HEADING_RATIO_H1) level = 1;
619
+ else if (ratio >= _chunk7UXZTZBJcjs.HEADING_RATIO_H2) level = 2;
620
+ else if (ratio >= _chunk7UXZTZBJcjs.HEADING_RATIO_H3) level = 3;
621
621
  }
622
622
  const compactText = text.replace(/\s+/g, "");
623
623
  if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
@@ -1171,7 +1171,7 @@ function resolveParaHeading(paraEl, ctx) {
1171
1171
 
1172
1172
  // src/hwpx/table-build.ts
1173
1173
  function buildTableWithCellMeta(state) {
1174
- const table = _chunkVHXUD3PWcjs.buildTable.call(void 0, state.rows);
1174
+ const table = _chunk7UXZTZBJcjs.buildTable.call(void 0, state.rows);
1175
1175
  if (state.caption) table.caption = state.caption;
1176
1176
  const anchors = [];
1177
1177
  {
@@ -1241,7 +1241,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1241
1241
  const cell = parentTable.cell;
1242
1242
  (cell.blocks ??= []).push(block);
1243
1243
  cell.hasStructure = true;
1244
- let flat = _chunkVHXUD3PWcjs.convertTableToText.call(void 0, newTable.rows);
1244
+ let flat = _chunk7UXZTZBJcjs.convertTableToText.call(void 0, newTable.rows);
1245
1245
  if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
1246
1246
  if (flat) cell.text += (cell.text ? "\n" : "") + flat;
1247
1247
  } else {
@@ -1253,7 +1253,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1253
1253
  // src/hwpx/section-walker.ts
1254
1254
  function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
1255
1255
  const parser = createXmlParser(warnings);
1256
- const doc = parser.parseFromString(_chunkVHXUD3PWcjs.stripDtd.call(void 0, xml), "text/xml");
1256
+ const doc = parser.parseFromString(_chunk7UXZTZBJcjs.stripDtd.call(void 0, xml), "text/xml");
1257
1257
  if (!doc.documentElement) return [];
1258
1258
  const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
1259
1259
  ctx.shared.track.deleteDepth = 0;
@@ -1344,8 +1344,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
1344
1344
  const cs = isNaN(rawCs) ? 1 : rawCs;
1345
1345
  const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
1346
1346
  const rs = isNaN(rawRs) ? 1 : rawRs;
1347
- tableCtx.cell.colSpan = clampSpan(cs, _chunkVHXUD3PWcjs.MAX_COLS);
1348
- tableCtx.cell.rowSpan = clampSpan(rs, _chunkVHXUD3PWcjs.MAX_ROWS);
1347
+ tableCtx.cell.colSpan = clampSpan(cs, _chunk7UXZTZBJcjs.MAX_COLS);
1348
+ tableCtx.cell.rowSpan = clampSpan(rs, _chunk7UXZTZBJcjs.MAX_ROWS);
1349
1349
  }
1350
1350
  break;
1351
1351
  case "p": {
@@ -1567,7 +1567,7 @@ function extractHyperlinkHref(fieldBegin) {
1567
1567
  let url = (ch.textContent || "").trim();
1568
1568
  if (!url) continue;
1569
1569
  url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
1570
- const safe = _chunkVHXUD3PWcjs.sanitizeHref.call(void 0, url);
1570
+ const safe = _chunk7UXZTZBJcjs.sanitizeHref.call(void 0, url);
1571
1571
  if (safe) return safe;
1572
1572
  }
1573
1573
  return void 0;
@@ -1702,7 +1702,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
1702
1702
  case "hyperlink": {
1703
1703
  const url = child.getAttribute("url") || child.getAttribute("href") || "";
1704
1704
  if (url) {
1705
- const safe = _chunkVHXUD3PWcjs.sanitizeHref.call(void 0, url);
1705
+ const safe = _chunk7UXZTZBJcjs.sanitizeHref.call(void 0, url);
1706
1706
  if (safe) href = safe;
1707
1707
  }
1708
1708
  walk(child);
@@ -1888,13 +1888,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
1888
1888
  }
1889
1889
  const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
1890
1890
  for (const path of allCandidates) {
1891
- if (_chunkVHXUD3PWcjs.isPathTraversal.call(void 0, path)) continue;
1891
+ if (_chunk7UXZTZBJcjs.isPathTraversal.call(void 0, path)) continue;
1892
1892
  const file = zip.file(path);
1893
1893
  if (!file) continue;
1894
1894
  try {
1895
1895
  const data = await file.async("uint8array");
1896
1896
  decompressed.total += data.length;
1897
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1897
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk7UXZTZBJcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1898
1898
  const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
1899
1899
  const mimeType = imageExtToMime(ext);
1900
1900
  imageIndex++;
@@ -1903,7 +1903,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
1903
1903
  images.push(img);
1904
1904
  break;
1905
1905
  } catch (err) {
1906
- if (err instanceof _chunkVHXUD3PWcjs.KordocError) throw err;
1906
+ if (err instanceof _chunk7UXZTZBJcjs.KordocError) throw err;
1907
1907
  }
1908
1908
  }
1909
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" })]);
@@ -1965,7 +1965,7 @@ function extractFromBrokenZip(buffer) {
1965
1965
  }
1966
1966
  const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
1967
1967
  const name = new TextDecoder().decode(nameBytes);
1968
- if (_chunkVHXUD3PWcjs.isPathTraversal.call(void 0, name)) {
1968
+ if (_chunk7UXZTZBJcjs.isPathTraversal.call(void 0, name)) {
1969
1969
  pos = fileStart + compSize;
1970
1970
  continue;
1971
1971
  }
@@ -1983,16 +1983,16 @@ function extractFromBrokenZip(buffer) {
1983
1983
  continue;
1984
1984
  }
1985
1985
  totalDecompressed += content.length * 2;
1986
- if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
1986
+ if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunk7UXZTZBJcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
1987
1987
  sectionNum++;
1988
1988
  blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
1989
1989
  } catch (e13) {
1990
1990
  continue;
1991
1991
  }
1992
1992
  }
1993
- if (blocks.length === 0) throw new (0, _chunkVHXUD3PWcjs.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, _chunk7UXZTZBJcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
1994
1994
  applyPageText(blocks, shared);
1995
- const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, blocks);
1995
+ const markdown = _chunk7UXZTZBJcjs.blocksToMarkdown.call(void 0, blocks);
1996
1996
  return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
1997
1997
  }
1998
1998
  async function resolveSectionPaths(zip) {
@@ -2006,18 +2006,18 @@ async function resolveSectionPaths(zip) {
2006
2006
  if (paths.length > 0) return paths;
2007
2007
  }
2008
2008
  const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
2009
- return sectionFiles.map((f) => f.name).sort(_chunkVHXUD3PWcjs.compareSectionPaths);
2009
+ return sectionFiles.map((f) => f.name).sort(_chunk7UXZTZBJcjs.compareSectionPaths);
2010
2010
  }
2011
2011
  function parseSectionPathsFromManifest(xml) {
2012
2012
  const parser = createXmlParser();
2013
- const doc = parser.parseFromString(_chunkVHXUD3PWcjs.stripDtd.call(void 0, xml), "text/xml");
2013
+ const doc = parser.parseFromString(_chunk7UXZTZBJcjs.stripDtd.call(void 0, xml), "text/xml");
2014
2014
  const items = doc.getElementsByTagName("opf:item");
2015
2015
  const spine = doc.getElementsByTagName("opf:itemref");
2016
2016
  const idToHref = /* @__PURE__ */ new Map();
2017
2017
  for (let i = 0; i < items.length; i++) {
2018
2018
  const item = items[i];
2019
2019
  const id = item.getAttribute("id") || "";
2020
- const href = _chunkVHXUD3PWcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
2020
+ const href = _chunk7UXZTZBJcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
2021
2021
  if (id && href) idToHref.set(id, href);
2022
2022
  }
2023
2023
  if (spine.length > 0) {
@@ -2028,7 +2028,7 @@ function parseSectionPathsFromManifest(xml) {
2028
2028
  }
2029
2029
  if (ordered.length > 0) return ordered;
2030
2030
  }
2031
- return Array.from(idToHref.values()).sort(_chunkVHXUD3PWcjs.compareSectionPaths);
2031
+ return Array.from(idToHref.values()).sort(_chunk7UXZTZBJcjs.compareSectionPaths);
2032
2032
  }
2033
2033
 
2034
2034
  // src/hwpx/metadata.ts
@@ -2041,7 +2041,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
2041
2041
  const xml = await file.async("text");
2042
2042
  if (decompressed) {
2043
2043
  decompressed.total += xml.length * 2;
2044
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2044
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk7UXZTZBJcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2045
2045
  }
2046
2046
  parseDublinCoreMetadata(xml, metadata);
2047
2047
  if (metadata.title || metadata.author) return;
@@ -2051,7 +2051,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
2051
2051
  }
2052
2052
  function parseDublinCoreMetadata(xml, metadata) {
2053
2053
  const parser = createXmlParser();
2054
- const doc = parser.parseFromString(_chunkVHXUD3PWcjs.stripDtd.call(void 0, xml), "text/xml");
2054
+ const doc = parser.parseFromString(_chunk7UXZTZBJcjs.stripDtd.call(void 0, xml), "text/xml");
2055
2055
  if (!doc.documentElement) return;
2056
2056
  const getText = (tagNames) => {
2057
2057
  for (const tag of tagNames) {
@@ -2076,7 +2076,7 @@ function parseDublinCoreMetadata(xml, metadata) {
2076
2076
 
2077
2077
  // src/hwpx/parser.ts
2078
2078
  async function parseHwpxDocument(buffer, options) {
2079
- _chunkVHXUD3PWcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
2079
+ _chunk7UXZTZBJcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
2080
2080
  let zip;
2081
2081
  try {
2082
2082
  zip = await _jszip2.default.loadAsync(buffer);
@@ -2085,7 +2085,7 @@ async function parseHwpxDocument(buffer, options) {
2085
2085
  }
2086
2086
  const actualEntryCount = Object.keys(zip.files).length;
2087
2087
  if (actualEntryCount > MAX_ZIP_ENTRIES) {
2088
- throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2088
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2089
2089
  }
2090
2090
  const manifestFile = zip.file("META-INF/manifest.xml");
2091
2091
  if (manifestFile) {
@@ -2097,7 +2097,7 @@ async function parseHwpxDocument(buffer, options) {
2097
2097
  return comResultToParseResult(pages, pageCount, warnings2);
2098
2098
  }
2099
2099
  }
2100
- throw new (0, _chunkVHXUD3PWcjs.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, _chunk7UXZTZBJcjs.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.");
2101
2101
  }
2102
2102
  }
2103
2103
  const decompressed = { total: 0 };
@@ -2106,7 +2106,7 @@ async function parseHwpxDocument(buffer, options) {
2106
2106
  const styleMap = await extractHwpxStyles(zip, decompressed);
2107
2107
  const warnings = [];
2108
2108
  const sectionPaths = await resolveSectionPaths(zip);
2109
- if (sectionPaths.length === 0) throw new (0, _chunkVHXUD3PWcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
2109
+ if (sectionPaths.length === 0) throw new (0, _chunk7UXZTZBJcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
2110
2110
  metadata.pageCount = sectionPaths.length;
2111
2111
  const pageFilter = _optionalChain([options, 'optionalAccess', _45 => _45.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
2112
2112
  const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
@@ -2120,12 +2120,12 @@ async function parseHwpxDocument(buffer, options) {
2120
2120
  try {
2121
2121
  const xml = await file.async("text");
2122
2122
  decompressed.total += xml.length * 2;
2123
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2123
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunk7UXZTZBJcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2124
2124
  blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
2125
2125
  parsedSections++;
2126
2126
  _optionalChain([options, 'optionalAccess', _46 => _46.onProgress, 'optionalCall', _47 => _47(parsedSections, totalTarget)]);
2127
2127
  } catch (secErr) {
2128
- if (secErr instanceof _chunkVHXUD3PWcjs.KordocError) throw secErr;
2128
+ if (secErr instanceof _chunk7UXZTZBJcjs.KordocError) throw secErr;
2129
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" });
2130
2130
  }
2131
2131
  }
@@ -2133,7 +2133,7 @@ async function parseHwpxDocument(buffer, options) {
2133
2133
  const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
2134
2134
  detectHwpxHeadings(blocks, styleMap);
2135
2135
  const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
2136
- const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, blocks);
2136
+ const markdown = _chunk7UXZTZBJcjs.blocksToMarkdown.call(void 0, blocks);
2137
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 };
2138
2138
  }
2139
2139
 
@@ -2200,7 +2200,7 @@ function decompressStream(data) {
2200
2200
  return _zlib.inflateRawSync.call(void 0, data, opts);
2201
2201
  }
2202
2202
  function parseFileHeader(data) {
2203
- if (data.length < 40) throw new (0, _chunkVHXUD3PWcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
2203
+ if (data.length < 40) throw new (0, _chunk7UXZTZBJcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
2204
2204
  const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
2205
2205
  return {
2206
2206
  signature: sig,
@@ -2508,11 +2508,11 @@ function formatRoman(n, upper) {
2508
2508
  const values = [1e3, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
2509
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"];
2510
2510
  let result = "";
2511
- let num = n;
2511
+ let num2 = n;
2512
2512
  for (let i = 0; i < values.length; i++) {
2513
- while (num >= values[i]) {
2513
+ while (num2 >= values[i]) {
2514
2514
  result += symbols[i];
2515
- num -= values[i];
2515
+ num2 -= values[i];
2516
2516
  }
2517
2517
  }
2518
2518
  return result;
@@ -2520,11 +2520,11 @@ function formatRoman(n, upper) {
2520
2520
  function formatLatin(n, upper) {
2521
2521
  if (n <= 0) return "";
2522
2522
  let result = "";
2523
- let num = n;
2524
- while (num > 0) {
2525
- num--;
2526
- result = String.fromCharCode((upper ? 65 : 97) + num % 26) + result;
2527
- 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);
2528
2528
  }
2529
2529
  return result;
2530
2530
  }
@@ -2532,15 +2532,15 @@ function formatEastAsianNumber(n, digits, units, zero) {
2532
2532
  if (n === 0) return zero;
2533
2533
  if (n < 0 || n > 99999) return String(n);
2534
2534
  let result = "";
2535
- let num = n;
2535
+ let num2 = n;
2536
2536
  let unit = 0;
2537
- while (num > 0) {
2538
- const d = num % 10;
2537
+ while (num2 > 0) {
2538
+ const d = num2 % 10;
2539
2539
  if (d > 0) {
2540
2540
  const digitStr = d === 1 && unit > 0 ? "" : digits[d];
2541
2541
  result = digitStr + units[unit] + result;
2542
2542
  }
2543
- num = Math.floor(num / 10);
2543
+ num2 = Math.floor(num2 / 10);
2544
2544
  unit++;
2545
2545
  }
2546
2546
  return result;
@@ -2587,8 +2587,8 @@ function expandNumberingFormat(formatStr, counters, numbering) {
2587
2587
  const idx = levelRef - 1;
2588
2588
  const counterVal = _nullishCoalesce(counters[idx], () => ( 0));
2589
2589
  const start = _nullishCoalesce(numbering.startNumbers[idx], () => ( 1));
2590
- const num = counterVal > 0 ? start - 1 + counterVal : start;
2591
- 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))));
2592
2592
  i += 2;
2593
2593
  continue;
2594
2594
  }
@@ -3734,7 +3734,7 @@ function parseHwp5Document(buffer, options) {
3734
3734
  lenientCfb = parseLenientCfb(buffer);
3735
3735
  warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
3736
3736
  } catch (e21) {
3737
- throw new (0, _chunkVHXUD3PWcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
3737
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
3738
3738
  }
3739
3739
  }
3740
3740
  const findStream = (path) => {
@@ -3745,11 +3745,11 @@ function parseHwp5Document(buffer, options) {
3745
3745
  return lenientCfb.findStream(path);
3746
3746
  };
3747
3747
  const headerData = findStream("/FileHeader");
3748
- if (!headerData) throw new (0, _chunkVHXUD3PWcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
3748
+ if (!headerData) throw new (0, _chunk7UXZTZBJcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
3749
3749
  const header = parseFileHeader(headerData);
3750
- if (header.signature !== "HWP Document File") throw new (0, _chunkVHXUD3PWcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
3751
- if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3752
- if (header.flags & FLAG_DRM) throw new (0, _chunkVHXUD3PWcjs.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, _chunk7UXZTZBJcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
3751
+ if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunk7UXZTZBJcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3752
+ if (header.flags & FLAG_DRM) throw new (0, _chunk7UXZTZBJcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3753
3753
  const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
3754
3754
  const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
3755
3755
  const metadata = {
@@ -3758,7 +3758,7 @@ function parseHwp5Document(buffer, options) {
3758
3758
  if (cfb) extractHwp5Metadata(cfb, metadata);
3759
3759
  const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
3760
3760
  const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
3761
- if (sections.length === 0) throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3761
+ if (sections.length === 0) throw new (0, _chunk7UXZTZBJcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3762
3762
  metadata.pageCount = sections.length;
3763
3763
  const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
3764
3764
  const totalTarget = pageFilter ? pageFilter.size : sections.length;
@@ -3772,25 +3772,25 @@ function parseHwp5Document(buffer, options) {
3772
3772
  const sectionData = sections[si];
3773
3773
  const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
3774
3774
  totalDecompressed += data.length;
3775
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3775
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk7UXZTZBJcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3776
3776
  const records = readRecords(data);
3777
3777
  const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
3778
3778
  bodyBlocks.push(...sectionBlocks);
3779
3779
  parsedSections++;
3780
3780
  _optionalChain([options, 'optionalAccess', _52 => _52.onProgress, 'optionalCall', _53 => _53(parsedSections, totalTarget)]);
3781
3781
  } catch (secErr) {
3782
- if (secErr instanceof _chunkVHXUD3PWcjs.KordocError) throw secErr;
3782
+ if (secErr instanceof _chunk7UXZTZBJcjs.KordocError) throw secErr;
3783
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" });
3784
3784
  }
3785
3785
  }
3786
3786
  const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
3787
3787
  const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
3788
- const flatBlocks = _chunkVHXUD3PWcjs.flattenLayoutTables.call(void 0, blocks);
3788
+ const flatBlocks = _chunk7UXZTZBJcjs.flattenLayoutTables.call(void 0, blocks);
3789
3789
  if (docInfo) {
3790
3790
  detectHwp5Headings(flatBlocks, docInfo);
3791
3791
  }
3792
3792
  const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
3793
- const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, flatBlocks);
3793
+ const markdown = _chunk7UXZTZBJcjs.blocksToMarkdown.call(void 0, flatBlocks);
3794
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 };
3795
3795
  }
3796
3796
  function parseDocInfoStream(cfb, compressed) {
@@ -3850,9 +3850,9 @@ function detectHwp5Headings(blocks, docInfo) {
3850
3850
  let level = 0;
3851
3851
  if (_optionalChain([block, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]) && baseFontSize > 0) {
3852
3852
  const ratio = block.style.fontSize / baseFontSize;
3853
- if (ratio >= _chunkVHXUD3PWcjs.HEADING_RATIO_H1) level = 1;
3854
- else if (ratio >= _chunkVHXUD3PWcjs.HEADING_RATIO_H2) level = 2;
3855
- else if (ratio >= _chunkVHXUD3PWcjs.HEADING_RATIO_H3) level = 3;
3853
+ if (ratio >= _chunk7UXZTZBJcjs.HEADING_RATIO_H1) level = 1;
3854
+ else if (ratio >= _chunk7UXZTZBJcjs.HEADING_RATIO_H2) level = 2;
3855
+ else if (ratio >= _chunk7UXZTZBJcjs.HEADING_RATIO_H3) level = 3;
3856
3856
  }
3857
3857
  if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
3858
3858
  if (level === 0) level = 2;
@@ -3937,7 +3937,7 @@ function findSectionsLenient(lcfb, compressed) {
3937
3937
  if (!raw) break;
3938
3938
  const content = compressed ? decompressStream(raw) : raw;
3939
3939
  totalDecompressed += content.length;
3940
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3940
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk7UXZTZBJcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3941
3941
  sections.push({ idx: i, content });
3942
3942
  }
3943
3943
  if (sections.length === 0) {
@@ -3949,7 +3949,7 @@ function findSectionsLenient(lcfb, compressed) {
3949
3949
  if (raw) {
3950
3950
  const content = compressed ? decompressStream(raw) : raw;
3951
3951
  totalDecompressed += content.length;
3952
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3952
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk7UXZTZBJcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3953
3953
  sections.push({ idx, content });
3954
3954
  }
3955
3955
  }
@@ -3966,7 +3966,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
3966
3966
  try {
3967
3967
  const content = decryptViewText(raw, compressed);
3968
3968
  totalDecompressed += content.length;
3969
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3969
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunk7UXZTZBJcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3970
3970
  sections.push({ idx: i, content });
3971
3971
  } catch (e26) {
3972
3972
  break;
@@ -4069,7 +4069,7 @@ function parseParagraph(records, start, end, ctx) {
4069
4069
  const ctrl = ctrls[r.ctrlIdx];
4070
4070
  if (!_optionalChain([ctrl, 'optionalAccess', _66 => _66.href]) || r.end <= r.start) continue;
4071
4071
  if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
4072
- const href = _chunkVHXUD3PWcjs.sanitizeHref.call(void 0, ctrl.href);
4072
+ const href = _chunk7UXZTZBJcjs.sanitizeHref.call(void 0, ctrl.href);
4073
4073
  if (!href) continue;
4074
4074
  const anchor = text.slice(r.start, r.end);
4075
4075
  if (!anchor.trim()) continue;
@@ -4156,11 +4156,11 @@ function applyCtrlEffect(ctrl, records, ctx) {
4156
4156
  const attr = ctrl.data.readUInt32LE(4);
4157
4157
  const type = attr & 15;
4158
4158
  const format = attr >>> 4 & 255;
4159
- const num = _nullishCoalesce(ctx.doc.autoCounters.get(type), () => ( 1));
4160
- 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);
4161
4161
  const prefix = ctrl.data.length >= 14 ? wcharAt(ctrl.data, 12) : "";
4162
4162
  const suffix = ctrl.data.length >= 16 ? wcharAt(ctrl.data, 14) : "";
4163
- ctrl.inlineText = `${prefix}${formatNumber(num, shapeFormatToNumFmt(format))}${suffix}`;
4163
+ ctrl.inlineText = `${prefix}${formatNumber(num2, shapeFormatToNumFmt(format))}${suffix}`;
4164
4164
  }
4165
4165
  return;
4166
4166
  }
@@ -4168,8 +4168,8 @@ function applyCtrlEffect(ctrl, records, ctx) {
4168
4168
  if (ctrl.data.length >= 10) {
4169
4169
  const attr = ctrl.data.readUInt32LE(4);
4170
4170
  const type = attr & 15;
4171
- const num = ctrl.data.readUInt16LE(8);
4172
- 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);
4173
4173
  }
4174
4174
  return;
4175
4175
  }
@@ -4231,7 +4231,7 @@ function blocksPlainText(blocks, sep) {
4231
4231
  return parts.join(sep).trim();
4232
4232
  }
4233
4233
  function applyNoteEffect(ctrl, records, ctx, autoType) {
4234
- const num = _nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1));
4234
+ const num2 = _nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1));
4235
4235
  let before = "";
4236
4236
  let after = "";
4237
4237
  let shape = 0;
@@ -4242,11 +4242,11 @@ function applyNoteEffect(ctrl, records, ctx, autoType) {
4242
4242
  if (ctrl.data.length >= 16) {
4243
4243
  shape = ctrl.data.readUInt32LE(12) & 255;
4244
4244
  }
4245
- const formatted = formatNumber(num, shapeFormatToNumFmt(shape));
4245
+ const formatted = formatNumber(num2, shapeFormatToNumFmt(shape));
4246
4246
  const marker = before || after ? `${before}${formatted}${after}` : `${formatted})`;
4247
4247
  const content = blocksPlainText(parseListHeaderParagraphs(ctrl, records, ctx), " ");
4248
- if ((_nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1))) <= num) {
4249
- 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);
4250
4250
  }
4251
4251
  ctrl.inlineText = marker;
4252
4252
  if (content) ctrl.footnote = content.startsWith(marker) ? content : `${marker} ${content}`;
@@ -4302,8 +4302,8 @@ function parseTableControl(ctrl, records, ctx) {
4302
4302
  let tableIdx = -1;
4303
4303
  for (let i2 = childStart; i2 < childEnd; i2++) {
4304
4304
  if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
4305
- rows = Math.min(records[i2].data.readUInt16LE(4), _chunkVHXUD3PWcjs.MAX_ROWS);
4306
- cols = Math.min(records[i2].data.readUInt16LE(6), _chunkVHXUD3PWcjs.MAX_COLS);
4305
+ rows = Math.min(records[i2].data.readUInt16LE(4), _chunk7UXZTZBJcjs.MAX_ROWS);
4306
+ cols = Math.min(records[i2].data.readUInt16LE(6), _chunk7UXZTZBJcjs.MAX_COLS);
4307
4307
  tableIdx = i2;
4308
4308
  break;
4309
4309
  }
@@ -4352,7 +4352,7 @@ function parseTableControl(ctrl, records, ctx) {
4352
4352
  return table2;
4353
4353
  }
4354
4354
  const cellRows = arrangeCells(rows, cols, cells);
4355
- const table = _chunkVHXUD3PWcjs.buildTable.call(void 0, cellRows);
4355
+ const table = _chunk7UXZTZBJcjs.buildTable.call(void 0, cellRows);
4356
4356
  if (caption && table.rows > 0) table.caption = caption;
4357
4357
  return table.rows > 0 ? table : null;
4358
4358
  }
@@ -4369,8 +4369,8 @@ function parseCell(records, lhIdx, end, ctx) {
4369
4369
  rowAddr = rec.data.readUInt16LE(10);
4370
4370
  const cs = rec.data.readUInt16LE(12);
4371
4371
  const rs = rec.data.readUInt16LE(14);
4372
- if (cs > 0) colSpan = Math.min(cs, _chunkVHXUD3PWcjs.MAX_COLS);
4373
- if (rs > 0) rowSpan = Math.min(rs, _chunkVHXUD3PWcjs.MAX_ROWS);
4372
+ if (cs > 0) colSpan = Math.min(cs, _chunk7UXZTZBJcjs.MAX_COLS);
4373
+ if (rs > 0) rowSpan = Math.min(rs, _chunk7UXZTZBJcjs.MAX_ROWS);
4374
4374
  }
4375
4375
  const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
4376
4376
  const parts = [];
@@ -4380,7 +4380,7 @@ function parseCell(records, lhIdx, end, ctx) {
4380
4380
  parts.push(`![image](hwp5bin:${b.text})`);
4381
4381
  hasStructure = true;
4382
4382
  } else if (b.type === "table" && b.table) {
4383
- const flat = _chunkVHXUD3PWcjs.convertTableToText.call(void 0, b.table.cells);
4383
+ const flat = _chunk7UXZTZBJcjs.convertTableToText.call(void 0, b.table.cells);
4384
4384
  if (flat) parts.push(flat);
4385
4385
  hasStructure = true;
4386
4386
  } else if (b.text) {
@@ -16784,9 +16784,9 @@ var MAX_ROWS2 = 1e4;
16784
16784
  var MAX_COLS2 = 200;
16785
16785
  function cleanNumericValue(raw) {
16786
16786
  if (!/^-?\d+\.\d+$/.test(raw)) return raw;
16787
- const num = parseFloat(raw);
16788
- if (!isFinite(num)) return raw;
16789
- 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();
16790
16790
  return cleaned;
16791
16791
  }
16792
16792
  function parseCellRef(ref) {
@@ -16817,7 +16817,7 @@ function getTextContent(el) {
16817
16817
  return _nullishCoalesce(_optionalChain([el, 'access', _81 => _81.textContent, 'optionalAccess', _82 => _82.trim, 'call', _83 => _83()]), () => ( ""));
16818
16818
  }
16819
16819
  function parseXml(text) {
16820
- return new (0, _xmldom.DOMParser)().parseFromString(_chunkVHXUD3PWcjs.stripDtd.call(void 0, text), "text/xml");
16820
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunk7UXZTZBJcjs.stripDtd.call(void 0, text), "text/xml");
16821
16821
  }
16822
16822
  function parseSharedStrings(xml) {
16823
16823
  const doc = parseXml(xml);
@@ -16961,7 +16961,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
16961
16961
  cellRows.push(row);
16962
16962
  }
16963
16963
  if (cellRows.length > 0) {
16964
- const table = _chunkVHXUD3PWcjs.buildTable.call(void 0, cellRows);
16964
+ const table = _chunk7UXZTZBJcjs.buildTable.call(void 0, cellRows);
16965
16965
  if (table.rows > 0) {
16966
16966
  blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
16967
16967
  }
@@ -16969,12 +16969,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
16969
16969
  return blocks;
16970
16970
  }
16971
16971
  async function parseXlsxDocument(buffer, options) {
16972
- _chunkVHXUD3PWcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
16972
+ _chunk7UXZTZBJcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
16973
16973
  const zip = await _jszip2.default.loadAsync(buffer);
16974
16974
  const warnings = [];
16975
16975
  const workbookFile = zip.file("xl/workbook.xml");
16976
16976
  if (!workbookFile) {
16977
- throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
16977
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
16978
16978
  }
16979
16979
  let sharedStrings = [];
16980
16980
  const ssFile = zip.file("xl/sharedStrings.xml");
@@ -16983,7 +16983,7 @@ async function parseXlsxDocument(buffer, options) {
16983
16983
  }
16984
16984
  const sheets = parseWorkbook(await workbookFile.async("text"));
16985
16985
  if (sheets.length === 0) {
16986
- throw new (0, _chunkVHXUD3PWcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
16986
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
16987
16987
  }
16988
16988
  let relsMap = /* @__PURE__ */ new Map();
16989
16989
  const relsFile = zip.file("xl/_rels/workbook.xml.rels");
@@ -17055,7 +17055,7 @@ async function parseXlsxDocument(buffer, options) {
17055
17055
  } catch (e27) {
17056
17056
  }
17057
17057
  }
17058
- const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, blocks);
17058
+ const markdown = _chunk7UXZTZBJcjs.blocksToMarkdown.call(void 0, blocks);
17059
17059
  return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
17060
17060
  }
17061
17061
 
@@ -17129,17 +17129,17 @@ function decodeRk(rk) {
17129
17129
  const fDiv100 = (rk & 1) !== 0;
17130
17130
  const fInt = (rk & 2) !== 0;
17131
17131
  const val30 = rk >> 2;
17132
- let num;
17132
+ let num2;
17133
17133
  if (fInt) {
17134
- num = val30;
17134
+ num2 = val30;
17135
17135
  } else {
17136
17136
  const high32 = (rk & 4294967292) >>> 0;
17137
17137
  const buf = Buffer.alloc(8);
17138
17138
  buf.writeUInt32LE(0, 0);
17139
17139
  buf.writeUInt32LE(high32, 4);
17140
- num = buf.readDoubleLE(0);
17140
+ num2 = buf.readDoubleLE(0);
17141
17141
  }
17142
- return fDiv100 ? num / 100 : num;
17142
+ return fDiv100 ? num2 / 100 : num2;
17143
17143
  }
17144
17144
  function decodeMulRk(data) {
17145
17145
  if (data.length < 6) return null;
@@ -17462,11 +17462,11 @@ function processGlobals(records) {
17462
17462
  let encrypted = false;
17463
17463
  const firstBof = records[0];
17464
17464
  if (!firstBof || firstBof.opcode !== OP_BOF) {
17465
- throw new (0, _chunkVHXUD3PWcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
17465
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
17466
17466
  }
17467
17467
  const bof = decodeBof(firstBof.data);
17468
17468
  if (!bof || bof.dt !== DT_GLOBALS) {
17469
- throw new (0, _chunkVHXUD3PWcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
17469
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
17470
17470
  }
17471
17471
  let i = 1;
17472
17472
  while (i < records.length) {
@@ -17581,7 +17581,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
17581
17581
  cellRows.push(row);
17582
17582
  }
17583
17583
  if (cellRows.length > 0) {
17584
- const table = _chunkVHXUD3PWcjs.buildTable.call(void 0, cellRows);
17584
+ const table = _chunk7UXZTZBJcjs.buildTable.call(void 0, cellRows);
17585
17585
  if (table.rows > 0) {
17586
17586
  blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
17587
17587
  }
@@ -17594,21 +17594,21 @@ async function parseXlsDocument(buffer, options) {
17594
17594
  try {
17595
17595
  cfb = parseLenientCfb(buf);
17596
17596
  } catch (e) {
17597
- throw new (0, _chunkVHXUD3PWcjs.KordocError)(
17597
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)(
17598
17598
  `XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
17599
17599
  );
17600
17600
  }
17601
17601
  const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
17602
17602
  if (!wb) {
17603
- throw new (0, _chunkVHXUD3PWcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
17603
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
17604
17604
  }
17605
17605
  const records = readRecords2(wb);
17606
17606
  if (records.length === 0) {
17607
- throw new (0, _chunkVHXUD3PWcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
17607
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
17608
17608
  }
17609
17609
  const firstBof = decodeBof(records[0].data);
17610
17610
  if (firstBof && firstBof.vers !== 1536) {
17611
- throw new (0, _chunkVHXUD3PWcjs.KordocError)(
17611
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)(
17612
17612
  `XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
17613
17613
  );
17614
17614
  }
@@ -17668,7 +17668,7 @@ async function parseXlsDocument(buffer, options) {
17668
17668
  pageCount: totalSheets
17669
17669
  };
17670
17670
  return {
17671
- markdown: _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, allBlocks),
17671
+ markdown: _chunk7UXZTZBJcjs.blocksToMarkdown.call(void 0, allBlocks),
17672
17672
  blocks: allBlocks,
17673
17673
  metadata,
17674
17674
  warnings: warnings.length > 0 ? warnings : void 0
@@ -17839,9 +17839,9 @@ function nodeToLatex(el) {
17839
17839
  case "f": {
17840
17840
  const n = firstKid(el, "num");
17841
17841
  const d = firstKid(el, "den");
17842
- const num = n ? childrenToLatex(n) : "";
17842
+ const num2 = n ? childrenToLatex(n) : "";
17843
17843
  const den = d ? childrenToLatex(d) : "";
17844
- return "\\frac" + grp(num) + grp(den);
17844
+ return "\\frac" + grp(num2) + grp(den);
17845
17845
  }
17846
17846
  // 첨자
17847
17847
  case "sSup": {
@@ -18106,7 +18106,7 @@ function getAttr(el, localName2) {
18106
18106
  return null;
18107
18107
  }
18108
18108
  function parseXml2(text) {
18109
- return new (0, _xmldom.DOMParser)().parseFromString(_chunkVHXUD3PWcjs.stripDtd.call(void 0, text), "text/xml");
18109
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunk7UXZTZBJcjs.stripDtd.call(void 0, text), "text/xml");
18110
18110
  }
18111
18111
  function parseStyles(xml) {
18112
18112
  const doc = parseXml2(xml);
@@ -18367,7 +18367,7 @@ function parseTable(tbl, styles, numbering, footnotes, rels) {
18367
18367
  return { text: cell.text, colSpan: cell.colSpan, rowSpan, colAddr: cell.col, rowAddr: r };
18368
18368
  })
18369
18369
  );
18370
- const table = _chunkVHXUD3PWcjs.buildTable.call(void 0, cellRows);
18370
+ const table = _chunk7UXZTZBJcjs.buildTable.call(void 0, cellRows);
18371
18371
  if (table.rows === 0 || table.cols === 0) return null;
18372
18372
  return { type: "table", table };
18373
18373
  }
@@ -18434,12 +18434,12 @@ async function extractImages(zip, rels, doc, warnings) {
18434
18434
  return { blocks, images };
18435
18435
  }
18436
18436
  async function parseDocxDocument(buffer, options) {
18437
- _chunkVHXUD3PWcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
18437
+ _chunk7UXZTZBJcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
18438
18438
  const zip = await _jszip2.default.loadAsync(buffer);
18439
18439
  const warnings = [];
18440
18440
  const docFile = zip.file("word/document.xml");
18441
18441
  if (!docFile) {
18442
- throw new (0, _chunkVHXUD3PWcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
18442
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
18443
18443
  }
18444
18444
  let rels = /* @__PURE__ */ new Map();
18445
18445
  const relsFile = zip.file("word/_rels/document.xml.rels");
@@ -18486,7 +18486,7 @@ async function parseDocxDocument(buffer, options) {
18486
18486
  const doc = parseXml2(docXml);
18487
18487
  const body = findElements(doc, "body");
18488
18488
  if (body.length === 0) {
18489
- throw new (0, _chunkVHXUD3PWcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
18489
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
18490
18490
  }
18491
18491
  const blocks = [];
18492
18492
  const bodyEl = body[0];
@@ -18531,7 +18531,7 @@ async function parseDocxDocument(buffer, options) {
18531
18531
  }
18532
18532
  }
18533
18533
  const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
18534
- const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, blocks);
18534
+ const markdown = _chunk7UXZTZBJcjs.blocksToMarkdown.call(void 0, blocks);
18535
18535
  return {
18536
18536
  markdown,
18537
18537
  blocks,
@@ -18554,7 +18554,7 @@ function parseHwpmlDocument(buffer, options) {
18554
18554
  }
18555
18555
  const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
18556
18556
  const normalized = text.replace(/&nbsp;/g, "&#160;");
18557
- const xml = _chunkVHXUD3PWcjs.stripDtd.call(void 0, normalized);
18557
+ const xml = _chunk7UXZTZBJcjs.stripDtd.call(void 0, normalized);
18558
18558
  const warnings = [];
18559
18559
  const parser = new (0, _xmldom.DOMParser)({
18560
18560
  onError: (_level, msg2) => {
@@ -18594,7 +18594,7 @@ function parseHwpmlDocument(buffer, options) {
18594
18594
  parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
18595
18595
  }
18596
18596
  const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
18597
- const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, blocks);
18597
+ const markdown = _chunk7UXZTZBJcjs.blocksToMarkdown.call(void 0, blocks);
18598
18598
  return {
18599
18599
  markdown,
18600
18600
  blocks,
@@ -18752,7 +18752,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
18752
18752
  const cellRows = grid.map(
18753
18753
  (row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
18754
18754
  );
18755
- const table = _chunkVHXUD3PWcjs.buildTable.call(void 0, cellRows);
18755
+ const table = _chunk7UXZTZBJcjs.buildTable.call(void 0, cellRows);
18756
18756
  blocks.push({ type: "table", table, pageNumber: sectionNum });
18757
18757
  }
18758
18758
  function extractCellText(cellEl) {
@@ -19941,19 +19941,19 @@ function parseCentralDirectory(buf) {
19941
19941
  }
19942
19942
  }
19943
19943
  }
19944
- if (eocdOffset < 0) throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19944
+ if (eocdOffset < 0) throw new (0, _chunk7UXZTZBJcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19945
19945
  const totalEntries = view.getUint16(eocdOffset + 10, true);
19946
19946
  const cdSize = view.getUint32(eocdOffset + 12, true);
19947
19947
  const cdOffset = view.getUint32(eocdOffset + 16, true);
19948
- if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19948
+ if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunk7UXZTZBJcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19949
19949
  if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
19950
- throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19950
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19951
19951
  }
19952
19952
  const decoder = new TextDecoder("utf-8");
19953
19953
  const entries = [];
19954
19954
  let pos = cdOffset;
19955
19955
  for (let i = 0; i < totalEntries; i++) {
19956
- if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
19956
+ if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunk7UXZTZBJcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
19957
19957
  const flags = view.getUint16(pos + 8, true);
19958
19958
  const method = view.getUint16(pos + 10, true);
19959
19959
  const crc = view.getUint32(pos + 16, true);
@@ -19964,7 +19964,7 @@ function parseCentralDirectory(buf) {
19964
19964
  const commentLen = view.getUint16(pos + 32, true);
19965
19965
  const localOffset = view.getUint32(pos + 42, true);
19966
19966
  if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
19967
- throw new (0, _chunkVHXUD3PWcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19967
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19968
19968
  }
19969
19969
  const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
19970
19970
  const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
@@ -19993,7 +19993,7 @@ function patchZipEntries(original, replacements) {
19993
19993
  const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
19994
19994
  const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
19995
19995
  for (const name of replacements.keys()) {
19996
- if (!entries.some((e) => e.name === name)) throw new (0, _chunkVHXUD3PWcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
19996
+ if (!entries.some((e) => e.name === name)) throw new (0, _chunk7UXZTZBJcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
19997
19997
  }
19998
19998
  const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
19999
19999
  const segments = [];
@@ -20011,7 +20011,7 @@ function patchZipEntries(original, replacements) {
20011
20011
  offset += seg.length;
20012
20012
  continue;
20013
20013
  }
20014
- if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkVHXUD3PWcjs.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, _chunk7UXZTZBJcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
20015
20015
  const nameLen = view.getUint16(e.localOffset + 26, true);
20016
20016
  const extraLen = view.getUint16(e.localOffset + 28, true);
20017
20017
  const headerLen = 30 + nameLen + extraLen;
@@ -20066,7 +20066,7 @@ async function fillHwpx(hwpxBuffer, values) {
20066
20066
  const zip = await _jszip2.default.loadAsync(hwpxBuffer);
20067
20067
  const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
20068
20068
  if (sectionPaths.length === 0) {
20069
- throw new (0, _chunkVHXUD3PWcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
20069
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
20070
20070
  }
20071
20071
  const normalizedValues = normalizeValues(values);
20072
20072
  const cursor = new ValueCursor(normalizedValues);
@@ -20482,10 +20482,10 @@ function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "kee
20482
20482
  const spacing = _nullishCoalesce(_optionalChain([opts, 'optionalAccess', _158 => _158.spacingPct]), () => ( 0));
20483
20483
  const k = height * ratioPct / 100 / 1e3;
20484
20484
  const cwCp = (cp) => (cp === 32 ? spaceEm : charWidthEm1000(cp)) * (1 + spacing / 100) * k;
20485
- const charW = (ch) => cwCp(ch.codePointAt(0));
20485
+ const charW2 = (ch) => cwCp(ch.codePointAt(0));
20486
20486
  const rangeW = (from, to) => {
20487
20487
  let w = 0;
20488
- for (const ch of text.slice(from, to)) w += charW(ch);
20488
+ for (const ch of text.slice(from, to)) w += charW2(ch);
20489
20489
  return w;
20490
20490
  };
20491
20491
  const units = _nullishCoalesce(text.match(mode === "keep" ? / +|[^ ]+/g : / +|[^ ]/g), () => ( []));
@@ -20506,7 +20506,7 @@ function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "kee
20506
20506
  };
20507
20507
  for (const u of units) {
20508
20508
  if (u[0] === " ") {
20509
- lineW += charW(" ") * u.length;
20509
+ lineW += charW2(" ") * u.length;
20510
20510
  pos += u.length;
20511
20511
  continue;
20512
20512
  }
@@ -20519,7 +20519,7 @@ function simulateWrap(text, firstWidth, contWidth, height, ratioPct, mode = "kee
20519
20519
  if (lineW === 0 || w > contWidth + EPS) {
20520
20520
  let sub = 0;
20521
20521
  for (const ch of u) {
20522
- const c = charW(ch);
20522
+ const c = charW2(ch);
20523
20523
  if (lineW + c > avail + EPS && lineW > 0) breakBefore(pos + sub, 0);
20524
20524
  lineW += c;
20525
20525
  sub += ch.length;
@@ -21437,7 +21437,7 @@ function escapeGfm(text) {
21437
21437
  }
21438
21438
  var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
21439
21439
  function sanitizeText(text) {
21440
- let result = _chunkVHXUD3PWcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
21440
+ let result = _chunk7UXZTZBJcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
21441
21441
  if (result.length <= 30 && result.includes(" ")) {
21442
21442
  const tokens = result.split(" ");
21443
21443
  const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-힯ㄱ-ㆎ]/.test(t)).length;
@@ -21923,9 +21923,9 @@ function readCommand(input, idx, depth) {
21923
21923
  const command = name.value;
21924
21924
  if (command === "\\") return { value: "#", next: name.next };
21925
21925
  if (command === "frac") {
21926
- const num = readGroupOrToken(input, name.next, depth);
21927
- const den = readGroupOrToken(input, num.next, depth);
21928
- return { value: `{${num.value}} over {${den.value}}`, next: den.next };
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
21929
  }
21930
21930
  if (command === "sqrt") {
21931
21931
  let cursor = skipSpaces(input, name.next);
@@ -22942,7 +22942,7 @@ async function resolveSectionEntryNames(zip) {
22942
22942
  const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
22943
22943
  if (paths.length > 0) return paths;
22944
22944
  }
22945
- return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkVHXUD3PWcjs.compareSectionPaths);
22945
+ return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunk7UXZTZBJcjs.compareSectionPaths);
22946
22946
  }
22947
22947
  function sectionPathsFromManifest(xml) {
22948
22948
  const attr = (tag, name) => {
@@ -22952,7 +22952,7 @@ function sectionPathsFromManifest(xml) {
22952
22952
  const idToHref = /* @__PURE__ */ new Map();
22953
22953
  for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
22954
22954
  const id = attr(m[1], "id");
22955
- const href = _chunkVHXUD3PWcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
22955
+ const href = _chunk7UXZTZBJcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
22956
22956
  if (id && href) idToHref.set(id, href);
22957
22957
  }
22958
22958
  const ordered = [];
@@ -22961,7 +22961,7 @@ function sectionPathsFromManifest(xml) {
22961
22961
  if (href) ordered.push(href);
22962
22962
  }
22963
22963
  if (ordered.length > 0) return ordered;
22964
- return Array.from(idToHref.values()).sort(_chunkVHXUD3PWcjs.compareSectionPaths);
22964
+ return Array.from(idToHref.values()).sort(_chunk7UXZTZBJcjs.compareSectionPaths);
22965
22965
  }
22966
22966
 
22967
22967
  // src/roundtrip/patcher.ts
@@ -23072,9 +23072,9 @@ function buildOrigUnits(blocks) {
23072
23072
  if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
23073
23073
  const next = blocks[i + 1];
23074
23074
  if (_optionalChain([next, 'optionalAccess', _217 => _217.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
23075
- chunk = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
23075
+ chunk = _chunk7UXZTZBJcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
23076
23076
  } else {
23077
- chunk = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, [block]);
23077
+ chunk = _chunk7UXZTZBJcjs.blocksToMarkdown.call(void 0, [block]);
23078
23078
  }
23079
23079
  if (chunk) {
23080
23080
  const subUnits = splitMarkdownUnits(chunk);
@@ -24772,13 +24772,13 @@ async function htmlToPdf(html, options) {
24772
24772
  try {
24773
24773
  puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
24774
24774
  } catch (e30) {
24775
- throw new (0, _chunkVHXUD3PWcjs.KordocError)(
24775
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)(
24776
24776
  "PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
24777
24777
  );
24778
24778
  }
24779
24779
  const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
24780
24780
  if (!executablePath) {
24781
- throw new (0, _chunkVHXUD3PWcjs.KordocError)(
24781
+ throw new (0, _chunk7UXZTZBJcjs.KordocError)(
24782
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."
24783
24783
  );
24784
24784
  }
@@ -24837,24 +24837,647 @@ async function markdownToPdf(markdown, options) {
24837
24837
  return htmlToPdf(html, options);
24838
24838
  }
24839
24839
  async function blocksToPdf(blocks, options) {
24840
- const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, blocks);
24840
+ const markdown = _chunk7UXZTZBJcjs.blocksToMarkdown.call(void 0, blocks);
24841
24841
  return markdownToPdf(markdown, options);
24842
24842
  }
24843
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, _chunk7UXZTZBJcjs.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, _chunk7UXZTZBJcjs.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, _chunk7UXZTZBJcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
25401
+ if (!secXml.includes("linesegarray")) {
25402
+ throw new (0, _chunk7UXZTZBJcjs.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, _chunk7UXZTZBJcjs.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)}pt" height="${pt(PH)}pt" 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
+
24844
25467
  // src/index.ts
24845
25468
  async function parse(input, options) {
24846
25469
  let buffer;
24847
- 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;
24848
25471
  if (typeof input === "string") {
24849
25472
  try {
24850
25473
  const buf = await _promises.readFile.call(void 0, input);
24851
- buffer = _chunkVHXUD3PWcjs.toArrayBuffer.call(void 0, buf);
25474
+ buffer = _chunk7UXZTZBJcjs.toArrayBuffer.call(void 0, buf);
24852
25475
  } catch (err) {
24853
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}`;
24854
25477
  return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
24855
25478
  }
24856
25479
  } else if (Buffer.isBuffer(input)) {
24857
- buffer = _chunkVHXUD3PWcjs.toArrayBuffer.call(void 0, input);
25480
+ buffer = _chunk7UXZTZBJcjs.toArrayBuffer.call(void 0, input);
24858
25481
  } else {
24859
25482
  buffer = input;
24860
25483
  }
@@ -24889,21 +25512,21 @@ async function parseHwp3(buffer, options) {
24889
25512
  const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
24890
25513
  return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
24891
25514
  } catch (err) {
24892
- return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err) };
25515
+ return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunk7UXZTZBJcjs.classifyError.call(void 0, err) };
24893
25516
  }
24894
25517
  }
24895
25518
  async function parseHwpx(buffer, options) {
24896
25519
  try {
24897
25520
  const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
24898
- 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 };
24899
25522
  } catch (err) {
24900
- return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err) };
25523
+ return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk7UXZTZBJcjs.classifyError.call(void 0, err) };
24901
25524
  }
24902
25525
  }
24903
25526
  async function parseHwp(buffer, options) {
24904
25527
  try {
24905
25528
  const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
24906
- if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _278 => _278.filePath])) {
25529
+ if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _298 => _298.filePath])) {
24907
25530
  try {
24908
25531
  const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
24909
25532
  if (pages.some((p) => p && p.trim().length > 0)) {
@@ -24917,20 +25540,20 @@ async function parseHwp(buffer, options) {
24917
25540
  warnings: com.warnings
24918
25541
  };
24919
25542
  }
24920
- } catch (e31) {
25543
+ } catch (e32) {
24921
25544
  }
24922
25545
  }
24923
- 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 };
24924
25547
  } catch (err) {
24925
- return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err) };
25548
+ return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunk7UXZTZBJcjs.classifyError.call(void 0, err) };
24926
25549
  }
24927
25550
  }
24928
25551
  async function parsePdf(buffer, options) {
24929
25552
  let parsePdfDocument;
24930
25553
  try {
24931
- const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-N4G5KQBE.cjs")));
25554
+ const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-AT22HMF5.cjs")));
24932
25555
  parsePdfDocument = mod.parsePdfDocument;
24933
- } catch (e32) {
25556
+ } catch (e33) {
24934
25557
  return {
24935
25558
  success: false,
24936
25559
  fileType: "pdf",
@@ -24943,7 +25566,7 @@ async function parsePdf(buffer, options) {
24943
25566
  return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
24944
25567
  } catch (err) {
24945
25568
  const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
24946
- return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err), isImageBased };
25569
+ return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunk7UXZTZBJcjs.classifyError.call(void 0, err), isImageBased };
24947
25570
  }
24948
25571
  }
24949
25572
  async function parseXlsx(buffer, options) {
@@ -24951,7 +25574,7 @@ async function parseXlsx(buffer, options) {
24951
25574
  const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
24952
25575
  return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
24953
25576
  } catch (err) {
24954
- return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err) };
25577
+ return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk7UXZTZBJcjs.classifyError.call(void 0, err) };
24955
25578
  }
24956
25579
  }
24957
25580
  async function parseXls(buffer, options) {
@@ -24959,15 +25582,15 @@ async function parseXls(buffer, options) {
24959
25582
  const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
24960
25583
  return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
24961
25584
  } catch (err) {
24962
- return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err) };
25585
+ return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunk7UXZTZBJcjs.classifyError.call(void 0, err) };
24963
25586
  }
24964
25587
  }
24965
25588
  async function parseDocx(buffer, options) {
24966
25589
  try {
24967
25590
  const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
24968
- 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 };
24969
25592
  } catch (err) {
24970
- return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err) };
25593
+ return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunk7UXZTZBJcjs.classifyError.call(void 0, err) };
24971
25594
  }
24972
25595
  }
24973
25596
  async function parseHwpml(buffer, options) {
@@ -24975,16 +25598,16 @@ async function parseHwpml(buffer, options) {
24975
25598
  const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
24976
25599
  return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
24977
25600
  } catch (err) {
24978
- return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkVHXUD3PWcjs.classifyError.call(void 0, err) };
25601
+ return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunk7UXZTZBJcjs.classifyError.call(void 0, err) };
24979
25602
  }
24980
25603
  }
24981
25604
  async function fillForm(input, values, outputFormat = "markdown") {
24982
25605
  let buffer;
24983
25606
  if (typeof input === "string") {
24984
25607
  const buf = await _promises.readFile.call(void 0, input);
24985
- buffer = _chunkVHXUD3PWcjs.toArrayBuffer.call(void 0, buf);
25608
+ buffer = _chunk7UXZTZBJcjs.toArrayBuffer.call(void 0, buf);
24986
25609
  } else if (Buffer.isBuffer(input)) {
24987
- buffer = _chunkVHXUD3PWcjs.toArrayBuffer.call(void 0, input);
25610
+ buffer = _chunk7UXZTZBJcjs.toArrayBuffer.call(void 0, input);
24988
25611
  } else {
24989
25612
  buffer = input;
24990
25613
  }
@@ -25010,7 +25633,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
25010
25633
  throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
25011
25634
  }
25012
25635
  const fill = fillFormFields(parsed.blocks, values);
25013
- const markdown = _chunkVHXUD3PWcjs.blocksToMarkdown.call(void 0, fill.blocks);
25636
+ const markdown = _chunk7UXZTZBJcjs.blocksToMarkdown.call(void 0, fill.blocks);
25014
25637
  if (outputFormat === "hwpx") {
25015
25638
  const hwpxBuffer = await markdownToHwpx(markdown);
25016
25639
  return { output: hwpxBuffer, format: "hwpx", fill };
@@ -25068,5 +25691,6 @@ async function fillForm(input, values, outputFormat = "markdown") {
25068
25691
 
25069
25692
 
25070
25693
 
25071
- exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkVHXUD3PWcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkVHXUD3PWcjs.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 = _chunk7UXZTZBJcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunk7UXZTZBJcjs.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;
25072
25696
  //# sourceMappingURL=index.cjs.map