kordoc 4.25.4 → 4.25.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/NOTICE +27 -0
  2. package/README.md +4 -4
  3. package/dist/{chunk-E6GI46SG.js → chunk-24J4EDVI.js} +2 -2
  4. package/dist/{chunk-ZG6RALGH.js → chunk-2RBIZALD.js} +8 -8
  5. package/dist/{chunk-FDGWDXAD.js → chunk-2VNL3FDS.js} +2 -2
  6. package/dist/{chunk-RZOEJ5TZ.js → chunk-3URB7DI4.js} +2 -2
  7. package/dist/{chunk-T7CUC2NM.js → chunk-3Y76RPK3.js} +6 -6
  8. package/dist/{chunk-LQ3FFPJ6.js → chunk-6L3VEOCI.js} +5 -5
  9. package/dist/{chunk-UAUB6Y5Z.js → chunk-6ZUQ6D3B.js} +6 -6
  10. package/dist/{chunk-HR2KFPXI.js → chunk-767ACEVN.js} +10 -4
  11. package/dist/{chunk-HR2KFPXI.js.map → chunk-767ACEVN.js.map} +2 -2
  12. package/dist/{chunk-M2V4WP7W.js → chunk-D2WQC6ME.js} +314 -22
  13. package/dist/chunk-D2WQC6ME.js.map +7 -0
  14. package/dist/{chunk-4XD2IEF7.js → chunk-D6MGUFRQ.js} +10 -10
  15. package/dist/{chunk-JKWHGHNW.js → chunk-DTUCE7H2.js} +2 -2
  16. package/dist/{chunk-RVUX6HWM.js → chunk-EDCNR6QZ.js} +2 -2
  17. package/dist/{chunk-V2TGRTXA.js → chunk-HMTLJJEC.js} +2 -2
  18. package/dist/{chunk-JNRXFGHU.js → chunk-I7MD3WQR.js} +2 -2
  19. package/dist/{chunk-35WXNRU4.js → chunk-IKQMEXGU.js} +4 -4
  20. package/dist/{chunk-MGVESXR2.js → chunk-ILUYLDIW.js} +4 -4
  21. package/dist/{chunk-PVZRQRIE.js → chunk-IOADEIUV.js} +3 -3
  22. package/dist/{chunk-MQCNWXMU.js → chunk-K4YTD6RG.js} +55 -7
  23. package/dist/{chunk-MQCNWXMU.js.map → chunk-K4YTD6RG.js.map} +2 -2
  24. package/dist/{chunk-A5DP2XNA.js → chunk-O4XRI7EC.js} +6 -6
  25. package/dist/{chunk-CO2A2WC5.js → chunk-QQVTLNLV.js} +2 -2
  26. package/dist/{chunk-FLHUJYGP.js → chunk-S4NQTGXD.js} +2 -2
  27. package/dist/{chunk-XS7MBWUH.js → chunk-TH7SIDYM.js} +2 -2
  28. package/dist/{chunk-KLWTVM6B.js → chunk-VDF7ZVNW.js} +2 -2
  29. package/dist/{chunk-FVDYN3E7.js → chunk-VHZYGCS4.js} +3 -3
  30. package/dist/{chunk-TWAXYEO2.js → chunk-VLOQQJ2D.js} +2 -2
  31. package/dist/{chunk-SEX4BBAX.js → chunk-XI47ZEQB.js} +2 -2
  32. package/dist/{chunk-ERNLA4BH.js → chunk-ZEJCW4XP.js} +2 -2
  33. package/dist/chunks-GPCDFBSF.js +10 -0
  34. package/dist/cli.js +52 -39
  35. package/dist/cli.js.map +2 -2
  36. package/dist/{formula-TAHOTZCD.js → formula-R6LXXMAS.js} +4 -4
  37. package/dist/{generator-UNGTBZVD.js → generator-ERKQ7LUN.js} +7 -7
  38. package/dist/{hancom-Q3SEMBRZ.js → hancom-VQUG46NV.js} +2 -2
  39. package/dist/{image-ocr-E3KNVXGP.js → image-ocr-MWQ6UDGP.js} +11 -11
  40. package/dist/index.cjs +473 -36
  41. package/dist/index.cjs.map +4 -4
  42. package/dist/index.d.cts +83 -2
  43. package/dist/index.d.ts +83 -2
  44. package/dist/index.js +27 -20
  45. package/dist/mcp.js +39 -36
  46. package/dist/mcp.js.map +2 -2
  47. package/dist/memo-7UFH4MNW.js +15 -0
  48. package/dist/{model-bundle-SNYPWRM5.js → model-bundle-3F33HOS2.js} +5 -5
  49. package/dist/{models-EMLB76WT.js → models-PD6EQIHL.js} +5 -5
  50. package/dist/{page-images-HZ2DRJGX.js → page-images-MZECTCSJ.js} +2 -2
  51. package/dist/{parse-worker-v2-XQPQK5RR.js → parse-worker-v2-ZXURNYJZ.js} +25 -22
  52. package/dist/{parse-worker-v2-XQPQK5RR.js.map → parse-worker-v2-ZXURNYJZ.js.map} +1 -1
  53. package/dist/{parser-MAPRIHZS.js → parser-WAJNO5VU.js} +108 -18
  54. package/dist/parser-WAJNO5VU.js.map +7 -0
  55. package/dist/{pdf-ocr-GB3Z5UHQ.js → pdf-ocr-GTVOOQNV.js} +9 -9
  56. package/dist/{profile-io-EVGG3THS.js → profile-io-UQSLXMWG.js} +3 -3
  57. package/dist/{rasterize-7PQL2TCQ.js → rasterize-3QDKNJC3.js} +3 -3
  58. package/dist/{redact-XWZQ7XUF.js → redact-M5UJUA23.js} +2 -2
  59. package/dist/{redact-doc-364J2TKR.js → redact-doc-IBLP55CI.js} +41 -24
  60. package/dist/{redact-doc-364J2TKR.js.map → redact-doc-IBLP55CI.js.map} +2 -2
  61. package/dist/{render-AZ5YXHUA.js → render-EPOTL6LB.js} +10 -10
  62. package/dist/{rewrite-fallback-VTXOOSUU.js → rewrite-fallback-5GPUDXDK.js} +12 -12
  63. package/dist/seal-7YV46Q77.js +14 -0
  64. package/dist/{setup-6NQLZAV2.js → setup-CTWIURYW.js} +3 -3
  65. package/dist/{to-hwpx-ULUHUGBZ.js → to-hwpx-OJNCWBXT.js} +7 -7
  66. package/dist/visual-U7X4QE2V.js +42 -0
  67. package/dist/{watch-5FI3NIL2.js → watch-NXUTGUPA.js} +24 -22
  68. package/dist/{watch-5FI3NIL2.js.map → watch-NXUTGUPA.js.map} +1 -1
  69. package/package.json +1 -1
  70. package/dist/chunk-M2V4WP7W.js.map +0 -7
  71. package/dist/chunks-WSSD23QG.js +0 -10
  72. package/dist/memo-BK5AJ3GY.js +0 -15
  73. package/dist/parser-MAPRIHZS.js.map +0 -7
  74. package/dist/seal-A3HZQLN5.js +0 -14
  75. package/dist/visual-VXECTX4R.js +0 -39
  76. /package/dist/{chunk-E6GI46SG.js.map → chunk-24J4EDVI.js.map} +0 -0
  77. /package/dist/{chunk-ZG6RALGH.js.map → chunk-2RBIZALD.js.map} +0 -0
  78. /package/dist/{chunk-FDGWDXAD.js.map → chunk-2VNL3FDS.js.map} +0 -0
  79. /package/dist/{chunk-RZOEJ5TZ.js.map → chunk-3URB7DI4.js.map} +0 -0
  80. /package/dist/{chunk-T7CUC2NM.js.map → chunk-3Y76RPK3.js.map} +0 -0
  81. /package/dist/{chunk-LQ3FFPJ6.js.map → chunk-6L3VEOCI.js.map} +0 -0
  82. /package/dist/{chunk-UAUB6Y5Z.js.map → chunk-6ZUQ6D3B.js.map} +0 -0
  83. /package/dist/{chunk-4XD2IEF7.js.map → chunk-D6MGUFRQ.js.map} +0 -0
  84. /package/dist/{chunk-JKWHGHNW.js.map → chunk-DTUCE7H2.js.map} +0 -0
  85. /package/dist/{chunk-RVUX6HWM.js.map → chunk-EDCNR6QZ.js.map} +0 -0
  86. /package/dist/{chunk-V2TGRTXA.js.map → chunk-HMTLJJEC.js.map} +0 -0
  87. /package/dist/{chunk-JNRXFGHU.js.map → chunk-I7MD3WQR.js.map} +0 -0
  88. /package/dist/{chunk-35WXNRU4.js.map → chunk-IKQMEXGU.js.map} +0 -0
  89. /package/dist/{chunk-MGVESXR2.js.map → chunk-ILUYLDIW.js.map} +0 -0
  90. /package/dist/{chunk-PVZRQRIE.js.map → chunk-IOADEIUV.js.map} +0 -0
  91. /package/dist/{chunk-A5DP2XNA.js.map → chunk-O4XRI7EC.js.map} +0 -0
  92. /package/dist/{chunk-CO2A2WC5.js.map → chunk-QQVTLNLV.js.map} +0 -0
  93. /package/dist/{chunk-FLHUJYGP.js.map → chunk-S4NQTGXD.js.map} +0 -0
  94. /package/dist/{chunk-XS7MBWUH.js.map → chunk-TH7SIDYM.js.map} +0 -0
  95. /package/dist/{chunk-KLWTVM6B.js.map → chunk-VDF7ZVNW.js.map} +0 -0
  96. /package/dist/{chunk-FVDYN3E7.js.map → chunk-VHZYGCS4.js.map} +0 -0
  97. /package/dist/{chunk-TWAXYEO2.js.map → chunk-VLOQQJ2D.js.map} +0 -0
  98. /package/dist/{chunk-SEX4BBAX.js.map → chunk-XI47ZEQB.js.map} +0 -0
  99. /package/dist/{chunk-ERNLA4BH.js.map → chunk-ZEJCW4XP.js.map} +0 -0
  100. /package/dist/{chunks-WSSD23QG.js.map → chunks-GPCDFBSF.js.map} +0 -0
  101. /package/dist/{formula-TAHOTZCD.js.map → formula-R6LXXMAS.js.map} +0 -0
  102. /package/dist/{generator-UNGTBZVD.js.map → generator-ERKQ7LUN.js.map} +0 -0
  103. /package/dist/{hancom-Q3SEMBRZ.js.map → hancom-VQUG46NV.js.map} +0 -0
  104. /package/dist/{image-ocr-E3KNVXGP.js.map → image-ocr-MWQ6UDGP.js.map} +0 -0
  105. /package/dist/{memo-BK5AJ3GY.js.map → memo-7UFH4MNW.js.map} +0 -0
  106. /package/dist/{model-bundle-SNYPWRM5.js.map → model-bundle-3F33HOS2.js.map} +0 -0
  107. /package/dist/{models-EMLB76WT.js.map → models-PD6EQIHL.js.map} +0 -0
  108. /package/dist/{page-images-HZ2DRJGX.js.map → page-images-MZECTCSJ.js.map} +0 -0
  109. /package/dist/{pdf-ocr-GB3Z5UHQ.js.map → pdf-ocr-GTVOOQNV.js.map} +0 -0
  110. /package/dist/{profile-io-EVGG3THS.js.map → profile-io-UQSLXMWG.js.map} +0 -0
  111. /package/dist/{rasterize-7PQL2TCQ.js.map → rasterize-3QDKNJC3.js.map} +0 -0
  112. /package/dist/{redact-XWZQ7XUF.js.map → redact-M5UJUA23.js.map} +0 -0
  113. /package/dist/{render-AZ5YXHUA.js.map → render-EPOTL6LB.js.map} +0 -0
  114. /package/dist/{rewrite-fallback-VTXOOSUU.js.map → rewrite-fallback-5GPUDXDK.js.map} +0 -0
  115. /package/dist/{seal-A3HZQLN5.js.map → seal-7YV46Q77.js.map} +0 -0
  116. /package/dist/{setup-6NQLZAV2.js.map → setup-CTWIURYW.js.map} +0 -0
  117. /package/dist/{to-hwpx-ULUHUGBZ.js.map → to-hwpx-OJNCWBXT.js.map} +0 -0
  118. /package/dist/{visual-VXECTX4R.js.map → visual-U7X4QE2V.js.map} +0 -0
