@mlightcad/data-model 1.7.27 → 1.7.29

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 (87) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +224 -224
  3. package/dist/data-model.cjs +4 -3
  4. package/dist/data-model.js +6601 -3480
  5. package/dist/dxf-parser-worker.js +1023 -740
  6. package/lib/converter/AcDbDxfConverter.d.ts +1 -0
  7. package/lib/converter/AcDbDxfConverter.d.ts.map +1 -1
  8. package/lib/converter/AcDbDxfConverter.js +48 -1
  9. package/lib/converter/AcDbDxfConverter.js.map +1 -1
  10. package/lib/converter/AcDbEntitiyConverter.d.ts +12 -0
  11. package/lib/converter/AcDbEntitiyConverter.d.ts.map +1 -1
  12. package/lib/converter/AcDbEntitiyConverter.js +528 -3
  13. package/lib/converter/AcDbEntitiyConverter.js.map +1 -1
  14. package/lib/converter/AcDbObjectConverter.d.ts +10 -3
  15. package/lib/converter/AcDbObjectConverter.d.ts.map +1 -1
  16. package/lib/converter/AcDbObjectConverter.js +173 -1
  17. package/lib/converter/AcDbObjectConverter.js.map +1 -1
  18. package/lib/converter/AcDbRegenerator.d.ts.map +1 -1
  19. package/lib/converter/AcDbRegenerator.js +22 -4
  20. package/lib/converter/AcDbRegenerator.js.map +1 -1
  21. package/lib/database/AcDbBlockTableRecord.d.ts.map +1 -1
  22. package/lib/database/AcDbBlockTableRecord.js +1 -0
  23. package/lib/database/AcDbBlockTableRecord.js.map +1 -1
  24. package/lib/database/AcDbDatabase.d.ts +42 -0
  25. package/lib/database/AcDbDatabase.d.ts.map +1 -1
  26. package/lib/database/AcDbDatabase.js +250 -32
  27. package/lib/database/AcDbDatabase.js.map +1 -1
  28. package/lib/database/AcDbSysVarManager.d.ts.map +1 -1
  29. package/lib/database/AcDbSysVarManager.js +28 -1
  30. package/lib/database/AcDbSysVarManager.js.map +1 -1
  31. package/lib/database/AcDbSystemVariables.d.ts +7 -1
  32. package/lib/database/AcDbSystemVariables.d.ts.map +1 -1
  33. package/lib/database/AcDbSystemVariables.js +6 -0
  34. package/lib/database/AcDbSystemVariables.js.map +1 -1
  35. package/lib/entity/AcDbLeader.d.ts +32 -3
  36. package/lib/entity/AcDbLeader.d.ts.map +1 -1
  37. package/lib/entity/AcDbLeader.js +140 -10
  38. package/lib/entity/AcDbLeader.js.map +1 -1
  39. package/lib/entity/AcDbMLeader.d.ts +1092 -0
  40. package/lib/entity/AcDbMLeader.d.ts.map +1 -0
  41. package/lib/entity/AcDbMLeader.js +2553 -0
  42. package/lib/entity/AcDbMLeader.js.map +1 -0
  43. package/lib/entity/AcDbMLine.d.ts +670 -0
  44. package/lib/entity/AcDbMLine.d.ts.map +1 -0
  45. package/lib/entity/AcDbMLine.js +1510 -0
  46. package/lib/entity/AcDbMLine.js.map +1 -0
  47. package/lib/entity/dimension/AcDbDiametricDimension.d.ts +0 -33
  48. package/lib/entity/dimension/AcDbDiametricDimension.d.ts.map +1 -1
  49. package/lib/entity/dimension/AcDbDiametricDimension.js +0 -80
  50. package/lib/entity/dimension/AcDbDiametricDimension.js.map +1 -1
  51. package/lib/entity/dimension/AcDbDimension.d.ts +1 -9
  52. package/lib/entity/dimension/AcDbDimension.d.ts.map +1 -1
  53. package/lib/entity/dimension/AcDbDimension.js +0 -10
  54. package/lib/entity/dimension/AcDbDimension.js.map +1 -1
  55. package/lib/entity/dimension/AcDbRadialDimension.d.ts +0 -6
  56. package/lib/entity/dimension/AcDbRadialDimension.d.ts.map +1 -1
  57. package/lib/entity/dimension/AcDbRadialDimension.js +0 -8
  58. package/lib/entity/dimension/AcDbRadialDimension.js.map +1 -1
  59. package/lib/entity/index.d.ts +2 -0
  60. package/lib/entity/index.d.ts.map +1 -1
  61. package/lib/entity/index.js +2 -0
  62. package/lib/entity/index.js.map +1 -1
  63. package/lib/misc/AcDbConstants.d.ts +14 -0
  64. package/lib/misc/AcDbConstants.d.ts.map +1 -1
  65. package/lib/misc/AcDbConstants.js +14 -0
  66. package/lib/misc/AcDbConstants.js.map +1 -1
  67. package/lib/misc/AcDbMLeaderStyleColorCodec.d.ts +59 -0
  68. package/lib/misc/AcDbMLeaderStyleColorCodec.d.ts.map +1 -0
  69. package/lib/misc/AcDbMLeaderStyleColorCodec.js +101 -0
  70. package/lib/misc/AcDbMLeaderStyleColorCodec.js.map +1 -0
  71. package/lib/misc/index.d.ts +1 -0
  72. package/lib/misc/index.d.ts.map +1 -1
  73. package/lib/misc/index.js +1 -0
  74. package/lib/misc/index.js.map +1 -1
  75. package/lib/object/AcDbMLeaderStyle.d.ts +405 -0
  76. package/lib/object/AcDbMLeaderStyle.d.ts.map +1 -0
  77. package/lib/object/AcDbMLeaderStyle.js +1006 -0
  78. package/lib/object/AcDbMLeaderStyle.js.map +1 -0
  79. package/lib/object/AcDbMlineStyle.d.ts +58 -0
  80. package/lib/object/AcDbMlineStyle.d.ts.map +1 -0
  81. package/lib/object/AcDbMlineStyle.js +158 -0
  82. package/lib/object/AcDbMlineStyle.js.map +1 -0
  83. package/lib/object/index.d.ts +2 -0
  84. package/lib/object/index.d.ts.map +1 -1
  85. package/lib/object/index.js +2 -0
  86. package/lib/object/index.js.map +1 -1
  87. package/package.json +5 -5
