kordoc 3.13.0 → 3.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.md +34 -1
  2. package/dist/{-MRPDPE2X.js → -H7N62NZU.js} +24 -13
  3. package/dist/{chunk-33CIKNL4.js → chunk-5RHRQ7HK.js} +479 -258
  4. package/dist/chunk-5RHRQ7HK.js.map +1 -0
  5. package/dist/{chunk-MEXUFQVC.cjs → chunk-BIP4JAVG.cjs} +5 -5
  6. package/dist/chunk-BIP4JAVG.cjs.map +1 -0
  7. package/dist/chunk-DCZVOIEO.cjs.map +1 -1
  8. package/dist/chunk-FGL7BH4P.js +1019 -0
  9. package/dist/chunk-FGL7BH4P.js.map +1 -0
  10. package/dist/chunk-GS7T56RP.cjs.map +1 -1
  11. package/dist/{chunk-Q6UXVJXI.js → chunk-IC56KHBL.js} +2 -2
  12. package/dist/chunk-JFNWJFKP.js +185 -0
  13. package/dist/chunk-JFNWJFKP.js.map +1 -0
  14. package/dist/{chunk-YXOT7P5B.js → chunk-LYL4IL3E.js} +5 -5
  15. package/dist/{chunk-YXOT7P5B.js.map → chunk-LYL4IL3E.js.map} +1 -1
  16. package/dist/{chunk-O4WFPOFN.js → chunk-Q7EGGW3H.js} +5 -5
  17. package/dist/{chunk-O4WFPOFN.js.map → chunk-Q7EGGW3H.js.map} +1 -1
  18. package/dist/{chunk-TWACKS3K.js → chunk-WD5NUUU6.js} +571 -729
  19. package/dist/chunk-WD5NUUU6.js.map +1 -0
  20. package/dist/cli.js +125 -12
  21. package/dist/cli.js.map +1 -1
  22. package/dist/formula-5NKVS2LR.cjs.map +1 -1
  23. package/dist/index.cjs +1668 -449
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +144 -6
  26. package/dist/index.d.ts +144 -6
  27. package/dist/index.js +1502 -283
  28. package/dist/index.js.map +1 -1
  29. package/dist/mcp.js +93 -12
  30. package/dist/mcp.js.map +1 -1
  31. package/dist/page-range-P7SDW6LR.cjs.map +1 -1
  32. package/dist/{parser-Z3IL2ESY.js → parser-5G247XYD.js} +54 -6
  33. package/dist/parser-5G247XYD.js.map +1 -0
  34. package/dist/{parser-DZBI3EA2.cjs → parser-6V7F3GET.cjs} +66 -18
  35. package/dist/parser-6V7F3GET.cjs.map +1 -0
  36. package/dist/{parser-XUNGOH76.js → parser-HBHCD7TE.js} +55 -7
  37. package/dist/parser-HBHCD7TE.js.map +1 -0
  38. package/dist/provider-G4C2V2PD.cjs.map +1 -1
  39. package/dist/render-VA4NHROW.js +10 -0
  40. package/dist/seal-UVDRGHEF.js +10 -0
  41. package/dist/seal-UVDRGHEF.js.map +1 -0
  42. package/dist/{watch-G5NFIT5L.js → watch-HIYNOSFD.js} +7 -5
  43. package/dist/{watch-G5NFIT5L.js.map → watch-HIYNOSFD.js.map} +1 -1
  44. package/package.json +4 -3
  45. package/dist/chunk-33CIKNL4.js.map +0 -1
  46. package/dist/chunk-MEXUFQVC.cjs.map +0 -1
  47. package/dist/chunk-TWACKS3K.js.map +0 -1
  48. package/dist/parser-DZBI3EA2.cjs.map +0 -1
  49. package/dist/parser-XUNGOH76.js.map +0 -1
  50. package/dist/parser-Z3IL2ESY.js.map +0 -1
  51. package/dist/render-VZ4OGHZU.js +0 -9
  52. /package/dist/{-MRPDPE2X.js.map → -H7N62NZU.js.map} +0 -0
  53. /package/dist/{chunk-Q6UXVJXI.js.map → chunk-IC56KHBL.js.map} +0 -0
  54. /package/dist/{render-VZ4OGHZU.js.map → render-VA4NHROW.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -19,7 +19,7 @@
19
19
 
20
20
 
21
21
 
22
- var _chunkMEXUFQVCcjs = require('./chunk-MEXUFQVC.cjs');
22
+ var _chunkBIP4JAVGcjs = require('./chunk-BIP4JAVG.cjs');
23
23
 
24
24
 
25
25
  var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
@@ -405,7 +405,7 @@ function createSectionShared() {
405
405
  function createXmlParser(warnings) {
406
406
  return new (0, _xmldom.DOMParser)({
407
407
  onError(level, msg2) {
408
- if (level === "fatalError") throw new (0, _chunkMEXUFQVCcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
408
+ if (level === "fatalError") throw new (0, _chunkBIP4JAVGcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
409
409
  _optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warn" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
410
410
  }
411
411
  });
@@ -460,10 +460,10 @@ async function extractHwpxStyles(zip, decompressed) {
460
460
  const xml = await file.async("text");
461
461
  if (decompressed) {
462
462
  decompressed.total += xml.length * 2;
463
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
463
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
464
464
  }
465
465
  const parser = createXmlParser();
466
- const doc = parser.parseFromString(_chunkMEXUFQVCcjs.stripDtd.call(void 0, xml), "text/xml");
466
+ const doc = parser.parseFromString(_chunkBIP4JAVGcjs.stripDtd.call(void 0, xml), "text/xml");
467
467
  if (!doc.documentElement) continue;
468
468
  parseCharProperties(doc, result.charProperties);
469
469
  parseStyleElements(doc, result.styles);
@@ -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 elements2 = doc.getElementsByTagName(tagName);
485
- for (let i = 0; i < elements2.length; i++) {
486
- const el = elements2[i];
484
+ const elements3 = doc.getElementsByTagName(tagName);
485
+ for (let i = 0; i < elements3.length; i++) {
486
+ const el = elements3[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 elements2 = doc.getElementsByTagName(tagName);
521
- for (let i = 0; i < elements2.length; i++) {
522
- const el = elements2[i];
520
+ const elements3 = doc.getElementsByTagName(tagName);
521
+ for (let i = 0; i < elements3.length; i++) {
522
+ const el = elements3[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 elements2 = doc.getElementsByTagName(tagName);
535
- for (let i = 0; i < elements2.length; i++) {
536
- const el = elements2[i];
534
+ const elements3 = doc.getElementsByTagName(tagName);
535
+ for (let i = 0; i < elements3.length; i++) {
536
+ const el = elements3[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 elements2 = doc.getElementsByTagName(tagName);
564
- for (let i = 0; i < elements2.length; i++) {
565
- const el = elements2[i];
563
+ const elements3 = doc.getElementsByTagName(tagName);
564
+ for (let i = 0; i < elements3.length; i++) {
565
+ const el = elements3[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 elements2 = doc.getElementsByTagName(tagName);
577
- for (let i = 0; i < elements2.length; i++) {
578
- const el = elements2[i];
576
+ const elements3 = doc.getElementsByTagName(tagName);
577
+ for (let i = 0; i < elements3.length; i++) {
578
+ const el = elements3[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 >= _chunkMEXUFQVCcjs.HEADING_RATIO_H1) level = 1;
619
- else if (ratio >= _chunkMEXUFQVCcjs.HEADING_RATIO_H2) level = 2;
620
- else if (ratio >= _chunkMEXUFQVCcjs.HEADING_RATIO_H3) level = 3;
618
+ if (ratio >= _chunkBIP4JAVGcjs.HEADING_RATIO_H1) level = 1;
619
+ else if (ratio >= _chunkBIP4JAVGcjs.HEADING_RATIO_H2) level = 2;
620
+ else if (ratio >= _chunkBIP4JAVGcjs.HEADING_RATIO_H3) level = 3;
621
621
  }
622
622
  const compactText = text.replace(/\s+/g, "");
623
623
  if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
@@ -923,10 +923,22 @@ function findEnclosingBrackets(eqString, startIdx) {
923
923
  }
924
924
  return null;
925
925
  }
926
+ function maskLiteralSpans(eqString) {
927
+ return eqString.replace(/"[^"]*"/g, (m) => "\uFFFF".repeat(m.length)).replace(/\\text\{[^}]*\}/g, (m) => "\uFFFF".repeat(m.length));
928
+ }
929
+ function findKeywordToken(eqString, word, from = 0) {
930
+ const masked = maskLiteralSpans(eqString);
931
+ for (let i = masked.indexOf(word, from); i !== -1; i = masked.indexOf(word, i + 1)) {
932
+ const okL = i === 0 || masked[i - 1] === " ";
933
+ const okR = i + word.length === masked.length || masked[i + word.length] === " ";
934
+ if (okL && okR) return i;
935
+ }
936
+ return -1;
937
+ }
926
938
  function replaceFrac(eqString) {
927
939
  const hmlFrac = "over";
928
940
  while (true) {
929
- const cursor = eqString.indexOf(hmlFrac);
941
+ const cursor = findKeywordToken(eqString, hmlFrac);
930
942
  if (cursor === -1) break;
931
943
  try {
932
944
  const [numStart, numEnd] = findBrackets(eqString, cursor, 0);
@@ -942,12 +954,12 @@ function replaceFrac(eqString) {
942
954
  }
943
955
  function replaceRootOf(eqString) {
944
956
  while (true) {
945
- const rootCursor = eqString.indexOf("root");
957
+ const rootCursor = findKeywordToken(eqString, "root");
946
958
  if (rootCursor === -1) break;
947
959
  try {
948
- const ofCursor = eqString.indexOf("of");
949
- if (ofCursor === -1) return eqString;
950
960
  const elem1 = findBrackets(eqString, rootCursor, 1);
961
+ const ofCursor = findKeywordToken(eqString, "of", elem1[1]);
962
+ if (ofCursor === -1) return eqString;
951
963
  const elem2 = findBrackets(eqString, ofCursor, 1);
952
964
  const e1 = eqString.slice(elem1[0] + 1, elem1[1] - 1);
953
965
  const e2 = eqString.slice(elem2[0] + 1, elem2[1] - 1);
@@ -1171,7 +1183,7 @@ function resolveParaHeading(paraEl, ctx) {
1171
1183
 
1172
1184
  // src/hwpx/table-build.ts
1173
1185
  function buildTableWithCellMeta(state) {
1174
- const table = _chunkMEXUFQVCcjs.buildTable.call(void 0, state.rows);
1186
+ const table = _chunkBIP4JAVGcjs.buildTable.call(void 0, state.rows);
1175
1187
  if (state.caption) table.caption = state.caption;
1176
1188
  const anchors = [];
1177
1189
  {
@@ -1241,7 +1253,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1241
1253
  const cell = parentTable.cell;
1242
1254
  (cell.blocks ??= []).push(block);
1243
1255
  cell.hasStructure = true;
1244
- let flat = _chunkMEXUFQVCcjs.convertTableToText.call(void 0, newTable.rows);
1256
+ let flat = _chunkBIP4JAVGcjs.convertTableToText.call(void 0, newTable.rows);
1245
1257
  if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
1246
1258
  if (flat) cell.text += (cell.text ? "\n" : "") + flat;
1247
1259
  } else {
@@ -1253,7 +1265,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1253
1265
  // src/hwpx/section-walker.ts
1254
1266
  function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
1255
1267
  const parser = createXmlParser(warnings);
1256
- const doc = parser.parseFromString(_chunkMEXUFQVCcjs.stripDtd.call(void 0, xml), "text/xml");
1268
+ const doc = parser.parseFromString(_chunkBIP4JAVGcjs.stripDtd.call(void 0, xml), "text/xml");
1257
1269
  if (!doc.documentElement) return [];
1258
1270
  const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
1259
1271
  ctx.shared.track.deleteDepth = 0;
@@ -1344,8 +1356,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
1344
1356
  const cs = isNaN(rawCs) ? 1 : rawCs;
1345
1357
  const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
1346
1358
  const rs = isNaN(rawRs) ? 1 : rawRs;
1347
- tableCtx.cell.colSpan = clampSpan(cs, _chunkMEXUFQVCcjs.MAX_COLS);
1348
- tableCtx.cell.rowSpan = clampSpan(rs, _chunkMEXUFQVCcjs.MAX_ROWS);
1359
+ tableCtx.cell.colSpan = clampSpan(cs, _chunkBIP4JAVGcjs.MAX_COLS);
1360
+ tableCtx.cell.rowSpan = clampSpan(rs, _chunkBIP4JAVGcjs.MAX_ROWS);
1349
1361
  }
1350
1362
  break;
1351
1363
  case "p": {
@@ -1567,7 +1579,7 @@ function extractHyperlinkHref(fieldBegin) {
1567
1579
  let url = (ch.textContent || "").trim();
1568
1580
  if (!url) continue;
1569
1581
  url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
1570
- const safe = _chunkMEXUFQVCcjs.sanitizeHref.call(void 0, url);
1582
+ const safe = _chunkBIP4JAVGcjs.sanitizeHref.call(void 0, url);
1571
1583
  if (safe) return safe;
1572
1584
  }
1573
1585
  return void 0;
@@ -1702,7 +1714,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
1702
1714
  case "hyperlink": {
1703
1715
  const url = child.getAttribute("url") || child.getAttribute("href") || "";
1704
1716
  if (url) {
1705
- const safe = _chunkMEXUFQVCcjs.sanitizeHref.call(void 0, url);
1717
+ const safe = _chunkBIP4JAVGcjs.sanitizeHref.call(void 0, url);
1706
1718
  if (safe) href = safe;
1707
1719
  }
1708
1720
  walk(child);
@@ -1888,13 +1900,13 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
1888
1900
  }
1889
1901
  const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
1890
1902
  for (const path of allCandidates) {
1891
- if (_chunkMEXUFQVCcjs.isPathTraversal.call(void 0, path)) continue;
1903
+ if (_chunkBIP4JAVGcjs.isPathTraversal.call(void 0, path)) continue;
1892
1904
  const file = zip.file(path);
1893
1905
  if (!file) continue;
1894
1906
  try {
1895
1907
  const data = await file.async("uint8array");
1896
1908
  decompressed.total += data.length;
1897
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1909
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1898
1910
  const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
1899
1911
  const mimeType = imageExtToMime(ext);
1900
1912
  imageIndex++;
@@ -1903,7 +1915,7 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
1903
1915
  images.push(img);
1904
1916
  break;
1905
1917
  } catch (err) {
1906
- if (err instanceof _chunkMEXUFQVCcjs.KordocError) throw err;
1918
+ if (err instanceof _chunkBIP4JAVGcjs.KordocError) throw err;
1907
1919
  }
1908
1920
  }
1909
1921
  if (!img) _optionalChain([warnings, 'optionalAccess', _38 => _38.push, 'call', _39 => _39({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
@@ -1965,7 +1977,7 @@ function extractFromBrokenZip(buffer) {
1965
1977
  }
1966
1978
  const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
1967
1979
  const name = new TextDecoder().decode(nameBytes);
1968
- if (_chunkMEXUFQVCcjs.isPathTraversal.call(void 0, name)) {
1980
+ if (_chunkBIP4JAVGcjs.isPathTraversal.call(void 0, name)) {
1969
1981
  pos = fileStart + compSize;
1970
1982
  continue;
1971
1983
  }
@@ -1983,16 +1995,16 @@ function extractFromBrokenZip(buffer) {
1983
1995
  continue;
1984
1996
  }
1985
1997
  totalDecompressed += content.length * 2;
1986
- if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
1998
+ if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
1987
1999
  sectionNum++;
1988
2000
  blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
1989
2001
  } catch (e13) {
1990
2002
  continue;
1991
2003
  }
1992
2004
  }
1993
- if (blocks.length === 0) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
2005
+ if (blocks.length === 0) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
1994
2006
  applyPageText(blocks, shared);
1995
- const markdown = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, blocks);
2007
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, blocks);
1996
2008
  return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
1997
2009
  }
1998
2010
  async function resolveSectionPaths(zip) {
@@ -2006,18 +2018,18 @@ async function resolveSectionPaths(zip) {
2006
2018
  if (paths.length > 0) return paths;
2007
2019
  }
2008
2020
  const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
2009
- return sectionFiles.map((f) => f.name).sort(_chunkMEXUFQVCcjs.compareSectionPaths);
2021
+ return sectionFiles.map((f) => f.name).sort(_chunkBIP4JAVGcjs.compareSectionPaths);
2010
2022
  }
2011
2023
  function parseSectionPathsFromManifest(xml) {
2012
2024
  const parser = createXmlParser();
2013
- const doc = parser.parseFromString(_chunkMEXUFQVCcjs.stripDtd.call(void 0, xml), "text/xml");
2025
+ const doc = parser.parseFromString(_chunkBIP4JAVGcjs.stripDtd.call(void 0, xml), "text/xml");
2014
2026
  const items = doc.getElementsByTagName("opf:item");
2015
2027
  const spine = doc.getElementsByTagName("opf:itemref");
2016
2028
  const idToHref = /* @__PURE__ */ new Map();
2017
2029
  for (let i = 0; i < items.length; i++) {
2018
2030
  const item = items[i];
2019
2031
  const id = item.getAttribute("id") || "";
2020
- const href = _chunkMEXUFQVCcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
2032
+ const href = _chunkBIP4JAVGcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
2021
2033
  if (id && href) idToHref.set(id, href);
2022
2034
  }
2023
2035
  if (spine.length > 0) {
@@ -2028,7 +2040,7 @@ function parseSectionPathsFromManifest(xml) {
2028
2040
  }
2029
2041
  if (ordered.length > 0) return ordered;
2030
2042
  }
2031
- return Array.from(idToHref.values()).sort(_chunkMEXUFQVCcjs.compareSectionPaths);
2043
+ return Array.from(idToHref.values()).sort(_chunkBIP4JAVGcjs.compareSectionPaths);
2032
2044
  }
2033
2045
 
2034
2046
  // src/hwpx/metadata.ts
@@ -2041,7 +2053,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
2041
2053
  const xml = await file.async("text");
2042
2054
  if (decompressed) {
2043
2055
  decompressed.total += xml.length * 2;
2044
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2056
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2045
2057
  }
2046
2058
  parseDublinCoreMetadata(xml, metadata);
2047
2059
  if (metadata.title || metadata.author) return;
@@ -2051,7 +2063,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
2051
2063
  }
2052
2064
  function parseDublinCoreMetadata(xml, metadata) {
2053
2065
  const parser = createXmlParser();
2054
- const doc = parser.parseFromString(_chunkMEXUFQVCcjs.stripDtd.call(void 0, xml), "text/xml");
2066
+ const doc = parser.parseFromString(_chunkBIP4JAVGcjs.stripDtd.call(void 0, xml), "text/xml");
2055
2067
  if (!doc.documentElement) return;
2056
2068
  const getText = (tagNames) => {
2057
2069
  for (const tag of tagNames) {
@@ -2076,7 +2088,7 @@ function parseDublinCoreMetadata(xml, metadata) {
2076
2088
 
2077
2089
  // src/hwpx/parser.ts
2078
2090
  async function parseHwpxDocument(buffer, options) {
2079
- _chunkMEXUFQVCcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
2091
+ _chunkBIP4JAVGcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
2080
2092
  let zip;
2081
2093
  try {
2082
2094
  zip = await _jszip2.default.loadAsync(buffer);
@@ -2085,7 +2097,7 @@ async function parseHwpxDocument(buffer, options) {
2085
2097
  }
2086
2098
  const actualEntryCount = Object.keys(zip.files).length;
2087
2099
  if (actualEntryCount > MAX_ZIP_ENTRIES) {
2088
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2100
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2089
2101
  }
2090
2102
  const manifestFile = zip.file("META-INF/manifest.xml");
2091
2103
  if (manifestFile) {
@@ -2097,7 +2109,7 @@ async function parseHwpxDocument(buffer, options) {
2097
2109
  return comResultToParseResult(pages, pageCount, warnings2);
2098
2110
  }
2099
2111
  }
2100
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
2112
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("DRM \uC554\uD638\uD654\uB41C HWPX \uD30C\uC77C\uC785\uB2C8\uB2E4. Windows + \uD55C\uCEF4 \uC624\uD53C\uC2A4 \uC124\uCE58 \uC2DC \uC790\uB3D9 \uCD94\uCD9C\uB429\uB2C8\uB2E4.");
2101
2113
  }
2102
2114
  }
2103
2115
  const decompressed = { total: 0 };
@@ -2106,7 +2118,7 @@ async function parseHwpxDocument(buffer, options) {
2106
2118
  const styleMap = await extractHwpxStyles(zip, decompressed);
2107
2119
  const warnings = [];
2108
2120
  const sectionPaths = await resolveSectionPaths(zip);
2109
- if (sectionPaths.length === 0) throw new (0, _chunkMEXUFQVCcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
2121
+ if (sectionPaths.length === 0) throw new (0, _chunkBIP4JAVGcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
2110
2122
  metadata.pageCount = sectionPaths.length;
2111
2123
  const pageFilter = _optionalChain([options, 'optionalAccess', _45 => _45.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
2112
2124
  const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
@@ -2120,12 +2132,12 @@ async function parseHwpxDocument(buffer, options) {
2120
2132
  try {
2121
2133
  const xml = await file.async("text");
2122
2134
  decompressed.total += xml.length * 2;
2123
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2135
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
2124
2136
  blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
2125
2137
  parsedSections++;
2126
2138
  _optionalChain([options, 'optionalAccess', _46 => _46.onProgress, 'optionalCall', _47 => _47(parsedSections, totalTarget)]);
2127
2139
  } catch (secErr) {
2128
- if (secErr instanceof _chunkMEXUFQVCcjs.KordocError) throw secErr;
2140
+ if (secErr instanceof _chunkBIP4JAVGcjs.KordocError) throw secErr;
2129
2141
  warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
2130
2142
  }
2131
2143
  }
@@ -2133,7 +2145,7 @@ async function parseHwpxDocument(buffer, options) {
2133
2145
  const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
2134
2146
  detectHwpxHeadings(blocks, styleMap);
2135
2147
  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 = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, blocks);
2148
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, blocks);
2137
2149
  return { markdown, blocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
2138
2150
  }
2139
2151
 
@@ -2200,7 +2212,7 @@ function decompressStream(data) {
2200
2212
  return _zlib.inflateRawSync.call(void 0, data, opts);
2201
2213
  }
2202
2214
  function parseFileHeader(data) {
2203
- if (data.length < 40) throw new (0, _chunkMEXUFQVCcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
2215
+ if (data.length < 40) throw new (0, _chunkBIP4JAVGcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
2204
2216
  const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
2205
2217
  return {
2206
2218
  signature: sig,
@@ -2352,7 +2364,6 @@ function appendParaText(state, data, resolveControl) {
2352
2364
  break;
2353
2365
  }
2354
2366
  result += "\n";
2355
- if (i + 14 <= data.length) i += 14;
2356
2367
  break;
2357
2368
  }
2358
2369
  case CHAR_PARA:
@@ -2508,11 +2519,11 @@ function formatRoman(n, upper) {
2508
2519
  const values = [1e3, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1];
2509
2520
  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
2521
  let result = "";
2511
- let num2 = n;
2522
+ let num3 = n;
2512
2523
  for (let i = 0; i < values.length; i++) {
2513
- while (num2 >= values[i]) {
2524
+ while (num3 >= values[i]) {
2514
2525
  result += symbols[i];
2515
- num2 -= values[i];
2526
+ num3 -= values[i];
2516
2527
  }
2517
2528
  }
2518
2529
  return result;
@@ -2520,11 +2531,11 @@ function formatRoman(n, upper) {
2520
2531
  function formatLatin(n, upper) {
2521
2532
  if (n <= 0) return "";
2522
2533
  let result = "";
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);
2534
+ let num3 = n;
2535
+ while (num3 > 0) {
2536
+ num3--;
2537
+ result = String.fromCharCode((upper ? 65 : 97) + num3 % 26) + result;
2538
+ num3 = Math.floor(num3 / 26);
2528
2539
  }
2529
2540
  return result;
2530
2541
  }
@@ -2532,15 +2543,15 @@ function formatEastAsianNumber(n, digits, units, zero) {
2532
2543
  if (n === 0) return zero;
2533
2544
  if (n < 0 || n > 99999) return String(n);
2534
2545
  let result = "";
2535
- let num2 = n;
2546
+ let num3 = n;
2536
2547
  let unit = 0;
2537
- while (num2 > 0) {
2538
- const d = num2 % 10;
2548
+ while (num3 > 0) {
2549
+ const d = num3 % 10;
2539
2550
  if (d > 0) {
2540
2551
  const digitStr = d === 1 && unit > 0 ? "" : digits[d];
2541
2552
  result = digitStr + units[unit] + result;
2542
2553
  }
2543
- num2 = Math.floor(num2 / 10);
2554
+ num3 = Math.floor(num3 / 10);
2544
2555
  unit++;
2545
2556
  }
2546
2557
  return result;
@@ -2587,8 +2598,8 @@ function expandNumberingFormat(formatStr, counters, numbering) {
2587
2598
  const idx = levelRef - 1;
2588
2599
  const counterVal = _nullishCoalesce(counters[idx], () => ( 0));
2589
2600
  const start = _nullishCoalesce(numbering.startNumbers[idx], () => ( 1));
2590
- const num2 = counterVal > 0 ? start - 1 + counterVal : start;
2591
- result += formatNumber(num2, headFormatToNumFmt(_nullishCoalesce(numbering.numberFormats[idx], () => ( 0))));
2601
+ const num3 = counterVal > 0 ? start - 1 + counterVal : start;
2602
+ result += formatNumber(num3, headFormatToNumFmt(_nullishCoalesce(numbering.numberFormats[idx], () => ( 0))));
2592
2603
  i += 2;
2593
2604
  continue;
2594
2605
  }
@@ -3734,7 +3745,7 @@ function parseHwp5Document(buffer, options) {
3734
3745
  lenientCfb = parseLenientCfb(buffer);
3735
3746
  warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
3736
3747
  } catch (e21) {
3737
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
3748
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
3738
3749
  }
3739
3750
  }
3740
3751
  const findStream = (path) => {
@@ -3745,11 +3756,11 @@ function parseHwp5Document(buffer, options) {
3745
3756
  return lenientCfb.findStream(path);
3746
3757
  };
3747
3758
  const headerData = findStream("/FileHeader");
3748
- if (!headerData) throw new (0, _chunkMEXUFQVCcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
3759
+ if (!headerData) throw new (0, _chunkBIP4JAVGcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
3749
3760
  const header = parseFileHeader(headerData);
3750
- if (header.signature !== "HWP Document File") throw new (0, _chunkMEXUFQVCcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
3751
- if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3752
- if (header.flags & FLAG_DRM) throw new (0, _chunkMEXUFQVCcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3761
+ if (header.signature !== "HWP Document File") throw new (0, _chunkBIP4JAVGcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
3762
+ if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3763
+ if (header.flags & FLAG_DRM) throw new (0, _chunkBIP4JAVGcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3753
3764
  const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
3754
3765
  const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
3755
3766
  const metadata = {
@@ -3758,7 +3769,7 @@ function parseHwp5Document(buffer, options) {
3758
3769
  if (cfb) extractHwp5Metadata(cfb, metadata);
3759
3770
  const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
3760
3771
  const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
3761
- if (sections.length === 0) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3772
+ if (sections.length === 0) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3762
3773
  metadata.pageCount = sections.length;
3763
3774
  const pageFilter = _optionalChain([options, 'optionalAccess', _51 => _51.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
3764
3775
  const totalTarget = pageFilter ? pageFilter.size : sections.length;
@@ -3772,25 +3783,25 @@ function parseHwp5Document(buffer, options) {
3772
3783
  const sectionData = sections[si];
3773
3784
  const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
3774
3785
  totalDecompressed += data.length;
3775
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3786
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3776
3787
  const records = readRecords(data);
3777
3788
  const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
3778
3789
  bodyBlocks.push(...sectionBlocks);
3779
3790
  parsedSections++;
3780
3791
  _optionalChain([options, 'optionalAccess', _52 => _52.onProgress, 'optionalCall', _53 => _53(parsedSections, totalTarget)]);
3781
3792
  } catch (secErr) {
3782
- if (secErr instanceof _chunkMEXUFQVCcjs.KordocError) throw secErr;
3793
+ if (secErr instanceof _chunkBIP4JAVGcjs.KordocError) throw secErr;
3783
3794
  warnings.push({ page: si + 1, message: `\uC139\uC158 ${si + 1} \uD30C\uC2F1 \uC2E4\uD328: ${secErr instanceof Error ? secErr.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`, code: "PARTIAL_PARSE" });
3784
3795
  }
3785
3796
  }
3786
3797
  const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
3787
3798
  const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
3788
- const flatBlocks = _chunkMEXUFQVCcjs.flattenLayoutTables.call(void 0, blocks);
3799
+ const flatBlocks = _chunkBIP4JAVGcjs.flattenLayoutTables.call(void 0, blocks);
3789
3800
  if (docInfo) {
3790
3801
  detectHwp5Headings(flatBlocks, docInfo);
3791
3802
  }
3792
3803
  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 = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, flatBlocks);
3804
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, flatBlocks);
3794
3805
  return { markdown, blocks: flatBlocks, metadata, outline: outline.length > 0 ? outline : void 0, warnings: warnings.length > 0 ? warnings : void 0, images: images.length > 0 ? images : void 0 };
3795
3806
  }
3796
3807
  function parseDocInfoStream(cfb, compressed) {
@@ -3850,9 +3861,9 @@ function detectHwp5Headings(blocks, docInfo) {
3850
3861
  let level = 0;
3851
3862
  if (_optionalChain([block, 'access', _58 => _58.style, 'optionalAccess', _59 => _59.fontSize]) && baseFontSize > 0) {
3852
3863
  const ratio = block.style.fontSize / baseFontSize;
3853
- if (ratio >= _chunkMEXUFQVCcjs.HEADING_RATIO_H1) level = 1;
3854
- else if (ratio >= _chunkMEXUFQVCcjs.HEADING_RATIO_H2) level = 2;
3855
- else if (ratio >= _chunkMEXUFQVCcjs.HEADING_RATIO_H3) level = 3;
3864
+ if (ratio >= _chunkBIP4JAVGcjs.HEADING_RATIO_H1) level = 1;
3865
+ else if (ratio >= _chunkBIP4JAVGcjs.HEADING_RATIO_H2) level = 2;
3866
+ else if (ratio >= _chunkBIP4JAVGcjs.HEADING_RATIO_H3) level = 3;
3856
3867
  }
3857
3868
  if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
3858
3869
  if (level === 0) level = 2;
@@ -3937,7 +3948,7 @@ function findSectionsLenient(lcfb, compressed) {
3937
3948
  if (!raw) break;
3938
3949
  const content = compressed ? decompressStream(raw) : raw;
3939
3950
  totalDecompressed += content.length;
3940
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3951
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3941
3952
  sections.push({ idx: i, content });
3942
3953
  }
3943
3954
  if (sections.length === 0) {
@@ -3949,7 +3960,7 @@ function findSectionsLenient(lcfb, compressed) {
3949
3960
  if (raw) {
3950
3961
  const content = compressed ? decompressStream(raw) : raw;
3951
3962
  totalDecompressed += content.length;
3952
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3963
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3953
3964
  sections.push({ idx, content });
3954
3965
  }
3955
3966
  }
@@ -3966,7 +3977,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
3966
3977
  try {
3967
3978
  const content = decryptViewText(raw, compressed);
3968
3979
  totalDecompressed += content.length;
3969
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3980
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3970
3981
  sections.push({ idx: i, content });
3971
3982
  } catch (e26) {
3972
3983
  break;
@@ -4069,7 +4080,7 @@ function parseParagraph(records, start, end, ctx) {
4069
4080
  const ctrl = ctrls[r.ctrlIdx];
4070
4081
  if (!_optionalChain([ctrl, 'optionalAccess', _66 => _66.href]) || r.end <= r.start) continue;
4071
4082
  if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
4072
- const href = _chunkMEXUFQVCcjs.sanitizeHref.call(void 0, ctrl.href);
4083
+ const href = _chunkBIP4JAVGcjs.sanitizeHref.call(void 0, ctrl.href);
4073
4084
  if (!href) continue;
4074
4085
  const anchor = text.slice(r.start, r.end);
4075
4086
  if (!anchor.trim()) continue;
@@ -4156,11 +4167,11 @@ function applyCtrlEffect(ctrl, records, ctx) {
4156
4167
  const attr = ctrl.data.readUInt32LE(4);
4157
4168
  const type = attr & 15;
4158
4169
  const format = attr >>> 4 & 255;
4159
- const num2 = _nullishCoalesce(ctx.doc.autoCounters.get(type), () => ( 1));
4160
- ctx.doc.autoCounters.set(type, num2 + 1);
4170
+ const num3 = _nullishCoalesce(ctx.doc.autoCounters.get(type), () => ( 1));
4171
+ ctx.doc.autoCounters.set(type, num3 + 1);
4161
4172
  const prefix = ctrl.data.length >= 14 ? wcharAt(ctrl.data, 12) : "";
4162
4173
  const suffix = ctrl.data.length >= 16 ? wcharAt(ctrl.data, 14) : "";
4163
- ctrl.inlineText = `${prefix}${formatNumber(num2, shapeFormatToNumFmt(format))}${suffix}`;
4174
+ ctrl.inlineText = `${prefix}${formatNumber(num3, shapeFormatToNumFmt(format))}${suffix}`;
4164
4175
  }
4165
4176
  return;
4166
4177
  }
@@ -4168,8 +4179,8 @@ function applyCtrlEffect(ctrl, records, ctx) {
4168
4179
  if (ctrl.data.length >= 10) {
4169
4180
  const attr = ctrl.data.readUInt32LE(4);
4170
4181
  const type = attr & 15;
4171
- const num2 = ctrl.data.readUInt16LE(8);
4172
- if (num2 > 0) ctx.doc.autoCounters.set(type, num2);
4182
+ const num3 = ctrl.data.readUInt16LE(8);
4183
+ if (num3 > 0) ctx.doc.autoCounters.set(type, num3);
4173
4184
  }
4174
4185
  return;
4175
4186
  }
@@ -4231,7 +4242,7 @@ function blocksPlainText(blocks, sep) {
4231
4242
  return parts.join(sep).trim();
4232
4243
  }
4233
4244
  function applyNoteEffect(ctrl, records, ctx, autoType) {
4234
- const num2 = _nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1));
4245
+ const num3 = _nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1));
4235
4246
  let before = "";
4236
4247
  let after = "";
4237
4248
  let shape = 0;
@@ -4242,11 +4253,11 @@ function applyNoteEffect(ctrl, records, ctx, autoType) {
4242
4253
  if (ctrl.data.length >= 16) {
4243
4254
  shape = ctrl.data.readUInt32LE(12) & 255;
4244
4255
  }
4245
- const formatted = formatNumber(num2, shapeFormatToNumFmt(shape));
4256
+ const formatted = formatNumber(num3, shapeFormatToNumFmt(shape));
4246
4257
  const marker = before || after ? `${before}${formatted}${after}` : `${formatted})`;
4247
4258
  const content = blocksPlainText(parseListHeaderParagraphs(ctrl, records, ctx), " ");
4248
- if ((_nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1))) <= num2) {
4249
- ctx.doc.autoCounters.set(autoType, num2 + 1);
4259
+ if ((_nullishCoalesce(ctx.doc.autoCounters.get(autoType), () => ( 1))) <= num3) {
4260
+ ctx.doc.autoCounters.set(autoType, num3 + 1);
4250
4261
  }
4251
4262
  ctrl.inlineText = marker;
4252
4263
  if (content) ctrl.footnote = content.startsWith(marker) ? content : `${marker} ${content}`;
@@ -4302,8 +4313,8 @@ function parseTableControl(ctrl, records, ctx) {
4302
4313
  let tableIdx = -1;
4303
4314
  for (let i2 = childStart; i2 < childEnd; i2++) {
4304
4315
  if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
4305
- rows = Math.min(records[i2].data.readUInt16LE(4), _chunkMEXUFQVCcjs.MAX_ROWS);
4306
- cols = Math.min(records[i2].data.readUInt16LE(6), _chunkMEXUFQVCcjs.MAX_COLS);
4316
+ rows = Math.min(records[i2].data.readUInt16LE(4), _chunkBIP4JAVGcjs.MAX_ROWS);
4317
+ cols = Math.min(records[i2].data.readUInt16LE(6), _chunkBIP4JAVGcjs.MAX_COLS);
4307
4318
  tableIdx = i2;
4308
4319
  break;
4309
4320
  }
@@ -4352,7 +4363,7 @@ function parseTableControl(ctrl, records, ctx) {
4352
4363
  return table2;
4353
4364
  }
4354
4365
  const cellRows = arrangeCells(rows, cols, cells);
4355
- const table = _chunkMEXUFQVCcjs.buildTable.call(void 0, cellRows);
4366
+ const table = _chunkBIP4JAVGcjs.buildTable.call(void 0, cellRows);
4356
4367
  if (caption && table.rows > 0) table.caption = caption;
4357
4368
  return table.rows > 0 ? table : null;
4358
4369
  }
@@ -4369,8 +4380,8 @@ function parseCell(records, lhIdx, end, ctx) {
4369
4380
  rowAddr = rec.data.readUInt16LE(10);
4370
4381
  const cs = rec.data.readUInt16LE(12);
4371
4382
  const rs = rec.data.readUInt16LE(14);
4372
- if (cs > 0) colSpan = Math.min(cs, _chunkMEXUFQVCcjs.MAX_COLS);
4373
- if (rs > 0) rowSpan = Math.min(rs, _chunkMEXUFQVCcjs.MAX_ROWS);
4383
+ if (cs > 0) colSpan = Math.min(cs, _chunkBIP4JAVGcjs.MAX_COLS);
4384
+ if (rs > 0) rowSpan = Math.min(rs, _chunkBIP4JAVGcjs.MAX_ROWS);
4374
4385
  }
4375
4386
  const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
4376
4387
  const parts = [];
@@ -4380,7 +4391,7 @@ function parseCell(records, lhIdx, end, ctx) {
4380
4391
  parts.push(`![image](hwp5bin:${b.text})`);
4381
4392
  hasStructure = true;
4382
4393
  } else if (b.type === "table" && b.table) {
4383
- const flat = _chunkMEXUFQVCcjs.convertTableToText.call(void 0, b.table.cells);
4394
+ const flat = _chunkBIP4JAVGcjs.convertTableToText.call(void 0, b.table.cells);
4384
4395
  if (flat) parts.push(flat);
4385
4396
  hasStructure = true;
4386
4397
  } else if (b.text) {
@@ -16784,9 +16795,9 @@ var MAX_ROWS2 = 1e4;
16784
16795
  var MAX_COLS2 = 200;
16785
16796
  function cleanNumericValue(raw) {
16786
16797
  if (!/^-?\d+\.\d+$/.test(raw)) return raw;
16787
- const num2 = parseFloat(raw);
16788
- if (!isFinite(num2)) return raw;
16789
- const cleaned = parseFloat(num2.toPrecision(15)).toString();
16798
+ const num3 = parseFloat(raw);
16799
+ if (!isFinite(num3)) return raw;
16800
+ const cleaned = parseFloat(num3.toPrecision(15)).toString();
16790
16801
  return cleaned;
16791
16802
  }
16792
16803
  function parseCellRef(ref) {
@@ -16817,7 +16828,7 @@ function getTextContent(el) {
16817
16828
  return _nullishCoalesce(_optionalChain([el, 'access', _81 => _81.textContent, 'optionalAccess', _82 => _82.trim, 'call', _83 => _83()]), () => ( ""));
16818
16829
  }
16819
16830
  function parseXml(text) {
16820
- return new (0, _xmldom.DOMParser)().parseFromString(_chunkMEXUFQVCcjs.stripDtd.call(void 0, text), "text/xml");
16831
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunkBIP4JAVGcjs.stripDtd.call(void 0, text), "text/xml");
16821
16832
  }
16822
16833
  function parseSharedStrings(xml) {
16823
16834
  const doc = parseXml(xml);
@@ -16961,7 +16972,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
16961
16972
  cellRows.push(row);
16962
16973
  }
16963
16974
  if (cellRows.length > 0) {
16964
- const table = _chunkMEXUFQVCcjs.buildTable.call(void 0, cellRows);
16975
+ const table = _chunkBIP4JAVGcjs.buildTable.call(void 0, cellRows);
16965
16976
  if (table.rows > 0) {
16966
16977
  blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
16967
16978
  }
@@ -16969,12 +16980,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
16969
16980
  return blocks;
16970
16981
  }
16971
16982
  async function parseXlsxDocument(buffer, options) {
16972
- _chunkMEXUFQVCcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
16983
+ _chunkBIP4JAVGcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
16973
16984
  const zip = await _jszip2.default.loadAsync(buffer);
16974
16985
  const warnings = [];
16975
16986
  const workbookFile = zip.file("xl/workbook.xml");
16976
16987
  if (!workbookFile) {
16977
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
16988
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
16978
16989
  }
16979
16990
  let sharedStrings = [];
16980
16991
  const ssFile = zip.file("xl/sharedStrings.xml");
@@ -16983,7 +16994,7 @@ async function parseXlsxDocument(buffer, options) {
16983
16994
  }
16984
16995
  const sheets = parseWorkbook(await workbookFile.async("text"));
16985
16996
  if (sheets.length === 0) {
16986
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
16997
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
16987
16998
  }
16988
16999
  let relsMap = /* @__PURE__ */ new Map();
16989
17000
  const relsFile = zip.file("xl/_rels/workbook.xml.rels");
@@ -17055,7 +17066,7 @@ async function parseXlsxDocument(buffer, options) {
17055
17066
  } catch (e27) {
17056
17067
  }
17057
17068
  }
17058
- const markdown = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, blocks);
17069
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, blocks);
17059
17070
  return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
17060
17071
  }
17061
17072
 
@@ -17129,17 +17140,17 @@ function decodeRk(rk) {
17129
17140
  const fDiv100 = (rk & 1) !== 0;
17130
17141
  const fInt = (rk & 2) !== 0;
17131
17142
  const val30 = rk >> 2;
17132
- let num2;
17143
+ let num3;
17133
17144
  if (fInt) {
17134
- num2 = val30;
17145
+ num3 = val30;
17135
17146
  } else {
17136
17147
  const high32 = (rk & 4294967292) >>> 0;
17137
17148
  const buf = Buffer.alloc(8);
17138
17149
  buf.writeUInt32LE(0, 0);
17139
17150
  buf.writeUInt32LE(high32, 4);
17140
- num2 = buf.readDoubleLE(0);
17151
+ num3 = buf.readDoubleLE(0);
17141
17152
  }
17142
- return fDiv100 ? num2 / 100 : num2;
17153
+ return fDiv100 ? num3 / 100 : num3;
17143
17154
  }
17144
17155
  function decodeMulRk(data) {
17145
17156
  if (data.length < 6) return null;
@@ -17462,11 +17473,11 @@ function processGlobals(records) {
17462
17473
  let encrypted = false;
17463
17474
  const firstBof = records[0];
17464
17475
  if (!firstBof || firstBof.opcode !== OP_BOF) {
17465
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
17476
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
17466
17477
  }
17467
17478
  const bof = decodeBof(firstBof.data);
17468
17479
  if (!bof || bof.dt !== DT_GLOBALS) {
17469
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
17480
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
17470
17481
  }
17471
17482
  let i = 1;
17472
17483
  while (i < records.length) {
@@ -17581,7 +17592,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
17581
17592
  cellRows.push(row);
17582
17593
  }
17583
17594
  if (cellRows.length > 0) {
17584
- const table = _chunkMEXUFQVCcjs.buildTable.call(void 0, cellRows);
17595
+ const table = _chunkBIP4JAVGcjs.buildTable.call(void 0, cellRows);
17585
17596
  if (table.rows > 0) {
17586
17597
  blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
17587
17598
  }
@@ -17594,21 +17605,21 @@ async function parseXlsDocument(buffer, options) {
17594
17605
  try {
17595
17606
  cfb = parseLenientCfb(buf);
17596
17607
  } catch (e) {
17597
- throw new (0, _chunkMEXUFQVCcjs.KordocError)(
17608
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)(
17598
17609
  `XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
17599
17610
  );
17600
17611
  }
17601
17612
  const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
17602
17613
  if (!wb) {
17603
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
17614
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
17604
17615
  }
17605
17616
  const records = readRecords2(wb);
17606
17617
  if (records.length === 0) {
17607
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
17618
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
17608
17619
  }
17609
17620
  const firstBof = decodeBof(records[0].data);
17610
17621
  if (firstBof && firstBof.vers !== 1536) {
17611
- throw new (0, _chunkMEXUFQVCcjs.KordocError)(
17622
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)(
17612
17623
  `XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
17613
17624
  );
17614
17625
  }
@@ -17668,7 +17679,7 @@ async function parseXlsDocument(buffer, options) {
17668
17679
  pageCount: totalSheets
17669
17680
  };
17670
17681
  return {
17671
- markdown: _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, allBlocks),
17682
+ markdown: _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, allBlocks),
17672
17683
  blocks: allBlocks,
17673
17684
  metadata,
17674
17685
  warnings: warnings.length > 0 ? warnings : void 0
@@ -17839,9 +17850,9 @@ function nodeToLatex(el) {
17839
17850
  case "f": {
17840
17851
  const n = firstKid(el, "num");
17841
17852
  const d = firstKid(el, "den");
17842
- const num2 = n ? childrenToLatex(n) : "";
17853
+ const num3 = n ? childrenToLatex(n) : "";
17843
17854
  const den = d ? childrenToLatex(d) : "";
17844
- return "\\frac" + grp(num2) + grp(den);
17855
+ return "\\frac" + grp(num3) + grp(den);
17845
17856
  }
17846
17857
  // 첨자
17847
17858
  case "sSup": {
@@ -18106,7 +18117,7 @@ function getAttr(el, localName2) {
18106
18117
  return null;
18107
18118
  }
18108
18119
  function parseXml2(text) {
18109
- return new (0, _xmldom.DOMParser)().parseFromString(_chunkMEXUFQVCcjs.stripDtd.call(void 0, text), "text/xml");
18120
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunkBIP4JAVGcjs.stripDtd.call(void 0, text), "text/xml");
18110
18121
  }
18111
18122
  function parseStyles(xml) {
18112
18123
  const doc = parseXml2(xml);
@@ -18211,6 +18222,7 @@ function collectOmmlRoots(p) {
18211
18222
  const tag = el.localName || _optionalChain([el, 'access', _103 => _103.tagName, 'optionalAccess', _104 => _104.replace, 'call', _105 => _105(/^[^:]+:/, "")]) || "";
18212
18223
  if (tag === "oMath" || tag === "oMathPara") {
18213
18224
  out.push(el);
18225
+ } else if (tag === "txbxContent" || tag === "Fallback") {
18214
18226
  } else {
18215
18227
  walk(el);
18216
18228
  }
@@ -18335,6 +18347,13 @@ function parseTable(tbl, styles, numbering, footnotes, rels) {
18335
18347
  for (const tr of trElements) {
18336
18348
  const row = [];
18337
18349
  let col = 0;
18350
+ const trPrEls = getChildElements(tr, "trPr");
18351
+ if (trPrEls.length > 0) {
18352
+ const gridBeforeEls = getChildElements(trPrEls[0], "gridBefore");
18353
+ if (gridBeforeEls.length > 0) {
18354
+ col = parseInt(_nullishCoalesce(getAttr(gridBeforeEls[0], "val"), () => ( "0")), 10) || 0;
18355
+ }
18356
+ }
18338
18357
  for (const tc of getChildElements(tr, "tc")) {
18339
18358
  let colSpan = 1;
18340
18359
  let vMerge = null;
@@ -18349,12 +18368,28 @@ function parseTable(tbl, styles, numbering, footnotes, rels) {
18349
18368
  vMerge = getAttr(vMergeEls[0], "val") === "restart" ? "restart" : "continue";
18350
18369
  }
18351
18370
  }
18352
- const text = vMerge === "continue" ? "" : collectCellText(tc, styles, numbering, footnotes, rels, 0).join("\n");
18371
+ const text = collectCellText(tc, styles, numbering, footnotes, rels, 0).join("\n");
18353
18372
  row.push({ col, colSpan, vMerge, text });
18354
18373
  col += colSpan;
18355
18374
  }
18356
18375
  rawRows.push(row);
18357
18376
  }
18377
+ for (let r = 0; r < rawRows.length; r++) {
18378
+ for (const cell of rawRows[r]) {
18379
+ if (cell.vMerge !== "continue" || !cell.text) continue;
18380
+ let start;
18381
+ for (let pr = r - 1; pr >= 0 && !start; pr--) {
18382
+ start = rawRows[pr].find((pc) => pc.col === cell.col && pc.vMerge !== "continue");
18383
+ }
18384
+ if (start) {
18385
+ start.text = start.text ? `${start.text}
18386
+ ${cell.text}` : cell.text;
18387
+ cell.text = "";
18388
+ } else {
18389
+ cell.vMerge = null;
18390
+ }
18391
+ }
18392
+ }
18358
18393
  const cellRows = rawRows.map(
18359
18394
  (row, r) => row.filter((cell) => cell.vMerge !== "continue").map((cell) => {
18360
18395
  let rowSpan = 1;
@@ -18367,7 +18402,7 @@ function parseTable(tbl, styles, numbering, footnotes, rels) {
18367
18402
  return { text: cell.text, colSpan: cell.colSpan, rowSpan, colAddr: cell.col, rowAddr: r };
18368
18403
  })
18369
18404
  );
18370
- const table = _chunkMEXUFQVCcjs.buildTable.call(void 0, cellRows);
18405
+ const table = _chunkBIP4JAVGcjs.buildTable.call(void 0, cellRows);
18371
18406
  if (table.rows === 0 || table.cols === 0) return null;
18372
18407
  return { type: "table", table };
18373
18408
  }
@@ -18434,12 +18469,12 @@ async function extractImages(zip, rels, doc, warnings) {
18434
18469
  return { blocks, images };
18435
18470
  }
18436
18471
  async function parseDocxDocument(buffer, options) {
18437
- _chunkMEXUFQVCcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
18472
+ _chunkBIP4JAVGcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
18438
18473
  const zip = await _jszip2.default.loadAsync(buffer);
18439
18474
  const warnings = [];
18440
18475
  const docFile = zip.file("word/document.xml");
18441
18476
  if (!docFile) {
18442
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
18477
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
18443
18478
  }
18444
18479
  let rels = /* @__PURE__ */ new Map();
18445
18480
  const relsFile = zip.file("word/_rels/document.xml.rels");
@@ -18486,7 +18521,7 @@ async function parseDocxDocument(buffer, options) {
18486
18521
  const doc = parseXml2(docXml);
18487
18522
  const body = findElements(doc, "body");
18488
18523
  if (body.length === 0) {
18489
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
18524
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
18490
18525
  }
18491
18526
  const blocks = [];
18492
18527
  const bodyEl = body[0];
@@ -18531,7 +18566,7 @@ async function parseDocxDocument(buffer, options) {
18531
18566
  }
18532
18567
  }
18533
18568
  const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
18534
- const markdown = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, blocks);
18569
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, blocks);
18535
18570
  return {
18536
18571
  markdown,
18537
18572
  blocks,
@@ -18554,7 +18589,7 @@ function parseHwpmlDocument(buffer, options) {
18554
18589
  }
18555
18590
  const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
18556
18591
  const normalized = text.replace(/&nbsp;/g, "&#160;");
18557
- const xml = _chunkMEXUFQVCcjs.stripDtd.call(void 0, normalized);
18592
+ const xml = _chunkBIP4JAVGcjs.stripDtd.call(void 0, normalized);
18558
18593
  const warnings = [];
18559
18594
  const parser = new (0, _xmldom.DOMParser)({
18560
18595
  onError: (_level, msg2) => {
@@ -18594,7 +18629,7 @@ function parseHwpmlDocument(buffer, options) {
18594
18629
  parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
18595
18630
  }
18596
18631
  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 = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, blocks);
18632
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, blocks);
18598
18633
  return {
18599
18634
  markdown,
18600
18635
  blocks,
@@ -18752,7 +18787,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
18752
18787
  const cellRows = grid.map(
18753
18788
  (row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
18754
18789
  );
18755
- const table = _chunkMEXUFQVCcjs.buildTable.call(void 0, cellRows);
18790
+ const table = _chunkBIP4JAVGcjs.buildTable.call(void 0, cellRows);
18756
18791
  const caption = extractShapeCaption(el);
18757
18792
  if (caption.text && caption.before) {
18758
18793
  blocks.push({ type: "paragraph", text: caption.text, pageNumber: sectionNum });
@@ -18844,6 +18879,81 @@ function countSections(body) {
18844
18879
  }
18845
18880
 
18846
18881
  // src/form/match.ts
18882
+ function parseYMD(v) {
18883
+ const d = v.replace(/\D/g, "");
18884
+ let y, m, day;
18885
+ if (d.length >= 8) {
18886
+ y = d.slice(0, 4);
18887
+ m = d.slice(4, 6);
18888
+ day = d.slice(6, 8);
18889
+ } else if (d.length === 6) {
18890
+ const yy = +d.slice(0, 2);
18891
+ y = String(yy <= 29 ? 2e3 + yy : 1900 + yy);
18892
+ m = d.slice(2, 4);
18893
+ day = d.slice(4, 6);
18894
+ } else return null;
18895
+ return { y, yy: y.slice(2), m, d: day };
18896
+ }
18897
+ function fmtDate(v, style) {
18898
+ const p = parseYMD(v);
18899
+ if (!p) return v;
18900
+ return (style || "yyyy-mm-dd").replace(/yyyy/g, p.y).replace(/yy/g, p.yy).replace(/mm/g, p.m).replace(/dd/g, p.d).replace(/m/g, String(+p.m)).replace(/d/g, String(+p.d));
18901
+ }
18902
+ function maskDigits(v, pattern) {
18903
+ const ds = v.replace(/\D/g, "");
18904
+ let i = 0;
18905
+ return pattern.replace(/#/g, () => _nullishCoalesce(ds[i++], () => ( "")));
18906
+ }
18907
+ function fmtPhone(v, style) {
18908
+ const d = v.replace(/\D/g, "");
18909
+ if (d.length < 9) return v;
18910
+ const a = d.slice(0, 3), b = d.slice(3, -4), c = d.slice(-4);
18911
+ switch (style) {
18912
+ case "digits":
18913
+ return d;
18914
+ case "dot":
18915
+ return `${a}.${b}.${c}`;
18916
+ case "space":
18917
+ return `${a} ${b} ${c}`;
18918
+ case "intl":
18919
+ return `+82-${d.slice(1, 3)}-${b}-${c}`;
18920
+ case "intl-paren":
18921
+ return `82)${d.slice(1, 3)}-${b}-${c}`;
18922
+ default:
18923
+ return `${a}-${b}-${c}`;
18924
+ }
18925
+ }
18926
+ function fmtRRN(v, style) {
18927
+ const d = v.replace(/\D/g, "");
18928
+ if (d.length !== 13) return v;
18929
+ switch (style) {
18930
+ case "digits":
18931
+ return d;
18932
+ case "front":
18933
+ return d.slice(0, 6);
18934
+ case "masked":
18935
+ return `${d.slice(0, 6)}-${d[6]}******`;
18936
+ default:
18937
+ return `${d.slice(0, 6)}-${d.slice(6)}`;
18938
+ }
18939
+ }
18940
+ function formatFillValue(value, format) {
18941
+ if (!format) return value;
18942
+ const ci = format.indexOf(":");
18943
+ const kind = ci >= 0 ? format.slice(0, ci) : format;
18944
+ const style = ci >= 0 ? format.slice(ci + 1) : "";
18945
+ if (kind === "date") return fmtDate(value, style);
18946
+ if (kind === "phone") return fmtPhone(value, style);
18947
+ if (kind === "rrn") return fmtRRN(value, style);
18948
+ if (kind === "mask") return maskDigits(value, style);
18949
+ if (kind === "digits") return value.replace(/\D/g, "");
18950
+ if (kind === "upper") return value.toUpperCase();
18951
+ if (kind === "lower") return value.toLowerCase();
18952
+ if (kind === "nospace") return value.replace(/\s+/g, "");
18953
+ if (format.includes("#")) return maskDigits(value, format);
18954
+ if (/(yyyy|yy|mm|dd)/.test(format)) return fmtDate(value, format);
18955
+ return value;
18956
+ }
18847
18957
  var ValueCursor = (_class2 = class {
18848
18958
  constructor(values) {;_class2.prototype.__init4.call(this);
18849
18959
  this.values = values;
@@ -18995,11 +19105,32 @@ function padInsertion(text, pos, value) {
18995
19105
  }
18996
19106
  function normalizeValues(values) {
18997
19107
  const map = /* @__PURE__ */ new Map();
18998
- for (const [label, value] of Object.entries(values)) {
18999
- map.set(normalizeLabel(label), value);
19108
+ for (const [label, raw] of Object.entries(values)) {
19109
+ const { value, format } = typeof raw === "object" && !Array.isArray(raw) ? raw : { value: raw, format: void 0 };
19110
+ map.set(normalizeLabel(label), Array.isArray(value) ? value.map((v) => formatFillValue(v, format)) : formatFillValue(value, format));
19000
19111
  }
19001
19112
  return map;
19002
19113
  }
19114
+ async function fillWithUniqueGuard(values, run) {
19115
+ const first = await run(values);
19116
+ const counts = /* @__PURE__ */ new Map();
19117
+ for (const f of first.filled) {
19118
+ if (f.key) counts.set(f.key, (_nullishCoalesce(counts.get(f.key), () => ( 0))) + 1);
19119
+ }
19120
+ const isArrayValue = (normKey) => {
19121
+ for (const [label, raw] of Object.entries(values)) {
19122
+ if (normalizeLabel(label) !== normKey) continue;
19123
+ return Array.isArray(typeof raw === "object" && !Array.isArray(raw) ? raw.value : raw);
19124
+ }
19125
+ return false;
19126
+ };
19127
+ const dup = new Set([...counts].filter(([k, n]) => n >= 2 && !isArrayValue(k)).map(([k]) => k));
19128
+ if (dup.size === 0) return { ...first, rejected: [] };
19129
+ const filtered = Object.fromEntries(Object.entries(values).filter(([label]) => !dup.has(normalizeLabel(label))));
19130
+ const second = await run(filtered);
19131
+ const rejected = Object.keys(values).filter((label) => dup.has(normalizeLabel(label)));
19132
+ return { ...second, rejected };
19133
+ }
19003
19134
  function resolveUnmatched(normalizedValues, matchedLabels, originalValues) {
19004
19135
  return [...normalizedValues.keys()].filter((k) => !matchedLabels.has(k)).map((k) => {
19005
19136
  for (const orig of Object.keys(originalValues)) {
@@ -19269,7 +19400,7 @@ function fillFormFields(blocks, values) {
19269
19400
  cell.text = result.text;
19270
19401
  patternFilledCells.add(cell);
19271
19402
  for (const m of result.matches) {
19272
- filled.push({ label: m.label, value: m.value, row: r, col: c });
19403
+ filled.push({ label: m.label, value: m.value, row: r, col: c, key: m.key });
19273
19404
  }
19274
19405
  }
19275
19406
  }
@@ -19349,7 +19480,8 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
19349
19480
  label: labelCell.text.trim().replace(/[::]\s*$/, ""),
19350
19481
  value: newValue,
19351
19482
  row: r,
19352
- col: c
19483
+ col: c,
19484
+ key: matchKey
19353
19485
  });
19354
19486
  }
19355
19487
  }
@@ -19378,7 +19510,8 @@ function fillTable(table, values, filled, matchedLabels, patternFilledCells) {
19378
19510
  label: headerCell.text.trim(),
19379
19511
  value: newValue,
19380
19512
  row: r,
19381
- col: c
19513
+ col: c,
19514
+ key: matchKey
19382
19515
  });
19383
19516
  }
19384
19517
  }
@@ -19395,7 +19528,7 @@ function fillInlineFields(text, values, filled, matchedLabels) {
19395
19528
  const newValue = values.consume(matchKey);
19396
19529
  if (newValue === void 0) continue;
19397
19530
  matchedLabels.add(matchKey);
19398
- filled.push({ label: seg.label.trim(), value: newValue, row: -1, col: -1 });
19531
+ filled.push({ label: seg.label.trim(), value: newValue, row: -1, col: -1, key: matchKey });
19399
19532
  out += text.slice(pos, seg.valueStart);
19400
19533
  out += seg.valueStart === seg.valueEnd ? padInsertion(text, seg.valueStart, newValue) : newValue;
19401
19534
  pos = seg.valueEnd;
@@ -19957,19 +20090,19 @@ function parseCentralDirectory(buf) {
19957
20090
  }
19958
20091
  }
19959
20092
  }
19960
- if (eocdOffset < 0) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
20093
+ if (eocdOffset < 0) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19961
20094
  const totalEntries = view.getUint16(eocdOffset + 10, true);
19962
20095
  const cdSize = view.getUint32(eocdOffset + 12, true);
19963
20096
  const cdOffset = view.getUint32(eocdOffset + 16, true);
19964
- if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
20097
+ if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19965
20098
  if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
19966
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
20099
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19967
20100
  }
19968
20101
  const decoder = new TextDecoder("utf-8");
19969
20102
  const entries = [];
19970
20103
  let pos = cdOffset;
19971
20104
  for (let i = 0; i < totalEntries; i++) {
19972
- if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
20105
+ if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
19973
20106
  const flags = view.getUint16(pos + 8, true);
19974
20107
  const method = view.getUint16(pos + 10, true);
19975
20108
  const crc = view.getUint32(pos + 16, true);
@@ -19980,7 +20113,7 @@ function parseCentralDirectory(buf) {
19980
20113
  const commentLen = view.getUint16(pos + 32, true);
19981
20114
  const localOffset = view.getUint32(pos + 42, true);
19982
20115
  if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
19983
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
20116
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19984
20117
  }
19985
20118
  const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
19986
20119
  const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
@@ -20005,11 +20138,16 @@ function crc32(data) {
20005
20138
  }
20006
20139
  return (crc ^ 4294967295) >>> 0;
20007
20140
  }
20008
- function patchZipEntries(original, replacements) {
20141
+ function patchZipEntries(original, replacements, additions) {
20009
20142
  const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
20010
20143
  const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
20011
20144
  for (const name of replacements.keys()) {
20012
- if (!entries.some((e) => e.name === name)) throw new (0, _chunkMEXUFQVCcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
20145
+ if (!entries.some((e) => e.name === name)) throw new (0, _chunkBIP4JAVGcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
20146
+ }
20147
+ if (additions) {
20148
+ for (const name of additions.keys()) {
20149
+ if (entries.some((e) => e.name === name)) throw new (0, _chunkBIP4JAVGcjs.KordocError)(`ZIP\uC5D0 \uC774\uBBF8 \uC788\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
20150
+ }
20013
20151
  }
20014
20152
  const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
20015
20153
  const segments = [];
@@ -20027,7 +20165,7 @@ function patchZipEntries(original, replacements) {
20027
20165
  offset += seg.length;
20028
20166
  continue;
20029
20167
  }
20030
- if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkMEXUFQVCcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
20168
+ if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkBIP4JAVGcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
20031
20169
  const nameLen = view.getUint16(e.localOffset + 26, true);
20032
20170
  const extraLen = view.getUint16(e.localOffset + 28, true);
20033
20171
  const headerLen = 30 + nameLen + extraLen;
@@ -20045,6 +20183,34 @@ function patchZipEntries(original, replacements) {
20045
20183
  offset += headerLen + compData.length;
20046
20184
  newMeta.set(e, { crc, compSize: compData.length, uncompSize: newData.length, flags });
20047
20185
  }
20186
+ const added = [];
20187
+ if (additions) {
20188
+ const encoder = new TextEncoder();
20189
+ for (const [name, data] of additions) {
20190
+ const nameBytes = encoder.encode(name);
20191
+ const deflated = new Uint8Array(_zlib.deflateRawSync.call(void 0, data));
20192
+ const method = deflated.length < data.length ? 8 : 0;
20193
+ const compData = method === 8 ? deflated : data;
20194
+ const crc = crc32(data);
20195
+ const header = new Uint8Array(30 + nameBytes.length);
20196
+ const hv = new DataView(header.buffer);
20197
+ hv.setUint32(0, LOCAL_SIG, true);
20198
+ hv.setUint16(4, 20, true);
20199
+ hv.setUint16(6, 2048, true);
20200
+ hv.setUint16(8, method, true);
20201
+ hv.setUint16(10, 0, true);
20202
+ hv.setUint16(12, 33, true);
20203
+ hv.setUint32(14, crc, true);
20204
+ hv.setUint32(18, compData.length, true);
20205
+ hv.setUint32(22, data.length, true);
20206
+ hv.setUint16(26, nameBytes.length, true);
20207
+ hv.setUint16(28, 0, true);
20208
+ header.set(nameBytes, 30);
20209
+ added.push({ nameBytes, crc, compSize: compData.length, uncompSize: data.length, method, localOffset: offset });
20210
+ segments.push(header, compData);
20211
+ offset += header.length + compData.length;
20212
+ }
20213
+ }
20048
20214
  const newCdOffset = offset;
20049
20215
  for (const e of entries) {
20050
20216
  const cd = copyBytes(original, e.cdStart, e.cdEnd);
@@ -20060,9 +20226,32 @@ function patchZipEntries(original, replacements) {
20060
20226
  segments.push(cd);
20061
20227
  offset += cd.length;
20062
20228
  }
20229
+ for (const a of added) {
20230
+ const cd = new Uint8Array(46 + a.nameBytes.length);
20231
+ const cv = new DataView(cd.buffer);
20232
+ cv.setUint32(0, CD_SIG, true);
20233
+ cv.setUint16(4, 20, true);
20234
+ cv.setUint16(6, 20, true);
20235
+ cv.setUint16(8, 2048, true);
20236
+ cv.setUint16(10, a.method, true);
20237
+ cv.setUint16(12, 0, true);
20238
+ cv.setUint16(14, 33, true);
20239
+ cv.setUint32(16, a.crc, true);
20240
+ cv.setUint32(20, a.compSize, true);
20241
+ cv.setUint32(24, a.uncompSize, true);
20242
+ cv.setUint16(28, a.nameBytes.length, true);
20243
+ cv.setUint32(42, a.localOffset, true);
20244
+ cd.set(a.nameBytes, 46);
20245
+ segments.push(cd);
20246
+ offset += cd.length;
20247
+ }
20063
20248
  const newCdSize = offset - newCdOffset;
20064
20249
  const eocd = copyBytes(original, eocdOffset);
20065
20250
  const eview = new DataView(eocd.buffer, eocd.byteOffset, eocd.byteLength);
20251
+ if (added.length > 0) {
20252
+ eview.setUint16(8, view.getUint16(eocdOffset + 8, true) + added.length, true);
20253
+ eview.setUint16(10, view.getUint16(eocdOffset + 10, true) + added.length, true);
20254
+ }
20066
20255
  eview.setUint32(12, newCdSize, true);
20067
20256
  eview.setUint32(16, newCdOffset, true);
20068
20257
  segments.push(eocd);
@@ -20082,7 +20271,7 @@ async function fillHwpx(hwpxBuffer, values) {
20082
20271
  const zip = await _jszip2.default.loadAsync(hwpxBuffer);
20083
20272
  const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
20084
20273
  if (sectionPaths.length === 0) {
20085
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
20274
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
20086
20275
  }
20087
20276
  const normalizedValues = normalizeValues(values);
20088
20277
  const cursor = new ValueCursor(normalizedValues);
@@ -20232,7 +20421,8 @@ async function fillHwpx(hwpxBuffer, values) {
20232
20421
  label: cellLabelText(headerCells[colIdx]).trim(),
20233
20422
  value: newValue,
20234
20423
  row: rowIdx,
20235
- col: colIdx
20424
+ col: colIdx,
20425
+ key: matchKey
20236
20426
  });
20237
20427
  }
20238
20428
  }
@@ -21008,12 +21198,14 @@ function generateContainerXml() {
21008
21198
  </ocf:rootfiles>
21009
21199
  </ocf:container>`;
21010
21200
  }
21011
- function generateManifest() {
21201
+ function generateManifest(chartParts = []) {
21202
+ const chartItems = chartParts.map((p, i) => `
21203
+ <opf:item id="chart${i + 1}" href="${p.name}" media-type="application/xml"/>`).join("");
21012
21204
  return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
21013
21205
  <opf:package xmlns:opf="${NS_OPF}" xmlns:hpf="${NS_HPF}" xmlns:hh="${NS_HEAD}">
21014
21206
  <opf:manifest>
21015
21207
  <opf:item id="header" href="Contents/header.xml" media-type="application/xml"/>
21016
- <opf:item id="section0" href="Contents/section0.xml" media-type="application/xml"/>
21208
+ <opf:item id="section0" href="Contents/section0.xml" media-type="application/xml"/>${chartItems}
21017
21209
  </opf:manifest>
21018
21210
  <opf:spine>
21019
21211
  <opf:itemref idref="header" linear="no"/>
@@ -21453,7 +21645,7 @@ function escapeGfm(text) {
21453
21645
  }
21454
21646
  var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
21455
21647
  function sanitizeText(text) {
21456
- let result = _chunkMEXUFQVCcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
21648
+ let result = _chunkBIP4JAVGcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
21457
21649
  if (result.length <= 30 && result.includes(" ")) {
21458
21650
  const tokens = result.split(" ");
21459
21651
  const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-힯ㄱ-ㆎ]/.test(t)).length;
@@ -21939,9 +22131,9 @@ function readCommand(input, idx, depth) {
21939
22131
  const command = name.value;
21940
22132
  if (command === "\\") return { value: "#", next: name.next };
21941
22133
  if (command === "frac") {
21942
- const num2 = readGroupOrToken(input, name.next, depth);
21943
- const den = readGroupOrToken(input, num2.next, depth);
21944
- return { value: `{${num2.value}} over {${den.value}}`, next: den.next };
22134
+ const num3 = readGroupOrToken(input, name.next, depth);
22135
+ const den = readGroupOrToken(input, num3.next, depth);
22136
+ return { value: `{${num3.value}} over {${den.value}}`, next: den.next };
21945
22137
  }
21946
22138
  if (command === "sqrt") {
21947
22139
  let cursor = skipSpaces(input, name.next);
@@ -21982,6 +22174,9 @@ function readCommand(input, idx, depth) {
21982
22174
  const body = readGroupOrToken(input, name.next, depth);
21983
22175
  return { value: `${ACCENT_COMMANDS[command]}{${body.value}}`, next: body.next };
21984
22176
  }
22177
+ if (command === ",") return { value: "`", next: name.next };
22178
+ if (command === ";" || command === ":") return { value: "~", next: name.next };
22179
+ if (command === "!") return { value: "", next: name.next };
21985
22180
  if (command === "mathrm" || command === "text") {
21986
22181
  const start = skipSpaces(input, name.next);
21987
22182
  if (input[start] === "{") {
@@ -22057,6 +22252,210 @@ function generateEquationParagraph(input, zOrder = 0) {
22057
22252
  return `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${generateEquationXml(script, zOrder)}</hp:run></hp:p>`;
22058
22253
  }
22059
22254
 
22255
+ // src/hwpx/chart-gen.ts
22256
+ var XML_ESC = { "&": "&amp;", "<": "&lt;", ">": "&gt;" };
22257
+ var xmlEscape = (s) => s.replace(/[&<>]/g, (c) => XML_ESC[c]);
22258
+ var CHART_TYPES = {
22259
+ 0: { el: "barChart", dir: "col", grp: "clustered" },
22260
+ 1: { el: "barChart", dir: "col", grp: "stacked", overlap: 100 },
22261
+ 2: { el: "lineChart", grp: "standard", marker: true },
22262
+ 3: { el: "barChart", dir: "bar", grp: "clustered" },
22263
+ 4: { el: "barChart", dir: "bar", grp: "stacked", overlap: 100 },
22264
+ 5: { el: "scatterChart", scatter: true },
22265
+ 6: { el: "pieChart", pie: true },
22266
+ 7: { el: "pieChart", pie: true, explode: true },
22267
+ 8: { el: "doughnutChart", pie: true, hole: 50 },
22268
+ 9: { el: "areaChart", grp: "standard" },
22269
+ 10: { el: "areaChart", grp: "stacked" },
22270
+ 11: { el: "radarChart", radar: true },
22271
+ 12: { el: "bar3DChart", dir: "col", grp: "clustered" },
22272
+ 13: { el: "bar3DChart", dir: "col", grp: "stacked", overlap: 100 },
22273
+ 14: { el: "bar3DChart", dir: "bar", grp: "clustered" },
22274
+ 15: { el: "bar3DChart", dir: "bar", grp: "stacked", overlap: 100 },
22275
+ 16: { el: "pie3DChart", pie: true },
22276
+ 17: { el: "pie3DChart", pie: true, explode: true },
22277
+ 18: { el: "area3DChart", grp: "standard" },
22278
+ 19: { el: "area3DChart", grp: "stacked" }
22279
+ };
22280
+ var CHART_ALIAS = {
22281
+ column: 0,
22282
+ col: 0,
22283
+ \uC138\uB85C\uB9C9\uB300: 0,
22284
+ \uB9C9\uB300: 0,
22285
+ column_stacked: 1,
22286
+ \uC138\uB85C\uB9C9\uB300_\uB204\uC801: 1,
22287
+ line: 2,
22288
+ \uC120: 2,
22289
+ \uAEBE\uC740\uC120: 2,
22290
+ bar: 3,
22291
+ \uAC00\uB85C\uB9C9\uB300: 3,
22292
+ bar_stacked: 4,
22293
+ scatter: 5,
22294
+ \uBD84\uC0B0: 5,
22295
+ pie: 6,
22296
+ \uC6D0: 6,
22297
+ \uD30C\uC774: 6,
22298
+ pie_explode: 7,
22299
+ doughnut: 8,
22300
+ donut: 8,
22301
+ \uB3C4\uB11B: 8,
22302
+ area: 9,
22303
+ \uC601\uC5ED: 9,
22304
+ area_stacked: 10,
22305
+ radar: 11,
22306
+ \uBC29\uC0AC\uD615: 11,
22307
+ bar3d: 12,
22308
+ column3d: 12,
22309
+ pie3d: 16
22310
+ };
22311
+ function chartSpec(t) {
22312
+ if (!t) return CHART_TYPES[0];
22313
+ const key = _nullishCoalesce(CHART_ALIAS[t.toLowerCase()], () => ( Number(t)));
22314
+ return _nullishCoalesce(CHART_TYPES[key], () => ( CHART_TYPES[0]));
22315
+ }
22316
+ var HU_PER_MM = 7200 / 25.4;
22317
+ var RESERVED_KEYS = /* @__PURE__ */ new Set(["type", "cat", "size", "colors", "point_colors", "title"]);
22318
+ function parseChartFence(text) {
22319
+ let type;
22320
+ let cat = null;
22321
+ let widthMm = 32250 / HU_PER_MM;
22322
+ let heightMm = 18750 / HU_PER_MM;
22323
+ let colors = null;
22324
+ let pointColors = null;
22325
+ const series = [];
22326
+ for (const rawLine of text.split("\n")) {
22327
+ const line = rawLine.trim();
22328
+ if (!line || line.startsWith("#")) continue;
22329
+ const colon = line.search(/[::]/);
22330
+ if (colon <= 0) continue;
22331
+ const key = line.slice(0, colon).trim();
22332
+ const value = line.slice(colon + 1).trim();
22333
+ const keyLower = key.toLowerCase();
22334
+ if (keyLower === "type") {
22335
+ type = value;
22336
+ } else if (keyLower === "cat") {
22337
+ cat = value.split(",").map((s) => s.trim()).filter(Boolean);
22338
+ } else if (keyLower === "size") {
22339
+ const m = value.match(/^(\d+(?:\.\d+)?)\s*[x×]\s*(\d+(?:\.\d+)?)$/i);
22340
+ if (m) {
22341
+ widthMm = Number(m[1]);
22342
+ heightMm = Number(m[2]);
22343
+ }
22344
+ } else if (keyLower === "colors") {
22345
+ colors = value.split(",").map((s) => s.trim()).filter(Boolean);
22346
+ } else if (keyLower === "point_colors") {
22347
+ pointColors = value.split(",").map((s) => s.trim()).filter(Boolean);
22348
+ } else if (keyLower === "title") {
22349
+ } else if (!RESERVED_KEYS.has(keyLower)) {
22350
+ const nums = value.split(",").map((s) => Number(s.trim()));
22351
+ if (nums.length > 0 && nums.every((n) => Number.isFinite(n))) {
22352
+ series.push({ name: key, values: nums });
22353
+ }
22354
+ }
22355
+ }
22356
+ if (series.length === 0) return null;
22357
+ const spec = chartSpec(type);
22358
+ const catFinal = _nullishCoalesce(cat, () => ( series[0].values.map((_, i) => `\uD56D\uBAA9 ${i + 1}`)));
22359
+ let finalSeries = spec.pie ? [series[0]] : series;
22360
+ finalSeries = finalSeries.map((s) => ({ ...s }));
22361
+ if (spec.pie) {
22362
+ const slice = _nullishCoalesce(colors, () => ( pointColors));
22363
+ if (slice) finalSeries[0].pointColors = slice;
22364
+ } else {
22365
+ if (colors) finalSeries.forEach((s, i) => {
22366
+ s.color = colors[i % colors.length];
22367
+ });
22368
+ if (pointColors && finalSeries[0]) finalSeries[0].pointColors = pointColors;
22369
+ }
22370
+ return {
22371
+ spec,
22372
+ cat: catFinal,
22373
+ series: finalSeries,
22374
+ widthHu: Math.round(widthMm * HU_PER_MM),
22375
+ heightHu: Math.round(heightMm * HU_PER_MM)
22376
+ };
22377
+ }
22378
+ var colLetter = (i) => String.fromCharCode(66 + i);
22379
+ function strCachePts(vals) {
22380
+ return `<c:ptCount val="${vals.length}"/>` + vals.map((v, i) => `<c:pt idx="${i}"><c:v>${xmlEscape(v)}</c:v></c:pt>`).join("");
22381
+ }
22382
+ function numCachePts(vals) {
22383
+ return `<c:formatCode>General</c:formatCode><c:ptCount val="${vals.length}"/>` + vals.map((v, i) => `<c:pt idx="${i}"><c:v>${Number(v) || 0}</c:v></c:pt>`).join("");
22384
+ }
22385
+ function chartColorFill(color) {
22386
+ if (color == null) return null;
22387
+ const c = color.trim();
22388
+ if (/^accent[1-6]$/i.test(c)) return `<a:solidFill><a:schemeClr val="${c.toLowerCase()}"/></a:solidFill>`;
22389
+ const hex = c.replace(/^#/, "").toUpperCase();
22390
+ if (/^[0-9A-F]{6}$/.test(hex)) return `<a:solidFill><a:srgbClr val="${hex}"/></a:solidFill>`;
22391
+ return null;
22392
+ }
22393
+ function serSpPr(color, stroke) {
22394
+ const f = chartColorFill(color);
22395
+ if (!f) return "<c:spPr/>";
22396
+ return stroke ? `<c:spPr><a:ln w="28575" cap="flat" cmpd="sng" algn="ctr">${f}<a:prstDash val="solid"/><a:round/></a:ln></c:spPr>` : `<c:spPr>${f}</c:spPr>`;
22397
+ }
22398
+ function dPtXml(pointColors, pie) {
22399
+ if (!_optionalChain([pointColors, 'optionalAccess', _188 => _188.length])) return "";
22400
+ return pointColors.map((col, i) => {
22401
+ const f = chartColorFill(col);
22402
+ if (!f) return "";
22403
+ const mid = pie ? '<c:invertIfNegative val="0"/><c:bubble3D val="0"/><c:explosion val="0"/>' : '<c:bubble3D val="0"/>';
22404
+ return `<c:dPt><c:idx val="${i}"/>${mid}<c:spPr>${f}</c:spPr></c:dPt>`;
22405
+ }).join("");
22406
+ }
22407
+ function stdSer(idx, name, cat, values, explode, color, pointColors, stroke, pie) {
22408
+ const cl = colLetter(idx);
22409
+ return `<c:ser><c:idx val="${idx}"/><c:order val="${idx}"/><c:tx><c:strRef><c:f>Sheet1!$${cl}$1</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>${xmlEscape(name)}</c:v></c:pt></c:strCache></c:strRef></c:tx>${serSpPr(color, stroke)}<c:invertIfNegative val="0"/>` + (explode ? `<c:explosion val="25"/>` : "") + dPtXml(pointColors, pie) + `<c:cat><c:strRef><c:f>Sheet1!$A$2:$A$${cat.length + 1}</c:f><c:strCache>${strCachePts(cat)}</c:strCache></c:strRef></c:cat><c:val><c:numRef><c:f>Sheet1!$${cl}$2:$${cl}$${values.length + 1}</c:f><c:numCache>${numCachePts(values)}</c:numCache></c:numRef></c:val></c:ser>`;
22410
+ }
22411
+ function scatterSer(idx, name, xvals, yvals) {
22412
+ const cl = colLetter(idx);
22413
+ return `<c:ser><c:idx val="${idx}"/><c:order val="${idx}"/><c:tx><c:strRef><c:f>Sheet1!$${cl}$1</c:f><c:strCache><c:ptCount val="1"/><c:pt idx="0"><c:v>${xmlEscape(name)}</c:v></c:pt></c:strCache></c:strRef></c:tx><c:spPr><a:ln w="28575"><a:noFill/></a:ln></c:spPr><c:marker><c:symbol val="circle"/><c:size val="7"/></c:marker><c:xVal><c:numRef><c:f>Sheet1!$A$2:$A$${xvals.length + 1}</c:f><c:numCache>${numCachePts(xvals)}</c:numCache></c:numRef></c:xVal><c:yVal><c:numRef><c:f>Sheet1!$${cl}$2:$${cl}$${yvals.length + 1}</c:f><c:numCache>${numCachePts(yvals)}</c:numCache></c:numRef></c:yVal></c:ser>`;
22414
+ }
22415
+ function catAxXml(id, pos, cross) {
22416
+ return `<c:catAx><c:axId val="${id}"/><c:scaling><c:orientation val="minMax"/></c:scaling><c:axPos val="${pos}"/><c:crossAx val="${cross}"/><c:delete val="0"/><c:majorTickMark val="out"/><c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/><c:crosses val="autoZero"/><c:auto val="1"/><c:lblAlgn val="ctr"/><c:lblOffset val="100"/><c:noMultiLvlLbl val="0"/></c:catAx>`;
22417
+ }
22418
+ function valAxXml(id, pos, cross) {
22419
+ return `<c:valAx><c:axId val="${id}"/><c:scaling><c:orientation val="minMax"/></c:scaling><c:axPos val="${pos}"/><c:majorGridlines/><c:numFmt formatCode="General" sourceLinked="1"/><c:crossAx val="${cross}"/><c:delete val="0"/><c:majorTickMark val="out"/><c:minorTickMark val="none"/><c:tickLblPos val="nextTo"/><c:crosses val="autoZero"/><c:crossBetween val="between"/></c:valAx>`;
22420
+ }
22421
+ function buildChartSpaceXml(fence) {
22422
+ const { spec, cat, series } = fence;
22423
+ const NS = 'xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"';
22424
+ const ax1 = "111111111";
22425
+ const ax2 = "222222222";
22426
+ let plot;
22427
+ if (spec.scatter) {
22428
+ const n = Math.max(0, ...series.map((s) => s.values.length));
22429
+ const xs = Array.from({ length: n }, (_, i) => {
22430
+ const c = cat[i];
22431
+ const v = Number(c);
22432
+ return c !== void 0 && c !== "" && Number.isFinite(v) ? v : i + 1;
22433
+ });
22434
+ const sers = series.map((s, i) => scatterSer(i, s.name, xs, s.values)).join("");
22435
+ plot = `<c:scatterChart><c:scatterStyle val="lineMarker"/><c:varyColors val="0"/>${sers}<c:axId val="${ax1}"/><c:axId val="${ax2}"/></c:scatterChart>` + valAxXml(ax1, "b", ax2) + valAxXml(ax2, "l", ax1);
22436
+ } else if (spec.pie) {
22437
+ const s0 = series[0];
22438
+ plot = `<c:${spec.el}><c:varyColors val="1"/>${stdSer(0, s0.name, cat, s0.values, !!spec.explode, s0.color, s0.pointColors, false, true)}<c:firstSliceAng val="0"/>` + (spec.hole != null ? `<c:holeSize val="${spec.hole}"/>` : "") + `</c:${spec.el}>`;
22439
+ } else {
22440
+ const stroke = spec.el === "lineChart" || spec.el === "radarChart" || !!spec.radar;
22441
+ const sers = series.map((s, i) => stdSer(i, s.name, cat, s.values, false, s.color, s.pointColors, stroke, false)).join("");
22442
+ const horiz = spec.dir === "bar";
22443
+ let inner = "";
22444
+ if (spec.dir) inner += `<c:barDir val="${spec.dir}"/>`;
22445
+ if (spec.grp) inner += `<c:grouping val="${spec.grp}"/>`;
22446
+ if (spec.radar) inner += `<c:radarStyle val="standard"/>`;
22447
+ inner += `<c:varyColors val="0"/>${sers}`;
22448
+ if (spec.marker) inner += `<c:marker val="1"/>`;
22449
+ if (spec.el.startsWith("bar")) inner += `<c:gapWidth val="150"/><c:overlap val="${_nullishCoalesce(spec.overlap, () => ( 0))}"/>`;
22450
+ inner += `<c:axId val="${ax1}"/><c:axId val="${ax2}"/>`;
22451
+ plot = `<c:${spec.el}>${inner}</c:${spec.el}>` + catAxXml(ax1, horiz ? "l" : "b", ax2) + valAxXml(ax2, horiz ? "b" : "l", ax1);
22452
+ }
22453
+ return `<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><c:chartSpace ${NS}><c:date1904 val="0"/><c:roundedCorners val="0"/><c:chart><c:autoTitleDeleted val="0"/><c:plotArea><c:layout/>${plot}</c:plotArea><c:legend><c:legendPos val="r"/><c:overlay val="0"/></c:legend><c:plotVisOnly val="1"/><c:dispBlanksAs val="gap"/></c:chart></c:chartSpace>`;
22454
+ }
22455
+ function buildChartElementXml(partName, widthHu, heightHu, id) {
22456
+ return `<hp:chart id="${id}" zOrder="0" numberingType="PICTURE" textWrap="TOP_AND_BOTTOM" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" chartIDRef="${partName}"><hp:sz width="${widthHu}" widthRelTo="ABSOLUTE" height="${heightHu}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="1" affectLSpacing="0" flowWithText="1" allowOverlap="0" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="PARA" vertAlign="TOP" horzAlign="LEFT" vertOffset="0" horzOffset="0"/><hp:outMargin left="709" right="709" top="709" bottom="709"/></hp:chart>`;
22457
+ }
22458
+
22060
22459
  // src/hwpx/gen-section.ts
22061
22460
  function generateSecPr(gongmun) {
22062
22461
  const m = gongmun ? {
@@ -22069,7 +22468,7 @@ function generateSecPr(gongmun) {
22069
22468
  } : { top: 8504, bottom: 4252, left: 5670, right: 4252, header: 2835, footer: 2835 };
22070
22469
  return `<hp:secPr textDirection="HORIZONTAL" spaceColumns="1134" tabStop="8000" outlineShapeIDRef="1" memoShapeIDRef="0" textVerticalWidthHead="0" masterPageCnt="0"><hp:grid lineGrid="0" charGrid="0" wonggojiFormat="0"/><hp:startNum pageStartsOn="BOTH" page="0" pic="0" tbl="0" equation="0"/><hp:visibility hideFirstHeader="0" hideFirstFooter="0" hideFirstMasterPage="0" border="SHOW_ALL" fill="SHOW_ALL" hideFirstPageNum="0" hideFirstEmptyLine="0" showLineNumber="0"/><hp:pagePr landscape="WIDELY" width="59528" height="84188" gutterType="LEFT_ONLY"><hp:margin header="${m.header}" footer="${m.footer}" gutter="0" left="${m.left}" right="${m.right}" top="${m.top}" bottom="${m.bottom}"/></hp:pagePr><hp:footNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="-1" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="283" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="EACH_COLUMN" beneathText="0"/></hp:footNotePr><hp:endNotePr><hp:autoNumFormat type="DIGIT" userChar="" prefixChar="" suffixChar=")" supscript="0"/><hp:noteLine length="14692344" type="SOLID" width="0.12 mm" color="#000000"/><hp:noteSpacing betweenNotes="0" belowLine="567" aboveLine="850"/><hp:numbering type="CONTINUOUS" newNum="1"/><hp:placement place="END_OF_DOCUMENT" beneathText="0"/></hp:endNotePr></hp:secPr>`;
22071
22470
  }
22072
- function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null) {
22471
+ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null, fit = null, chartParts = null) {
22073
22472
  const paraXmls = [];
22074
22473
  let isFirst = true;
22075
22474
  const orderedCounters = {};
@@ -22100,6 +22499,21 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
22100
22499
  break;
22101
22500
  }
22102
22501
  case "code_block": {
22502
+ if (chartParts !== null && (block.lang || "").toLowerCase() === "chart") {
22503
+ const fence = parseChartFence(block.text || "");
22504
+ if (fence) {
22505
+ const partName = `Chart/chart${chartParts.length + 1}.xml`;
22506
+ chartParts.push({ name: partName, xml: buildChartSpaceXml(fence) });
22507
+ const chartEl = buildChartElementXml(partName, fence.widthHu, fence.heightHu, 91e5 + blockIdx);
22508
+ if (isFirst) {
22509
+ const secRun = `<hp:run charPrIDRef="0">${generateSecPr(gongmun)}<hp:t></hp:t></hp:run>`;
22510
+ paraXmls.push(`<hp:p paraPrIDRef="0" styleIDRef="0">${secRun}</hp:p>`);
22511
+ isFirst = false;
22512
+ }
22513
+ xml = `<hp:p paraPrIDRef="${PARA_NORMAL}" styleIDRef="0"><hp:run charPrIDRef="${CHAR_NORMAL}">${chartEl}</hp:run></hp:p>`;
22514
+ break;
22515
+ }
22516
+ }
22103
22517
  const codeLines = (block.text || "").split("\n");
22104
22518
  xml = codeLines.map((line) => generateParagraph(line || " ", PARA_CODE)).join("\n ");
22105
22519
  break;
@@ -22123,8 +22537,8 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
22123
22537
  case "list_item": {
22124
22538
  if (gongmun && gongmunList) {
22125
22539
  const info = gongmunList.get(blockIdx);
22126
- const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _188 => _188.depth]), () => ( 0));
22127
- const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _189 => _189.marker]), () => ( ""));
22540
+ const depth = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _189 => _189.depth]), () => ( 0));
22541
+ const marker2 = _nullishCoalesce(_optionalChain([info, 'optionalAccess', _190 => _190.marker]), () => ( ""));
22128
22542
  const content = block.text || "";
22129
22543
  const text = marker2 ? `${marker2} ${content}` : content;
22130
22544
  const listCharPr = gongmun.numbering === "report" && depth === 0 ? CHAR_BOLD : CHAR_NORMAL;
@@ -22204,18 +22618,20 @@ function blocksToSectionXml(blocks, theme, gongmun, gongmunList = gongmun ? prec
22204
22618
 
22205
22619
  // src/hwpx/generator.ts
22206
22620
  async function markdownToHwpx(markdown, options) {
22207
- const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _190 => _190.theme]));
22208
- const gongmun = _optionalChain([options, 'optionalAccess', _191 => _191.gongmun]) ? resolveGongmun(options.gongmun) : null;
22621
+ const theme = resolveTheme(_optionalChain([options, 'optionalAccess', _191 => _191.theme]));
22622
+ const gongmun = _optionalChain([options, 'optionalAccess', _192 => _192.gongmun]) ? resolveGongmun(options.gongmun) : null;
22209
22623
  const blocks = parseMarkdownToBlocks(markdown);
22210
22624
  const gongmunList = gongmun ? precomputeGongmunList(blocks, gongmun) : null;
22211
22625
  const fit = gongmun && gongmunList ? computeGongmunFitPlan(blocks, gongmun, gongmunList) : null;
22212
- const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit);
22626
+ const chartParts = [];
22627
+ const sectionXml = blocksToSectionXml(blocks, theme, gongmun, gongmunList, fit, chartParts);
22213
22628
  const zip = new (0, _jszip2.default)();
22214
22629
  zip.file("mimetype", "application/hwp+zip", { compression: "STORE" });
22215
22630
  zip.file("META-INF/container.xml", generateContainerXml());
22216
- zip.file("Contents/content.hpf", generateManifest());
22217
- zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess', _192 => _192.variants]), () => ( []))));
22631
+ zip.file("Contents/content.hpf", generateManifest(chartParts));
22632
+ zip.file("Contents/header.xml", generateHeaderXml(theme, gongmun, _nullishCoalesce(_optionalChain([fit, 'optionalAccess', _193 => _193.variants]), () => ( []))));
22218
22633
  zip.file("Contents/section0.xml", sectionXml);
22634
+ for (const part of chartParts) zip.file(part.name, part.xml);
22219
22635
  zip.file("Preview/PrvText.txt", buildPrvText(blocks));
22220
22636
  return await zip.generateAsync({ type: "arraybuffer" });
22221
22637
  }
@@ -22354,6 +22770,392 @@ function diffTableCells(a, b) {
22354
22770
  return result;
22355
22771
  }
22356
22772
 
22773
+ // src/form/seal.ts
22774
+
22775
+
22776
+ // src/render/head-styles.ts
22777
+ var DEFAULT_PARA_GEOM = {
22778
+ lineSpacingType: "PERCENT",
22779
+ lineSpacingValue: 160,
22780
+ marginLeft: 0,
22781
+ marginRight: 0,
22782
+ marginIntent: 0,
22783
+ spaceBefore: 0,
22784
+ spaceAfter: 0
22785
+ };
22786
+ var DEFAULT_CHAR = { height: 1e3, bold: false, italic: false, underline: false, ratio: 100, spacing: 0 };
22787
+ function borderWidthPt(v) {
22788
+ const n = parseFloat(_nullishCoalesce(v, () => ( "")));
22789
+ if (!Number.isFinite(n)) return 0.34;
22790
+ return n * 2.834645;
22791
+ }
22792
+ function parseEdge(el) {
22793
+ if (!el) return void 0;
22794
+ const type = _nullishCoalesce(el.getAttribute("type"), () => ( "NONE"));
22795
+ if (type === "NONE") return void 0;
22796
+ return { type, widthPt: borderWidthPt(el.getAttribute("width")), color: _nullishCoalesce(el.getAttribute("color"), () => ( "#000000")) };
22797
+ }
22798
+ function findDeep(el, name, depth = 0) {
22799
+ if (depth > 32) return null;
22800
+ const children = el.childNodes;
22801
+ if (!children) return null;
22802
+ for (let i = 0; i < children.length; i++) {
22803
+ const ch = children[i];
22804
+ if (ch.nodeType !== 1) continue;
22805
+ const e = ch;
22806
+ if ((e.tagName || "").replace(/^[^:]+:/, "") === name) return e;
22807
+ const found = findDeep(e, name, depth + 1);
22808
+ if (found) return found;
22809
+ }
22810
+ return null;
22811
+ }
22812
+ function parseParaGeom(el) {
22813
+ const g = { ...DEFAULT_PARA_GEOM };
22814
+ const ls = findDeep(el, "lineSpacing");
22815
+ if (ls) {
22816
+ g.lineSpacingType = _nullishCoalesce(ls.getAttribute("type"), () => ( "PERCENT"));
22817
+ g.lineSpacingValue = Number(ls.getAttribute("value")) || 160;
22818
+ }
22819
+ const margin = findDeep(el, "margin");
22820
+ if (margin) {
22821
+ const v = (n) => {
22822
+ const c = findDeep(margin, n);
22823
+ return c ? Number(c.getAttribute("value")) || 0 : 0;
22824
+ };
22825
+ g.marginLeft = v("left");
22826
+ g.marginRight = v("right");
22827
+ g.marginIntent = v("intent");
22828
+ g.spaceBefore = v("prev");
22829
+ g.spaceAfter = v("next");
22830
+ }
22831
+ return g;
22832
+ }
22833
+ function parseRenderStyles(headXml) {
22834
+ const styles = { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
22835
+ const doc = createXmlParser().parseFromString(headXml, "text/xml");
22836
+ const root = doc.documentElement;
22837
+ if (!root) return styles;
22838
+ const walk = (el) => {
22839
+ const tag = (el.tagName || "").replace(/^[^:]+:/, "");
22840
+ if (tag === "charPr") {
22841
+ const id = el.getAttribute("id");
22842
+ if (id != null) {
22843
+ const ratioEl = findChildByLocalName(el, "ratio");
22844
+ const spacingEl = findChildByLocalName(el, "spacing");
22845
+ const underlineEl = findChildByLocalName(el, "underline");
22846
+ const textColor = el.getAttribute("textColor");
22847
+ styles.charPr.set(id, {
22848
+ height: Number(el.getAttribute("height")) || 1e3,
22849
+ bold: findChildByLocalName(el, "bold") != null,
22850
+ italic: findChildByLocalName(el, "italic") != null,
22851
+ underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
22852
+ color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
22853
+ ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _194 => _194.getAttribute, 'call', _195 => _195("hangul")])) || 100,
22854
+ spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _196 => _196.getAttribute, 'call', _197 => _197("hangul")])) || 0
22855
+ });
22856
+ }
22857
+ } else if (tag === "paraPr") {
22858
+ const id = el.getAttribute("id");
22859
+ if (id != null) {
22860
+ const align = findChildByLocalName(el, "align");
22861
+ styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _198 => _198.getAttribute, 'call', _199 => _199("horizontal")]) || "JUSTIFY");
22862
+ styles.paraGeom.set(id, parseParaGeom(el));
22863
+ }
22864
+ } else if (tag === "borderFill") {
22865
+ const id = el.getAttribute("id");
22866
+ if (id != null) {
22867
+ const bf = {
22868
+ left: parseEdge(findChildByLocalName(el, "leftBorder")),
22869
+ right: parseEdge(findChildByLocalName(el, "rightBorder")),
22870
+ top: parseEdge(findChildByLocalName(el, "topBorder")),
22871
+ bottom: parseEdge(findChildByLocalName(el, "bottomBorder"))
22872
+ };
22873
+ const fillBrush = findChildByLocalName(el, "fillBrush");
22874
+ const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
22875
+ const face = _optionalChain([winBrush, 'optionalAccess', _200 => _200.getAttribute, 'call', _201 => _201("faceColor")]);
22876
+ if (face && face.toLowerCase() !== "none") bf.fill = face;
22877
+ styles.borderFill.set(id, bf);
22878
+ }
22879
+ }
22880
+ const children = el.childNodes;
22881
+ for (let i = 0; i < children.length; i++) {
22882
+ const ch = children[i];
22883
+ if (ch.nodeType === 1) walk(ch);
22884
+ }
22885
+ };
22886
+ walk(root);
22887
+ return styles;
22888
+ }
22889
+
22890
+ // src/form/seal.ts
22891
+ var HU_PER_MM2 = 7200 / 25.4;
22892
+ var mm2hu = (mm) => Math.round(mm * HU_PER_MM2);
22893
+ var MIME = {
22894
+ png: "image/png",
22895
+ jpg: "image/jpeg",
22896
+ jpeg: "image/jpeg",
22897
+ bmp: "image/bmp",
22898
+ gif: "image/gif"
22899
+ };
22900
+ function glyphEm(code) {
22901
+ if (code < 32) return 0;
22902
+ if (code <= 126) return 0.5;
22903
+ if (code >= 65377 && code <= 65500) return 0.5;
22904
+ return 1;
22905
+ }
22906
+ function measureMm(text, emMm) {
22907
+ let w = 0;
22908
+ for (const ch of text) w += glyphEm(_nullishCoalesce(ch.codePointAt(0), () => ( 0))) * emMm;
22909
+ return w;
22910
+ }
22911
+ function collectSites(scan) {
22912
+ const sites = [];
22913
+ for (const p of scan.bodyParagraphs) sites.push({ para: p });
22914
+ const walkTables = (tables, depth) => {
22915
+ if (depth > 16) return;
22916
+ for (const t of tables) {
22917
+ for (const row of t.rows) {
22918
+ for (const cell of row) {
22919
+ for (const p of cell.paragraphs) sites.push({ para: p, cell, table: t });
22920
+ walkTables(cell.tables, depth + 1);
22921
+ }
22922
+ }
22923
+ }
22924
+ };
22925
+ walkTables(scan.tables, 0);
22926
+ walkTables(scan.orphanTables, 0);
22927
+ sites.sort((a, b) => a.para.start - b.para.start);
22928
+ return sites;
22929
+ }
22930
+ function attrOf(openTag, name) {
22931
+ const m = openTag.match(new RegExp(`\\b${name}="([^"]*)"`));
22932
+ return _optionalChain([m, 'optionalAccess', _202 => _202[1]]);
22933
+ }
22934
+ function paraOpenTag(xml, para) {
22935
+ const end = xml.indexOf(">", para.start);
22936
+ return end === -1 ? "" : xml.slice(para.start, end + 1);
22937
+ }
22938
+ function anchorRunInfo(xml, para, anchor) {
22939
+ let tr = para.tRanges.find((r) => !r.selfClosing && xml.slice(r.contentStart, r.contentEnd).includes(anchor));
22940
+ if (!tr) tr = para.tRanges[para.tRanges.length - 1];
22941
+ if (!tr) return null;
22942
+ const before = xml.slice(Math.max(0, para.start), tr.contentStart);
22943
+ const runOpen = [...before.matchAll(/<([A-Za-z0-9]+):run\b[^>]*>/g)].pop();
22944
+ const prefix = _nullishCoalesce(_nullishCoalesce(_optionalChain([runOpen, 'optionalAccess', _203 => _203[1]]), () => ( tr.prefix)), () => ( "hp"));
22945
+ const charPr2 = runOpen && attrOf(runOpen[0], "charPrIDRef") || "0";
22946
+ const close = xml.indexOf(`</${prefix}:run>`, tr.contentEnd);
22947
+ if (close === -1) return null;
22948
+ return { charPr: charPr2, prefix, insertAt: close + `</${prefix}:run>`.length };
22949
+ }
22950
+ function cellAddrWindow(xml, cell) {
22951
+ if (!cell.addrTagRange) return null;
22952
+ return xml.slice(cell.addrTagRange.end, cell.addrTagRange.end + 400);
22953
+ }
22954
+ function cellSzWidthHu(xml, cell) {
22955
+ const win = cellAddrWindow(xml, cell);
22956
+ if (win) {
22957
+ const m = win.match(/<[A-Za-z0-9]+:cellSz\b[^>]*\bwidth="(\d+)"/);
22958
+ if (m) return Number(m[1]);
22959
+ }
22960
+ const firstPara = cell.paragraphs[0];
22961
+ if (!firstPara) return null;
22962
+ const upto = xml.slice(0, firstPara.start);
22963
+ const szMatch = [...upto.matchAll(/<[A-Za-z0-9]+:cellSz\b[^>]*\bwidth="(\d+)"[^>]*>/g)].pop();
22964
+ return szMatch ? Number(szMatch[1]) : null;
22965
+ }
22966
+ function cellContentWidthMm(xml, cell) {
22967
+ const width = cellSzWidthHu(xml, cell);
22968
+ if (width === null) return null;
22969
+ let content = width;
22970
+ const win = cellAddrWindow(xml, cell);
22971
+ const mg = _optionalChain([win, 'optionalAccess', _204 => _204.match, 'call', _205 => _205(/<[A-Za-z0-9]+:cellMargin\b[^>]*>/)]);
22972
+ if (mg) {
22973
+ content -= Number(_nullishCoalesce(attrOf(mg[0], "left"), () => ( 0))) + Number(_nullishCoalesce(attrOf(mg[0], "right"), () => ( 0)));
22974
+ }
22975
+ return content > 0 ? content / HU_PER_MM2 : null;
22976
+ }
22977
+ function cellLeftOffsetMm(xml, table, cell) {
22978
+ if (cell.colAddr === void 0) return 0;
22979
+ const row = table.rows.find((r) => r.includes(cell));
22980
+ if (!row) return 0;
22981
+ let sum = 0;
22982
+ for (const c of row) {
22983
+ if (c === cell || c.colAddr === void 0 || c.colAddr >= cell.colAddr) continue;
22984
+ const w = cellSzWidthHu(xml, c);
22985
+ if (w) sum += w;
22986
+ }
22987
+ return sum / HU_PER_MM2;
22988
+ }
22989
+ function bodyColumnWidthMm(xml) {
22990
+ const page = xml.match(/<[A-Za-z0-9]+:pagePr\b[^>]*\bwidth="(\d+)"[^>]*>/);
22991
+ const margin = xml.match(/<[A-Za-z0-9]+:margin\b[^>]*\bleft="(\d+)"[^>]*\bright="(\d+)"[^>]*>/);
22992
+ if (!page) return 150;
22993
+ const w = Number(page[1]) - (margin ? Number(margin[1]) + Number(margin[2]) : 0);
22994
+ return w > 0 ? w / HU_PER_MM2 : 150;
22995
+ }
22996
+ function buildFloatPicXml(itemId, sizeHu, posXHu, posYHu, ids) {
22997
+ const w = sizeHu;
22998
+ const h = sizeHu;
22999
+ return `<hp:pic xmlns:hc="http://www.hancom.co.kr/hwpml/2011/core" id="${ids.id}" zOrder="0" numberingType="PICTURE" textWrap="IN_FRONT_OF_TEXT" textFlow="BOTH_SIDES" lock="0" dropcapstyle="None" href="" groupLevel="0" instid="${ids.instid}" reverse="0"><hp:offset x="0" y="0"/><hp:orgSz width="${w}" height="${h}"/><hp:curSz width="${w}" height="${h}"/><hp:flip horizontal="0" vertical="0"/><hp:rotationInfo angle="0" centerX="${Math.round(w / 2)}" centerY="${Math.round(h / 2)}" rotateimage="1"/><hp:renderingInfo><hc:transMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:scaMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/><hc:rotMatrix e1="1" e2="0" e3="0" e4="0" e5="1" e6="0"/></hp:renderingInfo><hp:imgRect><hc:pt0 x="0" y="0"/><hc:pt1 x="${w}" y="0"/><hc:pt2 x="${w}" y="${h}"/><hc:pt3 x="0" y="${h}"/></hp:imgRect><hp:imgClip left="0" right="${w}" top="0" bottom="${h}"/><hp:inMargin left="0" right="0" top="0" bottom="0"/><hp:imgDim dimwidth="${w}" dimheight="${h}"/><hc:img binaryItemIDRef="${itemId}" bright="0" contrast="0" effect="REAL_PIC" alpha="0"/><hp:effects/><hp:sz width="${w}" widthRelTo="ABSOLUTE" height="${h}" heightRelTo="ABSOLUTE" protect="0"/><hp:pos treatAsChar="0" affectLSpacing="0" flowWithText="0" allowOverlap="1" holdAnchorAndSO="0" vertRelTo="PARA" horzRelTo="COLUMN" vertAlign="TOP" horzAlign="LEFT" vertOffset="${posYHu}" horzOffset="${posXHu}"/><hp:outMargin left="0" right="0" top="0" bottom="0"/><hp:shapeComment>kordoc seal</hp:shapeComment></hp:pic>`;
23000
+ }
23001
+ async function placeSealHwpx(hwpxBuffer, ops) {
23002
+ if (ops.length === 0) throw new (0, _chunkBIP4JAVGcjs.KordocError)("place_seal: \uBC30\uCE58\uD560 \uB3C4\uC7A5\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
23003
+ const u8 = new Uint8Array(hwpxBuffer);
23004
+ const zip = await _jszip2.default.loadAsync(hwpxBuffer);
23005
+ const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
23006
+ if (sectionPaths.length === 0) throw new (0, _chunkBIP4JAVGcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
23007
+ const manifestPath = Object.keys(zip.files).find((name) => /\.hpf$/i.test(name));
23008
+ const headerPath = Object.keys(zip.files).find((name) => /(^|\/)header\.xml$/i.test(name));
23009
+ const styles = headerPath ? parseRenderStyles(await zip.file(headerPath).async("text")) : null;
23010
+ const sectionXmls = [];
23011
+ const scans = [];
23012
+ for (let si = 0; si < sectionPaths.length; si++) {
23013
+ const xml = await zip.file(sectionPaths[si]).async("text");
23014
+ sectionXmls.push(xml);
23015
+ scans.push(scanSectionXml(xml, si));
23016
+ }
23017
+ const sitesBySection = scans.map(collectSites);
23018
+ const usedIds = /* @__PURE__ */ new Set();
23019
+ let manifestXml = "";
23020
+ if (manifestPath) {
23021
+ manifestXml = await zip.file(manifestPath).async("text");
23022
+ for (const m of manifestXml.matchAll(/<opf:item\b[^>]*\bid="([^"]+)"/g)) usedIds.add(m[1]);
23023
+ }
23024
+ const usedImageNums = /* @__PURE__ */ new Set();
23025
+ for (const name of Object.keys(zip.files)) {
23026
+ const m = name.match(/^BinData\/(?:image|img)(\d+)\./i);
23027
+ if (m) usedImageNums.add(Number(m[1]));
23028
+ }
23029
+ const nextImageNum = () => {
23030
+ let n = 1;
23031
+ while (usedImageNums.has(n) || usedIds.has(`image${n}`)) n++;
23032
+ usedImageNums.add(n);
23033
+ return n;
23034
+ };
23035
+ let maxId = 1e6;
23036
+ for (const xml of sectionXmls) {
23037
+ for (const m of xml.matchAll(/\b(?:id|instid)="(\d+)"/g)) {
23038
+ const v = Number(m[1]);
23039
+ if (Number.isFinite(v) && v > maxId) maxId = v;
23040
+ }
23041
+ }
23042
+ const splicesBySection = sectionPaths.map(() => []);
23043
+ const additions = /* @__PURE__ */ new Map();
23044
+ const manifestItems = [];
23045
+ const placed = [];
23046
+ for (const op of ops) {
23047
+ if (!op.anchor) throw new (0, _chunkBIP4JAVGcjs.KordocError)("place_seal: anchor \uBB38\uAD6C\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
23048
+ if (!op.image || op.image.length === 0) throw new (0, _chunkBIP4JAVGcjs.KordocError)("place_seal: \uB3C4\uC7A5 \uC774\uBBF8\uC9C0\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4");
23049
+ const ext = (_nullishCoalesce(op.ext, () => ( "png"))).toLowerCase();
23050
+ if (!MIME[ext]) throw new (0, _chunkBIP4JAVGcjs.KordocError)(`place_seal: \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC774\uBBF8\uC9C0 \uD655\uC7A5\uC790 .${ext} (png/jpg/bmp/gif)`);
23051
+ const wantOcc = _nullishCoalesce(op.occurrence, () => ( 0));
23052
+ let found = null;
23053
+ let total = 0;
23054
+ for (let si2 = 0; si2 < scans.length && !found; si2++) {
23055
+ for (const site2 of sitesBySection[si2]) {
23056
+ let from = 0;
23057
+ for (; ; ) {
23058
+ const idx = site2.para.text.indexOf(op.anchor, from);
23059
+ if (idx === -1) break;
23060
+ if (total === wantOcc) {
23061
+ found = { si: si2, site: site2, idxInText: idx };
23062
+ break;
23063
+ }
23064
+ total++;
23065
+ from = idx + op.anchor.length;
23066
+ }
23067
+ if (found) break;
23068
+ }
23069
+ }
23070
+ if (!found) {
23071
+ total = 0;
23072
+ for (let si2 = 0; si2 < scans.length; si2++) {
23073
+ for (const site2 of sitesBySection[si2]) {
23074
+ let from = 0;
23075
+ for (; ; ) {
23076
+ const idx = site2.para.text.indexOf(op.anchor, from);
23077
+ if (idx === -1) break;
23078
+ total++;
23079
+ from = idx + op.anchor.length;
23080
+ }
23081
+ }
23082
+ }
23083
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)(
23084
+ `place_seal: \uC575\uCEE4 "${op.anchor}" ${wantOcc}\uBC88\uC9F8 \uB4F1\uC7A5\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4 (\uBCF8\uBB38 \uB0B4 ${total}\uD68C \uB4F1\uC7A5 \u2014 occurrence 0..${Math.max(0, total - 1)})`
23085
+ );
23086
+ }
23087
+ const { si, site, idxInText } = found;
23088
+ const xml = sectionXmls[si];
23089
+ const run = anchorRunInfo(xml, site.para, op.anchor);
23090
+ if (!run) {
23091
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)(`place_seal: \uC575\uCEE4 "${op.anchor}" \uBB38\uB2E8\uC5D0\uC11C run\uC744 \uCC3E\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4`);
23092
+ }
23093
+ const charPrHeight = _nullishCoalesce(_optionalChain([styles, 'optionalAccess', _206 => _206.charPr, 'access', _207 => _207.get, 'call', _208 => _208(run.charPr), 'optionalAccess', _209 => _209.height]), () => ( 1e3));
23094
+ const fontPt = charPrHeight / 100;
23095
+ const emMm = fontPt * 25.4 / 72;
23096
+ const lineHMm = emMm;
23097
+ const startXMm = measureMm(site.para.text.slice(0, idxInText), emMm);
23098
+ const anchorWMm = measureMm(op.anchor, emMm);
23099
+ const sizeMm = _nullishCoalesce(op.sizeMm, () => ( Math.max(7, Math.min(18, lineHMm * 1.6))));
23100
+ const availMm = _nullishCoalesce((site.cell ? cellContentWidthMm(xml, site.cell) : null), () => ( bodyColumnWidthMm(xml)));
23101
+ const paraPrId = _nullishCoalesce(attrOf(paraOpenTag(xml, site.para), "paraPrIDRef"), () => ( "0"));
23102
+ const align = _optionalChain([styles, 'optionalAccess', _210 => _210.paraAlign, 'access', _211 => _211.get, 'call', _212 => _212(paraPrId)]);
23103
+ let alignShiftMm = 0;
23104
+ if (align === "CENTER" || align === "RIGHT") {
23105
+ const paraWMm = measureMm(site.para.text, emMm);
23106
+ alignShiftMm = align === "CENTER" ? (availMm - paraWMm) / 2 : availMm - paraWMm;
23107
+ if (!Number.isFinite(alignShiftMm) || alignShiftMm < 0) alignShiftMm = 0;
23108
+ }
23109
+ let mode = _nullishCoalesce(op.mode, () => ( "auto"));
23110
+ if (mode === "auto") {
23111
+ mode = availMm - (alignShiftMm + startXMm + anchorWMm) >= sizeMm + 2 ? "right" : "overlap";
23112
+ }
23113
+ const cellShiftMm = site.cell && site.table ? cellLeftOffsetMm(xml, site.table, site.cell) : 0;
23114
+ const posXMm = (mode === "right" ? startXMm + anchorWMm + 2 : startXMm + anchorWMm / 2 - sizeMm / 2) + alignShiftMm + cellShiftMm + (_nullishCoalesce(op.dxMm, () => ( 0)));
23115
+ const posYMm = -(sizeMm - lineHMm) / 2 + (_nullishCoalesce(op.dyMm, () => ( 0)));
23116
+ const n = nextImageNum();
23117
+ const entry = `BinData/image${n}.${ext}`;
23118
+ const itemId = `image${n}`;
23119
+ usedIds.add(itemId);
23120
+ additions.set(entry, op.image);
23121
+ manifestItems.push(`<opf:item id="${itemId}" href="${entry}" media-type="${MIME[ext]}" isEmbeded="1"/>`);
23122
+ const pic = buildFloatPicXml(itemId, mm2hu(sizeMm), mm2hu(posXMm), mm2hu(posYMm), {
23123
+ id: ++maxId,
23124
+ instid: ++maxId
23125
+ });
23126
+ splicesBySection[si].push({
23127
+ start: run.insertAt,
23128
+ end: run.insertAt,
23129
+ replacement: `<${run.prefix}:run charPrIDRef="${run.charPr}">${pic}</${run.prefix}:run>`
23130
+ });
23131
+ placed.push({
23132
+ anchor: op.anchor,
23133
+ occurrence: wantOcc,
23134
+ sectionIndex: si,
23135
+ mode,
23136
+ posXMm: Math.round(posXMm * 100) / 100,
23137
+ posYMm: Math.round(posYMm * 100) / 100,
23138
+ sizeMm: Math.round(sizeMm * 100) / 100,
23139
+ entry
23140
+ });
23141
+ }
23142
+ const encoder = new TextEncoder();
23143
+ const replacements = /* @__PURE__ */ new Map();
23144
+ for (let si = 0; si < sectionPaths.length; si++) {
23145
+ if (splicesBySection[si].length === 0) continue;
23146
+ replacements.set(sectionPaths[si], encoder.encode(applySplices(sectionXmls[si], splicesBySection[si])));
23147
+ }
23148
+ if (manifestPath && manifestItems.length > 0) {
23149
+ const patched = manifestXml.includes("</opf:manifest>") ? manifestXml.replace("</opf:manifest>", `${manifestItems.join("")}</opf:manifest>`) : manifestXml;
23150
+ if (patched !== manifestXml) replacements.set(manifestPath, encoder.encode(patched));
23151
+ }
23152
+ const out = patchZipEntries(u8, replacements, additions);
23153
+ return {
23154
+ buffer: out.buffer.slice(out.byteOffset, out.byteOffset + out.byteLength),
23155
+ placed
23156
+ };
23157
+ }
23158
+
22357
23159
  // src/roundtrip/patcher.ts
22358
23160
 
22359
23161
 
@@ -22362,7 +23164,7 @@ var ROW_OBJECT_RE = /<(?:[A-Za-z0-9_]+:)?(?:tbl|pic|equation|ole|container|shape
22362
23164
  var TAG_AT_RE = /<[A-Za-z0-9_:]+(?:"[^"]*"|'[^']*'|[^>"'])*>/y;
22363
23165
  function patchTableRows(input) {
22364
23166
  const { table, scanTable, ctx, skip, origKeys, editedKeys } = input;
22365
- const xml = _optionalChain([ctx, 'access', _193 => _193.scans, 'access', _194 => _194[scanTable.sectionIndex], 'optionalAccess', _195 => _195.xml]);
23167
+ const xml = _optionalChain([ctx, 'access', _213 => _213.scans, 'access', _214 => _214[scanTable.sectionIndex], 'optionalAccess', _215 => _215.xml]);
22366
23168
  if (!xml) return skip("\uC139\uC158 XML \uB9E4\uD551 \uC2E4\uD328");
22367
23169
  const numRows = table.rows;
22368
23170
  if (origKeys.length !== numRows) return skip("\uD45C \uD589 \uC88C\uD45C \uBD88\uC77C\uCE58 \u2014 \uD589 \uCD94\uAC00/\uC0AD\uC81C \uBBF8\uC9C0\uC6D0");
@@ -22529,7 +23331,7 @@ function buildRowFragment(xml, scanTable, template, cells, finalRow, hasExplicit
22529
23331
  const rr = scanTable.rowRanges[template];
22530
23332
  const wrapped = FRAG_OPEN + xml.slice(rr.start, rr.end) + FRAG_CLOSE;
22531
23333
  const scan = scanSectionXml(wrapped, 0);
22532
- const row = _optionalChain([scan, 'access', _196 => _196.tables, 'access', _197 => _197[0], 'optionalAccess', _198 => _198.rows, 'access', _199 => _199[0]]);
23334
+ const row = _optionalChain([scan, 'access', _216 => _216.tables, 'access', _217 => _217[0], 'optionalAccess', _218 => _218.rows, 'access', _219 => _219[0]]);
22533
23335
  if (!row || row.length !== cells.length) return null;
22534
23336
  const splices = allLinesegRemovalSplices(wrapped);
22535
23337
  for (let i = 0; i < cells.length; i++) {
@@ -22572,7 +23374,7 @@ function rowHeightOf(fragment) {
22572
23374
  }
22573
23375
  function tableSzHeightSplice(xml, scanTable, tblOpenLen, delta) {
22574
23376
  const from = scanTable.start + tblOpenLen;
22575
- const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _200 => _200.rowRanges, 'access', _201 => _201[0], 'optionalAccess', _202 => _202.start]), () => ( from));
23377
+ const to = _nullishCoalesce(_optionalChain([scanTable, 'access', _220 => _220.rowRanges, 'access', _221 => _221[0], 'optionalAccess', _222 => _222.start]), () => ( from));
22576
23378
  const slice = xml.slice(from, to);
22577
23379
  const szM = slice.match(/<(?:[A-Za-z0-9_]+:)?sz\b(?:"[^"]*"|'[^']*'|[^>"'])*>/);
22578
23380
  if (!szM || szM.index === void 0) return null;
@@ -22761,9 +23563,9 @@ function patchHtmlTableRows(table, scanTable, replica, editedRows, ctx, skip, de
22761
23563
  });
22762
23564
  }
22763
23565
  function patchNestedTables(table, scanTable, oc, origTables, editedTables, ctx, skip, depth) {
22764
- const irCell = _optionalChain([table, 'access', _203 => _203.cells, 'access', _204 => _204[oc.gridR], 'optionalAccess', _205 => _205[oc.gridC]]);
23566
+ const irCell = _optionalChain([table, 'access', _223 => _223.cells, 'access', _224 => _224[oc.gridR], 'optionalAccess', _225 => _225[oc.gridC]]);
22765
23567
  const scanCell = scanTable.cellByAnchor.get(`${oc.gridR},${oc.gridC}`);
22766
- const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _206 => _206.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
23568
+ const nestedIRs = (_nullishCoalesce(_optionalChain([irCell, 'optionalAccess', _226 => _226.blocks]), () => ( []))).filter((b) => b.type === "table" && b.table).map((b) => b.table);
22767
23569
  if (!scanCell || nestedIRs.length !== origTables.length || scanCell.tables.length !== origTables.length) {
22768
23570
  return skip("\uC911\uCCA9\uD45C \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328");
22769
23571
  }
@@ -22831,7 +23633,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
22831
23633
  };
22832
23634
  const cell = scanTable.cellByAnchor.get(`${gridR},${gridC}`);
22833
23635
  if (!cell) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
22834
- const irCell = _optionalChain([table, 'access', _207 => _207.cells, 'access', _208 => _208[gridR], 'optionalAccess', _209 => _209[gridC]]);
23636
+ const irCell = _optionalChain([table, 'access', _227 => _227.cells, 'access', _228 => _228[gridR], 'optionalAccess', _229 => _229[gridC]]);
22835
23637
  const scanJoined = cell.paragraphs.map((p) => p.text).filter((t) => normForMatch(t)).join("\n");
22836
23638
  if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
22837
23639
  if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
@@ -22854,7 +23656,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
22854
23656
  if (newLines.length === 0) return 0;
22855
23657
  const target = cell.paragraphs[0];
22856
23658
  if (!target) return skip("\uBE48 \uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC5B4 \uD14D\uC2A4\uD2B8 \uC0BD\uC785 \uBD88\uAC00");
22857
- const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _210 => _210.scans, 'access', _211 => _211[target.sectionIndex], 'optionalAccess', _212 => _212.xml]));
23659
+ const sp = buildParagraphSplices(target, newLines.join(" "), _optionalChain([ctx, 'access', _230 => _230.scans, 'access', _231 => _231[target.sectionIndex], 'optionalAccess', _232 => _232.xml]));
22858
23660
  if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
22859
23661
  splices.push(...sp);
22860
23662
  sectionIndex = target.sectionIndex;
@@ -22877,7 +23679,7 @@ function applyCellEdit(table, scanTable, gridR, gridC, newLines, ctx, before, af
22877
23679
  }
22878
23680
  for (let i = 0; i < nonEmpty.length; i++) {
22879
23681
  if (assigned[i] === nonEmpty[i].text || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].text)) continue;
22880
- const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _213 => _213.scans, 'access', _214 => _214[nonEmpty[i].sectionIndex], 'optionalAccess', _215 => _215.xml]));
23682
+ const sp = buildParagraphSplices(nonEmpty[i], assigned[i], _optionalChain([ctx, 'access', _233 => _233.scans, 'access', _234 => _234[nonEmpty[i].sectionIndex], 'optionalAccess', _235 => _235.xml]));
22881
23683
  if (sp === null) return skip("\uC140 \uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
22882
23684
  splices.push(...sp);
22883
23685
  sectionIndex = nonEmpty[i].sectionIndex;
@@ -22958,7 +23760,7 @@ async function resolveSectionEntryNames(zip) {
22958
23760
  const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
22959
23761
  if (paths.length > 0) return paths;
22960
23762
  }
22961
- return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkMEXUFQVCcjs.compareSectionPaths);
23763
+ return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkBIP4JAVGcjs.compareSectionPaths);
22962
23764
  }
22963
23765
  function sectionPathsFromManifest(xml) {
22964
23766
  const attr = (tag, name) => {
@@ -22968,7 +23770,7 @@ function sectionPathsFromManifest(xml) {
22968
23770
  const idToHref = /* @__PURE__ */ new Map();
22969
23771
  for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
22970
23772
  const id = attr(m[1], "id");
22971
- const href = _chunkMEXUFQVCcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
23773
+ const href = _chunkBIP4JAVGcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
22972
23774
  if (id && href) idToHref.set(id, href);
22973
23775
  }
22974
23776
  const ordered = [];
@@ -22977,7 +23779,7 @@ function sectionPathsFromManifest(xml) {
22977
23779
  if (href) ordered.push(href);
22978
23780
  }
22979
23781
  if (ordered.length > 0) return ordered;
22980
- return Array.from(idToHref.values()).sort(_chunkMEXUFQVCcjs.compareSectionPaths);
23782
+ return Array.from(idToHref.values()).sort(_chunkBIP4JAVGcjs.compareSectionPaths);
22981
23783
  }
22982
23784
 
22983
23785
  // src/roundtrip/patcher.ts
@@ -23069,7 +23871,7 @@ async function patchHwpx(original, editedMarkdown, options) {
23069
23871
  }
23070
23872
  }
23071
23873
  let verification;
23072
- if (_optionalChain([options, 'optionalAccess', _216 => _216.verify]) !== false) {
23874
+ if (_optionalChain([options, 'optionalAccess', _236 => _236.verify]) !== false) {
23073
23875
  try {
23074
23876
  const reparsed = await parseHwpxDocument(u8ToArrayBuffer(data));
23075
23877
  verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
@@ -23087,17 +23889,17 @@ function buildOrigUnits(blocks) {
23087
23889
  let chunk;
23088
23890
  if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
23089
23891
  const next = blocks[i + 1];
23090
- if (_optionalChain([next, 'optionalAccess', _217 => _217.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
23091
- chunk = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
23892
+ if (_optionalChain([next, 'optionalAccess', _237 => _237.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
23893
+ chunk = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
23092
23894
  } else {
23093
- chunk = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, [block]);
23895
+ chunk = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, [block]);
23094
23896
  }
23095
23897
  if (chunk) {
23096
23898
  const subUnits = splitMarkdownUnits(chunk);
23097
23899
  const isFragment = consume === 2 || (block.type === "paragraph" || block.type === "heading") && subUnits.length > 1;
23098
23900
  for (let s = 0; s < subUnits.length; s++) {
23099
23901
  const u = { ...subUnits[s], blockIdx: i, fragment: isFragment || void 0 };
23100
- if (block.type === "table" && _optionalChain([block, 'access', _218 => _218.table, 'optionalAccess', _219 => _219.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
23902
+ if (block.type === "table" && _optionalChain([block, 'access', _238 => _238.table, 'optionalAccess', _239 => _239.caption]) && s === 0 && subUnits.length > 1 && u.kind === "text" && u.raw.startsWith("**")) {
23101
23903
  u.role = "caption";
23102
23904
  }
23103
23905
  units.push(u);
@@ -23208,7 +24010,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
23208
24010
  const ti = ctx.tableInsert;
23209
24011
  if (!ti) return skip("\uBB38\uB2E8\u2192\uD45C \uBCC0\uD658 \uBD88\uAC00 \u2014 header \uC5D4\uD2B8\uB9AC(borderFills) \uD574\uC11D \uC2E4\uD328");
23210
24012
  const mapping = ctx.paraMap.get(orig.blockIdx);
23211
- if (!_optionalChain([mapping, 'optionalAccess', _220 => _220.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED) \u2014 \uD45C \uBCC0\uD658 \uBD88\uAC00");
24013
+ if (!_optionalChain([mapping, 'optionalAccess', _240 => _240.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED) \u2014 \uD45C \uBCC0\uD658 \uBD88\uAC00");
23212
24014
  const para = mapping.para;
23213
24015
  if (para.kind !== "body") return skip("\uBCF8\uBB38 \uC678 \uC601\uC5ED(\uD45C \uC140/\uAE00\uC0C1\uC790) \uBB38\uB2E8\uC758 \uD45C \uBCC0\uD658\uC740 \uBBF8\uC9C0\uC6D0");
23214
24016
  const scan = ctx.scans[para.sectionIndex];
@@ -23236,7 +24038,7 @@ function convertParagraphToTable(block, orig, edited, ctx, skip) {
23236
24038
  }
23237
24039
  function patchParagraphUnit(block, orig, edited, ctx, skip) {
23238
24040
  const mapping = ctx.paraMap.get(orig.blockIdx);
23239
- if (!_optionalChain([mapping, 'optionalAccess', _221 => _221.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
24041
+ if (!_optionalChain([mapping, 'optionalAccess', _241 => _241.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
23240
24042
  if (block.text && block.text.includes("\n")) {
23241
24043
  return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
23242
24044
  }
@@ -23267,7 +24069,7 @@ function patchParagraphUnit(block, orig, edited, ctx, skip) {
23267
24069
  if (sanitizeText(newPlain) !== newPlain) {
23268
24070
  return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
23269
24071
  }
23270
- const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _222 => _222.scans, 'access', _223 => _223[mapping.para.sectionIndex], 'optionalAccess', _224 => _224.xml]));
24072
+ const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([ctx, 'access', _242 => _242.scans, 'access', _243 => _243[mapping.para.sectionIndex], 'optionalAccess', _244 => _244.xml]));
23271
24073
  if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
23272
24074
  ctx.sectionSplices[mapping.para.sectionIndex].push(...splices);
23273
24075
  return 1;
@@ -23453,7 +24255,7 @@ var Surgeon = (_class4 = class {
23453
24255
  /** 디렉토리 트리에서 경로 해석 (형제 = L/R 이진 트리, 자식 = child) */
23454
24256
  findEntry(path) {
23455
24257
  const parts = path.replace(/^\//, "").split("/");
23456
- let scope = _nullishCoalesce(_optionalChain([this, 'access', _225 => _225.entries, 'access', _226 => _226[0], 'optionalAccess', _227 => _227.child]), () => ( -1));
24258
+ let scope = _nullishCoalesce(_optionalChain([this, 'access', _245 => _245.entries, 'access', _246 => _246[0], 'optionalAccess', _247 => _247.child]), () => ( -1));
23457
24259
  let current;
23458
24260
  for (const part of parts) {
23459
24261
  const search = (idx) => {
@@ -23666,8 +24468,8 @@ function serializeRecords(recs, repl, inserts) {
23666
24468
  parts.push(header, data);
23667
24469
  };
23668
24470
  for (let i = 0; i < recs.length; i++) {
23669
- for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _228 => _228.get, 'call', _229 => _229(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
23670
- push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _230 => _230.get, 'call', _231 => _231(i)]), () => ( recs[i].data)));
24471
+ for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _248 => _248.get, 'call', _249 => _249(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
24472
+ push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _250 => _250.get, 'call', _251 => _251(i)]), () => ( recs[i].data)));
23671
24473
  }
23672
24474
  return Buffer.concat(parts);
23673
24475
  }
@@ -23785,7 +24587,7 @@ async function patchHwp(original, editedMarkdown, options) {
23785
24587
  return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
23786
24588
  }
23787
24589
  const fhEntry = CFB2.find(cfb, "/FileHeader");
23788
- if (!_optionalChain([fhEntry, 'optionalAccess', _232 => _232.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
24590
+ if (!_optionalChain([fhEntry, 'optionalAccess', _252 => _252.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
23789
24591
  let flags;
23790
24592
  try {
23791
24593
  flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
@@ -23807,7 +24609,7 @@ async function patchHwp(original, editedMarkdown, options) {
23807
24609
  const scans = [];
23808
24610
  for (let i = 0; i < sectionPaths.length; i++) {
23809
24611
  const entry = CFB2.find(cfb, sectionPaths[i]);
23810
- if (!_optionalChain([entry, 'optionalAccess', _233 => _233.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
24612
+ if (!_optionalChain([entry, 'optionalAccess', _253 => _253.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
23811
24613
  let stream;
23812
24614
  try {
23813
24615
  stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
@@ -23858,7 +24660,7 @@ async function patchHwp(original, editedMarkdown, options) {
23858
24660
  }
23859
24661
  }
23860
24662
  let verification;
23861
- if (_optionalChain([options, 'optionalAccess', _234 => _234.verify]) !== false) {
24663
+ if (_optionalChain([options, 'optionalAccess', _254 => _254.verify]) !== false) {
23862
24664
  try {
23863
24665
  const reparsed = parseHwp5Document(Buffer.from(data));
23864
24666
  verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
@@ -23947,7 +24749,7 @@ function tableContentScore(irTable, scanTable) {
23947
24749
  for (const [key, scanCell] of scanTable.cells) {
23948
24750
  const comma = key.indexOf(",");
23949
24751
  const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
23950
- const irCell = _optionalChain([irTable, 'access', _235 => _235.cells, 'access', _236 => _236[r], 'optionalAccess', _237 => _237[c]]);
24752
+ const irCell = _optionalChain([irTable, 'access', _255 => _255.cells, 'access', _256 => _256[r], 'optionalAccess', _257 => _257[c]]);
23951
24753
  if (!irCell) continue;
23952
24754
  const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
23953
24755
  const b = normForMatch(stripCellTokens(irCell.text));
@@ -23983,11 +24785,12 @@ function handleModified(orig, edited, ctx) {
23983
24785
  }
23984
24786
  function patchParagraph(block, orig, edited, ctx, skip) {
23985
24787
  const mapping = ctx.paraMap.get(orig.blockIdx);
23986
- if (!_optionalChain([mapping, 'optionalAccess', _238 => _238.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
23987
- if (block.text && block.text.includes("\n")) {
23988
- return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
24788
+ if (!_optionalChain([mapping, 'optionalAccess', _258 => _258.para])) return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
24789
+ const restoreBr = (s) => s.replace(/\s*<br\s*\/?\s*>\s*/gi, "\n");
24790
+ let newPlain = restoreBr(textUnitToPlain(edited.raw, block));
24791
+ if (block.text && block.text.includes("\n") && !newPlain.includes("\n")) {
24792
+ return skip("\uB2E4\uC911\uC904 \uBB38\uB2E8 \uC218\uC815\uC5D0 <br> \uC5C6\uC74C \u2014 \uC904\uBC14\uAFC8 \uC704\uCE58 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (\uC904\uBC14\uAFC8\uC740 <br>\uB85C \uD45C\uAE30)");
23989
24793
  }
23990
- let newPlain = textUnitToPlain(edited.raw, block);
23991
24794
  if (block.footnoteText) {
23992
24795
  const noteMatch = newPlain.match(/\s*\(주: ([\s\S]*)\)$/);
23993
24796
  if (noteMatch) {
@@ -24009,7 +24812,7 @@ function patchParagraph(block, orig, edited, ctx, skip) {
24009
24812
  ctx.skipped.push({ reason: "\uC790\uB3D9\uBC88\uD638 \uC811\uB450 \uC2DD\uBCC4 \uC2E4\uD328 \u2014 \uBC88\uD638 \uD3EC\uD568 \uD14D\uC2A4\uD2B8\uB85C \uC801\uC6A9 (\uBDF0\uC5B4\uC5D0\uC11C \uC911\uBCF5 \uD45C\uC2DC \uAC00\uB2A5)", after: summarize(newPlain) });
24010
24813
  }
24011
24814
  }
24012
- const origPlain = textUnitToPlain(orig.raw, block);
24815
+ const origPlain = restoreBr(textUnitToPlain(orig.raw, block));
24013
24816
  if (newPlain === origPlain) return skip("\uD14D\uC2A4\uD2B8 \uC678 \uBCC0\uACBD(\uD5E4\uB529 \uB808\uBCA8/\uC11C\uC2DD)\uB9CC \uAC10\uC9C0 \u2014 \uC2A4\uD0C0\uC77C \uBCC0\uACBD\uC740 \uBBF8\uC9C0\uC6D0");
24014
24817
  if (sanitizeText(newPlain) !== newPlain) {
24015
24818
  return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
@@ -24037,6 +24840,28 @@ function patchGfmCells(scanTable, orig, edited, ctx, skip) {
24037
24840
  }
24038
24841
  const beforeParts = origRows[r][c].split(/<br\s*\/?>/i);
24039
24842
  const afterParts = editedRows[r][c].split(/<br\s*\/?>/i);
24843
+ if (cell.paras.length === 1) {
24844
+ const beforeEach = beforeParts.map(gfmCellToPlain);
24845
+ const afterEach = afterParts.map(gfmCellToPlain);
24846
+ if (beforeEach.some((p) => p === null) || afterEach.some((p) => p === null)) {
24847
+ cellSkip("\uC11C\uC2DD/\uB9C1\uD06C/\uC774\uBBF8\uC9C0 \uD3EC\uD568 \uC140 \uC218\uC815\uC740 \uBBF8\uC9C0\uC6D0 (v1)");
24848
+ continue;
24849
+ }
24850
+ const before = beforeEach.join("\n");
24851
+ const after = afterEach.join("\n");
24852
+ if (before === after) continue;
24853
+ const para = cell.paras[0];
24854
+ if (normForMatch(para.rawText) !== normForMatch(before)) {
24855
+ cellSkip("\uC140 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58 \u2014 \uC18C\uC2A4\uB9F5 \uC2E0\uB8B0 \uBD88\uAC00");
24856
+ continue;
24857
+ }
24858
+ if (afterEach.some((l) => sanitizeText(l) !== l)) {
24859
+ cellSkip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uBBF8\uC9C0\uC6D0");
24860
+ continue;
24861
+ }
24862
+ applied += stageParaPatch(ctx.scans[para.sectionIndex], para, after, cellSkip);
24863
+ continue;
24864
+ }
24040
24865
  if (beforeParts.length !== cell.paras.length || afterParts.length !== cell.paras.length) {
24041
24866
  cellSkip("\uC140 \uBB38\uB2E8 \uC218 \uBCC0\uACBD \u2014 \uBBF8\uC9C0\uC6D0 (\uBB38\uB2E8 \uCD94\uAC00/\uC0AD\uC81C)");
24042
24867
  continue;
@@ -24159,7 +24984,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
24159
24984
  };
24160
24985
  const cell = scanTable.cells.get(`${gridR},${gridC}`);
24161
24986
  if (!cell) return skip("\uC140 \uC88C\uD45C \uB9E4\uD551 \uC2E4\uD328 (\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58)");
24162
- const irCell = _optionalChain([table, 'access', _239 => _239.cells, 'access', _240 => _240[gridR], 'optionalAccess', _241 => _241[gridC]]);
24987
+ const irCell = _optionalChain([table, 'access', _259 => _259.cells, 'access', _260 => _260[gridR], 'optionalAccess', _261 => _261[gridC]]);
24163
24988
  const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
24164
24989
  if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
24165
24990
  if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
@@ -24181,13 +25006,13 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
24181
25006
  const assigned = [];
24182
25007
  for (let i = 0; i < targets.length; i++) {
24183
25008
  if (i < newLines.length) {
24184
- assigned.push(i === targets.length - 1 && newLines.length > targets.length ? newLines.slice(i).join(" ") : newLines[i]);
25009
+ assigned.push(i === targets.length - 1 && newLines.length > targets.length ? newLines.slice(i).join("\n") : newLines[i]);
24185
25010
  } else {
24186
25011
  assigned.push("");
24187
25012
  }
24188
25013
  }
24189
25014
  if (newLines.length > targets.length) {
24190
- ctx.skipped.push({ reason: "\uC140 \uB0B4 \uC904 \uCD94\uAC00\uB294 \uBB38\uB2E8 \uC0DD\uC131 \uBBF8\uC9C0\uC6D0 \u2014 \uB9C8\uC9C0\uB9C9 \uBB38\uB2E8\uC5D0 \uBCD1\uD569 \uC801\uC6A9", after: summarize(after), partial: true });
25015
+ ctx.skipped.push({ reason: "\uC140 \uB0B4 \uCD94\uAC00 \uC904\uC744 \uB9C8\uC9C0\uB9C9 \uBB38\uB2E8\uC5D0 \uAC15\uC81C \uC904\uBC14\uAFC8\uC73C\uB85C \uBCD1\uD569(\uBB38\uB2E8 \uC0DD\uC131 \uB300\uC2E0)", after: summarize(after), partial: true });
24191
25016
  } else if (newLines.length < nonEmpty.length && nonEmpty.length > 1) {
24192
25017
  ctx.skipped.push({ reason: "\uC140 \uB0B4 \uC904 \uC0AD\uC81C\uB294 \uBB38\uB2E8 \uC81C\uAC70 \uBBF8\uC9C0\uC6D0 \u2014 \uBE48 \uBB38\uB2E8 \uC794\uC874(\uBDF0\uC5B4\uC5D0 \uBE48 \uC904 \uD45C\uC2DC \uAC00\uB2A5)", before: summarize(before), after: summarize(after), partial: true });
24193
25018
  }
@@ -24245,8 +25070,7 @@ function splitParaText(data) {
24245
25070
  i += 16;
24246
25071
  toks.push({ start, end: i, units: 1, plain: false, visible: false });
24247
25072
  } else {
24248
- if (i + 14 <= data.length) i += 14;
24249
- toks.push({ start, end: i, units: 1, plain: false, visible: true });
25073
+ toks.push({ start, end: i, units: 1, plain: true, visible: true });
24250
25074
  }
24251
25075
  break;
24252
25076
  default: {
@@ -24309,13 +25133,31 @@ function rebuildCharShape(csData, coreStartUnit) {
24309
25133
  });
24310
25134
  return { buf, count: kept.length };
24311
25135
  }
25136
+ function synthesizeLineSegs(lineSegData, newRaw, startUnits) {
25137
+ if (lineSegData.length < 36) return null;
25138
+ const seg0 = lineSegData.subarray(0, 36);
25139
+ const vPos0 = seg0.readInt32LE(4);
25140
+ const pitch = seg0.readInt32LE(8) + seg0.readInt32LE(20);
25141
+ if (pitch <= 0) return null;
25142
+ const lines = newRaw.split("\n");
25143
+ const segs = [];
25144
+ let pos = startUnits;
25145
+ for (let k = 0; k < lines.length; k++) {
25146
+ const s = Buffer.from(seg0);
25147
+ s.writeUInt32LE((k === 0 ? 0 : pos) >>> 0, 0);
25148
+ s.writeInt32LE(vPos0 + k * pitch, 4);
25149
+ segs.push(s);
25150
+ pos += lines[k].length + 1;
25151
+ }
25152
+ return { buf: Buffer.concat(segs), count: lines.length };
25153
+ }
24312
25154
  function stageParaPatch(scan, para, newPlain, skip) {
24313
25155
  if (!scan.safe) return skip("\uC139\uC158 \uB808\uCF54\uB4DC \uC7AC\uC9C1\uB82C\uD654 \uBD88\uC77C\uCE58 \u2014 \uC548\uC804\uC744 \uC704\uD574 \uC774 \uC139\uC158\uC740 \uBBF8\uC9C0\uC6D0");
24314
25156
  if (para.textIdx === -2) return skip("\uBCF5\uC218 PARA_TEXT \uB808\uCF54\uB4DC \uBB38\uB2E8 \u2014 \uBBF8\uC9C0\uC6D0 (v1)");
24315
25157
  if (para.rangeTagCount > 0) return skip("\uBC94\uC704 \uD0DC\uADF8(\uD615\uAD11\uD39C/\uAD50\uC815\uBD80\uD638) \uBB38\uB2E8 \u2014 \uBBF8\uC9C0\uC6D0 (v1)");
24316
25158
  if (para.charShapeIdx < 0 || para.lineSegIdx < 0) return skip("\uBB38\uB2E8 \uB808\uCF54\uB4DC \uAD6C\uC131 \uBE44\uC815\uD615 \u2014 \uBBF8\uC9C0\uC6D0");
24317
25159
  if (scan.repl.has(para.headerIdx)) return skip("\uB3D9\uC77C \uBB38\uB2E8 \uC911\uBCF5 \uC218\uC815 \u2014 \uCCAB \uC218\uC815\uB9CC \uC801\uC6A9");
24318
- if (/[\u0000-\u001f]/.test(newPlain)) return skip("\uC0C8 \uD14D\uC2A4\uD2B8\uC5D0 \uC81C\uC5B4\uBB38\uC790 \uD3EC\uD568 \u2014 \uBBF8\uC9C0\uC6D0");
25160
+ if (/[\u0000-\u0009\u000b-\u001f]/.test(newPlain)) return skip("\uC0C8 \uD14D\uC2A4\uD2B8\uC5D0 \uC81C\uC5B4\uBB38\uC790 \uD3EC\uD568 \u2014 \uBBF8\uC9C0\uC6D0");
24319
25161
  const records = scan.records;
24320
25162
  const headerRec = records[para.headerIdx];
24321
25163
  const charShapeRec = records[para.charShapeIdx];
@@ -24335,6 +25177,13 @@ function stageParaPatch(scan, para, newPlain, skip) {
24335
25177
  const cs2 = rebuildCharShape(charShapeRec.data, 0);
24336
25178
  scan.repl.set(para.charShapeIdx, cs2.buf);
24337
25179
  newHeader2.writeUInt16LE(cs2.count, 12);
25180
+ if (newPlain.includes("\n")) {
25181
+ const synth = synthesizeLineSegs(records[para.lineSegIdx].data, newPlain, 0);
25182
+ if (synth) {
25183
+ scan.repl.set(para.lineSegIdx, synth.buf);
25184
+ newHeader2.writeUInt16LE(synth.count, 16);
25185
+ }
25186
+ }
24338
25187
  scan.repl.set(para.headerIdx, newHeader2);
24339
25188
  return 1;
24340
25189
  }
@@ -24355,10 +25204,103 @@ function stageParaPatch(scan, para, newPlain, skip) {
24355
25204
  const cs = rebuildCharShape(charShapeRec.data, seg.prefixUnits);
24356
25205
  scan.repl.set(para.charShapeIdx, cs.buf);
24357
25206
  newHeader.writeUInt16LE(cs.count, 12);
25207
+ if (newRaw.includes("\n")) {
25208
+ const synth = synthesizeLineSegs(records[para.lineSegIdx].data, newRaw, seg.prefixUnits);
25209
+ if (synth) {
25210
+ scan.repl.set(para.lineSegIdx, synth.buf);
25211
+ newHeader.writeUInt16LE(synth.count, 16);
25212
+ }
25213
+ }
24358
25214
  scan.repl.set(para.headerIdx, newHeader);
24359
25215
  return 1;
24360
25216
  }
24361
25217
 
25218
+ // src/validate.ts
25219
+
25220
+
25221
+ var REQUIRED_FILES = [
25222
+ "mimetype",
25223
+ "META-INF/container.xml",
25224
+ "Contents/content.hpf",
25225
+ "Contents/header.xml",
25226
+ "Contents/section0.xml"
25227
+ ];
25228
+ var EXPECTED_MIMETYPE = "application/hwp+zip";
25229
+ var XML_SUFFIXES = [".xml", ".hpf", ".rdf"];
25230
+ var SECTION_FILE_RE = /^Contents\/section\d+\.xml$/;
25231
+ var SECCNT_RE = /<(?:\w+:)?head\b[^>]*?\bsecCnt="(\d+)"/;
25232
+ var OPF_HREF_RE = /<opf:item\b[^>]*?\bhref="([^"]*)"/g;
25233
+ async function validateHwpx(buffer) {
25234
+ const issues = [];
25235
+ let zip;
25236
+ try {
25237
+ zip = await _jszip2.default.loadAsync(buffer);
25238
+ } catch (err) {
25239
+ return {
25240
+ ok: false,
25241
+ issues: [{ message: `\uC720\uD6A8\uD55C ZIP\uC774 \uC544\uB2D8: ${err instanceof Error ? err.message : String(err)}` }],
25242
+ entryCount: 0
25243
+ };
25244
+ }
25245
+ const rawNames = Object.keys(zip.files);
25246
+ const names = rawNames.filter((n) => !zip.files[n].dir);
25247
+ if (names.length === 0) return { ok: false, issues: [{ message: "\uBE48 ZIP" }], entryCount: 0 };
25248
+ if (rawNames[0] !== "mimetype") {
25249
+ issues.push({ message: `\uCCAB zip \uC5D4\uD2B8\uB9AC\uAC00 '${rawNames[0]}' \u2014 'mimetype'\uC774\uC5B4\uC57C \uD568` });
25250
+ }
25251
+ const nameset = new Set(names);
25252
+ if (nameset.has("mimetype")) {
25253
+ const mt = (await zip.files["mimetype"].async("string")).trim();
25254
+ if (mt !== EXPECTED_MIMETYPE) {
25255
+ issues.push({ path: "mimetype", message: `\uB0B4\uC6A9\uC774 '${mt}' \u2014 '${EXPECTED_MIMETYPE}'\uC774\uC5B4\uC57C \uD568` });
25256
+ }
25257
+ }
25258
+ for (const req of REQUIRED_FILES) {
25259
+ if (!nameset.has(req)) issues.push({ message: `\uD544\uC218 \uD30C\uC77C \uB204\uB77D: ${req}` });
25260
+ }
25261
+ for (const name of names) {
25262
+ if (!XML_SUFFIXES.some((s) => name.endsWith(s))) continue;
25263
+ const text = await zip.files[name].async("string");
25264
+ let firstError = null;
25265
+ try {
25266
+ new (0, _xmldom.DOMParser)({
25267
+ onError(level, msg2) {
25268
+ if (level !== "warning" && firstError === null) firstError = String(msg2);
25269
+ }
25270
+ }).parseFromString(text, "text/xml");
25271
+ } catch (err) {
25272
+ firstError ??= err instanceof Error ? err.message : String(err);
25273
+ }
25274
+ if (firstError !== null) {
25275
+ issues.push({ path: name, message: `XML \uC6F0\uD3FC\uB4DC \uC704\uBC18: ${firstError.split("\n")[0]}` });
25276
+ }
25277
+ }
25278
+ if (nameset.has("Contents/header.xml")) {
25279
+ const header = await zip.files["Contents/header.xml"].async("string");
25280
+ const m = SECCNT_RE.exec(header);
25281
+ if (m) {
25282
+ const declared = Number(m[1]);
25283
+ const actual = names.filter((n) => SECTION_FILE_RE.test(n)).length;
25284
+ if (declared !== actual) {
25285
+ issues.push({
25286
+ path: "Contents/header.xml",
25287
+ message: `secCnt=${declared}\uC778\uB370 \uC2E4\uC81C sectionN.xml\uC740 ${actual}\uAC1C \u2014 \uD55C\uCEF4\uB3C5\uC2A4\uAC00 \uC5F4\uAE30\uB97C \uAC70\uBD80\uD568`
25288
+ });
25289
+ }
25290
+ }
25291
+ }
25292
+ if (nameset.has("Contents/content.hpf")) {
25293
+ const hpf = await zip.files["Contents/content.hpf"].async("string");
25294
+ for (const m of hpf.matchAll(OPF_HREF_RE)) {
25295
+ const href = m[1];
25296
+ if (!nameset.has(href) && !nameset.has(`Contents/${href}`)) {
25297
+ issues.push({ path: "Contents/content.hpf", message: `manifest\uAC00 \uC5C6\uB294 \uD30C\uC77C\uC744 \uCC38\uC870: ${href}` });
25298
+ }
25299
+ }
25300
+ }
25301
+ return { ok: issues.length === 0, issues, entryCount: names.length };
25302
+ }
25303
+
24362
25304
  // src/roundtrip/session.ts
24363
25305
 
24364
25306
  async function buildState(bytes) {
@@ -24434,7 +25376,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24434
25376
  const block = st.blocks[blockIndex];
24435
25377
  if (!block) return void 0;
24436
25378
  if (block.type === "paragraph" || block.type === "heading") {
24437
- const para = _optionalChain([st, 'access', _242 => _242.paraMap, 'access', _243 => _243.get, 'call', _244 => _244(blockIndex), 'optionalAccess', _245 => _245.para]);
25379
+ const para = _optionalChain([st, 'access', _262 => _262.paraMap, 'access', _263 => _263.get, 'call', _264 => _264(blockIndex), 'optionalAccess', _265 => _265.para]);
24438
25380
  if (!para) return void 0;
24439
25381
  return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
24440
25382
  }
@@ -24459,7 +25401,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24459
25401
  if (block.text && block.text.includes("\n")) {
24460
25402
  return { capability: "locked", reason: "\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)" };
24461
25403
  }
24462
- if (!_optionalChain([st, 'access', _246 => _246.paraMap, 'access', _247 => _247.get, 'call', _248 => _248(blockIndex), 'optionalAccess', _249 => _249.para])) {
25404
+ if (!_optionalChain([st, 'access', _266 => _266.paraMap, 'access', _267 => _267.get, 'call', _268 => _268(blockIndex), 'optionalAccess', _269 => _269.para])) {
24463
25405
  return { capability: "locked", reason: "\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)" };
24464
25406
  }
24465
25407
  return { capability: "text" };
@@ -24525,7 +25467,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24525
25467
  continue;
24526
25468
  }
24527
25469
  if (block.type === "table" && block.table) {
24528
- if (!_optionalChain([edit, 'access', _250 => _250.cells, 'optionalAccess', _251 => _251.length])) {
25470
+ if (!_optionalChain([edit, 'access', _270 => _270.cells, 'optionalAccess', _271 => _271.length])) {
24529
25471
  skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
24530
25472
  continue;
24531
25473
  }
@@ -24545,7 +25487,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24545
25487
  skipped.push({ reason: "\uAC19\uC740 \uC140\uC5D0 \uC911\uBCF5 \uD3B8\uC9D1 \u2014 \uBA3C\uC800 \uC801\uC6A9\uB41C \uD3B8\uC9D1 \uC720\uC9C0", after: summarize(cellEdit.text) });
24546
25488
  continue;
24547
25489
  }
24548
- const irCell = _optionalChain([block, 'access', _252 => _252.table, 'access', _253 => _253.cells, 'access', _254 => _254[cellEdit.row], 'optionalAccess', _255 => _255[cellEdit.col]]);
25490
+ const irCell = _optionalChain([block, 'access', _272 => _272.table, 'access', _273 => _273.cells, 'access', _274 => _274[cellEdit.row], 'optionalAccess', _275 => _275[cellEdit.col]]);
24549
25491
  if (!irCell) {
24550
25492
  skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
24551
25493
  continue;
@@ -24601,7 +25543,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24601
25543
  }
24602
25544
  if (replacements.size === 0) {
24603
25545
  let changes2;
24604
- if (_optionalChain([options, 'optionalAccess', _256 => _256.verify]) !== false) {
25546
+ if (_optionalChain([options, 'optionalAccess', _276 => _276.verify]) !== false) {
24605
25547
  const units = splitMarkdownUnits(st.markdown);
24606
25548
  changes2 = diffUnitLists(units, units);
24607
25549
  }
@@ -24622,7 +25564,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24622
25564
  }
24623
25565
  this.state = newState;
24624
25566
  let changes;
24625
- if (_optionalChain([options, 'optionalAccess', _257 => _257.verify]) !== false) {
25567
+ if (_optionalChain([options, 'optionalAccess', _277 => _277.verify]) !== false) {
24626
25568
  changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
24627
25569
  }
24628
25570
  return { success: true, data: new Uint8Array(data), applied, skipped, changes };
@@ -24642,7 +25584,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24642
25584
  return skip("\uBB38\uB2E8 \uB0B4 \uAC15\uC81C \uC904\uBC14\uAFC8 \uD3EC\uD568 \u2014 \uC218\uC815 \uC2DC \uC904\uBC14\uAFC8 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0 (v1)");
24643
25585
  }
24644
25586
  const mapping = st.paraMap.get(blockIndex);
24645
- if (!_optionalChain([mapping, 'optionalAccess', _258 => _258.para])) {
25587
+ if (!_optionalChain([mapping, 'optionalAccess', _278 => _278.para])) {
24646
25588
  return skip("\uBB38\uB2E8 \uC18C\uC2A4\uB9F5 \uB9E4\uD551 \uC2E4\uD328 (\uBA38\uB9AC\uB9D0/\uAE00\uC0C1\uC790/\uCEA1\uC158 \uC601\uC5ED\uC774\uAC70\uB098 \uD14D\uC2A4\uD2B8 \uBD88\uC77C\uCE58)");
24647
25589
  }
24648
25590
  let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
@@ -24662,14 +25604,14 @@ var HwpxSession = (_class5 = class _HwpxSession {
24662
25604
  if (sanitizeText(newPlain) !== newPlain) {
24663
25605
  return skip("\uACF5\uBC31 \uC815\uADDC\uD654 \uBD88\uC548\uC815 \uD14D\uC2A4\uD2B8 \u2014 \uD328\uCE58 \uC2DC \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
24664
25606
  }
24665
- const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _259 => _259.scans, 'access', _260 => _260[mapping.para.sectionIndex], 'optionalAccess', _261 => _261.xml]));
25607
+ const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _279 => _279.scans, 'access', _280 => _280[mapping.para.sectionIndex], 'optionalAccess', _281 => _281.xml]));
24666
25608
  if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
24667
25609
  sectionSplices[mapping.para.sectionIndex].push(...splices);
24668
25610
  return 1;
24669
25611
  }
24670
25612
  }, _class5);
24671
25613
  function cellStaticCheck(table, scanTable, r, c) {
24672
- const irCell = _optionalChain([table, 'access', _262 => _262.cells, 'access', _263 => _263[r], 'optionalAccess', _264 => _264[c]]);
25614
+ const irCell = _optionalChain([table, 'access', _282 => _282.cells, 'access', _283 => _283[r], 'optionalAccess', _284 => _284[c]]);
24673
25615
  if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
24674
25616
  const cell = scanTable.cellByAnchor.get(`${r},${c}`);
24675
25617
  if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
@@ -24753,11 +25695,11 @@ var md = new (0, _markdownit2.default)({
24753
25695
  breaks: false
24754
25696
  });
24755
25697
  function renderHtml(markdown, options) {
24756
- const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _265 => _265.preset]), () => ( "default"));
24757
- const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _266 => _266.extraCss]), () => ( "")));
25698
+ const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _285 => _285.preset]), () => ( "default"));
25699
+ const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _286 => _286.extraCss]), () => ( "")));
24758
25700
  const body = md.render(markdown);
24759
- const watermark = _optionalChain([options, 'optionalAccess', _267 => _267.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
24760
- const watermarkCss = _optionalChain([options, 'optionalAccess', _268 => _268.watermark]) ? `
25701
+ const watermark = _optionalChain([options, 'optionalAccess', _287 => _287.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
25702
+ const watermarkCss = _optionalChain([options, 'optionalAccess', _288 => _288.watermark]) ? `
24761
25703
  .watermark {
24762
25704
  position: fixed;
24763
25705
  top: 50%; left: 50%;
@@ -24788,13 +25730,13 @@ async function htmlToPdf(html, options) {
24788
25730
  try {
24789
25731
  puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
24790
25732
  } catch (e30) {
24791
- throw new (0, _chunkMEXUFQVCcjs.KordocError)(
25733
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)(
24792
25734
  "PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
24793
25735
  );
24794
25736
  }
24795
25737
  const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
24796
25738
  if (!executablePath) {
24797
- throw new (0, _chunkMEXUFQVCcjs.KordocError)(
25739
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)(
24798
25740
  "Chromium \uC2E4\uD589 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. PUPPETEER_EXECUTABLE_PATH \uD658\uACBD\uBCC0\uC218\uB97C \uC124\uC815\uD558\uC138\uC694."
24799
25741
  );
24800
25742
  }
@@ -24806,10 +25748,10 @@ async function htmlToPdf(html, options) {
24806
25748
  try {
24807
25749
  const page = await browser.newPage();
24808
25750
  await page.setContent(html, { waitUntil: "networkidle0" });
24809
- const margin = _optionalChain([options, 'optionalAccess', _269 => _269.margin]);
25751
+ const margin = _optionalChain([options, 'optionalAccess', _289 => _289.margin]);
24810
25752
  const pdf = await page.pdf({
24811
- format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _270 => _270.pageSize]), () => ( "A4")),
24812
- landscape: _optionalChain([options, 'optionalAccess', _271 => _271.orientation]) === "landscape",
25753
+ format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _290 => _290.pageSize]), () => ( "A4")),
25754
+ landscape: _optionalChain([options, 'optionalAccess', _291 => _291.orientation]) === "landscape",
24813
25755
  printBackground: true,
24814
25756
  margin: margin ? {
24815
25757
  top: toCss(margin.top),
@@ -24817,9 +25759,9 @@ async function htmlToPdf(html, options) {
24817
25759
  bottom: toCss(margin.bottom),
24818
25760
  left: toCss(margin.left)
24819
25761
  } : void 0,
24820
- displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _272 => _272.header]) || _optionalChain([options, 'optionalAccess', _273 => _273.footer])),
24821
- headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _274 => _274.header]), () => ( "<div></div>")),
24822
- footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _275 => _275.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
25762
+ displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _292 => _292.header]) || _optionalChain([options, 'optionalAccess', _293 => _293.footer])),
25763
+ headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _294 => _294.header]), () => ( "<div></div>")),
25764
+ footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _295 => _295.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
24823
25765
  });
24824
25766
  return Buffer.from(pdf);
24825
25767
  } finally {
@@ -24853,7 +25795,7 @@ async function markdownToPdf(markdown, options) {
24853
25795
  return htmlToPdf(html, options);
24854
25796
  }
24855
25797
  async function blocksToPdf(blocks, options) {
24856
- const markdown = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, blocks);
25798
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, blocks);
24857
25799
  return markdownToPdf(markdown, options);
24858
25800
  }
24859
25801
 
@@ -24934,80 +25876,162 @@ function solveRowHeights(cells, rowCount) {
24934
25876
  return h;
24935
25877
  }
24936
25878
 
24937
- // src/render/head-styles.ts
24938
- var DEFAULT_CHAR = { height: 1e3, bold: false, italic: false, underline: false, ratio: 100, spacing: 0 };
24939
- function borderWidthPt(v) {
24940
- const n = parseFloat(_nullishCoalesce(v, () => ( "")));
24941
- if (!Number.isFinite(n)) return 0.34;
24942
- return n * 2.834645;
25879
+ // src/render/reflow.ts
25880
+ var LINESEG_FLAGS = "393216";
25881
+ var BASELINE_RATIO = 0.85;
25882
+ function ln(el) {
25883
+ return (el.tagName || "").replace(/^[^:]+:/, "");
24943
25884
  }
24944
- function parseEdge(el) {
24945
- if (!el) return void 0;
24946
- const type = _nullishCoalesce(el.getAttribute("type"), () => ( "NONE"));
24947
- if (type === "NONE") return void 0;
24948
- return { type, widthPt: borderWidthPt(el.getAttribute("width")), color: _nullishCoalesce(el.getAttribute("color"), () => ( "#000000")) };
25885
+ function elements(el) {
25886
+ const out = [];
25887
+ const kids2 = el.childNodes;
25888
+ if (!kids2) return out;
25889
+ for (let i = 0; i < kids2.length; i++) if (kids2[i].nodeType === 1) out.push(kids2[i]);
25890
+ return out;
24949
25891
  }
24950
- function parseRenderStyles(headXml) {
24951
- const styles = { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
24952
- const doc = createXmlParser().parseFromString(headXml, "text/xml");
24953
- const root = doc.documentElement;
24954
- if (!root) return styles;
24955
- const walk = (el) => {
24956
- const tag = (el.tagName || "").replace(/^[^:]+:/, "");
24957
- if (tag === "charPr") {
24958
- const id = el.getAttribute("id");
24959
- if (id != null) {
24960
- const ratioEl = findChildByLocalName(el, "ratio");
24961
- const spacingEl = findChildByLocalName(el, "spacing");
24962
- const underlineEl = findChildByLocalName(el, "underline");
24963
- const textColor = el.getAttribute("textColor");
24964
- styles.charPr.set(id, {
24965
- height: Number(el.getAttribute("height")) || 1e3,
24966
- bold: findChildByLocalName(el, "bold") != null,
24967
- italic: findChildByLocalName(el, "italic") != null,
24968
- underline: underlineEl != null && (_nullishCoalesce(underlineEl.getAttribute("type"), () => ( "NONE"))) !== "NONE",
24969
- color: textColor && textColor !== "#000000" && textColor.toLowerCase() !== "none" ? textColor : void 0,
24970
- ratio: Number(_optionalChain([ratioEl, 'optionalAccess', _276 => _276.getAttribute, 'call', _277 => _277("hangul")])) || 100,
24971
- spacing: Number(_optionalChain([spacingEl, 'optionalAccess', _278 => _278.getAttribute, 'call', _279 => _279("hangul")])) || 0
24972
- });
24973
- }
24974
- } else if (tag === "paraPr") {
24975
- const id = el.getAttribute("id");
24976
- if (id != null) {
24977
- const align = findChildByLocalName(el, "align");
24978
- styles.paraAlign.set(id, _optionalChain([align, 'optionalAccess', _280 => _280.getAttribute, 'call', _281 => _281("horizontal")]) || "JUSTIFY");
25892
+ function num(el, attr, fallback = 0) {
25893
+ return el ? toInt32(_nullishCoalesce(el.getAttribute(attr), () => ( void 0)), fallback) : fallback;
25894
+ }
25895
+ function shiftParaVert(p, delta) {
25896
+ for (const lsa of elements(p)) {
25897
+ if (ln(lsa) !== "linesegarray") continue;
25898
+ for (const seg of elements(lsa)) {
25899
+ if (ln(seg) !== "lineseg") continue;
25900
+ seg.setAttribute("vertpos", String(num(seg, "vertpos") + delta));
25901
+ }
25902
+ }
25903
+ }
25904
+ function pitchFor(height, geom) {
25905
+ const v = geom.lineSpacingValue;
25906
+ switch (geom.lineSpacingType) {
25907
+ case "PERCENT":
25908
+ return Math.round(height * v / 100);
25909
+ case "FIXED":
25910
+ return v > 0 ? v : Math.round(height * 1.6);
25911
+ // 고정 줄높이(HWPUNIT)
25912
+ case "AT_LEAST":
25913
+ return Math.max(v, height);
25914
+ default:
25915
+ return Math.round(height * 1.6);
25916
+ }
25917
+ }
25918
+ function reflowPara(p, doc, styles, areaW, startV, mode) {
25919
+ const m = buildPara(p);
25920
+ if (m.segs.length > 0) return null;
25921
+ const realIdx = [];
25922
+ let text = "";
25923
+ for (let i = 0; i < m.chars.length; i++) {
25924
+ const ch = m.chars[i].ch;
25925
+ if (ch === "") continue;
25926
+ for (let u = 0; u < ch.length; u++) realIdx.push(i);
25927
+ text += ch;
25928
+ }
25929
+ const geom = _nullishCoalesce(styles.paraGeom.get(_nullishCoalesce(m.paraPrId, () => ( ""))), () => ( DEFAULT_PARA_GEOM));
25930
+ let domChar = DEFAULT_CHAR;
25931
+ for (const c of m.chars) {
25932
+ if (c.ch !== "" && c.prId != null) {
25933
+ const st = styles.charPr.get(c.prId);
25934
+ if (st) {
25935
+ domChar = st;
25936
+ break;
24979
25937
  }
24980
- } else if (tag === "borderFill") {
24981
- const id = el.getAttribute("id");
24982
- if (id != null) {
24983
- const bf = {
24984
- left: parseEdge(findChildByLocalName(el, "leftBorder")),
24985
- right: parseEdge(findChildByLocalName(el, "rightBorder")),
24986
- top: parseEdge(findChildByLocalName(el, "topBorder")),
24987
- bottom: parseEdge(findChildByLocalName(el, "bottomBorder"))
24988
- };
24989
- const fillBrush = findChildByLocalName(el, "fillBrush");
24990
- const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
24991
- const face = _optionalChain([winBrush, 'optionalAccess', _282 => _282.getAttribute, 'call', _283 => _283("faceColor")]);
24992
- if (face && face.toLowerCase() !== "none") bf.fill = face;
24993
- styles.borderFill.set(id, bf);
25938
+ }
25939
+ }
25940
+ const height = domChar.height || 1e3;
25941
+ const ratio = domChar.ratio || 100;
25942
+ const spacingPct = domChar.spacing || 0;
25943
+ const marginL = geom.marginLeft;
25944
+ const avail = Math.max(1e3, areaW - marginL - geom.marginRight);
25945
+ const firstWidth = avail;
25946
+ const contWidth = Math.max(500, avail + Math.min(0, geom.marginIntent));
25947
+ const contHorz = marginL - Math.min(0, geom.marginIntent);
25948
+ const wrap = text.length === 0 ? { lines: 1, starts: [0], lastLineWidth: 0 } : simulateWrap(text, firstWidth, contWidth, height, ratio, mode, { spacingPct });
25949
+ const pitch = pitchFor(height, geom);
25950
+ const baseline = Math.round(height * BASELINE_RATIO);
25951
+ const spacing = Math.max(0, pitch - height);
25952
+ const lsa = doc.createElement("hp:linesegarray");
25953
+ for (let li = 0; li < wrap.starts.length; li++) {
25954
+ const startReal = wrap.starts[li];
25955
+ const textpos = startReal < realIdx.length ? realIdx[startReal] : m.chars.length;
25956
+ const vertpos = startV + li * pitch;
25957
+ const isFirst = li === 0;
25958
+ const seg = doc.createElement("hp:lineseg");
25959
+ seg.setAttribute("textpos", String(textpos));
25960
+ seg.setAttribute("vertpos", String(vertpos));
25961
+ seg.setAttribute("vertsize", String(height));
25962
+ seg.setAttribute("textheight", String(height));
25963
+ seg.setAttribute("baseline", String(baseline));
25964
+ seg.setAttribute("spacing", String(spacing));
25965
+ seg.setAttribute("horzpos", String(isFirst ? marginL : contHorz));
25966
+ seg.setAttribute("horzsize", String(isFirst ? firstWidth : contWidth));
25967
+ seg.setAttribute("flags", LINESEG_FLAGS);
25968
+ lsa.appendChild(seg);
25969
+ }
25970
+ p.appendChild(lsa);
25971
+ const textBottom = startV + wrap.starts.length * pitch;
25972
+ let objBottom = startV;
25973
+ for (const o of m.objs) {
25974
+ const h = o.tag === "tbl" ? Math.max(o.height, measureTableHeight(o.el)) : o.height;
25975
+ objBottom = Math.max(objBottom, startV + h);
25976
+ }
25977
+ return { paraBottom: Math.max(textBottom, objBottom), spaceAfter: geom.spaceAfter };
25978
+ }
25979
+ function reflowTablesIn(p, doc, styles, mode, counter) {
25980
+ for (const run of elements(p)) {
25981
+ if (ln(run) !== "run") continue;
25982
+ for (const obj of elements(run)) {
25983
+ if (ln(obj) !== "tbl") continue;
25984
+ for (const tr of elements(obj)) {
25985
+ if (ln(tr) !== "tr") continue;
25986
+ for (const tc of elements(tr)) {
25987
+ if (ln(tc) !== "tc") continue;
25988
+ const csz = findChildByLocalName(tc, "cellSz");
25989
+ const cm = findChildByLocalName(tc, "cellMargin");
25990
+ const cellW = num(csz, "width");
25991
+ const mL = cm ? num(cm, "left", 141) : 141;
25992
+ const mR = cm ? num(cm, "right", 141) : 141;
25993
+ const areaW = Math.max(500, cellW - mL - mR);
25994
+ const sub = findChildByLocalName(tc, "subList");
25995
+ if (sub) reflowBlockFlow(sub, doc, styles, areaW, mode, counter, 0);
25996
+ }
24994
25997
  }
24995
25998
  }
24996
- const children = el.childNodes;
24997
- for (let i = 0; i < children.length; i++) {
24998
- const ch = children[i];
24999
- if (ch.nodeType === 1) walk(ch);
25999
+ }
26000
+ }
26001
+ function reflowBlockFlow(container, doc, styles, areaW, mode, counter, bodyH) {
26002
+ let cursorV = 0;
26003
+ let prevSpaceAfter = 0;
26004
+ for (const p of elements(container)) {
26005
+ if (ln(p) !== "p") continue;
26006
+ reflowTablesIn(p, doc, styles, mode, counter);
26007
+ const g = styles.paraGeom.get(_nullishCoalesce(p.getAttribute("paraPrIDRef"), () => ( "")));
26008
+ const startV = cursorV + prevSpaceAfter + (_nullishCoalesce(_optionalChain([g, 'optionalAccess', _296 => _296.spaceBefore]), () => ( 0)));
26009
+ const res = reflowPara(p, doc, styles, areaW, startV, mode);
26010
+ if (res) {
26011
+ const paraH = res.paraBottom - startV;
26012
+ if (bodyH > 0 && startV > 0 && res.paraBottom > bodyH && paraH <= bodyH) {
26013
+ shiftParaVert(p, -startV);
26014
+ cursorV = paraH;
26015
+ } else {
26016
+ cursorV = res.paraBottom;
26017
+ }
26018
+ prevSpaceAfter = res.spaceAfter;
26019
+ counter.n++;
25000
26020
  }
25001
- };
25002
- walk(root);
25003
- return styles;
26021
+ }
26022
+ }
26023
+ function reflowSection(root, styles, geom, mode = "keep") {
26024
+ const doc = root.ownerDocument;
26025
+ const counter = { n: 0 };
26026
+ reflowBlockFlow(root, doc, styles, geom.BODY_W, mode, counter, geom.BODY_H);
26027
+ return counter.n;
25004
26028
  }
25005
26029
 
25006
26030
  // src/render/svg-render.ts
25007
- function ln(el) {
26031
+ function ln2(el) {
25008
26032
  return (el.tagName || "").replace(/^[^:]+:/, "");
25009
26033
  }
25010
- function elements(el) {
26034
+ function elements2(el) {
25011
26035
  const out = [];
25012
26036
  const children = el.childNodes;
25013
26037
  if (!children) return out;
@@ -25016,13 +26040,13 @@ function elements(el) {
25016
26040
  }
25017
26041
  return out;
25018
26042
  }
25019
- function num(el, attr, fallback = 0) {
26043
+ function num2(el, attr, fallback = 0) {
25020
26044
  return el ? toInt32(_nullishCoalesce(el.getAttribute(attr), () => ( void 0)), fallback) : fallback;
25021
26045
  }
25022
26046
  function findFirst(el, name, depth = 0) {
25023
26047
  if (depth > 64) return null;
25024
- for (const ch of elements(el)) {
25025
- if (ln(ch) === name) return ch;
26048
+ for (const ch of elements2(el)) {
26049
+ if (ln2(ch) === name) return ch;
25026
26050
  const found = findFirst(ch, name, depth + 1);
25027
26051
  if (found) return found;
25028
26052
  }
@@ -25033,59 +26057,80 @@ function escapeXml3(s) {
25033
26057
  }
25034
26058
  var OBJ_TAGS = /* @__PURE__ */ new Set(["tbl", "pic", "container", "equation", "rect", "ellipse", "polygon", "curv", "line", "arc", "ole", "textart"]);
25035
26059
  var pt = (u) => String(Math.round(u) / 100);
26060
+ function emit(ctx, s) {
26061
+ ctx.pages[ctx.page].push(s);
26062
+ }
25036
26063
  function warnOnce(ctx, key, msg2) {
25037
26064
  if (ctx.warned.has(key)) return;
25038
26065
  ctx.warned.add(key);
25039
26066
  ctx.warnings.push(msg2);
25040
26067
  }
25041
- function textOfT(t) {
25042
- let s = "";
25043
- const walk = (n, d) => {
25044
- if (d > 32) return;
25045
- const kids2 = n.childNodes;
25046
- if (!kids2) return;
25047
- for (let i = 0; i < kids2.length; i++) {
25048
- const c = kids2[i];
25049
- if (c.nodeType === 3) s += _nullishCoalesce(c.textContent, () => ( ""));
25050
- else if (c.nodeType === 1) walk(c, d + 1);
26068
+ var CHAR_CTRL_1SLOT = /* @__PURE__ */ new Set(["lineBreak", "hyphen", "nbSpace", "fwSpace"]);
26069
+ function pushFillers(chars, n, prId) {
26070
+ for (let i = 0; i < n; i++) chars.push({ ch: "", prId });
26071
+ }
26072
+ function pushTextSlots(t, chars, prId, depth) {
26073
+ if (depth > 32) return;
26074
+ const kids2 = t.childNodes;
26075
+ if (!kids2) return;
26076
+ for (let i = 0; i < kids2.length; i++) {
26077
+ const c = kids2[i];
26078
+ if (c.nodeType === 3) {
26079
+ for (const cp of _nullishCoalesce(c.textContent, () => ( ""))) {
26080
+ chars.push({ ch: cp, prId });
26081
+ if (cp.length === 2) chars.push({ ch: "", prId });
26082
+ }
26083
+ } else if (c.nodeType === 1) {
26084
+ const el = c;
26085
+ const tag = ln2(el);
26086
+ if (tag === "tab") {
26087
+ pushFillers(chars, 8, prId);
26088
+ } else if (CHAR_CTRL_1SLOT.has(tag)) {
26089
+ chars.push({ ch: tag === "nbSpace" || tag === "fwSpace" ? " " : "", prId });
26090
+ } else {
26091
+ pushTextSlots(el, chars, prId, depth + 1);
26092
+ }
25051
26093
  }
25052
- };
25053
- walk(t, 0);
25054
- return s;
26094
+ }
25055
26095
  }
25056
26096
  function buildPara(p) {
25057
26097
  const chars = [];
25058
26098
  const objs = [];
25059
26099
  let segs = [];
25060
- for (const runEl of elements(p)) {
25061
- const tag = ln(runEl);
26100
+ for (const runEl of elements2(p)) {
26101
+ const tag = ln2(runEl);
25062
26102
  if (tag === "run") {
25063
26103
  const prId = runEl.getAttribute("charPrIDRef");
25064
- for (const ch of elements(runEl)) {
25065
- const cn = ln(ch);
26104
+ for (const ch of elements2(runEl)) {
26105
+ const cn = ln2(ch);
25066
26106
  if (cn === "t") {
25067
- for (const c of textOfT(ch)) chars.push({ ch: c, prId });
26107
+ pushTextSlots(ch, chars, prId, 0);
25068
26108
  } else if (OBJ_TAGS.has(cn)) {
25069
26109
  const sz = findChildByLocalName(ch, "sz");
25070
26110
  const pos = findChildByLocalName(ch, "pos");
26111
+ const w = num2(sz, "width") || num2(findChildByLocalName(ch, "curSz"), "width") || num2(findChildByLocalName(ch, "orgSz"), "width");
26112
+ const h = num2(sz, "height") || num2(findChildByLocalName(ch, "curSz"), "height") || num2(findChildByLocalName(ch, "orgSz"), "height");
25071
26113
  objs.push({
25072
26114
  el: ch,
25073
26115
  tag: cn,
25074
26116
  index: chars.length,
25075
- inline: _optionalChain([pos, 'optionalAccess', _284 => _284.getAttribute, 'call', _285 => _285("treatAsChar")]) === "1",
25076
- width: num(sz, "width"),
25077
- height: num(sz, "height")
26117
+ inline: _optionalChain([pos, 'optionalAccess', _297 => _297.getAttribute, 'call', _298 => _298("treatAsChar")]) === "1",
26118
+ width: w,
26119
+ height: h
25078
26120
  });
26121
+ pushFillers(chars, 8, prId);
26122
+ } else {
26123
+ pushFillers(chars, 8, prId);
25079
26124
  }
25080
26125
  }
25081
26126
  } else if (tag === "linesegarray") {
25082
- segs = elements(runEl).filter((s) => ln(s) === "lineseg").map((s) => ({
25083
- textpos: num(s, "textpos"),
25084
- vertpos: num(s, "vertpos"),
25085
- horzpos: num(s, "horzpos"),
25086
- horzsize: num(s, "horzsize"),
25087
- textheight: num(s, "textheight", 1e3),
25088
- baseline: num(s, "baseline", 850)
26127
+ segs = elements2(runEl).filter((s) => ln2(s) === "lineseg").map((s) => ({
26128
+ textpos: num2(s, "textpos"),
26129
+ vertpos: num2(s, "vertpos"),
26130
+ horzpos: num2(s, "horzpos"),
26131
+ horzsize: num2(s, "horzsize"),
26132
+ textheight: num2(s, "textheight", 1e3),
26133
+ baseline: num2(s, "baseline", 850)
25089
26134
  }));
25090
26135
  }
25091
26136
  }
@@ -25133,38 +26178,41 @@ function advanceTo(m, styles, plan, upto) {
25133
26178
  for (const o of m.objs) if (o.inline && o.index >= plan.start && o.index < upto) x += o.width;
25134
26179
  return x;
25135
26180
  }
25136
- function drawPara(p, ox, oy, areaW, ctx, depth) {
26181
+ function drawPara(p, ox, oy, areaW, ctx, depth, segPages) {
25137
26182
  if (depth > 16) {
25138
26183
  warnOnce(ctx, "depth", "\uC911\uCCA9 \uAE4A\uC774 16 \uCD08\uACFC \u2014 \uC774\uD558 \uC0DD\uB7B5");
25139
26184
  return;
25140
26185
  }
25141
26186
  const m = buildPara(p);
25142
26187
  if (m.segs.length === 0) {
26188
+ if (m.chars.some((c) => c.ch !== "")) {
26189
+ warnOnce(ctx, "no-lineseg", "\uC870\uD310 \uCE90\uC2DC \uC5C6\uB294 \uBB38\uB2E8 \uD14D\uC2A4\uD2B8 \uC0DD\uB7B5 \u2014 reflow \uC635\uC158\uC73C\uB85C \uD569\uC131 \uAC00\uB2A5");
26190
+ }
25143
26191
  for (const o of m.objs) drawObject(o, ox, oy, 0, areaW, ctx, depth);
25144
26192
  return;
25145
26193
  }
25146
26194
  const plans = planLines(m, ctx.styles);
25147
26195
  const baseV = m.segs[0].vertpos;
25148
- for (const plan of plans) {
26196
+ for (let li = 0; li < plans.length; li++) {
26197
+ const plan = plans[li];
26198
+ if (segPages && segPages[li] !== void 0) ctx.page = segPages[li];
25149
26199
  const { seg } = plan;
25150
26200
  let i = plan.start;
25151
26201
  let cursor = ox + seg.horzpos + plan.xoff;
25152
26202
  const y = oy + seg.vertpos + seg.baseline;
25153
26203
  while (i < plan.end && i < m.chars.length) {
26204
+ if (m.chars[i].ch === "") {
26205
+ for (const o of m.objs) if (o.inline && o.index === i) cursor += o.width;
26206
+ i++;
26207
+ continue;
26208
+ }
25154
26209
  const prId = m.chars[i].prId;
25155
26210
  let j = i;
25156
26211
  let piece = "";
25157
- while (j < plan.end && j < m.chars.length && m.chars[j].prId === prId) {
26212
+ while (j < plan.end && j < m.chars.length && m.chars[j].prId === prId && m.chars[j].ch !== "") {
25158
26213
  piece += m.chars[j].ch;
25159
26214
  j++;
25160
26215
  }
25161
- for (const o of m.objs) {
25162
- if (o.inline && o.index > i && o.index < j) {
25163
- piece = piece.slice(0, o.index - i);
25164
- j = o.index;
25165
- break;
25166
- }
25167
- }
25168
26216
  {
25169
26217
  const cut = piece.search(/ {2,}/);
25170
26218
  if (cut > 0) {
@@ -25177,32 +26225,71 @@ function drawPara(p, ox, oy, areaW, ctx, depth) {
25177
26225
  }
25178
26226
  }
25179
26227
  const st = _nullishCoalesce((prId != null ? ctx.styles.charPr.get(prId) : void 0), () => ( DEFAULT_CHAR));
25180
- const w = measureTextWidth(piece, st.height, st.ratio, { spacingPct: st.spacing }) * plan.scale;
25181
- if (piece.trim().length > 0) {
25182
- const attrs = [`x="${pt(cursor)}"`, `y="${pt(y)}"`, `font-size="${pt(st.height)}"`];
25183
- if ([...piece].length > 1 && w > 50) {
25184
- attrs.push(`textLength="${pt(w)}"`, `lengthAdjust="${plan.scale < 1 ? "spacingAndGlyphs" : "spacing"}"`);
26228
+ const renderSeg = (text, cx, hit) => {
26229
+ const sw = measureTextWidth(text, st.height, st.ratio, { spacingPct: st.spacing }) * plan.scale;
26230
+ if (hit) {
26231
+ emit(ctx, `<rect x="${pt(cx)}" y="${pt(oy + seg.vertpos)}" width="${pt(sw)}" height="${pt(seg.textheight)}" fill="#ffd54f" fill-opacity="0.45"/>`);
26232
+ }
26233
+ if (text.trim().length > 0) {
26234
+ const attrs = [`x="${pt(cx)}"`, `y="${pt(y)}"`, `font-size="${pt(st.height)}"`];
26235
+ if ([...text].length > 1 && sw > 50) {
26236
+ attrs.push(`textLength="${pt(sw)}"`, `lengthAdjust="${plan.scale < 1 ? "spacingAndGlyphs" : "spacing"}"`);
26237
+ }
26238
+ if (st.bold) attrs.push(`font-weight="bold"`);
26239
+ if (st.italic) attrs.push(`font-style="italic"`);
26240
+ if (st.underline) attrs.push(`text-decoration="underline"`);
26241
+ if (st.color) attrs.push(`fill="${escapeXml3(st.color)}"`);
26242
+ emit(ctx, `<text ${attrs.join(" ")}>${escapeXml3(text)}</text>`);
26243
+ ctx.stats.texts++;
26244
+ }
26245
+ return sw;
26246
+ };
26247
+ const merged = [];
26248
+ if (ctx.highlights.length > 0 && piece.trim().length > 0) {
26249
+ const found = [];
26250
+ const lower = piece.toLowerCase();
26251
+ for (const term of ctx.highlights) {
26252
+ for (let f = lower.indexOf(term); f !== -1; f = lower.indexOf(term, f + term.length)) {
26253
+ found.push([f, f + term.length]);
26254
+ }
26255
+ }
26256
+ found.sort((a, b) => a[0] - b[0]);
26257
+ for (const [s, e] of found) {
26258
+ const tail = merged[merged.length - 1];
26259
+ if (tail && s <= tail[1]) tail[1] = Math.max(tail[1], e);
26260
+ else merged.push([s, e]);
25185
26261
  }
25186
- if (st.bold) attrs.push(`font-weight="bold"`);
25187
- if (st.italic) attrs.push(`font-style="italic"`);
25188
- if (st.underline) attrs.push(`text-decoration="underline"`);
25189
- if (st.color) attrs.push(`fill="${escapeXml3(st.color)}"`);
25190
- ctx.svg.push(`<text ${attrs.join(" ")}>${escapeXml3(piece)}</text>`);
25191
- ctx.stats.texts++;
25192
26262
  }
25193
- cursor += w;
25194
- for (const o of m.objs) if (o.inline && o.index === j) cursor += o.width;
26263
+ if (merged.length === 0) {
26264
+ cursor += renderSeg(piece, cursor, false);
26265
+ } else {
26266
+ let segCur = cursor;
26267
+ let last = 0;
26268
+ for (const [s, e] of merged) {
26269
+ segCur += renderSeg(piece.slice(last, s), segCur, false);
26270
+ segCur += renderSeg(piece.slice(s, e), segCur, true);
26271
+ last = e;
26272
+ }
26273
+ segCur += renderSeg(piece.slice(last), segCur, false);
26274
+ cursor = segCur;
26275
+ }
25195
26276
  i = j;
25196
26277
  }
25197
26278
  }
25198
26279
  for (const o of m.objs) {
25199
26280
  if (o.inline) {
25200
- let plan = plans[0];
25201
- for (const pl of plans) if (pl.start <= o.index && (o.index < pl.end || pl === plans[plans.length - 1])) plan = pl;
26281
+ let planIdx = 0;
26282
+ for (let k = 0; k < plans.length; k++) {
26283
+ const pl = plans[k];
26284
+ if (pl.start <= o.index && (o.index < pl.end || k === plans.length - 1)) planIdx = k;
26285
+ }
26286
+ const plan = plans[planIdx];
26287
+ if (segPages && segPages[planIdx] !== void 0) ctx.page = segPages[planIdx];
25202
26288
  const x = ox + plan.seg.horzpos + plan.xoff + advanceTo(m, ctx.styles, plan, o.index);
25203
26289
  const yTop = oy + plan.seg.vertpos + Math.max(0, plan.seg.baseline - o.height);
25204
26290
  drawObject(o, x, yTop, baseV, areaW, ctx, depth);
25205
26291
  } else {
26292
+ if (segPages && segPages[0] !== void 0) ctx.page = segPages[0];
25206
26293
  const { x, y } = anchorObject(o, ox, oy, baseV, areaW, ctx);
25207
26294
  drawObject(o, x, y, baseV, areaW, ctx, depth);
25208
26295
  }
@@ -25212,11 +26299,11 @@ function anchorObject(o, ox, oy, baseV, areaW, ctx) {
25212
26299
  const { PW, PH, ML, MT, BODY_W, BODY_H } = ctx.geom;
25213
26300
  const pos = findChildByLocalName(o.el, "pos");
25214
26301
  const om = findChildByLocalName(o.el, "outMargin");
25215
- const omT = num(om, "top"), omB = num(om, "bottom");
26302
+ const omT = num2(om, "top"), omB = num2(om, "bottom");
25216
26303
  const w = o.width, h = o.height;
25217
26304
  if (!pos) return { x: ox, y: oy + baseV };
25218
- const vo = num(pos, "vertOffset");
25219
- const ho = num(pos, "horzOffset");
26305
+ const vo = num2(pos, "vertOffset");
26306
+ const ho = num2(pos, "horzOffset");
25220
26307
  const vrel = _nullishCoalesce(pos.getAttribute("vertRelTo"), () => ( "PARA"));
25221
26308
  const hrel = _nullishCoalesce(pos.getAttribute("horzRelTo"), () => ( "PARA"));
25222
26309
  const va = _nullishCoalesce(pos.getAttribute("vertAlign"), () => ( "TOP"));
@@ -25248,36 +26335,85 @@ function drawObject(o, x, y, baseV, areaW, ctx, depth) {
25248
26335
  if (o.tag === "tbl") drawTable(o.el, x, y, ctx, depth + 1);
25249
26336
  else if (o.tag === "pic") drawPic(o.el, x, y, ctx);
25250
26337
  else if (o.tag === "container") {
25251
- for (const ch of elements(o.el)) {
25252
- const tag = ln(ch);
26338
+ for (const ch of elements2(o.el)) {
26339
+ const tag = ln2(ch);
25253
26340
  if (!OBJ_TAGS.has(tag)) continue;
25254
26341
  const sz = findChildByLocalName(ch, "sz");
25255
26342
  const off = findChildByLocalName(ch, "offset");
25256
- const sub = { el: ch, tag, index: 0, inline: true, width: num(sz, "width"), height: num(sz, "height") };
25257
- drawObject(sub, x + num(off, "x"), y + num(off, "y"), baseV, areaW, ctx, depth + 1);
26343
+ const sub = { el: ch, tag, index: 0, inline: true, width: num2(sz, "width"), height: num2(sz, "height") };
26344
+ drawObject(sub, x + num2(off, "x"), y + num2(off, "y"), baseV, areaW, ctx, depth + 1);
25258
26345
  }
25259
26346
  } else if (o.tag === "equation") {
25260
26347
  warnOnce(ctx, "equation", "\uC218\uC2DD \uAC1C\uCCB4\uB294 \uB80C\uB354 \uBBF8\uC9C0\uC6D0 \u2014 \uC0DD\uB7B5");
26348
+ } else if (SHAPE_TAGS.has(o.tag)) {
26349
+ drawShape(o, x, y, ctx, depth);
25261
26350
  } else {
25262
- warnOnce(ctx, `shape:${o.tag}`, `\uB3C4\uD615 \uAC1C\uCCB4(${o.tag}) \uB80C\uB354 \uBBF8\uC9C0\uC6D0 \u2014 \uC0DD\uB7B5`);
25263
- }
25264
- }
25265
- function cellContentExtent(cell, ctx) {
26351
+ warnOnce(ctx, `shape:${o.tag}`, `\uAC1C\uCCB4(${o.tag}) \uB80C\uB354 \uBBF8\uC9C0\uC6D0 \u2014 \uC0DD\uB7B5`);
26352
+ }
26353
+ }
26354
+ var SHAPE_TAGS = /* @__PURE__ */ new Set(["rect", "ellipse", "line", "polygon", "curv", "arc"]);
26355
+ function shapeStrokePt(v) {
26356
+ return Math.max(0.2, v / 100 * 2.834645);
26357
+ }
26358
+ function drawShape(o, x, y, ctx, depth) {
26359
+ const el = o.el;
26360
+ const orgSz = findChildByLocalName(el, "orgSz");
26361
+ const curSz = findChildByLocalName(el, "curSz");
26362
+ const ow = num2(orgSz, "width"), oh = num2(orgSz, "height");
26363
+ const w = num2(curSz, "width") || ow || o.width;
26364
+ const h = num2(curSz, "height") || oh || o.height;
26365
+ const sx = ow > 0 ? w / ow : 1;
26366
+ const sy = oh > 0 ? h / oh : 1;
26367
+ const lineShape = findChildByLocalName(el, "lineShape");
26368
+ const lstyle = _nullishCoalesce(_optionalChain([lineShape, 'optionalAccess', _299 => _299.getAttribute, 'call', _300 => _300("style")]), () => ( "SOLID"));
26369
+ const strokeCol = _optionalChain([lineShape, 'optionalAccess', _301 => _301.getAttribute, 'call', _302 => _302("color")]) || "#000000";
26370
+ const hasStroke = lstyle !== "NONE";
26371
+ const strokeW = hasStroke ? shapeStrokePt(lineShape ? num2(lineShape, "width") : 33) : 0;
26372
+ const dash = /DASH|DOT/.test(lstyle) ? ` stroke-dasharray="${lstyle.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
26373
+ const strokeAttr = hasStroke ? ` stroke="${escapeXml3(strokeCol)}" stroke-width="${strokeW.toFixed(2)}"${dash}` : "";
26374
+ const fillBrush = findChildByLocalName(el, "fillBrush");
26375
+ const winBrush = fillBrush ? findChildByLocalName(fillBrush, "winBrush") : null;
26376
+ const face = _optionalChain([winBrush, 'optionalAccess', _303 => _303.getAttribute, 'call', _304 => _304("faceColor")]);
26377
+ const fill = face && face.toLowerCase() !== "none" ? face : "none";
26378
+ const fillAttr = ` fill="${fill === "none" ? "none" : escapeXml3(fill)}"`;
26379
+ if (o.tag === "rect") {
26380
+ emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}"${fillAttr}${strokeAttr}/>`);
26381
+ } else if (o.tag === "ellipse") {
26382
+ emit(ctx, `<ellipse cx="${pt(x + w / 2)}" cy="${pt(y + h / 2)}" rx="${pt(w / 2)}" ry="${pt(h / 2)}"${fillAttr}${strokeAttr}/>`);
26383
+ } else if (o.tag === "line") {
26384
+ const s = findChildByLocalName(el, "startPt"), e = findChildByLocalName(el, "endPt");
26385
+ const x1 = x + num2(s, "x") * sx, y1 = y + num2(s, "y") * sy;
26386
+ const x2 = x + num2(e, "x") * sx, y2 = y + num2(e, "y") * sy;
26387
+ emit(ctx, `<line x1="${pt(x1)}" y1="${pt(y1)}" x2="${pt(x2)}" y2="${pt(y2)}" stroke="${escapeXml3(strokeCol)}" stroke-width="${(strokeW || 0.3).toFixed(2)}"${dash}/>`);
26388
+ } else if (o.tag === "polygon" || o.tag === "curv") {
26389
+ const pts = [];
26390
+ for (const c of elements2(el)) if (ln2(c) === "pt") pts.push(`${pt(x + num2(c, "x") * sx)},${pt(y + num2(c, "y") * sy)}`);
26391
+ if (pts.length >= 2) emit(ctx, `<polygon points="${pts.join(" ")}"${fillAttr}${strokeAttr}/>`);
26392
+ } else if (o.tag === "arc") {
26393
+ emit(ctx, `<ellipse cx="${pt(x + w / 2)}" cy="${pt(y + h / 2)}" rx="${pt(w / 2)}" ry="${pt(h / 2)}" fill="none"${strokeAttr || ` stroke="${escapeXml3(strokeCol)}" stroke-width="0.3"`}/>`);
26394
+ }
26395
+ const dt = findChildByLocalName(el, "drawText");
26396
+ const sub = dt ? findChildByLocalName(dt, "subList") : null;
26397
+ if (sub) {
26398
+ for (const p of elements2(sub)) if (ln2(p) === "p") drawPara(p, x, y, w, ctx, depth + 1);
26399
+ }
26400
+ }
26401
+ function cellContentExtent(cell) {
25266
26402
  if (!cell.sub) return 0;
25267
26403
  let ext = 0;
25268
- for (const p of elements(cell.sub)) {
25269
- if (ln(p) !== "p") continue;
26404
+ for (const p of elements2(cell.sub)) {
26405
+ if (ln2(p) !== "p") continue;
25270
26406
  const m = buildPara(p);
25271
26407
  for (const s of m.segs) ext = Math.max(ext, s.vertpos + s.textheight);
25272
- const baseV = _nullishCoalesce(_optionalChain([m, 'access', _286 => _286.segs, 'access', _287 => _287[0], 'optionalAccess', _288 => _288.vertpos]), () => ( 0));
26408
+ const baseV = _nullishCoalesce(_optionalChain([m, 'access', _305 => _305.segs, 'access', _306 => _306[0], 'optionalAccess', _307 => _307.vertpos]), () => ( 0));
25273
26409
  for (const o of m.objs) {
25274
26410
  if (o.inline) continue;
25275
26411
  const pos = findChildByLocalName(o.el, "pos");
25276
- if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _289 => _289.getAttribute, 'call', _290 => _290("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
26412
+ if ((_nullishCoalesce(_optionalChain([pos, 'optionalAccess', _308 => _308.getAttribute, 'call', _309 => _309("vertRelTo")]), () => ( "PARA"))) !== "PARA") continue;
25277
26413
  const om = findChildByLocalName(o.el, "outMargin");
25278
- const pushed = baseV - (num(om, "top") + o.height + num(om, "bottom"));
26414
+ const pushed = baseV - (num2(om, "top") + o.height + num2(om, "bottom"));
25279
26415
  const anchor = pushed >= -100 ? pushed : baseV;
25280
- ext = Math.max(ext, anchor + num(om, "top") + num(pos, "vertOffset") + o.height);
26416
+ ext = Math.max(ext, anchor + num2(om, "top") + num2(pos, "vertOffset") + o.height);
25281
26417
  }
25282
26418
  }
25283
26419
  return ext;
@@ -25286,21 +26422,15 @@ function edgeLine(x1, y1, x2, y2, e) {
25286
26422
  const dash = /DASH|DOT/.test(e.type) ? ` stroke-dasharray="${e.type.includes("DOT") ? "1,1.5" : "3,1.5"}"` : "";
25287
26423
  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}/>`;
25288
26424
  }
25289
- function drawTable(tbl, tx, ty, ctx, depth) {
25290
- if (depth > 16) {
25291
- warnOnce(ctx, "depth", "\uC911\uCCA9 \uAE4A\uC774 16 \uCD08\uACFC \u2014 \uC774\uD558 \uC0DD\uB7B5");
25292
- return;
25293
- }
25294
- ctx.stats.tables++;
25295
- const tblSz = findChildByLocalName(tbl, "sz");
26425
+ function collectCells(tbl) {
25296
26426
  const inMargin = findChildByLocalName(tbl, "inMargin");
25297
- const defL = num(inMargin, "left", 141), defR = num(inMargin, "right", 141);
25298
- const defT = num(inMargin, "top", 141), defB = num(inMargin, "bottom", 141);
26427
+ const defL = num2(inMargin, "left", 141), defR = num2(inMargin, "right", 141);
26428
+ const defT = num2(inMargin, "top", 141), defB = num2(inMargin, "bottom", 141);
25299
26429
  const cells = [];
25300
- for (const tr of elements(tbl)) {
25301
- if (ln(tr) !== "tr") continue;
25302
- for (const tc of elements(tr)) {
25303
- if (ln(tc) !== "tc") continue;
26430
+ for (const tr of elements2(tbl)) {
26431
+ if (ln2(tr) !== "tr") continue;
26432
+ for (const tc of elements2(tr)) {
26433
+ if (ln2(tc) !== "tc") continue;
25304
26434
  const addr = findChildByLocalName(tc, "cellAddr");
25305
26435
  const span = findChildByLocalName(tc, "cellSpan");
25306
26436
  const csz = findChildByLocalName(tc, "cellSz");
@@ -25308,28 +26438,50 @@ function drawTable(tbl, tx, ty, ctx, depth) {
25308
26438
  if (!addr || !csz) continue;
25309
26439
  cells.push({
25310
26440
  el: tc,
25311
- ca: num(addr, "colAddr"),
25312
- ra: num(addr, "rowAddr"),
25313
- cs: Math.max(1, num(span, "colSpan", 1)),
25314
- rs: Math.max(1, num(span, "rowSpan", 1)),
25315
- w: num(csz, "width"),
25316
- h: num(csz, "height"),
26441
+ ca: num2(addr, "colAddr"),
26442
+ ra: num2(addr, "rowAddr"),
26443
+ cs: Math.max(1, num2(span, "colSpan", 1)),
26444
+ rs: Math.max(1, num2(span, "rowSpan", 1)),
26445
+ w: num2(csz, "width"),
26446
+ h: num2(csz, "height"),
25317
26447
  bfId: tc.getAttribute("borderFillIDRef"),
25318
26448
  sub: findChildByLocalName(tc, "subList"),
25319
- marginL: cm ? num(cm, "left", defL) : defL,
25320
- marginR: cm ? num(cm, "right", defR) : defR,
25321
- marginT: cm ? num(cm, "top", defT) : defT,
25322
- marginB: cm ? num(cm, "bottom", defB) : defB
26449
+ marginL: cm ? num2(cm, "left", defL) : defL,
26450
+ marginR: cm ? num2(cm, "right", defR) : defR,
26451
+ marginT: cm ? num2(cm, "top", defT) : defT,
26452
+ marginB: cm ? num2(cm, "bottom", defB) : defB
25323
26453
  });
25324
26454
  }
25325
26455
  }
26456
+ return cells;
26457
+ }
26458
+ function measureTableHeight(tbl) {
26459
+ const cells = collectCells(tbl);
26460
+ if (cells.length === 0 || cells.length > 4096) return 0;
26461
+ const nRows = Math.max(...cells.map((c) => c.ra + c.rs));
26462
+ const rowH = solveRowHeights(
26463
+ cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: c.h, contentH: c.rs === 1 ? cellContentExtent(c) : void 0 })),
26464
+ nRows
26465
+ );
26466
+ let sum = 0;
26467
+ for (const h of rowH) sum += h;
26468
+ return sum;
26469
+ }
26470
+ function drawTable(tbl, tx, ty, ctx, depth) {
26471
+ if (depth > 16) {
26472
+ warnOnce(ctx, "depth", "\uC911\uCCA9 \uAE4A\uC774 16 \uCD08\uACFC \u2014 \uC774\uD558 \uC0DD\uB7B5");
26473
+ return;
26474
+ }
26475
+ ctx.stats.tables++;
26476
+ const tblSz = findChildByLocalName(tbl, "sz");
26477
+ const cells = collectCells(tbl);
25326
26478
  if (cells.length === 0 || cells.length > 4096) return;
25327
26479
  const nCols = Math.max(...cells.map((c) => c.ca + c.cs));
25328
26480
  const nRows = Math.max(...cells.map((c) => c.ra + c.rs));
25329
26481
  const colCons = cells.map((c) => ({ a: c.ca, b: c.ca + c.cs, size: c.w }));
25330
- const colX = solveBoundaries(colCons, nCols, num(tblSz, "width") || void 0);
26482
+ const colX = solveBoundaries(colCons, nCols, num2(tblSz, "width") || void 0);
25331
26483
  const rowH = solveRowHeights(
25332
- cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: c.h, contentH: c.rs === 1 ? cellContentExtent(c, ctx) : void 0 })),
26484
+ cells.map((c) => ({ rowAddr: c.ra, rowSpan: c.rs, height: c.h, contentH: c.rs === 1 ? cellContentExtent(c) : void 0 })),
25333
26485
  nRows
25334
26486
  );
25335
26487
  const rowY = [0];
@@ -25343,55 +26495,69 @@ function drawTable(tbl, tx, ty, ctx, depth) {
25343
26495
  }));
25344
26496
  for (const g of geom) {
25345
26497
  const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
25346
- 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)}"/>`);
26498
+ if (_optionalChain([bf, 'optionalAccess', _310 => _310.fill])) emit(ctx, `<rect x="${pt(g.x)}" y="${pt(g.y)}" width="${pt(g.w)}" height="${pt(g.h)}" fill="${escapeXml3(bf.fill)}"/>`);
25347
26499
  }
25348
26500
  for (const g of geom) {
25349
26501
  const { c } = g;
25350
26502
  if (!c.sub) continue;
25351
26503
  const innerH = g.h - c.marginT - c.marginB;
25352
- const extent = cellContentExtent(c, ctx);
26504
+ const extent = cellContentExtent(c);
25353
26505
  const va = _nullishCoalesce(c.sub.getAttribute("vertAlign"), () => ( "TOP"));
25354
26506
  let yoff = 0;
25355
26507
  if (va === "CENTER") yoff = Math.max(0, (innerH - extent) / 2);
25356
26508
  else if (va === "BOTTOM") yoff = Math.max(0, innerH - extent);
25357
- for (const p of elements(c.sub)) {
25358
- if (ln(p) !== "p") continue;
26509
+ for (const p of elements2(c.sub)) {
26510
+ if (ln2(p) !== "p") continue;
25359
26511
  drawPara(p, g.x + c.marginL, g.y + c.marginT + yoff, g.w - c.marginL - c.marginR, ctx, depth + 1);
25360
26512
  }
25361
26513
  }
25362
26514
  for (const g of geom) {
25363
26515
  const bf = g.c.bfId != null ? ctx.styles.borderFill.get(g.c.bfId) : void 0;
25364
26516
  if (!bf) continue;
25365
- if (bf.top) ctx.svg.push(edgeLine(g.x, g.y, g.x + g.w, g.y, bf.top));
25366
- if (bf.bottom) ctx.svg.push(edgeLine(g.x, g.y + g.h, g.x + g.w, g.y + g.h, bf.bottom));
25367
- if (bf.left) ctx.svg.push(edgeLine(g.x, g.y, g.x, g.y + g.h, bf.left));
25368
- if (bf.right) ctx.svg.push(edgeLine(g.x + g.w, g.y, g.x + g.w, g.y + g.h, bf.right));
26517
+ if (bf.top) emit(ctx, edgeLine(g.x, g.y, g.x + g.w, g.y, bf.top));
26518
+ if (bf.bottom) emit(ctx, edgeLine(g.x, g.y + g.h, g.x + g.w, g.y + g.h, bf.bottom));
26519
+ if (bf.left) emit(ctx, edgeLine(g.x, g.y, g.x, g.y + g.h, bf.left));
26520
+ if (bf.right) emit(ctx, edgeLine(g.x + g.w, g.y, g.x + g.w, g.y + g.h, bf.right));
26521
+ }
26522
+ }
26523
+ function imageSymbol(loaded, ctx) {
26524
+ if (!loaded.symId) {
26525
+ loaded.symId = `bin${ctx.defs.length}`;
26526
+ ctx.defs.push(
26527
+ `<symbol id="${loaded.symId}" viewBox="0 0 100 100" preserveAspectRatio="none"><image width="100" height="100" preserveAspectRatio="none" href="${loaded.dataUri}"/></symbol>`
26528
+ );
25369
26529
  }
26530
+ return loaded.symId;
25370
26531
  }
25371
26532
  function drawPic(pic, x, y, ctx) {
25372
26533
  const sz = findChildByLocalName(pic, "sz");
25373
- const w = num(sz, "width", 5669), h = num(sz, "height", 5669);
26534
+ const w = num2(sz, "width", 5669), h = num2(sz, "height", 5669);
25374
26535
  const img = findFirst(pic, "img");
25375
- const ref = _optionalChain([img, 'optionalAccess', _292 => _292.getAttribute, 'call', _293 => _293("binaryItemIDRef")]);
26536
+ const ref = _optionalChain([img, 'optionalAccess', _311 => _311.getAttribute, 'call', _312 => _312("binaryItemIDRef")]);
25376
26537
  const loaded = ref != null ? ctx.images.get(ref) : void 0;
25377
26538
  if (!loaded) {
25378
- ctx.svg.push(`<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
26539
+ emit(ctx, `<rect x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" fill="#eee" stroke="#c00" stroke-width="0.5"/>`);
25379
26540
  warnOnce(ctx, `img:${ref}`, `\uC774\uBBF8\uC9C0 \uBC14\uC774\uB108\uB9AC \uB204\uB77D: ${_nullishCoalesce(ref, () => ( "(ref \uC5C6\uC74C)"))}`);
25380
26541
  return;
25381
26542
  }
25382
26543
  ctx.stats.images++;
25383
- const orgSz = findChildByLocalName(pic, "orgSz");
25384
26544
  const clip = findChildByLocalName(pic, "imgClip");
25385
- const orgW = num(orgSz, "width"), orgH = num(orgSz, "height");
25386
- const cl = num(clip, "left"), ct = num(clip, "top");
25387
- const cr = num(clip, "right", orgW), cb = num(clip, "bottom", orgH);
25388
- const cropped = orgW > 0 && orgH > 0 && clip != null && (cl > 0 || ct > 0 || cr < orgW || cb < orgH) && cr > cl && cb > ct;
26545
+ const imgDim = findChildByLocalName(pic, "imgDim");
26546
+ const orgSz = findChildByLocalName(pic, "orgSz");
26547
+ const dimW = num2(imgDim, "dimwidth"), dimH = num2(imgDim, "dimheight");
26548
+ const refW = dimW > 0 ? dimW : num2(orgSz, "width");
26549
+ const refH = dimH > 0 ? dimH : num2(orgSz, "height");
26550
+ const cl = num2(clip, "left"), ct = num2(clip, "top");
26551
+ const cr = num2(clip, "right", refW), cb = num2(clip, "bottom", refH);
26552
+ const cropped = refW > 0 && refH > 0 && clip != null && (cl > 0 || ct > 0 || cr < refW || cb < refH) && cr > cl && cb > ct;
26553
+ const symId = imageSymbol(loaded, ctx);
25389
26554
  if (cropped) {
25390
- ctx.svg.push(
25391
- `<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>`
26555
+ emit(
26556
+ ctx,
26557
+ `<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"><use href="#${symId}" x="0" y="0" width="${pt(refW)}" height="${pt(refH)}"/></svg>`
25392
26558
  );
25393
26559
  } else {
25394
- ctx.svg.push(`<image x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}" preserveAspectRatio="none" href="${loaded.dataUri}"/>`);
26560
+ emit(ctx, `<use href="#${symId}" x="${pt(x)}" y="${pt(y)}" width="${pt(w)}" height="${pt(h)}"/>`);
25395
26561
  }
25396
26562
  }
25397
26563
  function sniffMime(name, bytes) {
@@ -25403,23 +26569,24 @@ function sniffMime(name, bytes) {
25403
26569
  return "image/jpeg";
25404
26570
  }
25405
26571
  async function renderHwpxToSvg(input, options) {
25406
- const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _294 => _294.maxImageBytes]), () => ( 40 * 1024 * 1024));
26572
+ const maxImg = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _313 => _313.maxImageBytes]), () => ( 40 * 1024 * 1024));
25407
26573
  let zip;
25408
26574
  try {
25409
26575
  zip = await _jszip2.default.loadAsync(input);
25410
26576
  } catch (e31) {
25411
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
26577
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("HWPX(ZIP) \uD615\uC2DD\uC774 \uC544\uB2D9\uB2C8\uB2E4 \u2014 \uB80C\uB354\uB294 HWPX\uB9CC \uC9C0\uC6D0");
25412
26578
  }
25413
26579
  const secFile = _nullishCoalesce(zip.file("Contents/section0.xml"), () => ( zip.file(/Contents\/section\d+\.xml$/i).sort((a, b) => a.name.localeCompare(b.name))[0]));
25414
- if (!secFile) throw new (0, _chunkMEXUFQVCcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
26580
+ if (!secFile) throw new (0, _chunkBIP4JAVGcjs.KordocError)("Contents/section0.xml \uC5C6\uC74C \u2014 HWPX\uAC00 \uC544\uB2C8\uAC70\uB098 \uC190\uC0C1\uB428");
25415
26581
  const secXml = await secFile.async("string");
25416
- if (secXml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
25417
- if (!secXml.includes("linesegarray")) {
25418
- throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC870\uD310 \uCE90\uC2DC(linesegarray) \uC5C6\uC74C \u2014 \uD55C\uCEF4\uC5D0\uC11C \uC800\uC7A5\uD55C HWPX\uB9CC \uB80C\uB354 \uAC00\uB2A5");
26582
+ if (secXml.length > MAX_DECOMPRESS_SIZE) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC139\uC158 XML\uC774 \uD5C8\uC6A9 \uD06C\uAE30\uB97C \uCD08\uACFC");
26583
+ const hasCache = /<(?:[A-Za-z][\w.-]*:)?linesegarray[\s/>]/.test(secXml);
26584
+ if (!hasCache && !_optionalChain([options, 'optionalAccess', _314 => _314.reflow])) {
26585
+ throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC870\uD310 \uCE90\uC2DC(linesegarray) \uC5C6\uC74C \u2014 \uD55C\uCEF4\uC5D0\uC11C \uC800\uC7A5\uD55C HWPX\uB9CC \uB80C\uB354 \uAC00\uB2A5 (reflow \uC635\uC158\uC73C\uB85C \uD569\uC131 \uB80C\uB354 \uAC00\uB2A5)");
25419
26586
  }
25420
26587
  const warnings = [];
25421
26588
  const headFile = _nullishCoalesce(zip.file("Contents/header.xml"), () => ( zip.file("Contents/head.xml")));
25422
- const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
26589
+ const styles = headFile ? parseRenderStyles(await headFile.async("string")) : { charPr: /* @__PURE__ */ new Map(), paraAlign: /* @__PURE__ */ new Map(), paraGeom: /* @__PURE__ */ new Map(), borderFill: /* @__PURE__ */ new Map() };
25423
26590
  if (!headFile) warnings.push("header.xml \uC5C6\uC74C \u2014 \uAE30\uBCF8 \uC2A4\uD0C0\uC77C\uB85C \uB80C\uB354");
25424
26591
  const binmap = /* @__PURE__ */ new Map();
25425
26592
  const hpf = zip.file(/content\.hpf$/i)[0];
@@ -25428,14 +26595,21 @@ async function renderHwpxToSvg(input, options) {
25428
26595
  for (const m of man.matchAll(/<[^>]*\bid="([^"]+)"[^>]*\bhref="(BinData\/[^"]+)"[^>]*>/g)) binmap.set(m[1], m[2]);
25429
26596
  for (const m of man.matchAll(/<[^>]*\bhref="(BinData\/[^"]+)"[^>]*\bid="([^"]+)"[^>]*>/g)) binmap.set(m[2], m[1]);
25430
26597
  }
26598
+ const MAX_IMAGE_REFS = 256;
26599
+ const MAX_TOTAL_IMAGE_BYTES = 128 * 1024 * 1024;
25431
26600
  const images = /* @__PURE__ */ new Map();
25432
26601
  const refs = /* @__PURE__ */ new Set();
25433
26602
  for (const m of secXml.matchAll(/binaryItemIDRef="([^"]+)"/g)) refs.add(m[1]);
26603
+ let totalImgBytes = 0;
25434
26604
  for (const ref of refs) {
26605
+ if (images.size >= MAX_IMAGE_REFS) {
26606
+ warnings.push(`\uC774\uBBF8\uC9C0 ${refs.size}\uC885 \uC911 ${MAX_IMAGE_REFS}\uC885\uB9CC \uB85C\uB529 \u2014 \uAC1C\uC218 \uD55C\uB3C4 \uCD08\uACFC\uBD84 \uC0DD\uB7B5`);
26607
+ break;
26608
+ }
25435
26609
  let href = binmap.get(ref);
25436
26610
  if (!href) {
25437
26611
  const cand = zip.file(new RegExp(`BinData/.*${ref.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "i"))[0];
25438
- href = _optionalChain([cand, 'optionalAccess', _295 => _295.name]);
26612
+ href = _optionalChain([cand, 'optionalAccess', _315 => _315.name]);
25439
26613
  }
25440
26614
  if (!href) continue;
25441
26615
  const f = _nullishCoalesce(zip.file(href), () => ( zip.file("Contents/" + href)));
@@ -25445,55 +26619,96 @@ async function renderHwpxToSvg(input, options) {
25445
26619
  warnings.push(`\uC774\uBBF8\uC9C0 ${href} ${(bytes.length / 1048576).toFixed(1)}MB \u2014 \uD55C\uB3C4 \uCD08\uACFC\uB85C \uC0DD\uB7B5`);
25446
26620
  continue;
25447
26621
  }
26622
+ if (totalImgBytes + bytes.length > MAX_TOTAL_IMAGE_BYTES) {
26623
+ warnings.push(`\uC774\uBBF8\uC9C0 \uB204\uC801 ${Math.round(MAX_TOTAL_IMAGE_BYTES / 1048576)}MB \uD55C\uB3C4 \uCD08\uACFC \u2014 \uC774\uD6C4 \uC0DD\uB7B5`);
26624
+ break;
26625
+ }
26626
+ totalImgBytes += bytes.length;
25448
26627
  images.set(ref, { dataUri: `data:${sniffMime(href, bytes)};base64,${Buffer.from(bytes).toString("base64")}` });
25449
26628
  }
25450
26629
  const doc = createXmlParser().parseFromString(secXml, "text/xml");
25451
26630
  const root = doc.documentElement;
25452
- if (!root) throw new (0, _chunkMEXUFQVCcjs.KordocError)("\uC139\uC158 XML \uD30C\uC2F1 \uC2E4\uD328");
26631
+ if (!root) throw new (0, _chunkBIP4JAVGcjs.KordocError)("\uC139\uC158 XML \uD30C\uC2F1 \uC2E4\uD328");
25453
26632
  const pagePr = findFirst(root, "pagePr");
25454
26633
  const margin = pagePr ? findChildByLocalName(pagePr, "margin") : null;
25455
- const PW = num(pagePr, "width", 59528), PH = num(pagePr, "height", 84188);
25456
- const ML = num(margin, "left", 8504);
25457
- const MT = num(margin, "top", 5668) + num(margin, "header", 0);
25458
- const BODY_H = PH - MT - num(margin, "bottom", 4252) - num(margin, "footer", 0);
25459
- const BODY_W = PW - ML - num(margin, "right", 8504);
26634
+ const PW = num2(pagePr, "width", 59528), PH = num2(pagePr, "height", 84188);
26635
+ const ML = num2(margin, "left", 8504);
26636
+ const MT = num2(margin, "top", 5668) + num2(margin, "header", 0);
26637
+ const BODY_H = PH - MT - num2(margin, "bottom", 4252) - num2(margin, "footer", 0);
26638
+ const BODY_W = PW - ML - num2(margin, "right", 8504);
26639
+ if (!hasCache) reflowSection(root, styles, { BODY_W, BODY_H }, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _316 => _316.reflowMode]), () => ( "keep")));
26640
+ const colPr = findFirst(root, "colPr");
26641
+ const multiCol = num2(colPr, "colCount", 1) > 1;
26642
+ const paraSegPages = /* @__PURE__ */ new Map();
26643
+ let nPages = 1;
26644
+ let maxTopV = 0;
26645
+ {
26646
+ let prevV = Number.NEGATIVE_INFINITY;
26647
+ let prevH = Number.NEGATIVE_INFINITY;
26648
+ let cur = 0;
26649
+ for (const p of elements2(root)) {
26650
+ if (ln2(p) !== "p") continue;
26651
+ const lsa = findChildByLocalName(p, "linesegarray");
26652
+ const segEls = lsa ? elements2(lsa).filter((s) => ln2(s) === "lineseg") : [];
26653
+ const pagesOf = [];
26654
+ for (const s of segEls) {
26655
+ const v = num2(s, "vertpos");
26656
+ const h = num2(s, "horzpos");
26657
+ if (v < prevV && (!multiCol || h <= prevH)) cur++;
26658
+ pagesOf.push(cur);
26659
+ maxTopV = Math.max(maxTopV, v + num2(s, "textheight", 1e3));
26660
+ prevV = v;
26661
+ prevH = h;
26662
+ }
26663
+ paraSegPages.set(p, pagesOf);
26664
+ nPages = Math.max(nPages, cur + 1);
26665
+ }
26666
+ }
25460
26667
  const ctx = {
25461
- svg: [],
26668
+ pages: Array.from({ length: nPages }, () => []),
26669
+ page: 0,
25462
26670
  geom: { PW, PH, ML, MT, BODY_W, BODY_H },
25463
26671
  styles,
25464
26672
  images,
26673
+ defs: [],
26674
+ highlights: (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _317 => _317.highlights]), () => ( []))).map((s) => s.trim().toLowerCase()).filter((s) => s.length > 0),
25465
26675
  warnings,
25466
26676
  warned: /* @__PURE__ */ new Set(),
25467
26677
  stats: { texts: 0, images: 0, tables: 0 }
25468
26678
  };
25469
- for (const p of elements(root)) {
25470
- if (ln(p) !== "p") continue;
25471
- const segs = findChildByLocalName(p, "linesegarray");
25472
- const first = segs ? elements(segs)[0] : null;
25473
- if (first && num(first, "vertpos") > BODY_H) continue;
25474
- drawPara(p, ML, MT, BODY_W, ctx, 0);
25475
- }
25476
- 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">
25477
- <rect width="100%" height="100%" fill="white"/>
25478
- ${ctx.svg.join("\n")}
26679
+ for (const p of elements2(root)) {
26680
+ if (ln2(p) !== "p") continue;
26681
+ drawPara(p, ML, MT, BODY_W, ctx, 0, paraSegPages.get(p));
26682
+ }
26683
+ const pageH = nPages === 1 ? Math.max(PH, MT + maxTopV + 2e3) : PH;
26684
+ const GAP = 2400;
26685
+ const totalH = nPages * pageH + (nPages - 1) * GAP;
26686
+ const pagesSvg = ctx.pages.map(
26687
+ (buf, k) => `<g data-page="${k + 1}" transform="translate(0 ${pt(k * (pageH + GAP))})"><rect width="${pt(PW)}" height="${pt(pageH)}" fill="white" stroke="#c9c7c4" stroke-width="0.75"/><g clip-path="url(#pgclip)">
26688
+ ${buf.join("\n")}
26689
+ </g></g>`
26690
+ ).join("\n");
26691
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${pt(PW)} ${pt(totalH)}" width="${pt(PW)}pt" height="${pt(totalH)}pt" font-family="'HCR Batang','\uD568\uCD08\uB86C\uBC14\uD0D5','Hancom Batang',AppleMyungjo,'Noto Serif CJK KR',serif" xml:space="preserve">
26692
+ <defs><clipPath id="pgclip"><rect x="0" y="0" width="${pt(PW)}" height="${pt(pageH)}"/></clipPath>${ctx.defs.join("")}</defs>
26693
+ ${pagesSvg}
25479
26694
  </svg>`;
25480
- return { svg, width: Math.round(PW) / 100, height: Math.round(PH) / 100, warnings, stats: ctx.stats };
26695
+ return { svg, width: Math.round(PW) / 100, height: Math.round(totalH) / 100, pageCount: nPages, warnings, stats: ctx.stats };
25481
26696
  }
25482
26697
 
25483
26698
  // src/index.ts
25484
26699
  async function parse(input, options) {
25485
26700
  let buffer;
25486
- const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _296 => _296.filePath]) ? { ...options, filePath: input } : options;
26701
+ const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _318 => _318.filePath]) ? { ...options, filePath: input } : options;
25487
26702
  if (typeof input === "string") {
25488
26703
  try {
25489
26704
  const buf = await _promises.readFile.call(void 0, input);
25490
- buffer = _chunkMEXUFQVCcjs.toArrayBuffer.call(void 0, buf);
26705
+ buffer = _chunkBIP4JAVGcjs.toArrayBuffer.call(void 0, buf);
25491
26706
  } catch (err) {
25492
26707
  const msg2 = err instanceof Error && "code" in err && err.code === "ENOENT" ? `\uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4: ${input}` : `\uD30C\uC77C \uC77D\uAE30 \uC2E4\uD328: ${input}`;
25493
26708
  return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
25494
26709
  }
25495
26710
  } else if (Buffer.isBuffer(input)) {
25496
- buffer = _chunkMEXUFQVCcjs.toArrayBuffer.call(void 0, input);
26711
+ buffer = _chunkBIP4JAVGcjs.toArrayBuffer.call(void 0, input);
25497
26712
  } else {
25498
26713
  buffer = input;
25499
26714
  }
@@ -25528,21 +26743,21 @@ async function parseHwp3(buffer, options) {
25528
26743
  const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
25529
26744
  return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
25530
26745
  } catch (err) {
25531
- return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err) };
26746
+ return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err) };
25532
26747
  }
25533
26748
  }
25534
26749
  async function parseHwpx(buffer, options) {
25535
26750
  try {
25536
26751
  const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
25537
- return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _297 => _297.length]) ? images : void 0 };
26752
+ return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _319 => _319.length]) ? images : void 0 };
25538
26753
  } catch (err) {
25539
- return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err) };
26754
+ return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err) };
25540
26755
  }
25541
26756
  }
25542
26757
  async function parseHwp(buffer, options) {
25543
26758
  try {
25544
26759
  const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
25545
- if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _298 => _298.filePath])) {
26760
+ if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _320 => _320.filePath])) {
25546
26761
  try {
25547
26762
  const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
25548
26763
  if (pages.some((p) => p && p.trim().length > 0)) {
@@ -25559,15 +26774,15 @@ async function parseHwp(buffer, options) {
25559
26774
  } catch (e32) {
25560
26775
  }
25561
26776
  }
25562
- return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _299 => _299.length]) ? images : void 0 };
26777
+ return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _321 => _321.length]) ? images : void 0 };
25563
26778
  } catch (err) {
25564
- return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err) };
26779
+ return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err) };
25565
26780
  }
25566
26781
  }
25567
26782
  async function parsePdf(buffer, options) {
25568
26783
  let parsePdfDocument;
25569
26784
  try {
25570
- const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-DZBI3EA2.cjs")));
26785
+ const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-6V7F3GET.cjs")));
25571
26786
  parsePdfDocument = mod.parsePdfDocument;
25572
26787
  } catch (e33) {
25573
26788
  return {
@@ -25582,7 +26797,7 @@ async function parsePdf(buffer, options) {
25582
26797
  return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
25583
26798
  } catch (err) {
25584
26799
  const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
25585
- return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err), isImageBased };
26800
+ return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err), isImageBased };
25586
26801
  }
25587
26802
  }
25588
26803
  async function parseXlsx(buffer, options) {
@@ -25590,7 +26805,7 @@ async function parseXlsx(buffer, options) {
25590
26805
  const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
25591
26806
  return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
25592
26807
  } catch (err) {
25593
- return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err) };
26808
+ return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err) };
25594
26809
  }
25595
26810
  }
25596
26811
  async function parseXls(buffer, options) {
@@ -25598,15 +26813,15 @@ async function parseXls(buffer, options) {
25598
26813
  const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
25599
26814
  return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
25600
26815
  } catch (err) {
25601
- return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err) };
26816
+ return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err) };
25602
26817
  }
25603
26818
  }
25604
26819
  async function parseDocx(buffer, options) {
25605
26820
  try {
25606
26821
  const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
25607
- return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _300 => _300.length]) ? images : void 0 };
26822
+ return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _322 => _322.length]) ? images : void 0 };
25608
26823
  } catch (err) {
25609
- return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err) };
26824
+ return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err) };
25610
26825
  }
25611
26826
  }
25612
26827
  async function parseHwpml(buffer, options) {
@@ -25614,16 +26829,16 @@ async function parseHwpml(buffer, options) {
25614
26829
  const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
25615
26830
  return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
25616
26831
  } catch (err) {
25617
- return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkMEXUFQVCcjs.classifyError.call(void 0, err) };
26832
+ return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkBIP4JAVGcjs.classifyError.call(void 0, err) };
25618
26833
  }
25619
26834
  }
25620
26835
  async function fillForm(input, values, outputFormat = "markdown") {
25621
26836
  let buffer;
25622
26837
  if (typeof input === "string") {
25623
26838
  const buf = await _promises.readFile.call(void 0, input);
25624
- buffer = _chunkMEXUFQVCcjs.toArrayBuffer.call(void 0, buf);
26839
+ buffer = _chunkBIP4JAVGcjs.toArrayBuffer.call(void 0, buf);
25625
26840
  } else if (Buffer.isBuffer(input)) {
25626
- buffer = _chunkMEXUFQVCcjs.toArrayBuffer.call(void 0, input);
26841
+ buffer = _chunkBIP4JAVGcjs.toArrayBuffer.call(void 0, input);
25627
26842
  } else {
25628
26843
  buffer = input;
25629
26844
  }
@@ -25649,7 +26864,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
25649
26864
  throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
25650
26865
  }
25651
26866
  const fill = fillFormFields(parsed.blocks, values);
25652
- const markdown = _chunkMEXUFQVCcjs.blocksToMarkdown.call(void 0, fill.blocks);
26867
+ const markdown = _chunkBIP4JAVGcjs.blocksToMarkdown.call(void 0, fill.blocks);
25653
26868
  if (outputFormat === "hwpx") {
25654
26869
  const hwpxBuffer = await markdownToHwpx(markdown);
25655
26870
  return { output: hwpxBuffer, format: "hwpx", fill };
@@ -25708,5 +26923,9 @@ async function fillForm(input, values, outputFormat = "markdown") {
25708
26923
 
25709
26924
 
25710
26925
 
25711
- exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkMEXUFQVCcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkMEXUFQVCcjs.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;
26926
+
26927
+
26928
+
26929
+
26930
+ exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkBIP4JAVGcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkBIP4JAVGcjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.charWidthEm1000 = charWidthEm1000; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.fillWithUniqueGuard = fillWithUniqueGuard; exports.fitRatioForFewerLines = fitRatioForFewerLines; exports.formatFillValue = formatFillValue; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.measureTextWidth = measureTextWidth; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.placeSealHwpx = placeSealHwpx; exports.renderHtml = renderHtml; exports.renderHwpxToSvg = renderHwpxToSvg; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord; exports.validateHwpx = validateHwpx;
25712
26931
  //# sourceMappingURL=index.cjs.map