@@ -53,17 +53,17 @@ import {
53
53
  unescapeGfm,
54
54
  unescapeGfmCell,
55
55
  wordHunks
56
- } from "./chunk-T7CUC2NM.js";
56
+ } from "./chunk-3Y76RPK3.js";
57
57
  import {
58
58
  decryptHwpxInPlace,
59
59
  lockedHwpxError,
60
60
  noteFormatFrom,
61
61
  noteRefMark
62
- } from "./chunk-FVDYN3E7.js";
62
+ } from "./chunk-VHZYGCS4.js";
63
63
  import {
64
64
  patchZipEntries,
65
65
  readZipEntries
66
- } from "./chunk-FLHUJYGP.js";
66
+ } from "./chunk-S4NQTGXD.js";
67
67
  import {
68
68
  allLinesegRemovalSplices,
69
69
  applySplices,
@@ -92,7 +92,7 @@ import {
92
92
  findChildByLocalName,
93
93
  localName,
94
94
  readZipEntry
95
- } from "./chunk-CO2A2WC5.js";
95
+ } from "./chunk-QQVTLNLV.js";
96
96
  import {
97
97
  comResultToParseResult,
98
98
  extractTextViaCom,
@@ -107,7 +107,7 @@ import {
107
107
  locateMemoBlocks,
108
108
  parseHwp5Document,
109
109
  unfilledClickHereGuide
110
- } from "./chunk-LQ3FFPJ6.js";
110
+ } from "./chunk-6L3VEOCI.js";
111
111
  import {
112
112
  FLAG_COMPRESSED,
113
113
  FLAG_DISTRIBUTION,
@@ -128,7 +128,7 @@ import {
128
128
  isExtendedOnlyCtrlChar,
129
129
  parseFileHeader,
130
130
  readRecords
131
- } from "./chunk-SEX4BBAX.js";
131
+ } from "./chunk-XI47ZEQB.js";
132
132
  import {
133
133
  parsePageRange
134
134
  } from "./chunk-W5CMIZUB.js";
