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
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  extractRenderedRegions,
3
3
  renderDocumentToScene
4
- } from "./chunk-ZG6RALGH.js";
4
+ } from "./chunk-2RBIZALD.js";
5
5
  import {
6
6
  EV,
7
7
  blocksToPages,
@@ -17,7 +17,7 @@ import {
17
17
  restoreUnmappedGlyphs,
18
18
  spaceMappedDots,
19
19
  wmfBitmap
20
- } from "./chunk-JKWHGHNW.js";
20
+ } from "./chunk-DTUCE7H2.js";
21
21
  import {
22
22
  applyCellEdit,
23
23
  buildOrigUnits,
@@ -30,13 +30,13 @@ import {
30
30
  resolveParagraphMappings,
31
31
  resolveSectionEntryNames,
32
32
  stripCellTokens
33
- } from "./chunk-4XD2IEF7.js";
33
+ } from "./chunk-D6MGUFRQ.js";
34
34
  import {
35
35
  dcxPages,
36
36
  hasLibheif,
37
37
  heicToRgba,
38
38
  pcxToRgba
39
- } from "./chunk-V2TGRTXA.js";
39
+ } from "./chunk-HMTLJJEC.js";
40
40
  import {
41
41
  WEBP_OPTIONS,
42
42
  flushHeifCache,
@@ -69,10 +69,10 @@ import {
69
69
  summarize,
70
70
  topLevelParagraphs,
71
71
  usesV5Engine
72
- } from "./chunk-T7CUC2NM.js";
72
+ } from "./chunk-3Y76RPK3.js";
73
73
  import {
74
74
  patchZipEntries
75
- } from "./chunk-FLHUJYGP.js";
75
+ } from "./chunk-S4NQTGXD.js";
76
76
  import {
77
77
  ANNOTATION_BLANK_RE,
78
78
  ValueCursor,
@@ -111,7 +111,7 @@ import {
111
111
  rawTextContent,
112
112
  readZipEntry,
113
113
  warnInto
114
- } from "./chunk-CO2A2WC5.js";
114
+ } from "./chunk-QQVTLNLV.js";
115
115
  import {
116
116
  comResultToParseResult,
117
117
  extractTextViaCom,
@@ -128,7 +128,7 @@ import {
128
128
  memosMarkdown,
129
129
  parseHwp5Document,
130
130
  resolveImageBlocks
131
- } from "./chunk-LQ3FFPJ6.js";
131
+ } from "./chunk-6L3VEOCI.js";
132
132
  import {
133
133
  MAX_PIXELS,
134
134
  bmpToPng,
@@ -166,7 +166,7 @@ import {
166
166
  stripScriptTags,
167
167
  tidyScriptTags,
168
168
  wrapScript
169
- } from "./chunk-JNRXFGHU.js";
169
+ } from "./chunk-I7MD3WQR.js";
170
170
  import {
171
171
  MAX_COLS,
172
172
  MAX_ROWS,
@@ -177,11 +177,18 @@ import {
177
177
  flattenLayoutTables,
178
178
  hasStructuredCellContent,
179
179
  sanitizeText
180
- } from "./chunk-E6GI46SG.js";
180
+ } from "./chunk-24J4EDVI.js";
181
181
  import {
182
182
  hangulAmount,
183
183
  mapPuaText
184
184
  } from "./chunk-RJCXOE4N.js";
185
+ import {
186
+ disableOrtTelemetry
187
+ } from "./chunk-AY66PEUP.js";
188
+ import {
189
+ ensureModelsIn,
190
+ getModelsDir
191
+ } from "./chunk-2VNL3FDS.js";
185
192
  import {
186
193
  BARE_URL,
187
194
  KordocError,
@@ -199,10 +206,10 @@ import {
199
206
  toArrayBuffer,
200
207
  unescapeHtml,
201
208
  unzipLimitBytes
202
- } from "./chunk-RZOEJ5TZ.js";
209
+ } from "./chunk-3URB7DI4.js";
203
210
 
204
211
  // src/table/visual.ts
205
- import { readFile as readFile3 } from "node:fs/promises";
212
+ import { readFile as readFile4 } from "node:fs/promises";
206
213
 
207
214
  // src/plain-markdown.ts