@@ -0,0 +1,2553 @@
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 __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ var __read = (this && this.__read) || function (o, n) {
28
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
29
+ if (!m) return o;
30
+ var i = m.call(o), r, ar = [], e;
31
+ try {
32
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
33
+ }
34
+ catch (error) { e = { error: error }; }
35
+ finally {
36
+ try {
37
+ if (r && !r.done && (m = i["return"])) m.call(i);
38
+ }
39
+ finally { if (e) throw e.error; }
40
+ }
41
+ return ar;
42
+ };
43
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
44
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
45
+ if (ar || !(i in from)) {
46
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
47
+ ar[i] = from[i];
48
+ }
49
+ }
50
+ return to.concat(ar || Array.prototype.slice.call(from));
51
+ };
52
+ var __values = (this && this.__values) || function(o) {
53
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
54
+ if (m) return m.call(o);
55
+ if (o && typeof o.length === "number") return {
56
+ next: function () {
57
+ if (o && i >= o.length) o = void 0;
58
+ return { value: o && o[i++], done: !o };
59
+ }
60
+ };
61
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
62
+ };
63
+ import { AcGeArea2d, AcGeBox3d, AcGeMatrix3d, AcGePoint3d, AcGePolyline2d, AcGeVector3d } from '@mlightcad/geometry-engine';
64
+ import { AcGiMTextAttachmentPoint, AcGiMTextFlowDirection } from '@mlightcad/graphic-interface';
65
+ import { AcDbRenderingCache, decodeMLeaderStyleRawColor, DEFAULT_MLEADER_STYLE, DEFAULT_TEXT_STYLE } from '../misc';
66
+ import { AcDbEntity } from './AcDbEntity';
67
+ /**
68
+ * Defines the type of leader line used by a multileader.
69
+ */
70
+ export var AcDbMLeaderLineType;
71
+ (function (AcDbMLeaderLineType) {
72
+ /** The leader line is not displayed. */
73
+ AcDbMLeaderLineType[AcDbMLeaderLineType["InvisibleLeader"] = 0] = "InvisibleLeader";
74
+ /** The leader line is drawn using straight segments. */
75
+ AcDbMLeaderLineType[AcDbMLeaderLineType["StraightLeader"] = 1] = "StraightLeader";
76
+ /** The leader line is drawn as a spline. */
77
+ AcDbMLeaderLineType[AcDbMLeaderLineType["SplineLeader"] = 2] = "SplineLeader";
78
+ })(AcDbMLeaderLineType || (AcDbMLeaderLineType = {}));
79
+ /**
80
+ * Defines the annotation content type used by a multileader.
81
+ */
82
+ export var AcDbMLeaderContentType;
83
+ (function (AcDbMLeaderContentType) {
84
+ /** No annotation content. */
85
+ AcDbMLeaderContentType[AcDbMLeaderContentType["NoneContent"] = 0] = "NoneContent";
86
+ /** Block annotation content. */
87
+ AcDbMLeaderContentType[AcDbMLeaderContentType["BlockContent"] = 1] = "BlockContent";
88
+ /** MText annotation content. */
89
+ AcDbMLeaderContentType[AcDbMLeaderContentType["MTextContent"] = 2] = "MTextContent";
90
+ /** Tolerance annotation content. */
91
+ AcDbMLeaderContentType[AcDbMLeaderContentType["ToleranceContent"] = 3] = "ToleranceContent";
92
+ })(AcDbMLeaderContentType || (AcDbMLeaderContentType = {}));
93
+ /**
94
+ * Defines the attachment direction of multileader text.
95
+ */
96
+ export var AcDbMLeaderTextAttachmentDirection;
97
+ (function (AcDbMLeaderTextAttachmentDirection) {
98
+ /** Text is attached horizontally. */
99
+ AcDbMLeaderTextAttachmentDirection[AcDbMLeaderTextAttachmentDirection["Horizontal"] = 0] = "Horizontal";
100
+ /** Text is attached vertically. */
101
+ AcDbMLeaderTextAttachmentDirection[AcDbMLeaderTextAttachmentDirection["Vertical"] = 1] = "Vertical";
102
+ })(AcDbMLeaderTextAttachmentDirection || (AcDbMLeaderTextAttachmentDirection = {}));
103
+ /**
104
+ * Defines the general direction of a leader branch.
105
+ */
106
+ export var AcDbMLeaderDirectionType;
107
+ (function (AcDbMLeaderDirectionType) {
108
+ /** Direction is not known or not applicable. */
109
+ AcDbMLeaderDirectionType[AcDbMLeaderDirectionType["Unknown"] = 0] = "Unknown";
110
+ /** Leader points to the left of the content. */
111
+ AcDbMLeaderDirectionType[AcDbMLeaderDirectionType["Left"] = 1] = "Left";
112
+ /** Leader points to the right of the content. */
113
+ AcDbMLeaderDirectionType[AcDbMLeaderDirectionType["Right"] = 2] = "Right";
114
+ /** Leader points above the content. */
115
+ AcDbMLeaderDirectionType[AcDbMLeaderDirectionType["Top"] = 3] = "Top";
116
+ /** Leader points below the content. */
117
+ AcDbMLeaderDirectionType[AcDbMLeaderDirectionType["Bottom"] = 4] = "Bottom";
118
+ })(AcDbMLeaderDirectionType || (AcDbMLeaderDirectionType = {}));
119
+ var MLEADER_OVERRIDE_LEADER_LINE_TYPE = 1 << 0;
120
+ var MLEADER_OVERRIDE_LEADER_LINE_COLOR = 1 << 1;
121
+ var MLEADER_OVERRIDE_LEADER_LINE_TYPE_ID = 1 << 2;
122
+ var MLEADER_OVERRIDE_LEADER_LINE_WEIGHT = 1 << 3;
123
+ var MLEADER_OVERRIDE_DOGLEG_ENABLED = 1 << 6;
124
+ var MLEADER_OVERRIDE_DOGLEG_LENGTH = 1 << 7;
125
+ var MLEADER_OVERRIDE_TEXT_COLOR = 1 << 15;
126
+ /**
127
+ * Represents a multileader entity.
128
+ *
129
+ * A multileader contains one or more leader branches, each of which can contain
130
+ * one or more leader lines, plus optional MText or block content.
131
+ */
132
+ var AcDbMLeader = /** @class */ (function (_super) {
133
+ __extends(AcDbMLeader, _super);
134
+ /**
135
+ * Creates an empty multileader entity with default style-related state.
136
+ *
137
+ * @remarks
138
+ * Initializes geometry, text, and block-related members to defaults that
139
+ * are compatible with common MLEADER behavior.
140
+ */
141
+ function AcDbMLeader() {
142
+ var _this = _super.call(this) || this;
143
+ _this._leaders = [];
144
+ _this._leaderLineType = AcDbMLeaderLineType.StraightLeader;
145
+ _this._contentType = AcDbMLeaderContentType.NoneContent;
146
+ _this._doglegEnabled = false;
147
+ _this._doglegLength = 0;
148
+ _this._doglegVector = new AcGeVector3d(1, 0, 0);
149
+ _this._normal = new AcGeVector3d(0, 0, 1);
150
+ _this._mleaderStyleId = '';
151
+ _this._textHeight = 2.5;
152
+ _this._textWidth = 0;
153
+ _this._textRotation = 0;
154
+ _this._textDirection = new AcGeVector3d(1, 0, 0);
155
+ _this._textStyleName = '';
156
+ _this._textAttachmentPoint = AcGiMTextAttachmentPoint.MiddleLeft;
157
+ _this._textDrawingDirection = AcGiMTextFlowDirection.LEFT_TO_RIGHT;
158
+ _this._textLineSpacingFactor = 1;
159
+ _this._textAttachmentDirection =
160
+ AcDbMLeaderTextAttachmentDirection.Horizontal;
161
+ _this._arrowheadOverrides = [];
162
+ _this._blockAttributes = [];
163
+ return _this;
164
+ }
165
+ Object.defineProperty(AcDbMLeader.prototype, "dxfTypeName", {
166
+ /**
167
+ * Gets the DXF type name used when exporting this entity.
168
+ */
169
+ get: function () {
170
+ return 'MULTILEADER';
171
+ },
172
+ enumerable: false,
173
+ configurable: true
174
+ });
175
+ Object.defineProperty(AcDbMLeader.prototype, "leaders", {
176
+ /**
177
+ * Gets a deep-cloned collection of all leader branches.
178
+ */
179
+ get: function () {
180
+ var _this = this;
181
+ return this._leaders.map(function (leader) { return _this.cloneLeader(leader); });
182
+ },
183
+ enumerable: false,
184
+ configurable: true
185
+ });
186
+ Object.defineProperty(AcDbMLeader.prototype, "numberOfLeaders", {
187
+ /**
188
+ * Gets the current number of leader branches.
189
+ */
190
+ get: function () {
191
+ return this._leaders.length;
192
+ },
193
+ enumerable: false,
194
+ configurable: true
195
+ });
196
+ Object.defineProperty(AcDbMLeader.prototype, "leaderLineType", {
197
+ /**
198
+ * Gets the leader line type.
199
+ */
200
+ get: function () {
201
+ return this._leaderLineType;
202
+ },
203
+ set: function (value) {
204
+ this._leaderLineType = value;
205
+ },
206
+ enumerable: false,
207
+ configurable: true
208
+ });
209
+ Object.defineProperty(AcDbMLeader.prototype, "contentType", {
210
+ /**
211
+ * Gets the content type.
212
+ */
213
+ get: function () {
214
+ return this._contentType;
215
+ },
216
+ set: function (value) {
217
+ this._contentType = value;
218
+ },
219
+ enumerable: false,
220
+ configurable: true
221
+ });
222
+ Object.defineProperty(AcDbMLeader.prototype, "doglegEnabled", {
223
+ /**
224
+ * Gets the dogleg enabled.
225
+ */
226
+ get: function () {
227
+ return this._doglegEnabled;
228
+ },
229
+ set: function (value) {
230
+ this._doglegEnabled = value;
231
+ },
232
+ enumerable: false,
233
+ configurable: true
234
+ });
235
+ Object.defineProperty(AcDbMLeader.prototype, "doglegLength", {
236
+ /**
237
+ * Gets the dogleg length.
238
+ */
239
+ get: function () {
240
+ return this._doglegLength;
241
+ },
242
+ set: function (value) {
243
+ this._doglegLength = value;
244
+ },
245
+ enumerable: false,
246
+ configurable: true
247
+ });
248
+ Object.defineProperty(AcDbMLeader.prototype, "doglegVector", {
249
+ /**
250
+ * Gets the dogleg vector.
251
+ */
252
+ get: function () {
253
+ return this._doglegVector;
254
+ },
255
+ set: function (value) {
256
+ this._doglegVector.copy(value);
257
+ },
258
+ enumerable: false,
259
+ configurable: true
260
+ });
261
+ Object.defineProperty(AcDbMLeader.prototype, "landingPoint", {
262
+ /**
263
+ * Gets the landing point.
264
+ */
265
+ get: function () {
266
+ return this._landingPoint;
267
+ },
268
+ set: function (value) {
269
+ this._landingPoint = value ? this.createPoint(value) : undefined;
270
+ },
271
+ enumerable: false,
272
+ configurable: true
273
+ });
274
+ Object.defineProperty(AcDbMLeader.prototype, "normal", {
275
+ /**
276
+ * Gets the normal.
277
+ */
278
+ get: function () {
279
+ return this._normal;
280
+ },
281
+ set: function (value) {
282
+ this._normal.copy(value);
283
+ },
284
+ enumerable: false,
285
+ configurable: true
286
+ });
287
+ Object.defineProperty(AcDbMLeader.prototype, "mleaderStyleId", {
288
+ /**
289
+ * Gets the mleader style id.
290
+ */
291
+ get: function () {
292
+ return this._mleaderStyleId;
293
+ },
294
+ set: function (value) {
295
+ this._mleaderStyleId = value;
296
+ },
297
+ enumerable: false,
298
+ configurable: true
299
+ });
300
+ Object.defineProperty(AcDbMLeader.prototype, "version", {
301
+ /**
302
+ * Gets or sets the serialized MLeader version code.
303
+ *
304
+ * This value mirrors DXF/internal version metadata and is used to keep
305
+ * compatibility with files saved from different AutoCAD generations.
306
+ */
307
+ get: function () {
308
+ return this._version;
309
+ },
310
+ set: function (value) {
311
+ this._version = value;
312
+ },
313
+ enumerable: false,
314
+ configurable: true
315
+ });
316
+ Object.defineProperty(AcDbMLeader.prototype, "leaderStyleId", {
317
+ /**
318
+ * Gets or sets the MLeader style handle override stored on the entity.
319
+ *
320
+ * When provided, this value is typically used as a fallback in addition to
321
+ * `mleaderStyleId` during style resolution.
322
+ */
323
+ get: function () {
324
+ return this._leaderStyleId;
325
+ },
326
+ set: function (value) {
327
+ this._leaderStyleId = value;
328
+ },
329
+ enumerable: false,
330
+ configurable: true
331
+ });
332
+ Object.defineProperty(AcDbMLeader.prototype, "propertyOverrideFlag", {
333
+ /**
334
+ * Gets or sets the property-override bit flag.
335
+ *
336
+ * The flag indicates which visual/behavioral properties are overridden at the
337
+ * entity level instead of inherited from the referenced MLeader style.
338
+ */
339
+ get: function () {
340
+ return this._propertyOverrideFlag;
341
+ },
342
+ set: function (value) {
343
+ this._propertyOverrideFlag = value;
344
+ },
345
+ enumerable: false,
346
+ configurable: true
347
+ });
348
+ Object.defineProperty(AcDbMLeader.prototype, "leaderLineColor", {
349
+ /**
350
+ * Gets or sets the explicit leader line color override.
351
+ */
352
+ get: function () {
353
+ return this._leaderLineColor;
354
+ },
355
+ set: function (value) {
356
+ this._leaderLineColor = value;
357
+ },
358
+ enumerable: false,
359
+ configurable: true
360
+ });
361
+ Object.defineProperty(AcDbMLeader.prototype, "leaderLineTypeId", {
362
+ /**
363
+ * Gets or sets the leader line type handle override.
364
+ */
365
+ get: function () {
366
+ return this._leaderLineTypeId;
367
+ },
368
+ set: function (value) {
369
+ this._leaderLineTypeId = value;
370
+ },
371
+ enumerable: false,
372
+ configurable: true
373
+ });
374
+ Object.defineProperty(AcDbMLeader.prototype, "leaderLineWeight", {
375
+ /**
376
+ * Gets or sets the lineweight override for leader segments.
377
+ */
378
+ get: function () {
379
+ return this._leaderLineWeight;
380
+ },
381
+ set: function (value) {
382
+ this._leaderLineWeight = value;
383
+ },
384
+ enumerable: false,
385
+ configurable: true
386
+ });
387
+ Object.defineProperty(AcDbMLeader.prototype, "landingEnabled", {
388
+ /**
389
+ * Gets or sets whether leader landings are enabled.
390
+ */
391
+ get: function () {
392
+ return this._landingEnabled;
393
+ },
394
+ set: function (value) {
395
+ this._landingEnabled = value;
396
+ },
397
+ enumerable: false,
398
+ configurable: true
399
+ });
400
+ Object.defineProperty(AcDbMLeader.prototype, "arrowheadId", {
401
+ /**
402
+ * Gets or sets the arrowhead block handle/name override.
403
+ */
404
+ get: function () {
405
+ return this._arrowheadId;
406
+ },
407
+ set: function (value) {
408
+ this._arrowheadId = value;
409
+ },
410
+ enumerable: false,
411
+ configurable: true
412
+ });
413
+ Object.defineProperty(AcDbMLeader.prototype, "arrowheadSize", {
414
+ /**
415
+ * Gets or sets the arrowhead size override in drawing units.
416
+ */
417
+ get: function () {
418
+ return this._arrowheadSize;
419
+ },
420
+ set: function (value) {
421
+ this._arrowheadSize = value;
422
+ },
423
+ enumerable: false,
424
+ configurable: true
425
+ });
426
+ Object.defineProperty(AcDbMLeader.prototype, "textStyleId", {
427
+ /**
428
+ * Gets or sets the text style handle override for MText content.
429
+ */
430
+ get: function () {
431
+ return this._textStyleId;
432
+ },
433
+ set: function (value) {
434
+ this._textStyleId = value;
435
+ },
436
+ enumerable: false,
437
+ configurable: true
438
+ });
439
+ Object.defineProperty(AcDbMLeader.prototype, "textLeftAttachmentType", {
440
+ /**
441
+ * Gets or sets left-side text attachment behavior code.
442
+ */
443
+ get: function () {
444
+ return this._textLeftAttachmentType;
445
+ },
446
+ set: function (value) {
447
+ this._textLeftAttachmentType = value;
448
+ },
449
+ enumerable: false,
450
+ configurable: true
451
+ });
452
+ Object.defineProperty(AcDbMLeader.prototype, "textRightAttachmentType", {
453
+ /**
454
+ * Gets or sets right-side text attachment behavior code.
455
+ */
456
+ get: function () {
457
+ return this._textRightAttachmentType;
458
+ },
459
+ set: function (value) {
460
+ this._textRightAttachmentType = value;
461
+ },
462
+ enumerable: false,
463
+ configurable: true
464
+ });
465
+ Object.defineProperty(AcDbMLeader.prototype, "textAngleType", {
466
+ /**
467
+ * Gets or sets the text angle type code controlling rotation strategy.
468
+ */
469
+ get: function () {
470
+ return this._textAngleType;
471
+ },
472
+ set: function (value) {
473
+ this._textAngleType = value;
474
+ },
475
+ enumerable: false,
476
+ configurable: true
477
+ });
478
+ Object.defineProperty(AcDbMLeader.prototype, "textAlignmentType", {
479
+ /**
480
+ * Gets or sets the text alignment type code.
481
+ */
482
+ get: function () {
483
+ return this._textAlignmentType;
484
+ },
485
+ set: function (value) {
486
+ this._textAlignmentType = value;
487
+ },
488
+ enumerable: false,
489
+ configurable: true
490
+ });
491
+ Object.defineProperty(AcDbMLeader.prototype, "textColor", {
492
+ /**
493
+ * Gets or sets the MText color override.
494
+ */
495
+ get: function () {
496
+ return this._textColor;
497
+ },
498
+ set: function (value) {
499
+ this._textColor = value;
500
+ },
501
+ enumerable: false,
502
+ configurable: true
503
+ });
504
+ Object.defineProperty(AcDbMLeader.prototype, "textFrameEnabled", {
505
+ /**
506
+ * Gets or sets whether a text frame (border) is enabled.
507
+ */
508
+ get: function () {
509
+ return this._textFrameEnabled;
510
+ },
511
+ set: function (value) {
512
+ this._textFrameEnabled = value;
513
+ },
514
+ enumerable: false,
515
+ configurable: true
516
+ });
517
+ Object.defineProperty(AcDbMLeader.prototype, "landingGap", {
518
+ /**
519
+ * Gets or sets the gap distance between landing and annotation content.
520
+ */
521
+ get: function () {
522
+ return this._landingGap;
523
+ },
524
+ set: function (value) {
525
+ this._landingGap = value;
526
+ },
527
+ enumerable: false,
528
+ configurable: true
529
+ });
530
+ Object.defineProperty(AcDbMLeader.prototype, "textAttachment", {
531
+ /**
532
+ * Gets or sets the legacy text attachment value used in some DXF variants.
533
+ */
534
+ get: function () {
535
+ return this._textAttachment;
536
+ },
537
+ set: function (value) {
538
+ this._textAttachment = value;
539
+ },
540
+ enumerable: false,
541
+ configurable: true
542
+ });
543
+ Object.defineProperty(AcDbMLeader.prototype, "textFlowDirection", {
544
+ /**
545
+ * Gets or sets the text flow direction override code.
546
+ */
547
+ get: function () {
548
+ return this._textFlowDirection;
549
+ },
550
+ set: function (value) {
551
+ this._textFlowDirection = value;
552
+ },
553
+ enumerable: false,
554
+ configurable: true
555
+ });
556
+ Object.defineProperty(AcDbMLeader.prototype, "blockContentId", {
557
+ /**
558
+ * Gets or sets the referenced block content id/handle for block-based content.
559
+ */
560
+ get: function () {
561
+ return this._blockContentId;
562
+ },
563
+ set: function (value) {
564
+ this._blockContentId = value;
565
+ },
566
+ enumerable: false,
567
+ configurable: true
568
+ });
569
+ Object.defineProperty(AcDbMLeader.prototype, "blockContentColor", {
570
+ /**
571
+ * Gets or sets the block content color override.
572
+ */
573
+ get: function () {
574
+ return this._blockContentColor;
575
+ },
576
+ set: function (value) {
577
+ this._blockContentColor = value;
578
+ },
579
+ enumerable: false,
580
+ configurable: true
581
+ });
582
+ Object.defineProperty(AcDbMLeader.prototype, "blockContentScale", {
583
+ /**
584
+ * Gets or sets the block content scale vector override.
585
+ */
586
+ get: function () {
587
+ return this._blockContentScale;
588
+ },
589
+ set: function (value) {
590
+ this._blockContentScale = value;
591
+ },
592
+ enumerable: false,
593
+ configurable: true
594
+ });
595
+ Object.defineProperty(AcDbMLeader.prototype, "blockContentRotation", {
596
+ /**
597
+ * Gets or sets the block content rotation override in radians.
598
+ */
599
+ get: function () {
600
+ return this._blockContentRotation;
601
+ },
602
+ set: function (value) {
603
+ this._blockContentRotation = value;
604
+ },
605
+ enumerable: false,
606
+ configurable: true
607
+ });
608
+ Object.defineProperty(AcDbMLeader.prototype, "blockContentConnectionType", {
609
+ /**
610
+ * Gets or sets the block content connection type code.
611
+ */
612
+ get: function () {
613
+ return this._blockContentConnectionType;
614
+ },
615
+ set: function (value) {
616
+ this._blockContentConnectionType = value;
617
+ },
618
+ enumerable: false,
619
+ configurable: true
620
+ });
621
+ Object.defineProperty(AcDbMLeader.prototype, "annotativeScaleEnabled", {
622
+ /**
623
+ * Gets or sets whether annotative scaling is enabled for this entity.
624
+ */
625
+ get: function () {
626
+ return this._annotativeScaleEnabled;
627
+ },
628
+ set: function (value) {
629
+ this._annotativeScaleEnabled = value;
630
+ },
631
+ enumerable: false,
632
+ configurable: true
633
+ });
634
+ Object.defineProperty(AcDbMLeader.prototype, "arrowheadOverrides", {
635
+ /**
636
+ * Gets or sets per-index arrowhead overrides.
637
+ *
638
+ * Each entry maps a branch/line index to a specific arrowhead handle.
639
+ */
640
+ get: function () {
641
+ return this._arrowheadOverrides;
642
+ },
643
+ set: function (value) {
644
+ this._arrowheadOverrides = value;
645
+ },
646
+ enumerable: false,
647
+ configurable: true
648
+ });
649
+ Object.defineProperty(AcDbMLeader.prototype, "blockAttributes", {
650
+ /**
651
+ * Gets or sets block attribute override values used by block content.
652
+ */
653
+ get: function () {
654
+ return this._blockAttributes;
655
+ },
656
+ set: function (value) {
657
+ this._blockAttributes = value;
658
+ },
659
+ enumerable: false,
660
+ configurable: true
661
+ });
662
+ Object.defineProperty(AcDbMLeader.prototype, "textDirectionNegative", {
663
+ /**
664
+ * Gets or sets whether text direction is treated as negative.
665
+ */
666
+ get: function () {
667
+ return this._textDirectionNegative;
668
+ },
669
+ set: function (value) {
670
+ this._textDirectionNegative = value;
671
+ },
672
+ enumerable: false,
673
+ configurable: true
674
+ });
675
+ Object.defineProperty(AcDbMLeader.prototype, "textAlignInIPE", {
676
+ /**
677
+ * Gets or sets the in-place editor text alignment code.
678
+ */
679
+ get: function () {
680
+ return this._textAlignInIPE;
681
+ },
682
+ set: function (value) {
683
+ this._textAlignInIPE = value;
684
+ },
685
+ enumerable: false,
686
+ configurable: true
687
+ });
688
+ Object.defineProperty(AcDbMLeader.prototype, "bottomTextAttachmentDirection", {
689
+ /**
690
+ * Gets or sets bottom attachment direction code for vertical text behavior.
691
+ */
692
+ get: function () {
693
+ return this._bottomTextAttachmentDirection;
694
+ },
695
+ set: function (value) {
696
+ this._bottomTextAttachmentDirection = value;
697
+ },
698
+ enumerable: false,
699
+ configurable: true
700
+ });
701
+ Object.defineProperty(AcDbMLeader.prototype, "topTextAttachmentDirection", {
702
+ /**
703
+ * Gets or sets top attachment direction code for vertical text behavior.
704
+ */
705
+ get: function () {
706
+ return this._topTextAttachmentDirection;
707
+ },
708
+ set: function (value) {
709
+ this._topTextAttachmentDirection = value;
710
+ },
711
+ enumerable: false,
712
+ configurable: true
713
+ });
714
+ Object.defineProperty(AcDbMLeader.prototype, "contentScale", {
715
+ /**
716
+ * Gets or sets the overall content scale override.
717
+ */
718
+ get: function () {
719
+ return this._contentScale;
720
+ },
721
+ set: function (value) {
722
+ this._contentScale = value;
723
+ },
724
+ enumerable: false,
725
+ configurable: true
726
+ });
727
+ Object.defineProperty(AcDbMLeader.prototype, "contentBasePosition", {
728
+ /**
729
+ * Gets or sets the base insertion position of annotation content.
730
+ */
731
+ get: function () {
732
+ return this._contentBasePosition;
733
+ },
734
+ set: function (value) {
735
+ this._contentBasePosition = value;
736
+ },
737
+ enumerable: false,
738
+ configurable: true
739
+ });
740
+ Object.defineProperty(AcDbMLeader.prototype, "textAnchor", {
741
+ /**
742
+ * Gets or sets the explicit text anchor position.
743
+ */
744
+ get: function () {
745
+ return this._textAnchor;
746
+ },
747
+ set: function (value) {
748
+ this._textAnchor = value;
749
+ },
750
+ enumerable: false,
751
+ configurable: true
752
+ });
753
+ Object.defineProperty(AcDbMLeader.prototype, "textLineSpacingStyle", {
754
+ /**
755
+ * Gets or sets the text line spacing style code for column/text layout.
756
+ */
757
+ get: function () {
758
+ return this._textLineSpacingStyle;
759
+ },
760
+ set: function (value) {
761
+ this._textLineSpacingStyle = value;
762
+ },
763
+ enumerable: false,
764
+ configurable: true
765
+ });
766
+ Object.defineProperty(AcDbMLeader.prototype, "textBackgroundColor", {
767
+ /**
768
+ * Gets or sets text background color override.
769
+ */
770
+ get: function () {
771
+ return this._textBackgroundColor;
772
+ },
773
+ set: function (value) {
774
+ this._textBackgroundColor = value;
775
+ },
776
+ enumerable: false,
777
+ configurable: true
778
+ });
779
+ Object.defineProperty(AcDbMLeader.prototype, "textBackgroundScaleFactor", {
780
+ /**
781
+ * Gets or sets background-mask scale factor around text.
782
+ */
783
+ get: function () {
784
+ return this._textBackgroundScaleFactor;
785
+ },
786
+ set: function (value) {
787
+ this._textBackgroundScaleFactor = value;
788
+ },
789
+ enumerable: false,
790
+ configurable: true
791
+ });
792
+ Object.defineProperty(AcDbMLeader.prototype, "textBackgroundTransparency", {
793
+ /**
794
+ * Gets or sets text background transparency value.
795
+ */
796
+ get: function () {
797
+ return this._textBackgroundTransparency;
798
+ },
799
+ set: function (value) {
800
+ this._textBackgroundTransparency = value;
801
+ },
802
+ enumerable: false,
803
+ configurable: true
804
+ });
805
+ Object.defineProperty(AcDbMLeader.prototype, "textBackgroundColorOn", {
806
+ /**
807
+ * Gets or sets whether explicit background color masking is enabled.
808
+ */
809
+ get: function () {
810
+ return this._textBackgroundColorOn;
811
+ },
812
+ set: function (value) {
813
+ this._textBackgroundColorOn = value;
814
+ },
815
+ enumerable: false,
816
+ configurable: true
817
+ });
818
+ Object.defineProperty(AcDbMLeader.prototype, "textFillOn", {
819
+ /**
820
+ * Gets or sets whether text fill/mask is enabled.
821
+ */
822
+ get: function () {
823
+ return this._textFillOn;
824
+ },
825
+ set: function (value) {
826
+ this._textFillOn = value;
827
+ },
828
+ enumerable: false,
829
+ configurable: true
830
+ });
831
+ Object.defineProperty(AcDbMLeader.prototype, "textColumnType", {
832
+ /**
833
+ * Gets or sets the text column layout type code.
834
+ */
835
+ get: function () {
836
+ return this._textColumnType;
837
+ },
838
+ set: function (value) {
839
+ this._textColumnType = value;
840
+ },
841
+ enumerable: false,
842
+ configurable: true
843
+ });
844
+ Object.defineProperty(AcDbMLeader.prototype, "textUseAutoHeight", {
845
+ /**
846
+ * Gets or sets whether text column height is auto-managed.
847
+ */
848
+ get: function () {
849
+ return this._textUseAutoHeight;
850
+ },
851
+ set: function (value) {
852
+ this._textUseAutoHeight = value;
853
+ },
854
+ enumerable: false,
855
+ configurable: true
856
+ });
857
+ Object.defineProperty(AcDbMLeader.prototype, "textColumnWidth", {
858
+ /**
859
+ * Gets or sets the fixed width for text columns.
860
+ */
861
+ get: function () {
862
+ return this._textColumnWidth;
863
+ },
864
+ set: function (value) {
865
+ this._textColumnWidth = value;
866
+ },
867
+ enumerable: false,
868
+ configurable: true
869
+ });
870
+ Object.defineProperty(AcDbMLeader.prototype, "textColumnGutterWidth", {
871
+ /**
872
+ * Gets or sets the gutter width between text columns.
873
+ */
874
+ get: function () {
875
+ return this._textColumnGutterWidth;
876
+ },
877
+ set: function (value) {
878
+ this._textColumnGutterWidth = value;
879
+ },
880
+ enumerable: false,
881
+ configurable: true
882
+ });
883
+ Object.defineProperty(AcDbMLeader.prototype, "textColumnFlowReversed", {
884
+ /**
885
+ * Gets or sets whether text columns flow in reverse order.
886
+ */
887
+ get: function () {
888
+ return this._textColumnFlowReversed;
889
+ },
890
+ set: function (value) {
891
+ this._textColumnFlowReversed = value;
892
+ },
893
+ enumerable: false,
894
+ configurable: true
895
+ });
896
+ Object.defineProperty(AcDbMLeader.prototype, "textColumnHeight", {
897
+ /**
898
+ * Gets or sets the explicit text column height.
899
+ */
900
+ get: function () {
901
+ return this._textColumnHeight;
902
+ },
903
+ set: function (value) {
904
+ this._textColumnHeight = value;
905
+ },
906
+ enumerable: false,
907
+ configurable: true
908
+ });
909
+ Object.defineProperty(AcDbMLeader.prototype, "textUseWordBreak", {
910
+ /**
911
+ * Gets or sets whether word breaking is enabled in column layout.
912
+ */
913
+ get: function () {
914
+ return this._textUseWordBreak;
915
+ },
916
+ set: function (value) {
917
+ this._textUseWordBreak = value;
918
+ },
919
+ enumerable: false,
920
+ configurable: true
921
+ });
922
+ Object.defineProperty(AcDbMLeader.prototype, "hasMText", {
923
+ /**
924
+ * Gets or sets whether MText content exists in the serialized payload.
925
+ */
926
+ get: function () {
927
+ return this._hasMText;
928
+ },
929
+ set: function (value) {
930
+ this._hasMText = value;
931
+ },
932
+ enumerable: false,
933
+ configurable: true
934
+ });
935
+ Object.defineProperty(AcDbMLeader.prototype, "hasBlock", {
936
+ /**
937
+ * Gets or sets whether block content exists in the serialized payload.
938
+ */
939
+ get: function () {
940
+ return this._hasBlock;
941
+ },
942
+ set: function (value) {
943
+ this._hasBlock = value;
944
+ },
945
+ enumerable: false,
946
+ configurable: true
947
+ });
948
+ Object.defineProperty(AcDbMLeader.prototype, "planeOrigin", {
949
+ /**
950
+ * Gets or sets the origin of the MLeader plane definition.
951
+ */
952
+ get: function () {
953
+ return this._planeOrigin;
954
+ },
955
+ set: function (value) {
956
+ this._planeOrigin = value;
957
+ },
958
+ enumerable: false,
959
+ configurable: true
960
+ });
961
+ Object.defineProperty(AcDbMLeader.prototype, "planeXAxisDirection", {
962
+ /**
963
+ * Gets or sets the X-axis direction vector of the MLeader plane.
964
+ */
965
+ get: function () {
966
+ return this._planeXAxisDirection;
967
+ },
968
+ set: function (value) {
969
+ this._planeXAxisDirection = value;
970
+ },
971
+ enumerable: false,
972
+ configurable: true
973
+ });
974
+ Object.defineProperty(AcDbMLeader.prototype, "planeYAxisDirection", {
975
+ /**
976
+ * Gets or sets the Y-axis direction vector of the MLeader plane.
977
+ */
978
+ get: function () {
979
+ return this._planeYAxisDirection;
980
+ },
981
+ set: function (value) {
982
+ this._planeYAxisDirection = value;
983
+ },
984
+ enumerable: false,
985
+ configurable: true
986
+ });
987
+ Object.defineProperty(AcDbMLeader.prototype, "planeNormalReversed", {
988
+ /**
989
+ * Gets or sets whether the MLeader plane normal is reversed.
990
+ */
991
+ get: function () {
992
+ return this._planeNormalReversed;
993
+ },
994
+ set: function (value) {
995
+ this._planeNormalReversed = value;
996
+ },
997
+ enumerable: false,
998
+ configurable: true
999
+ });
1000
+ Object.defineProperty(AcDbMLeader.prototype, "leaderSections", {
1001
+ /**
1002
+ * Gets the alias of `leaders`.
1003
+ */
1004
+ get: function () {
1005
+ return this.leaders;
1006
+ },
1007
+ enumerable: false,
1008
+ configurable: true
1009
+ });
1010
+ Object.defineProperty(AcDbMLeader.prototype, "blockContentData", {
1011
+ /**
1012
+ * Gets the alias of `blockContent`.
1013
+ */
1014
+ get: function () {
1015
+ return this.blockContent;
1016
+ },
1017
+ enumerable: false,
1018
+ configurable: true
1019
+ });
1020
+ Object.defineProperty(AcDbMLeader.prototype, "mtextContent", {
1021
+ /**
1022
+ * Gets the MText content payload if present.
1023
+ */
1024
+ get: function () {
1025
+ return this._mtextContent
1026
+ ? {
1027
+ text: this._mtextContent.text,
1028
+ anchorPoint: this._mtextContent.anchorPoint.clone()
1029
+ }
1030
+ : undefined;
1031
+ },
1032
+ set: function (value) {
1033
+ if (!value) {
1034
+ this._mtextContent = undefined;
1035
+ if (this._contentType === AcDbMLeaderContentType.MTextContent) {
1036
+ this._contentType = AcDbMLeaderContentType.NoneContent;
1037
+ }
1038
+ return;
1039
+ }
1040
+ this._mtextContent = {
1041
+ text: value.text,
1042
+ anchorPoint: this.createPoint(value.anchorPoint)
1043
+ };
1044
+ this._contentType = AcDbMLeaderContentType.MTextContent;
1045
+ },
1046
+ enumerable: false,
1047
+ configurable: true
1048
+ });
1049
+ Object.defineProperty(AcDbMLeader.prototype, "contents", {
1050
+ /**
1051
+ * Gets the displayed MText string content.
1052
+ */
1053
+ get: function () {
1054
+ var _a, _b;
1055
+ return (_b = (_a = this._mtextContent) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : '';
1056
+ },
1057
+ set: function (value) {
1058
+ if (!this._mtextContent) {
1059
+ this._mtextContent = {
1060
+ text: value,
1061
+ anchorPoint: new AcGePoint3d()
1062
+ };
1063
+ }
1064
+ else {
1065
+ this._mtextContent.text = value;
1066
+ }
1067
+ this._contentType = AcDbMLeaderContentType.MTextContent;
1068
+ },
1069
+ enumerable: false,
1070
+ configurable: true
1071
+ });
1072
+ Object.defineProperty(AcDbMLeader.prototype, "textLocation", {
1073
+ /**
1074
+ * Gets the MText anchor point.
1075
+ */
1076
+ get: function () {
1077
+ var _a;
1078
+ return (_a = this._mtextContent) === null || _a === void 0 ? void 0 : _a.anchorPoint;
1079
+ },
1080
+ set: function (value) {
1081
+ if (!value) {
1082
+ this._mtextContent = undefined;
1083
+ return;
1084
+ }
1085
+ if (!this._mtextContent) {
1086
+ this._mtextContent = {
1087
+ text: '',
1088
+ anchorPoint: this.createPoint(value)
1089
+ };
1090
+ }
1091
+ else {
1092
+ this._mtextContent.anchorPoint.copy(value);
1093
+ }
1094
+ this._contentType = AcDbMLeaderContentType.MTextContent;
1095
+ },
1096
+ enumerable: false,
1097
+ configurable: true
1098
+ });
1099
+ Object.defineProperty(AcDbMLeader.prototype, "textHeight", {
1100
+ /**
1101
+ * Gets the text height.
1102
+ */
1103
+ get: function () {
1104
+ return this._textHeight;
1105
+ },
1106
+ set: function (value) {
1107
+ this._textHeight = value;
1108
+ },
1109
+ enumerable: false,
1110
+ configurable: true
1111
+ });
1112
+ Object.defineProperty(AcDbMLeader.prototype, "textWidth", {
1113
+ /**
1114
+ * Gets the text width.
1115
+ */
1116
+ get: function () {
1117
+ return this._textWidth;
1118
+ },
1119
+ set: function (value) {
1120
+ this._textWidth = value;
1121
+ },
1122
+ enumerable: false,
1123
+ configurable: true
1124
+ });
1125
+ Object.defineProperty(AcDbMLeader.prototype, "textRotation", {
1126
+ /**
1127
+ * Gets the text rotation.
1128
+ */
1129
+ get: function () {
1130
+ return this._textRotation;
1131
+ },
1132
+ set: function (value) {
1133
+ this._textRotation = value;
1134
+ },
1135
+ enumerable: false,
1136
+ configurable: true
1137
+ });
1138
+ Object.defineProperty(AcDbMLeader.prototype, "textDirection", {
1139
+ /**
1140
+ * Gets the text direction.
1141
+ */
1142
+ get: function () {
1143
+ return this._textDirection;
1144
+ },
1145
+ set: function (value) {
1146
+ this._textDirection.copy(value);
1147
+ },
1148
+ enumerable: false,
1149
+ configurable: true
1150
+ });
1151
+ Object.defineProperty(AcDbMLeader.prototype, "textStyleName", {
1152
+ /**
1153
+ * Gets the text style name.
1154
+ */
1155
+ get: function () {
1156
+ return this._textStyleName;
1157
+ },
1158
+ set: function (value) {
1159
+ this._textStyleName = value;
1160
+ },
1161
+ enumerable: false,
1162
+ configurable: true
1163
+ });
1164
+ Object.defineProperty(AcDbMLeader.prototype, "textAttachmentPoint", {
1165
+ /**
1166
+ * Gets the text attachment point.
1167
+ */
1168
+ get: function () {
1169
+ return this._textAttachmentPoint;
1170
+ },
1171
+ set: function (value) {
1172
+ this._textAttachmentPoint = value;
1173
+ },
1174
+ enumerable: false,
1175
+ configurable: true
1176
+ });
1177
+ Object.defineProperty(AcDbMLeader.prototype, "textDrawingDirection", {
1178
+ /**
1179
+ * Gets the text drawing direction.
1180
+ */
1181
+ get: function () {
1182
+ return this._textDrawingDirection;
1183
+ },
1184
+ set: function (value) {
1185
+ this._textDrawingDirection = value;
1186
+ },
1187
+ enumerable: false,
1188
+ configurable: true
1189
+ });
1190
+ Object.defineProperty(AcDbMLeader.prototype, "textLineSpacingFactor", {
1191
+ /**
1192
+ * Gets the text line spacing factor.
1193
+ */
1194
+ get: function () {
1195
+ return this._textLineSpacingFactor;
1196
+ },
1197
+ set: function (value) {
1198
+ this._textLineSpacingFactor = value;
1199
+ },
1200
+ enumerable: false,
1201
+ configurable: true
1202
+ });
1203
+ Object.defineProperty(AcDbMLeader.prototype, "textAttachmentDirection", {
1204
+ /**
1205
+ * Gets the text attachment direction.
1206
+ */
1207
+ get: function () {
1208
+ return this._textAttachmentDirection;
1209
+ },
1210
+ set: function (value) {
1211
+ this._textAttachmentDirection = value;
1212
+ },
1213
+ enumerable: false,
1214
+ configurable: true
1215
+ });
1216
+ Object.defineProperty(AcDbMLeader.prototype, "blockContent", {
1217
+ /**
1218
+ * Gets the block content.
1219
+ */
1220
+ get: function () {
1221
+ var _a, _b;
1222
+ return this._blockContent
1223
+ ? {
1224
+ blockContentId: this._blockContent.blockContentId,
1225
+ blockHandle: this._blockContent.blockHandle,
1226
+ normal: (_a = this._blockContent.normal) === null || _a === void 0 ? void 0 : _a.clone(),
1227
+ position: (_b = this._blockContent.position) === null || _b === void 0 ? void 0 : _b.clone(),
1228
+ scale: this._blockContent.scale.clone(),
1229
+ rotation: this._blockContent.rotation,
1230
+ color: this._blockContent.color,
1231
+ transformationMatrix: __spreadArray([], __read(this._blockContent.transformationMatrix), false)
1232
+ }
1233
+ : undefined;
1234
+ },
1235
+ set: function (value) {
1236
+ var _a, _b, _c;
1237
+ if (!value) {
1238
+ this._blockContent = undefined;
1239
+ if (this._contentType === AcDbMLeaderContentType.BlockContent) {
1240
+ this._contentType = AcDbMLeaderContentType.NoneContent;
1241
+ }
1242
+ return;
1243
+ }
1244
+ this._blockContent = {
1245
+ blockContentId: (_a = value.blockContentId) !== null && _a !== void 0 ? _a : value.blockHandle,
1246
+ blockHandle: value.blockHandle,
1247
+ normal: value.normal ? new AcGeVector3d(value.normal) : undefined,
1248
+ position: value.position ? this.createPoint(value.position) : undefined,
1249
+ scale: new AcGeVector3d((_b = value.scale) !== null && _b !== void 0 ? _b : { x: 1, y: 1, z: 1 }),
1250
+ rotation: (_c = value.rotation) !== null && _c !== void 0 ? _c : 0,
1251
+ color: value.color,
1252
+ transformationMatrix: value.transformationMatrix
1253
+ ? __spreadArray([], __read(value.transformationMatrix), false) : []
1254
+ };
1255
+ this.blockContentId = this._blockContent.blockContentId;
1256
+ this._contentType = AcDbMLeaderContentType.BlockContent;
1257
+ },
1258
+ enumerable: false,
1259
+ configurable: true
1260
+ });
1261
+ /**
1262
+ * Adds a leader branch and returns its index.
1263
+ *
1264
+ * @param leader Optional leader payload used to initialize branch data.
1265
+ * @returns Index of the newly added leader branch.
1266
+ */
1267
+ AcDbMLeader.prototype.addLeader = function (leader) {
1268
+ var _this = this;
1269
+ var _a, _b, _c;
1270
+ if (leader === void 0) { leader = {}; }
1271
+ var dbLeader = {
1272
+ lastLeaderLinePoint: leader.lastLeaderLinePoint
1273
+ ? this.createPoint(leader.lastLeaderLinePoint)
1274
+ : undefined,
1275
+ lastLeaderLinePointSet: leader.lastLeaderLinePointSet,
1276
+ landingPoint: leader.landingPoint
1277
+ ? this.createPoint(leader.landingPoint)
1278
+ : undefined,
1279
+ doglegVector: leader.doglegVector
1280
+ ? new AcGeVector3d(leader.doglegVector)
1281
+ : undefined,
1282
+ doglegVectorSet: leader.doglegVectorSet,
1283
+ doglegLength: leader.doglegLength,
1284
+ breaks: (_b = (_a = leader.breaks) === null || _a === void 0 ? void 0 : _a.map(function (item) { return ({
1285
+ index: item.index,
1286
+ start: _this.createPoint(item.start),
1287
+ end: _this.createPoint(item.end)
1288
+ }); })) !== null && _b !== void 0 ? _b : [],
1289
+ leaderBranchIndex: leader.leaderBranchIndex,
1290
+ directionType: leader.directionType,
1291
+ leaderLines: []
1292
+ };
1293
+ (_c = leader.leaderLines) === null || _c === void 0 ? void 0 : _c.forEach(function (line) {
1294
+ dbLeader.leaderLines.push(_this.createLeaderLine(line));
1295
+ });
1296
+ this._leaders.push(dbLeader);
1297
+ return this._leaders.length - 1;
1298
+ };
1299
+ /**
1300
+ * Removes a leader branch.
1301
+ *
1302
+ * @param leaderIndex Zero-based index of the leader branch to remove.
1303
+ * @returns The current entity instance for chaining.
1304
+ */
1305
+ AcDbMLeader.prototype.removeLeader = function (leaderIndex) {
1306
+ this.checkLeaderIndex(leaderIndex);
1307
+ this._leaders.splice(leaderIndex, 1);
1308
+ return this;
1309
+ };
1310
+ /**
1311
+ * Adds a leader line to a leader branch and returns the line index.
1312
+ *
1313
+ * @param leaderIndex Index of the target leader branch.
1314
+ * @param vertices Optional initial vertices for the leader line.
1315
+ * @returns Index of the newly added leader line.
1316
+ */
1317
+ AcDbMLeader.prototype.addLeaderLine = function (leaderIndex, vertices) {
1318
+ if (vertices === void 0) { vertices = []; }
1319
+ this.checkLeaderIndex(leaderIndex);
1320
+ this._leaders[leaderIndex].leaderLines.push(this.createLeaderLine({ vertices: vertices }));
1321
+ return this._leaders[leaderIndex].leaderLines.length - 1;
1322
+ };
1323
+ /**
1324
+ * Appends a vertex to one leader line.
1325
+ *
1326
+ * @param leaderIndex Index of the target leader branch.
1327
+ * @param leaderLineIndex Index of the target leader line.
1328
+ * @param point Vertex to append.
1329
+ * @returns The current entity instance for chaining.
1330
+ */
1331
+ AcDbMLeader.prototype.appendVertex = function (leaderIndex, leaderLineIndex, point) {
1332
+ this.getMutableLeaderLine(leaderIndex, leaderLineIndex).vertices.push(this.createPoint(point));
1333
+ return this;
1334
+ };
1335
+ /**
1336
+ * Replaces the vertices of one leader line.
1337
+ *
1338
+ * @param leaderIndex Index of the target leader branch.
1339
+ * @param leaderLineIndex Index of the target leader line.
1340
+ * @param vertices New vertex sequence.
1341
+ * @returns The current entity instance for chaining.
1342
+ */
1343
+ AcDbMLeader.prototype.setLeaderLineVertices = function (leaderIndex, leaderLineIndex, vertices) {
1344
+ var _this = this;
1345
+ this.getMutableLeaderLine(leaderIndex, leaderLineIndex).vertices =
1346
+ vertices.map(function (point) { return _this.createPoint(point); });
1347
+ return this;
1348
+ };
1349
+ /**
1350
+ * Gets cloned vertices from the specified leader line.
1351
+ *
1352
+ * @param leaderIndex Index of the leader branch.
1353
+ * @param leaderLineIndex Index of the leader line in the branch.
1354
+ * @returns A cloned vertex list so callers cannot mutate internal state.
1355
+ */
1356
+ AcDbMLeader.prototype.getLeaderLineVertices = function (leaderIndex, leaderLineIndex) {
1357
+ return this.getMutableLeaderLine(leaderIndex, leaderLineIndex).vertices.map(function (point) { return point.clone(); });
1358
+ };
1359
+ /**
1360
+ * Adds a break segment to a specific leader line.
1361
+ *
1362
+ * @param leaderIndex Index of the leader branch.
1363
+ * @param leaderLineIndex Index of the leader line.
1364
+ * @param start Break start point.
1365
+ * @param end Break end point.
1366
+ * @returns The current entity instance for chaining.
1367
+ */
1368
+ AcDbMLeader.prototype.addBreak = function (leaderIndex, leaderLineIndex, start, end) {
1369
+ this.getMutableLeaderLine(leaderIndex, leaderLineIndex).breaks.push({
1370
+ start: this.createPoint(start),
1371
+ end: this.createPoint(end)
1372
+ });
1373
+ return this;
1374
+ };
1375
+ /**
1376
+ * Sets the landing point for one leader branch.
1377
+ *
1378
+ * @param leaderIndex Index of the leader branch.
1379
+ * @param point New landing point, or `undefined` to clear it.
1380
+ * @returns The current entity instance for chaining.
1381
+ */
1382
+ AcDbMLeader.prototype.setLandingPoint = function (leaderIndex, point) {
1383
+ this.checkLeaderIndex(leaderIndex);
1384
+ this._leaders[leaderIndex].landingPoint = point
1385
+ ? this.createPoint(point)
1386
+ : undefined;
1387
+ return this;
1388
+ };
1389
+ /**
1390
+ * Sets the dogleg direction for one leader branch.
1391
+ *
1392
+ * @param leaderIndex Index of the leader branch.
1393
+ * @param vector New dogleg direction vector.
1394
+ * @returns The current entity instance for chaining.
1395
+ */
1396
+ AcDbMLeader.prototype.setDoglegDirection = function (leaderIndex, vector) {
1397
+ this.checkLeaderIndex(leaderIndex);
1398
+ this._leaders[leaderIndex].doglegVector = new AcGeVector3d(vector);
1399
+ return this;
1400
+ };
1401
+ /**
1402
+ * Sets the dogleg length for one leader branch.
1403
+ *
1404
+ * @param leaderIndex Index of the leader branch.
1405
+ * @param length New dogleg length, or `undefined` to clear the override.
1406
+ * @returns The current entity instance for chaining.
1407
+ */
1408
+ AcDbMLeader.prototype.setDoglegLength = function (leaderIndex, length) {
1409
+ this.checkLeaderIndex(leaderIndex);
1410
+ this._leaders[leaderIndex].doglegLength = length;
1411
+ return this;
1412
+ };
1413
+ Object.defineProperty(AcDbMLeader.prototype, "geometricExtents", {
1414
+ /**
1415
+ * Gets the axis-aligned extents computed from all geometry points.
1416
+ */
1417
+ get: function () {
1418
+ var points = this.collectGeometryPoints();
1419
+ return points.length > 0
1420
+ ? new AcGeBox3d().setFromPoints(points)
1421
+ : new AcGeBox3d();
1422
+ },
1423
+ enumerable: false,
1424
+ configurable: true
1425
+ });
1426
+ /**
1427
+ * Gets grip points used for interactive editing.
1428
+ *
1429
+ * @returns Cloned grip points derived from renderable geometry.
1430
+ */
1431
+ AcDbMLeader.prototype.subGetGripPoints = function () {
1432
+ return this.collectGeometryPoints().map(function (point) { return point.clone(); });
1433
+ };
1434
+ /**
1435
+ * Applies a transformation matrix to this entity.
1436
+ *
1437
+ * @param matrix Transformation matrix applied to all geometry and vectors.
1438
+ * @returns The current entity instance for chaining.
1439
+ */
1440
+ AcDbMLeader.prototype.transformBy = function (matrix) {
1441
+ var _this = this;
1442
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1443
+ this._leaders.forEach(function (leader) {
1444
+ var _a, _b;
1445
+ (_a = leader.lastLeaderLinePoint) === null || _a === void 0 ? void 0 : _a.applyMatrix4(matrix);
1446
+ (_b = leader.landingPoint) === null || _b === void 0 ? void 0 : _b.applyMatrix4(matrix);
1447
+ if (leader.doglegVector) {
1448
+ _this.transformVector(leader.doglegVector, matrix);
1449
+ }
1450
+ leader.breaks.forEach(function (item) {
1451
+ item.start.applyMatrix4(matrix);
1452
+ item.end.applyMatrix4(matrix);
1453
+ });
1454
+ leader.leaderLines.forEach(function (line) {
1455
+ line.vertices.forEach(function (point) { return point.applyMatrix4(matrix); });
1456
+ line.breaks.forEach(function (item) {
1457
+ item.start.applyMatrix4(matrix);
1458
+ item.end.applyMatrix4(matrix);
1459
+ });
1460
+ });
1461
+ });
1462
+ (_a = this._landingPoint) === null || _a === void 0 ? void 0 : _a.applyMatrix4(matrix);
1463
+ (_b = this.contentBasePosition) === null || _b === void 0 ? void 0 : _b.applyMatrix4(matrix);
1464
+ this.transformVector(this._doglegVector, matrix);
1465
+ this.transformVector(this._normal, matrix);
1466
+ (_c = this.textAnchor) === null || _c === void 0 ? void 0 : _c.applyMatrix4(matrix);
1467
+ (_d = this._mtextContent) === null || _d === void 0 ? void 0 : _d.anchorPoint.applyMatrix4(matrix);
1468
+ this.transformVector(this._textDirection, matrix);
1469
+ (_f = (_e = this._blockContent) === null || _e === void 0 ? void 0 : _e.position) === null || _f === void 0 ? void 0 : _f.applyMatrix4(matrix);
1470
+ if ((_g = this._blockContent) === null || _g === void 0 ? void 0 : _g.normal) {
1471
+ this.transformVector(this._blockContent.normal, matrix);
1472
+ }
1473
+ if (this.blockContentScale) {
1474
+ this.transformVector(this.blockContentScale, matrix);
1475
+ }
1476
+ (_h = this.planeOrigin) === null || _h === void 0 ? void 0 : _h.applyMatrix4(matrix);
1477
+ if (this.planeXAxisDirection) {
1478
+ this.transformVector(this.planeXAxisDirection, matrix);
1479
+ }
1480
+ if (this.planeYAxisDirection) {
1481
+ this.transformVector(this.planeYAxisDirection, matrix);
1482
+ }
1483
+ return this;
1484
+ };
1485
+ Object.defineProperty(AcDbMLeader.prototype, "properties", {
1486
+ get: function () {
1487
+ var _this = this;
1488
+ return {
1489
+ type: this.type,
1490
+ groups: [
1491
+ this.getGeneralProperties(),
1492
+ {
1493
+ groupName: 'leader',
1494
+ properties: [
1495
+ {
1496
+ name: 'contentType',
1497
+ type: 'enum',
1498
+ editable: true,
1499
+ options: [
1500
+ {
1501
+ label: AcDbMLeaderContentType[AcDbMLeaderContentType.NoneContent],
1502
+ value: AcDbMLeaderContentType.NoneContent
1503
+ },
1504
+ {
1505
+ label: AcDbMLeaderContentType[AcDbMLeaderContentType.BlockContent],
1506
+ value: AcDbMLeaderContentType.BlockContent
1507
+ },
1508
+ {
1509
+ label: AcDbMLeaderContentType[AcDbMLeaderContentType.MTextContent],
1510
+ value: AcDbMLeaderContentType.MTextContent
1511
+ },
1512
+ {
1513
+ label: AcDbMLeaderContentType[AcDbMLeaderContentType.ToleranceContent],
1514
+ value: AcDbMLeaderContentType.ToleranceContent
1515
+ }
1516
+ ],
1517
+ accessor: {
1518
+ get: function () { return _this.contentType; },
1519
+ set: function (value) {
1520
+ _this.contentType = value;
1521
+ }
1522
+ }
1523
+ },
1524
+ {
1525
+ name: 'leaderLineType',
1526
+ type: 'enum',
1527
+ editable: true,
1528
+ options: [
1529
+ {
1530
+ label: AcDbMLeaderLineType[AcDbMLeaderLineType.InvisibleLeader],
1531
+ value: AcDbMLeaderLineType.InvisibleLeader
1532
+ },
1533
+ {
1534
+ label: AcDbMLeaderLineType[AcDbMLeaderLineType.StraightLeader],
1535
+ value: AcDbMLeaderLineType.StraightLeader
1536
+ },
1537
+ {
1538
+ label: AcDbMLeaderLineType[AcDbMLeaderLineType.SplineLeader],
1539
+ value: AcDbMLeaderLineType.SplineLeader
1540
+ }
1541
+ ],
1542
+ accessor: {
1543
+ get: function () { return _this.leaderLineType; },
1544
+ set: function (value) {
1545
+ _this.leaderLineType = value;
1546
+ }
1547
+ }
1548
+ },
1549
+ {
1550
+ name: 'doglegEnabled',
1551
+ type: 'boolean',
1552
+ editable: true,
1553
+ accessor: {
1554
+ get: function () { return _this.doglegEnabled; },
1555
+ set: function (value) {
1556
+ _this.doglegEnabled = value;
1557
+ }
1558
+ }
1559
+ },
1560
+ {
1561
+ name: 'doglegLength',
1562
+ type: 'float',
1563
+ editable: true,
1564
+ accessor: {
1565
+ get: function () { return _this.doglegLength; },
1566
+ set: function (value) {
1567
+ _this.doglegLength = value;
1568
+ }
1569
+ }
1570
+ },
1571
+ {
1572
+ name: 'leaderCount',
1573
+ type: 'int',
1574
+ editable: false,
1575
+ accessor: {
1576
+ get: function () { return _this.numberOfLeaders; }
1577
+ }
1578
+ }
1579
+ ]
1580
+ },
1581
+ {
1582
+ groupName: 'text',
1583
+ properties: [
1584
+ {
1585
+ name: 'contents',
1586
+ type: 'string',
1587
+ editable: true,
1588
+ accessor: {
1589
+ get: function () { return _this.contents; },
1590
+ set: function (value) {
1591
+ _this.contents = value;
1592
+ }
1593
+ }
1594
+ },
1595
+ {
1596
+ name: 'textHeight',
1597
+ type: 'float',
1598
+ editable: true,
1599
+ accessor: {
1600
+ get: function () { return _this.textHeight; },
1601
+ set: function (value) {
1602
+ _this.textHeight = value;
1603
+ }
1604
+ }
1605
+ },
1606
+ {
1607
+ name: 'textWidth',
1608
+ type: 'float',
1609
+ editable: true,
1610
+ accessor: {
1611
+ get: function () { return _this.textWidth; },
1612
+ set: function (value) {
1613
+ _this.textWidth = value;
1614
+ }
1615
+ }
1616
+ },
1617
+ {
1618
+ name: 'textStyleName',
1619
+ type: 'string',
1620
+ editable: true,
1621
+ accessor: {
1622
+ get: function () { return _this.textStyleName; },
1623
+ set: function (value) {
1624
+ _this.textStyleName = value;
1625
+ }
1626
+ }
1627
+ }
1628
+ ]
1629
+ }
1630
+ ]
1631
+ };
1632
+ },
1633
+ enumerable: false,
1634
+ configurable: true
1635
+ });
1636
+ /**
1637
+ * @inheritdoc
1638
+ *
1639
+ * @returns The current entity instance with effective properties resolved.
1640
+ */
1641
+ AcDbMLeader.prototype.resolveEffectiveProperties = function () {
1642
+ _super.prototype.resolveEffectiveProperties.call(this);
1643
+ if (this._mleaderStyleId)
1644
+ return;
1645
+ var style = this.getDefaultMLeaderStyle();
1646
+ if (style) {
1647
+ this._mleaderStyleId = style.objectId;
1648
+ }
1649
+ };
1650
+ /**
1651
+ * Builds renderable primitives for this multileader entity.
1652
+ *
1653
+ * @param renderer Graphics renderer used to create draw entities.
1654
+ * @returns A single entity, an entity group, or undefined when nothing is drawable.
1655
+ */
1656
+ AcDbMLeader.prototype.subWorldDraw = function (renderer) {
1657
+ var _this = this;
1658
+ var entities = [];
1659
+ var traits = renderer.subEntityTraits;
1660
+ var originalColor = traits.color;
1661
+ var originalRgbColor = traits.rgbColor;
1662
+ var originalLineType = traits.lineType;
1663
+ var originalLineWeight = traits.lineWeight;
1664
+ var leaderLineColor = this.getResolvedLeaderLineColor();
1665
+ var leaderLineStyle = this.getResolvedLeaderLineStyle();
1666
+ var leaderLineWeight = this.getResolvedLeaderLineWeight();
1667
+ var textColor = this.getResolvedTextColor();
1668
+ if (this.getResolvedLeaderLineType() !== AcDbMLeaderLineType.InvisibleLeader) {
1669
+ this.applyColorTraits(traits, leaderLineColor, originalColor, originalRgbColor);
1670
+ this.applyLineTraits(traits, leaderLineStyle, leaderLineWeight);
1671
+ this._leaders.forEach(function (leader) {
1672
+ leader.leaderLines.forEach(function (line) {
1673
+ var points = _this.getLeaderLineDrawPoints(leader, line);
1674
+ if (points.length > 0) {
1675
+ var leaderEntity = _this.drawLeaderLine(renderer, points);
1676
+ if (leaderEntity)
1677
+ entities.push(leaderEntity);
1678
+ }
1679
+ });
1680
+ var doglegPoints = _this.getDoglegPoints(leader);
1681
+ if (doglegPoints) {
1682
+ entities.push(renderer.lines(doglegPoints));
1683
+ }
1684
+ });
1685
+ }
1686
+ var mtextContent = this.getRenderableMTextContent();
1687
+ if (this.contentType === AcDbMLeaderContentType.MTextContent &&
1688
+ mtextContent) {
1689
+ this.applyColorTraits(traits, textColor, originalColor, originalRgbColor);
1690
+ var textHeight = this.getResolvedTextHeight();
1691
+ var mtextData = {
1692
+ text: mtextContent.text,
1693
+ height: textHeight,
1694
+ width: this.getMTextRenderWidth(mtextContent.text, textHeight),
1695
+ position: mtextContent.anchorPoint,
1696
+ rotation: this.textRotation,
1697
+ directionVector: this.textDirection,
1698
+ attachmentPoint: this.textAttachmentPoint,
1699
+ drawingDirection: this.textDrawingDirection,
1700
+ lineSpaceFactor: this.textLineSpacingFactor
1701
+ };
1702
+ // MLeader draws multiple primitives as a group. Delayed MText rendering is
1703
+ // only scheduled for top-level entities, so render nested MText eagerly.
1704
+ entities.push(renderer.mtext(mtextData, this.getTextStyle(), false));
1705
+ }
1706
+ traits.color = originalColor;
1707
+ traits.rgbColor = originalRgbColor;
1708
+ traits.lineType = originalLineType;
1709
+ traits.lineWeight = originalLineWeight;
1710
+ if (entities.length === 0)
1711
+ return undefined;
1712
+ return entities.length === 1 ? entities[0] : renderer.group(entities);
1713
+ };
1714
+ /**
1715
+ * Writes this multileader entity to DXF group codes.
1716
+ *
1717
+ * @param filer DXF filer that receives serialized values.
1718
+ * @returns The current entity instance for chaining.
1719
+ */
1720
+ AcDbMLeader.prototype.dxfOutFields = function (filer) {
1721
+ var _a;
1722
+ _super.prototype.dxfOutFields.call(this, filer);
1723
+ filer.writeSubclassMarker('AcDbMLeader');
1724
+ filer.writeInt16(170, this.leaderLineType);
1725
+ filer.writeBoolean(290, this.doglegEnabled);
1726
+ filer.writeDouble(41, this.doglegLength);
1727
+ filer.writeInt16(172, this.contentType);
1728
+ filer.writeVector3d(210, this.normal);
1729
+ filer.writeHandle(340, this.mleaderStyleId);
1730
+ if (this._landingPoint)
1731
+ filer.writePoint3d(10, this._landingPoint);
1732
+ filer.writeVector3d(11, this.doglegVector);
1733
+ if (this._mtextContent) {
1734
+ filer.writeString(1, this._mtextContent.text);
1735
+ filer.writePoint3d(12, this._mtextContent.anchorPoint);
1736
+ filer.writeDouble(40, this.textHeight);
1737
+ filer.writeDouble(42, this.textWidth);
1738
+ filer.writeAngle(50, this.textRotation);
1739
+ filer.writeString(7, this.textStyleName);
1740
+ }
1741
+ if (this._blockContent) {
1742
+ filer.writeHandle(341, (_a = this._blockContent.blockContentId) !== null && _a !== void 0 ? _a : '');
1743
+ if (this._blockContent.position) {
1744
+ filer.writePoint3d(15, this._blockContent.position);
1745
+ }
1746
+ filer.writeVector3d(16, this._blockContent.scale);
1747
+ filer.writeAngle(52, this._blockContent.rotation);
1748
+ }
1749
+ this._leaders.forEach(function (leader) {
1750
+ if (leader.landingPoint)
1751
+ filer.writePoint3d(110, leader.landingPoint);
1752
+ if (leader.doglegVector)
1753
+ filer.writeVector3d(111, leader.doglegVector);
1754
+ filer.writeDouble(140, leader.doglegLength);
1755
+ filer.writeInt16(171, leader.leaderLines.length);
1756
+ leader.leaderLines.forEach(function (line) {
1757
+ filer.writeInt16(90, line.vertices.length);
1758
+ line.vertices.forEach(function (point) { return filer.writePoint3d(10, point); });
1759
+ });
1760
+ });
1761
+ return this;
1762
+ };
1763
+ /**
1764
+ * Creates a concrete point from point-like input.
1765
+ *
1766
+ * @param point Source point-like value.
1767
+ * @returns A newly created point instance.
1768
+ */
1769
+ AcDbMLeader.prototype.createPoint = function (point) {
1770
+ return new AcGePoint3d().copy(point);
1771
+ };
1772
+ /**
1773
+ * Normalizes one leader-line payload into internal storage format.
1774
+ *
1775
+ * @param line Source leader-line payload.
1776
+ * @returns A normalized leader line.
1777
+ */
1778
+ AcDbMLeader.prototype.createLeaderLine = function (line) {
1779
+ var _this = this;
1780
+ var _a, _b, _c, _d;
1781
+ return {
1782
+ vertices: (_b = (_a = line.vertices) === null || _a === void 0 ? void 0 : _a.map(function (point) { return _this.createPoint(point); })) !== null && _b !== void 0 ? _b : [],
1783
+ breakPointIndexes: line.breakPointIndexes
1784
+ ? __spreadArray([], __read(line.breakPointIndexes), false) : [],
1785
+ leaderLineIndex: line.leaderLineIndex,
1786
+ breaks: (_d = (_c = line.breaks) === null || _c === void 0 ? void 0 : _c.map(function (item) { return ({
1787
+ index: item.index,
1788
+ start: _this.createPoint(item.start),
1789
+ end: _this.createPoint(item.end)
1790
+ }); })) !== null && _d !== void 0 ? _d : []
1791
+ };
1792
+ };
1793
+ /**
1794
+ * Creates a deep clone of a leader branch.
1795
+ *
1796
+ * @param leader Leader branch to clone.
1797
+ * @returns A deep-cloned leader branch.
1798
+ */
1799
+ AcDbMLeader.prototype.cloneLeader = function (leader) {
1800
+ var _a, _b, _c;
1801
+ return {
1802
+ lastLeaderLinePoint: (_a = leader.lastLeaderLinePoint) === null || _a === void 0 ? void 0 : _a.clone(),
1803
+ lastLeaderLinePointSet: leader.lastLeaderLinePointSet,
1804
+ landingPoint: (_b = leader.landingPoint) === null || _b === void 0 ? void 0 : _b.clone(),
1805
+ doglegVector: (_c = leader.doglegVector) === null || _c === void 0 ? void 0 : _c.clone(),
1806
+ doglegVectorSet: leader.doglegVectorSet,
1807
+ doglegLength: leader.doglegLength,
1808
+ breaks: leader.breaks.map(function (item) { return ({
1809
+ index: item.index,
1810
+ start: item.start.clone(),
1811
+ end: item.end.clone()
1812
+ }); }),
1813
+ leaderBranchIndex: leader.leaderBranchIndex,
1814
+ directionType: leader.directionType,
1815
+ leaderLines: leader.leaderLines.map(function (line) { return ({
1816
+ vertices: line.vertices.map(function (point) { return point.clone(); }),
1817
+ breakPointIndexes: __spreadArray([], __read(line.breakPointIndexes), false),
1818
+ leaderLineIndex: line.leaderLineIndex,
1819
+ breaks: line.breaks.map(function (item) { return ({
1820
+ index: item.index,
1821
+ start: item.start.clone(),
1822
+ end: item.end.clone()
1823
+ }); })
1824
+ }); })
1825
+ };
1826
+ };
1827
+ /**
1828
+ * Validates that a leader index is in range.
1829
+ *
1830
+ * @param leaderIndex Leader branch index to validate.
1831
+ * @throws {Error} Thrown when `leaderIndex` is outside valid range.
1832
+ * @returns `void`.
1833
+ */
1834
+ AcDbMLeader.prototype.checkLeaderIndex = function (leaderIndex) {
1835
+ if (leaderIndex < 0 || leaderIndex >= this._leaders.length) {
1836
+ throw new Error('The leader index is out of range!');
1837
+ }
1838
+ };
1839
+ /**
1840
+ * Gets a mutable leader line by branch and line index.
1841
+ *
1842
+ * @param leaderIndex Leader branch index.
1843
+ * @param leaderLineIndex Leader-line index in the branch.
1844
+ * @returns The mutable leader line reference.
1845
+ */
1846
+ AcDbMLeader.prototype.getMutableLeaderLine = function (leaderIndex, leaderLineIndex) {
1847
+ this.checkLeaderIndex(leaderIndex);
1848
+ var line = this._leaders[leaderIndex].leaderLines[leaderLineIndex];
1849
+ if (!line) {
1850
+ throw new Error('The leader line index is out of range!');
1851
+ }
1852
+ return line;
1853
+ };
1854
+ /**
1855
+ * Collects all geometry points contributing to draw/extents calculations.
1856
+ *
1857
+ * @returns Geometry point collection.
1858
+ */
1859
+ AcDbMLeader.prototype.collectGeometryPoints = function () {
1860
+ var _this = this;
1861
+ var _a;
1862
+ var points = [];
1863
+ this._leaders.forEach(function (leader) {
1864
+ if (leader.lastLeaderLinePoint)
1865
+ points.push(leader.lastLeaderLinePoint);
1866
+ if (leader.landingPoint)
1867
+ points.push(leader.landingPoint);
1868
+ leader.breaks.forEach(function (item) { return points.push(item.start, item.end); });
1869
+ leader.leaderLines.forEach(function (line) {
1870
+ points.push.apply(points, __spreadArray([], __read(line.vertices), false));
1871
+ line.breaks.forEach(function (item) { return points.push(item.start, item.end); });
1872
+ });
1873
+ var doglegPoints = _this.getDoglegPoints(leader);
1874
+ if (doglegPoints)
1875
+ points.push.apply(points, __spreadArray([], __read(doglegPoints), false));
1876
+ leader.leaderLines.forEach(function (line) {
1877
+ var arrowPoints = _this.getArrowheadPoints(_this.getLeaderLineDrawPoints(leader, line));
1878
+ if (arrowPoints)
1879
+ points.push.apply(points, __spreadArray([], __read(arrowPoints), false));
1880
+ });
1881
+ });
1882
+ if (this._landingPoint)
1883
+ points.push(this._landingPoint);
1884
+ if (this.contentBasePosition)
1885
+ points.push(this.contentBasePosition);
1886
+ if (this.textAnchor)
1887
+ points.push(this.textAnchor);
1888
+ if (this._mtextContent)
1889
+ points.push(this._mtextContent.anchorPoint);
1890
+ if ((_a = this._blockContent) === null || _a === void 0 ? void 0 : _a.position)
1891
+ points.push(this._blockContent.position);
1892
+ if (this.planeOrigin)
1893
+ points.push(this.planeOrigin);
1894
+ return points;
1895
+ };
1896
+ /**
1897
+ * Resolves the final draw points for a leader line.
1898
+ *
1899
+ * @param leader Owning leader branch.
1900
+ * @param line Leader line to resolve.
1901
+ * @returns The resolved draw-point sequence.
1902
+ */
1903
+ AcDbMLeader.prototype.getLeaderLineDrawPoints = function (leader, line) {
1904
+ var _a, _b, _c;
1905
+ if (line.vertices.length >= 2)
1906
+ return line.vertices;
1907
+ if (line.vertices.length === 0)
1908
+ return [];
1909
+ var end = (_c = (_b = (_a = leader.lastLeaderLinePoint) !== null && _a !== void 0 ? _a : leader.landingPoint) !== null && _b !== void 0 ? _b : this._landingPoint) !== null && _c !== void 0 ? _c : this.contentBasePosition;
1910
+ if (!end || line.vertices[0].equals(end))
1911
+ return line.vertices;
1912
+ return [line.vertices[0], end];
1913
+ };
1914
+ /**
1915
+ * Computes the dogleg segment points for a leader branch.
1916
+ *
1917
+ * @param leader Leader branch to evaluate.
1918
+ * @returns Dogleg segment points, or `undefined` if not applicable.
1919
+ */
1920
+ AcDbMLeader.prototype.getDoglegPoints = function (leader) {
1921
+ var _a, _b, _c, _d;
1922
+ if (!this.getResolvedDoglegEnabled())
1923
+ return undefined;
1924
+ var start = (_b = (_a = leader.lastLeaderLinePoint) !== null && _a !== void 0 ? _a : leader.landingPoint) !== null && _b !== void 0 ? _b : this._landingPoint;
1925
+ var vector = (_c = leader.doglegVector) !== null && _c !== void 0 ? _c : this._doglegVector;
1926
+ var length = (_d = leader.doglegLength) !== null && _d !== void 0 ? _d : this.getResolvedDoglegLength();
1927
+ if (!start || length == null || length === 0 || vector.lengthSq() === 0) {
1928
+ return undefined;
1929
+ }
1930
+ var end = start
1931
+ .clone()
1932
+ .add(vector.clone().normalize().multiplyScalar(length));
1933
+ return [start, end];
1934
+ };
1935
+ /**
1936
+ * Builds arrowhead polyline points from leader-line points.
1937
+ *
1938
+ * @param points Leader-line points where the first point is treated as tip.
1939
+ * @returns Arrowhead points, or `undefined` when no arrowhead is drawable.
1940
+ */
1941
+ AcDbMLeader.prototype.getArrowheadPoints = function (points) {
1942
+ if (!this.isArrowheadVisible() || points.length < 2)
1943
+ return undefined;
1944
+ var frame = this.getArrowheadFrame(points);
1945
+ if (!frame)
1946
+ return undefined;
1947
+ var size = this.getResolvedArrowheadSize();
1948
+ var tip = frame.tip, unit = frame.unit;
1949
+ var baseCenter = tip.clone().add(unit.clone().multiplyScalar(size));
1950
+ var halfWidth = size / 6;
1951
+ var perpendicular = new AcGeVector3d(-unit.y, unit.x, 0);
1952
+ var left = baseCenter
1953
+ .clone()
1954
+ .add(perpendicular.clone().multiplyScalar(halfWidth));
1955
+ var right = baseCenter
1956
+ .clone()
1957
+ .add(perpendicular.clone().multiplyScalar(-halfWidth));
1958
+ return [tip, left, right, tip];
1959
+ };
1960
+ /**
1961
+ * Checks whether an arrowhead should be rendered.
1962
+ *
1963
+ * @returns `true` if arrowhead configuration is visible.
1964
+ */
1965
+ AcDbMLeader.prototype.isArrowheadVisible = function () {
1966
+ var arrowId = this.getResolvedArrowheadId();
1967
+ if ((arrowId === null || arrowId === void 0 ? void 0 : arrowId.toUpperCase()) === '_NONE')
1968
+ return false;
1969
+ return this.getResolvedArrowheadSize() > 0;
1970
+ };
1971
+ /**
1972
+ * Draws one leader line and applies arrow style from MLEADER/MLEADERSTYLE.
1973
+ *
1974
+ * @param renderer Graphics renderer used to create primitives.
1975
+ * @param points Leader-line draw points.
1976
+ * @returns One entity or an entity group representing the full leader line.
1977
+ */
1978
+ AcDbMLeader.prototype.drawLeaderLine = function (renderer, points) {
1979
+ var entities = [];
1980
+ var linePoints = this.getLeaderLinePointsForDraw(points);
1981
+ if (linePoints.length >= 2) {
1982
+ entities.push(renderer.lines(linePoints));
1983
+ }
1984
+ var arrow = this.drawArrowhead(renderer, points);
1985
+ if (arrow)
1986
+ entities.push(arrow);
1987
+ if (entities.length === 0)
1988
+ return undefined;
1989
+ return entities.length === 1 ? entities[0] : renderer.group(entities);
1990
+ };
1991
+ /**
1992
+ * Resolves leader-line points used for stroke drawing after arrow overlap trim.
1993
+ *
1994
+ * @param points Original leader polyline points.
1995
+ * @returns Trimmed points used to draw the leader stroke.
1996
+ */
1997
+ AcDbMLeader.prototype.getLeaderLinePointsForDraw = function (points) {
1998
+ var trimDistance = this.getArrowheadLeaderLineTrimDistance();
1999
+ if (trimDistance <= 0)
2000
+ return points;
2001
+ return this.trimPolylineStart(points, trimDistance);
2002
+ };
2003
+ /**
2004
+ * Resolves how much of leader start should be trimmed to avoid arrow overlap.
2005
+ *
2006
+ * @returns Trim distance in drawing units.
2007
+ */
2008
+ AcDbMLeader.prototype.getArrowheadLeaderLineTrimDistance = function () {
2009
+ var e_1, _a;
2010
+ var _b;
2011
+ if (!this.isArrowheadVisible())
2012
+ return 0;
2013
+ var blockTableRecord = this.getResolvedArrowheadBlockTableRecord();
2014
+ if (!blockTableRecord)
2015
+ return 0;
2016
+ var size = this.getResolvedArrowheadSize();
2017
+ if (size <= 0)
2018
+ return 0;
2019
+ var basePoint = (_b = blockTableRecord.origin) !== null && _b !== void 0 ? _b : AcGePoint3d.ORIGIN;
2020
+ var maxX = basePoint.x;
2021
+ try {
2022
+ for (var _c = __values(blockTableRecord.newIterator()), _d = _c.next(); !_d.done; _d = _c.next()) {
2023
+ var entity = _d.value;
2024
+ var extents = entity.geometricExtents;
2025
+ if (extents.isEmpty())
2026
+ continue;
2027
+ if (extents.max.x > maxX)
2028
+ maxX = extents.max.x;
2029
+ }
2030
+ }
2031
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2032
+ finally {
2033
+ try {
2034
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
2035
+ }
2036
+ finally { if (e_1) throw e_1.error; }
2037
+ }
2038
+ return Math.max(0, (maxX - basePoint.x) * size);
2039
+ };
2040
+ /**
2041
+ * Trims the start of a polyline by a given distance.
2042
+ *
2043
+ * @param points Polyline points.
2044
+ * @param trimDistance Distance to trim from the start.
2045
+ * @returns Trimmed polyline points.
2046
+ */
2047
+ AcDbMLeader.prototype.trimPolylineStart = function (points, trimDistance) {
2048
+ if (points.length < 2 || trimDistance <= 0)
2049
+ return points;
2050
+ var remaining = trimDistance;
2051
+ for (var i = 0; i < points.length - 1; i++) {
2052
+ var start = points[i];
2053
+ var end = points[i + 1];
2054
+ var segment = end.distanceTo(start);
2055
+ if (segment <= 0)
2056
+ continue;
2057
+ if (remaining < segment) {
2058
+ var direction = new AcGeVector3d().subVectors(end, start);
2059
+ var newStart = start
2060
+ .clone()
2061
+ .add(direction.multiplyScalar(remaining / segment));
2062
+ return __spreadArray([newStart], __read(points.slice(i + 1)), false);
2063
+ }
2064
+ remaining -= segment;
2065
+ }
2066
+ return [points[points.length - 1]];
2067
+ };
2068
+ /**
2069
+ * Draws one arrowhead primitive from leader-line points.
2070
+ *
2071
+ * @param renderer Graphics renderer used to create primitives.
2072
+ * @param points Leader-line points where the first point is treated as tip.
2073
+ * @returns Arrowhead entity, or `undefined` when no arrowhead is drawable.
2074
+ */
2075
+ AcDbMLeader.prototype.drawArrowhead = function (renderer, points) {
2076
+ if (!this.isArrowheadVisible())
2077
+ return undefined;
2078
+ var blockArrow = this.drawArrowheadBlock(renderer, points);
2079
+ if (blockArrow)
2080
+ return blockArrow;
2081
+ var arrowPoints = this.getArrowheadPoints(points);
2082
+ if (!arrowPoints)
2083
+ return undefined;
2084
+ var area = new AcGeArea2d();
2085
+ area.add(new AcGePolyline2d(arrowPoints, true));
2086
+ var traits = renderer.subEntityTraits;
2087
+ var originalFillType = traits.fillType;
2088
+ traits.fillType = {
2089
+ solidFill: true,
2090
+ patternAngle: 0,
2091
+ definitionLines: []
2092
+ };
2093
+ var entity = renderer.area(area);
2094
+ traits.fillType = originalFillType;
2095
+ return entity;
2096
+ };
2097
+ /**
2098
+ * Draws arrowhead by rendering entities from referenced arrow block record.
2099
+ *
2100
+ * @param renderer Graphics renderer used to create primitives.
2101
+ * @param points Leader-line points where the first point is treated as tip.
2102
+ * @returns Rendered block-based arrowhead entity, or `undefined`.
2103
+ */
2104
+ AcDbMLeader.prototype.drawArrowheadBlock = function (renderer, points) {
2105
+ var _a;
2106
+ var blockTableRecord = this.getResolvedArrowheadBlockTableRecord();
2107
+ if (!blockTableRecord)
2108
+ return undefined;
2109
+ var frame = this.getArrowheadFrame(points);
2110
+ if (!frame)
2111
+ return undefined;
2112
+ var tip = frame.tip, unit = frame.unit;
2113
+ var size = this.getResolvedArrowheadSize();
2114
+ var angle = Math.atan2(unit.y, unit.x);
2115
+ var basePoint = (_a = blockTableRecord.origin) !== null && _a !== void 0 ? _a : AcGePoint3d.ORIGIN;
2116
+ var mBase = new AcGeMatrix3d().makeTranslation(-basePoint.x, -basePoint.y, -basePoint.z);
2117
+ var mScale = new AcGeMatrix3d().makeScale(size, size, size);
2118
+ var mRot = new AcGeMatrix3d().makeRotationZ(angle);
2119
+ var mInsert = new AcGeMatrix3d().makeTranslation(tip.x, tip.y, tip.z);
2120
+ var transform = new AcGeMatrix3d()
2121
+ .multiplyMatrices(mInsert, mRot)
2122
+ .multiply(mScale)
2123
+ .multiply(mBase);
2124
+ return AcDbRenderingCache.instance.draw(renderer, blockTableRecord, this.rgbColor, [], true, transform, new AcGeVector3d(this.normal));
2125
+ };
2126
+ /**
2127
+ * Resolves tip point and direction for arrowhead placement.
2128
+ *
2129
+ * @param points Leader-line points where the first point is treated as tip.
2130
+ * @returns Tip and normalized direction, or `undefined` when unavailable.
2131
+ */
2132
+ AcDbMLeader.prototype.getArrowheadFrame = function (points) {
2133
+ if (points.length < 2)
2134
+ return undefined;
2135
+ var tip = points[0];
2136
+ var next = points.find(function (point) { return !point.equals(tip); });
2137
+ if (!next)
2138
+ return undefined;
2139
+ var direction = new AcGeVector3d().subVectors(next, tip);
2140
+ if (direction.lengthSq() === 0)
2141
+ return undefined;
2142
+ return {
2143
+ tip: tip,
2144
+ unit: direction.normalize()
2145
+ };
2146
+ };
2147
+ /**
2148
+ * Resolves the effective arrowhead id.
2149
+ *
2150
+ * @returns Arrowhead id used for rendering.
2151
+ */
2152
+ AcDbMLeader.prototype.getResolvedArrowheadId = function () {
2153
+ var _a, _b;
2154
+ var styleArrowId = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.arrowSymbolId;
2155
+ return (_b = this.arrowheadId) !== null && _b !== void 0 ? _b : styleArrowId;
2156
+ };
2157
+ /**
2158
+ * Resolves arrowhead block record by Arrowhead ID handle.
2159
+ *
2160
+ * @returns Arrowhead block table record, or `undefined` when not found.
2161
+ */
2162
+ AcDbMLeader.prototype.getResolvedArrowheadBlockTableRecord = function () {
2163
+ var arrowId = this.getResolvedArrowheadId();
2164
+ if (!arrowId)
2165
+ return undefined;
2166
+ return this.database.tables.blockTable.getIdAt(arrowId);
2167
+ };
2168
+ /**
2169
+ * Resolves the effective arrowhead size.
2170
+ *
2171
+ * @returns Arrowhead size used for rendering.
2172
+ */
2173
+ AcDbMLeader.prototype.getResolvedArrowheadSize = function () {
2174
+ var _a, _b, _c, _d;
2175
+ var style = this.getMLeaderStyle();
2176
+ var styleArrowSize = (_a = style === null || style === void 0 ? void 0 : style.arrowSize) !== null && _a !== void 0 ? _a : style === null || style === void 0 ? void 0 : style.scale;
2177
+ return ((_d = (_c = (_b = this.arrowheadSize) !== null && _b !== void 0 ? _b : this.contentScale) !== null && _c !== void 0 ? _c : styleArrowSize) !== null && _d !== void 0 ? _d : this.getResolvedTextHeight());
2178
+ };
2179
+ /**
2180
+ * Resolves effective text height by style and override-flag rules.
2181
+ *
2182
+ * @returns Effective text height used for rendering.
2183
+ */
2184
+ AcDbMLeader.prototype.getResolvedTextHeight = function () {
2185
+ var _a;
2186
+ var styleTextHeight = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.textHeight;
2187
+ if (this.textHeight > 0)
2188
+ return this.textHeight;
2189
+ if (styleTextHeight != null && styleTextHeight > 0)
2190
+ return styleTextHeight;
2191
+ return 2.5;
2192
+ };
2193
+ /**
2194
+ * Resolves renderable MText content using entity content first, with style fallback.
2195
+ *
2196
+ * @returns Renderable text payload, or `undefined` when unavailable.
2197
+ */
2198
+ AcDbMLeader.prototype.getRenderableMTextContent = function () {
2199
+ var _a, _b, _c;
2200
+ if (this._mtextContent) {
2201
+ return {
2202
+ text: this._mtextContent.text,
2203
+ anchorPoint: this._mtextContent.anchorPoint
2204
+ };
2205
+ }
2206
+ var defaultText = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.defaultMTextContents;
2207
+ var anchorPoint = (_c = (_b = this.textAnchor) !== null && _b !== void 0 ? _b : this.contentBasePosition) !== null && _c !== void 0 ? _c : this._landingPoint;
2208
+ if (!defaultText || !anchorPoint)
2209
+ return undefined;
2210
+ return {
2211
+ text: defaultText,
2212
+ anchorPoint: anchorPoint
2213
+ };
2214
+ };
2215
+ /**
2216
+ * Computes render width for current MText content.
2217
+ *
2218
+ * @param text Source MText content string.
2219
+ * @param textHeight Effective text height used for fallback estimation.
2220
+ * @returns Explicit width or an estimated width based on plain text length.
2221
+ */
2222
+ AcDbMLeader.prototype.getMTextRenderWidth = function (text, textHeight) {
2223
+ if (this._textWidth > 0)
2224
+ return this._textWidth;
2225
+ if (!text)
2226
+ return this._textWidth;
2227
+ var plainText = text
2228
+ .replace(/\\[PpNn]/g, '\n')
2229
+ .replace(/\\[A-Za-z][^;]*;/g, '')
2230
+ .replace(/[{}]/g, '');
2231
+ var longestLineLength = Math.max.apply(Math, __spreadArray(__spreadArray([], __read(plainText.split(/\r\n|\r|\n/g).map(function (line) { return line.length; })), false), [1], false));
2232
+ return Math.max(textHeight, longestLineLength * textHeight);
2233
+ };
2234
+ /**
2235
+ * Transforms a direction vector with an affine matrix.
2236
+ *
2237
+ * @param vector Vector to mutate.
2238
+ * @param matrix Transformation matrix.
2239
+ * @returns `void`.
2240
+ */
2241
+ AcDbMLeader.prototype.transformVector = function (vector, matrix) {
2242
+ var origin = new AcGePoint3d();
2243
+ var endpoint = new AcGePoint3d(vector.x, vector.y, vector.z);
2244
+ origin.applyMatrix4(matrix);
2245
+ endpoint.applyMatrix4(matrix);
2246
+ vector.set(endpoint.x - origin.x, endpoint.y - origin.y, endpoint.z - origin.z);
2247
+ };
2248
+ /**
2249
+ * Resolves the referenced MLeader style object.
2250
+ *
2251
+ * @returns Resolved style object or `undefined` when not available.
2252
+ */
2253
+ AcDbMLeader.prototype.getMLeaderStyle = function () {
2254
+ var dictionary = this.database.objects.mleaderStyle;
2255
+ var styleId = this.mleaderStyleId || this.leaderStyleId;
2256
+ if (styleId) {
2257
+ var style = dictionary.getIdAt(styleId);
2258
+ if (style)
2259
+ return style;
2260
+ }
2261
+ return this.getDefaultMLeaderStyle();
2262
+ };
2263
+ /**
2264
+ * Resolves the default MLEADER style from CMLEADERSTYLE, with first-entry fallback.
2265
+ *
2266
+ * @returns Default style object or `undefined` when style dictionary is empty.
2267
+ */
2268
+ AcDbMLeader.prototype.getDefaultMLeaderStyle = function () {
2269
+ var bySysVar = this.resolveMLeaderStyleByName(this.getDefaultMLeaderStyleName());
2270
+ if (bySysVar)
2271
+ return bySysVar;
2272
+ return this.database.objects.mleaderStyle.newIterator().toArray()[0];
2273
+ };
2274
+ /**
2275
+ * Resolves one MLEADER style by style name (dictionary key) or object ID.
2276
+ *
2277
+ * @param styleName Style name or object id candidate.
2278
+ * @returns Matching style object, or `undefined` when not found.
2279
+ */
2280
+ AcDbMLeader.prototype.resolveMLeaderStyleByName = function (styleName) {
2281
+ var e_2, _a;
2282
+ var rawName = styleName === null || styleName === void 0 ? void 0 : styleName.trim();
2283
+ if (!rawName)
2284
+ return undefined;
2285
+ var dictionary = this.database.objects.mleaderStyle;
2286
+ var directByName = dictionary.getAt(rawName);
2287
+ if (directByName)
2288
+ return directByName;
2289
+ var directById = dictionary.getIdAt(rawName);
2290
+ if (directById)
2291
+ return directById;
2292
+ var normalizedStyleName = rawName.toUpperCase();
2293
+ try {
2294
+ for (var _b = __values(dictionary.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
2295
+ var _d = __read(_c.value, 2), name_1 = _d[0], style = _d[1];
2296
+ if (name_1.toUpperCase() === normalizedStyleName) {
2297
+ return style;
2298
+ }
2299
+ }
2300
+ }
2301
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2302
+ finally {
2303
+ try {
2304
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2305
+ }
2306
+ finally { if (e_2) throw e_2.error; }
2307
+ }
2308
+ return undefined;
2309
+ };
2310
+ /**
2311
+ * Resolves current CMLEADERSTYLE value with a stable default fallback.
2312
+ *
2313
+ * @returns Preferred default style name.
2314
+ */
2315
+ AcDbMLeader.prototype.getDefaultMLeaderStyleName = function () {
2316
+ try {
2317
+ return this.database.cmleaderstyle || DEFAULT_MLEADER_STYLE;
2318
+ }
2319
+ catch (_a) {
2320
+ return DEFAULT_MLEADER_STYLE;
2321
+ }
2322
+ };
2323
+ /**
2324
+ * Resolves text style name considering entity values, ids and style fallback.
2325
+ *
2326
+ * @returns Resolved text style name, or `undefined` when unresolved.
2327
+ */
2328
+ AcDbMLeader.prototype.getResolvedTextStyleName = function () {
2329
+ var _a, _b;
2330
+ var textStyleTable = this.database.tables.textStyleTable;
2331
+ var styleIdFromStyle = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.textStyleId;
2332
+ var styleNameFromStyleId = styleIdFromStyle
2333
+ ? (_b = textStyleTable.getIdAt(styleIdFromStyle)) === null || _b === void 0 ? void 0 : _b.name
2334
+ : undefined;
2335
+ if (this.textStyleName)
2336
+ return this.textStyleName;
2337
+ var directStyle = this.textStyleId
2338
+ ? textStyleTable.getIdAt(this.textStyleId)
2339
+ : undefined;
2340
+ if (directStyle === null || directStyle === void 0 ? void 0 : directStyle.name)
2341
+ return directStyle.name;
2342
+ return styleNameFromStyleId;
2343
+ };
2344
+ /**
2345
+ * Resolves the text style used by renderer-side MText drawing.
2346
+ *
2347
+ * @returns A valid text style object.
2348
+ */
2349
+ AcDbMLeader.prototype.getTextStyle = function () {
2350
+ var _a, _b;
2351
+ var textStyleTable = this.database.tables.textStyleTable;
2352
+ var textStyleName = this.getResolvedTextStyleName();
2353
+ var style = (_b = (_a = (textStyleName ? textStyleTable.getAt(textStyleName) : undefined)) !== null && _a !== void 0 ? _a : textStyleTable.getAt(this.database.textstyle)) !== null && _b !== void 0 ? _b : textStyleTable.getAt(DEFAULT_TEXT_STYLE);
2354
+ if (!style) {
2355
+ throw new Error('No valid text style found in text style table.');
2356
+ }
2357
+ return style.textStyle;
2358
+ };
2359
+ /**
2360
+ * Resolves effective leader-line color by override-flag and style rules.
2361
+ *
2362
+ * @returns Effective leader-line color.
2363
+ */
2364
+ AcDbMLeader.prototype.getResolvedLeaderLineColor = function () {
2365
+ var _a;
2366
+ return this.getResolvedComponentColor(this.leaderLineColor, (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.leaderLineColor, MLEADER_OVERRIDE_LEADER_LINE_COLOR);
2367
+ };
2368
+ /**
2369
+ * Resolves effective leader-line geometry type.
2370
+ *
2371
+ * @returns Effective leader-line type.
2372
+ */
2373
+ AcDbMLeader.prototype.getResolvedLeaderLineType = function () {
2374
+ var _a;
2375
+ var styleLineType = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.leaderLineType;
2376
+ return this.getResolvedStyleDrivenValue(this.leaderLineType, styleLineType, MLEADER_OVERRIDE_LEADER_LINE_TYPE);
2377
+ };
2378
+ /**
2379
+ * Resolves effective leader-line linetype id/handle.
2380
+ *
2381
+ * @returns Effective linetype id, or `undefined` when not available.
2382
+ */
2383
+ AcDbMLeader.prototype.getResolvedLeaderLineTypeId = function () {
2384
+ var _a;
2385
+ return this.getResolvedStyleDrivenValue(this.leaderLineTypeId, (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.leaderLineTypeId, MLEADER_OVERRIDE_LEADER_LINE_TYPE_ID);
2386
+ };
2387
+ /**
2388
+ * Resolves renderer linetype style for leader lines.
2389
+ *
2390
+ * @returns User-specified renderer linetype style, or `undefined`.
2391
+ */
2392
+ AcDbMLeader.prototype.getResolvedLeaderLineStyle = function () {
2393
+ var lineTypeId = this.getResolvedLeaderLineTypeId();
2394
+ if (!lineTypeId)
2395
+ return undefined;
2396
+ var lineTypeRecord = this.database.tables.linetypeTable.getIdAt(lineTypeId);
2397
+ if (!lineTypeRecord)
2398
+ return undefined;
2399
+ return __assign({ type: 'UserSpecified' }, lineTypeRecord.linetype);
2400
+ };
2401
+ /**
2402
+ * Resolves effective leader-line weight by override-flag and style rules.
2403
+ *
2404
+ * @returns Effective line weight, or `undefined`.
2405
+ */
2406
+ AcDbMLeader.prototype.getResolvedLeaderLineWeight = function () {
2407
+ var _a;
2408
+ var styleLineWeight = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.leaderLineWeight;
2409
+ var lineWeight = this.getResolvedStyleDrivenValue(this.leaderLineWeight, styleLineWeight, MLEADER_OVERRIDE_LEADER_LINE_WEIGHT);
2410
+ if (lineWeight == null)
2411
+ return undefined;
2412
+ return lineWeight;
2413
+ };
2414
+ /**
2415
+ * Resolves whether dogleg drawing is effectively enabled.
2416
+ *
2417
+ * @returns Effective dogleg-enabled state.
2418
+ */
2419
+ AcDbMLeader.prototype.getResolvedDoglegEnabled = function () {
2420
+ var _a;
2421
+ var styleEnabled = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.doglegEnabled;
2422
+ return this.getResolvedStyleDrivenValue(this.doglegEnabled, styleEnabled, MLEADER_OVERRIDE_DOGLEG_ENABLED);
2423
+ };
2424
+ /**
2425
+ * Resolves effective dogleg length by override-flag and style rules.
2426
+ *
2427
+ * @returns Effective dogleg length.
2428
+ */
2429
+ AcDbMLeader.prototype.getResolvedDoglegLength = function () {
2430
+ var _a;
2431
+ var styleLength = (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.doglegLength;
2432
+ return this.getResolvedStyleDrivenValue(this.doglegLength, styleLength, MLEADER_OVERRIDE_DOGLEG_LENGTH);
2433
+ };
2434
+ /**
2435
+ * Resolves effective text color by override-flag and style rules.
2436
+ *
2437
+ * @returns Effective text color.
2438
+ */
2439
+ AcDbMLeader.prototype.getResolvedTextColor = function () {
2440
+ var _a;
2441
+ return this.getResolvedComponentColor(this.textColor, (_a = this.getMLeaderStyle()) === null || _a === void 0 ? void 0 : _a.textColor, MLEADER_OVERRIDE_TEXT_COLOR);
2442
+ };
2443
+ /**
2444
+ * Resolves effective component color from entity raw value and style fallback.
2445
+ *
2446
+ * @param rawEntityColor Raw DXF color value stored on the entity.
2447
+ * @param styleColor Style-level fallback color.
2448
+ * @param overrideFlagMask Property-override flag mask for this component.
2449
+ * @returns Effective color used for rendering and trait application.
2450
+ */
2451
+ AcDbMLeader.prototype.getResolvedComponentColor = function (rawEntityColor, styleColor, overrideFlagMask) {
2452
+ var entityColor = rawEntityColor != null
2453
+ ? decodeMLeaderStyleRawColor(rawEntityColor)
2454
+ : undefined;
2455
+ if (!entityColor)
2456
+ return styleColor;
2457
+ var overrideEnabled = this.isPropertyOverrideEnabled(overrideFlagMask);
2458
+ if (overrideEnabled === true)
2459
+ return entityColor;
2460
+ if (overrideEnabled === false)
2461
+ return styleColor !== null && styleColor !== void 0 ? styleColor : entityColor;
2462
+ // Some DXF producers always write entity color fields as ByBlock/ByLayer even
2463
+ // when no override flag is enabled. Prefer style color in that ambiguous case.
2464
+ if (!entityColor.isByBlock && !entityColor.isByLayer) {
2465
+ return entityColor;
2466
+ }
2467
+ return styleColor !== null && styleColor !== void 0 ? styleColor : entityColor;
2468
+ };
2469
+ /**
2470
+ * Resolves effective value using override-flag and style fallback rules.
2471
+ *
2472
+ * @typeParam T Value type.
2473
+ * @param entityValue Value stored on the entity.
2474
+ * @param styleValue Value provided by style.
2475
+ * @param overrideFlagMask Property-override flag mask for this component.
2476
+ * @returns Effective resolved value.
2477
+ */
2478
+ AcDbMLeader.prototype.getResolvedStyleDrivenValue = function (entityValue, styleValue, overrideFlagMask) {
2479
+ var overrideEnabled = this.isPropertyOverrideEnabled(overrideFlagMask);
2480
+ if (overrideEnabled === true)
2481
+ return entityValue !== null && entityValue !== void 0 ? entityValue : styleValue;
2482
+ if (overrideEnabled === false)
2483
+ return styleValue !== null && styleValue !== void 0 ? styleValue : entityValue;
2484
+ return styleValue !== null && styleValue !== void 0 ? styleValue : entityValue;
2485
+ };
2486
+ /**
2487
+ * Checks whether a specific property-override bit is enabled.
2488
+ *
2489
+ * @param flagMask Bit mask for the property being queried.
2490
+ * @returns `true` if enabled, `false` if disabled, or `undefined` when flag is absent.
2491
+ */
2492
+ AcDbMLeader.prototype.isPropertyOverrideEnabled = function (flagMask) {
2493
+ if (this.propertyOverrideFlag == null)
2494
+ return undefined;
2495
+ return (this.propertyOverrideFlag & flagMask) !== 0;
2496
+ };
2497
+ /**
2498
+ * Applies color traits while preserving original values for reset.
2499
+ *
2500
+ * @param traits Renderer traits object to mutate.
2501
+ * @param color Effective component color to apply.
2502
+ * @param originalColor Original trait color value.
2503
+ * @param originalRgbColor Original trait RGB value.
2504
+ * @returns `void`.
2505
+ */
2506
+ AcDbMLeader.prototype.applyColorTraits = function (traits, color, originalColor, originalRgbColor) {
2507
+ traits.color = originalColor;
2508
+ traits.rgbColor = originalRgbColor;
2509
+ if (!color)
2510
+ return;
2511
+ traits.color = color;
2512
+ traits.rgbColor = this.resolveColorToRgb(color);
2513
+ };
2514
+ /**
2515
+ * Applies line style traits when resolved values are available.
2516
+ *
2517
+ * @param traits Renderer traits object to mutate.
2518
+ * @param lineType Resolved linetype style.
2519
+ * @param lineWeight Resolved line weight.
2520
+ * @returns `void`.
2521
+ */
2522
+ AcDbMLeader.prototype.applyLineTraits = function (traits, lineType, lineWeight) {
2523
+ if (lineType) {
2524
+ traits.lineType = lineType;
2525
+ }
2526
+ if (lineWeight != null) {
2527
+ traits.lineWeight = lineWeight;
2528
+ }
2529
+ };
2530
+ /**
2531
+ * Converts an `AcCmColor` to resolved RGB for rendering.
2532
+ *
2533
+ * @param color Source color definition.
2534
+ * @returns Resolved RGB integer color.
2535
+ */
2536
+ AcDbMLeader.prototype.resolveColorToRgb = function (color) {
2537
+ var _a;
2538
+ if (color.isByLayer) {
2539
+ var layerColor = this.getLayerColor();
2540
+ if ((layerColor === null || layerColor === void 0 ? void 0 : layerColor.RGB) != null)
2541
+ return layerColor.RGB;
2542
+ return this.rgbColor;
2543
+ }
2544
+ if (color.isByBlock)
2545
+ return this.rgbColor;
2546
+ return (_a = color.RGB) !== null && _a !== void 0 ? _a : this.rgbColor;
2547
+ };
2548
+ /** The entity type name. */
2549
+ AcDbMLeader.typeName = 'MLeader';
2550
+ return AcDbMLeader;
2551
+ }(AcDbEntity));
2552
+ export { AcDbMLeader };
2553
+ //# sourceMappingURL=AcDbMLeader.js.map