@claritylabs/cl-sdk 3.1.12 → 3.1.14
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.js +62 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11256,7 +11256,8 @@ function appendDistinctText(base, addition) {
|
|
|
11256
11256
|
if (!current) return next || void 0;
|
|
11257
11257
|
if (!next) return current;
|
|
11258
11258
|
if (current.toLowerCase().includes(next.toLowerCase())) return current;
|
|
11259
|
-
const
|
|
11259
|
+
const joinsWithSpace = /(?:[/(:;-]|,\s*)$/.test(current) || /\b(?:part of|including|subject to|not in addition to)$/i.test(current) || /^(?:aggregate|claim|loss|proceeding|occurrence|each\s+(?:claim|loss|proceeding|occurrence)|coverage\s+part\b)/i.test(next);
|
|
11260
|
+
const delimiter = joinsWithSpace ? " " : " / ";
|
|
11260
11261
|
return cleanText(`${current}${delimiter}${next}`, current);
|
|
11261
11262
|
}
|
|
11262
11263
|
function mergedBbox(nodes) {
|
|
@@ -11285,6 +11286,23 @@ function findCellForContinuation(params) {
|
|
|
11285
11286
|
}
|
|
11286
11287
|
return params.cells[1] ?? params.cells[params.cells.length - 1];
|
|
11287
11288
|
}
|
|
11289
|
+
function bboxCenterX(node) {
|
|
11290
|
+
const box = node.bbox?.[0];
|
|
11291
|
+
if (!box) return void 0;
|
|
11292
|
+
return box.x + box.width / 2;
|
|
11293
|
+
}
|
|
11294
|
+
function findCellByVisualPosition(sourceCell, targetCells) {
|
|
11295
|
+
const sourceX = bboxCenterX(sourceCell);
|
|
11296
|
+
if (sourceX === void 0) return void 0;
|
|
11297
|
+
const positioned = targetCells.map((cell) => ({ cell, centerX: bboxCenterX(cell) })).filter(
|
|
11298
|
+
(entry) => entry.centerX !== void 0
|
|
11299
|
+
);
|
|
11300
|
+
if (positioned.length === 0) return void 0;
|
|
11301
|
+
positioned.sort(
|
|
11302
|
+
(left, right) => Math.abs(left.centerX - sourceX) - Math.abs(right.centerX - sourceX)
|
|
11303
|
+
);
|
|
11304
|
+
return positioned[0]?.cell;
|
|
11305
|
+
}
|
|
11288
11306
|
function columnLabelStartIndex(rows) {
|
|
11289
11307
|
const headerIndex = rows.findIndex(
|
|
11290
11308
|
({ row, cells }) => isSourceTreeHeaderRow(row) && cells.length > 1
|
|
@@ -11436,7 +11454,41 @@ function applyVisualTableRepair(sourceTree, repair) {
|
|
|
11436
11454
|
});
|
|
11437
11455
|
const sourceNodes = [sourceRow, ...sourceCells];
|
|
11438
11456
|
const sourceSpanIds = sourceSpanIdsForNodes(sourceNodes);
|
|
11439
|
-
|
|
11457
|
+
let mergedIntoCells = false;
|
|
11458
|
+
if (sourceCells.length > 0 && targetCells.length > 0) {
|
|
11459
|
+
for (const sourceCell of sourceCells) {
|
|
11460
|
+
const cellText = tableCellValueText(sourceCell);
|
|
11461
|
+
if (!cellText) continue;
|
|
11462
|
+
const visualTargetCell = findCellByVisualPosition(sourceCell, targetCells) ?? targetCell;
|
|
11463
|
+
if (!visualTargetCell) continue;
|
|
11464
|
+
const currentTargetCell = currentNode(visualTargetCell.id) ?? visualTargetCell;
|
|
11465
|
+
const nextCellText = appendDistinctText(tableCellText(currentTargetCell), cellText);
|
|
11466
|
+
if (!nextCellText) continue;
|
|
11467
|
+
updates.set(visualTargetCell.id, {
|
|
11468
|
+
...currentTargetCell,
|
|
11469
|
+
textExcerpt: nextCellText,
|
|
11470
|
+
description: cleanText(
|
|
11471
|
+
[currentTargetCell.title, nextCellText].filter(Boolean).join(" | "),
|
|
11472
|
+
currentTargetCell.description
|
|
11473
|
+
),
|
|
11474
|
+
sourceSpanIds: [
|
|
11475
|
+
.../* @__PURE__ */ new Set([
|
|
11476
|
+
...currentTargetCell.sourceSpanIds,
|
|
11477
|
+
...sourceRow.sourceSpanIds,
|
|
11478
|
+
...sourceCell.sourceSpanIds
|
|
11479
|
+
])
|
|
11480
|
+
],
|
|
11481
|
+
bbox: mergedBbox([currentTargetCell, sourceCell]),
|
|
11482
|
+
metadata: {
|
|
11483
|
+
...currentTargetCell.metadata ?? {},
|
|
11484
|
+
visualTableRepair: "merged_continuation"
|
|
11485
|
+
}
|
|
11486
|
+
});
|
|
11487
|
+
mergedIntoCells = true;
|
|
11488
|
+
}
|
|
11489
|
+
if (mergedIntoCells) rowsToRebuildText.add(targetRow.id);
|
|
11490
|
+
}
|
|
11491
|
+
if (!mergedIntoCells && targetCell) {
|
|
11440
11492
|
const nextCellText = appendDistinctText(tableCellText(targetCell), sourceText);
|
|
11441
11493
|
if (nextCellText) {
|
|
11442
11494
|
const mergedNodes = [targetCell, ...sourceNodes];
|
|
@@ -11454,11 +11506,16 @@ function applyVisualTableRepair(sourceTree, repair) {
|
|
|
11454
11506
|
rowsToRebuildText.add(targetRow.id);
|
|
11455
11507
|
}
|
|
11456
11508
|
}
|
|
11457
|
-
const
|
|
11509
|
+
const fallbackRowText = mergedIntoCells ? void 0 : appendDistinctText(targetRow.textExcerpt ?? targetRow.description, sourceText);
|
|
11458
11510
|
updates.set(targetRow.id, {
|
|
11459
11511
|
...currentNode(targetRow.id) ?? targetRow,
|
|
11460
|
-
|
|
11461
|
-
|
|
11512
|
+
...mergedIntoCells ? {} : {
|
|
11513
|
+
textExcerpt: fallbackRowText,
|
|
11514
|
+
description: cleanText(
|
|
11515
|
+
[targetRow.title, fallbackRowText].filter(Boolean).join(" | "),
|
|
11516
|
+
targetRow.description
|
|
11517
|
+
)
|
|
11518
|
+
},
|
|
11462
11519
|
sourceSpanIds: [.../* @__PURE__ */ new Set([...targetRow.sourceSpanIds, ...sourceSpanIds])],
|
|
11463
11520
|
bbox: mergedBbox([targetRow, ...sourceNodes]),
|
|
11464
11521
|
metadata: {
|