@@ -140,20 +140,20 @@ import {
140
140
  } from "./chunk-G5XEBGZD.js";
141
141
  import {
142
142
  unframeLayoutTables
143
- } from "./chunk-JNRXFGHU.js";
143
+ } from "./chunk-I7MD3WQR.js";
144
144
  import {
145
145
  blocksToMarkdown,
146
146
  escapeGfm,
147
147
  hasInlineCellBlocks,
148
148
  sanitizeText
149
- } from "./chunk-E6GI46SG.js";
149
+ } from "./chunk-24J4EDVI.js";
150
150
  import {
151
151
  KordocError,
152
152
  compareSectionPaths,
153
153
  isPathTraversal,
154
154
  precheckZipSize,
155
155
  stripDtd
156
- } from "./chunk-RZOEJ5TZ.js";
156
+ } from "./chunk-3URB7DI4.js";
157
157
 
158
158
  // src/hwpx/parser.ts
159
159
  import JSZip2 from "jszip";
@@ -4210,4 +4210,4 @@ export {
4210
4210
  removeNoteMarks,
4211
4211
  diffUnitLists
4212
4212
  };
4213
- //# sourceMappingURL=chunk-4XD2IEF7.js.map
4213
+ //# sourceMappingURL=chunk-D6MGUFRQ.js.map
@@ -12,7 +12,7 @@ import {
12
12
  } from "./chunk-ZVBVGSXC.js";
