@mlightcad/libredwg-converter 3.0.3 → 3.0.5

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.
@@ -1,6 +1,6 @@
1
- import { AcDbArc as S, AcDbCircle as P, AcGeVector3d as h, AcDbEllipse as E, AcDbLine as L, AcGePoint3d as A, AcDbSpline as w, AcDbPoint as C, AcDbTrace as x, AcDbPolyline as I, AcGePoint2d as u, AcDbHatch as v, AcGePolyline2d as O, AcGeLoop2d as R, AcGeLine2d as N, AcGeCircArc2d as V, AcGeVector2d as m, AcGeEllipseArc2d as k, AcGeSpline3d as b, AcDbTable as F, AcDbText as B, AcDbMText as j, AcDbLeader as z, AcDbAlignedDimension as H, AcDb3PointAngularDimension as W, AcDbOrdinateDimension as X, AcDbRadialDimension as G, AcDbDiametricDimension as Y, AcDbRasterImage as U, AcDbViewport as _, AcDbRay as Z, AcDbXline as K, AcDbBlockReference as q, AcDbDatabaseConverter as J, AcDbLinetypeTableRecord as Q, AcDbTextStyleTableRecord as $, AcDbDimStyleTableRecord as ee, AcCmColor as ne, AcDbLayerTableRecord as te, AcDbViewportTableRecord as oe, AcDbBlockTableRecord as se, AcDbBatchProcessing as re, AcDbLayout as ie, AcDbRasterImageDef as ce } from "@mlightcad/data-model";
2
- import { LibreDwg as ae, Dwg_File_Type as le } from "@mlightcad/libredwg-web";
3
- class T {
1
+ import { AcDbArc as S, AcDbCircle as P, AcGeVector3d as h, AcDbEllipse as E, AcDbLine as L, AcGePoint3d as w, AcDbSpline as I, AcDbPoint as C, AcDbTrace as x, AcDbPolyline as b, AcGePoint2d as A, AcDbHatch as v, AcGePolyline2d as O, AcGeLoop2d as R, AcGeLine2d as k, AcGeCircArc2d as N, AcGeVector2d as V, AcGeEllipseArc2d as m, AcGeSpline3d as T, AcDbTable as F, AcDbText as B, AcDbMText as j, AcDbLeader as z, AcDbAlignedDimension as H, AcDb3PointAngularDimension as W, AcDbOrdinateDimension as X, AcDbRadialDimension as G, AcDbDiametricDimension as U, AcDbRasterImage as Y, AcDbViewport as _, AcDbRay as Z, AcDbXline as K, AcDbBlockReference as q, AcDbDatabaseConverter as J, createWorkerApi as Q, AcDbLinetypeTableRecord as $, AcDbTextStyleTableRecord as ee, AcDbDimStyleTableRecord as ne, AcCmColor as te, AcDbLayerTableRecord as oe, AcDbViewportTableRecord as re, AcDbBlockTableRecord as se, AcDbBatchProcessing as ie, AcDbLayout as ce, AcDbRasterImageDef as ae } from "@mlightcad/data-model";
2
+ import { LibreDwg as le, Dwg_File_Type as de } from "@mlightcad/libredwg-web";
3
+ class y {
4
4
  convert(e) {
5
5
  const n = this.createEntity(e);
6
6
  return n && this.processCommonAttrs(e, n), n;
@@ -25,32 +25,32 @@ class T {
25
25
  return new P(e.center, e.radius);
26
26
  }
27
27
  convertEllipse(e) {
28
- const n = new h(e.majorAxisEndPoint), s = n.length();
28
+ const n = new h(e.majorAxisEndPoint), r = n.length();
29
29
  return new E(
30
30
  e.center,
31
31
  h.Z_AXIS,
32
32
  n,
33
- s,
34
- s * e.axisRatio,
33
+ r,
34
+ r * e.axisRatio,
35
35
  e.startAngle,
36
36
  e.endAngle
37
37
  );
38
38
  }
39
39
  convertLine(e) {
40
- const n = e.startPoint, s = e.endPoint;
40
+ const n = e.startPoint, r = e.endPoint;
41
41
  return new L(
42
- new A(n.x, n.y, n.z),
43
- new A(s.x, s.y, s.z)
42
+ new w(n.x, n.y, n.z),
43
+ new w(r.x, r.y, r.z)
44
44
  );
45
45
  }
46
46
  convertSpline(e) {
47
- return e.numberOfControlPoints > 0 && e.numberOfKnots > 0 ? new w(
47
+ return e.numberOfControlPoints > 0 && e.numberOfKnots > 0 ? new I(
48
48
  e.controlPoints,
49
49
  e.knots,
50
50
  e.weights,
51
51
  e.degree,
52
52
  !!(e.flag & 1)
53
- ) : e.numberOfFitPoints > 0 ? new w(
53
+ ) : e.numberOfFitPoints > 0 ? new I(
54
54
  e.fitPoints,
55
55
  "Uniform",
56
56
  e.degree,
@@ -69,26 +69,26 @@ class T {
69
69
  ), n.thickness = e.thickness, n;
70
70
  }
71
71
  convertLWPolyline(e) {
72
- const n = new I();
73
- return n.closed = !!(e.flag & 512), e.vertices.forEach((s, t) => {
72
+ const n = new b();
73
+ return n.closed = !!(e.flag & 512), e.vertices.forEach((r, t) => {
74
74
  n.addVertexAt(
75
75
  t,
76
- new u(s.x, s.y),
77
- s.bulge,
78
- s.startWidth,
79
- s.endWidth
76
+ new A(r.x, r.y),
77
+ r.bulge,
78
+ r.startWidth,
79
+ r.endWidth
80
80
  );
81
81
  }), n;
82
82
  }
83
83
  convertPolyline(e) {
84
- const n = new I();
85
- return n.closed = !!(e.flag & 1), e.vertices.forEach((s, t) => {
84
+ const n = new b();
85
+ return n.closed = !!(e.flag & 1), e.vertices.forEach((r, t) => {
86
86
  n.addVertexAt(
87
87
  t,
88
- new u(s.x, s.y),
89
- s.bulge,
90
- s.startWidth,
91
- s.endWidth
88
+ new A(r.x, r.y),
89
+ r.bulge,
90
+ r.startWidth,
91
+ r.endWidth
92
92
  );
93
93
  }), n;
94
94
  }
@@ -117,11 +117,11 @@ class T {
117
117
  a.edges.forEach((l) => {
118
118
  if (l.type == 1) {
119
119
  const i = l;
120
- c.add(new N(i.start, i.end));
120
+ c.add(new k(i.start, i.end));
121
121
  } else if (l.type == 2) {
122
122
  const i = l;
123
123
  c.add(
124
- new V(
124
+ new N(
125
125
  i.center,
126
126
  i.radius,
127
127
  i.startAngle,
@@ -131,19 +131,19 @@ class T {
131
131
  );
132
132
  } else if (l.type == 3) {
133
133
  const i = l;
134
- new m().subVectors(i.end, i.center);
134
+ new V().subVectors(i.end, i.center);
135
135
  const d = Math.sqrt(
136
136
  Math.pow(i.end.x, 2) + Math.pow(i.end.y, 2)
137
137
  ), p = d * i.lengthOfMinorAxis;
138
- let D = i.startAngle, f = i.endAngle;
138
+ let D = i.startAngle, u = i.endAngle;
139
139
  const M = Math.atan2(i.end.y, i.end.x);
140
- i.isCCW || (D = Math.PI * 2 - D, f = Math.PI * 2 - f), c.add(
141
- new k(
140
+ i.isCCW || (D = Math.PI * 2 - D, u = Math.PI * 2 - u), c.add(
141
+ new m(
142
142
  { ...i.center, z: 0 },
143
143
  d,
144
144
  p,
145
145
  D,
146
- f,
146
+ u,
147
147
  !i.isCCW,
148
148
  M
149
149
  )
@@ -151,7 +151,7 @@ class T {
151
151
  } else if (l.type == 4) {
152
152
  const i = l;
153
153
  if (i.numberOfControlPoints > 0 && i.numberOfKnots > 0) {
154
- const g = i.controlPoints.map(
154
+ const f = i.controlPoints.map(
155
155
  (D) => ({
156
156
  x: D.x,
157
157
  y: D.y,
@@ -161,19 +161,19 @@ class T {
161
161
  let d = !0;
162
162
  const p = i.controlPoints.map((D) => (D.weight == null && (d = !1), D.weight || 1));
163
163
  c.add(
164
- new b(
165
- g,
164
+ new T(
165
+ f,
166
166
  i.knots,
167
167
  d ? p : void 0
168
168
  )
169
169
  );
170
170
  } else if (i.numberOfFitData > 0) {
171
- const g = i.fitDatum.map((d) => ({
171
+ const f = i.fitDatum.map((d) => ({
172
172
  x: d.x,
173
173
  y: d.y,
174
174
  z: 0
175
175
  }));
176
- c.add(new b(g, "Uniform"));
176
+ c.add(new T(f, "Uniform"));
177
177
  }
178
178
  }
179
179
  }), n.add(c);
@@ -187,11 +187,11 @@ class T {
187
187
  e.columnCount
188
188
  );
189
189
  return n.attachmentPoint = e.attachmentPoint, n.position.copy(e.startPoint), e.columnWidthArr.forEach(
190
- (s, t) => n.setColumnWidth(t, s)
190
+ (r, t) => n.setColumnWidth(t, r)
191
191
  ), e.rowHeightArr.forEach(
192
- (s, t) => n.setRowHeight(t, s)
193
- ), e.cells.forEach((s, t) => {
194
- n.setCell(t, s);
192
+ (r, t) => n.setRowHeight(t, r)
193
+ ), e.cells.forEach((r, t) => {
194
+ n.setCell(t, r);
195
195
  }), n;
196
196
  }
197
197
  convertText(e) {
@@ -204,52 +204,52 @@ class T {
204
204
  }
205
205
  convertLeader(e) {
206
206
  const n = new z();
207
- return e.vertices.forEach((s) => {
208
- n.appendVertex(s);
207
+ return e.vertices.forEach((r) => {
208
+ n.appendVertex(r);
209
209
  }), n.hasArrowHead = e.isArrowheadEnabled, n.hasHookLine = e.isHooklineExists, n.isSplined = e.isSpline, n.dimensionStyle = e.styleName, n.annoType = e.leaderCreationFlag, n;
210
210
  }
211
211
  convertDimension(e) {
212
212
  if (e.subclassMarker == "AcDbAlignedDimension" || e.subclassMarker == "AcDbRotatedDimension") {
213
- const n = e, s = new H(
213
+ const n = e, r = new H(
214
214
  n.subDefinitionPoint1,
215
215
  n.subDefinitionPoint2,
216
216
  n.definitionPoint
217
217
  );
218
- return s.rotation = n.rotationAngle, this.processDimensionCommonAttrs(e, s), s;
218
+ return r.rotation = n.rotationAngle, this.processDimensionCommonAttrs(e, r), r;
219
219
  } else if (e.subclassMarker == "AcDb3PointAngularDimension") {
220
- const n = e, s = new W(
220
+ const n = e, r = new W(
221
221
  n.centerPoint,
222
222
  n.subDefinitionPoint1,
223
223
  n.subDefinitionPoint2,
224
224
  n.definitionPoint
225
225
  );
226
- return this.processDimensionCommonAttrs(e, s), s;
226
+ return this.processDimensionCommonAttrs(e, r), r;
227
227
  } else if (e.subclassMarker == "AcDbOrdinateDimension") {
228
- const n = e, s = new X(
228
+ const n = e, r = new X(
229
229
  n.subDefinitionPoint1,
230
230
  n.subDefinitionPoint2
231
231
  );
232
- return this.processDimensionCommonAttrs(e, s), s;
232
+ return this.processDimensionCommonAttrs(e, r), r;
233
233
  } else if (e.subclassMarker == "AcDbRadialDimension") {
234
- const n = e, s = new G(
234
+ const n = e, r = new G(
235
235
  n.definitionPoint,
236
236
  n.centerPoint,
237
237
  n.leaderLength
238
238
  );
239
- return this.processDimensionCommonAttrs(e, s), s;
239
+ return this.processDimensionCommonAttrs(e, r), r;
240
240
  } else if (e.subclassMarker == "AcDbDiametricDimension") {
241
- const n = e, s = new Y(
241
+ const n = e, r = new U(
242
242
  n.definitionPoint,
243
243
  n.centerPoint,
244
244
  n.leaderLength
245
245
  );
246
- return this.processDimensionCommonAttrs(e, s), s;
246
+ return this.processDimensionCommonAttrs(e, r), r;
247
247
  }
248
248
  return null;
249
249
  }
250
250
  processImage(e, n) {
251
- n.position.copy(e.position), n.brightness = e.brightness, n.contrast = e.contrast, n.fade = e.fade, n.imageDefId = e.imageDefHandle.toString(), n.isClipped = (e.flags | 4) > 0, n.isImageShown = (e.flags | 3) > 0, n.isImageTransparent = (e.flags | 8) > 0, e.clippingBoundaryPath.forEach((s) => {
252
- n.clipBoundary.push(new u(s));
251
+ n.position.copy(e.position), n.brightness = e.brightness, n.contrast = e.contrast, n.fade = e.fade, n.imageDefId = e.imageDefHandle.toString(), n.isClipped = (e.flags | 4) > 0, n.isImageShown = (e.flags | 3) > 0, n.isImageTransparent = (e.flags | 8) > 0, e.clippingBoundaryPath.forEach((r) => {
252
+ n.clipBoundary.push(new A(r));
253
253
  }), n.clipBoundaryType = e.clippingBoundaryType, n.width = Math.sqrt(
254
254
  e.uPixel.x ** 2 + e.uPixel.y ** 2 + e.uPixel.z ** 2
255
255
  ) * e.imageSize.x, n.height = Math.sqrt(
@@ -257,7 +257,7 @@ class T {
257
257
  ) * e.imageSize.y, n.rotation = Math.atan2(e.uPixel.y, e.uPixel.x);
258
258
  }
259
259
  convertImage(e) {
260
- const n = new U();
260
+ const n = new Y();
261
261
  return this.processImage(e, n), n;
262
262
  }
263
263
  // private convertWipeout(wipeout: WipeoutEntity) {
@@ -288,18 +288,22 @@ class T {
288
288
  n.layer = e.layer, n.objectId = e.handle.toString(), n.ownerId = e.ownerBlockRecordSoftId.toString(), e.lineType != null && (n.lineType = e.lineType), e.lineweight != null && (n.lineWeight = e.lineweight), e.lineTypeScale != null && (n.linetypeScale = e.lineTypeScale), e.color != null && (n.color.color = e.color), e.colorIndex != null && (n.color.colorIndex = e.colorIndex), e.colorName != null && (n.color.colorName = e.colorName), e.isVisible != null && (n.visibility = e.isVisible), e.transparency != null && (n.transparency = e.transparency);
289
289
  }
290
290
  }
291
- class De extends J {
292
- constructor(e) {
293
- super(), this.libredwg = ae.createByWasmInstance(e);
294
- }
295
- parse(e) {
296
- if (this.libredwg == null)
297
- throw new Error("libredwg is not loaded!");
298
- const n = this.libredwg.dwg_read_data(e, le.DWG);
299
- if (n == null)
300
- throw new Error("Failed to read dwg data!");
301
- const s = this.libredwg.convert(n);
302
- return this.libredwg.dwg_free(n), s;
291
+ async function pe(g) {
292
+ const e = await le.create();
293
+ if (e == null)
294
+ throw new Error("libredwg is not loaded!");
295
+ const n = e.dwg_read_data(g, de.DWG);
296
+ if (n == null)
297
+ throw new Error("Failed to read dwg data!");
298
+ const r = e.convert(n);
299
+ return e.dwg_free(n), r;
300
+ }
301
+ class ue extends J {
302
+ constructor(e = {}) {
303
+ super(e), e.useWorker = !0, e.parserWorkerUrl || (e.parserWorkerUrl = "/assets/libredwg-parser-worker.js");
304
+ }
305
+ async parse(e) {
306
+ return this.config.useWorker && this.config.parserWorkerUrl ? (await Q({ workerUrl: this.config.parserWorkerUrl }).execute(e)).data : await pe(e);
303
307
  }
304
308
  /**
305
309
  * Gets all of fonts used by entities in model space and paper space
@@ -308,42 +312,42 @@ class De extends J {
308
312
  */
309
313
  getFonts(e) {
310
314
  const n = /* @__PURE__ */ new Map();
311
- e.tables.BLOCK_RECORD.entries.forEach((r) => {
312
- n.set(r.name, r);
315
+ e.tables.BLOCK_RECORD.entries.forEach((s) => {
316
+ n.set(s.name, s);
313
317
  });
314
- const s = /* @__PURE__ */ new Map(), t = (r) => {
315
- if (r) {
316
- const a = r.lastIndexOf(".");
317
- return a >= 0 ? r.substring(0, a).toLowerCase() : r.toLowerCase();
318
+ const r = /* @__PURE__ */ new Map(), t = (s) => {
319
+ if (s) {
320
+ const a = s.lastIndexOf(".");
321
+ return a >= 0 ? s.substring(0, a).toLowerCase() : s.toLowerCase();
318
322
  }
319
323
  };
320
- e.tables.STYLE.entries.forEach((r) => {
324
+ e.tables.STYLE.entries.forEach((s) => {
321
325
  const a = [];
322
- let c = t(r.font);
323
- c && a.push(c), c = t(r.bigFont), c && a.push(c), s.set(r.name, a);
326
+ let c = t(s.font);
327
+ c && a.push(c), c = t(s.bigFont), c && a.push(c), r.set(s.name, a);
324
328
  });
325
329
  const o = /* @__PURE__ */ new Set();
326
- return this.getFontsInBlock(e.entities, n, s, o), Array.from(o);
330
+ return this.getFontsInBlock(e.entities, n, r, o), Array.from(o);
327
331
  }
328
332
  /**
329
333
  * Iterate entities in model space to get fonts used by text, mtext and insert entities
330
334
  */
331
- getFontsInBlock(e, n, s, t) {
335
+ getFontsInBlock(e, n, r, t) {
332
336
  const o = /\\f(.*?)\|/g;
333
- e.forEach((r) => {
334
- if (r.type == "MTEXT") {
335
- const a = r;
337
+ e.forEach((s) => {
338
+ if (s.type == "MTEXT") {
339
+ const a = s;
336
340
  [...a.text.matchAll(o)].forEach((l) => {
337
341
  t.add(l[1].toLowerCase());
338
342
  });
339
- const c = s.get(a.styleName);
343
+ const c = r.get(a.styleName);
340
344
  c == null || c.forEach((l) => t.add(l));
341
- } else if (r.type == "TEXT") {
342
- const a = r, c = s.get(a.styleName);
345
+ } else if (s.type == "TEXT") {
346
+ const a = s, c = r.get(a.styleName);
343
347
  c == null || c.forEach((l) => t.add(l));
344
- } else if (r.type == "INSERT") {
345
- const a = r, c = n.get(a.name);
346
- c && this.getFontsInBlock(c.entities, n, s, t);
348
+ } else if (s.type == "INSERT") {
349
+ const a = s, c = n.get(a.name);
350
+ c && this.getFontsInBlock(c.entities, n, r, t);
347
351
  }
348
352
  });
349
353
  }
@@ -355,13 +359,13 @@ class De extends J {
355
359
  standardFlag: t.standardFlag,
356
360
  totalPatternLength: t.totalPatternLength,
357
361
  pattern: t.pattern
358
- }, r = new Q(o);
359
- this.processCommonTableEntryAttrs(t, r), r.name = t.name, n.tables.linetypeTable.add(r);
362
+ }, s = new $(o);
363
+ this.processCommonTableEntryAttrs(t, s), s.name = t.name, n.tables.linetypeTable.add(s);
360
364
  });
361
365
  }
362
366
  processTextStyles(e, n) {
363
367
  e.tables.STYLE.entries.forEach((t) => {
364
- const o = new $(t);
368
+ const o = new ee(t);
365
369
  this.processCommonTableEntryAttrs(t, o), n.tables.textStyleTable.add(o);
366
370
  });
367
371
  }
@@ -441,15 +445,15 @@ class De extends J {
441
445
  // TODO: Set correct value
442
446
  dimlwd: t.DIMLWD,
443
447
  dimlwe: t.DIMLWE
444
- }, r = new ee(o);
445
- this.processCommonTableEntryAttrs(t, r), n.tables.dimStyleTable.add(r);
448
+ }, s = new ne(o);
449
+ this.processCommonTableEntryAttrs(t, s), n.tables.dimStyleTable.add(s);
446
450
  });
447
451
  }
448
452
  processLayers(e, n) {
449
453
  e.tables.LAYER.entries.forEach((t) => {
450
- const o = new ne();
454
+ const o = new te();
451
455
  o.colorIndex = t.colorIndex;
452
- const r = new te({
456
+ const s = new oe({
453
457
  name: t.name,
454
458
  standardFlags: t.standardFlag,
455
459
  linetype: t.lineType,
@@ -458,12 +462,12 @@ class De extends J {
458
462
  color: o,
459
463
  isPlottable: t.plotFlag != 0
460
464
  });
461
- this.processCommonTableEntryAttrs(t, r), n.tables.layerTable.add(r);
465
+ this.processCommonTableEntryAttrs(t, s), n.tables.layerTable.add(s);
462
466
  });
463
467
  }
464
468
  processViewports(e, n) {
465
469
  e.tables.VPORT.entries.forEach((t) => {
466
- const o = new oe();
470
+ const o = new re();
467
471
  this.processCommonTableEntryAttrs(t, o), t.circleSides && (o.circleSides = t.circleSides), o.standardFlag = t.standardFlag, o.center.copy(t.center), o.lowerLeftCorner.copy(t.lowerLeftCorner), o.upperRightCorner.copy(t.upperRightCorner), t.snapBasePoint && o.snapBase.copy(t.snapBasePoint), t.snapRotationAngle && (o.snapAngle = t.snapRotationAngle), t.snapSpacing && o.snapIncrements.copy(t.snapSpacing), t.majorGridLines && (o.gridMajor = t.majorGridLines), t.gridSpacing && o.gridIncrements.copy(t.gridSpacing), t.backgroundObjectId && (o.backgroundObjectId = t.backgroundObjectId), o.gsView.center.copy(t.center), o.gsView.viewDirectionFromTarget.copy(t.viewDirectionFromTarget), o.gsView.viewTarget.copy(t.viewTarget), t.lensLength && (o.gsView.lensLength = t.lensLength), t.frontClippingPlane && (o.gsView.frontClippingPlane = t.frontClippingPlane), t.backClippingPlane && (o.gsView.backClippingPlane = t.backClippingPlane), t.viewHeight && (o.gsView.viewHeight = t.viewHeight), t.viewTwistAngle && (o.gsView.viewTwistAngle = t.viewTwistAngle), t.frozenLayers && (o.gsView.frozenLayers = t.frozenLayers), t.styleSheet && (o.gsView.styleSheet = t.styleSheet), t.renderMode && (o.gsView.renderMode = t.renderMode), t.viewMode && (o.gsView.viewMode = t.viewMode), t.ucsIconSetting && (o.gsView.ucsIconSetting = t.ucsIconSetting), t.ucsOrigin && o.gsView.ucsOrigin.copy(t.ucsOrigin), t.ucsXAxis && o.gsView.ucsXAxis.copy(t.ucsXAxis), t.ucsYAxis && o.gsView.ucsYAxis.copy(t.ucsYAxis), t.orthographicType && (o.gsView.orthographicType = t.orthographicType), t.shadePlotSetting && (o.gsView.shadePlotSetting = t.shadePlotSetting), t.shadePlotObjectId && (o.gsView.shadePlotObjectId = t.shadePlotObjectId), t.visualStyleObjectId && (o.gsView.visualStyleObjectId = t.visualStyleObjectId), t.isDefaultLightingOn && (o.gsView.isDefaultLightingOn = t.isDefaultLightingOn), t.defaultLightingType && (o.gsView.defaultLightingType = t.defaultLightingType), t.brightness && (o.gsView.brightness = t.brightness), t.contrast && (o.gsView.contrast = t.contrast), t.ambientColor && (o.gsView.ambientColor = t.ambientColor), n.tables.viewportTable.add(o);
468
472
  });
469
473
  }
@@ -476,9 +480,9 @@ class De extends J {
476
480
  processBlocks(e, n) {
477
481
  }
478
482
  async processEntitiesInBlock(e, n) {
479
- const s = new T(), t = e.length;
483
+ const r = new y(), t = e.length;
480
484
  for (let o = 0; o < t; o++) {
481
- const r = e[o], a = s.convert(r);
485
+ const s = e[o], a = r.convert(s);
482
486
  a && n.appendEntity(a);
483
487
  }
484
488
  }
@@ -487,16 +491,16 @@ class De extends J {
487
491
  * as "batch processing" or "cooperative multitasking," where the time-consuming task is broken into
488
492
  * smaller pieces and executed in small intervals to allow the UI to remain responsive.
489
493
  */
490
- async processEntities(e, n, s, t, o) {
491
- const r = new T(), a = e.entities, c = a.length, l = new re(
494
+ async processEntities(e, n, r, t, o) {
495
+ const s = new y(), a = e.entities, c = a.length, l = new ie(
492
496
  c,
493
497
  100 - t.value,
494
- s
498
+ r
495
499
  ), i = n.tables.blockTable.modelSpace;
496
- await l.processChunk(async (g, d) => {
497
- for (let p = g; p < d; p++) {
498
- const D = a[p], f = r.convert(D);
499
- f && i.appendEntity(f);
500
+ await l.processChunk(async (f, d) => {
501
+ for (let p = f; p < d; p++) {
502
+ const D = a[p], u = s.convert(D);
503
+ u && i.appendEntity(u);
500
504
  }
501
505
  if (o) {
502
506
  let p = t.value + d / c * (100 - t.value);
@@ -505,8 +509,8 @@ class De extends J {
505
509
  });
506
510
  }
507
511
  processHeader(e, n) {
508
- const s = e.header;
509
- n.cecolor.colorIndex = s.CECOLOR || 256, n.angBase = s.ANGBASE ?? 0, n.angDir = s.ANGDIR ?? 0, n.aunits = s.AUNITS ?? 0, n.extmax = s.EXTMAX, n.extmin = s.EXTMIN, n.insunits = s.INSUNITS ?? 1, n.pdmode = s.PDMODE ?? 0, n.pdsize = s.PDSIZE ?? 0;
512
+ const r = e.header;
513
+ n.cecolor.colorIndex = r.CECOLOR || 256, n.angBase = r.ANGBASE ?? 0, n.angDir = r.ANGDIR ?? 0, n.aunits = r.AUNITS ?? 0, n.extmax = r.EXTMAX, n.extmin = r.EXTMIN, n.insunits = r.INSUNITS ?? 1, n.pdmode = r.PDMODE ?? 0, n.pdsize = r.PDSIZE ?? 0;
510
514
  }
511
515
  processCommonTableEntryAttrs(e, n) {
512
516
  n.name = e.name, n.objectId = e.handle.toString(), n.ownerId = e.ownerHandle.toString();
@@ -515,17 +519,17 @@ class De extends J {
515
519
  this.processLayouts(e, n), this.processImageDefs(e, n);
516
520
  }
517
521
  processLayouts(e, n) {
518
- const s = n.dictionaries.layouts;
522
+ const r = n.dictionaries.layouts;
519
523
  e.objects.LAYOUT.forEach((o) => {
520
- const r = new ie();
521
- r.layoutName = o.layoutName, r.tabOrder = o.tabOrder, r.blockTableRecordId = o.ownerHandle.toString(), r.limits.min.copy(o.minLimit), r.limits.max.copy(o.maxLimit), r.extents.min.copy(o.minExtent), r.extents.max.copy(o.maxExtent), this.processCommonObjectAttrs(o, r), s.setAt(r.layoutName, r);
524
+ const s = new ce();
525
+ s.layoutName = o.layoutName, s.tabOrder = o.tabOrder, s.blockTableRecordId = o.ownerHandle.toString(), s.limits.min.copy(o.minLimit), s.limits.max.copy(o.maxLimit), s.extents.min.copy(o.minExtent), s.extents.max.copy(o.maxExtent), this.processCommonObjectAttrs(o, s), r.setAt(s.layoutName, s);
522
526
  });
523
527
  }
524
528
  processImageDefs(e, n) {
525
- const s = n.dictionaries.imageDefs;
529
+ const r = n.dictionaries.imageDefs;
526
530
  e.objects.IMAGEDEF.forEach((o) => {
527
- const r = new ce();
528
- r.sourceFileName = o.fileName, this.processCommonObjectAttrs(o, r), s.setAt(r.objectId, r);
531
+ const s = new ae();
532
+ s.sourceFileName = o.fileName, this.processCommonObjectAttrs(o, s), r.setAt(s.objectId, s);
529
533
  });
530
534
  }
531
535
  processCommonObjectAttrs(e, n) {
@@ -533,5 +537,5 @@ class De extends J {
533
537
  }
534
538
  }
535
539
  export {
536
- De as AcDbLibreDwgConverter
540
+ ue as AcDbLibreDwgConverter
537
541
  };
@@ -1 +1 @@
1
- (function(D,r){typeof exports=="object"&&typeof module<"u"?r(exports,require("@mlightcad/data-model"),require("@mlightcad/libredwg-web")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/data-model","@mlightcad/libredwg-web"],r):(D=typeof globalThis<"u"?globalThis:D||self,r(D["libredwg-converter"]={},D.dataModel,D.libredwgWeb))})(this,function(D,r,A){"use strict";class w{convert(e){const n=this.createEntity(e);return n&&this.processCommonAttrs(e,n),n}createEntity(e){return e.type=="ARC"?this.convertArc(e):e.type=="CIRCLE"?this.convertCirle(e):e.type=="DIMENSION"?this.convertDimension(e):e.type=="ELLIPSE"?this.convertEllipse(e):e.type=="HATCH"?this.convertHatch(e):e.type=="IMAGE"?this.convertImage(e):e.type=="LEADER"?this.convertLeader(e):e.type=="LINE"?this.convertLine(e):e.type=="LWPOLYLINE"?this.convertLWPolyline(e):e.type=="MTEXT"?this.convertMText(e):e.type=="POINT"?this.convertPoint(e):e.type=="POLYLINE"?this.convertPolyline(e):e.type=="RAY"?this.convertRay(e):e.type=="SPLINE"?this.convertSpline(e):e.type=="ACAD_TABLE"?this.convertTable(e):e.type=="TEXT"?this.convertText(e):e.type=="SOLID"?this.convertSolid(e):e.type=="VIEWPORT"?this.convertViewport(e):e.type=="XLINE"?this.convertXline(e):e.type=="INSERT"?this.convertBlockReference(e):null}convertArc(e){return new r.AcDbArc(e.center,e.radius,e.startAngle,e.endAngle)}convertCirle(e){return new r.AcDbCircle(e.center,e.radius)}convertEllipse(e){const n=new r.AcGeVector3d(e.majorAxisEndPoint),o=n.length();return new r.AcDbEllipse(e.center,r.AcGeVector3d.Z_AXIS,n,o,o*e.axisRatio,e.startAngle,e.endAngle)}convertLine(e){const n=e.startPoint,o=e.endPoint;return new r.AcDbLine(new r.AcGePoint3d(n.x,n.y,n.z),new r.AcGePoint3d(o.x,o.y,o.z))}convertSpline(e){return e.numberOfControlPoints>0&&e.numberOfKnots>0?new r.AcDbSpline(e.controlPoints,e.knots,e.weights,e.degree,!!(e.flag&1)):e.numberOfFitPoints>0?new r.AcDbSpline(e.fitPoints,"Uniform",e.degree,!!(e.flag&1)):null}convertPoint(e){const n=new r.AcDbPoint;return n.position=e.position,n}convertSolid(e){const n=new r.AcDbTrace;return n.setPointAt(0,{...e.corner1,z:0}),n.setPointAt(1,{...e.corner2,z:0}),n.setPointAt(2,{...e.corner3,z:0}),n.setPointAt(3,e.corner4?{...e.corner4,z:0}:{...e.corner3,z:0}),n.thickness=e.thickness,n}convertLWPolyline(e){const n=new r.AcDbPolyline;return n.closed=!!(e.flag&512),e.vertices.forEach((o,t)=>{n.addVertexAt(t,new r.AcGePoint2d(o.x,o.y),o.bulge,o.startWidth,o.endWidth)}),n}convertPolyline(e){const n=new r.AcDbPolyline;return n.closed=!!(e.flag&1),e.vertices.forEach((o,t)=>{n.addVertexAt(t,new r.AcGePoint2d(o.x,o.y),o.bulge,o.startWidth,o.endWidth)}),n}convertHatch(e){var t;const n=new r.AcDbHatch;return(t=e.definitionLines)==null||t.forEach(s=>{n.definitionLines.push({angle:s.angle,origin:s.base,delta:s.offset,dashPattern:s.numberOfDashLengths>0?s.dashLengths:[]})}),n.hatchStyle=e.hatchStyle,n.patternName=e.patternName,n.patternType=e.patternType,n.patternAngle=e.patternAngle==null?0:e.patternAngle,n.patternScale=e.patternScale==null?0:e.patternScale,e.boundaryPaths.forEach(s=>{if(s.boundaryPathTypeFlag&2){const a=s,l=new r.AcGePolyline2d;l.closed=a.isClosed,a.vertices.forEach((d,c)=>{l.addVertexAt(c,{x:d.x,y:d.y,bulge:d.bulge})}),n.add(l)}else{const a=s,l=new r.AcGeLoop2d;a.edges.forEach(d=>{if(d.type==1){const c=d;l.add(new r.AcGeLine2d(c.start,c.end))}else if(d.type==2){const c=d;l.add(new r.AcGeCircArc2d(c.center,c.radius,c.startAngle,c.endAngle,!c.isCCW))}else if(d.type==3){const c=d;new r.AcGeVector2d().subVectors(c.end,c.center);const p=Math.sqrt(Math.pow(c.end.x,2)+Math.pow(c.end.y,2)),f=p*c.lengthOfMinorAxis;let g=c.startAngle,u=c.endAngle;const T=Math.atan2(c.end.y,c.end.x);c.isCCW||(g=Math.PI*2-g,u=Math.PI*2-u),l.add(new r.AcGeEllipseArc2d({...c.center,z:0},p,f,g,u,!c.isCCW,T))}else if(d.type==4){const c=d;if(c.numberOfControlPoints>0&&c.numberOfKnots>0){const h=c.controlPoints.map(g=>({x:g.x,y:g.y,z:0}));let p=!0;const f=c.controlPoints.map(g=>(g.weight==null&&(p=!1),g.weight||1));l.add(new r.AcGeSpline3d(h,c.knots,p?f:void 0))}else if(c.numberOfFitData>0){const h=c.fitDatum.map(p=>({x:p.x,y:p.y,z:0}));l.add(new r.AcGeSpline3d(h,"Uniform"))}}}),n.add(l)}}),n}convertTable(e){const n=new r.AcDbTable(e.name,e.rowCount,e.columnCount);return n.attachmentPoint=e.attachmentPoint,n.position.copy(e.startPoint),e.columnWidthArr.forEach((o,t)=>n.setColumnWidth(t,o)),e.rowHeightArr.forEach((o,t)=>n.setRowHeight(t,o)),e.cells.forEach((o,t)=>{n.setCell(t,o)}),n}convertText(e){const n=new r.AcDbText;return n.textString=e.text,n.styleName=e.styleName,n.height=e.textHeight,n.position.copy(e.startPoint),n.rotation=e.rotation,n.oblique=e.obliqueAngle??0,n.thickness=e.thickness,n.horizontalMode=e.halign,n.verticalMode=e.valign,n.widthFactor=e.xScale??1,n}convertMText(e){const n=new r.AcDbMText;return n.contents=e.text,e.styleName!=null&&(n.styleName=e.styleName),n.height=e.textHeight,n.width=e.rectWidth,n.rotation=e.rotation||0,n.location=e.insertionPoint,n.attachmentPoint=e.attachmentPoint,e.direction&&(n.direction=new r.AcGeVector3d(e.direction)),n.drawingDirection=e.drawingDirection,n}convertLeader(e){const n=new r.AcDbLeader;return e.vertices.forEach(o=>{n.appendVertex(o)}),n.hasArrowHead=e.isArrowheadEnabled,n.hasHookLine=e.isHooklineExists,n.isSplined=e.isSpline,n.dimensionStyle=e.styleName,n.annoType=e.leaderCreationFlag,n}convertDimension(e){if(e.subclassMarker=="AcDbAlignedDimension"||e.subclassMarker=="AcDbRotatedDimension"){const n=e,o=new r.AcDbAlignedDimension(n.subDefinitionPoint1,n.subDefinitionPoint2,n.definitionPoint);return o.rotation=n.rotationAngle,this.processDimensionCommonAttrs(e,o),o}else if(e.subclassMarker=="AcDb3PointAngularDimension"){const n=e,o=new r.AcDb3PointAngularDimension(n.centerPoint,n.subDefinitionPoint1,n.subDefinitionPoint2,n.definitionPoint);return this.processDimensionCommonAttrs(e,o),o}else if(e.subclassMarker=="AcDbOrdinateDimension"){const n=e,o=new r.AcDbOrdinateDimension(n.subDefinitionPoint1,n.subDefinitionPoint2);return this.processDimensionCommonAttrs(e,o),o}else if(e.subclassMarker=="AcDbRadialDimension"){const n=e,o=new r.AcDbRadialDimension(n.definitionPoint,n.centerPoint,n.leaderLength);return this.processDimensionCommonAttrs(e,o),o}else if(e.subclassMarker=="AcDbDiametricDimension"){const n=e,o=new r.AcDbDiametricDimension(n.definitionPoint,n.centerPoint,n.leaderLength);return this.processDimensionCommonAttrs(e,o),o}return null}processImage(e,n){n.position.copy(e.position),n.brightness=e.brightness,n.contrast=e.contrast,n.fade=e.fade,n.imageDefId=e.imageDefHandle.toString(),n.isClipped=(e.flags|4)>0,n.isImageShown=(e.flags|3)>0,n.isImageTransparent=(e.flags|8)>0,e.clippingBoundaryPath.forEach(o=>{n.clipBoundary.push(new r.AcGePoint2d(o))}),n.clipBoundaryType=e.clippingBoundaryType,n.width=Math.sqrt(e.uPixel.x**2+e.uPixel.y**2+e.uPixel.z**2)*e.imageSize.x,n.height=Math.sqrt(e.vPixel.x**2+e.vPixel.y**2+e.vPixel.z**2)*e.imageSize.y,n.rotation=Math.atan2(e.uPixel.y,e.uPixel.x)}convertImage(e){const n=new r.AcDbRasterImage;return this.processImage(e,n),n}convertViewport(e){const n=new r.AcDbViewport;return n.number=e.viewportId,n.centerPoint.copy(e.viewportCenter),n.height=e.height,n.width=e.width,n.viewCenter.copy(e.displayCenter),n.viewHeight=e.viewHeight,n}convertRay(e){const n=new r.AcDbRay;return n.basePoint.copy(e.firstPoint),n.unitDir.copy(e.unitDirection),n}convertXline(e){const n=new r.AcDbXline;return n.basePoint.copy(e.firstPoint),n.unitDir.copy(e.unitDirection),n}convertBlockReference(e){const n=new r.AcDbBlockReference(e.name);return e.insertionPoint&&n.position.copy(e.insertionPoint),n.scaleFactors.x=e.xScale,n.scaleFactors.y=e.yScale,n.scaleFactors.z=e.zScale,n.rotation=e.rotation,n.normal.copy(e.extrusionDirection),n}processDimensionCommonAttrs(e,n){n.dimBlockId=e.name,n.textPosition.copy(e.textPoint),n.textRotation=e.textRotation||0,e.textLineSpacingFactor&&(n.textLineSpacingFactor=e.textLineSpacingFactor),e.textLineSpacingStyle&&(n.textLineSpacingStyle=e.textLineSpacingStyle),n.dimensionStyleName=e.styleName,n.dimensionText=e.text||"",n.measurement=e.measurement}processCommonAttrs(e,n){n.layer=e.layer,n.objectId=e.handle.toString(),n.ownerId=e.ownerBlockRecordSoftId.toString(),e.lineType!=null&&(n.lineType=e.lineType),e.lineweight!=null&&(n.lineWeight=e.lineweight),e.lineTypeScale!=null&&(n.linetypeScale=e.lineTypeScale),e.color!=null&&(n.color.color=e.color),e.colorIndex!=null&&(n.color.colorIndex=e.colorIndex),e.colorName!=null&&(n.color.colorName=e.colorName),e.isVisible!=null&&(n.visibility=e.isVisible),e.transparency!=null&&(n.transparency=e.transparency)}}class b extends r.AcDbDatabaseConverter{constructor(e){super(),this.libredwg=A.LibreDwg.createByWasmInstance(e)}parse(e){if(this.libredwg==null)throw new Error("libredwg is not loaded!");const n=this.libredwg.dwg_read_data(e,A.Dwg_File_Type.DWG);if(n==null)throw new Error("Failed to read dwg data!");const o=this.libredwg.convert(n);return this.libredwg.dwg_free(n),o}getFonts(e){const n=new Map;e.tables.BLOCK_RECORD.entries.forEach(i=>{n.set(i.name,i)});const o=new Map,t=i=>{if(i){const a=i.lastIndexOf(".");return a>=0?i.substring(0,a).toLowerCase():i.toLowerCase()}};e.tables.STYLE.entries.forEach(i=>{const a=[];let l=t(i.font);l&&a.push(l),l=t(i.bigFont),l&&a.push(l),o.set(i.name,a)});const s=new Set;return this.getFontsInBlock(e.entities,n,o,s),Array.from(s)}getFontsInBlock(e,n,o,t){const s=/\\f(.*?)\|/g;e.forEach(i=>{if(i.type=="MTEXT"){const a=i;[...a.text.matchAll(s)].forEach(d=>{t.add(d[1].toLowerCase())});const l=o.get(a.styleName);l==null||l.forEach(d=>t.add(d))}else if(i.type=="TEXT"){const a=i,l=o.get(a.styleName);l==null||l.forEach(d=>t.add(d))}else if(i.type=="INSERT"){const a=i,l=n.get(a.name);l&&this.getFontsInBlock(l.entities,n,o,t)}})}processLineTypes(e,n){e.tables.LTYPE.entries.forEach(t=>{const s={name:t.name,description:t.description,standardFlag:t.standardFlag,totalPatternLength:t.totalPatternLength,pattern:t.pattern},i=new r.AcDbLinetypeTableRecord(s);this.processCommonTableEntryAttrs(t,i),i.name=t.name,n.tables.linetypeTable.add(i)})}processTextStyles(e,n){e.tables.STYLE.entries.forEach(t=>{const s=new r.AcDbTextStyleTableRecord(t);this.processCommonTableEntryAttrs(t,s),n.tables.textStyleTable.add(s)})}processDimStyles(e,n){e.tables.DIMSTYLE.entries.forEach(t=>{const s={name:t.name,ownerId:t.ownerHandle.toString(),dimpost:t.DIMPOST||"",dimapost:t.DIMAPOST||"",dimscale:t.DIMSCALE,dimasz:t.DIMASZ,dimexo:t.DIMEXO,dimdli:t.DIMDLI,dimexe:t.DIMEXE,dimrnd:t.DIMRND,dimdle:t.DIMDLE,dimtp:t.DIMTP,dimtm:t.DIMTM,dimtxt:t.DIMTXT,dimcen:t.DIMCEN,dimtsz:t.DIMTSZ,dimaltf:t.DIMALTF,dimlfac:t.DIMLFAC,dimtvp:t.DIMTVP,dimtfac:t.DIMTFAC,dimgap:t.DIMGAP,dimaltrnd:t.DIMALTRND,dimtol:t.DIMTOL==null||t.DIMTOL==0?0:1,dimlim:t.DIMLIM==null||t.DIMLIM==0?0:1,dimtih:t.DIMTIH==null||t.DIMTIH==0?0:1,dimtoh:t.DIMTOH==null||t.DIMTOH==0?0:1,dimse1:t.DIMSE1==null||t.DIMSE1==0?0:1,dimse2:t.DIMSE2==null||t.DIMSE2==0?0:1,dimtad:t.DIMTAD,dimzin:t.DIMZIN,dimazin:t.DIMAZIN,dimalt:t.DIMALT,dimaltd:t.DIMALTD,dimtofl:t.DIMTOFL,dimsah:t.DIMSAH,dimtix:t.DIMTIX,dimsoxd:t.DIMSOXD,dimclrd:t.DIMCLRD,dimclre:t.DIMCLRE,dimclrt:t.DIMCLRT,dimadec:t.DIMADEC||0,dimunit:t.DIMUNIT||2,dimdec:t.DIMDEC,dimtdec:t.DIMTDEC,dimaltu:t.DIMALTU,dimalttd:t.DIMALTTD,dimaunit:t.DIMAUNIT,dimfrac:t.DIMFRAC,dimlunit:t.DIMLUNIT,dimdsep:t.DIMDSEP,dimtmove:t.DIMTMOVE||0,dimjust:t.DIMJUST,dimsd1:t.DIMSD1,dimsd2:t.DIMSD2,dimtolj:t.DIMTOLJ,dimtzin:t.DIMTZIN,dimaltz:t.DIMALTZ,dimalttz:t.DIMALTTZ,dimfit:t.DIMFIT||0,dimupt:t.DIMUPT,dimatfit:t.DIMATFIT,dimtxsty:"Standard",dimldrblk:"",dimblk:t.DIMBLK||"",dimblk1:t.DIMBLK1||"",dimblk2:t.DIMBLK2||"",dimlwd:t.DIMLWD,dimlwe:t.DIMLWE},i=new r.AcDbDimStyleTableRecord(s);this.processCommonTableEntryAttrs(t,i),n.tables.dimStyleTable.add(i)})}processLayers(e,n){e.tables.LAYER.entries.forEach(t=>{const s=new r.AcCmColor;s.colorIndex=t.colorIndex;const i=new r.AcDbLayerTableRecord({name:t.name,standardFlags:t.standardFlag,linetype:t.lineType,lineWeight:t.lineweight,isOff:t.off,color:s,isPlottable:t.plotFlag!=0});this.processCommonTableEntryAttrs(t,i),n.tables.layerTable.add(i)})}processViewports(e,n){e.tables.VPORT.entries.forEach(t=>{const s=new r.AcDbViewportTableRecord;this.processCommonTableEntryAttrs(t,s),t.circleSides&&(s.circleSides=t.circleSides),s.standardFlag=t.standardFlag,s.center.copy(t.center),s.lowerLeftCorner.copy(t.lowerLeftCorner),s.upperRightCorner.copy(t.upperRightCorner),t.snapBasePoint&&s.snapBase.copy(t.snapBasePoint),t.snapRotationAngle&&(s.snapAngle=t.snapRotationAngle),t.snapSpacing&&s.snapIncrements.copy(t.snapSpacing),t.majorGridLines&&(s.gridMajor=t.majorGridLines),t.gridSpacing&&s.gridIncrements.copy(t.gridSpacing),t.backgroundObjectId&&(s.backgroundObjectId=t.backgroundObjectId),s.gsView.center.copy(t.center),s.gsView.viewDirectionFromTarget.copy(t.viewDirectionFromTarget),s.gsView.viewTarget.copy(t.viewTarget),t.lensLength&&(s.gsView.lensLength=t.lensLength),t.frontClippingPlane&&(s.gsView.frontClippingPlane=t.frontClippingPlane),t.backClippingPlane&&(s.gsView.backClippingPlane=t.backClippingPlane),t.viewHeight&&(s.gsView.viewHeight=t.viewHeight),t.viewTwistAngle&&(s.gsView.viewTwistAngle=t.viewTwistAngle),t.frozenLayers&&(s.gsView.frozenLayers=t.frozenLayers),t.styleSheet&&(s.gsView.styleSheet=t.styleSheet),t.renderMode&&(s.gsView.renderMode=t.renderMode),t.viewMode&&(s.gsView.viewMode=t.viewMode),t.ucsIconSetting&&(s.gsView.ucsIconSetting=t.ucsIconSetting),t.ucsOrigin&&s.gsView.ucsOrigin.copy(t.ucsOrigin),t.ucsXAxis&&s.gsView.ucsXAxis.copy(t.ucsXAxis),t.ucsYAxis&&s.gsView.ucsYAxis.copy(t.ucsYAxis),t.orthographicType&&(s.gsView.orthographicType=t.orthographicType),t.shadePlotSetting&&(s.gsView.shadePlotSetting=t.shadePlotSetting),t.shadePlotObjectId&&(s.gsView.shadePlotObjectId=t.shadePlotObjectId),t.visualStyleObjectId&&(s.gsView.visualStyleObjectId=t.visualStyleObjectId),t.isDefaultLightingOn&&(s.gsView.isDefaultLightingOn=t.isDefaultLightingOn),t.defaultLightingType&&(s.gsView.defaultLightingType=t.defaultLightingType),t.brightness&&(s.gsView.brightness=t.brightness),t.contrast&&(s.gsView.contrast=t.contrast),t.ambientColor&&(s.gsView.ambientColor=t.ambientColor),n.tables.viewportTable.add(s)})}processBlockTables(e,n){e.tables.BLOCK_RECORD.entries.forEach(t=>{let s=n.tables.blockTable.getAt(t.name);s||(s=new r.AcDbBlockTableRecord,s.objectId=t.handle.toString(),s.name=t.name,n.tables.blockTable.add(s)),!s.isModelSapce&&!s.isPaperSapce&&t.entities&&t.entities.length>0&&this.processEntitiesInBlock(t.entities,s)})}processBlocks(e,n){}async processEntitiesInBlock(e,n){const o=new w,t=e.length;for(let s=0;s<t;s++){const i=e[s],a=o.convert(i);a&&n.appendEntity(a)}}async processEntities(e,n,o,t,s){const i=new w,a=e.entities,l=a.length,d=new r.AcDbBatchProcessing(l,100-t.value,o),c=n.tables.blockTable.modelSpace;await d.processChunk(async(h,p)=>{for(let f=h;f<p;f++){const g=a[f],u=i.convert(g);u&&c.appendEntity(u)}if(s){let f=t.value+p/l*(100-t.value);f>100&&(f=100),await s(f,"ENTITY","IN-PROGRESS")}})}processHeader(e,n){const o=e.header;n.cecolor.colorIndex=o.CECOLOR||256,n.angBase=o.ANGBASE??0,n.angDir=o.ANGDIR??0,n.aunits=o.AUNITS??0,n.extmax=o.EXTMAX,n.extmin=o.EXTMIN,n.insunits=o.INSUNITS??1,n.pdmode=o.PDMODE??0,n.pdsize=o.PDSIZE??0}processCommonTableEntryAttrs(e,n){n.name=e.name,n.objectId=e.handle.toString(),n.ownerId=e.ownerHandle.toString()}processObjects(e,n){this.processLayouts(e,n),this.processImageDefs(e,n)}processLayouts(e,n){const o=n.dictionaries.layouts;e.objects.LAYOUT.forEach(s=>{const i=new r.AcDbLayout;i.layoutName=s.layoutName,i.tabOrder=s.tabOrder,i.blockTableRecordId=s.ownerHandle.toString(),i.limits.min.copy(s.minLimit),i.limits.max.copy(s.maxLimit),i.extents.min.copy(s.minExtent),i.extents.max.copy(s.maxExtent),this.processCommonObjectAttrs(s,i),o.setAt(i.layoutName,i)})}processImageDefs(e,n){const o=n.dictionaries.imageDefs;e.objects.IMAGEDEF.forEach(s=>{const i=new r.AcDbRasterImageDef;i.sourceFileName=s.fileName,this.processCommonObjectAttrs(s,i),o.setAt(i.objectId,i)})}processCommonObjectAttrs(e,n){n.objectId=e.handle.toString(),n.ownerId=e.ownerHandle.toString()}}D.AcDbLibreDwgConverter=b,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
1
+ (function(D,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@mlightcad/data-model"),require("@mlightcad/libredwg-web")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/data-model","@mlightcad/libredwg-web"],o):(D=typeof globalThis<"u"?globalThis:D||self,o(D["libredwg-converter"]={},D.dataModel,D.libredwgWeb))})(this,function(D,o,w){"use strict";class b{convert(e){const n=this.createEntity(e);return n&&this.processCommonAttrs(e,n),n}createEntity(e){return e.type=="ARC"?this.convertArc(e):e.type=="CIRCLE"?this.convertCirle(e):e.type=="DIMENSION"?this.convertDimension(e):e.type=="ELLIPSE"?this.convertEllipse(e):e.type=="HATCH"?this.convertHatch(e):e.type=="IMAGE"?this.convertImage(e):e.type=="LEADER"?this.convertLeader(e):e.type=="LINE"?this.convertLine(e):e.type=="LWPOLYLINE"?this.convertLWPolyline(e):e.type=="MTEXT"?this.convertMText(e):e.type=="POINT"?this.convertPoint(e):e.type=="POLYLINE"?this.convertPolyline(e):e.type=="RAY"?this.convertRay(e):e.type=="SPLINE"?this.convertSpline(e):e.type=="ACAD_TABLE"?this.convertTable(e):e.type=="TEXT"?this.convertText(e):e.type=="SOLID"?this.convertSolid(e):e.type=="VIEWPORT"?this.convertViewport(e):e.type=="XLINE"?this.convertXline(e):e.type=="INSERT"?this.convertBlockReference(e):null}convertArc(e){return new o.AcDbArc(e.center,e.radius,e.startAngle,e.endAngle)}convertCirle(e){return new o.AcDbCircle(e.center,e.radius)}convertEllipse(e){const n=new o.AcGeVector3d(e.majorAxisEndPoint),s=n.length();return new o.AcDbEllipse(e.center,o.AcGeVector3d.Z_AXIS,n,s,s*e.axisRatio,e.startAngle,e.endAngle)}convertLine(e){const n=e.startPoint,s=e.endPoint;return new o.AcDbLine(new o.AcGePoint3d(n.x,n.y,n.z),new o.AcGePoint3d(s.x,s.y,s.z))}convertSpline(e){return e.numberOfControlPoints>0&&e.numberOfKnots>0?new o.AcDbSpline(e.controlPoints,e.knots,e.weights,e.degree,!!(e.flag&1)):e.numberOfFitPoints>0?new o.AcDbSpline(e.fitPoints,"Uniform",e.degree,!!(e.flag&1)):null}convertPoint(e){const n=new o.AcDbPoint;return n.position=e.position,n}convertSolid(e){const n=new o.AcDbTrace;return n.setPointAt(0,{...e.corner1,z:0}),n.setPointAt(1,{...e.corner2,z:0}),n.setPointAt(2,{...e.corner3,z:0}),n.setPointAt(3,e.corner4?{...e.corner4,z:0}:{...e.corner3,z:0}),n.thickness=e.thickness,n}convertLWPolyline(e){const n=new o.AcDbPolyline;return n.closed=!!(e.flag&512),e.vertices.forEach((s,t)=>{n.addVertexAt(t,new o.AcGePoint2d(s.x,s.y),s.bulge,s.startWidth,s.endWidth)}),n}convertPolyline(e){const n=new o.AcDbPolyline;return n.closed=!!(e.flag&1),e.vertices.forEach((s,t)=>{n.addVertexAt(t,new o.AcGePoint2d(s.x,s.y),s.bulge,s.startWidth,s.endWidth)}),n}convertHatch(e){var t;const n=new o.AcDbHatch;return(t=e.definitionLines)==null||t.forEach(r=>{n.definitionLines.push({angle:r.angle,origin:r.base,delta:r.offset,dashPattern:r.numberOfDashLengths>0?r.dashLengths:[]})}),n.hatchStyle=e.hatchStyle,n.patternName=e.patternName,n.patternType=e.patternType,n.patternAngle=e.patternAngle==null?0:e.patternAngle,n.patternScale=e.patternScale==null?0:e.patternScale,e.boundaryPaths.forEach(r=>{if(r.boundaryPathTypeFlag&2){const l=r,a=new o.AcGePolyline2d;a.closed=l.isClosed,l.vertices.forEach((p,c)=>{a.addVertexAt(c,{x:p.x,y:p.y,bulge:p.bulge})}),n.add(a)}else{const l=r,a=new o.AcGeLoop2d;l.edges.forEach(p=>{if(p.type==1){const c=p;a.add(new o.AcGeLine2d(c.start,c.end))}else if(p.type==2){const c=p;a.add(new o.AcGeCircArc2d(c.center,c.radius,c.startAngle,c.endAngle,!c.isCCW))}else if(p.type==3){const c=p;new o.AcGeVector2d().subVectors(c.end,c.center);const d=Math.sqrt(Math.pow(c.end.x,2)+Math.pow(c.end.y,2)),f=d*c.lengthOfMinorAxis;let u=c.startAngle,h=c.endAngle;const y=Math.atan2(c.end.y,c.end.x);c.isCCW||(u=Math.PI*2-u,h=Math.PI*2-h),a.add(new o.AcGeEllipseArc2d({...c.center,z:0},d,f,u,h,!c.isCCW,y))}else if(p.type==4){const c=p;if(c.numberOfControlPoints>0&&c.numberOfKnots>0){const g=c.controlPoints.map(u=>({x:u.x,y:u.y,z:0}));let d=!0;const f=c.controlPoints.map(u=>(u.weight==null&&(d=!1),u.weight||1));a.add(new o.AcGeSpline3d(g,c.knots,d?f:void 0))}else if(c.numberOfFitData>0){const g=c.fitDatum.map(d=>({x:d.x,y:d.y,z:0}));a.add(new o.AcGeSpline3d(g,"Uniform"))}}}),n.add(a)}}),n}convertTable(e){const n=new o.AcDbTable(e.name,e.rowCount,e.columnCount);return n.attachmentPoint=e.attachmentPoint,n.position.copy(e.startPoint),e.columnWidthArr.forEach((s,t)=>n.setColumnWidth(t,s)),e.rowHeightArr.forEach((s,t)=>n.setRowHeight(t,s)),e.cells.forEach((s,t)=>{n.setCell(t,s)}),n}convertText(e){const n=new o.AcDbText;return n.textString=e.text,n.styleName=e.styleName,n.height=e.textHeight,n.position.copy(e.startPoint),n.rotation=e.rotation,n.oblique=e.obliqueAngle??0,n.thickness=e.thickness,n.horizontalMode=e.halign,n.verticalMode=e.valign,n.widthFactor=e.xScale??1,n}convertMText(e){const n=new o.AcDbMText;return n.contents=e.text,e.styleName!=null&&(n.styleName=e.styleName),n.height=e.textHeight,n.width=e.rectWidth,n.rotation=e.rotation||0,n.location=e.insertionPoint,n.attachmentPoint=e.attachmentPoint,e.direction&&(n.direction=new o.AcGeVector3d(e.direction)),n.drawingDirection=e.drawingDirection,n}convertLeader(e){const n=new o.AcDbLeader;return e.vertices.forEach(s=>{n.appendVertex(s)}),n.hasArrowHead=e.isArrowheadEnabled,n.hasHookLine=e.isHooklineExists,n.isSplined=e.isSpline,n.dimensionStyle=e.styleName,n.annoType=e.leaderCreationFlag,n}convertDimension(e){if(e.subclassMarker=="AcDbAlignedDimension"||e.subclassMarker=="AcDbRotatedDimension"){const n=e,s=new o.AcDbAlignedDimension(n.subDefinitionPoint1,n.subDefinitionPoint2,n.definitionPoint);return s.rotation=n.rotationAngle,this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDb3PointAngularDimension"){const n=e,s=new o.AcDb3PointAngularDimension(n.centerPoint,n.subDefinitionPoint1,n.subDefinitionPoint2,n.definitionPoint);return this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDbOrdinateDimension"){const n=e,s=new o.AcDbOrdinateDimension(n.subDefinitionPoint1,n.subDefinitionPoint2);return this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDbRadialDimension"){const n=e,s=new o.AcDbRadialDimension(n.definitionPoint,n.centerPoint,n.leaderLength);return this.processDimensionCommonAttrs(e,s),s}else if(e.subclassMarker=="AcDbDiametricDimension"){const n=e,s=new o.AcDbDiametricDimension(n.definitionPoint,n.centerPoint,n.leaderLength);return this.processDimensionCommonAttrs(e,s),s}return null}processImage(e,n){n.position.copy(e.position),n.brightness=e.brightness,n.contrast=e.contrast,n.fade=e.fade,n.imageDefId=e.imageDefHandle.toString(),n.isClipped=(e.flags|4)>0,n.isImageShown=(e.flags|3)>0,n.isImageTransparent=(e.flags|8)>0,e.clippingBoundaryPath.forEach(s=>{n.clipBoundary.push(new o.AcGePoint2d(s))}),n.clipBoundaryType=e.clippingBoundaryType,n.width=Math.sqrt(e.uPixel.x**2+e.uPixel.y**2+e.uPixel.z**2)*e.imageSize.x,n.height=Math.sqrt(e.vPixel.x**2+e.vPixel.y**2+e.vPixel.z**2)*e.imageSize.y,n.rotation=Math.atan2(e.uPixel.y,e.uPixel.x)}convertImage(e){const n=new o.AcDbRasterImage;return this.processImage(e,n),n}convertViewport(e){const n=new o.AcDbViewport;return n.number=e.viewportId,n.centerPoint.copy(e.viewportCenter),n.height=e.height,n.width=e.width,n.viewCenter.copy(e.displayCenter),n.viewHeight=e.viewHeight,n}convertRay(e){const n=new o.AcDbRay;return n.basePoint.copy(e.firstPoint),n.unitDir.copy(e.unitDirection),n}convertXline(e){const n=new o.AcDbXline;return n.basePoint.copy(e.firstPoint),n.unitDir.copy(e.unitDirection),n}convertBlockReference(e){const n=new o.AcDbBlockReference(e.name);return e.insertionPoint&&n.position.copy(e.insertionPoint),n.scaleFactors.x=e.xScale,n.scaleFactors.y=e.yScale,n.scaleFactors.z=e.zScale,n.rotation=e.rotation,n.normal.copy(e.extrusionDirection),n}processDimensionCommonAttrs(e,n){n.dimBlockId=e.name,n.textPosition.copy(e.textPoint),n.textRotation=e.textRotation||0,e.textLineSpacingFactor&&(n.textLineSpacingFactor=e.textLineSpacingFactor),e.textLineSpacingStyle&&(n.textLineSpacingStyle=e.textLineSpacingStyle),n.dimensionStyleName=e.styleName,n.dimensionText=e.text||"",n.measurement=e.measurement}processCommonAttrs(e,n){n.layer=e.layer,n.objectId=e.handle.toString(),n.ownerId=e.ownerBlockRecordSoftId.toString(),e.lineType!=null&&(n.lineType=e.lineType),e.lineweight!=null&&(n.lineWeight=e.lineweight),e.lineTypeScale!=null&&(n.linetypeScale=e.lineTypeScale),e.color!=null&&(n.color.color=e.color),e.colorIndex!=null&&(n.color.colorIndex=e.colorIndex),e.colorName!=null&&(n.color.colorName=e.colorName),e.isVisible!=null&&(n.visibility=e.isVisible),e.transparency!=null&&(n.transparency=e.transparency)}}async function I(A){const e=await w.LibreDwg.create();if(e==null)throw new Error("libredwg is not loaded!");const n=e.dwg_read_data(A,w.Dwg_File_Type.DWG);if(n==null)throw new Error("Failed to read dwg data!");const s=e.convert(n);return e.dwg_free(n),s}class T extends o.AcDbDatabaseConverter{constructor(e={}){super(e),e.useWorker=!0,e.parserWorkerUrl||(e.parserWorkerUrl="/assets/libredwg-parser-worker.js")}async parse(e){return this.config.useWorker&&this.config.parserWorkerUrl?(await o.createWorkerApi({workerUrl:this.config.parserWorkerUrl}).execute(e)).data:await I(e)}getFonts(e){const n=new Map;e.tables.BLOCK_RECORD.entries.forEach(i=>{n.set(i.name,i)});const s=new Map,t=i=>{if(i){const l=i.lastIndexOf(".");return l>=0?i.substring(0,l).toLowerCase():i.toLowerCase()}};e.tables.STYLE.entries.forEach(i=>{const l=[];let a=t(i.font);a&&l.push(a),a=t(i.bigFont),a&&l.push(a),s.set(i.name,l)});const r=new Set;return this.getFontsInBlock(e.entities,n,s,r),Array.from(r)}getFontsInBlock(e,n,s,t){const r=/\\f(.*?)\|/g;e.forEach(i=>{if(i.type=="MTEXT"){const l=i;[...l.text.matchAll(r)].forEach(p=>{t.add(p[1].toLowerCase())});const a=s.get(l.styleName);a==null||a.forEach(p=>t.add(p))}else if(i.type=="TEXT"){const l=i,a=s.get(l.styleName);a==null||a.forEach(p=>t.add(p))}else if(i.type=="INSERT"){const l=i,a=n.get(l.name);a&&this.getFontsInBlock(a.entities,n,s,t)}})}processLineTypes(e,n){e.tables.LTYPE.entries.forEach(t=>{const r={name:t.name,description:t.description,standardFlag:t.standardFlag,totalPatternLength:t.totalPatternLength,pattern:t.pattern},i=new o.AcDbLinetypeTableRecord(r);this.processCommonTableEntryAttrs(t,i),i.name=t.name,n.tables.linetypeTable.add(i)})}processTextStyles(e,n){e.tables.STYLE.entries.forEach(t=>{const r=new o.AcDbTextStyleTableRecord(t);this.processCommonTableEntryAttrs(t,r),n.tables.textStyleTable.add(r)})}processDimStyles(e,n){e.tables.DIMSTYLE.entries.forEach(t=>{const r={name:t.name,ownerId:t.ownerHandle.toString(),dimpost:t.DIMPOST||"",dimapost:t.DIMAPOST||"",dimscale:t.DIMSCALE,dimasz:t.DIMASZ,dimexo:t.DIMEXO,dimdli:t.DIMDLI,dimexe:t.DIMEXE,dimrnd:t.DIMRND,dimdle:t.DIMDLE,dimtp:t.DIMTP,dimtm:t.DIMTM,dimtxt:t.DIMTXT,dimcen:t.DIMCEN,dimtsz:t.DIMTSZ,dimaltf:t.DIMALTF,dimlfac:t.DIMLFAC,dimtvp:t.DIMTVP,dimtfac:t.DIMTFAC,dimgap:t.DIMGAP,dimaltrnd:t.DIMALTRND,dimtol:t.DIMTOL==null||t.DIMTOL==0?0:1,dimlim:t.DIMLIM==null||t.DIMLIM==0?0:1,dimtih:t.DIMTIH==null||t.DIMTIH==0?0:1,dimtoh:t.DIMTOH==null||t.DIMTOH==0?0:1,dimse1:t.DIMSE1==null||t.DIMSE1==0?0:1,dimse2:t.DIMSE2==null||t.DIMSE2==0?0:1,dimtad:t.DIMTAD,dimzin:t.DIMZIN,dimazin:t.DIMAZIN,dimalt:t.DIMALT,dimaltd:t.DIMALTD,dimtofl:t.DIMTOFL,dimsah:t.DIMSAH,dimtix:t.DIMTIX,dimsoxd:t.DIMSOXD,dimclrd:t.DIMCLRD,dimclre:t.DIMCLRE,dimclrt:t.DIMCLRT,dimadec:t.DIMADEC||0,dimunit:t.DIMUNIT||2,dimdec:t.DIMDEC,dimtdec:t.DIMTDEC,dimaltu:t.DIMALTU,dimalttd:t.DIMALTTD,dimaunit:t.DIMAUNIT,dimfrac:t.DIMFRAC,dimlunit:t.DIMLUNIT,dimdsep:t.DIMDSEP,dimtmove:t.DIMTMOVE||0,dimjust:t.DIMJUST,dimsd1:t.DIMSD1,dimsd2:t.DIMSD2,dimtolj:t.DIMTOLJ,dimtzin:t.DIMTZIN,dimaltz:t.DIMALTZ,dimalttz:t.DIMALTTZ,dimfit:t.DIMFIT||0,dimupt:t.DIMUPT,dimatfit:t.DIMATFIT,dimtxsty:"Standard",dimldrblk:"",dimblk:t.DIMBLK||"",dimblk1:t.DIMBLK1||"",dimblk2:t.DIMBLK2||"",dimlwd:t.DIMLWD,dimlwe:t.DIMLWE},i=new o.AcDbDimStyleTableRecord(r);this.processCommonTableEntryAttrs(t,i),n.tables.dimStyleTable.add(i)})}processLayers(e,n){e.tables.LAYER.entries.forEach(t=>{const r=new o.AcCmColor;r.colorIndex=t.colorIndex;const i=new o.AcDbLayerTableRecord({name:t.name,standardFlags:t.standardFlag,linetype:t.lineType,lineWeight:t.lineweight,isOff:t.off,color:r,isPlottable:t.plotFlag!=0});this.processCommonTableEntryAttrs(t,i),n.tables.layerTable.add(i)})}processViewports(e,n){e.tables.VPORT.entries.forEach(t=>{const r=new o.AcDbViewportTableRecord;this.processCommonTableEntryAttrs(t,r),t.circleSides&&(r.circleSides=t.circleSides),r.standardFlag=t.standardFlag,r.center.copy(t.center),r.lowerLeftCorner.copy(t.lowerLeftCorner),r.upperRightCorner.copy(t.upperRightCorner),t.snapBasePoint&&r.snapBase.copy(t.snapBasePoint),t.snapRotationAngle&&(r.snapAngle=t.snapRotationAngle),t.snapSpacing&&r.snapIncrements.copy(t.snapSpacing),t.majorGridLines&&(r.gridMajor=t.majorGridLines),t.gridSpacing&&r.gridIncrements.copy(t.gridSpacing),t.backgroundObjectId&&(r.backgroundObjectId=t.backgroundObjectId),r.gsView.center.copy(t.center),r.gsView.viewDirectionFromTarget.copy(t.viewDirectionFromTarget),r.gsView.viewTarget.copy(t.viewTarget),t.lensLength&&(r.gsView.lensLength=t.lensLength),t.frontClippingPlane&&(r.gsView.frontClippingPlane=t.frontClippingPlane),t.backClippingPlane&&(r.gsView.backClippingPlane=t.backClippingPlane),t.viewHeight&&(r.gsView.viewHeight=t.viewHeight),t.viewTwistAngle&&(r.gsView.viewTwistAngle=t.viewTwistAngle),t.frozenLayers&&(r.gsView.frozenLayers=t.frozenLayers),t.styleSheet&&(r.gsView.styleSheet=t.styleSheet),t.renderMode&&(r.gsView.renderMode=t.renderMode),t.viewMode&&(r.gsView.viewMode=t.viewMode),t.ucsIconSetting&&(r.gsView.ucsIconSetting=t.ucsIconSetting),t.ucsOrigin&&r.gsView.ucsOrigin.copy(t.ucsOrigin),t.ucsXAxis&&r.gsView.ucsXAxis.copy(t.ucsXAxis),t.ucsYAxis&&r.gsView.ucsYAxis.copy(t.ucsYAxis),t.orthographicType&&(r.gsView.orthographicType=t.orthographicType),t.shadePlotSetting&&(r.gsView.shadePlotSetting=t.shadePlotSetting),t.shadePlotObjectId&&(r.gsView.shadePlotObjectId=t.shadePlotObjectId),t.visualStyleObjectId&&(r.gsView.visualStyleObjectId=t.visualStyleObjectId),t.isDefaultLightingOn&&(r.gsView.isDefaultLightingOn=t.isDefaultLightingOn),t.defaultLightingType&&(r.gsView.defaultLightingType=t.defaultLightingType),t.brightness&&(r.gsView.brightness=t.brightness),t.contrast&&(r.gsView.contrast=t.contrast),t.ambientColor&&(r.gsView.ambientColor=t.ambientColor),n.tables.viewportTable.add(r)})}processBlockTables(e,n){e.tables.BLOCK_RECORD.entries.forEach(t=>{let r=n.tables.blockTable.getAt(t.name);r||(r=new o.AcDbBlockTableRecord,r.objectId=t.handle.toString(),r.name=t.name,n.tables.blockTable.add(r)),!r.isModelSapce&&!r.isPaperSapce&&t.entities&&t.entities.length>0&&this.processEntitiesInBlock(t.entities,r)})}processBlocks(e,n){}async processEntitiesInBlock(e,n){const s=new b,t=e.length;for(let r=0;r<t;r++){const i=e[r],l=s.convert(i);l&&n.appendEntity(l)}}async processEntities(e,n,s,t,r){const i=new b,l=e.entities,a=l.length,p=new o.AcDbBatchProcessing(a,100-t.value,s),c=n.tables.blockTable.modelSpace;await p.processChunk(async(g,d)=>{for(let f=g;f<d;f++){const u=l[f],h=i.convert(u);h&&c.appendEntity(h)}if(r){let f=t.value+d/a*(100-t.value);f>100&&(f=100),await r(f,"ENTITY","IN-PROGRESS")}})}processHeader(e,n){const s=e.header;n.cecolor.colorIndex=s.CECOLOR||256,n.angBase=s.ANGBASE??0,n.angDir=s.ANGDIR??0,n.aunits=s.AUNITS??0,n.extmax=s.EXTMAX,n.extmin=s.EXTMIN,n.insunits=s.INSUNITS??1,n.pdmode=s.PDMODE??0,n.pdsize=s.PDSIZE??0}processCommonTableEntryAttrs(e,n){n.name=e.name,n.objectId=e.handle.toString(),n.ownerId=e.ownerHandle.toString()}processObjects(e,n){this.processLayouts(e,n),this.processImageDefs(e,n)}processLayouts(e,n){const s=n.dictionaries.layouts;e.objects.LAYOUT.forEach(r=>{const i=new o.AcDbLayout;i.layoutName=r.layoutName,i.tabOrder=r.tabOrder,i.blockTableRecordId=r.ownerHandle.toString(),i.limits.min.copy(r.minLimit),i.limits.max.copy(r.maxLimit),i.extents.min.copy(r.minExtent),i.extents.max.copy(r.maxExtent),this.processCommonObjectAttrs(r,i),s.setAt(i.layoutName,i)})}processImageDefs(e,n){const s=n.dictionaries.imageDefs;e.objects.IMAGEDEF.forEach(r=>{const i=new o.AcDbRasterImageDef;i.sourceFileName=r.fileName,this.processCommonObjectAttrs(r,i),s.setAt(i.objectId,i)})}processCommonObjectAttrs(e,n){n.objectId=e.handle.toString(),n.ownerId=e.ownerHandle.toString()}}D.AcDbLibreDwgConverter=T,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});