kordoc 3.7.0 → 3.8.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.
package/dist/index.cjs CHANGED
@@ -19,7 +19,7 @@
19
19
 
20
20
 
21
21
 
22
- var _chunkQZCP3UWUcjs = require('./chunk-QZCP3UWU.cjs');
22
+ var _chunkITJIALN5cjs = require('./chunk-ITJIALN5.cjs');
23
23
 
24
24
 
25
25
  var _chunkDCZVOIEOcjs = require('./chunk-DCZVOIEO.cjs');
@@ -845,7 +845,7 @@ function createSectionShared() {
845
845
  function createXmlParser(warnings) {
846
846
  return new (0, _xmldom.DOMParser)({
847
847
  onError(level, msg2) {
848
- if (level === "fatalError") throw new (0, _chunkQZCP3UWUcjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
848
+ if (level === "fatalError") throw new (0, _chunkITJIALN5cjs.KordocError)(`XML \uD30C\uC2F1 \uC2E4\uD328: ${msg2}`);
849
849
  _optionalChain([warnings, 'optionalAccess', _3 => _3.push, 'call', _4 => _4({ code: "MALFORMED_XML", message: `XML ${level === "warn" ? "\uACBD\uACE0" : "\uC624\uB958"}: ${msg2}` })]);
850
850
  }
851
851
  });
@@ -867,10 +867,10 @@ async function extractHwpxStyles(zip, decompressed) {
867
867
  const xml = await file.async("text");
868
868
  if (decompressed) {
869
869
  decompressed.total += xml.length * 2;
870
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkQZCP3UWUcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
870
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkITJIALN5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
871
871
  }
872
872
  const parser = createXmlParser();
873
- const doc = parser.parseFromString(_chunkQZCP3UWUcjs.stripDtd.call(void 0, xml), "text/xml");
873
+ const doc = parser.parseFromString(_chunkITJIALN5cjs.stripDtd.call(void 0, xml), "text/xml");
874
874
  if (!doc.documentElement) continue;
875
875
  parseCharProperties(doc, result.charProperties);
876
876
  parseStyleElements(doc, result.styles);
@@ -1092,7 +1092,7 @@ function resolveParaHeading(paraEl, ctx) {
1092
1092
  return { prefix, headingLevel };
1093
1093
  }
1094
1094
  async function parseHwpxDocument(buffer, options) {
1095
- _chunkQZCP3UWUcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
1095
+ _chunkITJIALN5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE, MAX_ZIP_ENTRIES);
1096
1096
  let zip;
1097
1097
  try {
1098
1098
  zip = await _jszip2.default.loadAsync(buffer);
@@ -1101,7 +1101,7 @@ async function parseHwpxDocument(buffer, options) {
1101
1101
  }
1102
1102
  const actualEntryCount = Object.keys(zip.files).length;
1103
1103
  if (actualEntryCount > MAX_ZIP_ENTRIES) {
1104
- throw new (0, _chunkQZCP3UWUcjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1104
+ throw new (0, _chunkITJIALN5cjs.KordocError)("ZIP \uC5D4\uD2B8\uB9AC \uC218 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1105
1105
  }
1106
1106
  const manifestFile = zip.file("META-INF/manifest.xml");
1107
1107
  if (manifestFile) {
@@ -1113,7 +1113,7 @@ async function parseHwpxDocument(buffer, options) {
1113
1113
  return comResultToParseResult(pages, pageCount, warnings2);
1114
1114
  }
1115
1115
  }
1116
- throw new (0, _chunkQZCP3UWUcjs.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.");
1116
+ throw new (0, _chunkITJIALN5cjs.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.");
1117
1117
  }
1118
1118
  }
1119
1119
  const decompressed = { total: 0 };
@@ -1122,7 +1122,7 @@ async function parseHwpxDocument(buffer, options) {
1122
1122
  const styleMap = await extractHwpxStyles(zip, decompressed);
1123
1123
  const warnings = [];
1124
1124
  const sectionPaths = await resolveSectionPaths(zip);
1125
- if (sectionPaths.length === 0) throw new (0, _chunkQZCP3UWUcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
1125
+ if (sectionPaths.length === 0) throw new (0, _chunkITJIALN5cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
1126
1126
  metadata.pageCount = sectionPaths.length;
1127
1127
  const pageFilter = _optionalChain([options, 'optionalAccess', _12 => _12.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sectionPaths.length) : null;
1128
1128
  const totalTarget = pageFilter ? pageFilter.size : sectionPaths.length;
@@ -1136,12 +1136,12 @@ async function parseHwpxDocument(buffer, options) {
1136
1136
  try {
1137
1137
  const xml = await file.async("text");
1138
1138
  decompressed.total += xml.length * 2;
1139
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkQZCP3UWUcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1139
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkITJIALN5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1140
1140
  blocks.push(...parseSectionXml(xml, styleMap, warnings, si + 1, shared));
1141
1141
  parsedSections++;
1142
1142
  _optionalChain([options, 'optionalAccess', _13 => _13.onProgress, 'optionalCall', _14 => _14(parsedSections, totalTarget)]);
1143
1143
  } catch (secErr) {
1144
- if (secErr instanceof _chunkQZCP3UWUcjs.KordocError) throw secErr;
1144
+ if (secErr instanceof _chunkITJIALN5cjs.KordocError) throw secErr;
1145
1145
  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" });
1146
1146
  }
1147
1147
  }
@@ -1149,7 +1149,7 @@ async function parseHwpxDocument(buffer, options) {
1149
1149
  const images = await extractImagesFromZip(zip, blocks, decompressed, warnings);
1150
1150
  detectHwpxHeadings(blocks, styleMap);
1151
1151
  const outline = blocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
1152
- const markdown = _chunkQZCP3UWUcjs.blocksToMarkdown.call(void 0, blocks);
1152
+ const markdown = _chunkITJIALN5cjs.blocksToMarkdown.call(void 0, blocks);
1153
1153
  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 };
1154
1154
  }
1155
1155
  function applyPageText(blocks, shared) {
@@ -1215,57 +1215,62 @@ async function extractImagesFromZip(zip, blocks, decompressed, warnings) {
1215
1215
  let imageIndex = 0;
1216
1216
  const imageBlocks = [];
1217
1217
  collectImageBlocks(blocks, imageBlocks);
1218
+ const resolved = /* @__PURE__ */ new Map();
1218
1219
  for (const { block, ownerCell } of imageBlocks) {
1219
1220
  if (block.type !== "image" || !block.text) continue;
1220
1221
  const ref = block.text;
1221
- const candidates = [
1222
- `BinData/${ref}`,
1223
- `Contents/BinData/${ref}`,
1224
- ref
1225
- // 절대 경로일 수도 있음
1226
- ];
1227
- let resolvedPath = null;
1228
- if (!ref.includes(".")) {
1229
- const prefixes = [`BinData/${ref}`, `Contents/BinData/${ref}`];
1230
- for (const prefix of prefixes) {
1231
- const match = zip.file(new RegExp(`^${prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\.[a-zA-Z0-9]+$`));
1232
- if (match.length > 0) {
1233
- resolvedPath = match[0].name;
1234
- break;
1222
+ let img = resolved.get(ref);
1223
+ if (img === void 0) {
1224
+ img = null;
1225
+ const candidates = [
1226
+ `BinData/${ref}`,
1227
+ `Contents/BinData/${ref}`,
1228
+ ref
1229
+ // 절대 경로일 수도 있음
1230
+ ];
1231
+ let resolvedPath = null;
1232
+ if (!ref.includes(".")) {
1233
+ const prefixes = [`BinData/${ref}`, `Contents/BinData/${ref}`];
1234
+ for (const prefix of prefixes) {
1235
+ const match = zip.file(new RegExp(`^${prefix.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\.[a-zA-Z0-9]+$`));
1236
+ if (match.length > 0) {
1237
+ resolvedPath = match[0].name;
1238
+ break;
1239
+ }
1235
1240
  }
1236
1241
  }
1237
- }
1238
- let found = false;
1239
- const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
1240
- for (const path of allCandidates) {
1241
- if (_chunkQZCP3UWUcjs.isPathTraversal.call(void 0, path)) continue;
1242
- const file = zip.file(path);
1243
- if (!file) continue;
1244
- try {
1245
- const data = await file.async("uint8array");
1246
- decompressed.total += data.length;
1247
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkQZCP3UWUcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1248
- const actualPath = path;
1249
- const ext = actualPath.includes(".") ? actualPath.split(".").pop() || "png" : "png";
1250
- const mimeType = imageExtToMime(ext);
1251
- imageIndex++;
1252
- const filename = `image_${String(imageIndex).padStart(3, "0")}.${mimeToExt(mimeType)}`;
1253
- images.push({ filename, data, mimeType });
1254
- block.text = filename;
1255
- block.imageData = { data, mimeType, filename: ref };
1256
- if (ownerCell) ownerCell.text = ownerCell.text.replace(`![image](${ref})`, `![image](${filename})`);
1257
- found = true;
1258
- break;
1259
- } catch (err) {
1260
- if (err instanceof _chunkQZCP3UWUcjs.KordocError) throw err;
1242
+ const allCandidates = resolvedPath ? [resolvedPath, ...candidates] : candidates;
1243
+ for (const path of allCandidates) {
1244
+ if (_chunkITJIALN5cjs.isPathTraversal.call(void 0, path)) continue;
1245
+ const file = zip.file(path);
1246
+ if (!file) continue;
1247
+ try {
1248
+ const data = await file.async("uint8array");
1249
+ decompressed.total += data.length;
1250
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkITJIALN5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1251
+ const ext = path.includes(".") ? path.split(".").pop() || "png" : "png";
1252
+ const mimeType = imageExtToMime(ext);
1253
+ imageIndex++;
1254
+ const filename = `image_${String(imageIndex).padStart(3, "0")}.${mimeToExt(mimeType)}`;
1255
+ img = { filename, data, mimeType };
1256
+ images.push(img);
1257
+ break;
1258
+ } catch (err) {
1259
+ if (err instanceof _chunkITJIALN5cjs.KordocError) throw err;
1260
+ }
1261
1261
  }
1262
+ if (!img) _optionalChain([warnings, 'optionalAccess', _17 => _17.push, 'call', _18 => _18({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
1263
+ resolved.set(ref, img);
1262
1264
  }
1263
- if (!found) {
1264
- _optionalChain([warnings, 'optionalAccess', _17 => _17.push, 'call', _18 => _18({ page: block.pageNumber, message: `\uC774\uBBF8\uC9C0 \uD30C\uC77C \uC5C6\uC74C: ${ref}`, code: "SKIPPED_IMAGE" })]);
1265
+ if (!img) {
1265
1266
  block.type = "paragraph";
1266
1267
  block.text = `[\uC774\uBBF8\uC9C0: ${ref}]`;
1267
1268
  if (ownerCell) ownerCell.text = ownerCell.text.replace(`![image](${ref})`, `[\uC774\uBBF8\uC9C0: ${ref}]`);
1269
+ continue;
1268
1270
  }
1271
+ block.text = img.filename;
1272
+ block.imageData = { data: img.data, mimeType: img.mimeType, filename: ref };
1273
+ if (ownerCell) ownerCell.text = ownerCell.text.replace(`![image](${ref})`, `![image](${img.filename})`);
1269
1274
  }
1270
1275
  return images;
1271
1276
  }
@@ -1278,7 +1283,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
1278
1283
  const xml = await file.async("text");
1279
1284
  if (decompressed) {
1280
1285
  decompressed.total += xml.length * 2;
1281
- if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkQZCP3UWUcjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1286
+ if (decompressed.total > MAX_DECOMPRESS_SIZE) throw new (0, _chunkITJIALN5cjs.KordocError)("ZIP \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (ZIP bomb \uC758\uC2EC)");
1282
1287
  }
1283
1288
  parseDublinCoreMetadata(xml, metadata);
1284
1289
  if (metadata.title || metadata.author) return;
@@ -1288,7 +1293,7 @@ async function extractHwpxMetadata(zip, metadata, decompressed) {
1288
1293
  }
1289
1294
  function parseDublinCoreMetadata(xml, metadata) {
1290
1295
  const parser = createXmlParser();
1291
- const doc = parser.parseFromString(_chunkQZCP3UWUcjs.stripDtd.call(void 0, xml), "text/xml");
1296
+ const doc = parser.parseFromString(_chunkITJIALN5cjs.stripDtd.call(void 0, xml), "text/xml");
1292
1297
  if (!doc.documentElement) return;
1293
1298
  const getText = (tagNames) => {
1294
1299
  for (const tag of tagNames) {
@@ -1348,7 +1353,7 @@ function extractFromBrokenZip(buffer) {
1348
1353
  }
1349
1354
  const nameBytes = data.slice(pos + 30, pos + 30 + nameLen);
1350
1355
  const name = new TextDecoder().decode(nameBytes);
1351
- if (_chunkQZCP3UWUcjs.isPathTraversal.call(void 0, name)) {
1356
+ if (_chunkITJIALN5cjs.isPathTraversal.call(void 0, name)) {
1352
1357
  pos = fileStart + compSize;
1353
1358
  continue;
1354
1359
  }
@@ -1366,16 +1371,16 @@ function extractFromBrokenZip(buffer) {
1366
1371
  continue;
1367
1372
  }
1368
1373
  totalDecompressed += content.length * 2;
1369
- if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkQZCP3UWUcjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
1374
+ if (totalDecompressed > MAX_DECOMPRESS_SIZE) throw new (0, _chunkITJIALN5cjs.KordocError)("\uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC");
1370
1375
  sectionNum++;
1371
1376
  blocks.push(...parseSectionXml(content, void 0, warnings, sectionNum, shared));
1372
1377
  } catch (e14) {
1373
1378
  continue;
1374
1379
  }
1375
1380
  }
1376
- if (blocks.length === 0) throw new (0, _chunkQZCP3UWUcjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
1381
+ if (blocks.length === 0) throw new (0, _chunkITJIALN5cjs.KordocError)("\uC190\uC0C1\uB41C HWPX\uC5D0\uC11C \uC139\uC158 \uB370\uC774\uD130\uB97C \uBCF5\uAD6C\uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
1377
1382
  applyPageText(blocks, shared);
1378
- const markdown = _chunkQZCP3UWUcjs.blocksToMarkdown.call(void 0, blocks);
1383
+ const markdown = _chunkITJIALN5cjs.blocksToMarkdown.call(void 0, blocks);
1379
1384
  return { markdown, blocks, warnings: warnings.length > 0 ? warnings : void 0 };
1380
1385
  }
1381
1386
  async function resolveSectionPaths(zip) {
@@ -1389,18 +1394,18 @@ async function resolveSectionPaths(zip) {
1389
1394
  if (paths.length > 0) return paths;
1390
1395
  }
1391
1396
  const sectionFiles = zip.file(/[Ss]ection\d+\.xml$/);
1392
- return sectionFiles.map((f) => f.name).sort(_chunkQZCP3UWUcjs.compareSectionPaths);
1397
+ return sectionFiles.map((f) => f.name).sort(_chunkITJIALN5cjs.compareSectionPaths);
1393
1398
  }
1394
1399
  function parseSectionPathsFromManifest(xml) {
1395
1400
  const parser = createXmlParser();
1396
- const doc = parser.parseFromString(_chunkQZCP3UWUcjs.stripDtd.call(void 0, xml), "text/xml");
1401
+ const doc = parser.parseFromString(_chunkITJIALN5cjs.stripDtd.call(void 0, xml), "text/xml");
1397
1402
  const items = doc.getElementsByTagName("opf:item");
1398
1403
  const spine = doc.getElementsByTagName("opf:itemref");
1399
1404
  const idToHref = /* @__PURE__ */ new Map();
1400
1405
  for (let i = 0; i < items.length; i++) {
1401
1406
  const item = items[i];
1402
1407
  const id = item.getAttribute("id") || "";
1403
- const href = _chunkQZCP3UWUcjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
1408
+ const href = _chunkITJIALN5cjs.normalizeSectionHref.call(void 0, item.getAttribute("href") || "");
1404
1409
  if (id && href) idToHref.set(id, href);
1405
1410
  }
1406
1411
  if (spine.length > 0) {
@@ -1411,7 +1416,7 @@ function parseSectionPathsFromManifest(xml) {
1411
1416
  }
1412
1417
  if (ordered.length > 0) return ordered;
1413
1418
  }
1414
- return Array.from(idToHref.values()).sort(_chunkQZCP3UWUcjs.compareSectionPaths);
1419
+ return Array.from(idToHref.values()).sort(_chunkITJIALN5cjs.compareSectionPaths);
1415
1420
  }
1416
1421
  function detectHwpxHeadings(blocks, styleMap) {
1417
1422
  if (blocks.some((b) => b.type === "heading")) return;
@@ -1436,9 +1441,9 @@ function detectHwpxHeadings(blocks, styleMap) {
1436
1441
  let level = 0;
1437
1442
  if (baseFontSize > 0 && _optionalChain([block, 'access', _25 => _25.style, 'optionalAccess', _26 => _26.fontSize])) {
1438
1443
  const ratio = block.style.fontSize / baseFontSize;
1439
- if (ratio >= _chunkQZCP3UWUcjs.HEADING_RATIO_H1) level = 1;
1440
- else if (ratio >= _chunkQZCP3UWUcjs.HEADING_RATIO_H2) level = 2;
1441
- else if (ratio >= _chunkQZCP3UWUcjs.HEADING_RATIO_H3) level = 3;
1444
+ if (ratio >= _chunkITJIALN5cjs.HEADING_RATIO_H1) level = 1;
1445
+ else if (ratio >= _chunkITJIALN5cjs.HEADING_RATIO_H2) level = 2;
1446
+ else if (ratio >= _chunkITJIALN5cjs.HEADING_RATIO_H3) level = 3;
1442
1447
  }
1443
1448
  const compactText = text.replace(/\s+/g, "");
1444
1449
  if (/^제\d+[조장절편]/.test(compactText) && text.length <= 50) {
@@ -1451,7 +1456,7 @@ function detectHwpxHeadings(blocks, styleMap) {
1451
1456
  }
1452
1457
  }
1453
1458
  function buildTableWithCellMeta(state) {
1454
- const table = _chunkQZCP3UWUcjs.buildTable.call(void 0, state.rows);
1459
+ const table = _chunkITJIALN5cjs.buildTable.call(void 0, state.rows);
1455
1460
  if (state.caption) table.caption = state.caption;
1456
1461
  const anchors = [];
1457
1462
  {
@@ -1521,7 +1526,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1521
1526
  const cell = parentTable.cell;
1522
1527
  (cell.blocks ??= []).push(block);
1523
1528
  cell.hasStructure = true;
1524
- let flat = _chunkQZCP3UWUcjs.convertTableToText.call(void 0, newTable.rows);
1529
+ let flat = _chunkITJIALN5cjs.convertTableToText.call(void 0, newTable.rows);
1525
1530
  if (newTable.caption) flat = newTable.caption + (flat ? "\n" + flat : "");
1526
1531
  if (flat) cell.text += (cell.text ? "\n" : "") + flat;
1527
1532
  } else {
@@ -1531,7 +1536,7 @@ function completeTable(newTable, tableStack, blocks, ctx) {
1531
1536
  }
1532
1537
  function parseSectionXml(xml, styleMap, warnings, sectionNum, shared) {
1533
1538
  const parser = createXmlParser(warnings);
1534
- const doc = parser.parseFromString(_chunkQZCP3UWUcjs.stripDtd.call(void 0, xml), "text/xml");
1539
+ const doc = parser.parseFromString(_chunkITJIALN5cjs.stripDtd.call(void 0, xml), "text/xml");
1535
1540
  if (!doc.documentElement) return [];
1536
1541
  const ctx = { styleMap, warnings, sectionNum, shared: _nullishCoalesce(shared, () => ( createSectionShared())) };
1537
1542
  ctx.shared.track.deleteDepth = 0;
@@ -1622,8 +1627,8 @@ function walkSection(node, blocks, tableCtx, tableStack, ctx, depth = 0) {
1622
1627
  const cs = isNaN(rawCs) ? 1 : rawCs;
1623
1628
  const rawRs = parseInt(el.getAttribute("rowSpan") || "1", 10);
1624
1629
  const rs = isNaN(rawRs) ? 1 : rawRs;
1625
- tableCtx.cell.colSpan = clampSpan(cs, _chunkQZCP3UWUcjs.MAX_COLS);
1626
- tableCtx.cell.rowSpan = clampSpan(rs, _chunkQZCP3UWUcjs.MAX_ROWS);
1630
+ tableCtx.cell.colSpan = clampSpan(cs, _chunkITJIALN5cjs.MAX_COLS);
1631
+ tableCtx.cell.rowSpan = clampSpan(rs, _chunkITJIALN5cjs.MAX_ROWS);
1627
1632
  }
1628
1633
  break;
1629
1634
  case "p": {
@@ -1845,7 +1850,7 @@ function extractHyperlinkHref(fieldBegin) {
1845
1850
  let url = (ch.textContent || "").trim();
1846
1851
  if (!url) continue;
1847
1852
  url = url.replace(/^https?:\/\/(?=https?:\/\/)/i, "");
1848
- const safe = _chunkQZCP3UWUcjs.sanitizeHref.call(void 0, url);
1853
+ const safe = _chunkITJIALN5cjs.sanitizeHref.call(void 0, url);
1849
1854
  if (safe) return safe;
1850
1855
  }
1851
1856
  return void 0;
@@ -1980,7 +1985,7 @@ function extractParagraphInfo(para, styleMap, ctx) {
1980
1985
  case "hyperlink": {
1981
1986
  const url = child.getAttribute("url") || child.getAttribute("href") || "";
1982
1987
  if (url) {
1983
- const safe = _chunkQZCP3UWUcjs.sanitizeHref.call(void 0, url);
1988
+ const safe = _chunkITJIALN5cjs.sanitizeHref.call(void 0, url);
1984
1989
  if (safe) href = safe;
1985
1990
  }
1986
1991
  walk(child);
@@ -2170,7 +2175,7 @@ function decompressStream(data) {
2170
2175
  return _zlib.inflateRawSync.call(void 0, data, opts);
2171
2176
  }
2172
2177
  function parseFileHeader(data) {
2173
- if (data.length < 40) throw new (0, _chunkQZCP3UWUcjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
2178
+ if (data.length < 40) throw new (0, _chunkITJIALN5cjs.KordocError)("FileHeader\uAC00 \uB108\uBB34 \uC9E7\uC2B5\uB2C8\uB2E4 (\uCD5C\uC18C 40\uBC14\uC774\uD2B8)");
2174
2179
  const sig = data.subarray(0, 32).toString("utf8").replace(/\0+$/, "");
2175
2180
  return {
2176
2181
  signature: sig,
@@ -2631,32 +2636,42 @@ function resolveImageBlocks(binDataMap, blocks, warnings) {
2631
2636
  if (imageBlocks.length === 0) return [];
2632
2637
  const images = [];
2633
2638
  const renamed = /* @__PURE__ */ new Map();
2639
+ const resolved = /* @__PURE__ */ new Map();
2634
2640
  let imageIndex = 0;
2635
2641
  for (const block of imageBlocks) {
2636
2642
  if (!block.text) continue;
2637
2643
  const storageId = parseInt(block.text, 10);
2638
2644
  if (isNaN(storageId)) continue;
2639
- const bin = binDataMap.get(storageId);
2640
- if (!bin) {
2641
- warnings.push({ page: block.pageNumber, message: `BinData ${storageId} \uC5C6\uC74C`, code: "SKIPPED_IMAGE" });
2642
- block.type = "paragraph";
2643
- block.text = `[\uC774\uBBF8\uC9C0: BinData ${storageId}]`;
2644
- continue;
2645
+ let img = resolved.get(storageId);
2646
+ if (img === void 0) {
2647
+ const bin = binDataMap.get(storageId);
2648
+ if (!bin) {
2649
+ warnings.push({ page: block.pageNumber, message: `BinData ${storageId} \uC5C6\uC74C`, code: "SKIPPED_IMAGE" });
2650
+ resolved.set(storageId, null);
2651
+ } else {
2652
+ const mime = detectImageMime(bin.data);
2653
+ if (!mime) {
2654
+ warnings.push({ page: block.pageNumber, message: `BinData ${storageId}: \uC54C \uC218 \uC5C6\uB294 \uC774\uBBF8\uC9C0 \uD615\uC2DD`, code: "SKIPPED_IMAGE" });
2655
+ resolved.set(storageId, null);
2656
+ } else {
2657
+ imageIndex++;
2658
+ const ext = mime.includes("jpeg") ? "jpg" : mime.includes("png") ? "png" : mime.includes("gif") ? "gif" : mime.includes("bmp") ? "bmp" : "bin";
2659
+ img = { filename: `image_${String(imageIndex).padStart(3, "0")}.${ext}`, data: new Uint8Array(bin.data), mime };
2660
+ resolved.set(storageId, img);
2661
+ images.push({ filename: img.filename, data: img.data, mimeType: img.mime });
2662
+ renamed.set(storageId, img.filename);
2663
+ }
2664
+ }
2665
+ img = resolved.get(storageId);
2645
2666
  }
2646
- const mime = detectImageMime(bin.data);
2647
- if (!mime) {
2648
- warnings.push({ page: block.pageNumber, message: `BinData ${storageId}: \uC54C \uC218 \uC5C6\uB294 \uC774\uBBF8\uC9C0 \uD615\uC2DD`, code: "SKIPPED_IMAGE" });
2667
+ if (!img) {
2668
+ const bin = binDataMap.get(storageId);
2649
2669
  block.type = "paragraph";
2650
- block.text = `[\uC774\uBBF8\uC9C0: ${bin.name}]`;
2670
+ block.text = bin ? `[\uC774\uBBF8\uC9C0: ${bin.name}]` : `[\uC774\uBBF8\uC9C0: BinData ${storageId}]`;
2651
2671
  continue;
2652
2672
  }
2653
- imageIndex++;
2654
- const ext = mime.includes("jpeg") ? "jpg" : mime.includes("png") ? "png" : mime.includes("gif") ? "gif" : mime.includes("bmp") ? "bmp" : "bin";
2655
- const filename = `image_${String(imageIndex).padStart(3, "0")}.${ext}`;
2656
- images.push({ filename, data: new Uint8Array(bin.data), mimeType: mime });
2657
- renamed.set(storageId, filename);
2658
- block.text = filename;
2659
- block.imageData = { data: new Uint8Array(bin.data), mimeType: mime, filename: bin.name };
2673
+ block.text = img.filename;
2674
+ block.imageData = { data: img.data, mimeType: img.mime, filename: binDataMap.get(storageId).name };
2660
2675
  }
2661
2676
  resolveCellImageSentinels(blocks, renamed);
2662
2677
  return images;
@@ -3694,7 +3709,7 @@ function parseHwp5Document(buffer, options) {
3694
3709
  lenientCfb = parseLenientCfb(buffer);
3695
3710
  warnings.push({ message: "\uC190\uC0C1\uB41C CFB \uCEE8\uD14C\uC774\uB108 \u2014 lenient \uBAA8\uB4DC\uB85C \uBCF5\uAD6C", code: "LENIENT_CFB_RECOVERY" });
3696
3711
  } catch (e21) {
3697
- throw new (0, _chunkQZCP3UWUcjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
3712
+ throw new (0, _chunkITJIALN5cjs.KordocError)("CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328 (strict \uBC0F lenient \uBAA8\uB450)");
3698
3713
  }
3699
3714
  }
3700
3715
  const findStream = (path) => {
@@ -3705,11 +3720,11 @@ function parseHwp5Document(buffer, options) {
3705
3720
  return lenientCfb.findStream(path);
3706
3721
  };
3707
3722
  const headerData = findStream("/FileHeader");
3708
- if (!headerData) throw new (0, _chunkQZCP3UWUcjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
3723
+ if (!headerData) throw new (0, _chunkITJIALN5cjs.KordocError)("FileHeader \uC2A4\uD2B8\uB9BC \uC5C6\uC74C");
3709
3724
  const header = parseFileHeader(headerData);
3710
- if (header.signature !== "HWP Document File") throw new (0, _chunkQZCP3UWUcjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
3711
- if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkQZCP3UWUcjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3712
- if (header.flags & FLAG_DRM) throw new (0, _chunkQZCP3UWUcjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3725
+ if (header.signature !== "HWP Document File") throw new (0, _chunkITJIALN5cjs.KordocError)("HWP \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
3726
+ if (header.flags & FLAG_ENCRYPTED) throw new (0, _chunkITJIALN5cjs.KordocError)("\uC554\uD638\uD654\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3727
+ if (header.flags & FLAG_DRM) throw new (0, _chunkITJIALN5cjs.KordocError)("DRM \uBCF4\uD638\uB41C HWP\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
3713
3728
  const compressed = (header.flags & FLAG_COMPRESSED) !== 0;
3714
3729
  const distribution = (header.flags & FLAG_DISTRIBUTION) !== 0;
3715
3730
  const metadata = {
@@ -3718,7 +3733,7 @@ function parseHwp5Document(buffer, options) {
3718
3733
  if (cfb) extractHwp5Metadata(cfb, metadata);
3719
3734
  const docInfo = cfb ? parseDocInfoStream(cfb, compressed) : parseDocInfoFromStream(findStream("/DocInfo"), compressed);
3720
3735
  const sections = distribution ? cfb ? findViewTextSections(cfb, compressed) : findViewTextSectionsLenient(lenientCfb, compressed) : cfb ? findSections(cfb) : findSectionsLenient(lenientCfb, compressed);
3721
- if (sections.length === 0) throw new (0, _chunkQZCP3UWUcjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3736
+ if (sections.length === 0) throw new (0, _chunkITJIALN5cjs.KordocError)("\uC139\uC158 \uC2A4\uD2B8\uB9BC\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
3722
3737
  metadata.pageCount = sections.length;
3723
3738
  const pageFilter = _optionalChain([options, 'optionalAccess', _54 => _54.pages]) ? _chunkDCZVOIEOcjs.parsePageRange.call(void 0, options.pages, sections.length) : null;
3724
3739
  const totalTarget = pageFilter ? pageFilter.size : sections.length;
@@ -3732,25 +3747,25 @@ function parseHwp5Document(buffer, options) {
3732
3747
  const sectionData = sections[si];
3733
3748
  const data = !distribution && compressed ? decompressStream(Buffer.from(sectionData)) : Buffer.from(sectionData);
3734
3749
  totalDecompressed += data.length;
3735
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkQZCP3UWUcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3750
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkITJIALN5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3736
3751
  const records = readRecords(data);
3737
3752
  const sectionBlocks = parseSection(records, docInfo, warnings, si + 1, doc);
3738
3753
  bodyBlocks.push(...sectionBlocks);
3739
3754
  parsedSections++;
3740
3755
  _optionalChain([options, 'optionalAccess', _55 => _55.onProgress, 'optionalCall', _56 => _56(parsedSections, totalTarget)]);
3741
3756
  } catch (secErr) {
3742
- if (secErr instanceof _chunkQZCP3UWUcjs.KordocError) throw secErr;
3757
+ if (secErr instanceof _chunkITJIALN5cjs.KordocError) throw secErr;
3743
3758
  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" });
3744
3759
  }
3745
3760
  }
3746
3761
  const blocks = [...doc.headerBlocks, ...bodyBlocks, ...doc.footerBlocks];
3747
3762
  const images = cfb ? extractHwp5Images(cfb.FileIndex, blocks, warnings) : extractHwp5ImagesLenient(lenientCfb, blocks, warnings);
3748
- const flatBlocks = _chunkQZCP3UWUcjs.flattenLayoutTables.call(void 0, blocks);
3763
+ const flatBlocks = _chunkITJIALN5cjs.flattenLayoutTables.call(void 0, blocks);
3749
3764
  if (docInfo) {
3750
3765
  detectHwp5Headings(flatBlocks, docInfo);
3751
3766
  }
3752
3767
  const outline = flatBlocks.filter((b) => b.type === "heading" && b.level && b.text).map((b) => ({ level: b.level, text: b.text, pageNumber: b.pageNumber }));
3753
- const markdown = _chunkQZCP3UWUcjs.blocksToMarkdown.call(void 0, flatBlocks);
3768
+ const markdown = _chunkITJIALN5cjs.blocksToMarkdown.call(void 0, flatBlocks);
3754
3769
  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 };
3755
3770
  }
3756
3771
  function parseDocInfoStream(cfb, compressed) {
@@ -3810,9 +3825,9 @@ function detectHwp5Headings(blocks, docInfo) {
3810
3825
  let level = 0;
3811
3826
  if (_optionalChain([block, 'access', _61 => _61.style, 'optionalAccess', _62 => _62.fontSize]) && baseFontSize > 0) {
3812
3827
  const ratio = block.style.fontSize / baseFontSize;
3813
- if (ratio >= _chunkQZCP3UWUcjs.HEADING_RATIO_H1) level = 1;
3814
- else if (ratio >= _chunkQZCP3UWUcjs.HEADING_RATIO_H2) level = 2;
3815
- else if (ratio >= _chunkQZCP3UWUcjs.HEADING_RATIO_H3) level = 3;
3828
+ if (ratio >= _chunkITJIALN5cjs.HEADING_RATIO_H1) level = 1;
3829
+ else if (ratio >= _chunkITJIALN5cjs.HEADING_RATIO_H2) level = 2;
3830
+ else if (ratio >= _chunkITJIALN5cjs.HEADING_RATIO_H3) level = 3;
3816
3831
  }
3817
3832
  if (/^제\d+[장절편]\s/.test(text) && text.length <= 50) {
3818
3833
  if (level === 0) level = 2;
@@ -3897,7 +3912,7 @@ function findSectionsLenient(lcfb, compressed) {
3897
3912
  if (!raw) break;
3898
3913
  const content = compressed ? decompressStream(raw) : raw;
3899
3914
  totalDecompressed += content.length;
3900
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkQZCP3UWUcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3915
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkITJIALN5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3901
3916
  sections.push({ idx: i, content });
3902
3917
  }
3903
3918
  if (sections.length === 0) {
@@ -3909,7 +3924,7 @@ function findSectionsLenient(lcfb, compressed) {
3909
3924
  if (raw) {
3910
3925
  const content = compressed ? decompressStream(raw) : raw;
3911
3926
  totalDecompressed += content.length;
3912
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkQZCP3UWUcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3927
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkITJIALN5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3913
3928
  sections.push({ idx, content });
3914
3929
  }
3915
3930
  }
@@ -3926,7 +3941,7 @@ function findViewTextSectionsLenient(lcfb, compressed) {
3926
3941
  try {
3927
3942
  const content = decryptViewText(raw, compressed);
3928
3943
  totalDecompressed += content.length;
3929
- if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkQZCP3UWUcjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3944
+ if (totalDecompressed > MAX_TOTAL_DECOMPRESS) throw new (0, _chunkITJIALN5cjs.KordocError)("\uCD1D \uC555\uCD95 \uD574\uC81C \uD06C\uAE30 \uCD08\uACFC (decompression bomb \uC758\uC2EC)");
3930
3945
  sections.push({ idx: i, content });
3931
3946
  } catch (e26) {
3932
3947
  break;
@@ -4029,7 +4044,7 @@ function parseParagraph(records, start, end, ctx) {
4029
4044
  const ctrl = ctrls[r.ctrlIdx];
4030
4045
  if (!_optionalChain([ctrl, 'optionalAccess', _69 => _69.href]) || r.end <= r.start) continue;
4031
4046
  if (applied.some(([s, e]) => r.start < e && r.end > s)) continue;
4032
- const href = _chunkQZCP3UWUcjs.sanitizeHref.call(void 0, ctrl.href);
4047
+ const href = _chunkITJIALN5cjs.sanitizeHref.call(void 0, ctrl.href);
4033
4048
  if (!href) continue;
4034
4049
  const anchor = text.slice(r.start, r.end);
4035
4050
  if (!anchor.trim()) continue;
@@ -4262,8 +4277,8 @@ function parseTableControl(ctrl, records, ctx) {
4262
4277
  let tableIdx = -1;
4263
4278
  for (let i2 = childStart; i2 < childEnd; i2++) {
4264
4279
  if (records[i2].tagId === TAG_TABLE && records[i2].data.length >= 8) {
4265
- rows = Math.min(records[i2].data.readUInt16LE(4), _chunkQZCP3UWUcjs.MAX_ROWS);
4266
- cols = Math.min(records[i2].data.readUInt16LE(6), _chunkQZCP3UWUcjs.MAX_COLS);
4280
+ rows = Math.min(records[i2].data.readUInt16LE(4), _chunkITJIALN5cjs.MAX_ROWS);
4281
+ cols = Math.min(records[i2].data.readUInt16LE(6), _chunkITJIALN5cjs.MAX_COLS);
4267
4282
  tableIdx = i2;
4268
4283
  break;
4269
4284
  }
@@ -4312,7 +4327,7 @@ function parseTableControl(ctrl, records, ctx) {
4312
4327
  return table2;
4313
4328
  }
4314
4329
  const cellRows = arrangeCells(rows, cols, cells);
4315
- const table = _chunkQZCP3UWUcjs.buildTable.call(void 0, cellRows);
4330
+ const table = _chunkITJIALN5cjs.buildTable.call(void 0, cellRows);
4316
4331
  if (caption && table.rows > 0) table.caption = caption;
4317
4332
  return table.rows > 0 ? table : null;
4318
4333
  }
@@ -4329,8 +4344,8 @@ function parseCell(records, lhIdx, end, ctx) {
4329
4344
  rowAddr = rec.data.readUInt16LE(10);
4330
4345
  const cs = rec.data.readUInt16LE(12);
4331
4346
  const rs = rec.data.readUInt16LE(14);
4332
- if (cs > 0) colSpan = Math.min(cs, _chunkQZCP3UWUcjs.MAX_COLS);
4333
- if (rs > 0) rowSpan = Math.min(rs, _chunkQZCP3UWUcjs.MAX_ROWS);
4347
+ if (cs > 0) colSpan = Math.min(cs, _chunkITJIALN5cjs.MAX_COLS);
4348
+ if (rs > 0) rowSpan = Math.min(rs, _chunkITJIALN5cjs.MAX_ROWS);
4334
4349
  }
4335
4350
  const blocks = ctx.depth < MAX_NEST_DEPTH ? parseParagraphList(records, lhIdx + 1, end, { ...ctx, depth: ctx.depth + 1 }) : [];
4336
4351
  const parts = [];
@@ -4340,7 +4355,7 @@ function parseCell(records, lhIdx, end, ctx) {
4340
4355
  parts.push(`![image](hwp5bin:${b.text})`);
4341
4356
  hasStructure = true;
4342
4357
  } else if (b.type === "table" && b.table) {
4343
- const flat = _chunkQZCP3UWUcjs.convertTableToText.call(void 0, b.table.cells);
4358
+ const flat = _chunkITJIALN5cjs.convertTableToText.call(void 0, b.table.cells);
4344
4359
  if (flat) parts.push(flat);
4345
4360
  hasStructure = true;
4346
4361
  } else if (b.text) {
@@ -16774,7 +16789,7 @@ function getTextContent(el) {
16774
16789
  return _nullishCoalesce(_optionalChain([el, 'access', _82 => _82.textContent, 'optionalAccess', _83 => _83.trim, 'call', _84 => _84()]), () => ( ""));
16775
16790
  }
16776
16791
  function parseXml(text) {
16777
- return new (0, _xmldom.DOMParser)().parseFromString(_chunkQZCP3UWUcjs.stripDtd.call(void 0, text), "text/xml");
16792
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunkITJIALN5cjs.stripDtd.call(void 0, text), "text/xml");
16778
16793
  }
16779
16794
  function parseSharedStrings(xml) {
16780
16795
  const doc = parseXml(xml);
@@ -16918,7 +16933,7 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
16918
16933
  cellRows.push(row);
16919
16934
  }
16920
16935
  if (cellRows.length > 0) {
16921
- const table = _chunkQZCP3UWUcjs.buildTable.call(void 0, cellRows);
16936
+ const table = _chunkITJIALN5cjs.buildTable.call(void 0, cellRows);
16922
16937
  if (table.rows > 0) {
16923
16938
  blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
16924
16939
  }
@@ -16926,12 +16941,12 @@ function sheetToBlocks(sheetName, grid, merges, maxRow, maxCol, sheetIndex) {
16926
16941
  return blocks;
16927
16942
  }
16928
16943
  async function parseXlsxDocument(buffer, options) {
16929
- _chunkQZCP3UWUcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
16944
+ _chunkITJIALN5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE3);
16930
16945
  const zip = await _jszip2.default.loadAsync(buffer);
16931
16946
  const warnings = [];
16932
16947
  const workbookFile = zip.file("xl/workbook.xml");
16933
16948
  if (!workbookFile) {
16934
- throw new (0, _chunkQZCP3UWUcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
16949
+ throw new (0, _chunkITJIALN5cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 XLSX \uD30C\uC77C: xl/workbook.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
16935
16950
  }
16936
16951
  let sharedStrings = [];
16937
16952
  const ssFile = zip.file("xl/sharedStrings.xml");
@@ -16940,7 +16955,7 @@ async function parseXlsxDocument(buffer, options) {
16940
16955
  }
16941
16956
  const sheets = parseWorkbook(await workbookFile.async("text"));
16942
16957
  if (sheets.length === 0) {
16943
- throw new (0, _chunkQZCP3UWUcjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
16958
+ throw new (0, _chunkITJIALN5cjs.KordocError)("XLSX \uD30C\uC77C\uC5D0 \uC2DC\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4");
16944
16959
  }
16945
16960
  let relsMap = /* @__PURE__ */ new Map();
16946
16961
  const relsFile = zip.file("xl/_rels/workbook.xml.rels");
@@ -17012,7 +17027,7 @@ async function parseXlsxDocument(buffer, options) {
17012
17027
  } catch (e27) {
17013
17028
  }
17014
17029
  }
17015
- const markdown = _chunkQZCP3UWUcjs.blocksToMarkdown.call(void 0, blocks);
17030
+ const markdown = _chunkITJIALN5cjs.blocksToMarkdown.call(void 0, blocks);
17016
17031
  return { markdown, blocks, metadata, warnings: warnings.length > 0 ? warnings : void 0 };
17017
17032
  }
17018
17033
 
@@ -17419,11 +17434,11 @@ function processGlobals(records) {
17419
17434
  let encrypted = false;
17420
17435
  const firstBof = records[0];
17421
17436
  if (!firstBof || firstBof.opcode !== OP_BOF) {
17422
- throw new (0, _chunkQZCP3UWUcjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
17437
+ throw new (0, _chunkITJIALN5cjs.KordocError)("XLS: \uCCAB \uB808\uCF54\uB4DC\uAC00 BOF\uAC00 \uC544\uB2D8");
17423
17438
  }
17424
17439
  const bof = decodeBof(firstBof.data);
17425
17440
  if (!bof || bof.dt !== DT_GLOBALS) {
17426
- throw new (0, _chunkQZCP3UWUcjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
17441
+ throw new (0, _chunkITJIALN5cjs.KordocError)("XLS: Globals \uC11C\uBE0C\uC2A4\uD2B8\uB9BC BOF \uB204\uB77D");
17427
17442
  }
17428
17443
  let i = 1;
17429
17444
  while (i < records.length) {
@@ -17538,7 +17553,7 @@ function sheetToBlocks2(sheetName, sheet, sheetIndex) {
17538
17553
  cellRows.push(row);
17539
17554
  }
17540
17555
  if (cellRows.length > 0) {
17541
- const table = _chunkQZCP3UWUcjs.buildTable.call(void 0, cellRows);
17556
+ const table = _chunkITJIALN5cjs.buildTable.call(void 0, cellRows);
17542
17557
  if (table.rows > 0) {
17543
17558
  blocks.push({ type: "table", table, pageNumber: sheetIndex + 1 });
17544
17559
  }
@@ -17551,21 +17566,21 @@ async function parseXlsDocument(buffer, options) {
17551
17566
  try {
17552
17567
  cfb = parseLenientCfb(buf);
17553
17568
  } catch (e) {
17554
- throw new (0, _chunkQZCP3UWUcjs.KordocError)(
17569
+ throw new (0, _chunkITJIALN5cjs.KordocError)(
17555
17570
  `XLS: OLE2 \uC2DC\uADF8\uB2C8\uCC98 \uAC80\uC99D \uC2E4\uD328 \u2014 ${e instanceof Error ? e.message : "\uC54C \uC218 \uC5C6\uB294 \uC624\uB958"}`
17556
17571
  );
17557
17572
  }
17558
17573
  const wb = _nullishCoalesce(cfb.findStream("/Workbook"), () => ( cfb.findStream("/Book")));
17559
17574
  if (!wb) {
17560
- throw new (0, _chunkQZCP3UWUcjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
17575
+ throw new (0, _chunkITJIALN5cjs.KordocError)("XLS: Workbook \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC74C (BIFF5 \uB610\uB294 \uBE44\uD45C\uC900 \uD30C\uC77C)");
17561
17576
  }
17562
17577
  const records = readRecords2(wb);
17563
17578
  if (records.length === 0) {
17564
- throw new (0, _chunkQZCP3UWUcjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
17579
+ throw new (0, _chunkITJIALN5cjs.KordocError)("XLS: \uC2DC\uADF8\uB2C8\uCC98 \uB808\uCF54\uB4DC\uAC00 \uC5C6\uC74C (Workbook \uC2A4\uD2B8\uB9BC \uC190\uC0C1)");
17565
17580
  }
17566
17581
  const firstBof = decodeBof(records[0].data);
17567
17582
  if (firstBof && firstBof.vers !== 1536) {
17568
- throw new (0, _chunkQZCP3UWUcjs.KordocError)(
17583
+ throw new (0, _chunkITJIALN5cjs.KordocError)(
17569
17584
  `XLS: BIFF8(0x0600)\uB9CC \uC9C0\uC6D0 \u2014 \uBCF8 \uD30C\uC77C\uC740 0x${firstBof.vers.toString(16)}`
17570
17585
  );
17571
17586
  }
@@ -17625,7 +17640,7 @@ async function parseXlsDocument(buffer, options) {
17625
17640
  pageCount: totalSheets
17626
17641
  };
17627
17642
  return {
17628
- markdown: _chunkQZCP3UWUcjs.blocksToMarkdown.call(void 0, allBlocks),
17643
+ markdown: _chunkITJIALN5cjs.blocksToMarkdown.call(void 0, allBlocks),
17629
17644
  blocks: allBlocks,
17630
17645
  metadata,
17631
17646
  warnings: warnings.length > 0 ? warnings : void 0
@@ -18063,7 +18078,7 @@ function getAttr(el, localName2) {
18063
18078
  return null;
18064
18079
  }
18065
18080
  function parseXml2(text) {
18066
- return new (0, _xmldom.DOMParser)().parseFromString(_chunkQZCP3UWUcjs.stripDtd.call(void 0, text), "text/xml");
18081
+ return new (0, _xmldom.DOMParser)().parseFromString(_chunkITJIALN5cjs.stripDtd.call(void 0, text), "text/xml");
18067
18082
  }
18068
18083
  function parseStyles(xml) {
18069
18084
  const doc = parseXml2(xml);
@@ -18344,7 +18359,7 @@ function parseTable(tbl, styles, numbering, footnotes, rels) {
18344
18359
  };
18345
18360
  return { type: "table", table };
18346
18361
  }
18347
- async function extractImages(zip, rels, doc) {
18362
+ async function extractImages(zip, rels, doc, warnings) {
18348
18363
  const blocks = [];
18349
18364
  const images = [];
18350
18365
  const drawingElements = findElements(doc.documentElement, "drawing");
@@ -18375,19 +18390,23 @@ async function extractImages(zip, rels, doc) {
18375
18390
  const filename = `image_${String(imgIdx).padStart(3, "0")}.${ext}`;
18376
18391
  images.push({ filename, data, mimeType: _nullishCoalesce(mimeMap[ext], () => ( "image/png")) });
18377
18392
  blocks.push({ type: "image", text: filename });
18378
- } catch (e28) {
18393
+ } catch (err) {
18394
+ warnings.push({
18395
+ code: "SKIPPED_IMAGE",
18396
+ message: `DOCX \uC774\uBBF8\uC9C0 \uCD94\uCD9C \uC2E4\uD328 (${imgPath}): ${err instanceof Error ? err.message : String(err)}`
18397
+ });
18379
18398
  }
18380
18399
  }
18381
18400
  }
18382
18401
  return { blocks, images };
18383
18402
  }
18384
18403
  async function parseDocxDocument(buffer, options) {
18385
- _chunkQZCP3UWUcjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
18404
+ _chunkITJIALN5cjs.precheckZipSize.call(void 0, buffer, MAX_DECOMPRESS_SIZE4);
18386
18405
  const zip = await _jszip2.default.loadAsync(buffer);
18387
18406
  const warnings = [];
18388
18407
  const docFile = zip.file("word/document.xml");
18389
18408
  if (!docFile) {
18390
- throw new (0, _chunkQZCP3UWUcjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
18409
+ throw new (0, _chunkITJIALN5cjs.KordocError)("\uC720\uD6A8\uD558\uC9C0 \uC54A\uC740 DOCX \uD30C\uC77C: word/document.xml\uC774 \uC5C6\uC2B5\uB2C8\uB2E4");
18391
18410
  }
18392
18411
  let rels = /* @__PURE__ */ new Map();
18393
18412
  const relsFile = zip.file("word/_rels/document.xml.rels");
@@ -18399,7 +18418,11 @@ async function parseDocxDocument(buffer, options) {
18399
18418
  if (stylesFile) {
18400
18419
  try {
18401
18420
  styles = parseStyles(await stylesFile.async("text"));
18402
- } catch (e29) {
18421
+ } catch (err) {
18422
+ warnings.push({
18423
+ code: "PARTIAL_PARSE",
18424
+ message: `DOCX \uC2A4\uD0C0\uC77C(styles.xml) \uD30C\uC2F1 \uC2E4\uD328 \u2014 \uAE30\uBCF8 \uC2A4\uD0C0\uC77C\uB85C \uACC4\uC18D: ${err instanceof Error ? err.message : String(err)}`
18425
+ });
18403
18426
  }
18404
18427
  }
18405
18428
  let numbering = /* @__PURE__ */ new Map();
@@ -18407,7 +18430,11 @@ async function parseDocxDocument(buffer, options) {
18407
18430
  if (numFile) {
18408
18431
  try {
18409
18432
  numbering = parseNumbering(await numFile.async("text"));
18410
- } catch (e30) {
18433
+ } catch (err) {
18434
+ warnings.push({
18435
+ code: "PARTIAL_PARSE",
18436
+ message: `DOCX \uBC88\uD638\uB9E4\uAE30\uAE30(numbering.xml) \uD30C\uC2F1 \uC2E4\uD328 \u2014 \uBAA9\uB85D \uBC88\uD638 \uC0DD\uB7B5: ${err instanceof Error ? err.message : String(err)}`
18437
+ });
18411
18438
  }
18412
18439
  }
18413
18440
  let footnotes = /* @__PURE__ */ new Map();
@@ -18415,14 +18442,18 @@ async function parseDocxDocument(buffer, options) {
18415
18442
  if (fnFile) {
18416
18443
  try {
18417
18444
  footnotes = parseFootnotes(await fnFile.async("text"));
18418
- } catch (e31) {
18445
+ } catch (err) {
18446
+ warnings.push({
18447
+ code: "PARTIAL_PARSE",
18448
+ message: `DOCX \uAC01\uC8FC(footnotes.xml) \uD30C\uC2F1 \uC2E4\uD328 \u2014 \uAC01\uC8FC \uC0DD\uB7B5: ${err instanceof Error ? err.message : String(err)}`
18449
+ });
18419
18450
  }
18420
18451
  }
18421
18452
  const docXml = await docFile.async("text");
18422
18453
  const doc = parseXml2(docXml);
18423
18454
  const body = findElements(doc, "body");
18424
18455
  if (body.length === 0) {
18425
- throw new (0, _chunkQZCP3UWUcjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
18456
+ throw new (0, _chunkITJIALN5cjs.KordocError)("DOCX \uBCF8\uBB38(w:body)\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
18426
18457
  }
18427
18458
  const blocks = [];
18428
18459
  const bodyEl = body[0];
@@ -18437,7 +18468,7 @@ async function parseDocxDocument(buffer, options) {
18437
18468
  if (block) blocks.push(block);
18438
18469
  }
18439
18470
  }
18440
- const { blocks: imgBlocks, images } = await extractImages(zip, rels, doc);
18471
+ const { blocks: imgBlocks, images } = await extractImages(zip, rels, doc, warnings);
18441
18472
  const metadata = {};
18442
18473
  const coreFile = zip.file("docProps/core.xml");
18443
18474
  if (coreFile) {
@@ -18455,11 +18486,15 @@ async function parseDocxDocument(buffer, options) {
18455
18486
  if (created) metadata.createdAt = created;
18456
18487
  const modified = getFirst("dcterms:modified");
18457
18488
  if (modified) metadata.modifiedAt = modified;
18458
- } catch (e32) {
18489
+ } catch (err) {
18490
+ warnings.push({
18491
+ code: "PARTIAL_PARSE",
18492
+ message: `DOCX \uBA54\uD0C0\uB370\uC774\uD130(core.xml) \uD30C\uC2F1 \uC2E4\uD328: ${err instanceof Error ? err.message : String(err)}`
18493
+ });
18459
18494
  }
18460
18495
  }
18461
18496
  const outline = blocks.filter((b) => b.type === "heading").map((b) => ({ level: _nullishCoalesce(b.level, () => ( 2)), text: _nullishCoalesce(b.text, () => ( "")) }));
18462
- const markdown = _chunkQZCP3UWUcjs.blocksToMarkdown.call(void 0, blocks);
18497
+ const markdown = _chunkITJIALN5cjs.blocksToMarkdown.call(void 0, blocks);
18463
18498
  return {
18464
18499
  markdown,
18465
18500
  blocks,
@@ -18482,7 +18517,7 @@ function parseHwpmlDocument(buffer, options) {
18482
18517
  }
18483
18518
  const text = new TextDecoder("utf-8").decode(buffer).replace(/^\uFEFF/, "");
18484
18519
  const normalized = text.replace(/&nbsp;/g, "&#160;");
18485
- const xml = _chunkQZCP3UWUcjs.stripDtd.call(void 0, normalized);
18520
+ const xml = _chunkITJIALN5cjs.stripDtd.call(void 0, normalized);
18486
18521
  const warnings = [];
18487
18522
  const parser = new (0, _xmldom.DOMParser)({
18488
18523
  onError: (_level, msg2) => {
@@ -18522,7 +18557,7 @@ function parseHwpmlDocument(buffer, options) {
18522
18557
  parseSection2(el, blocks, paraShapeMap, sectionIdx, warnings);
18523
18558
  }
18524
18559
  const outline = blocks.filter((b) => b.type === "heading" && b.text).map((b) => ({ level: _nullishCoalesce(b.level, () => ( 1)), text: b.text, pageNumber: b.pageNumber }));
18525
- const markdown = _chunkQZCP3UWUcjs.blocksToMarkdown.call(void 0, blocks);
18560
+ const markdown = _chunkITJIALN5cjs.blocksToMarkdown.call(void 0, blocks);
18526
18561
  return {
18527
18562
  markdown,
18528
18563
  blocks,
@@ -18664,7 +18699,7 @@ function parseTable2(el, blocks, paraShapeMap, sectionNum, warnings) {
18664
18699
  const cellRows = grid.map(
18665
18700
  (row) => row.map((cell) => _nullishCoalesce(cell, () => ( { text: "", colSpan: 1, rowSpan: 1 })))
18666
18701
  );
18667
- const table = _chunkQZCP3UWUcjs.buildTable.call(void 0, cellRows);
18702
+ const table = _chunkITJIALN5cjs.buildTable.call(void 0, cellRows);
18668
18703
  blocks.push({ type: "table", table, pageNumber: sectionNum });
18669
18704
  }
18670
18705
  function extractCellText(cellEl) {
@@ -19308,7 +19343,7 @@ function decodeXmlEntities(text) {
19308
19343
  try {
19309
19344
  const code = ent[1] === "x" || ent[1] === "X" ? parseInt(ent.slice(2), 16) : parseInt(ent.slice(1), 10);
19310
19345
  if (!isNaN(code) && code >= 0 && code <= 1114111) return String.fromCodePoint(code);
19311
- } catch (e33) {
19346
+ } catch (e28) {
19312
19347
  }
19313
19348
  return m;
19314
19349
  });
@@ -19837,19 +19872,19 @@ function parseCentralDirectory(buf) {
19837
19872
  }
19838
19873
  }
19839
19874
  }
19840
- if (eocdOffset < 0) throw new (0, _chunkQZCP3UWUcjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19875
+ if (eocdOffset < 0) throw new (0, _chunkITJIALN5cjs.KordocError)("ZIP EOCD\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19841
19876
  const totalEntries = view.getUint16(eocdOffset + 10, true);
19842
19877
  const cdSize = view.getUint32(eocdOffset + 12, true);
19843
19878
  const cdOffset = view.getUint32(eocdOffset + 16, true);
19844
- if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkQZCP3UWUcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19879
+ if (cdOffset === 4294967295 || totalEntries === 65535) throw new (0, _chunkITJIALN5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19845
19880
  if (eocdOffset >= 20 && view.getUint32(eocdOffset - 20, true) === ZIP64_EOCD_LOC_SIG) {
19846
- throw new (0, _chunkQZCP3UWUcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19881
+ throw new (0, _chunkITJIALN5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19847
19882
  }
19848
19883
  const decoder = new TextDecoder("utf-8");
19849
19884
  const entries = [];
19850
19885
  let pos = cdOffset;
19851
19886
  for (let i = 0; i < totalEntries; i++) {
19852
- if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkQZCP3UWUcjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
19887
+ if (view.getUint32(pos, true) !== CD_SIG) throw new (0, _chunkITJIALN5cjs.KordocError)("ZIP Central Directory \uC190\uC0C1");
19853
19888
  const flags = view.getUint16(pos + 8, true);
19854
19889
  const method = view.getUint16(pos + 10, true);
19855
19890
  const crc = view.getUint32(pos + 16, true);
@@ -19860,7 +19895,7 @@ function parseCentralDirectory(buf) {
19860
19895
  const commentLen = view.getUint16(pos + 32, true);
19861
19896
  const localOffset = view.getUint32(pos + 42, true);
19862
19897
  if (compSize === 4294967295 || uncompSize === 4294967295 || localOffset === 4294967295) {
19863
- throw new (0, _chunkQZCP3UWUcjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19898
+ throw new (0, _chunkITJIALN5cjs.KordocError)("ZIP64\uB294 \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4");
19864
19899
  }
19865
19900
  const name = decoder.decode(buf.subarray(pos + 46, pos + 46 + nameLen));
19866
19901
  const cdEnd = pos + 46 + nameLen + extraLen + commentLen;
@@ -19889,7 +19924,7 @@ function patchZipEntries(original, replacements) {
19889
19924
  const { entries, cdOffset, eocdOffset } = parseCentralDirectory(original);
19890
19925
  const view = new DataView(original.buffer, original.byteOffset, original.byteLength);
19891
19926
  for (const name of replacements.keys()) {
19892
- if (!entries.some((e) => e.name === name)) throw new (0, _chunkQZCP3UWUcjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
19927
+ if (!entries.some((e) => e.name === name)) throw new (0, _chunkITJIALN5cjs.KordocError)(`ZIP\uC5D0 \uC5C6\uB294 \uC5D4\uD2B8\uB9AC: ${name}`);
19893
19928
  }
19894
19929
  const byLocal = [...entries].sort((a, b) => a.localOffset - b.localOffset);
19895
19930
  const segments = [];
@@ -19907,7 +19942,7 @@ function patchZipEntries(original, replacements) {
19907
19942
  offset += seg.length;
19908
19943
  continue;
19909
19944
  }
19910
- if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkQZCP3UWUcjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
19945
+ if (view.getUint32(e.localOffset, true) !== LOCAL_SIG) throw new (0, _chunkITJIALN5cjs.KordocError)("ZIP \uB85C\uCEEC \uD5E4\uB354 \uC2DC\uADF8\uB2C8\uCC98 \uBD88\uC77C\uCE58");
19911
19946
  const nameLen = view.getUint16(e.localOffset + 26, true);
19912
19947
  const extraLen = view.getUint16(e.localOffset + 28, true);
19913
19948
  const headerLen = 30 + nameLen + extraLen;
@@ -19962,7 +19997,7 @@ async function fillHwpx(hwpxBuffer, values) {
19962
19997
  const zip = await _jszip2.default.loadAsync(hwpxBuffer);
19963
19998
  const sectionPaths = Object.keys(zip.files).filter((name) => /[Ss]ection\d+\.xml$/i.test(name)).sort();
19964
19999
  if (sectionPaths.length === 0) {
19965
- throw new (0, _chunkQZCP3UWUcjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
20000
+ throw new (0, _chunkITJIALN5cjs.KordocError)("HWPX\uC5D0\uC11C \uC139\uC158 \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4");
19966
20001
  }
19967
20002
  const normalizedValues = normalizeValues(values);
19968
20003
  const cursor = new ValueCursor(normalizedValues);
@@ -20748,7 +20783,7 @@ function escapeGfm(text) {
20748
20783
  }
20749
20784
  var HWP_SHAPE_ALT_TEXT_RE = /(?:모서리가 둥근 |둥근 )?(?:사각형|직사각형|정사각형|원|타원|삼각형|이등변 삼각형|직각 삼각형|선|직선|곡선|화살표|굵은 화살표|이중 화살표|오각형|육각형|팔각형|별|[4-8]점별|십자|십자형|구름|구름형|마름모|도넛|평행사변형|사다리꼴|부채꼴|호|반원|물결|번개|하트|빗금|블록 화살표|수식|표|그림|개체|그리기\s?개체|묶음\s?개체|글상자|수식\s?개체|OLE\s?개체)\s?입니다\.?/g;
20750
20785
  function sanitizeText(text) {
20751
- let result = _chunkQZCP3UWUcjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
20786
+ let result = _chunkITJIALN5cjs.mapPuaText.call(void 0, text).replace(/[\u{F0000}-\u{FFFFD}]/gu, "").replace(HWP_SHAPE_ALT_TEXT_RE, "").replace(/ +/g, " ").trim();
20752
20787
  if (result.length <= 30 && result.includes(" ")) {
20753
20788
  const tokens = result.split(" ");
20754
20789
  const koreanSingleCharCount = tokens.filter((t) => t.length === 1 && /[가-힯ㄱ-ㆎ]/.test(t)).length;
@@ -21580,9 +21615,22 @@ function precomputeGongmunList(blocks, gongmun) {
21580
21615
  continue;
21581
21616
  }
21582
21617
  const run = [];
21583
- while (i < blocks.length && blocks[i].type === "list_item") {
21584
- run.push(i);
21585
- i++;
21618
+ while (i < blocks.length) {
21619
+ const t = blocks[i].type;
21620
+ if (t === "list_item") {
21621
+ run.push(i);
21622
+ i++;
21623
+ continue;
21624
+ }
21625
+ if (t === "table" || t === "html_table") {
21626
+ let j = i + 1;
21627
+ while (j < blocks.length && (blocks[j].type === "table" || blocks[j].type === "html_table")) j++;
21628
+ if (j < blocks.length && blocks[j].type === "list_item") {
21629
+ i = j;
21630
+ continue;
21631
+ }
21632
+ }
21633
+ break;
21586
21634
  }
21587
21635
  const depths = run.map((bi) => Math.min(Math.max(blocks[bi].indent || 0, 0), GONGMUN_LIST_LEVELS - 1));
21588
21636
  const suppress = gongmun.numbering === "standard" ? computeSuppression(depths) : depths.map(() => false);
@@ -22453,7 +22501,7 @@ async function resolveSectionEntryNames(zip) {
22453
22501
  const paths = sectionPathsFromManifest(xml).filter((p) => zip.file(p) !== null);
22454
22502
  if (paths.length > 0) return paths;
22455
22503
  }
22456
- return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkQZCP3UWUcjs.compareSectionPaths);
22504
+ return Object.keys(zip.files).filter((n) => /[Ss]ection\d+\.xml$/.test(n)).sort(_chunkITJIALN5cjs.compareSectionPaths);
22457
22505
  }
22458
22506
  function sectionPathsFromManifest(xml) {
22459
22507
  const attr = (tag, name) => {
@@ -22463,7 +22511,7 @@ function sectionPathsFromManifest(xml) {
22463
22511
  const idToHref = /* @__PURE__ */ new Map();
22464
22512
  for (const m of xml.matchAll(/<opf:item(\s(?:"[^"]*"|'[^']*'|[^>"'])*?)\/?>/g)) {
22465
22513
  const id = attr(m[1], "id");
22466
- const href = _chunkQZCP3UWUcjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
22514
+ const href = _chunkITJIALN5cjs.normalizeSectionHref.call(void 0, attr(m[1], "href"));
22467
22515
  if (id && href) idToHref.set(id, href);
22468
22516
  }
22469
22517
  const ordered = [];
@@ -22472,7 +22520,7 @@ function sectionPathsFromManifest(xml) {
22472
22520
  if (href) ordered.push(href);
22473
22521
  }
22474
22522
  if (ordered.length > 0) return ordered;
22475
- return Array.from(idToHref.values()).sort(_chunkQZCP3UWUcjs.compareSectionPaths);
22523
+ return Array.from(idToHref.values()).sort(_chunkITJIALN5cjs.compareSectionPaths);
22476
22524
  }
22477
22525
 
22478
22526
  // src/roundtrip/patcher.ts
@@ -22489,7 +22537,7 @@ async function patchHwpx(original, editedMarkdown, options) {
22489
22537
  let zip;
22490
22538
  try {
22491
22539
  zip = await _jszip2.default.loadAsync(original);
22492
- } catch (e34) {
22540
+ } catch (e29) {
22493
22541
  return { success: false, applied: 0, skipped, error: "ZIP \uB85C\uB4DC \uC2E4\uD328" };
22494
22542
  }
22495
22543
  const sectionPaths = await resolveSectionEntryNames(zip);
@@ -22583,9 +22631,9 @@ function buildOrigUnits(blocks) {
22583
22631
  if (block.type === "paragraph" && block.text && /^\[별표\s*\d+/.test(sanitizeText(block.text))) {
22584
22632
  const next = blocks[i + 1];
22585
22633
  if (_optionalChain([next, 'optionalAccess', _220 => _220.type]) === "paragraph" && next.text && /관련\)?$/.test(next.text)) consume = 2;
22586
- chunk = _chunkQZCP3UWUcjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
22634
+ chunk = _chunkITJIALN5cjs.blocksToMarkdown.call(void 0, blocks.slice(i, i + consume));
22587
22635
  } else {
22588
- chunk = _chunkQZCP3UWUcjs.blocksToMarkdown.call(void 0, [block]);
22636
+ chunk = _chunkITJIALN5cjs.blocksToMarkdown.call(void 0, [block]);
22589
22637
  }
22590
22638
  if (chunk) {
22591
22639
  const subUnits = splitMarkdownUnits(chunk);
@@ -23151,21 +23199,24 @@ function readRecordsStrict(stream) {
23151
23199
  }
23152
23200
  return recs;
23153
23201
  }
23154
- function serializeRecords(recs, repl) {
23202
+ function serializeRecords(recs, repl, inserts) {
23155
23203
  const parts = [];
23156
- for (let i = 0; i < recs.length; i++) {
23157
- const data = _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _231 => _231.get, 'call', _232 => _232(i)]), () => ( recs[i].data));
23204
+ const push = (tagId, level, data) => {
23158
23205
  const ext = data.length >= 4095;
23159
23206
  const header = Buffer.alloc(ext ? 8 : 4);
23160
- header.writeUInt32LE((recs[i].tagId & 1023 | (recs[i].level & 1023) << 10 | (ext ? 4095 : data.length) << 20) >>> 0, 0);
23207
+ header.writeUInt32LE((tagId & 1023 | (level & 1023) << 10 | (ext ? 4095 : data.length) << 20) >>> 0, 0);
23161
23208
  if (ext) header.writeUInt32LE(data.length, 4);
23162
23209
  parts.push(header, data);
23210
+ };
23211
+ for (let i = 0; i < recs.length; i++) {
23212
+ for (const ins of _nullishCoalesce(_optionalChain([inserts, 'optionalAccess', _231 => _231.get, 'call', _232 => _232(i)]), () => ( []))) push(ins.tagId, ins.level, ins.data);
23213
+ push(recs[i].tagId, recs[i].level, _nullishCoalesce(_optionalChain([repl, 'optionalAccess', _233 => _233.get, 'call', _234 => _234(i)]), () => ( recs[i].data)));
23163
23214
  }
23164
23215
  return Buffer.concat(parts);
23165
23216
  }
23166
23217
  function scanSection(stream, sectionIndex, compressed) {
23167
23218
  const records = readRecordsStrict(stream);
23168
- if (!records) return { records: [], safe: false, paras: [], tables: [], compressed, repl: /* @__PURE__ */ new Map() };
23219
+ if (!records) return { records: [], safe: false, paras: [], tables: [], compressed, repl: /* @__PURE__ */ new Map(), inserts: /* @__PURE__ */ new Map() };
23169
23220
  const safe = serializeRecords(records).equals(stream);
23170
23221
  const parent = new Int32Array(records.length).fill(-1);
23171
23222
  const stack = [];
@@ -23264,7 +23315,7 @@ function scanSection(stream, sectionIndex, compressed) {
23264
23315
  }
23265
23316
  tables.push({ sectionIndex, rows, cols, cells });
23266
23317
  }
23267
- return { records, safe, paras, tables, compressed, repl: /* @__PURE__ */ new Map() };
23318
+ return { records, safe, paras, tables, compressed, repl: /* @__PURE__ */ new Map(), inserts: /* @__PURE__ */ new Map() };
23268
23319
  }
23269
23320
  async function patchHwp(original, editedMarkdown, options) {
23270
23321
  const skipped = [];
@@ -23277,7 +23328,7 @@ async function patchHwp(original, editedMarkdown, options) {
23277
23328
  return fail(`CFB \uCEE8\uD14C\uC774\uB108 \uD30C\uC2F1 \uC2E4\uD328: ${msg(err)}`);
23278
23329
  }
23279
23330
  const fhEntry = CFB2.find(cfb, "/FileHeader");
23280
- if (!_optionalChain([fhEntry, 'optionalAccess', _233 => _233.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
23331
+ if (!_optionalChain([fhEntry, 'optionalAccess', _235 => _235.content])) return fail("FileHeader \uC2A4\uD2B8\uB9BC\uC774 \uC5C6\uC2B5\uB2C8\uB2E4 \u2014 HWP 5.x \uD30C\uC77C\uC774 \uC544\uB2D9\uB2C8\uB2E4");
23281
23332
  let flags;
23282
23333
  try {
23283
23334
  flags = parseFileHeader(Buffer.from(fhEntry.content)).flags;
@@ -23299,7 +23350,7 @@ async function patchHwp(original, editedMarkdown, options) {
23299
23350
  const scans = [];
23300
23351
  for (let i = 0; i < sectionPaths.length; i++) {
23301
23352
  const entry = CFB2.find(cfb, sectionPaths[i]);
23302
- if (!_optionalChain([entry, 'optionalAccess', _234 => _234.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
23353
+ if (!_optionalChain([entry, 'optionalAccess', _236 => _236.content])) return fail(`\uC139\uC158 \uC2A4\uD2B8\uB9BC \uC77D\uAE30 \uC2E4\uD328: ${sectionPaths[i]}`);
23303
23354
  let stream;
23304
23355
  try {
23305
23356
  stream = compressed ? decompressStream(Buffer.from(entry.content)) : Buffer.from(entry.content);
@@ -23332,15 +23383,15 @@ async function patchHwp(original, editedMarkdown, options) {
23332
23383
  }
23333
23384
  }
23334
23385
  let data;
23335
- const dirty = scans.some((s) => s.repl.size > 0);
23386
+ const dirty = scans.some((s) => s.repl.size > 0 || s.inserts.size > 0);
23336
23387
  if (!dirty) {
23337
23388
  data = new Uint8Array(original);
23338
23389
  } else {
23339
23390
  try {
23340
23391
  let out = originalBuf;
23341
23392
  for (let i = 0; i < scans.length; i++) {
23342
- if (scans[i].repl.size === 0) continue;
23343
- const newStream = serializeRecords(scans[i].records, scans[i].repl);
23393
+ if (scans[i].repl.size === 0 && scans[i].inserts.size === 0) continue;
23394
+ const newStream = serializeRecords(scans[i].records, scans[i].repl, scans[i].inserts);
23344
23395
  const content = compressed ? _zlib.deflateRawSync.call(void 0, newStream) : newStream;
23345
23396
  out = replaceOleStream(out, sectionPaths[i], content);
23346
23397
  }
@@ -23350,7 +23401,7 @@ async function patchHwp(original, editedMarkdown, options) {
23350
23401
  }
23351
23402
  }
23352
23403
  let verification;
23353
- if (_optionalChain([options, 'optionalAccess', _235 => _235.verify]) !== false) {
23404
+ if (_optionalChain([options, 'optionalAccess', _237 => _237.verify]) !== false) {
23354
23405
  try {
23355
23406
  const reparsed = parseHwp5Document(Buffer.from(data));
23356
23407
  verification = diffUnitLists(splitMarkdownUnits(reparsed.markdown), editedUnits);
@@ -23439,7 +23490,7 @@ function tableContentScore(irTable, scanTable) {
23439
23490
  for (const [key, scanCell] of scanTable.cells) {
23440
23491
  const comma = key.indexOf(",");
23441
23492
  const r = Number(key.slice(0, comma)), c = Number(key.slice(comma + 1));
23442
- const irCell = _optionalChain([irTable, 'access', _236 => _236.cells, 'access', _237 => _237[r], 'optionalAccess', _238 => _238[c]]);
23493
+ const irCell = _optionalChain([irTable, 'access', _238 => _238.cells, 'access', _239 => _239[r], 'optionalAccess', _240 => _240[c]]);
23443
23494
  if (!irCell) continue;
23444
23495
  const a = normForMatch(scanCell.paras.map((p) => p.rawText).join(" "));
23445
23496
  const b = normForMatch(stripCellTokens(irCell.text));
@@ -23475,7 +23526,7 @@ function handleModified(orig, edited, ctx) {
23475
23526
  }
23476
23527
  function patchParagraph(block, orig, edited, ctx, skip) {
23477
23528
  const mapping = ctx.paraMap.get(orig.blockIdx);
23478
- if (!_optionalChain([mapping, 'optionalAccess', _239 => _239.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)");
23529
+ 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)");
23479
23530
  if (block.text && block.text.includes("\n")) {
23480
23531
  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)");
23481
23532
  }
@@ -23651,7 +23702,7 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
23651
23702
  };
23652
23703
  const cell = scanTable.cells.get(`${gridR},${gridC}`);
23653
23704
  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)");
23654
- const irCell = _optionalChain([table, 'access', _240 => _240.cells, 'access', _241 => _241[gridR], 'optionalAccess', _242 => _242[gridC]]);
23705
+ const irCell = _optionalChain([table, 'access', _242 => _242.cells, 'access', _243 => _243[gridR], 'optionalAccess', _244 => _244[gridC]]);
23655
23706
  const scanJoined = cell.paras.map((p) => p.rawText).filter((t) => normForMatch(t)).join("\n");
23656
23707
  if (irCell && normForMatch(scanJoined) !== normForMatch(stripCellTokens(irCell.text))) {
23657
23708
  if (normForMatch(irCell.text) !== "" || normForMatch(scanJoined) !== "") {
@@ -23668,24 +23719,25 @@ function applyCellEdit5(table, scanTable, gridR, gridC, newLines, ctx, before, a
23668
23719
  }
23669
23720
  const unstable = newLines.find((l) => sanitizeText(l) !== l);
23670
23721
  if (unstable !== void 0) 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");
23671
- if (nonEmpty.length === 0) return skip("\uBE48 \uC140 \uD14D\uC2A4\uD2B8 \uCC44\uC6B0\uAE30\uB294 HWP5 \uBBF8\uC9C0\uC6D0 (v1) \u2014 \uBB38\uB2E8 \uC0DD\uC131 \uD544\uC694");
23722
+ const targets = nonEmpty.length > 0 ? nonEmpty : cell.paras;
23723
+ if (targets.length === 0) return skip("\uC140\uC5D0 \uBB38\uB2E8\uC774 \uC5C6\uC74C \u2014 \uBBF8\uC9C0\uC6D0");
23672
23724
  const assigned = [];
23673
- for (let i = 0; i < nonEmpty.length; i++) {
23725
+ for (let i = 0; i < targets.length; i++) {
23674
23726
  if (i < newLines.length) {
23675
- assigned.push(i === nonEmpty.length - 1 && newLines.length > nonEmpty.length ? newLines.slice(i).join(" ") : newLines[i]);
23727
+ assigned.push(i === targets.length - 1 && newLines.length > targets.length ? newLines.slice(i).join(" ") : newLines[i]);
23676
23728
  } else {
23677
23729
  assigned.push("");
23678
23730
  }
23679
23731
  }
23680
- if (newLines.length > nonEmpty.length) {
23732
+ if (newLines.length > targets.length) {
23681
23733
  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 });
23682
23734
  } else if (newLines.length < nonEmpty.length && nonEmpty.length > 1) {
23683
23735
  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 });
23684
23736
  }
23685
23737
  let staged = 0;
23686
- for (let i = 0; i < nonEmpty.length; i++) {
23687
- if (assigned[i] === nonEmpty[i].rawText || normForMatch(assigned[i]) === normForMatch(nonEmpty[i].rawText)) continue;
23688
- staged += stageParaPatch(ctx.scans[nonEmpty[i].sectionIndex], nonEmpty[i], assigned[i], skip);
23738
+ for (let i = 0; i < targets.length; i++) {
23739
+ if (assigned[i] === targets[i].rawText || normForMatch(assigned[i]) === normForMatch(targets[i].rawText)) continue;
23740
+ staged += stageParaPatch(ctx.scans[targets[i].sectionIndex], targets[i], assigned[i], skip);
23689
23741
  }
23690
23742
  return staged > 0 ? 1 : 0;
23691
23743
  }
@@ -23755,7 +23807,21 @@ function splitParaText(data) {
23755
23807
  if (firstP < 0) firstP = k;
23756
23808
  lastP = k;
23757
23809
  }
23758
- if (firstP < 0) return null;
23810
+ if (firstP < 0) {
23811
+ if (toks.some((t) => t.visible)) return null;
23812
+ let cut = data.length;
23813
+ for (const t of toks) if (data.readUInt16LE(t.start) === 13) {
23814
+ cut = t.start;
23815
+ break;
23816
+ }
23817
+ return {
23818
+ prefix: data.subarray(0, cut),
23819
+ prefixUnits: cut / 2,
23820
+ core: "",
23821
+ suffix: data.subarray(cut),
23822
+ suffixUnits: (data.length - cut) / 2
23823
+ };
23824
+ }
23759
23825
  for (let k = firstP; k <= lastP; k++) if (!toks[k].plain) return null;
23760
23826
  for (let k = 0; k < firstP; k++) if (toks[k].visible) return null;
23761
23827
  for (let k = lastP + 1; k < toks.length; k++) if (toks[k].visible) return null;
@@ -23788,7 +23854,6 @@ function rebuildCharShape(csData, coreStartUnit) {
23788
23854
  }
23789
23855
  function stageParaPatch(scan, para, newPlain, skip) {
23790
23856
  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");
23791
- if (para.textIdx === -1) return skip("\uBE48 \uBB38\uB2E8 \uD14D\uC2A4\uD2B8 \uCD94\uAC00\uB294 \uBBF8\uC9C0\uC6D0 (v1)");
23792
23857
  if (para.textIdx === -2) return skip("\uBCF5\uC218 PARA_TEXT \uB808\uCF54\uB4DC \uBB38\uB2E8 \u2014 \uBBF8\uC9C0\uC6D0 (v1)");
23793
23858
  if (para.rangeTagCount > 0) return skip("\uBC94\uC704 \uD0DC\uADF8(\uD615\uAD11\uD39C/\uAD50\uC815\uBD80\uD638) \uBB38\uB2E8 \u2014 \uBBF8\uC9C0\uC6D0 (v1)");
23794
23859
  if (para.charShapeIdx < 0 || para.lineSegIdx < 0) return skip("\uBB38\uB2E8 \uB808\uCF54\uB4DC \uAD6C\uC131 \uBE44\uC815\uD615 \u2014 \uBBF8\uC9C0\uC6D0");
@@ -23796,11 +23861,27 @@ function stageParaPatch(scan, para, newPlain, skip) {
23796
23861
  if (/[\u0000-\u001f]/.test(newPlain)) return skip("\uC0C8 \uD14D\uC2A4\uD2B8\uC5D0 \uC81C\uC5B4\uBB38\uC790 \uD3EC\uD568 \u2014 \uBBF8\uC9C0\uC6D0");
23797
23862
  const records = scan.records;
23798
23863
  const headerRec = records[para.headerIdx];
23799
- const textRec = records[para.textIdx];
23800
23864
  const charShapeRec = records[para.charShapeIdx];
23801
23865
  if (charShapeRec.data.length < 8) {
23802
23866
  return skip("CHAR_SHAPE \uB808\uCF54\uB4DC \uBE44\uC815\uD615 \u2014 \uBBF8\uC9C0\uC6D0");
23803
23867
  }
23868
+ if (para.textIdx === -1) {
23869
+ const nCharsLow = para.nCharsRaw & 2147483647;
23870
+ if (nCharsLow > 1) return skip("PARA_TEXT \uC5C6\uB294 \uBB38\uB2E8\uC758 nChars \uBE44\uC815\uD615 \u2014 \uBBF8\uC9C0\uC6D0");
23871
+ const paraEnd = nCharsLow === 1 ? Buffer.from([13, 0]) : Buffer.alloc(0);
23872
+ const at = para.headerIdx + 1;
23873
+ const list = _nullishCoalesce(scan.inserts.get(at), () => ( []));
23874
+ list.push({ tagId: TAG_PARA_TEXT, level: headerRec.level + 1, data: Buffer.concat([Buffer.from(newPlain, "utf16le"), paraEnd]) });
23875
+ scan.inserts.set(at, list);
23876
+ const newHeader2 = Buffer.from(headerRec.data);
23877
+ newHeader2.writeUInt32LE((para.nCharsRaw & 2147483648 | newPlain.length + nCharsLow) >>> 0, 0);
23878
+ const cs2 = rebuildCharShape(charShapeRec.data, 0);
23879
+ scan.repl.set(para.charShapeIdx, cs2.buf);
23880
+ newHeader2.writeUInt16LE(cs2.count, 12);
23881
+ scan.repl.set(para.headerIdx, newHeader2);
23882
+ return 1;
23883
+ }
23884
+ const textRec = records[para.textIdx];
23804
23885
  const seg = splitParaText(textRec.data);
23805
23886
  if (!seg) {
23806
23887
  return skip(para.ctrlMask !== 0 ? "\uCEE8\uD2B8\uB864 \uBB38\uC790(\uD0ED/\uD544\uB4DC/\uD2B9\uC218\uACF5\uBC31 \uB4F1 \uD14D\uC2A4\uD2B8 \uC911\uAC04) \uD3EC\uD568 \uBB38\uB2E8 \u2014 \uBBF8\uC9C0\uC6D0 (v1)" : "PARA_TEXT \uC7AC\uAD6C\uC131 \uBD88\uC77C\uCE58 \u2014 \uC6D0\uBB38 \uBCF4\uC874 \uBD88\uAC00\uB85C \uBBF8\uC9C0\uC6D0");
@@ -23896,7 +23977,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
23896
23977
  const block = st.blocks[blockIndex];
23897
23978
  if (!block) return void 0;
23898
23979
  if (block.type === "paragraph" || block.type === "heading") {
23899
- const para = _optionalChain([st, 'access', _243 => _243.paraMap, 'access', _244 => _244.get, 'call', _245 => _245(blockIndex), 'optionalAccess', _246 => _246.para]);
23980
+ const para = _optionalChain([st, 'access', _245 => _245.paraMap, 'access', _246 => _246.get, 'call', _247 => _247(blockIndex), 'optionalAccess', _248 => _248.para]);
23900
23981
  if (!para) return void 0;
23901
23982
  return { kind: "paragraph", sectionIndex: para.sectionIndex, xmlStart: para.start };
23902
23983
  }
@@ -23921,7 +24002,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
23921
24002
  if (block.text && block.text.includes("\n")) {
23922
24003
  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)" };
23923
24004
  }
23924
- if (!_optionalChain([st, 'access', _247 => _247.paraMap, 'access', _248 => _248.get, 'call', _249 => _249(blockIndex), 'optionalAccess', _250 => _250.para])) {
24005
+ if (!_optionalChain([st, 'access', _249 => _249.paraMap, 'access', _250 => _250.get, 'call', _251 => _251(blockIndex), 'optionalAccess', _252 => _252.para])) {
23925
24006
  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)" };
23926
24007
  }
23927
24008
  return { capability: "text" };
@@ -23987,7 +24068,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
23987
24068
  continue;
23988
24069
  }
23989
24070
  if (block.type === "table" && block.table) {
23990
- if (!_optionalChain([edit, 'access', _251 => _251.cells, 'optionalAccess', _252 => _252.length])) {
24071
+ if (!_optionalChain([edit, 'access', _253 => _253.cells, 'optionalAccess', _254 => _254.length])) {
23991
24072
  skipped.push({ reason: "\uD45C \uBE14\uB85D\uC5D0\uB294 cells \uD3B8\uC9D1\uB9CC \uC9C0\uC6D0", before: summarize(_nullishCoalesce(block.table.caption, () => ( "(\uD45C)"))) });
23992
24073
  continue;
23993
24074
  }
@@ -24007,7 +24088,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24007
24088
  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) });
24008
24089
  continue;
24009
24090
  }
24010
- const irCell = _optionalChain([block, 'access', _253 => _253.table, 'access', _254 => _254.cells, 'access', _255 => _255[cellEdit.row], 'optionalAccess', _256 => _256[cellEdit.col]]);
24091
+ const irCell = _optionalChain([block, 'access', _255 => _255.table, 'access', _256 => _256.cells, 'access', _257 => _257[cellEdit.row], 'optionalAccess', _258 => _258[cellEdit.col]]);
24011
24092
  if (!irCell) {
24012
24093
  skipped.push({ reason: `\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16: ${cellEdit.row},${cellEdit.col}`, after: summarize(cellEdit.text) });
24013
24094
  continue;
@@ -24063,7 +24144,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24063
24144
  }
24064
24145
  if (replacements.size === 0) {
24065
24146
  let changes2;
24066
- if (_optionalChain([options, 'optionalAccess', _257 => _257.verify]) !== false) {
24147
+ if (_optionalChain([options, 'optionalAccess', _259 => _259.verify]) !== false) {
24067
24148
  const units = splitMarkdownUnits(st.markdown);
24068
24149
  changes2 = diffUnitLists(units, units);
24069
24150
  }
@@ -24084,7 +24165,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24084
24165
  }
24085
24166
  this.state = newState;
24086
24167
  let changes;
24087
- if (_optionalChain([options, 'optionalAccess', _258 => _258.verify]) !== false) {
24168
+ if (_optionalChain([options, 'optionalAccess', _260 => _260.verify]) !== false) {
24088
24169
  changes = diffUnitLists(splitMarkdownUnits(beforeMarkdown), splitMarkdownUnits(newState.markdown));
24089
24170
  }
24090
24171
  return { success: true, data: new Uint8Array(data), applied, skipped, changes };
@@ -24104,7 +24185,7 @@ var HwpxSession = (_class5 = class _HwpxSession {
24104
24185
  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)");
24105
24186
  }
24106
24187
  const mapping = st.paraMap.get(blockIndex);
24107
- if (!_optionalChain([mapping, 'optionalAccess', _259 => _259.para])) {
24188
+ if (!_optionalChain([mapping, 'optionalAccess', _261 => _261.para])) {
24108
24189
  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)");
24109
24190
  }
24110
24191
  let newPlain = newTextRaw.split("\n").map((l) => l.trim()).filter(Boolean).join(" ");
@@ -24124,14 +24205,14 @@ var HwpxSession = (_class5 = class _HwpxSession {
24124
24205
  if (sanitizeText(newPlain) !== newPlain) {
24125
24206
  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");
24126
24207
  }
24127
- const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _260 => _260.scans, 'access', _261 => _261[mapping.para.sectionIndex], 'optionalAccess', _262 => _262.xml]));
24208
+ const splices = buildParagraphSplices(mapping.para, newPlain, _optionalChain([st, 'access', _262 => _262.scans, 'access', _263 => _263[mapping.para.sectionIndex], 'optionalAccess', _264 => _264.xml]));
24128
24209
  if (splices === null) return skip("\uBB38\uB2E8\uC5D0 \uD14D\uC2A4\uD2B8 \uB178\uB4DC\uB97C \uB9CC\uB4E4 \uC218 \uC5C6\uC74C");
24129
24210
  sectionSplices[mapping.para.sectionIndex].push(...splices);
24130
24211
  return 1;
24131
24212
  }
24132
24213
  }, _class5);
24133
24214
  function cellStaticCheck(table, scanTable, r, c) {
24134
- const irCell = _optionalChain([table, 'access', _263 => _263.cells, 'access', _264 => _264[r], 'optionalAccess', _265 => _265[c]]);
24215
+ const irCell = _optionalChain([table, 'access', _265 => _265.cells, 'access', _266 => _266[r], 'optionalAccess', _267 => _267[c]]);
24135
24216
  if (!irCell) return { editable: false, reason: "\uC140 \uC88C\uD45C \uBC94\uC704 \uBC16" };
24136
24217
  const cell = scanTable.cellByAnchor.get(`${r},${c}`);
24137
24218
  if (!cell) return { editable: false, reason: "\uBCD1\uD569 \uC601\uC5ED\uC758 \uBE48 \uCE78\uC774\uAC70\uB098 \uC88C\uD45C \uBD88\uC77C\uCE58" };
@@ -24215,11 +24296,11 @@ var md = new (0, _markdownit2.default)({
24215
24296
  breaks: false
24216
24297
  });
24217
24298
  function renderHtml(markdown, options) {
24218
- const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _266 => _266.preset]), () => ( "default"));
24219
- const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _267 => _267.extraCss]), () => ( "")));
24299
+ const preset = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _268 => _268.preset]), () => ( "default"));
24300
+ const css = PRESETS[preset] + (_nullishCoalesce(_optionalChain([options, 'optionalAccess', _269 => _269.extraCss]), () => ( "")));
24220
24301
  const body = md.render(markdown);
24221
- const watermark = _optionalChain([options, 'optionalAccess', _268 => _268.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
24222
- const watermarkCss = _optionalChain([options, 'optionalAccess', _269 => _269.watermark]) ? `
24302
+ const watermark = _optionalChain([options, 'optionalAccess', _270 => _270.watermark]) ? `<div class="watermark">${escapeHtml(options.watermark)}</div>` : "";
24303
+ const watermarkCss = _optionalChain([options, 'optionalAccess', _271 => _271.watermark]) ? `
24223
24304
  .watermark {
24224
24305
  position: fixed;
24225
24306
  top: 50%; left: 50%;
@@ -24249,14 +24330,14 @@ async function htmlToPdf(html, options) {
24249
24330
  let puppeteer;
24250
24331
  try {
24251
24332
  puppeteer = await Promise.resolve().then(() => _interopRequireWildcard(require("puppeteer-core")));
24252
- } catch (e35) {
24253
- throw new (0, _chunkQZCP3UWUcjs.KordocError)(
24333
+ } catch (e30) {
24334
+ throw new (0, _chunkITJIALN5cjs.KordocError)(
24254
24335
  "PDF \uC0DD\uC131\uC5D0 puppeteer-core\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \uC124\uCE58: npm install puppeteer-core"
24255
24336
  );
24256
24337
  }
24257
24338
  const executablePath = _nullishCoalesce(process.env.PUPPETEER_EXECUTABLE_PATH, () => ( findChromiumPath()));
24258
24339
  if (!executablePath) {
24259
- throw new (0, _chunkQZCP3UWUcjs.KordocError)(
24340
+ throw new (0, _chunkITJIALN5cjs.KordocError)(
24260
24341
  "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."
24261
24342
  );
24262
24343
  }
@@ -24268,10 +24349,10 @@ async function htmlToPdf(html, options) {
24268
24349
  try {
24269
24350
  const page = await browser.newPage();
24270
24351
  await page.setContent(html, { waitUntil: "networkidle0" });
24271
- const margin = _optionalChain([options, 'optionalAccess', _270 => _270.margin]);
24352
+ const margin = _optionalChain([options, 'optionalAccess', _272 => _272.margin]);
24272
24353
  const pdf = await page.pdf({
24273
- format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _271 => _271.pageSize]), () => ( "A4")),
24274
- landscape: _optionalChain([options, 'optionalAccess', _272 => _272.orientation]) === "landscape",
24354
+ format: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _273 => _273.pageSize]), () => ( "A4")),
24355
+ landscape: _optionalChain([options, 'optionalAccess', _274 => _274.orientation]) === "landscape",
24275
24356
  printBackground: true,
24276
24357
  margin: margin ? {
24277
24358
  top: toCss(margin.top),
@@ -24279,9 +24360,9 @@ async function htmlToPdf(html, options) {
24279
24360
  bottom: toCss(margin.bottom),
24280
24361
  left: toCss(margin.left)
24281
24362
  } : void 0,
24282
- displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _273 => _273.header]) || _optionalChain([options, 'optionalAccess', _274 => _274.footer])),
24283
- headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _275 => _275.header]), () => ( "<div></div>")),
24284
- footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _276 => _276.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
24363
+ displayHeaderFooter: !!(_optionalChain([options, 'optionalAccess', _275 => _275.header]) || _optionalChain([options, 'optionalAccess', _276 => _276.footer])),
24364
+ headerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _277 => _277.header]), () => ( "<div></div>")),
24365
+ footerTemplate: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _278 => _278.footer]), () => ( '<div style="font-size:8pt;width:100%;text-align:center;color:#777;"><span class="pageNumber"></span>/<span class="totalPages"></span></div>'))
24285
24366
  });
24286
24367
  return Buffer.from(pdf);
24287
24368
  } finally {
@@ -24315,24 +24396,24 @@ async function markdownToPdf(markdown, options) {
24315
24396
  return htmlToPdf(html, options);
24316
24397
  }
24317
24398
  async function blocksToPdf(blocks, options) {
24318
- const markdown = _chunkQZCP3UWUcjs.blocksToMarkdown.call(void 0, blocks);
24399
+ const markdown = _chunkITJIALN5cjs.blocksToMarkdown.call(void 0, blocks);
24319
24400
  return markdownToPdf(markdown, options);
24320
24401
  }
24321
24402
 
24322
24403
  // src/index.ts
24323
24404
  async function parse(input, options) {
24324
24405
  let buffer;
24325
- const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _277 => _277.filePath]) ? { ...options, filePath: input } : options;
24406
+ const opts = typeof input === "string" && !_optionalChain([options, 'optionalAccess', _279 => _279.filePath]) ? { ...options, filePath: input } : options;
24326
24407
  if (typeof input === "string") {
24327
24408
  try {
24328
24409
  const buf = await _promises.readFile.call(void 0, input);
24329
- buffer = _chunkQZCP3UWUcjs.toArrayBuffer.call(void 0, buf);
24410
+ buffer = _chunkITJIALN5cjs.toArrayBuffer.call(void 0, buf);
24330
24411
  } catch (err) {
24331
24412
  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}`;
24332
24413
  return { success: false, fileType: "unknown", error: msg2, code: "PARSE_ERROR" };
24333
24414
  }
24334
24415
  } else if (Buffer.isBuffer(input)) {
24335
- buffer = _chunkQZCP3UWUcjs.toArrayBuffer.call(void 0, input);
24416
+ buffer = _chunkITJIALN5cjs.toArrayBuffer.call(void 0, input);
24336
24417
  } else {
24337
24418
  buffer = input;
24338
24419
  }
@@ -24367,21 +24448,21 @@ async function parseHwp3(buffer, options) {
24367
24448
  const { markdown, blocks, metadata, outline, warnings } = parseHwp3Document(buffer, options);
24368
24449
  return { success: true, fileType: "hwp3", markdown, blocks, metadata, outline, warnings };
24369
24450
  } catch (err) {
24370
- return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkQZCP3UWUcjs.classifyError.call(void 0, err) };
24451
+ return { success: false, fileType: "hwp3", error: err instanceof Error ? err.message : "HWP3 \uD30C\uC2F1 \uC2E4\uD328", code: _chunkITJIALN5cjs.classifyError.call(void 0, err) };
24371
24452
  }
24372
24453
  }
24373
24454
  async function parseHwpx(buffer, options) {
24374
24455
  try {
24375
24456
  const { markdown, blocks, metadata, outline, warnings, images } = await parseHwpxDocument(buffer, options);
24376
- return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _278 => _278.length]) ? images : void 0 };
24457
+ return { success: true, fileType: "hwpx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _280 => _280.length]) ? images : void 0 };
24377
24458
  } catch (err) {
24378
- return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkQZCP3UWUcjs.classifyError.call(void 0, err) };
24459
+ return { success: false, fileType: "hwpx", error: err instanceof Error ? err.message : "HWPX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkITJIALN5cjs.classifyError.call(void 0, err) };
24379
24460
  }
24380
24461
  }
24381
24462
  async function parseHwp(buffer, options) {
24382
24463
  try {
24383
24464
  const { markdown, blocks, metadata, outline, warnings, images } = parseHwp5Document(Buffer.from(buffer), options);
24384
- if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _279 => _279.filePath])) {
24465
+ if (isDistributionSentinel(markdown) && isComFallbackAvailable() && _optionalChain([options, 'optionalAccess', _281 => _281.filePath])) {
24385
24466
  try {
24386
24467
  const { pages, pageCount, warnings: comWarns } = extractTextViaCom(options.filePath);
24387
24468
  if (pages.some((p) => p && p.trim().length > 0)) {
@@ -24395,20 +24476,20 @@ async function parseHwp(buffer, options) {
24395
24476
  warnings: com.warnings
24396
24477
  };
24397
24478
  }
24398
- } catch (e36) {
24479
+ } catch (e31) {
24399
24480
  }
24400
24481
  }
24401
- return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _280 => _280.length]) ? images : void 0 };
24482
+ return { success: true, fileType: "hwp", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _282 => _282.length]) ? images : void 0 };
24402
24483
  } catch (err) {
24403
- return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkQZCP3UWUcjs.classifyError.call(void 0, err) };
24484
+ return { success: false, fileType: "hwp", error: err instanceof Error ? err.message : "HWP \uD30C\uC2F1 \uC2E4\uD328", code: _chunkITJIALN5cjs.classifyError.call(void 0, err) };
24404
24485
  }
24405
24486
  }
24406
24487
  async function parsePdf(buffer, options) {
24407
24488
  let parsePdfDocument;
24408
24489
  try {
24409
- const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-RFLPUZ7P.cjs")));
24490
+ const mod = await Promise.resolve().then(() => _interopRequireWildcard(require("./parser-GUSJH44K.cjs")));
24410
24491
  parsePdfDocument = mod.parsePdfDocument;
24411
- } catch (e37) {
24492
+ } catch (e32) {
24412
24493
  return {
24413
24494
  success: false,
24414
24495
  fileType: "pdf",
@@ -24421,7 +24502,7 @@ async function parsePdf(buffer, options) {
24421
24502
  return { success: true, fileType: "pdf", markdown, blocks, metadata, outline, warnings, isImageBased, pageQuality, qualitySummary };
24422
24503
  } catch (err) {
24423
24504
  const isImageBased = err instanceof Error && "isImageBased" in err ? true : void 0;
24424
- return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkQZCP3UWUcjs.classifyError.call(void 0, err), isImageBased };
24505
+ return { success: false, fileType: "pdf", error: err instanceof Error ? err.message : "PDF \uD30C\uC2F1 \uC2E4\uD328", code: _chunkITJIALN5cjs.classifyError.call(void 0, err), isImageBased };
24425
24506
  }
24426
24507
  }
24427
24508
  async function parseXlsx(buffer, options) {
@@ -24429,7 +24510,7 @@ async function parseXlsx(buffer, options) {
24429
24510
  const { markdown, blocks, metadata, warnings } = await parseXlsxDocument(buffer, options);
24430
24511
  return { success: true, fileType: "xlsx", markdown, blocks, metadata, warnings };
24431
24512
  } catch (err) {
24432
- return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkQZCP3UWUcjs.classifyError.call(void 0, err) };
24513
+ return { success: false, fileType: "xlsx", error: err instanceof Error ? err.message : "XLSX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkITJIALN5cjs.classifyError.call(void 0, err) };
24433
24514
  }
24434
24515
  }
24435
24516
  async function parseXls(buffer, options) {
@@ -24437,15 +24518,15 @@ async function parseXls(buffer, options) {
24437
24518
  const { markdown, blocks, metadata, warnings } = await parseXlsDocument(buffer, options);
24438
24519
  return { success: true, fileType: "xls", markdown, blocks, metadata, warnings };
24439
24520
  } catch (err) {
24440
- return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkQZCP3UWUcjs.classifyError.call(void 0, err) };
24521
+ return { success: false, fileType: "xls", error: err instanceof Error ? err.message : "XLS \uD30C\uC2F1 \uC2E4\uD328", code: _chunkITJIALN5cjs.classifyError.call(void 0, err) };
24441
24522
  }
24442
24523
  }
24443
24524
  async function parseDocx(buffer, options) {
24444
24525
  try {
24445
24526
  const { markdown, blocks, metadata, outline, warnings, images } = await parseDocxDocument(buffer, options);
24446
- return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _281 => _281.length]) ? images : void 0 };
24527
+ return { success: true, fileType: "docx", markdown, blocks, metadata, outline, warnings, images: _optionalChain([images, 'optionalAccess', _283 => _283.length]) ? images : void 0 };
24447
24528
  } catch (err) {
24448
- return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkQZCP3UWUcjs.classifyError.call(void 0, err) };
24529
+ return { success: false, fileType: "docx", error: err instanceof Error ? err.message : "DOCX \uD30C\uC2F1 \uC2E4\uD328", code: _chunkITJIALN5cjs.classifyError.call(void 0, err) };
24449
24530
  }
24450
24531
  }
24451
24532
  async function parseHwpml(buffer, options) {
@@ -24453,16 +24534,16 @@ async function parseHwpml(buffer, options) {
24453
24534
  const { markdown, blocks, metadata, outline, warnings } = parseHwpmlDocument(buffer, options);
24454
24535
  return { success: true, fileType: "hwpml", markdown, blocks, metadata, outline, warnings };
24455
24536
  } catch (err) {
24456
- return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkQZCP3UWUcjs.classifyError.call(void 0, err) };
24537
+ return { success: false, fileType: "hwpml", error: err instanceof Error ? err.message : "HWPML \uD30C\uC2F1 \uC2E4\uD328", code: _chunkITJIALN5cjs.classifyError.call(void 0, err) };
24457
24538
  }
24458
24539
  }
24459
24540
  async function fillForm(input, values, outputFormat = "markdown") {
24460
24541
  let buffer;
24461
24542
  if (typeof input === "string") {
24462
24543
  const buf = await _promises.readFile.call(void 0, input);
24463
- buffer = _chunkQZCP3UWUcjs.toArrayBuffer.call(void 0, buf);
24544
+ buffer = _chunkITJIALN5cjs.toArrayBuffer.call(void 0, buf);
24464
24545
  } else if (Buffer.isBuffer(input)) {
24465
- buffer = _chunkQZCP3UWUcjs.toArrayBuffer.call(void 0, input);
24546
+ buffer = _chunkITJIALN5cjs.toArrayBuffer.call(void 0, input);
24466
24547
  } else {
24467
24548
  buffer = input;
24468
24549
  }
@@ -24488,7 +24569,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
24488
24569
  throw new Error(`\uC11C\uC2DD \uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
24489
24570
  }
24490
24571
  const fill = fillFormFields(parsed.blocks, values);
24491
- const markdown = _chunkQZCP3UWUcjs.blocksToMarkdown.call(void 0, fill.blocks);
24572
+ const markdown = _chunkITJIALN5cjs.blocksToMarkdown.call(void 0, fill.blocks);
24492
24573
  if (outputFormat === "hwpx") {
24493
24574
  const hwpxBuffer = await markdownToHwpx(markdown);
24494
24575
  return { output: hwpxBuffer, format: "hwpx", fill };
@@ -24546,5 +24627,5 @@ async function fillForm(input, values, outputFormat = "markdown") {
24546
24627
 
24547
24628
 
24548
24629
 
24549
- exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkQZCP3UWUcjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkQZCP3UWUcjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.charWidthEm1000 = charWidthEm1000; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.fitRatioForFewerLines = fitRatioForFewerLines; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.measureTextWidth = measureTextWidth; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.renderHtml = renderHtml; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord;
24630
+ exports.HwpxSession = HwpxSession; exports.PRESET_ALIAS = PRESET_ALIAS; exports.SPACE_EM_FIXED = SPACE_EM_FIXED; exports.SPACE_EM_FONT = SPACE_EM_FONT; exports.VERSION = _chunkITJIALN5cjs.VERSION; exports.ValueCursor = ValueCursor; exports.applySplices = applySplices; exports.blocksToMarkdown = _chunkITJIALN5cjs.blocksToMarkdown; exports.blocksToPdf = blocksToPdf; exports.buildParagraphSplices = buildParagraphSplices; exports.buildRangeSplices = buildRangeSplices; exports.charWidthEm1000 = charWidthEm1000; exports.compare = compare; exports.detectFormat = detectFormat; exports.detectOle2Format = detectOle2Format; exports.detectZipFormat = detectZipFormat; exports.diffBlocks = diffBlocks; exports.extractFormFields = extractFormFields; exports.extractFormSchema = extractFormSchema; exports.fillForm = fillForm; exports.fillFormFields = fillFormFields; exports.fillHwpx = fillHwpx; exports.fitRatioForFewerLines = fitRatioForFewerLines; exports.inferFieldType = inferFieldType; exports.isHwpxFile = isHwpxFile; exports.isLabelCell = isLabelCell; exports.isOldHwpFile = isOldHwpFile; exports.isPdfFile = isPdfFile; exports.isZipFile = isZipFile; exports.markdownToHwpx = markdownToHwpx; exports.markdownToPdf = markdownToPdf; exports.measureTextWidth = measureTextWidth; exports.normalizeGongmunPreset = normalizeGongmunPreset; exports.openHwpxDocument = openHwpxDocument; exports.parse = parse; exports.parseDocx = parseDocx; exports.parseHwp = parseHwp; exports.parseHwp3 = parseHwp3; exports.parseHwpml = parseHwpml; exports.parseHwpx = parseHwpx; exports.parsePdf = parsePdf; exports.parseXls = parseXls; exports.parseXlsx = parseXlsx; exports.patchHwp = patchHwp; exports.patchHwpx = patchHwpx; exports.patchHwpxBlocks = patchHwpxBlocks; exports.renderHtml = renderHtml; exports.scanSectionXml = scanSectionXml; exports.simulateWrap = simulateWrap; exports.simulateWrapKeepWord = simulateWrapKeepWord;
24550
24631
  //# sourceMappingURL=index.cjs.map