13
13
  import {
14
14
  blocksToMarkdown
15
- } from "./chunk-E6GI46SG.js";
15
+ } from "./chunk-24J4EDVI.js";
16
16
  import {
17
17
  mapPuaText,
18
18
  pairedNumber
@@ -2199,4 +2199,4 @@ export {
2199
2199
  restoreNamedGlyphs,
2200
2200
  restoreUnmappedCidSpaces
2201
2201
  };
2202
- //# sourceMappingURL=chunk-JKWHGHNW.js.map
2202
+ //# sourceMappingURL=chunk-DTUCE7H2.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  KordocError
3
- } from "./chunk-RZOEJ5TZ.js";
3
+ } from "./chunk-3URB7DI4.js";
4
4
 
5
5
  // src/shared/offline.ts
6
6
  import { realpathSync } from "fs";
@@ -48,4 +48,4 @@ export {
48
48
  getAccessRoot,
49
49
  assertWithinRoot
50
50
  };
51
- //# sourceMappingURL=chunk-RVUX6HWM.js.map
51
+ //# sourceMappingURL=chunk-EDCNR6QZ.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-T3CW5OXA.js";
4
4
  import {
5
5
  KordocError
6
- } from "./chunk-RZOEJ5TZ.js";
6
+ } from "./chunk-3URB7DI4.js";
7
7
 