208
215
  function toPlainMarkdown(md) {
@@ -306,7 +313,7 @@ function htmlCellLinks(markdown) {
306
313
  }
307
314
 
308
315
  // src/index.ts
309
- import { readFile as readFile2 } from "fs/promises";
316
+ import { readFile as readFile3 } from "fs/promises";
310
317
 
311
318
  // src/hwp3/parser.ts
312
319
  import { inflateRawSync as inflateRawSync2 } from "zlib";
@@ -16977,7 +16984,7 @@ var MIN_SIDE = 24;
16977
16984
  async function ocrEmbeddedImages(blocks, options, warnings) {
16978
16985
  const ocr = options?.ocr;
16979
16986
  if (ocr !== true && ocr !== "force" && typeof ocr !== "function") return false;
16980
- const { parseImageDocument } = await import("./image-ocr-E3KNVXGP.js");
16987
+ const { parseImageDocument } = await import("./image-ocr-MWQ6UDGP.js");
16981
16988
  let inserted = false, unreadable = 0;
16982
16989
  let failed = null;
16983
16990
  const walk = async (list, depth) => {
@@ -20575,6 +20582,288 @@ async function validateHwpx(buffer) {
20575
20582
  return { ok: issues.length === 0, issues, entryCount: names.length };
20576
20583
  }
20577
20584
 
20585
+ // src/redact-model.ts
20586
+ import { join as join3 } from "path";
20587
+ import { readFile as readFile2 } from "fs/promises";
20588
+ var REVISION = "d0fd48e688f383d5bca27f4b15e2f3b61a0b010e";
20589
+ var BASE = `https://huggingface.co/schift-io/schift-ko-pii-ax-v1/resolve/${REVISION}/`;
20590
+ var offline = (f) => `\uC628\uB77C\uC778 PC\uC5D0\uC11C ${BASE}\u2026 \uC758 \uD30C\uC77C\uC744 \uBC1B\uC544 \uC774 PC \uBAA8\uB378 \uCE90\uC2DC\uC758 schift-pii/${f} \uB85C \uBC18\uC785\uD558\uC138\uC694(SHA-256 \uC744 \uAC80\uC99D\uD55C\uB2E4)`;
20591
+ var PII_TOKENIZER = {
20592
+ name: "schift-ko-pii-ax-v1 tokenizer",
20593
+ filename: "tokenizer.json",
20594
+ url: `${BASE}tokenizer.json`,
20595
+ sha256: "ef9bebca9c6529bdefa19909059e07dfdfd7c2f8afeefbf4d230a784a3847d64",
20596
+ sizeMb: 1.1,
20597
+ offlineHint: offline("tokenizer.json")
20598
+ };
20599
+ var PII_MODEL_INT8 = {
20600
+ name: "schift-ko-pii-ax-v1 int8",
20601
+ filename: "pii_int8.onnx",
20602
+ url: `${BASE}onnx/pii_int8.onnx`,
20603
+ sha256: "9070138ab3d3d1ebb0d1c5211ff4a10f5db35c7c09ae17261001e1aa0084b81c",
20604
+ sizeMb: 151,
20605
+ offlineHint: offline("pii_int8.onnx")
20606
+ };
20607
+ var PII_MODEL_Q4 = {
20608
+ name: "schift-ko-pii-ax-v1 q4",
20609
+ filename: "pii_q4b128.onnx",
20610
+ url: `${BASE}onnx/pii_q4b128.onnx`,
20611
+ sha256: "f58a873a6eb23bea6ab03f1cdd7b8b59cacf8fc688c9c1741d822e1661ed0be9",
20612
+ sizeMb: 81,
20613
+ offlineHint: offline("pii_q4b128.onnx")
20614
+ };
20615
+ var VARIANTS = {
20616
+ int8: { spec: PII_MODEL_INT8, threshold: 0.625 },
20617
+ q4: { spec: PII_MODEL_Q4, threshold: 0.725 }
20618
+ };
20619
+ var PII_MODEL_LABELS = [
20620
+ "O",
20621
+ "B-private_person",
20622
+ "I-private_person",
20623
+ "E-private_person",
20624
+ "S-private_person",
20625
+ "B-private_address",
20626
+ "I-private_address",
20627
+ "E-private_address",
20628
+ "S-private_address"
20629
+ ];
20630
+ var GROUP_RULE = { private_person: "name", private_address: "address" };
20631
+ function getPiiModelsDir() {
20632
+ return getModelsDir("schift-pii");
20633
+ }
20634
+ async function loadPiiModel(options) {
20635
+ const variant = options?.variant ?? "int8";
20636
+ const v = VARIANTS[variant];
20637
+ if (!v) throw new Error(`\uC54C \uC218 \uC5C6\uB294 PII \uBAA8\uB378: ${variant} (int8 \xB7 q4)`);
20638
+ const dir = getPiiModelsDir();
20639
+ await ensureModelsIn(dir, [PII_TOKENIZER, v.spec], options?.onProgress);
20640
+ let ort;
20641
+ try {
20642
+ disableOrtTelemetry();
20643
+ ort = await import("onnxruntime-node");
20644
+ } catch (e) {
20645
+ throw new Error(
20646
+ `\uC778\uBA85\xB7\uC8FC\uC18C \uBAA8\uB378\uC744 \uC4F0\uB824\uBA74 optional dependency 'onnxruntime-node' \uAC00 \uD544\uC694\uD569\uB2C8\uB2E4. \`npm install onnxruntime-node\` \uD6C4 \uB2E4\uC2DC \uC2E4\uD589\uD558\uC138\uC694. \uC6D0\uC778: ${e.message}`
20647
+ );
20648
+ }
20649
+ const session = await ort.InferenceSession.create(join3(dir, v.spec.filename), {
20650
+ graphOptimizationLevel: "all",
20651
+ executionProviders: ["cpu"],
20652
+ logSeverityLevel: 3,
20653
+ ...options?.threads ? { intraOpNumThreads: options.threads } : {}
20654
+ });
20655
+ const tokenizer = JSON.parse(await readFile2(join3(dir, PII_TOKENIZER.filename), "utf-8"));
20656
+ return createPiiModel({ ort, session, tokenizer, threshold: v.threshold, variant });
20657
+ }
20658
+ var shared = /* @__PURE__ */ new Map();
20659
+ function sharedPiiModel(options) {
20660
+ const key2 = `${options?.variant ?? "int8"}:${options?.threads ?? ""}`;
20661
+ let p = shared.get(key2);
20662
+ if (!p) {
20663
+ p = loadPiiModel(options);
20664
+ p.catch(() => shared.delete(key2));
20665
+ shared.set(key2, p);
20666
+ }
20667
+ return p;
20668
+ }
20669
+ function createPiiModel(o) {
20670
+ const labels = o.labels ?? PII_MODEL_LABELS;
20671
+ if (labels[0] !== "O") throw new Error("labels \uCCAB \uD56D\uBAA9\uC740 O \uC5EC\uC57C \uD568");
20672
+ const tok = createWordPiece(o.tokenizer);
20673
+ const width = (o.maxTokens ?? 512) - 2;
20674
+ const overlap = o.overlapTokens ?? 64;
20675
+ if (width <= overlap) throw new Error("maxTokens - 2 \uAC00 overlapTokens \uBCF4\uB2E4 \uCEE4\uC57C \uD568");
20676
+ const L = labels.length;
20677
+ async function window(ids, offsets) {
20678
+ const all = [tok.bos, ...ids, tok.eos];
20679
+ const n = all.length;
20680
+ const out = await o.session.run({
20681
+ input_ids: new o.ort.Tensor("int64", BigInt64Array.from(all, BigInt), [1, n]),
20682
+ attention_mask: new o.ort.Tensor("int64", new BigInt64Array(n).fill(1n), [1, n])
20683
+ });
20684
+ const logits = (out.logits ?? Object.values(out)[0]).data;
20685
+ if (logits.length !== n * L) throw new Error(`logits \uD06C\uAE30 ${logits.length} \u2260 ${n}\uD1A0\uD070 \xD7 ${L}\uB77C\uBCA8`);
20686
+ const tags = [];
20687
+ const conf = [];
20688
+ for (let k = 1; k < n - 1; k++) {
20689
+ let max = -Infinity;
20690
+ let arg = 0;
20691
+ for (let j = 0; j < L; j++) {
20692
+ const x = logits[k * L + j];
20693
+ if (x > max) {
20694
+ max = x;
20695
+ arg = j;
20696
+ }
20697
+ }
20698
+ let z = 0;
20699
+ for (let j = 0; j < L; j++) z += Math.exp(logits[k * L + j] - max);
20700
+ tags.push(arg);
20701
+ conf.push(1 / z);
20702
+ }
20703
+ return decodeBioes(tags, conf, offsets, labels).filter((s) => s[3] >= o.threshold);
20704
+ }
20705
+ return {
20706
+ variant: o.variant ?? "custom",
20707
+ async detect(text) {
20708
+ if (!text) return [];
20709
+ const { ids, offsets } = tok.encode(text);
20710
+ if (ids.length === 0) return [];
20711
+ const found = [];
20712
+ for (let i = 0; ; i += width - overlap) {
20713
+ const end = Math.min(i + width, ids.length);
20714
+ found.push(...await window(ids.slice(i, end), offsets.slice(i, end)));
20715
+ if (end >= ids.length) break;
20716
+ }
20717
+ const u16 = utf16Index(text);
20718
+ found.sort((a, b) => a[0] - b[0] || b[1] - a[1]);
20719
+ const spans = [];
20720
+ let lastEnd = -1;
20721
+ for (const [s, e, group, score] of found) {
20722
+ const rule = GROUP_RULE[group];
20723
+ if (!rule || s < lastEnd) continue;
20724
+ spans.push({ rule, index: u16[s], length: u16[e] - u16[s], score });
20725
+ lastEnd = e;
20726
+ }
20727
+ return spans;
20728
+ },
20729
+ async release() {
20730
+ await o.session.release?.();
20731
+ }
20732
+ };
20733
+ }
20734
+ function decodeBioes(tags, conf, offsets, labels) {
20735
+ const spans = [];
20736
+ let open = null;
20737
+ tags.forEach((t, k) => {
20738
+ const [s, e] = offsets[k];
20739
+ if (t === 0 || e <= s) {
20740
+ open = null;
20741
+ return;
20742
+ }
20743
+ const dash = labels[t].indexOf("-");
20744
+ const pos = labels[t].slice(0, dash);
20745
+ const group = labels[t].slice(dash + 1);
20746
+ const p = conf[k];
20747
+ if (pos === "S") spans.push([s, e, group, p]);
20748
+ if (pos === "E" && open && open[1] === group) spans.push([open[0], e, group, Math.min(open[2], p)]);
20749
+ if (pos === "B") open = [s, group, p];
20750
+ else if (pos === "I" && open && open[1] === group) open = [open[0], group, Math.min(open[2], p)];
20751
+ else open = null;
20752
+ });
20753
+ return spans;
20754
+ }
20755
+ function utf16Index(text) {
20756
+ const idx = [0];
20757
+ let u = 0;
20758
+ for (const ch of text) {
20759
+ u += ch.length;
20760
+ idx.push(u);
20761
+ }
20762
+ return idx;
20763
+ }
20764
+ var WHITESPACE = /* @__PURE__ */ new Set([9, 10, 11, 12, 13, 32, 133, 160, 5760, 8232, 8233, 8239, 8287, 12288]);
20765
+ for (let c = 8192; c <= 8202; c++) WHITESPACE.add(c);
20766
+ var ASCII_PUNCT = new Set("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~");
20767
+ var isPunct = (ch) => ASCII_PUNCT.has(ch) || new RegExp("\\p{P}", "u").test(ch);
20768
+ var continuesCluster = (ch) => {
20769
+ const c = ch.codePointAt(0);
20770
+ return new RegExp("\\p{M}", "u").test(ch) || c >= 4448 && c <= 4607 || c >= 55216 && c <= 55295;
20771
+ };
20772
+ function normalizeNfc(chars, base) {
20773
+ const out = [];
20774
+ let i = 0;
20775
+ while (i < chars.length) {
20776
+ let j = i + 1;
20777
+ while (j < chars.length && continuesCluster(chars[j])) j++;
20778
+ const norm2 = Array.from(chars.slice(i, j).join("").normalize("NFC"));
20779
+ if (norm2.length === j - i) norm2.forEach((ch, k) => out.push({ ch, from: base + i + k, to: base + i + k + 1 }));
20780
+ else norm2.forEach((ch) => out.push({ ch, from: base + i, to: base + j }));
20781
+ i = j;
20782
+ }
20783
+ return out;
20784
+ }
20785
+ function createWordPiece(tj) {
20786
+ if (tj.model?.type !== "WordPiece") throw new Error(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uD1A0\uD06C\uB098\uC774\uC800 \uBAA8\uB378: ${tj.model?.type}`);
20787
+ const normType = tj.normalizer?.type ?? null;
20788
+ if (normType !== null && normType !== "NFC") throw new Error(`\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC815\uADDC\uD654: ${normType}`);
20789
+ const vocab = new Map(Object.entries(tj.model.vocab));
20790
+ const unk = vocab.get(tj.model.unk_token);
20791
+ if (unk === void 0) throw new Error("unk_token \uC774 vocab \uC5D0 \uC5C6\uC74C");
20792
+ const prefix = tj.model.continuing_subword_prefix ?? "##";
20793
+ const maxChars = tj.model.max_input_chars_per_word ?? 100;
20794
+ const special = (tj.added_tokens ?? []).filter((a) => a.special).map((a) => ({ id: a.id, content: Array.from(a.content) })).sort((a, b) => b.content.length - a.content.length);
20795
+ const tmpl = tj.post_processor?.special_tokens ?? {};
20796
+ const bos = tmpl["<s>"]?.ids?.[0];
20797
+ const eos = tmpl["</s>"]?.ids?.[0];
20798
+ if (bos === void 0 || eos === void 0) throw new Error("tokenizer post_processor \uC5D0 <s>\xB7</s> \uAC00 \uC5C6\uC74C");
20799
+ function wordpiece(word, out) {
20800
+ const from = word[0].from;
20801
+ const to = word[word.length - 1].to;
20802
+ if (word.length > maxChars) {
20803
+ out.ids.push(unk);
20804
+ out.offsets.push([from, to]);
20805
+ return;
20806
+ }
20807
+ const chars = word.map((w) => w.ch);
20808
+ const pieces = [];
20809
+ let start = 0;
20810
+ while (start < chars.length) {
20811
+ let end = chars.length;
20812
+ let id;
20813
+ while (start < end) {
20814
+ id = vocab.get((start > 0 ? prefix : "") + chars.slice(start, end).join(""));
20815
+ if (id !== void 0) break;
20816
+ end--;
20817
+ }
20818
+ if (id === void 0) {
20819
+ out.ids.push(unk);
20820
+ out.offsets.push([from, to]);
20821
+ return;
20822
+ }
20823
+ pieces.push([id, word[start].from, word[end - 1].to]);
20824
+ start = end;
20825
+ }
20826
+ for (const [id, s, e] of pieces) {
20827
+ out.ids.push(id);
20828
+ out.offsets.push([s, e]);
20829
+ }
20830
+ }
20831
+ function pretokenize(chars, out) {
20832
+ let word = [];
20833
+ const flush = () => {
20834
+ if (word.length) wordpiece(word, out);
20835
+ word = [];
20836
+ };
20837
+ for (const c of chars) {
20838
+ if (WHITESPACE.has(c.ch.codePointAt(0))) flush();
20839
+ else if (isPunct(c.ch)) {
20840
+ flush();
20841
+ wordpiece([c], out);
20842
+ } else word.push(c);
20843
+ }
20844
+ flush();
20845
+ }
20846
+ function encode(text) {
20847
+ const chars = Array.from(text);
20848
+ const out = { ids: [], offsets: [] };
20849
+ let seg = 0;
20850
+ let i = 0;
20851
+ while (i < chars.length) {
20852
+ const hit = special.find((s) => s.content.length <= chars.length - i && s.content.every((ch, k) => chars[i + k] === ch));
20853
+ if (hit) {
20854
+ pretokenize(normalizeNfc(chars.slice(seg, i), seg), out);
20855
+ out.ids.push(hit.id);
20856
+ out.offsets.push([i, i + hit.content.length]);
20857
+ i += hit.content.length;
20858
+ seg = i;
20859
+ } else i++;
20860
+ }
20861
+ pretokenize(normalizeNfc(chars.slice(seg), seg), out);
20862
+ return out;
20863
+ }
20864
+ return { encode, bos, eos };
20865
+ }
20866
+
20578
20867
  // src/roundtrip/session.ts
20579
20868
  import JSZip8 from "jszip";
20580
20869
  async function buildState(bytes) {
@@ -20933,7 +21222,7 @@ async function parse(input, options) {
20933
21222
  if (ocrOptionError) return { success: false, fileType: "unknown", error: ocrOptionError };
20934
21223
  if (typeof input === "string") {
20935
21224
  try {
20936
- const buf = await readFile2(input);
21225
+ const buf = await readFile3(input);
20937
21226
  buffer = toArrayBuffer(buf);
20938
21227
  } catch (err) {
20939
21228
  const msg = 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}`;
@@ -21053,8 +21342,8 @@ var MAX_MULTIPAGE_PIXELS = 1e9;
21053
21342
  var MIN_PAGE_PIXELS = 1e6;
21054
21343
  async function parseImage(buffer, options) {
21055
21344
  try {
21056
- const { parseImageDocument, imagePageCount, imagePage, imagePagePixels, decodeToRgba } = await import("./image-ocr-E3KNVXGP.js");
21057
- const pageRasters = options?.pageImages ? new (await import("./page-images-HZ2DRJGX.js")).PageImageSink(options.pageImages) : null;
21345
+ const { parseImageDocument, imagePageCount, imagePage, imagePagePixels, decodeToRgba } = await import("./image-ocr-MWQ6UDGP.js");
21346
+ const pageRasters = options?.pageImages ? new (await import("./page-images-MZECTCSJ.js")).PageImageSink(options.pageImages) : null;
21058
21347
  const pageCount = await imagePageCount(buffer);
21059
21348
  const wanted = pageCount > 1 && options?.pages ? parsePageRange(options.pages, pageCount) : null;
21060
21349
  const blocks = [], warnings = [], lines = [], images = [];
@@ -21161,7 +21450,7 @@ async function parseHwp(buffer, options) {
21161
21450
  async function parsePdf(buffer, options) {
21162
21451
  let parsePdfDocument;
21163
21452
  try {
21164
- const mod = await import("./parser-MAPRIHZS.js");
21453
+ const mod = await import("./parser-WAJNO5VU.js");
21165
21454
  parsePdfDocument = mod.parsePdfDocument;
21166
21455
  } catch (err) {
21167
21456
  return { success: false, fileType: "pdf", error: sanitizeError(err), code: classifyError(err) };
@@ -21223,7 +21512,7 @@ async function parseHwpml(buffer, options) {
21223
21512
  async function fillForm(input, values, outputFormat = "markdown") {
21224
21513
  let buffer;
21225
21514
  if (typeof input === "string") {
21226
- const buf = await readFile2(input);
21515
+ const buf = await readFile3(input);
21227
21516
  buffer = toArrayBuffer(buf);
21228
21517
  } else if (Buffer.isBuffer(input)) {
21229
21518
  buffer = toArrayBuffer(input);
@@ -21238,7 +21527,7 @@ async function fillForm(input, values, outputFormat = "markdown") {
21238
21527
  throw new Error(`hwpx-preserve \uD3EC\uB9F7\uC740 HWPX\xB7HWP 5.x \uC785\uB825\uB9CC \uC9C0\uC6D0\uD569\uB2C8\uB2E4 (\uAC10\uC9C0\uB41C \uD3EC\uB9F7: ${zipFormat})`);
21239
21528
  }
21240
21529
  } else if (format2 === "hwp" && detectOle2Format(buffer) === "hwp") {
21241
- const { hwpToHwpx: hwpToHwpx2 } = await import("./to-hwpx-ULUHUGBZ.js");
21530
+ const { hwpToHwpx: hwpToHwpx2 } = await import("./to-hwpx-OJNCWBXT.js");
21242
21531
  const hwpx = await hwpToHwpx2(new Uint8Array(buffer));
21243
21532
  buffer = hwpx.buffer.slice(hwpx.byteOffset, hwpx.byteOffset + hwpx.byteLength);
21244
21533
  } else {
@@ -21273,7 +21562,7 @@ function wantsCrop(kind, policy) {
21273
21562
  }
21274
21563
  async function extractTables(input, options = {}) {
21275
21564
  const policy = options.policy ?? "non-tabular-and-uncertain";
21276
- const buffer = typeof input === "string" ? toArrayBuffer(await readFile3(input)) : Buffer.isBuffer(input) ? toArrayBuffer(input) : input;
21565
+ const buffer = typeof input === "string" ? toArrayBuffer(await readFile4(input)) : Buffer.isBuffer(input) ? toArrayBuffer(input) : input;
21277
21566
  const parsed = await parse(buffer, { classifyTables: true, layoutTables: "keep" });
21278
21567
  if (!parsed.success) throw new KordocError(`\uD30C\uC2F1 \uC2E4\uD328: ${parsed.error}`);
21279
21568
  const blocks = collectTableBlocks(parsed.blocks);
@@ -21374,6 +21663,9 @@ export {
21374
21663
  runLintSuite,
21375
21664
  lintBlocks,
21376
21665
  validateHwpx,
21666
+ getPiiModelsDir,
21667
+ loadPiiModel,
21668
+ sharedPiiModel,
21377
21669
  HwpxSession,
21378
21670
  openHwpxDocument,
21379
21671
  patchHwpxBlocks,
@@ -21391,4 +21683,4 @@ export {
21391
21683
  parseHwpml,
21392
21684
  fillForm
21393
21685
  };
21394
- //# sourceMappingURL=chunk-M2V4WP7W.js.map
21686
+ //# sourceMappingURL=chunk-D2WQC6ME.js.map