@mlightcad/cad-pdf-plugin 1.8.0-preview.2 → 1.8.0-preview.4
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/LICENSE +21 -21
- package/README.md +280 -186
- package/dist/cad-pdf-plugin-register.js +29 -11
- package/dist/cad-pdf-plugin-register.umd.cjs +1 -1
- package/dist/cad-pdf-plugin.js +17568 -8428
- package/dist/cad-pdf-plugin.umd.cjs +847 -13
- package/lib/AcApConvertToPdfCmd.d.ts.map +1 -1
- package/lib/AcApConvertToPdfCmd.js +14 -3
- package/lib/AcApConvertToPdfCmd.js.map +1 -1
- package/lib/AcApImportPdfCmd.d.ts +5 -3
- package/lib/AcApImportPdfCmd.d.ts.map +1 -1
- package/lib/AcApImportPdfCmd.js +5 -3
- package/lib/AcApImportPdfCmd.js.map +1 -1
- package/lib/AcApImportPdfPromptCmd.d.ts +16 -0
- package/lib/AcApImportPdfPromptCmd.d.ts.map +1 -0
- package/lib/AcApImportPdfPromptCmd.js +89 -0
- package/lib/AcApImportPdfPromptCmd.js.map +1 -0
- package/lib/AcApPdfBlockCmd.d.ts +15 -0
- package/lib/AcApPdfBlockCmd.d.ts.map +1 -0
- package/lib/AcApPdfBlockCmd.js +75 -0
- package/lib/AcApPdfBlockCmd.js.map +1 -0
- package/lib/AcApPdfDimCmd.d.ts +20 -0
- package/lib/AcApPdfDimCmd.d.ts.map +1 -0
- package/lib/AcApPdfDimCmd.js +413 -0
- package/lib/AcApPdfDimCmd.js.map +1 -0
- package/lib/AcApPdfDimSession.d.ts +82 -0
- package/lib/AcApPdfDimSession.d.ts.map +1 -0
- package/lib/AcApPdfDimSession.js +252 -0
- package/lib/AcApPdfDimSession.js.map +1 -0
- package/lib/AcApPdfFontResolver.d.ts.map +1 -1
- package/lib/AcApPdfFontResolver.js +2 -5
- package/lib/AcApPdfFontResolver.js.map +1 -1
- package/lib/AcApPdfHatchCmd.d.ts +33 -0
- package/lib/AcApPdfHatchCmd.d.ts.map +1 -0
- package/lib/AcApPdfHatchCmd.js +411 -0
- package/lib/AcApPdfHatchCmd.js.map +1 -0
- package/lib/AcApPdfHatchSession.d.ts +122 -0
- package/lib/AcApPdfHatchSession.d.ts.map +1 -0
- package/lib/AcApPdfHatchSession.js +357 -0
- package/lib/AcApPdfHatchSession.js.map +1 -0
- package/lib/AcApPdfImportConvertor.d.ts +47 -5
- package/lib/AcApPdfImportConvertor.d.ts.map +1 -1
- package/lib/AcApPdfImportConvertor.js +999 -108
- package/lib/AcApPdfImportConvertor.js.map +1 -1
- package/lib/AcApPdfImportOptions.d.ts +116 -0
- package/lib/AcApPdfImportOptions.d.ts.map +1 -0
- package/lib/AcApPdfImportOptions.js +31 -0
- package/lib/AcApPdfImportOptions.js.map +1 -0
- package/lib/AcApPdfImportResources.d.ts +41 -0
- package/lib/AcApPdfImportResources.d.ts.map +1 -0
- package/lib/AcApPdfImportResources.js +52 -0
- package/lib/AcApPdfImportResources.js.map +1 -0
- package/lib/AcApPdfPlugin.d.ts +3 -3
- package/lib/AcApPdfPlugin.d.ts.map +1 -1
- package/lib/AcApPdfPlugin.js +23 -5
- package/lib/AcApPdfPlugin.js.map +1 -1
- package/lib/AcApPdfScaleCmd.d.ts +22 -0
- package/lib/AcApPdfScaleCmd.d.ts.map +1 -0
- package/lib/AcApPdfScaleCmd.js +185 -0
- package/lib/AcApPdfScaleCmd.js.map +1 -0
- package/lib/AcApPdfTextCmd.d.ts +73 -0
- package/lib/AcApPdfTextCmd.d.ts.map +1 -0
- package/lib/AcApPdfTextCmd.js +777 -0
- package/lib/AcApPdfTextCmd.js.map +1 -0
- package/lib/AcApPdfTextSession.d.ts +232 -0
- package/lib/AcApPdfTextSession.d.ts.map +1 -0
- package/lib/AcApPdfTextSession.js +826 -0
- package/lib/AcApPdfTextSession.js.map +1 -0
- package/lib/acapPdfI18n.d.ts +11 -0
- package/lib/acapPdfI18n.d.ts.map +1 -0
- package/lib/acapPdfI18n.js +57 -0
- package/lib/acapPdfI18n.js.map +1 -0
- package/lib/acapPdfPrompts.d.ts +12 -0
- package/lib/acapPdfPrompts.d.ts.map +1 -0
- package/lib/acapPdfPrompts.js +100 -0
- package/lib/acapPdfPrompts.js.map +1 -0
- package/lib/index.d.ts +28 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +28 -0
- package/lib/index.js.map +1 -1
- package/lib/pdfDeprecatedMatching.d.ts +27 -0
- package/lib/pdfDeprecatedMatching.d.ts.map +1 -0
- package/lib/pdfDeprecatedMatching.js +20 -0
- package/lib/pdfDeprecatedMatching.js.map +1 -0
- package/lib/pdfDimStrokeTexts.d.ts +55 -0
- package/lib/pdfDimStrokeTexts.d.ts.map +1 -0
- package/lib/pdfDimStrokeTexts.js +274 -0
- package/lib/pdfDimStrokeTexts.js.map +1 -0
- package/lib/pdfDimensionConvert.d.ts +80 -0
- package/lib/pdfDimensionConvert.d.ts.map +1 -0
- package/lib/pdfDimensionConvert.js +566 -0
- package/lib/pdfDimensionConvert.js.map +1 -0
- package/lib/pdfEntityStrokes.d.ts +13 -0
- package/lib/pdfEntityStrokes.d.ts.map +1 -0
- package/lib/pdfEntityStrokes.js +86 -0
- package/lib/pdfEntityStrokes.js.map +1 -0
- package/lib/pdfHatchRecover.d.ts +57 -0
- package/lib/pdfHatchRecover.d.ts.map +1 -0
- package/lib/pdfHatchRecover.js +315 -0
- package/lib/pdfHatchRecover.js.map +1 -0
- package/lib/pdfImportAppend.d.ts +24 -0
- package/lib/pdfImportAppend.d.ts.map +1 -0
- package/lib/pdfImportAppend.js +35 -0
- package/lib/pdfImportAppend.js.map +1 -0
- package/lib/pdfImportEntities.d.ts +63 -0
- package/lib/pdfImportEntities.d.ts.map +1 -0
- package/lib/pdfImportEntities.js +307 -0
- package/lib/pdfImportEntities.js.map +1 -0
- package/lib/pdfImportImages.d.ts +90 -0
- package/lib/pdfImportImages.d.ts.map +1 -0
- package/lib/pdfImportImages.js +294 -0
- package/lib/pdfImportImages.js.map +1 -0
- package/lib/pdfImportShapes.d.ts +63 -0
- package/lib/pdfImportShapes.d.ts.map +1 -0
- package/lib/pdfImportShapes.js +248 -0
- package/lib/pdfImportShapes.js.map +1 -0
- package/lib/pdfVectorImport.d.ts +218 -5
- package/lib/pdfVectorImport.d.ts.map +1 -1
- package/lib/pdfVectorImport.js +566 -98
- package/lib/pdfVectorImport.js.map +1 -1
- package/lib/recognition/pdfCurveRecognition.d.ts +91 -0
- package/lib/recognition/pdfCurveRecognition.d.ts.map +1 -0
- package/lib/recognition/pdfCurveRecognition.js +506 -0
- package/lib/recognition/pdfCurveRecognition.js.map +1 -0
- package/lib/recognition/pdfDimDigitRecognition.d.ts +18 -0
- package/lib/recognition/pdfDimDigitRecognition.d.ts.map +1 -0
- package/lib/recognition/pdfDimDigitRecognition.js +520 -0
- package/lib/recognition/pdfDimDigitRecognition.js.map +1 -0
- package/lib/recognition/pdfDimensionPattern.d.ts +173 -0
- package/lib/recognition/pdfDimensionPattern.d.ts.map +1 -0
- package/lib/recognition/pdfDimensionPattern.js +1023 -0
- package/lib/recognition/pdfDimensionPattern.js.map +1 -0
- package/lib/recognition/pdfFormBlocks.d.ts +58 -0
- package/lib/recognition/pdfFormBlocks.d.ts.map +1 -0
- package/lib/recognition/pdfFormBlocks.js +260 -0
- package/lib/recognition/pdfFormBlocks.js.map +1 -0
- package/lib/recognition/pdfGlyphClustering.d.ts +81 -0
- package/lib/recognition/pdfGlyphClustering.d.ts.map +1 -0
- package/lib/recognition/pdfGlyphClustering.js +1005 -0
- package/lib/recognition/pdfGlyphClustering.js.map +1 -0
- package/lib/recognition/pdfGlyphDictionary.d.ts +49 -0
- package/lib/recognition/pdfGlyphDictionary.d.ts.map +1 -0
- package/lib/recognition/pdfGlyphDictionary.js +188 -0
- package/lib/recognition/pdfGlyphDictionary.js.map +1 -0
- package/lib/recognition/pdfHatchFaces.d.ts +84 -0
- package/lib/recognition/pdfHatchFaces.d.ts.map +1 -0
- package/lib/recognition/pdfHatchFaces.js +1285 -0
- package/lib/recognition/pdfHatchFaces.js.map +1 -0
- package/lib/recognition/pdfHatchRecognition.d.ts +222 -0
- package/lib/recognition/pdfHatchRecognition.d.ts.map +1 -0
- package/lib/recognition/pdfHatchRecognition.js +3781 -0
- package/lib/recognition/pdfHatchRecognition.js.map +1 -0
- package/lib/recognition/pdfRecGeometry.d.ts +67 -0
- package/lib/recognition/pdfRecGeometry.d.ts.map +1 -0
- package/lib/recognition/pdfRecGeometry.js +365 -0
- package/lib/recognition/pdfRecGeometry.js.map +1 -0
- package/lib/recognition/pdfTextFontKind.d.ts +16 -0
- package/lib/recognition/pdfTextFontKind.d.ts.map +1 -0
- package/lib/recognition/pdfTextFontKind.js +51 -0
- package/lib/recognition/pdfTextFontKind.js.map +1 -0
- package/lib/recognition/pdfTextMerge.d.ts +71 -0
- package/lib/recognition/pdfTextMerge.d.ts.map +1 -0
- package/lib/recognition/pdfTextMerge.js +382 -0
- package/lib/recognition/pdfTextMerge.js.map +1 -0
- package/lib/recognition/pdfTextRunMerge.d.ts +28 -0
- package/lib/recognition/pdfTextRunMerge.d.ts.map +1 -0
- package/lib/recognition/pdfTextRunMerge.js +90 -0
- package/lib/recognition/pdfTextRunMerge.js.map +1 -0
- package/lib/register.d.ts +8 -2
- package/lib/register.d.ts.map +1 -1
- package/lib/register.js +29 -4
- package/lib/register.js.map +1 -1
- package/lib/ui/AcUiPdfDimPanel.d.ts +55 -0
- package/lib/ui/AcUiPdfDimPanel.d.ts.map +1 -0
- package/lib/ui/AcUiPdfDimPanel.js +347 -0
- package/lib/ui/AcUiPdfDimPanel.js.map +1 -0
- package/lib/ui/AcUiPdfHatchPanel.d.ts +57 -0
- package/lib/ui/AcUiPdfHatchPanel.d.ts.map +1 -0
- package/lib/ui/AcUiPdfHatchPanel.js +420 -0
- package/lib/ui/AcUiPdfHatchPanel.js.map +1 -0
- package/lib/ui/AcUiPdfImportDialog.d.ts +120 -0
- package/lib/ui/AcUiPdfImportDialog.d.ts.map +1 -0
- package/lib/ui/AcUiPdfImportDialog.js +673 -0
- package/lib/ui/AcUiPdfImportDialog.js.map +1 -0
- package/lib/ui/AcUiPdfTextPanel.d.ts +95 -0
- package/lib/ui/AcUiPdfTextPanel.d.ts.map +1 -0
- package/lib/ui/AcUiPdfTextPanel.js +775 -0
- package/lib/ui/AcUiPdfTextPanel.js.map +1 -0
- package/package.json +11 -11
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
27
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
+
function step(op) {
|
|
30
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
32
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
+
switch (op[0]) {
|
|
35
|
+
case 0: case 1: t = op; break;
|
|
36
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
+
default:
|
|
40
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
+
if (t[2]) _.ops.pop();
|
|
45
|
+
_.trys.pop(); continue;
|
|
46
|
+
}
|
|
47
|
+
op = body.call(thisArg, _);
|
|
48
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
53
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
54
|
+
if (!m) return o;
|
|
55
|
+
var i = m.call(o), r, ar = [], e;
|
|
56
|
+
try {
|
|
57
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
58
|
+
}
|
|
59
|
+
catch (error) { e = { error: error }; }
|
|
60
|
+
finally {
|
|
61
|
+
try {
|
|
62
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
63
|
+
}
|
|
64
|
+
finally { if (e) throw e.error; }
|
|
65
|
+
}
|
|
66
|
+
return ar;
|
|
67
|
+
};
|
|
68
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
69
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
70
|
+
if (ar || !(i in from)) {
|
|
71
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
72
|
+
ar[i] = from[i];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
76
|
+
};
|
|
77
|
+
var __values = (this && this.__values) || function(o) {
|
|
78
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
79
|
+
if (m) return m.call(o);
|
|
80
|
+
if (o && typeof o.length === "number") return {
|
|
81
|
+
next: function () {
|
|
82
|
+
if (o && i >= o.length) o = void 0;
|
|
83
|
+
return { value: o && o[i++], done: !o };
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
87
|
+
};
|
|
88
|
+
import { AcApDocManager, AcApI18n, AcApPaletteService, acapZoomToVisible, AcEdCommand, AcEdOpenMode, AcEdPromptPointOptions, AcEdPromptStatus, resolveSelectedEntities } from '@mlightcad/cad-simple-viewer';
|
|
89
|
+
import { AcApPdfHatchSession } from './AcApPdfHatchSession';
|
|
90
|
+
import { acapPdfT } from './acapPdfI18n';
|
|
91
|
+
import { acapPdfCreateRecoveredHatch, acapPdfHatchPatternLabel, acapPdfRecoverHatches, pdfEntitiesToHatchInput } from './pdfHatchRecover';
|
|
92
|
+
import { AcUiPdfHatchPanel } from './ui/AcUiPdfHatchPanel';
|
|
93
|
+
/** Delay before an edit redraws the preview (ms). */
|
|
94
|
+
var PREVIEW_DELAY = 120;
|
|
95
|
+
/** Space around a hatch framed during the review, as a share of its size. */
|
|
96
|
+
var FOCUS_MARGIN = 0.3;
|
|
97
|
+
/**
|
|
98
|
+
* `pdfhatch`: turns the loose strokes a PDF made of a pattern hatch back
|
|
99
|
+
* into hatch objects.
|
|
100
|
+
*
|
|
101
|
+
* 1. Select the strokes together with the lines around them (a crossing
|
|
102
|
+
* window over the hatched area is enough).
|
|
103
|
+
* 2. Strokes that form a regular pattern are matched against `acadiso.pat`,
|
|
104
|
+
* a user-defined single or crossed pattern, or else measured as a custom
|
|
105
|
+
* pattern. The boundary comes from closed shapes in the selection or the
|
|
106
|
+
* faces the selected line work encloses.
|
|
107
|
+
* 3. A review panel opens in the palette with the hatches previewed in
|
|
108
|
+
* place of their strokes. Per hatch the user includes or skips it,
|
|
109
|
+
* changes its pattern, scale and angle (each change is refitted to the
|
|
110
|
+
* strokes and scored), and areas the recognition missed are added by
|
|
111
|
+
* picking a point inside them. Apply converts in one step; Cancel, or
|
|
112
|
+
* closing the palette, changes nothing. Without a DOM, every hatch found
|
|
113
|
+
* is converted directly.
|
|
114
|
+
*
|
|
115
|
+
* A hatch only replaces the entities it re-draws completely.
|
|
116
|
+
*/
|
|
117
|
+
var AcApPdfHatchCmd = /** @class */ (function (_super) {
|
|
118
|
+
__extends(AcApPdfHatchCmd, _super);
|
|
119
|
+
function AcApPdfHatchCmd() {
|
|
120
|
+
var _this = _super.call(this) || this;
|
|
121
|
+
_this.mode = AcEdOpenMode.Write;
|
|
122
|
+
return _this;
|
|
123
|
+
}
|
|
124
|
+
AcApPdfHatchCmd.prototype.execute = function (context) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
126
|
+
var resolved, entityById, input, recovery, session, interactive, apply, db, created, erased;
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
switch (_a.label) {
|
|
129
|
+
case 0: return [4 /*yield*/, resolveSelectedEntities(context, {
|
|
130
|
+
promptKey: 'pdfhatch'
|
|
131
|
+
})];
|
|
132
|
+
case 1:
|
|
133
|
+
resolved = _a.sent();
|
|
134
|
+
if (!resolved)
|
|
135
|
+
return [2 /*return*/];
|
|
136
|
+
context.view.selectionSet.clear();
|
|
137
|
+
entityById = new Map();
|
|
138
|
+
resolved.entities.forEach(function (entity, i) {
|
|
139
|
+
return entityById.set(resolved.ids[i], entity);
|
|
140
|
+
});
|
|
141
|
+
input = pdfEntitiesToHatchInput(entityById);
|
|
142
|
+
recovery = acapPdfRecoverHatches(input);
|
|
143
|
+
session = new AcApPdfHatchSession({
|
|
144
|
+
input: input,
|
|
145
|
+
tolerance: recovery.tolerance,
|
|
146
|
+
hatches: recovery.hatches.map(function (found) { return found.hatch; })
|
|
147
|
+
});
|
|
148
|
+
interactive = typeof document !== 'undefined';
|
|
149
|
+
if (session.rows.length === 0 && !interactive) {
|
|
150
|
+
this.notify(AcApI18n.t('jig.pdfhatch.noHatches'), 'warning');
|
|
151
|
+
return [2 /*return*/];
|
|
152
|
+
}
|
|
153
|
+
if (!interactive) return [3 /*break*/, 3];
|
|
154
|
+
if (session.rows.length === 0) {
|
|
155
|
+
this.notify(AcApI18n.t('jig.pdfhatch.noHatches'), 'warning');
|
|
156
|
+
}
|
|
157
|
+
return [4 /*yield*/, this.review(context, session, entityById)];
|
|
158
|
+
case 2:
|
|
159
|
+
apply = _a.sent();
|
|
160
|
+
if (!apply) {
|
|
161
|
+
this.notify(acapPdfT('jig.pdfhatch.cancelled'));
|
|
162
|
+
return [2 /*return*/];
|
|
163
|
+
}
|
|
164
|
+
_a.label = 3;
|
|
165
|
+
case 3:
|
|
166
|
+
db = context.doc.database;
|
|
167
|
+
created = session.readyRows.flatMap(function (row) {
|
|
168
|
+
var entity = createEntity(db, session, row, entityById);
|
|
169
|
+
return entity ? [{ row: row, entity: entity }] : [];
|
|
170
|
+
});
|
|
171
|
+
if (created.length === 0)
|
|
172
|
+
return [2 /*return*/];
|
|
173
|
+
db.tables.blockTable.modelSpace.appendEntity(created.map(function (item) { return item.entity; }));
|
|
174
|
+
erased = __spreadArray([], __read(new Set(created.flatMap(function (item) { return item.row.consumed; }))), false);
|
|
175
|
+
context.doc.entityService.eraseEntities(erased);
|
|
176
|
+
this.notify(acapPdfT('jig.pdfhatch.summary', {
|
|
177
|
+
count: created.length,
|
|
178
|
+
patterns: patternList(created.map(function (item) { return item.row; })),
|
|
179
|
+
strokes: erased.length
|
|
180
|
+
}));
|
|
181
|
+
return [2 /*return*/];
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
/**
|
|
187
|
+
* Shows the review panel in the palette and previews the hatches in the
|
|
188
|
+
* drawing until the user applies or cancels.
|
|
189
|
+
*
|
|
190
|
+
* @returns Whether the user applied.
|
|
191
|
+
*/
|
|
192
|
+
AcApPdfHatchCmd.prototype.review = function (context, session, entityById) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
194
|
+
var view, db, previews, hidden, hideStrokes, focused, timer, clearPreview, updateVisibility, refreshPreview, schedulePreview, focus, addRegion, finish, result, panel, handle;
|
|
195
|
+
var _this = this;
|
|
196
|
+
return __generator(this, function (_a) {
|
|
197
|
+
switch (_a.label) {
|
|
198
|
+
case 0:
|
|
199
|
+
view = context.view;
|
|
200
|
+
db = context.doc.database;
|
|
201
|
+
previews = [];
|
|
202
|
+
hidden = new Set();
|
|
203
|
+
hideStrokes = true;
|
|
204
|
+
focused = [];
|
|
205
|
+
clearPreview = function () {
|
|
206
|
+
var e_1, _a;
|
|
207
|
+
try {
|
|
208
|
+
for (var previews_1 = __values(previews), previews_1_1 = previews_1.next(); !previews_1_1.done; previews_1_1 = previews_1.next()) {
|
|
209
|
+
var entity = previews_1_1.value;
|
|
210
|
+
view.removeTransientEntity(entity.objectId);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
214
|
+
finally {
|
|
215
|
+
try {
|
|
216
|
+
if (previews_1_1 && !previews_1_1.done && (_a = previews_1.return)) _a.call(previews_1);
|
|
217
|
+
}
|
|
218
|
+
finally { if (e_1) throw e_1.error; }
|
|
219
|
+
}
|
|
220
|
+
previews = [];
|
|
221
|
+
};
|
|
222
|
+
updateVisibility = function () {
|
|
223
|
+
var e_2, _a, e_3, _b, e_4, _c;
|
|
224
|
+
var show = new Set(focused);
|
|
225
|
+
var want = new Set();
|
|
226
|
+
if (hideStrokes) {
|
|
227
|
+
try {
|
|
228
|
+
for (var _d = __values(session.erasedIds), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
229
|
+
var id = _e.value;
|
|
230
|
+
if (!show.has(id))
|
|
231
|
+
want.add(id);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
235
|
+
finally {
|
|
236
|
+
try {
|
|
237
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
238
|
+
}
|
|
239
|
+
finally { if (e_2) throw e_2.error; }
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
try {
|
|
243
|
+
for (var _f = __values(__spreadArray([], __read(hidden), false)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
244
|
+
var id = _g.value;
|
|
245
|
+
if (want.has(id))
|
|
246
|
+
continue;
|
|
247
|
+
view.setEntitySceneVisible(id, true);
|
|
248
|
+
hidden.delete(id);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
252
|
+
finally {
|
|
253
|
+
try {
|
|
254
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
255
|
+
}
|
|
256
|
+
finally { if (e_3) throw e_3.error; }
|
|
257
|
+
}
|
|
258
|
+
try {
|
|
259
|
+
for (var want_1 = __values(want), want_1_1 = want_1.next(); !want_1_1.done; want_1_1 = want_1.next()) {
|
|
260
|
+
var id = want_1_1.value;
|
|
261
|
+
if (hidden.has(id))
|
|
262
|
+
continue;
|
|
263
|
+
view.setEntitySceneVisible(id, false);
|
|
264
|
+
hidden.add(id);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
268
|
+
finally {
|
|
269
|
+
try {
|
|
270
|
+
if (want_1_1 && !want_1_1.done && (_c = want_1.return)) _c.call(want_1);
|
|
271
|
+
}
|
|
272
|
+
finally { if (e_4) throw e_4.error; }
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
refreshPreview = function () {
|
|
276
|
+
clearPreview();
|
|
277
|
+
previews = session.readyRows
|
|
278
|
+
.map(function (row) { return createEntity(db, session, row, entityById); })
|
|
279
|
+
.filter(function (entity) { return !!entity; });
|
|
280
|
+
if (previews.length > 0)
|
|
281
|
+
view.addTransientEntity(previews);
|
|
282
|
+
updateVisibility();
|
|
283
|
+
};
|
|
284
|
+
schedulePreview = function () {
|
|
285
|
+
if (timer)
|
|
286
|
+
clearTimeout(timer);
|
|
287
|
+
timer = setTimeout(function () {
|
|
288
|
+
timer = undefined;
|
|
289
|
+
refreshPreview();
|
|
290
|
+
}, PREVIEW_DELAY);
|
|
291
|
+
};
|
|
292
|
+
focus = function (row, zoom) {
|
|
293
|
+
var _a;
|
|
294
|
+
if (focused.length > 0)
|
|
295
|
+
view.unhighlight(focused);
|
|
296
|
+
focused = row ? __spreadArray([], __read(row.consumed), false) : [];
|
|
297
|
+
updateVisibility();
|
|
298
|
+
if (focused.length > 0)
|
|
299
|
+
view.highlight(focused);
|
|
300
|
+
if (!row || !zoom)
|
|
301
|
+
return;
|
|
302
|
+
var box = (_a = createEntity(db, session, row, entityById)) === null || _a === void 0 ? void 0 : _a.geometricExtents;
|
|
303
|
+
if (box && Number.isFinite(box.min.x)) {
|
|
304
|
+
acapZoomToVisible(view, box, FOCUS_MARGIN, handle.coveredInsets(view.canvas));
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
addRegion = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
308
|
+
var prompt, result, _a;
|
|
309
|
+
return __generator(this, function (_b) {
|
|
310
|
+
switch (_b.label) {
|
|
311
|
+
case 0:
|
|
312
|
+
prompt = new AcEdPromptPointOptions(acapPdfT('jig.pdfhatch.pickPoint'));
|
|
313
|
+
_b.label = 1;
|
|
314
|
+
case 1:
|
|
315
|
+
_b.trys.push([1, 3, , 4]);
|
|
316
|
+
return [4 /*yield*/, AcApDocManager.instance.editor.getPoint(prompt)];
|
|
317
|
+
case 2:
|
|
318
|
+
result = _b.sent();
|
|
319
|
+
return [3 /*break*/, 4];
|
|
320
|
+
case 3:
|
|
321
|
+
_a = _b.sent();
|
|
322
|
+
// An aborted or invalid input ends the pick, not the review.
|
|
323
|
+
return [2 /*return*/, 'cancelled'];
|
|
324
|
+
case 4:
|
|
325
|
+
if (result.status !== AcEdPromptStatus.OK || !result.value) {
|
|
326
|
+
return [2 /*return*/, 'cancelled'];
|
|
327
|
+
}
|
|
328
|
+
return [2 /*return*/, session.addRegion({ x: result.value.x, y: result.value.y })];
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}); };
|
|
332
|
+
finish = function () { };
|
|
333
|
+
result = new Promise(function (resolve) {
|
|
334
|
+
finish = resolve;
|
|
335
|
+
});
|
|
336
|
+
panel = new AcUiPdfHatchPanel({
|
|
337
|
+
session: session,
|
|
338
|
+
hideStrokes: hideStrokes,
|
|
339
|
+
onChange: schedulePreview,
|
|
340
|
+
onFocusRow: focus,
|
|
341
|
+
onHideStrokes: function (hide) {
|
|
342
|
+
hideStrokes = hide;
|
|
343
|
+
updateVisibility();
|
|
344
|
+
},
|
|
345
|
+
onAddRegion: addRegion,
|
|
346
|
+
onClose: function (apply) { return finish(apply); }
|
|
347
|
+
});
|
|
348
|
+
handle = AcApPaletteService.open({
|
|
349
|
+
id: 'pdfhatch',
|
|
350
|
+
title: acapPdfT('jig.pdfhatch.panel.title'),
|
|
351
|
+
element: panel.element
|
|
352
|
+
}, { container: view.container });
|
|
353
|
+
handle.onClosed(function () { return finish(false); });
|
|
354
|
+
_a.label = 1;
|
|
355
|
+
case 1:
|
|
356
|
+
_a.trys.push([1, , 3, 4]);
|
|
357
|
+
refreshPreview();
|
|
358
|
+
panel.selectFirst();
|
|
359
|
+
return [4 /*yield*/, result];
|
|
360
|
+
case 2: return [2 /*return*/, _a.sent()];
|
|
361
|
+
case 3:
|
|
362
|
+
if (timer)
|
|
363
|
+
clearTimeout(timer);
|
|
364
|
+
clearPreview();
|
|
365
|
+
if (focused.length > 0)
|
|
366
|
+
view.unhighlight(focused);
|
|
367
|
+
focused = [];
|
|
368
|
+
hideStrokes = false;
|
|
369
|
+
updateVisibility();
|
|
370
|
+
handle.close();
|
|
371
|
+
panel.destroy();
|
|
372
|
+
return [7 /*endfinally*/];
|
|
373
|
+
case 4: return [2 /*return*/];
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
};
|
|
378
|
+
return AcApPdfHatchCmd;
|
|
379
|
+
}(AcEdCommand));
|
|
380
|
+
export { AcApPdfHatchCmd };
|
|
381
|
+
/** The hatch entity of a row, on the layer and in the colour of its strokes. */
|
|
382
|
+
function createEntity(db, session, row, entityById) {
|
|
383
|
+
var source = session.sourceOf(row);
|
|
384
|
+
return acapPdfCreateRecoveredHatch(db, row.hatch, source === undefined ? undefined : entityById.get(source));
|
|
385
|
+
}
|
|
386
|
+
/** `ANSI31 ×2, AR-B816` for the summary. */
|
|
387
|
+
function patternList(rows) {
|
|
388
|
+
var e_5, _a;
|
|
389
|
+
var _b;
|
|
390
|
+
var counts = new Map();
|
|
391
|
+
try {
|
|
392
|
+
for (var rows_1 = __values(rows), rows_1_1 = rows_1.next(); !rows_1_1.done; rows_1_1 = rows_1.next()) {
|
|
393
|
+
var row = rows_1_1.value;
|
|
394
|
+
var label = acapPdfHatchPatternLabel(row.hatch);
|
|
395
|
+
counts.set(label, ((_b = counts.get(label)) !== null && _b !== void 0 ? _b : 0) + 1);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
399
|
+
finally {
|
|
400
|
+
try {
|
|
401
|
+
if (rows_1_1 && !rows_1_1.done && (_a = rows_1.return)) _a.call(rows_1);
|
|
402
|
+
}
|
|
403
|
+
finally { if (e_5) throw e_5.error; }
|
|
404
|
+
}
|
|
405
|
+
return __spreadArray([], __read(counts.entries()), false).map(function (_a) {
|
|
406
|
+
var _b = __read(_a, 2), label = _b[0], count = _b[1];
|
|
407
|
+
return (count > 1 ? "".concat(label, " \u00D7").concat(count) : label);
|
|
408
|
+
})
|
|
409
|
+
.join(', ');
|
|
410
|
+
}
|
|
411
|
+
//# sourceMappingURL=AcApPdfHatchCmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApPdfHatchCmd.js","sourceRoot":"","sources":["../src/AcApPdfHatchCmd.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAEL,cAAc,EACd,QAAQ,EACR,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,sBAAsB,EACtB,gBAAgB,EAChB,uBAAuB,EACxB,MAAM,8BAA8B,CAAA;AAQrC,OAAO,EAAE,mBAAmB,EAAoB,MAAM,uBAAuB,CAAA;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;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AK,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QACjD,CAAC;;;;;;;;;IACD,OAAO,yBAAI,MAAM,CAAC,OAAO,EAAE,UACxB,GAAG,CAAC,UAAC,EAAc;YAAd,KAAA,aAAc,EAAb,KAAK,QAAA,EAAE,KAAK,QAAA;QAAM,OAAA,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,UAAG,KAAK,oBAAK,KAAK,CAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IAA1C,CAA0C,CAAC;SACnE,IAAI,CAAC,IAAI,CAAC,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { PdfHatchInput } from './pdfHatchRecover';
|
|
2
|
+
import type { PdfRecognizedShape } from './recognition/pdfCurveRecognition';
|
|
3
|
+
import { type PdfHatchMatch, type PdfRecognizedHatch } from './recognition/pdfHatchRecognition';
|
|
4
|
+
import type { PdfRecPoint } from './recognition/pdfRecGeometry';
|
|
5
|
+
/** Lowest precision of a hatch shown as a good match. */
|
|
6
|
+
export declare const PDF_HATCH_GOOD_PRECISION = 0.95;
|
|
7
|
+
/** Lowest recall of a hatch shown as a good match. */
|
|
8
|
+
export declare const PDF_HATCH_GOOD_RECALL = 0.9;
|
|
9
|
+
/**
|
|
10
|
+
* Pattern choice of a row: `predefined:<name>` for a library pattern,
|
|
11
|
+
* `user` / `user2` for single / crossed user-defined lines, `custom` for the
|
|
12
|
+
* pattern the recognition measured.
|
|
13
|
+
*/
|
|
14
|
+
export type PdfHatchPatternKey = string;
|
|
15
|
+
/** Key of single user-defined lines. */
|
|
16
|
+
export declare const PDF_HATCH_USER_KEY = "user";
|
|
17
|
+
/** Key of crossed user-defined lines. */
|
|
18
|
+
export declare const PDF_HATCH_USER_DOUBLE_KEY = "user2";
|
|
19
|
+
/** Key of the measured custom pattern. */
|
|
20
|
+
export declare const PDF_HATCH_CUSTOM_KEY = "custom";
|
|
21
|
+
/** One hatch under review. */
|
|
22
|
+
export interface PdfHatchRow<Id> {
|
|
23
|
+
/** Stable id for the UI (rows are never reordered, only appended). */
|
|
24
|
+
readonly key: number;
|
|
25
|
+
hatch: PdfRecognizedHatch;
|
|
26
|
+
/** How well {@link hatch} re-draws the strokes inside its boundary. */
|
|
27
|
+
match: PdfHatchMatch;
|
|
28
|
+
/** Whether the hatch is created on Apply. */
|
|
29
|
+
included: boolean;
|
|
30
|
+
/** Entities every item of which the hatch re-draws (erased on Apply). */
|
|
31
|
+
consumed: Id[];
|
|
32
|
+
/** The strokes showed no trace of the chosen pattern (placed by guess). */
|
|
33
|
+
guessed: boolean;
|
|
34
|
+
/** The hatch as first found; a custom pattern can only be restored. */
|
|
35
|
+
readonly original: PdfRecognizedHatch;
|
|
36
|
+
/** Added by the user from a picked point. */
|
|
37
|
+
readonly added: boolean;
|
|
38
|
+
}
|
|
39
|
+
/** Size and angle of a row's pattern, for editing. */
|
|
40
|
+
export interface PdfHatchParams {
|
|
41
|
+
/** Pattern scale (library) or line spacing (user-defined). */
|
|
42
|
+
size: number;
|
|
43
|
+
/** Angle in degrees. */
|
|
44
|
+
angle: number;
|
|
45
|
+
}
|
|
46
|
+
/** Input of {@link AcApPdfHatchSession}. */
|
|
47
|
+
export interface AcApPdfHatchSessionInput<Id> {
|
|
48
|
+
input: PdfHatchInput<Id>;
|
|
49
|
+
/** Tolerance the hatches were recognized with. */
|
|
50
|
+
tolerance: number;
|
|
51
|
+
/** Recognized hatches (their `items` index `input.items`). */
|
|
52
|
+
hatches: PdfRecognizedHatch[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* State of a `pdfhatch` review: the recovered hatches, which of them to
|
|
56
|
+
* create, and their patterns. UI-free, so the panel stays a thin view.
|
|
57
|
+
*
|
|
58
|
+
* Every change of pattern or size refits the hatch to the strokes and
|
|
59
|
+
* scores it again; a hatch only replaces the entities it re-draws
|
|
60
|
+
* completely, so a poor choice leaves strokes in place instead of losing
|
|
61
|
+
* them.
|
|
62
|
+
*/
|
|
63
|
+
export declare class AcApPdfHatchSession<Id> {
|
|
64
|
+
readonly rows: PdfHatchRow<Id>[];
|
|
65
|
+
readonly tolerance: number;
|
|
66
|
+
private readonly input;
|
|
67
|
+
/** Items per entity, to tell whether a hatch re-draws all of one. */
|
|
68
|
+
private readonly itemCount;
|
|
69
|
+
private nextKey;
|
|
70
|
+
constructor(options: AcApPdfHatchSessionInput<Id>);
|
|
71
|
+
/** Rows created on Apply. */
|
|
72
|
+
get readyRows(): PdfHatchRow<Id>[];
|
|
73
|
+
/** Entities erased on Apply, each once. */
|
|
74
|
+
get erasedIds(): Id[];
|
|
75
|
+
/** Every entity some row may replace (hidden while previewing). */
|
|
76
|
+
get strokeIds(): Id[];
|
|
77
|
+
/** Whether a row re-draws its strokes well enough to trust it. */
|
|
78
|
+
isGood(row: PdfHatchRow<Id>): boolean;
|
|
79
|
+
/** Entity whose layer and colour the hatch of `row` takes. */
|
|
80
|
+
sourceOf(row: PdfHatchRow<Id>): Id | undefined;
|
|
81
|
+
setIncluded(row: PdfHatchRow<Id>, included: boolean): void;
|
|
82
|
+
/** Pattern choices for `row`, in display order. */
|
|
83
|
+
patternKeys(row: PdfHatchRow<Id>): PdfHatchPatternKey[];
|
|
84
|
+
/** Current pattern choice of `row`. */
|
|
85
|
+
patternKey(row: PdfHatchRow<Id>): PdfHatchPatternKey;
|
|
86
|
+
/** Size and angle, or `undefined` for a measured custom pattern. */
|
|
87
|
+
params(row: PdfHatchRow<Id>): PdfHatchParams | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Switches `row` to another pattern and measures its size and angle on
|
|
90
|
+
* the strokes.
|
|
91
|
+
*
|
|
92
|
+
* @returns Whether the row changed.
|
|
93
|
+
*/
|
|
94
|
+
setPattern(row: PdfHatchRow<Id>, key: PdfHatchPatternKey): boolean;
|
|
95
|
+
/**
|
|
96
|
+
* Places the row's pattern at the given size and angle (only the origin
|
|
97
|
+
* is searched).
|
|
98
|
+
*
|
|
99
|
+
* @returns Whether the row changed.
|
|
100
|
+
*/
|
|
101
|
+
setParams(row: PdfHatchRow<Id>, params: PdfHatchParams): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Measures size and angle of the row's pattern again (after manual
|
|
104
|
+
* edits); a custom pattern returns to what the recognition measured.
|
|
105
|
+
*/
|
|
106
|
+
autoFit(row: PdfHatchRow<Id>): boolean;
|
|
107
|
+
/**
|
|
108
|
+
* Adds a hatch for the closed area around `point`: the best fitting
|
|
109
|
+
* pattern for the strokes inside it.
|
|
110
|
+
*
|
|
111
|
+
* @returns The new row, `'noBoundary'` when no closed area holds the
|
|
112
|
+
* point, or `'noStrokes'` when no pattern explains strokes inside it.
|
|
113
|
+
*/
|
|
114
|
+
addRegion(point: PdfRecPoint): PdfHatchRow<Id> | 'noBoundary' | 'noStrokes';
|
|
115
|
+
/** Boundary shapes of `row` (for framing it in the drawing). */
|
|
116
|
+
boundaryOf(row: PdfHatchRow<Id>): readonly PdfRecognizedShape[];
|
|
117
|
+
private refit;
|
|
118
|
+
private restore;
|
|
119
|
+
/** Entities all of whose items are among `items`. */
|
|
120
|
+
private consumedBy;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=AcApPdfHatchSession.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApPdfHatchSession.d.ts","sourceRoot":"","sources":["../src/AcApPdfHatchSession.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA;AAC3E,OAAO,EAIL,KAAK,aAAa,EAElB,KAAK,kBAAkB,EACxB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAE/D,yDAAyD;AACzD,eAAO,MAAM,wBAAwB,OAAO,CAAA;AAC5C,sDAAsD;AACtD,eAAO,MAAM,qBAAqB,M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