8
8
  // src/image/heic.ts
9
9
  var MAX_HEIC_PIXELS = 16383 * 16383;
@@ -103,4 +103,4 @@ export {
103
103
  dcxPages,
104
104
  pcxToRgba
105
105
  };
106
- //# sourceMappingURL=chunk-V2TGRTXA.js.map
106
+ //# sourceMappingURL=chunk-HMTLJJEC.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  visibleText
3
- } from "./chunk-E6GI46SG.js";
3
+ } from "./chunk-24J4EDVI.js";
4
4
 
5
5
  // src/script-tags.ts
6
6
  var LITERAL_TAG = /<(?=\/?(?:u|sup|sub)>)/g;
@@ -335,4 +335,4 @@ export {
335
335
  HEADING_RATIO_H2,
336
336
  HEADING_RATIO_H3
337
337
  };
338
- //# sourceMappingURL=chunk-JNRXFGHU.js.map
338
+ //# sourceMappingURL=chunk-I7MD3WQR.js.map
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  patchZipEntries
3
- } from "./chunk-FLHUJYGP.js";
3
+ } from "./chunk-S4NQTGXD.js";
4
4
  import {
5
5
  applySplices,
6
6
  scanSectionXml
@@ -8,11 +8,11 @@ import {
8
8
  import {
9
9
  parseRenderStyles,
10
10
  readZipEntry
11
- } from "./chunk-CO2A2WC5.js";
11
+ } from "./chunk-QQVTLNLV.js";
12
12
  import {
13
13
  KordocError,
14
14
  precheckZipSize
15
- } from "./chunk-RZOEJ5TZ.js";
15
+ } from "./chunk-3URB7DI4.js";
16
16
 
17
17
  // src/form/seal.ts
18
18
  import JSZip from "jszip";
@@ -318,4 +318,4 @@ export {
318
318
  collectSites,
319
319
  placeSealHwpx
320
320
  };
321
- //# sourceMappingURL=chunk-35WXNRU4.js.map
321
+ //# sourceMappingURL=chunk-IKQMEXGU.js.map
@@ -29,7 +29,7 @@ import {
29
29
  stackedGlyphBands,
30
30
  starRun,
31
31
  tallInkCount
32
- } from "./chunk-HR2KFPXI.js";
32
+ } from "./chunk-767ACEVN.js";
33
33
  import {
34
34
  validateOcrOptions
35
35
  } from "./chunk-M3E5NYSN.js";
@@ -45,14 +45,14 @@ import {
45
45
  ocrSourcePath,
46
46
  parseCharacterDict,
47
47
  resolveOcrModels
48
- } from "./chunk-ERNLA4BH.js";
48
+ } from "./chunk-ZEJCW4XP.js";
49
49
  import {
50
50
  disableOrtTelemetry
51
51
  } from "./chunk-AY66PEUP.js";
52
52
  import {
53
53
  KordocError,
54
54
  OPTIONAL_DEP_INSTALL_HINT
55
- } from "./chunk-RZOEJ5TZ.js";
55
+ } from "./chunk-3URB7DI4.js";
56
56
 
57
57
  // src/ocr/ocr-stacked-rows.ts
58
58
  var NUMERIC = /^[-+−△▲▽▼]?[\d.,]+[%p원]?$|^[-–—·∼~]원?$|^\([-+−△▲▽▼]?[\d.,]+%?\)$/;
@@ -3637,4 +3637,4 @@ export {
3637
3637
  ocrItemsToBlocks,
3638
3638
  markOcrHeadings
3639
3639
  };
3640
- //# sourceMappingURL=chunk-MGVESXR2.js.map
3640
+ //# sourceMappingURL=chunk-ILUYLDIW.js.map
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  parse
3
- } from "./chunk-M2V4WP7W.js";
3
+ } from "./chunk-D2WQC6ME.js";
4
4
  import {
5
5
  classifyError,
6
6
  sanitizeError,
7
7
  toArrayBuffer
8
- } from "./chunk-RZOEJ5TZ.js";
8
+ } from "./chunk-3URB7DI4.js";
9
9
 
10
10
  // src/cli/worker-parse.ts
11
11
  import { readFile, stat } from "fs/promises";
@@ -25,4 +25,4 @@ async function parseWorkerFile(absPath, options) {
25
25
  export {
26
26
  parseWorkerFile
27
27
  };
28
- //# sourceMappingURL=chunk-PVZRQRIE.js.map
28
+ //# sourceMappingURL=chunk-IOADEIUV.js.map
@@ -1761,6 +1761,21 @@ var NAME_VARIANTS = [
1761
1761
  }
1762
1762
  }
1763
1763
  ];
1764
+ var REGION_PREFIX_RE = new RegExp(`^(?:${REGION})(?=\\s)`);
1765
+ var modelAddressOk = (norm) => !PLACEHOLDER_NO.test(norm);
1766
+ function maskModelSpan(value, norm, rule, maskChar) {
1767
+ let keep = 0;
1768
+ if (rule === "address") keep = REGION_PREFIX_RE.exec(norm)?.[0].length ?? 0;
1769
+ else {
1770
+ const first = norm.search(new RegExp("\\p{L}", "u"));
1771
+ if (first >= 0 && norm.replace(/\s/g, "").length >= 3) {
1772
+ keep = first + (DOUBLE_SURNAMES.some((d) => norm.startsWith(d, first)) ? 2 : 1);
1773
+ }
1774
+ }
1775
+ let out = "";
1776
+ for (let i = 0; i < value.length; i++) out += i >= keep && /[\p{L}\p{N}]/u.test(norm[i]) ? maskChar : value[i];
1777
+ return out;
1778
+ }
1764
1779
 
1765
1780
  // src/redact-rules.ts
1766
1781
  var RULE_PRIORITY = [
@@ -2175,13 +2190,25 @@ function assertMaskChar(maskChar) {
2175
2190
  throw new Error(`maskChar\uB294 \uC601\uC22B\uC790\xB7\uACF5\uBC31\xB7\uC81C\uC5B4/\uACB0\uD569 \uBB38\uC790\xB7\uAD6C\uBD84 \uAE30\uD638(|\\<>&"'._-@+:/,;)\uAC00 \uC544\uB2CC \uBCF4\uC774\uB294 1\uAE00\uC790\uC5EC\uC57C \uD568: ${JSON.stringify(maskChar)}`);
2176
2191
  }
2177
2192
  }
2193
+ var NO_CTX = /* @__PURE__ */ new Set();
2178
2194
  var LIST_SEP_RE = /^\s{0,2}(?:[,;/·、]|및|또는)?\s{0,2}$/;
2179
- function detect(text, rules, maskChar, headerAt) {
2195
+ function detect(text, rules, maskChar, headerAt, modelSpans) {
2180
2196
  const norm = normalizeForDetect(text);
2181
2197
  const hits = [];
2182
2198
  const occupied = [];
2183
2199
  for (const rule of RULE_PRIORITY) {
2184
2200
  if (!rules.includes(rule)) continue;
2201
+ for (const s of modelSpans ?? []) {
2202
+ if (s.rule !== rule) continue;
2203
+ const start = Math.max(0, s.index);
2204
+ const end = Math.min(text.length, s.index + s.length);
2205
+ if (end <= start || occupied.some((o) => start < o.end && end > o.start)) continue;
2206
+ if (rule === "address" && !modelAddressOk(norm.slice(start, end))) continue;
2207
+ const masked = maskModelSpan(text.slice(start, end), norm.slice(start, end), s.rule, maskChar);
2208
+ if (masked === text.slice(start, end)) continue;
2209
+ occupied.push({ start, end, ctx: () => NO_CTX, rule });
2210
+ hits.push({ rule, masked, index: start, length: end - start });
2211
+ }
2185
2212
  for (const v of RULES[rule]) {
2186
2213
  const re = v.re;
2187
2214
  re.lastIndex = 0;
@@ -2247,7 +2274,7 @@ function redactText(text, options) {
2247
2274
  assertMaskChar(maskChar);
2248
2275
  const rules = options?.rules ?? DEFAULT_REDACT_RULES;
2249
2276
  if (text === "" || rules.length === 0) return { text, hits: [] };
2250
- const hits = detect(text, rules, maskChar);
2277
+ const hits = detect(text, rules, maskChar, void 0, options?.modelSpans);
2251
2278
  return { text: applyHits(text, hits), hits };
2252
2279
  }
2253
2280
  function pipePositions(line) {
@@ -2345,9 +2372,9 @@ function mdMarkerRanges(line) {
2345
2372
  }
2346
2373
  return out.sort((a, b) => a[0] - b[0]);
2347
2374
  }
2348
- function detectMarkdownLine(line, rules, maskChar, headerAt) {
2375
+ function detectMarkdownLine(line, rules, maskChar, headerAt, modelSpans) {
2349
2376
  const markers = mdMarkerRanges(line);
2350
- if (markers.length === 0) return detect(line, rules, maskChar, headerAt);
2377
+ if (markers.length === 0) return detect(line, rules, maskChar, headerAt, modelSpans);
2351
2378
  let clean = "";
2352
2379
  const map = [];
2353
2380
  let cursor = 0;
@@ -2362,7 +2389,22 @@ function detectMarkdownLine(line, rules, maskChar, headerAt) {
2362
2389
  cursor = me;
2363
2390
  }
2364
2391
  keep(line.length);
2365
- const hits = detect(clean, rules, maskChar, headerAt ? (i) => headerAt(map[i] ?? i) : void 0);
2392
+ let cleanSpans;
2393
+ if (modelSpans?.length) {
2394
+ cleanSpans = [];
2395
+ for (const s of modelSpans) {
2396
+ let a = -1;
2397
+ let b = -1;
2398
+ for (let k = 0; k < map.length; k++) {
2399
+ if (map[k] < s.index) continue;
2400
+ if (map[k] >= s.index + s.length) break;
2401
+ if (a < 0) a = k;
2402
+ b = k + 1;
2403
+ }
2404
+ if (a >= 0) cleanSpans.push({ ...s, index: a, length: b - a });
2405
+ }
2406
+ }
2407
+ const hits = detect(clean, rules, maskChar, headerAt ? (i) => headerAt(map[i] ?? i) : void 0, cleanSpans);
2366
2408
  return hits.map((h) => {
2367
2409
  const start = map[h.index];
2368
2410
  const end = map[h.index + h.length - 1] + 1;
@@ -2380,13 +2422,19 @@ function redactMarkdown(markdown, options) {
2380
2422
  const lines = markdown.split("\n");
2381
2423
  const headers = tableHeaderContext(lines);
2382
2424
  const hits = [];
2425
+ const spans = options?.modelSpans;
2383
2426
  let offset = 0;
2384
2427
  const outLines = lines.map((line, i) => {
2385
2428
  if (line.includes("data:image/") || line === "" || rules.length === 0) {
2386
2429
  offset += line.length + 1;
2387
2430
  return line;
2388
2431
  }
2389
- const lineHits = detectMarkdownLine(line, rules, maskChar, headers.get(i));
2432
+ const lineEnd = offset + line.length;
2433
+ const lineSpans = spans?.filter((s) => s.index < lineEnd && s.index + s.length > offset).map((s) => {
2434
+ const a = Math.max(s.index, offset);
2435
+ return { ...s, index: a - offset, length: Math.min(s.index + s.length, lineEnd) - a };
2436
+ });
2437
+ const lineHits = detectMarkdownLine(line, rules, maskChar, headers.get(i), lineSpans);
2390
2438
  for (const h of lineHits) hits.push({ ...h, index: h.index + offset });
2391
2439
  offset += line.length + 1;
2392
2440
  return applyHits(line, lineHits);
@@ -2403,4 +2451,4 @@ export {
2403
2451
  mdMarkerRanges,
2404
2452
  redactMarkdown
2405
2453
  };
2406
- //# sourceMappingURL=chunk-MQCNWXMU.js.map
2454
+ //# sourceMappingURL=chunk-K4YTD6RG.js.map