@mlightcad/dxf-json-converter 1.10.1 → 1.10.2

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 +1 @@
1
- (function(oe,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@mlightcad/data-model")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/data-model"],i):(oe=typeof globalThis<"u"?globalThis:oe||self,i(oe["dxf-json-converter"]={},oe.dataModel))})(this,function(oe,i){"use strict";var S,Ce,T,g,Pe,v,ie,G,b,H,k,re,ae,le,R,W,be,me,se,ce,Ne,Re,Oe,O,Y,I,de,xe,d,m,ye,N,we,z,A,X,Me,ue,B,_e,Ge,Fe,j,K,Ve,ve,$,Ae,fe,ke,Ie,Z,De,C,q,x,Te,y,J,P,Q,w,pe,Be,ge,M,ee,_,te,He,he,F;(S={})[S.None=0]="None",S[S.Anonymous=1]="Anonymous",S[S.NonConstant=2]="NonConstant",S[S.Xref=4]="Xref",S[S.XrefOverlay=8]="XrefOverlay",S[S.ExternallyDependent=16]="ExternallyDependent",S[S.ResolvedOrDependent=32]="ResolvedOrDependent",S[S.ReferencedXref=64]="ReferencedXref",(Ce={})[Ce.BYBLOCK=0]="BYBLOCK",Ce[Ce.BYLAYER=256]="BYLAYER",(T={})[T.Rotated=0]="Rotated",T[T.Aligned=1]="Aligned",T[T.Angular=2]="Angular",T[T.Diameter=3]="Diameter",T[T.Radius=4]="Radius",T[T.Angular3Point=5]="Angular3Point",T[T.Ordinate=6]="Ordinate",T[T.ReferenceIsExclusive=32]="ReferenceIsExclusive",T[T.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",T[T.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag",(g={})[g.TopLeft=1]="TopLeft",g[g.TopCenter=2]="TopCenter",g[g.TopRight=3]="TopRight",g[g.MiddleLeft=4]="MiddleLeft",g[g.MiddleCenter=5]="MiddleCenter",g[g.MiddleRight=6]="MiddleRight",g[g.BottomLeft=7]="BottomLeft",g[g.BottomCenter=8]="BottomCenter",g[g.BottomRight=9]="BottomRight",(Pe={})[Pe.AtLeast=1]="AtLeast",Pe[Pe.Exact=2]="Exact";var We=((v={})[v.Center=0]="Center",v[v.Above=1]="Above",v[v.Outside=2]="Outside",v[v.JIS=3]="JIS",v[v.Below=4]="Below",v);(ie={})[ie.WithDimension=0]="WithDimension",ie[ie.AddLeader=1]="AddLeader",ie[ie.Independent=2]="Independent",(G={})[G.BothOutside=0]="BothOutside",G[G.ArrowFirst=1]="ArrowFirst",G[G.TextFirst=2]="TextFirst",G[G.Auto=3]="Auto";var Le=((b={})[b.Feet=0]="Feet",b[b.None=1]="None",b[b.Inch=2]="Inch",b[b.FeetAndInch=3]="FeetAndInch",b[b.Leading=4]="Leading",b[b.Trailing=8]="Trailing",b[b.LeadingAndTrailing=12]="LeadingAndTrailing",b),Ke=((H={})[H.None=0]="None",H[H.Leading=1]="Leading",H[H.Trailing=2]="Trailing",H[H.LeadingAndTrailing=3]="LeadingAndTrailing",H),$e=((k={})[k.Center=0]="Center",k[k.First=1]="First",k[k.Second=2]="Second",k[k.OverFirst=3]="OverFirst",k[k.OverSecond=4]="OverSecond",k),Ze=((re={})[re.Bottom=0]="Bottom",re[re.Center=1]="Center",re[re.Top=2]="Top",re);(ae={})[ae.None=0]="None",ae[ae.UseDrawingBackground=1]="UseDrawingBackground",ae[ae.Custom=2]="Custom",(le={})[le.Horizontal=0]="Horizontal",le[le.Diagonal=1]="Diagonal",le[le.NotStacked=2]="NotStacked",(R={})[R.Scientific=1]="Scientific",R[R.Decimal=2]="Decimal",R[R.Engineering=3]="Engineering",R[R.Architectural=4]="Architectural",R[R.Fractional=5]="Fractional",R[R.WindowDesktop=6]="WindowDesktop",(W={})[W.Decimal=0]="Decimal",W[W.DegreesMinutesSecond=1]="DegreesMinutesSecond",W[W.Gradian=2]="Gradian",W[W.Radian=3]="Radian";var qe=((be={})[be.PatternFill=0]="PatternFill",be[be.SolidFill=1]="SolidFill",be);(me={})[me.NonAssociative=0]="NonAssociative",me[me.Associative=1]="Associative",(se={})[se.Normal=0]="Normal",se[se.Outer=1]="Outer",se[se.Ignore=2]="Ignore",(ce={})[ce.UserDefined=0]="UserDefined",ce[ce.Predefined=1]="Predefined",ce[ce.Custom=2]="Custom",(Ne={})[Ne.NotAnnotated=0]="NotAnnotated",Ne[Ne.Annotated=1]="Annotated",(Re={})[Re.Solid=0]="Solid",Re[Re.Gradient=1]="Gradient",(Oe={})[Oe.TwoColor=0]="TwoColor",Oe[Oe.OneColor=1]="OneColor",(O={})[O.Default=0]="Default",O[O.External=1]="External",O[O.Polyline=2]="Polyline",O[O.Derived=4]="Derived",O[O.Textbox=8]="Textbox",O[O.Outermost=16]="Outermost",(Y={})[Y.Line=1]="Line",Y[Y.Circular=2]="Circular",Y[Y.Elliptic=3]="Elliptic",Y[Y.Spline=4]="Spline";var Je=((I={})[I.Off=0]="Off",I[I.Solid=1]="Solid",I[I.Dashed=2]="Dashed",I[I.Dotted=3]="Dotted",I[I.ShotDash=4]="ShotDash",I[I.MediumDash=5]="MediumDash",I[I.LongDash=6]="LongDash",I[I.DoubleShortDash=7]="DoubleShortDash",I[I.DoubleMediumDash=8]="DoubleMediumDash",I[I.DoubleLongDash=9]="DoubleLongDash",I[I.DoubleMediumLongDash=10]="DoubleMediumLongDash",I[I.SparseDot=11]="SparseDot",I);Je.Off,(de={})[de.Standard=-3]="Standard",de[de.ByLayer=-2]="ByLayer",de[de.ByBlock=-1]="ByBlock",(xe={})[xe.English=0]="English",xe[xe.Metric=1]="Metric",(d={})[d.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",d[d.FRONT_CLIPPING=2]="FRONT_CLIPPING",d[d.BACK_CLIPPING=4]="BACK_CLIPPING",d[d.UCS_FOLLOW=8]="UCS_FOLLOW",d[d.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",d[d.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",d[d.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",d[d.FAST_ZOOM=128]="FAST_ZOOM",d[d.SNAP_MODE=256]="SNAP_MODE",d[d.GRID_MODE=512]="GRID_MODE",d[d.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",d[d.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",d[d.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",d[d.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",d[d.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",d[d.UNUSED=32768]="UNUSED",d[d.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",d[d.VIEWPORT_OFF=131072]="VIEWPORT_OFF",d[d.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",d[d.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",d[d.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",d[d.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE",(m={})[m.OPTIMIZED_2D=0]="OPTIMIZED_2D",m[m.WIREFRAME=1]="WIREFRAME",m[m.HIDDEN_LINE=2]="HIDDEN_LINE",m[m.FLAT_SHADED=3]="FLAT_SHADED",m[m.GOURAUD_SHADED=4]="GOURAUD_SHADED",m[m.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",m[m.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",(ye={})[ye.UCS_UNCHANGED=0]="UCS_UNCHANGED",ye[ye.HAS_OWN_UCS=1]="HAS_OWN_UCS",(N={})[N.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",N[N.TOP=1]="TOP",N[N.BOTTOM=2]="BOTTOM",N[N.FRONT=3]="FRONT",N[N.BACK=4]="BACK",N[N.LEFT=5]="LEFT",N[N.RIGHT=6]="RIGHT",(we={})[we.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",we[we.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",(z={})[z.ByLayer=0]="ByLayer",z[z.ByBlock=1]="ByBlock",z[z.ByDictionaryDefault=2]="ByDictionaryDefault",z[z.ByObject=3]="ByObject",(A={})[A.NotAllowed=0]="NotAllowed",A[A.AllowErase=1]="AllowErase",A[A.AllowTransform=2]="AllowTransform",A[A.AllowChangeColor=4]="AllowChangeColor",A[A.AllowChangeLayer=8]="AllowChangeLayer",A[A.AllowChangeLinetype=16]="AllowChangeLinetype",A[A.AllowChangeLinetypeScale=32]="AllowChangeLinetypeScale",A[A.AllowChangeVisibility=64]="AllowChangeVisibility",A[A.AllowClone=128]="AllowClone",A[A.AllowChangeLineweight=256]="AllowChangeLineweight",A[A.AllowChangePlotStyleName=512]="AllowChangePlotStyleName",A[A.AllowAllExceptClone=895]="AllowAllExceptClone",A[A.AllowAll=1023]="AllowAll",A[A.DisableProxyWarning=1024]="DisableProxyWarning",A[A.R13FormatProxy=32768]="R13FormatProxy",(X={})[X.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",X[X.CAST=1]="CAST",X[X.RECEIVE=2]="RECEIVE",X[X.IGNORE=3]="IGNORE",(Me={})[Me.RayTrace=0]="RayTrace",Me[Me.ShadowMap=1]="ShadowMap",(ue={})[ue.BeforeText=0]="BeforeText",ue[ue.AboveText=1]="AboveText",ue[ue.None=2]="None",(B={})[B.NONE=0]="NONE",B[B.INVISIBLE=1]="INVISIBLE",B[B.CONSTANT=2]="CONSTANT",B[B.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",B[B.PRESET=8]="PRESET",(_e={})[_e.MULTILINE=2]="MULTILINE",_e[_e.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE",(Ge={})[Ge.ProxyEntity=498]="ProxyEntity",(Fe={})[Fe.Dwg=0]="Dwg",Fe[Fe.Dxf=1]="Dxf",(j={})[j.First=1]="First",j[j.Second=2]="Second",j[j.Third=4]="Third",j[j.Fourth=8]="Fourth",(K={})[K.ShowImage=1]="ShowImage",K[K.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",K[K.UseClippingBoundary=4]="UseClippingBoundary",K[K.TransparencyIsOn=8]="TransparencyIsOn",(Ve={})[Ve.Rectangular=1]="Rectangular",Ve[Ve.Polygonal=2]="Polygonal",(ve={})[ve.Outside=0]="Outside",ve[ve.Inside=1]="Inside",($={})[$.TextAnnotation=0]="TextAnnotation",$[$.ToleranceAnnotation=1]="ToleranceAnnotation",$[$.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",$[$.NoAnnotation=3]="NoAnnotation",(Ae={})[Ae.Distant=1]="Distant",Ae[Ae.Point=2]="Point",Ae[Ae.Spot=3]="Spot",(fe={})[fe.None=0]="None",fe[fe.InverseLinear=1]="InverseLinear",fe[fe.InverseSquare=2]="InverseSquare",(ke={})[ke.IS_CLOSED=1]="IS_CLOSED",ke[ke.PLINE_GEN=128]="PLINE_GEN",(Ie={})[Ie.Top=0]="Top",Ie[Ie.Zero=1]="Zero",Ie[Ie.Bottom=2]="Bottom",(Z={})[Z.HasVertex=1]="HasVertex",Z[Z.Closed=2]="Closed",Z[Z.SuppressStartCaps=4]="SuppressStartCaps",Z[Z.SuppressEndCaps=8]="SuppressEndCaps",(De={})[De.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",De[De.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",De[De.BY_STYLE=5]="BY_STYLE",(C={})[C.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",C[C.CURVE_FIT=2]="CURVE_FIT",C[C.SPLINE_FIT=4]="SPLINE_FIT",C[C.POLYLINE_3D=8]="POLYLINE_3D",C[C.POLYGON_3D=16]="POLYGON_3D",C[C.CLOSED_POLYGON=32]="CLOSED_POLYGON",C[C.POLYFACE=64]="POLYFACE",C[C.CONTINUOUS=128]="CONTINUOUS";var Ue=((q={})[q.NONE=0]="NONE",q[q.QUADRATIC=5]="QUADRATIC",q[q.CUBIC=6]="CUBIC",q[q.BEZIER=8]="BEZIER",q);(x={})[x.NONE=0]="NONE",x[x.CLOSED=1]="CLOSED",x[x.PERIODIC=2]="PERIODIC",x[x.RATIONAL=4]="RATIONAL",x[x.PLANAR=8]="PLANAR",x[x.LINEAR=16]="LINEAR",(Te={})[Te.NONE=0]="NONE",Te[Te.MIRRORED_X=2]="MIRRORED_X",Te[Te.MIRRORED_Y=4]="MIRRORED_Y",(y={})[y.LEFT=0]="LEFT",y[y.CENTER=1]="CENTER",y[y.RIGHT=2]="RIGHT",y[y.ALIGNED=3]="ALIGNED",y[y.MIDDLE=4]="MIDDLE",y[y.FIT=5]="FIT",(J={})[J.BASELINE=0]="BASELINE",J[J.BOTTOM=1]="BOTTOM",J[J.MIDDLE=2]="MIDDLE",J[J.TOP=3]="TOP";var Qe=((P={})[P.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",P[P.TANGENT_DEFINED=2]="TANGENT_DEFINED",P[P.NOT_USED=4]="NOT_USED",P[P.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",P[P.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",P[P.FOR_POLYLINE=32]="FOR_POLYLINE",P[P.FOR_POLYGON=64]="FOR_POLYGON",P[P.POLYFACE=128]="POLYFACE",P);(Q={})[Q.ShowImage=1]="ShowImage",Q[Q.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Q[Q.UseClippingBoundary=4]="UseClippingBoundary",Q[Q.Transparency=8]="Transparency",(w={})[w.NOT_APPLICABLE=0]="NOT_APPLICABLE",w[w.KEEP_EXISTING=1]="KEEP_EXISTING",w[w.USE_CLONE=2]="USE_CLONE",w[w.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",w[w.VALUE_NAME=4]="VALUE_NAME",w[w.UNMANGLE_NAME=5]="UNMANGLE_NAME",(pe={})[pe.NOUNIT=0]="NOUNIT",pe[pe.CENTIMETERS=2]="CENTIMETERS",pe[pe.INCH=5]="INCH",(Be={})[Be.PSLTSCALE=1]="PSLTSCALE",Be[Be.LIMCHECK=2]="LIMCHECK",(ge={})[ge.INCHES=0]="INCHES",ge[ge.MILLIMETERS=1]="MILLIMETERS",ge[ge.PIXELS=2]="PIXELS",(M={})[M.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",M[M.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",M[M.DRAWING_LIMITS=2]="DRAWING_LIMITS",M[M.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",M[M.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",M[M.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION",(ee={})[ee.AS_DISPLAYED=0]="AS_DISPLAYED",ee[ee.WIREFRAME=1]="WIREFRAME",ee[ee.HIDDEN=2]="HIDDEN",ee[ee.RENDERED=3]="RENDERED",(_={})[_.DRAFT=0]="DRAFT",_[_.PREVIEW=1]="PREVIEW",_[_.NORMAL=2]="NORMAL",_[_.PRESENTATION=3]="PRESENTATION",_[_.MAXIMUM=4]="MAXIMUM",_[_.CUSTOM=5]="CUSTOM",We.Above,We.Center,Le.Trailing,Le.Feet,Ke.None,$e.Center,Ze.Center,Le.Trailing,Le.Feet,Le.Trailing,Le.Trailing,(te={})[te.NONE=0]="NONE",te[te.AbsoluteRotation=1]="AbsoluteRotation",te[te.TextEmbedded=2]="TextEmbedded",te[te.ShapeEmbedded=4]="ShapeEmbedded",(He={})[He.PaperSpace=1]="PaperSpace",(he={})[he.XrefDependent=16]="XrefDependent",he[he.XrefResolved=32]="XrefResolved",he[he.Referenced=64]="Referenced",(F={})[F.Off=0]="Off",F[F.Perspective=1]="Perspective",F[F.ClipFront=2]="ClipFront",F[F.ClipBack=4]="ClipBack",F[F.UcsFollow=8]="UcsFollow",F[F.ClipFrontByFrontZ=16]="ClipFrontByFrontZ";class Ye{convert(e){const t=this.createEntity(e);return t&&this.processCommonAttrs(e,t),t}createEntity(e){return e.type=="3DFACE"?this.convertFace(e):e.type=="ARC"?this.convertArc(e):e.type=="ATTDEF"?this.convertAttributeDefinition(e):e.type=="ATTRIB"?this.convertAttribute(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=="MLINE"?this.convertMLine(e):e.type=="MULTILEADER"||e.type=="MLEADER"?this.convertMLeader(e):e.type=="POLYLINE"?this.convertPolyline(e):e.type=="POINT"?this.convertPoint(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=="SHAPE"?this.convertShape(e):e.type=="SOLID"?this.convertSolid(e):e.type=="VIEWPORT"?this.convertViewport(e):e.type=="WIPEOUT"?this.convertWipeout(e):e.type=="XLINE"?this.convertXline(e):e.type=="INSERT"?this.convertBlockReference(e):e.type=="ACAD_PROXY_ENTITY"?this.convertProxyEntity(e):null}convertProxyEntity(e){const t=new i.AcDbProxyEntity;if(t.proxyEntityClassId=e.proxyEntityClassId,e.originalDxfName&&(t.originalDxfName=e.originalDxfName),e.objectDrawingFormat!=null&&(t.graphicsMetafileType=e.objectDrawingFormat),e.applicationEntityClassId!=null&&(t.originalClassName=String(e.applicationEntityClassId)),e.graphicsData){const n=i.hexStringsToBytes([e.graphicsData]),a=e.graphicsDataSize??n.length;t.setProxyGraphic(n.subarray(0,a))}return t}convertFace(e){const t=new i.AcDbFace;return e.vertices.forEach((n,a)=>t.setVertexAt(a,n)),t}convertArc(e){const t=e.extrusionDirection??i.AcGeVector3d.Z_AXIS;return new i.AcDbArc(i.transformOcsPointToWcs(e.center,t),e.radius,i.AcGeMathUtil.degToRad(e.startAngle),i.AcGeMathUtil.degToRad(e.endAngle),t)}convertAttributeCommon(e,t){t.textString=e.text,t.height=e.textHeight,t.position.copy(e.startPoint);const n=e.alignmentPoint,a=!n||n.x===0&&n.y===0&&(n.z??0)===0;n&&!a?t.alignmentPoint.copy(n):t.alignmentPoint.copy(e.startPoint),t.rotation=e.rotation,t.oblique=e.obliqueAngle??0,t.thickness=e.thickness,t.tag=e.tag,t.fieldLength=0,t.isInvisible=(e.attributeFlag&i.AcDbAttributeFlags.Invisible)!==0,t.isConst=(e.attributeFlag&i.AcDbAttributeFlags.Const)!==0,t.isVerifiable=(e.attributeFlag&i.AcDbAttributeFlags.Verifiable)!==0,t.isPreset=(e.attributeFlag&i.AcDbAttributeFlags.Preset)!==0,t.isReallyLocked=!!e.isReallyLocked,t.isMTextAttribute=(e.mtextFlag&i.AcDbAttributeMTextFlag.MultiLine)!==0,t.isConstMTextAttribute=(e.mtextFlag&i.AcDbAttributeMTextFlag.ConstMultiLine)!==0}convertAttribute(e){const t=new i.AcDbAttribute;return this.convertAttributeCommon(e,t),t.styleName=e.textStyle,t.horizontalMode=e.horizontalJustification,t.verticalMode=e.verticalJustification,t.widthFactor=e.scale??1,t.lockPositionInBlock=e.lockPositionFlag,t}convertAttributeDefinition(e){const t=new i.AcDbAttributeDefinition;return this.convertAttributeCommon(e,t),t.styleName=e.styleName,t.horizontalMode=e.halign,t.verticalMode=e.valign,t.widthFactor=e.xScale??1,t.prompt=e.prompt,t}convertCirle(e){const t=e.extrusionDirection??i.AcGeVector3d.Z_AXIS;return new i.AcDbCircle(i.transformOcsPointToWcs(e.center,t),e.radius,t)}convertEllipse(e){const t=new i.AcGeVector3d(e.majorAxisEndPoint),n=t.length();return new i.AcDbEllipse(e.center,e.extrusionDirection??i.AcGeVector3d.Z_AXIS,t,n,n*e.axisRatio,e.startAngle,e.endAngle)}convertLine(e){const t=e.startPoint,n=e.endPoint;return new i.AcDbLine(new i.AcGePoint3d(t.x,t.y,t.z||0),new i.AcGePoint3d(n.x,n.y,n.z||0))}convertSpline(e){return i.AcDbSpline.fromDwgSpline(e)}convertPoint(e){const t=new i.AcDbPoint;return t.position=e.position,t}convertShape(e){const t=new i.AcDbShape;return t.position.copy(e.insertionPoint),t.size=e.size,t.name=e.shapeName,t.rotation=i.AcGeMathUtil.degToRad(e.rotation||0),t.widthFactor=e.xScale??1,t.oblique=i.AcGeMathUtil.degToRad(e.obliqueAngle||0),t.thickness=e.thickness??0,t.normal.copy(e.extrusionDirection??{x:0,y:0,z:1}),t}convertSolid(e){const t=new i.AcDbTrace;return e.points.forEach((n,a)=>t.setPointAt(a,n)),t.thickness=e.thickness,t}convertPolyline(e){var u;const t=!!(e.flag&1),n=!!(e.flag&8),a=!!(e.flag&16),r=!!(e.flag&64),o=!!(e.flag&32),l=[],c=[],f=[];if((u=e.vertices)==null||u.map(s=>{s.flag&Qe.SPLINE_CONTROL_POINT||(r&&s.flag&128?s.flag&64?(l.push({x:s.x,y:s.y,z:s.z}),c.push(s.bulge??0)):s.faces&&s.faces.length>=3&&f.push([...s.faces]):(l.push({x:s.x,y:s.y,z:s.z}),c.push(s.bulge??0)))}),a){const s=e.meshMVertexCount,h=e.meshNVertexCount;return new i.AcDbPolygonMesh(s,h,l,t,o)}else{if(r)return new i.AcDbPolyFaceMesh(l,f);if(n){let s=i.AcDbPoly3dType.SimplePoly;return e.flag&4&&(e.smoothType==Ue.CUBIC?s=i.AcDbPoly3dType.CubicSplinePoly:e.smoothType==Ue.QUADRATIC&&(s=i.AcDbPoly3dType.QuadSplinePoly)),new i.AcDb3dPolyline(s,l,t)}else{let s=i.AcDbPoly2dType.SimplePoly;return e.flag&2?s=i.AcDbPoly2dType.FitCurvePoly:e.flag&4&&(e.smoothType==Ue.CUBIC?s=i.AcDbPoly2dType.CubicSplinePoly:e.smoothType==Ue.QUADRATIC&&(s=i.AcDbPoly2dType.QuadSplinePoly)),new i.AcDb2dPolyline(s,l,0,t,e.startWidth,e.endWidth,c)}}}convertLWPolyline(e){var a;const t=new i.AcDbPolyline;t.closed=!!(e.flag&1);const n=e.constantWidth??-1;return(a=e.vertices)==null||a.forEach((r,o)=>{t.addVertexAt(o,new i.AcGePoint2d(r.x,r.y),r.bulge,r.startWidth??n,r.endWidth??n)}),t}convertHatch(e){var a;const t=new i.AcDbHatch;if((a=e.definitionLines)==null||a.forEach(r=>{t.definitionLines.push({angle:i.AcGeMathUtil.degToRad(r.angle||0),base:r.base,offset:r.offset,dashLengths:r.numberOfDashLengths>0?r.dashLengths:[]})}),t.isSolidFill=e.solidFill==qe.SolidFill,t.hatchStyle=e.hatchStyle,t.patternName=e.patternName,t.patternType=e.patternType,t.patternAngle=e.patternAngle==null?0:i.AcGeMathUtil.degToRad(e.patternAngle),t.patternScale=e.patternScale==null?0:e.patternScale,e.boundaryPaths.forEach(r=>{if(r.boundaryPathTypeFlag&2){const l=r,c=new i.AcGePolyline2d;c.closed=l.isClosed,l.vertices.forEach((f,u)=>{c.addVertexAt(u,{x:f.x,y:f.y,bulge:f.bulge})}),t.add(c)}else{const l=r,c=[];l.edges.forEach(u=>{if(u.type==1){const s=u;c.push(new i.AcGeLine2d(s.start,s.end))}else if(u.type==2){const s=u;c.push(new i.AcGeCircArc2d(s.center,s.radius,i.AcGeMathUtil.degToRad(s.startAngle||0),i.AcGeMathUtil.degToRad(s.endAngle||0),!s.isCCW))}else if(u.type==3){const s=u;new i.AcGeVector2d().subVectors(s.end,s.center);const L=Math.sqrt(Math.pow(s.end.x,2)+Math.pow(s.end.y,2)),D=L*s.lengthOfMinorAxis;let E=i.AcGeMathUtil.degToRad(s.startAngle||0),V=i.AcGeMathUtil.degToRad(s.endAngle||0);const ne=Math.atan2(s.end.y,s.end.x);s.isCCW||(E=Math.PI*2-E,V=Math.PI*2-V),c.push(new i.AcGeEllipseArc2d({...s.center,z:0},L,D,E,V,!s.isCCW,ne))}else if(u.type==4){const s=i.AcGeSpline3d.fromDwgSplineEdge(u);s&&c.push(s)}});const f=i.AcGeLoop2d.buildFromEdges(c);f.length==0&&c.length>0?t.add(new i.AcGeLoop2d(c)):f.forEach(u=>t.add(u))}}),e.gradientFlag){const r=e;if(t.hatchObjectType=i.AcDbHatchObjectType.GradientObject,t.gradientName=r.gradientName,t.gradientAngle=r.gradientRotation??0,t.gradientShift=r.gradientDefinition??0,t.gradientOneColorMode=r.gradientColorFlag==1,t.shadeTintValue=r.colorTint??0,r.gradientColors){const o=r.gradientColors.length;o>1?(t.gradientStartColor=r.gradientColors[0].rgb,t.gradientEndColor=r.gradientColors[1].rgb):o>0&&(t.gradientStartColor=r.gradientColors[0].rgb)}}return t}convertTable(e){const t=new i.AcDbTable(e.name,e.rowCount,e.columnCount);return t.tableDataVersion=e.version,t.tableStyleId=e.tableStyleId,t.owningBlockRecordId=e.blockRecordHandle,e.directionVector&&(t.horizontalDirection=new i.AcGeVector3d(e.directionVector)),t.attachmentPoint=e.attachmentPoint,t.position.copy(e.startPoint),t.tableValueFlag=e.tableValue,t.tableOverrideFlag=e.overrideFlag,t.borderColorOverrideFlag=e.borderColorOverrideFlag,t.borderLineweightOverrideFlag=e.borderLineWeightOverrideFlag,t.borderVisibilityOverrideFlag=e.borderVisibilityOverrideFlag,e.columnWidthArr.forEach((n,a)=>t.setColumnWidth(a,n)),e.rowHeightArr.forEach((n,a)=>t.setRowHeight(a,n)),e.cells.forEach((n,a)=>{t.setCell(a,n)}),t}convertText(e){const t=new i.AcDbText;t.textString=e.text,t.styleName=e.styleName,t.height=e.textHeight,t.position.copy(e.startPoint);const n=e.endPoint,a=!n||n.x===0&&n.y===0&&(n.z??0)===0;return n&&!a?t.alignmentPoint.copy(n):t.alignmentPoint.copy(e.startPoint),t.rotation=i.AcGeMathUtil.degToRad(e.rotation||0),t.oblique=e.obliqueAngle??0,t.thickness=e.thickness,t.horizontalMode=e.halign,t.verticalMode=e.valign,t.widthFactor=e.xScale??1,t}convertMText(e){const t=new i.AcDbMText;return t.contents=e.text,e.styleName!=null&&(t.styleName=e.styleName),t.height=e.height,t.width=e.width,t.rotation=i.AcGeMathUtil.degToRad(e.rotation||0),t.location=e.insertionPoint,t.attachmentPoint=e.attachmentPoint,e.direction&&(t.direction=new i.AcGeVector3d(e.direction)),t.drawingDirection=e.drawingDirection,t}convertLeader(e){var n;const t=new i.AcDbLeader;return(n=e.vertices)==null||n.forEach(a=>{t.appendVertex(a)}),t.hasArrowHead=e.isArrowheadEnabled,t.hasHookLine=e.isHooklineExists,t.isHookLineSameDirection=e.isHooklineSameDirection,t.isSplined=e.isSpline,t.dimensionStyle=e.styleName??"",t.annoType=e.leaderCreationFlag,t.textHeight=e.textHeight??0,t.textWidth=e.textWidth??0,t.byBlockColor=e.byBlockColor,t.associatedAnnotation=e.associatedAnnotation??"",e.normal&&(t.normal=e.normal),e.horizontalDirection&&(t.horizontalDirection=e.horizontalDirection),e.offsetFromBlock&&(t.offsetFromBlock=e.offsetFromBlock),e.offsetFromAnnotation&&(t.offsetFromAnnotation=e.offsetFromAnnotation),t}convertMLine(e){const t=new i.AcDbMLine;return t.styleName=e.name||"STANDARD",t.styleObjectHandle=e.styleObjectHandle,t.scale=e.scale,t.justification=e.justification,t.flags=e.flags,t.styleCount=e.styleCount,t.startPosition=e.startPosition,t.normal=e.extrusionDirection??i.AcGeVector3d.Z_AXIS,t.segments=(e.segments??[]).map(n=>{var a;return{position:n.position,direction:n.direction,miterDirection:n.miterDirection,elements:((a=n.elements)==null?void 0:a.map(r=>({parameterCount:r.parameterCount,parameters:r.parameters??[],fillCount:r.fillCount,fillParameters:r.fillParameters??[]})))??[]}}),t}convertMLeader(e){var Ee,Se;const t=new i.AcDbMLeader,n=e;t.version=e.version,t.leaderStyleId=e.leaderStyleId,e.leaderStyleId&&(t.mleaderStyleId=e.leaderStyleId),t.propertyOverrideFlag=e.propertyOverrideFlag,t.leaderLineType=e.leaderLineType??i.AcDbMLeaderLineType.StraightLeader,e.leaderLineColor!=null&&(t.leaderLineColor=i.decodeMLeaderStyleRawColor(e.leaderLineColor)),t.leaderLineTypeId=e.leaderLineTypeId,t.leaderLineWeight=e.leaderLineWeight,t.landingEnabled=e.landingEnabled,t.doglegEnabled=e.doglegEnabled??!1,t.doglegLength=e.doglegLength??0,t.arrowheadId=e.arrowheadId,t.arrowheadSize=e.arrowheadSize,t.textStyleId=e.textStyleId,t.textLeftAttachmentType=e.textLeftAttachmentType,t.textRightAttachmentType=e.textRightAttachmentType,t.textAngleType=e.textAngleType,t.textAlignmentType=e.textAlignmentType,e.textColor!=null&&(t.textColor=i.decodeMLeaderStyleRawColor(e.textColor)),t.textFrameEnabled=e.textFrameEnabled,t.landingGap=e.landingGap,t.textAttachment=e.textAttachment,t.textFlowDirection=e.textFlowDirection,this.isValidHandleId(e.blockContentId)&&(t.blockContentId=e.blockContentId),e.blockContentColor!=null&&(t.blockContentColor=i.decodeMLeaderStyleRawColor(e.blockContentColor)),t.blockContentRotation=e.blockContentRotation,t.blockContentConnectionType=e.blockContentConnectionType,t.annotativeScaleEnabled=e.annotativeScaleEnabled,t.arrowheadOverrides=e.arrowheadOverrides?e.arrowheadOverrides.map(p=>({...p})):[],t.blockAttributes=e.blockAttributes?e.blockAttributes.map(p=>({...p})):[],t.textDirectionNegative=e.textDirectionNegative,t.textAlignInIPE=e.textAlignInIPE,t.bottomTextAttachmentDirection=e.bottomTextAttachmentDirection,t.topTextAttachmentDirection=e.topTextAttachmentDirection,t.contentScale=e.contentScale,t.textLineSpacingStyle=e.textLineSpacingStyle,e.textBackgroundColor!=null&&(t.textBackgroundColor=i.decodeMLeaderStyleRawColor(e.textBackgroundColor)),t.textBackgroundScaleFactor=e.textBackgroundScaleFactor,t.textBackgroundTransparency=e.textBackgroundTransparency,t.textBackgroundColorOn=e.textBackgroundColorOn,t.textFillOn=e.textFillOn,t.textColumnType=e.textColumnType,t.textUseAutoHeight=e.textUseAutoHeight,t.textColumnWidth=e.textColumnWidth,t.textColumnGutterWidth=e.textColumnGutterWidth,t.textColumnFlowReversed=e.textColumnFlowReversed,t.textColumnHeight=e.textColumnHeight,t.textUseWordBreak=e.textUseWordBreak,t.hasMText=e.hasMText,t.hasBlock=e.hasBlock,t.planeNormalReversed=e.planeNormalReversed,e.blockContentScale&&(t.blockContentScale=new i.AcGeVector3d(e.blockContentScale)),e.contentBasePosition&&(t.contentBasePosition=new i.AcGePoint3d().copy(e.contentBasePosition)),e.textAnchor&&(t.textAnchor=new i.AcGePoint3d().copy(e.textAnchor)),e.planeOrigin&&(t.planeOrigin=new i.AcGePoint3d().copy(e.planeOrigin)),e.planeXAxisDirection&&(t.planeXAxisDirection=new i.AcGeVector3d(e.planeXAxisDirection)),e.planeYAxisDirection&&(t.planeYAxisDirection=new i.AcGeVector3d(e.planeYAxisDirection));const a=n.textContent,r=a&&typeof a=="object"?a:void 0,o=typeof a=="string"&&a.length>0||this.readString(r??{},["text","contents"])!=null||this.readString(n,["text","contents","mtext"])!=null,l=e.contentType??(o?i.AcDbMLeaderContentType.MTextContent:e.blockContent?i.AcDbMLeaderContentType.BlockContent:i.AcDbMLeaderContentType.NoneContent);t.contentType=l;const c=this.readPoint(n,["normal","extrusionDirection"]);c&&(t.normal=c);const f=this.readString(r??{},["styleName","textStyleName","textStyle"])??this.readString(n,["textStyleName","textStyle","styleName"]);f&&(t.textStyleName=f);const u=this.readPositiveNumber(r??{},["textHeight","height"])??this.readPositiveNumber(n,["textHeight","mtextHeight","textContentHeight"])??this.readPositiveNumber(n,["arrowheadSize","contentScale"]);u!=null&&(t.textHeight=u);const s=this.readPositiveNumber(r??{},["textWidth","width"])??this.readPositiveNumber(n,["textWidth","mtextWidth","textContentWidth"]);s!=null&&(t.textWidth=s),t.textLineSpacingFactor=this.readNumber(r??{},["lineSpacingFactor","textLineSpacingFactor"])??this.readNumber(n,["textLineSpacingFactor"])??t.textLineSpacingFactor;const h=this.readNumber(r??{},["textRotation","rotation"])??this.readNumber(n,["textRotation","mtextRotation","textContentRotation"]);h!=null&&(t.textRotation=i.AcGeMathUtil.degToRad(h));const L=this.readPoint(n,["textDirection","mtextDirection","textDirectionVector"]);L&&(t.textDirection=L);const D=this.readNumber(n,["textAttachmentPoint","attachmentPoint"]);D!=null&&D!==0&&(t.textAttachmentPoint=D);const E=e.textAttachmentDirection;E!=null&&(t.textAttachmentDirection=E);const V=this.readNumber(n,["textDrawingDirection","drawingDirection"]);V!=null&&(t.textDrawingDirection=V);const ne=typeof a=="string"?a:this.readString(r??{},["text","contents"])??this.readString(n,["text","contents","mtext"]),U=this.readPoint(r??{},["anchorPoint","textAnchor","textLocation","textPosition","textAnchorPoint"])??this.readPoint(n,["textAnchor","textLocation","textPosition","textAnchorPoint","contentBasePosition"]);if(ne!=null&&U&&(t.mtextContent={text:ne,anchorPoint:U}),e.blockContent){const p=e.blockContent,Xe=e.blockContent.blockContentId;if(this.isValidHandleId(Xe)){const je=this.readNumber(p,["color"]);t.blockContent={blockContentId:Xe,normal:this.readPoint(p,["normal"]),position:e.blockContent.position,scale:this.readPoint(p,["scale"]),rotation:this.readNumber(p,["rotation"]),color:je!=null?i.decodeMLeaderStyleRawColor(je):void 0,transformationMatrix:Array.isArray(e.blockContent.transformationMatrix)?e.blockContent.transformationMatrix:[]}}}else this.isValidHandleId(e.blockContentId)&&(t.blockContent={blockContentId:e.blockContentId,scale:e.blockContentScale,rotation:e.blockContentRotation,color:t.blockContentColor,transformationMatrix:[]});return(Ee=this.readMLeaderLeaders(n))==null||Ee.forEach(p=>{t.addLeader({lastLeaderLinePoint:p.lastLeaderLinePoint,lastLeaderLinePointSet:p.lastLeaderLinePointSet,doglegVector:p.doglegVector,doglegVectorSet:p.doglegVectorSet,doglegLength:p.doglegLength??e.doglegLength,breaks:p.breaks,leaderBranchIndex:p.leaderBranchIndex,leaderLines:p.leaderLines})}),t.numberOfLeaders===0&&((Se=this.readLeaderLineArray(n))==null||Se.forEach(p=>{t.addLeader({doglegLength:e.doglegLength}),t.addLeaderLine(t.numberOfLeaders-1,p)})),t.numberOfLeaders===0&&e.contentBasePosition&&t.addLeader({lastLeaderLinePoint:e.contentBasePosition,lastLeaderLinePointSet:!0,doglegLength:e.doglegLength}),t}convertDimension(e){if(e.subclassMarker=="AcDbAlignedDimension"){const t=e,n=new i.AcDbAlignedDimension(t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return t.insertionPoint&&(n.dimBlockPosition={...t.insertionPoint,z:0}),n.rotation=i.AcGeMathUtil.degToRad(t.rotationAngle||0),this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDbRotatedDimension"){const t=e,n=new i.AcDbRotatedDimension(t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return t.insertionPoint&&(n.dimBlockPosition={...t.insertionPoint,z:0}),n.rotation=i.AcGeMathUtil.degToRad(t.rotationAngle||0),this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDb3PointAngularDimension"){const t=e,n=new i.AcDb3PointAngularDimension(t.centerPoint,t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDb2LineAngularDimension"){const t=e,n=t.centerPoint??t.subDefinitionPoint2??t.definitionPoint,a=t.definitionPoint??t.subDefinitionPoint2;if(!n||!t.subDefinitionPoint1||!t.subDefinitionPoint2||!a)return null;const r=new i.AcDb3PointAngularDimension(n,t.subDefinitionPoint1,t.subDefinitionPoint2,a);return this.processDimensionCommonAttrs(e,r),r}else if(e.subclassMarker=="AcDbOrdinateDimension"){const t=e,n=new i.AcDbOrdinateDimension(t.subDefinitionPoint1,t.subDefinitionPoint2);return this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDbRadialDimension"){const t=e,n=new i.AcDbRadialDimension(t.definitionPoint,t.subDefinitionPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDbDiametricDimension"){const t=e,n=new i.AcDbDiametricDimension(t.definitionPoint,t.subDefinitionPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,n),n}return null}processImage(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.imageSize.copy(e.imageSize),t.isShownClipped=(e.flags|4)>0,t.isImageShown=(e.flags|3)>0,t.isImageTransparent=(e.flags|8)>0,t.imageDefId=e.imageDefHandle,t.isClipped=e.isClipped,e.clippingBoundaryPath.forEach(n=>{t.clipBoundary.push(new i.AcGePoint2d(n))}),t.width=Math.sqrt(e.uPixel.x**2+e.uPixel.y**2+e.uPixel.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vPixel.x**2+e.vPixel.y**2+e.vPixel.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uPixel.y,e.uPixel.x)}convertImage(e){const t=new i.AcDbRasterImage;return this.processImage(e,t),t.clipBoundaryType=e.clippingBoundaryType,t}processWipeout(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.imageSize.copy(e.imageSize),t.isShownClipped=(e.displayFlag|4)>0,t.isImageShown=(e.displayFlag|3)>0,t.isImageTransparent=(e.displayFlag|8)>0,t.imageDefId=e.imageDefHardId,t.isClipped=e.isClipping,e.boundary.forEach(n=>{t.clipBoundary.push(new i.AcGePoint2d(n))}),t.clipBoundaryType=e.boundaryType,t.width=Math.sqrt(e.uDirection.x**2+e.uDirection.y**2+e.uDirection.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vDirection.x**2+e.vDirection.y**2+e.vDirection.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uDirection.y,e.uDirection.x)}convertWipeout(e){const t=new i.AcDbWipeout;return this.processWipeout(e,t),t}convertViewport(e){const t=new i.AcDbViewport;return t.number=e.viewportId,t.centerPoint.copy(e.viewportCenter),t.height=e.height,t.width=e.width,t.viewCenter.copy(e.displayCenter),t.viewHeight=e.viewHeight,t}convertRay(e){const t=new i.AcDbRay;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertXline(e){const t=new i.AcDbXline;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertBlockReference(e){const t=new i.AcDbBlockReference(e.name);return e.insertionPoint&&t.position.copy(e.insertionPoint),t.scaleFactors.x=e.xScale||1,t.scaleFactors.y=e.yScale||1,t.scaleFactors.z=e.zScale||1,t.rotation=e.rotation!=null?i.AcGeMathUtil.degToRad(e.rotation):0,t.normal.copy(e.extrusionDirection??{x:0,y:0,z:1}),t}processDimensionCommonAttrs(e,t){t.dimBlockId=e.name,t.textPosition.copy(e.textPoint),t.textRotation=e.textRotation||0,e.textLineSpacingFactor&&(t.textLineSpacingFactor=e.textLineSpacingFactor),e.textLineSpacingStyle&&(t.textLineSpacingStyle=e.textLineSpacingStyle),t.dimensionStyleName=e.styleName,t.dimensionText=e.text||"",t.measurement=e.measurement,t.normal.copy(e.extrusionDirection??{x:0,y:0,z:1})}processCommonAttrs(e,t){if(t.layer=e.layer||"0",e.handle&&(t.objectId=e.handle.toString()),t.ownerId=e.ownerBlockRecordSoftId||"",e.lineType!=null&&(t.lineType=e.lineType),e.lineweight!=null&&(t.lineWeight=e.lineweight),e.lineTypeScale!=null&&(t.linetypeScale=e.lineTypeScale),e.color!=null||e.colorIndex!=null||e.colorName){const n=new i.AcCmColor;e.color!=null&&n.setRGBValue(e.color),e.colorIndex!=null&&(n.colorIndex=e.colorIndex),e.colorName&&(n.colorName=e.colorName),t.color=n}e.isVisible!=null&&(t.visibility=!e.isVisible),e.transparency!=null&&(t.transparency=i.AcCmTransparency.deserialize(e.transparency))}isValidHandleId(e){return e!=null&&e!==""&&e!=="0"}readNumber(e,t){for(const n of t){const a=e[n];if(typeof a=="number"&&Number.isFinite(a))return a}}readPositiveNumber(e,t){const n=this.readNumber(e,t);return n!=null&&n>0?n:void 0}readString(e,t){for(const n of t){const a=e[n];if(typeof a=="string")return a}}readBoolean(e,t){for(const n of t){const a=e[n];if(typeof a=="boolean")return a;if(typeof a=="number")return a!==0}}readPoint(e,t){for(const n of t){const a=e[n];if(this.isPointLike(a))return a;if(Array.isArray(a)&&typeof a[0]=="number"&&typeof a[1]=="number")return{x:a[0],y:a[1],z:a[2]??0}}}readLeaderLineArray(e){const t=e.leaderLines;if(Array.isArray(t))return t.map(a=>{if(!a||typeof a!="object")return;const r=a.vertices;return Array.isArray(r)?r.filter(o=>this.isPointLike(o)):void 0}).filter(a=>!!a&&a.length>0);const n=e.vertices;if(Array.isArray(n)){const a=n.filter(r=>this.isPointLike(r));return a.length>0?[a]:void 0}}readMLeaderLeaders(e){const t=e.leaderSections;if(!Array.isArray(t))return;const n=[];return t.forEach(a=>{if(!a||typeof a!="object")return;const r=a,o=r.leaderLines,l=Array.isArray(o)?o.reduce((D,E)=>{const V=this.readMLeaderLine(E);return V&&D.push(V),D},[]):void 0,c={},f=this.readPoint(r,["lastLeaderLinePoint"]),u=this.readPoint(r,["doglegVector"]),s=this.readNumber(r,["doglegLength"]),h=this.readMLeaderBreaks(r.breaks),L=this.readNumber(r,["leaderBranchIndex"]);f&&(c.lastLeaderLinePoint=f),r.lastLeaderLinePointSet!=null&&(c.lastLeaderLinePointSet=this.readBoolean(r,["lastLeaderLinePointSet"])),u&&(c.doglegVector=u),r.doglegVectorSet!=null&&(c.doglegVectorSet=this.readBoolean(r,["doglegVectorSet"])),s!=null&&(c.doglegLength=s),h&&(c.breaks=h),L!=null&&(c.leaderBranchIndex=L),l&&(c.leaderLines=l),n.push(c)}),n}readMLeaderLine(e){if(!e||typeof e!="object")return;const t=e,n=t.vertices,a=Array.isArray(n)?n.filter(c=>this.isPointLike(c)):[],r=this.readMLeaderBreaks(t.breaks),o=Array.isArray(t.breakPointIndexes)?t.breakPointIndexes.filter(c=>typeof c=="number"):void 0,l=this.readNumber(t,["leaderLineIndex"]);return a.length>0||r&&r.length>0?{vertices:a,breakPointIndexes:o,leaderLineIndex:l,breaks:r}:void 0}readMLeaderBreaks(e){if(!Array.isArray(e))return;const t=e.map(n=>{if(!n||typeof n!="object")return;const a=n,r=this.readPoint(a,["start"]),o=this.readPoint(a,["end"]),l=this.readNumber(a,["index"]);if(!r||!o)return;const c={start:r,end:o};return l!=null&&(c.index=l),c}).filter(n=>!!n);return t.length>0?t:void 0}isPointLike(e){return!!e&&typeof e=="object"&&typeof e.x=="number"&&typeof e.y=="number"}}class et{convertLayout(e,t){var r,o;const n=new i.AcDbLayout;n.layoutName=e.layoutName,n.tabOrder=e.tabOrder,n.plotSettingsName=e.pageSetupName,n.plotCfgName=e.configName,n.canonicalMediaName=e.paperSize,n.plotViewName=e.plotViewName,n.currentStyleSheet=e.currentStyleSheet,n.plotPaperMargins={left:e.marginLeft,right:e.marginRight,top:e.marginTop,bottom:e.marginBottom},n.plotPaperSize.copy({x:e.paperWidth,y:e.paperHeight}),n.plotOrigin.copy({x:e.plotOriginX,y:e.plotOriginY}),n.plotWindowArea.min.copy({x:e.windowAreaXMin,y:e.windowAreaYMin}),n.plotWindowArea.max.copy({x:e.windowAreaXMax,y:e.windowAreaYMax}),n.customPrintScale={numerator:e.printScaleNumerator,denominator:e.printScaleDenominator},n.plotPaperUnits=e.plotPaperUnit,n.plotRotation=e.plotRotation,n.plotType=e.plotType,n.stdScaleType=e.standardScaleType,n.shadePlot=(()=>{switch(e.shadePlotMode){case 1:return i.AcDbPlotShadePlotType.kWireframe;case 2:return i.AcDbPlotShadePlotType.kHidden;case 3:return i.AcDbPlotShadePlotType.kRendered;default:return i.AcDbPlotShadePlotType.kAsDisplayed}})(),n.shadePlotResLevel=(()=>{switch(e.shadePlotResolution){case 1:return i.AcDbPlotShadePlotResLevel.kPreview;case 2:return i.AcDbPlotShadePlotResLevel.kNormal;case 3:return i.AcDbPlotShadePlotResLevel.kPresentation;case 4:return i.AcDbPlotShadePlotResLevel.kMaximum;case 5:return i.AcDbPlotShadePlotResLevel.kCustom;default:return i.AcDbPlotShadePlotResLevel.kDraft}})(),e.shadePlotCustomDPI!=null&&(n.shadePlotCustomDPI=e.shadePlotCustomDPI),e.shadePlotId&&(n.shadePlotId=e.shadePlotId);const a=e.layoutFlag??0;if(n.plotViewportBorders=(a&1)!==0,n.showPlotStyles=(a&2)!==0,n.plotCentered=(a&4)!==0,n.plotHidden=(a&8)!==0,n.useStandardScale=(a&16)!==0,n.plotPlotStyles=(a&32)!==0,n.scaleLineweights=(a&64)!==0,n.printLineweights=(a&128)!==0,n.drawViewportsFirst=(a&512)!==0,n.modelType=(a&1024)!==0,e.viewportId&&n.viewportArray.push(e.viewportId),e.layoutName==="Model"){const l=i.AcDbBlockTableRecord.MODEL_SPACE_NAME.toUpperCase();(r=t.tables.BLOCK_RECORD)==null||r.entries.some(c=>c.name.toUpperCase()===l?(n.blockTableRecordId=c.handle,!0):!1)}else(o=t.tables.BLOCK_RECORD)==null||o.entries.some(l=>l.layoutObjects===e.handle?(n.blockTableRecordId=l.handle,!0):!1),n.blockTableRecordId||(n.blockTableRecordId=e.paperSpaceTableId);return e.minLimit&&n.limits.min.copy(e.minLimit),e.maxLimit&&n.limits.max.copy(e.maxLimit),e.minExtent&&n.extents.min.copy(e.minExtent),e.maxExtent&&n.extents.max.copy(e.maxExtent),this.processCommonAttrs(e,n),n}convertImageDef(e){const t=new i.AcDbRasterImageDef;return t.sourceFileName=e.fileName,this.processCommonAttrs(e,t),t}convertMLeaderStyle(e){const t=new i.AcDbMLeaderStyle;return t.unknown1=e.unknown1,e.contentType!=null&&(t.contentType=e.contentType),e.drawMLeaderOrderType!=null&&(t.drawMLeaderOrderType=e.drawMLeaderOrderType),e.drawLeaderOrderType!=null&&(t.drawLeaderOrderType=e.drawLeaderOrderType),e.maxLeaderSegmentPoints!=null&&(t.maxLeaderSegmentPoints=e.maxLeaderSegmentPoints),e.firstSegmentAngleConstraint!=null&&(t.firstSegmentAngleConstraint=e.firstSegmentAngleConstraint),e.secondSegmentAngleConstraint!=null&&(t.secondSegmentAngleConstraint=e.secondSegmentAngleConstraint),e.leaderLineType!=null&&(t.leaderLineType=e.leaderLineType),e.leaderLineColor!=null&&(t.leaderLineColor=i.decodeMLeaderStyleRawColor(e.leaderLineColor)),t.leaderLineTypeId=e.leaderLineTypeId,e.leaderLineWeight!=null&&(t.leaderLineWeight=e.leaderLineWeight),e.landingEnabled!=null&&(t.landingEnabled=e.landingEnabled),e.landingGap!=null&&(t.landingGap=e.landingGap),e.doglegEnabled!=null&&(t.doglegEnabled=e.doglegEnabled),e.doglegLength!=null&&(t.doglegLength=e.doglegLength),e.description!=null&&(t.description=e.description),t.arrowheadId=e.arrowheadId,e.arrowheadSize!=null&&(t.arrowheadSize=e.arrowheadSize),e.defaultMTextContents!=null&&(t.defaultMTextContents=e.defaultMTextContents),t.textStyleId=e.textStyleId,e.textLeftAttachmentType!=null&&(t.textLeftAttachmentType=e.textLeftAttachmentType),e.textAngleType!=null&&(t.textAngleType=e.textAngleType),e.textAlignmentType!=null&&(t.textAlignmentType=e.textAlignmentType),e.textRightAttachmentType!=null&&(t.textRightAttachmentType=e.textRightAttachmentType),e.textColor!=null&&(t.textColor=i.decodeMLeaderStyleRawColor(e.textColor)),e.textHeight!=null&&(t.textHeight=e.textHeight),e.textFrameEnabled!=null&&(t.textFrameEnabled=e.textFrameEnabled),e.textAlignAlwaysLeft!=null&&(t.textAlignAlwaysLeft=e.textAlignAlwaysLeft),e.alignSpace!=null&&(t.alignSpace=e.alignSpace),t.blockContentId=e.blockContentId,e.blockContentColor!=null&&(t.blockContentColor=i.decodeMLeaderStyleRawColor(e.blockContentColor)),e.blockContentScale&&(t.blockContentScale={x:e.blockContentScale.x,y:e.blockContentScale.y,z:e.blockContentScale.z??1}),e.blockContentScaleEnabled!=null&&(t.blockContentScaleEnabled=e.blockContentScaleEnabled),e.blockContentRotation!=null&&(t.blockContentRotation=e.blockContentRotation),e.blockContentRotationEnabled!=null&&(t.blockContentRotationEnabled=e.blockContentRotationEnabled),e.blockContentConnectionType!=null&&(t.blockContentConnectionType=e.blockContentConnectionType),e.scale!=null&&(t.scale=e.scale),e.overwritePropertyValue!=null&&(t.overwritePropertyValue=e.overwritePropertyValue),e.annotative!=null&&(t.annotative=e.annotative),e.breakGapSize!=null&&(t.breakGapSize=e.breakGapSize),e.textAttachmentDirection!=null&&(t.textAttachmentDirection=e.textAttachmentDirection),e.bottomTextAttachmentDirection!=null&&(t.bottomTextAttachmentDirection=e.bottomTextAttachmentDirection),e.topTextAttachmentDirection!=null&&(t.topTextAttachmentDirection=e.topTextAttachmentDirection),t.unknown2=e.unknown2,this.processCommonAttrs(e,t),t}convertMLineStyle(e){var a;const t=new i.AcDbMlineStyle;if(e.styleName!=null&&(t.styleName=e.styleName),e.flags!=null&&(t.flags=e.flags),e.description!=null&&(t.description=e.description),e.fillColor!=null)t.fillColor=new i.AcCmColor().setRGBValue(e.fillColor);else if(e.fillColorIndex!=null){const r=new i.AcCmColor;r.colorIndex=e.fillColorIndex,t.fillColor=r}e.startAngle!=null&&(t.startAngle=e.startAngle),e.endAngle!=null&&(t.endAngle=e.endAngle);const n=Math.max(e.elementCount??0,((a=e.elements)==null?void 0:a.length)??0);return n>0&&(t.elements=Array.from({length:n},(r,o)=>{var l,c,f,u;return{offset:((c=(l=e.elements)==null?void 0:l[o])==null?void 0:c.offset)??0,color:(()=>{var h,L,D,E;const s=new i.AcCmColor;return((L=(h=e.elements)==null?void 0:h[o])==null?void 0:L.color)!=null?s.setRGBValue(e.elements[o].color):s.colorIndex=((E=(D=e.elements)==null?void 0:D[o])==null?void 0:E.colorIndex)??256,s})(),lineType:((u=(f=e.elements)==null?void 0:f[o])==null?void 0:u.lineType)??"BYLAYER"}})),this.processCommonAttrs(e,t),t}processCommonAttrs(e,t){t.objectId=e.handle,e.ownerObjectId!=null&&(t.ownerId=e.ownerObjectId)}}class tt extends i.AcDbDatabaseConverter{constructor(e={}){super(e),this.config.parserWorkerUrl||(this.config.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(e,t){const n=this.config,a=this.getParserWorkerTimeout(e,t);if(n.useWorker&&n.parserWorkerUrl){const r=i.createWorkerApi({workerUrl:n.parserWorkerUrl,timeout:a,maxConcurrentWorkers:1}),o=await r.execute(e);if(r.destroy(),o.success)return{model:o.data,data:{unknownEntityCount:0}};throw new Error(`Failed to parse drawing due to error: '${o.error}'`)}else throw new Error("dxf converter can run in web worker only!")}getFonts(e){var n,a;const t=e.blocks??{};return new i.AcDbFontNameCollector({styles:((n=e.tables.STYLE)==null?void 0:n.entries)??[],textStyleVar:((a=e.header)==null?void 0:a.$TEXTSTYLE)||i.DEFAULT_TEXT_STYLE}).collect(e.entities,{getEntityFontInfo:r=>{if(r.type=="MTEXT"){const o=r;return{styleName:o.styleName,formattedText:o.text,resolveStyle:!0}}if(r.type=="TEXT"||r.type=="ATTRIB")return{styleName:r.styleName,resolveStyle:!0};if(r.type=="MULTILEADER"||r.type=="MLEADER"){const o=r,l=typeof o.textContent=="string"?o.textContent:"";return{styleName:typeof o.textStyleName=="string"?o.textStyleName:typeof o.styleName=="string"?o.styleName:void 0,formattedText:l,resolveStyle:!0}}return r.type=="INSERT"?{blockName:r.name}:null},getBlockEntities:r=>{var o;return(o=t[r])==null?void 0:o.entities}})}async processEntities(e,t,n,a,r){const o=new Ye;let l=e.entities;const c=l.length,f=new i.AcDbBatchProcessing(c,100-a.value,n);this.config.convertByEntityType&&(l=this.groupAndFlattenByType(l));const u=new Map;for(let h=0;h<c;h++){const L=l[h];if(L.type==="ATTRIB"){const D=o.convert(L);if(D&&D.ownerId&&D.ownerId!=="0"){let E=u.get(D==null?void 0:D.ownerId);E==null&&(E=[],u.set(D.ownerId,E)),E.push(D)}}}const s=t.tables.blockTable.modelSpace;await f.processChunk(async(h,L)=>{let D=[],E=h<L?l[h].type:"";for(let ne=h;ne<L;ne++){const U=l[ne];if(!(U.ownerBlockRecordSoftId&&U.ownerBlockRecordSoftId!==s.objectId)&&U.type!=="ATTRIB"){const Ee=o.convert(U);if(Ee){if(this.config.convertByEntityType&&U.type!==E&&(s.appendEntity(D),D=[],E=U.type),U.type==="INSERT"){const Se=u.get(Ee.objectId);Se&&Se.length>0&&Se.forEach(p=>{Ee.appendAttributes(p)})}D.push(Ee)}}}s.appendEntity(D);let V=a.value+L/c*(100-a.value);V>100&&(V=100),r&&await r(V,"ENTITY","IN-PROGRESS")})}async processEntitiesInBlock(e,t,n=!1){const a=new Ye,r=e.length,o=[],l=t.objectId,c=[];for(let f=0;f<r;f++){const u=e[f],s=a.convert(u);s&&(u.type==="ATTRIB"?c.push(s):(!n||u.ownerBlockRecordSoftId===l)&&o.push(s))}t.appendEntity(o),c.forEach(f=>{const u=t.getIdAt(f.ownerId);u&&u.appendAttributes(f)})}processBlocks(e,t){const n=e.blocks;for(const[a,r]of Object.entries(n)){let o=t.tables.blockTable.getAt(r.name);o||(o=new i.AcDbBlockTableRecord,r.handle!=null&&(o.objectId=String(r.handle)),o.name=a,t.tables.blockTable.add(o)),o.origin.copy(r.position),r.entities?this.processEntitiesInBlock(r.entities,o):o.isPaperSapce&&this.processEntitiesInBlock(e.entities,o,!0)}}processHeader(e,t){const n=e.header;n.$ACADVER&&(t.version=n.$ACADVER),t.cecolor.colorIndex=n.$CECOLOR||256,t.angbase=n.$ANGBASE||0,t.angdir=n.$ANGDIR||0,n.$AUNITS!=null&&(t.aunits=n.$AUNITS),n.$AUPREC!=null&&(t.auprec=n.$AUPREC),n.$LUNITS!=null&&(t.lunits=n.$LUNITS),n.$LUPREC!=null&&(t.luprec=n.$LUPREC),n.$UNITMODE!=null&&(t.unitmode=n.$UNITMODE),n.$MEASUREMENT!=null&&(t.measurement=n.$MEASUREMENT),t.celtype=n.$CELTYPE||i.ByLayer,i.AcDbSysVarManager.instance().setVar(i.AcDbSystemVariables.CETRANSPARENCY,n.$CETRANSPARENCY||"ByLayer",t),t.celtscale=n.$CELTSCALE||1;const a=this.normalizeHeaderStringValue(n.$CMLSTYLE)||this.normalizeHeaderStringValue(n.CMLSTYLE)||i.DEFAULT_MLINE_STYLE;t.cmlstyle=a;const r=n.$CMLSCALE??n.CMLSCALE;typeof r=="number"&&Number.isFinite(r)&&(t.cmlscale=r);const o=this.normalizeHeaderStringValue(n.$CMLEADERSTYLE)||this.normalizeHeaderStringValue(n.CMLEADERSTYLE)||i.DEFAULT_MLEADER_STYLE;t.cmleaderstyle=o,t.hplayer=this.normalizeHeaderStringValue(n.$HPLAYER)||this.normalizeHeaderStringValue(n.HPLAYER)||".",t.ltscale=n.$LTSCALE||1,n.$EXTMAX&&(t.extmax=n.$EXTMAX),n.$EXTMIN&&(t.extmin=n.$EXTMIN),n.$INSUNITS!=null&&(t.insunits=n.$INSUNITS),t.osmode=n.$OSMODE||0,t.orthomode=n.$ORTHOMODE||0,t.pdmode=n.$PDMODE||0,t.pdsize=n.$PDSIZE||0,t.textstyle=n.$TEXTSTYLE||i.DEFAULT_TEXT_STYLE}processBlockTables(e,t){var a;const n=(a=e.tables.BLOCK_RECORD)==null?void 0:a.entries;n&&n.length>0&&(t.tables.blockTable.removeAll(),n.forEach(r=>{const o=new i.AcDbBlockTableRecord;o.objectId=r.handle,o.name=r.name,o.layoutId=r.layoutObjects,o.blockInsertUnits=r.insertionUnits,o.explodability=r.explodability,o.blockScaling=r.scalability,r.bmpPreview&&(o.bmpPreview=r.bmpPreview),t.tables.blockTable.add(o)}))}processObjects(e,t){const n=e.objects.byName,a=new et;if("LAYOUT"in n){const r=t.objects.layout;n.LAYOUT.forEach(o=>{const l=a.convertLayout(o,e);r.setAt(l.layoutName,l)})}if("IMAGEDEF"in n){const r=t.objects.imageDefinition;n.IMAGEDEF.forEach(o=>{const l=a.convertImageDef(o);r.setAt(l.objectId,l)})}if("MLEADERSTYLE"in n){const r=t.objects.mleaderStyle;n.MLEADERSTYLE.forEach(o=>{const l=a.convertMLeaderStyle(o);r.setAt(l.objectId,l)})}if("MLINESTYLE"in n){const r=t.objects.mlineStyle;n.MLINESTYLE.forEach(o=>{const l=a.convertMLineStyle(o);r.setAt(l.styleName||l.objectId,l)})}}processViewports(e,t){var a;const n=(a=e.tables)==null?void 0:a.VPORT;if(n){this.processCommonTableAttrs(n,t.tables.viewportTable);const r=n.entries;r&&r.length>0&&r.forEach(o=>{const l=new i.AcDbViewportTableRecord;this.processCommonTableEntryAttrs(o,l),o.circleSides&&(l.circleSides=o.circleSides),l.standardFlag=o.standardFlag,l.center.copy(o.center??i.VPORT_FALLBACK_CENTER_2D),l.lowerLeftCorner.copy(o.lowerLeftCorner??i.VPORT_FALLBACK_LLC),l.upperRightCorner.copy(o.upperRightCorner??i.VPORT_FALLBACK_URC),o.snapBasePoint&&l.snapBase.copy(o.snapBasePoint),o.snapRotationAngle&&(l.snapAngle=o.snapRotationAngle),o.snapSpacing&&l.snapIncrements.copy(o.snapSpacing),o.majorGridLines&&(l.gridMajor=o.majorGridLines),o.gridSpacing&&l.gridIncrements.copy(o.gridSpacing),o.backgroundObjectId&&(l.backgroundObjectId=o.backgroundObjectId),l.gsView.center.copy(o.center??i.VPORT_FALLBACK_CENTER_2D),l.gsView.viewDirectionFromTarget.copy(o.viewDirectionFromTarget??i.VPORT_FALLBACK_VIEW_DIR),l.gsView.viewTarget.copy(o.viewTarget??i.VPORT_FALLBACK_VIEW_TARGET),o.lensLength&&(l.gsView.lensLength=o.lensLength),o.frontClippingPlane&&(l.gsView.frontClippingPlane=o.frontClippingPlane),o.backClippingPlane&&(l.gsView.backClippingPlane=o.backClippingPlane),o.viewHeight&&(l.gsView.viewHeight=o.viewHeight),o.aspectRatio!=null&&Number.isFinite(o.aspectRatio)&&o.aspectRatio>0&&(l.gsView.aspectRatio=o.aspectRatio),o.viewTwistAngle&&(l.gsView.viewTwistAngle=o.viewTwistAngle),o.frozenLayers&&(l.gsView.frozenLayers=o.frozenLayers),o.styleSheet&&(l.gsView.styleSheet=o.styleSheet),o.renderMode&&(l.gsView.renderMode=o.renderMode),o.viewMode&&(l.gsView.viewMode=o.viewMode),o.ucsIconSetting&&(l.gsView.ucsIconSetting=o.ucsIconSetting),o.ucsOrigin&&l.gsView.ucsOrigin.copy(o.ucsOrigin),o.ucsXAxis&&l.gsView.ucsXAxis.copy(o.ucsXAxis),o.ucsYAxis&&l.gsView.ucsYAxis.copy(o.ucsYAxis),o.orthographicType&&(l.gsView.orthographicType=o.orthographicType),o.shadePlotSetting&&(l.gsView.shadePlotSetting=o.shadePlotSetting),o.shadePlotObjectId&&(l.gsView.shadePlotObjectId=o.shadePlotObjectId),o.visualStyleObjectId&&(l.gsView.visualStyleObjectId=o.visualStyleObjectId),o.isDefaultLightingOn&&(l.gsView.isDefaultLightingOn=o.isDefaultLightingOn),o.defaultLightingType&&(l.gsView.defaultLightingType=o.defaultLightingType),o.brightness&&(l.gsView.brightness=o.brightness),o.contrast&&(l.gsView.contrast=o.contrast),o.ambientColor&&(l.gsView.ambientColor=o.ambientColor),t.tables.viewportTable.add(l)})}}processLayers(e,t){var a;const n=(a=e.tables)==null?void 0:a.LAYER;if(n){this.processCommonTableAttrs(n,t.tables.layerTable);const r=n.entries;r&&r.length>0&&r.forEach(o=>{const l=new i.AcCmColor;l.colorIndex=o.colorIndex;const c=new i.AcDbLayerTableRecord({name:o.name,standardFlags:o.standardFlag,linetype:o.lineType,lineWeight:o.lineweight,isOff:o.colorIndex<0,color:l,isPlottable:o.isPlotting});this.processCommonTableEntryAttrs(o,c),t.tables.layerTable.add(c)})}}processLineTypes(e,t){var a;const n=(a=e.tables)==null?void 0:a.LTYPE;if(n){this.processCommonTableAttrs(n,t.tables.linetypeTable);const r=n.entries;r&&r.length>0&&r.forEach(o=>{const l=new i.AcDbLinetypeTableRecord({name:o.name,standardFlag:o.standardFlag,description:o.description,totalPatternLength:o.totalPatternLength,pattern:o.pattern});this.processCommonTableEntryAttrs(o,l),t.tables.linetypeTable.add(l)})}}processTextStyles(e,t){var a;const n=(a=e.tables)==null?void 0:a.STYLE;if(n){this.processCommonTableAttrs(n,t.tables.textStyleTable);const r=n.entries;r&&r.length>0&&r.forEach(o=>{const l=new i.AcDbTextStyleTableRecord({name:o.name,standardFlag:o.standardFlag,fixedTextHeight:o.fixedTextHeight,widthFactor:o.widthFactor,obliqueAngle:o.obliqueAngle,textGenerationFlag:o.textGenerationFlag,lastHeight:o.lastHeight,font:o.font,bigFont:o.bigFont,extendedFont:o.extendedFont});this.processCommonTableEntryAttrs(o,l),t.tables.textStyleTable.add(l)})}t.ensureTextStyleDefaults()}processDimStyles(e,t){var a;const n=(a=e.tables)==null?void 0:a.DIMSTYLE;if(n){this.processCommonTableAttrs(n,t.tables.dimStyleTable);const r=n.entries;r&&r.length>0&&r.forEach(o=>{const l={name:o.name,ownerId:o.ownerObjectId,dimpost:o.DIMPOST||"",dimapost:o.DIMAPOST||"",dimscale:o.DIMSCALE,dimasz:o.DIMASZ,dimexo:o.DIMEXO,dimdli:o.DIMDLI,dimexe:o.DIMEXE,dimrnd:o.DIMRND,dimdle:o.DIMDLE,dimtp:o.DIMTP,dimtm:o.DIMTM,dimtxt:o.DIMTXT,dimcen:o.DIMCEN,dimtsz:o.DIMTSZ,dimaltf:o.DIMALTF,dimlfac:o.DIMLFAC,dimtvp:o.DIMTVP,dimtfac:o.DIMTFAC,dimgap:o.DIMGAP,dimaltrnd:o.DIMALTRND,dimtol:o.DIMTOL==null||o.DIMTOL==0?0:1,dimlim:o.DIMLIM==null||o.DIMLIM==0?0:1,dimtih:o.DIMTIH==null||o.DIMTIH==0?0:1,dimtoh:o.DIMTOH==null||o.DIMTOH==0?0:1,dimse1:o.DIMSE1==null||o.DIMSE1==0?0:1,dimse2:o.DIMSE2==null||o.DIMSE2==0?0:1,dimtad:o.DIMTAD,dimzin:o.DIMZIN,dimazin:o.DIMAZIN,dimalt:o.DIMALT,dimaltd:o.DIMALTD,dimtofl:o.DIMTOFL,dimsah:o.DIMSAH,dimtix:o.DIMTIX,dimsoxd:o.DIMSOXD,dimclrd:o.DIMCLRD,dimclre:o.DIMCLRE,dimclrt:o.DIMCLRT,dimadec:o.DIMADEC||0,dimunit:o.DIMUNIT||2,dimdec:o.DIMDEC,dimtdec:o.DIMTDEC,dimaltu:o.DIMALTU,dimalttd:o.DIMALTTD,dimaunit:o.DIMAUNIT,dimfrac:o.DIMFRAC,dimlunit:o.DIMLUNIT,dimdsep:o.DIMDSEP?o.DIMDSEP.toString():".",dimtmove:o.DIMTMOVE||0,dimjust:o.DIMJUST,dimsd1:o.DIMSD1,dimsd2:o.DIMSD2,dimtolj:o.DIMTOLJ,dimtzin:o.DIMTZIN,dimaltz:o.DIMALTZ,dimalttz:o.DIMALTTZ,dimfit:o.DIMFIT||0,dimupt:o.DIMUPT,dimatfit:o.DIMATFIT,dimtxsty:o.DIMTXSTY||i.DEFAULT_TEXT_STYLE,dimldrblk:o.DIMLDRBLK||"",dimblk:o.DIMBLK||"",dimblk1:o.DIMBLK1||"",dimblk2:o.DIMBLK2||"",dimlwd:o.DIMLWD,dimlwe:o.DIMLWE},c=new i.AcDbDimStyleTableRecord(l);this.processCommonTableEntryAttrs(o,c),t.tables.dimStyleTable.add(c)})}}processCommonTableAttrs(e,t){e.handle!=null&&(t.objectId=e.handle),e.ownerObjectId!=null&&(t.ownerId=e.ownerObjectId)}processCommonTableEntryAttrs(e,t){t.name="name"in e?e.name:"",e.handle!=null&&(t.objectId=e.handle),e.ownerObjectId!=null&&(t.ownerId=e.ownerObjectId)}groupAndFlattenByType(e){const t={},n=[];for(const a of e)t[a.type]||(t[a.type]=[],n.push(a.type)),t[a.type].push(a);return n.flatMap(a=>t[a])}normalizeHeaderStringValue(e){if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}}oe.AcDbDxfConverter=tt,Object.defineProperty(oe,Symbol.toStringTag,{value:"Module"})});
1
+ (function(oe,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@mlightcad/data-model")):typeof define=="function"&&define.amd?define(["exports","@mlightcad/data-model"],i):(oe=typeof globalThis<"u"?globalThis:oe||self,i(oe["dxf-json-converter"]={},oe.dataModel))})(this,function(oe,i){"use strict";var S,Ce,T,g,Pe,v,ie,G,b,H,k,re,ae,le,O,W,be,me,se,ce,Ne,Oe,Re,R,Y,I,de,xe,d,m,ye,N,we,z,A,X,Me,ue,B,_e,Ge,Fe,j,$,Ve,ve,K,Ae,fe,ke,Ie,Z,De,C,q,x,Te,y,J,P,Q,w,pe,Be,ge,M,ee,_,te,He,he,F;(S={})[S.None=0]="None",S[S.Anonymous=1]="Anonymous",S[S.NonConstant=2]="NonConstant",S[S.Xref=4]="Xref",S[S.XrefOverlay=8]="XrefOverlay",S[S.ExternallyDependent=16]="ExternallyDependent",S[S.ResolvedOrDependent=32]="ResolvedOrDependent",S[S.ReferencedXref=64]="ReferencedXref",(Ce={})[Ce.BYBLOCK=0]="BYBLOCK",Ce[Ce.BYLAYER=256]="BYLAYER",(T={})[T.Rotated=0]="Rotated",T[T.Aligned=1]="Aligned",T[T.Angular=2]="Angular",T[T.Diameter=3]="Diameter",T[T.Radius=4]="Radius",T[T.Angular3Point=5]="Angular3Point",T[T.Ordinate=6]="Ordinate",T[T.ReferenceIsExclusive=32]="ReferenceIsExclusive",T[T.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",T[T.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag",(g={})[g.TopLeft=1]="TopLeft",g[g.TopCenter=2]="TopCenter",g[g.TopRight=3]="TopRight",g[g.MiddleLeft=4]="MiddleLeft",g[g.MiddleCenter=5]="MiddleCenter",g[g.MiddleRight=6]="MiddleRight",g[g.BottomLeft=7]="BottomLeft",g[g.BottomCenter=8]="BottomCenter",g[g.BottomRight=9]="BottomRight",(Pe={})[Pe.AtLeast=1]="AtLeast",Pe[Pe.Exact=2]="Exact";var We=((v={})[v.Center=0]="Center",v[v.Above=1]="Above",v[v.Outside=2]="Outside",v[v.JIS=3]="JIS",v[v.Below=4]="Below",v);(ie={})[ie.WithDimension=0]="WithDimension",ie[ie.AddLeader=1]="AddLeader",ie[ie.Independent=2]="Independent",(G={})[G.BothOutside=0]="BothOutside",G[G.ArrowFirst=1]="ArrowFirst",G[G.TextFirst=2]="TextFirst",G[G.Auto=3]="Auto";var Le=((b={})[b.Feet=0]="Feet",b[b.None=1]="None",b[b.Inch=2]="Inch",b[b.FeetAndInch=3]="FeetAndInch",b[b.Leading=4]="Leading",b[b.Trailing=8]="Trailing",b[b.LeadingAndTrailing=12]="LeadingAndTrailing",b),$e=((H={})[H.None=0]="None",H[H.Leading=1]="Leading",H[H.Trailing=2]="Trailing",H[H.LeadingAndTrailing=3]="LeadingAndTrailing",H),Ke=((k={})[k.Center=0]="Center",k[k.First=1]="First",k[k.Second=2]="Second",k[k.OverFirst=3]="OverFirst",k[k.OverSecond=4]="OverSecond",k),Ze=((re={})[re.Bottom=0]="Bottom",re[re.Center=1]="Center",re[re.Top=2]="Top",re);(ae={})[ae.None=0]="None",ae[ae.UseDrawingBackground=1]="UseDrawingBackground",ae[ae.Custom=2]="Custom",(le={})[le.Horizontal=0]="Horizontal",le[le.Diagonal=1]="Diagonal",le[le.NotStacked=2]="NotStacked",(O={})[O.Scientific=1]="Scientific",O[O.Decimal=2]="Decimal",O[O.Engineering=3]="Engineering",O[O.Architectural=4]="Architectural",O[O.Fractional=5]="Fractional",O[O.WindowDesktop=6]="WindowDesktop",(W={})[W.Decimal=0]="Decimal",W[W.DegreesMinutesSecond=1]="DegreesMinutesSecond",W[W.Gradian=2]="Gradian",W[W.Radian=3]="Radian";var qe=((be={})[be.PatternFill=0]="PatternFill",be[be.SolidFill=1]="SolidFill",be);(me={})[me.NonAssociative=0]="NonAssociative",me[me.Associative=1]="Associative",(se={})[se.Normal=0]="Normal",se[se.Outer=1]="Outer",se[se.Ignore=2]="Ignore",(ce={})[ce.UserDefined=0]="UserDefined",ce[ce.Predefined=1]="Predefined",ce[ce.Custom=2]="Custom",(Ne={})[Ne.NotAnnotated=0]="NotAnnotated",Ne[Ne.Annotated=1]="Annotated",(Oe={})[Oe.Solid=0]="Solid",Oe[Oe.Gradient=1]="Gradient",(Re={})[Re.TwoColor=0]="TwoColor",Re[Re.OneColor=1]="OneColor",(R={})[R.Default=0]="Default",R[R.External=1]="External",R[R.Polyline=2]="Polyline",R[R.Derived=4]="Derived",R[R.Textbox=8]="Textbox",R[R.Outermost=16]="Outermost",(Y={})[Y.Line=1]="Line",Y[Y.Circular=2]="Circular",Y[Y.Elliptic=3]="Elliptic",Y[Y.Spline=4]="Spline";var Je=((I={})[I.Off=0]="Off",I[I.Solid=1]="Solid",I[I.Dashed=2]="Dashed",I[I.Dotted=3]="Dotted",I[I.ShotDash=4]="ShotDash",I[I.MediumDash=5]="MediumDash",I[I.LongDash=6]="LongDash",I[I.DoubleShortDash=7]="DoubleShortDash",I[I.DoubleMediumDash=8]="DoubleMediumDash",I[I.DoubleLongDash=9]="DoubleLongDash",I[I.DoubleMediumLongDash=10]="DoubleMediumLongDash",I[I.SparseDot=11]="SparseDot",I);Je.Off,(de={})[de.Standard=-3]="Standard",de[de.ByLayer=-2]="ByLayer",de[de.ByBlock=-1]="ByBlock",(xe={})[xe.English=0]="English",xe[xe.Metric=1]="Metric",(d={})[d.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",d[d.FRONT_CLIPPING=2]="FRONT_CLIPPING",d[d.BACK_CLIPPING=4]="BACK_CLIPPING",d[d.UCS_FOLLOW=8]="UCS_FOLLOW",d[d.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",d[d.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",d[d.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",d[d.FAST_ZOOM=128]="FAST_ZOOM",d[d.SNAP_MODE=256]="SNAP_MODE",d[d.GRID_MODE=512]="GRID_MODE",d[d.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",d[d.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",d[d.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",d[d.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",d[d.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",d[d.UNUSED=32768]="UNUSED",d[d.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",d[d.VIEWPORT_OFF=131072]="VIEWPORT_OFF",d[d.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",d[d.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",d[d.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",d[d.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE",(m={})[m.OPTIMIZED_2D=0]="OPTIMIZED_2D",m[m.WIREFRAME=1]="WIREFRAME",m[m.HIDDEN_LINE=2]="HIDDEN_LINE",m[m.FLAT_SHADED=3]="FLAT_SHADED",m[m.GOURAUD_SHADED=4]="GOURAUD_SHADED",m[m.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",m[m.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",(ye={})[ye.UCS_UNCHANGED=0]="UCS_UNCHANGED",ye[ye.HAS_OWN_UCS=1]="HAS_OWN_UCS",(N={})[N.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",N[N.TOP=1]="TOP",N[N.BOTTOM=2]="BOTTOM",N[N.FRONT=3]="FRONT",N[N.BACK=4]="BACK",N[N.LEFT=5]="LEFT",N[N.RIGHT=6]="RIGHT",(we={})[we.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",we[we.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",(z={})[z.ByLayer=0]="ByLayer",z[z.ByBlock=1]="ByBlock",z[z.ByDictionaryDefault=2]="ByDictionaryDefault",z[z.ByObject=3]="ByObject",(A={})[A.NotAllowed=0]="NotAllowed",A[A.AllowErase=1]="AllowErase",A[A.AllowTransform=2]="AllowTransform",A[A.AllowChangeColor=4]="AllowChangeColor",A[A.AllowChangeLayer=8]="AllowChangeLayer",A[A.AllowChangeLinetype=16]="AllowChangeLinetype",A[A.AllowChangeLinetypeScale=32]="AllowChangeLinetypeScale",A[A.AllowChangeVisibility=64]="AllowChangeVisibility",A[A.AllowClone=128]="AllowClone",A[A.AllowChangeLineweight=256]="AllowChangeLineweight",A[A.AllowChangePlotStyleName=512]="AllowChangePlotStyleName",A[A.AllowAllExceptClone=895]="AllowAllExceptClone",A[A.AllowAll=1023]="AllowAll",A[A.DisableProxyWarning=1024]="DisableProxyWarning",A[A.R13FormatProxy=32768]="R13FormatProxy",(X={})[X.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",X[X.CAST=1]="CAST",X[X.RECEIVE=2]="RECEIVE",X[X.IGNORE=3]="IGNORE",(Me={})[Me.RayTrace=0]="RayTrace",Me[Me.ShadowMap=1]="ShadowMap",(ue={})[ue.BeforeText=0]="BeforeText",ue[ue.AboveText=1]="AboveText",ue[ue.None=2]="None",(B={})[B.NONE=0]="NONE",B[B.INVISIBLE=1]="INVISIBLE",B[B.CONSTANT=2]="CONSTANT",B[B.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",B[B.PRESET=8]="PRESET",(_e={})[_e.MULTILINE=2]="MULTILINE",_e[_e.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE",(Ge={})[Ge.ProxyEntity=498]="ProxyEntity",(Fe={})[Fe.Dwg=0]="Dwg",Fe[Fe.Dxf=1]="Dxf",(j={})[j.First=1]="First",j[j.Second=2]="Second",j[j.Third=4]="Third",j[j.Fourth=8]="Fourth",($={})[$.ShowImage=1]="ShowImage",$[$.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",$[$.UseClippingBoundary=4]="UseClippingBoundary",$[$.TransparencyIsOn=8]="TransparencyIsOn",(Ve={})[Ve.Rectangular=1]="Rectangular",Ve[Ve.Polygonal=2]="Polygonal",(ve={})[ve.Outside=0]="Outside",ve[ve.Inside=1]="Inside",(K={})[K.TextAnnotation=0]="TextAnnotation",K[K.ToleranceAnnotation=1]="ToleranceAnnotation",K[K.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",K[K.NoAnnotation=3]="NoAnnotation",(Ae={})[Ae.Distant=1]="Distant",Ae[Ae.Point=2]="Point",Ae[Ae.Spot=3]="Spot",(fe={})[fe.None=0]="None",fe[fe.InverseLinear=1]="InverseLinear",fe[fe.InverseSquare=2]="InverseSquare",(ke={})[ke.IS_CLOSED=1]="IS_CLOSED",ke[ke.PLINE_GEN=128]="PLINE_GEN",(Ie={})[Ie.Top=0]="Top",Ie[Ie.Zero=1]="Zero",Ie[Ie.Bottom=2]="Bottom",(Z={})[Z.HasVertex=1]="HasVertex",Z[Z.Closed=2]="Closed",Z[Z.SuppressStartCaps=4]="SuppressStartCaps",Z[Z.SuppressEndCaps=8]="SuppressEndCaps",(De={})[De.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",De[De.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",De[De.BY_STYLE=5]="BY_STYLE",(C={})[C.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",C[C.CURVE_FIT=2]="CURVE_FIT",C[C.SPLINE_FIT=4]="SPLINE_FIT",C[C.POLYLINE_3D=8]="POLYLINE_3D",C[C.POLYGON_3D=16]="POLYGON_3D",C[C.CLOSED_POLYGON=32]="CLOSED_POLYGON",C[C.POLYFACE=64]="POLYFACE",C[C.CONTINUOUS=128]="CONTINUOUS";var Ue=((q={})[q.NONE=0]="NONE",q[q.QUADRATIC=5]="QUADRATIC",q[q.CUBIC=6]="CUBIC",q[q.BEZIER=8]="BEZIER",q);(x={})[x.NONE=0]="NONE",x[x.CLOSED=1]="CLOSED",x[x.PERIODIC=2]="PERIODIC",x[x.RATIONAL=4]="RATIONAL",x[x.PLANAR=8]="PLANAR",x[x.LINEAR=16]="LINEAR",(Te={})[Te.NONE=0]="NONE",Te[Te.MIRRORED_X=2]="MIRRORED_X",Te[Te.MIRRORED_Y=4]="MIRRORED_Y",(y={})[y.LEFT=0]="LEFT",y[y.CENTER=1]="CENTER",y[y.RIGHT=2]="RIGHT",y[y.ALIGNED=3]="ALIGNED",y[y.MIDDLE=4]="MIDDLE",y[y.FIT=5]="FIT",(J={})[J.BASELINE=0]="BASELINE",J[J.BOTTOM=1]="BOTTOM",J[J.MIDDLE=2]="MIDDLE",J[J.TOP=3]="TOP";var Qe=((P={})[P.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",P[P.TANGENT_DEFINED=2]="TANGENT_DEFINED",P[P.NOT_USED=4]="NOT_USED",P[P.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",P[P.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",P[P.FOR_POLYLINE=32]="FOR_POLYLINE",P[P.FOR_POLYGON=64]="FOR_POLYGON",P[P.POLYFACE=128]="POLYFACE",P);(Q={})[Q.ShowImage=1]="ShowImage",Q[Q.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Q[Q.UseClippingBoundary=4]="UseClippingBoundary",Q[Q.Transparency=8]="Transparency",(w={})[w.NOT_APPLICABLE=0]="NOT_APPLICABLE",w[w.KEEP_EXISTING=1]="KEEP_EXISTING",w[w.USE_CLONE=2]="USE_CLONE",w[w.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",w[w.VALUE_NAME=4]="VALUE_NAME",w[w.UNMANGLE_NAME=5]="UNMANGLE_NAME",(pe={})[pe.NOUNIT=0]="NOUNIT",pe[pe.CENTIMETERS=2]="CENTIMETERS",pe[pe.INCH=5]="INCH",(Be={})[Be.PSLTSCALE=1]="PSLTSCALE",Be[Be.LIMCHECK=2]="LIMCHECK",(ge={})[ge.INCHES=0]="INCHES",ge[ge.MILLIMETERS=1]="MILLIMETERS",ge[ge.PIXELS=2]="PIXELS",(M={})[M.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",M[M.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",M[M.DRAWING_LIMITS=2]="DRAWING_LIMITS",M[M.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",M[M.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",M[M.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION",(ee={})[ee.AS_DISPLAYED=0]="AS_DISPLAYED",ee[ee.WIREFRAME=1]="WIREFRAME",ee[ee.HIDDEN=2]="HIDDEN",ee[ee.RENDERED=3]="RENDERED",(_={})[_.DRAFT=0]="DRAFT",_[_.PREVIEW=1]="PREVIEW",_[_.NORMAL=2]="NORMAL",_[_.PRESENTATION=3]="PRESENTATION",_[_.MAXIMUM=4]="MAXIMUM",_[_.CUSTOM=5]="CUSTOM",We.Above,We.Center,Le.Trailing,Le.Feet,$e.None,Ke.Center,Ze.Center,Le.Trailing,Le.Feet,Le.Trailing,Le.Trailing,(te={})[te.NONE=0]="NONE",te[te.AbsoluteRotation=1]="AbsoluteRotation",te[te.TextEmbedded=2]="TextEmbedded",te[te.ShapeEmbedded=4]="ShapeEmbedded",(He={})[He.PaperSpace=1]="PaperSpace",(he={})[he.XrefDependent=16]="XrefDependent",he[he.XrefResolved=32]="XrefResolved",he[he.Referenced=64]="Referenced",(F={})[F.Off=0]="Off",F[F.Perspective=1]="Perspective",F[F.ClipFront=2]="ClipFront",F[F.ClipBack=4]="ClipBack",F[F.UcsFollow=8]="UcsFollow",F[F.ClipFrontByFrontZ=16]="ClipFrontByFrontZ";class Ye{convert(e){const t=this.createEntity(e);return t&&this.processCommonAttrs(e,t),t}createEntity(e){return e.type=="3DFACE"?this.convertFace(e):e.type=="ARC"?this.convertArc(e):e.type=="ATTDEF"?this.convertAttributeDefinition(e):e.type=="ATTRIB"?this.convertAttribute(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=="MLINE"?this.convertMLine(e):e.type=="MULTILEADER"||e.type=="MLEADER"?this.convertMLeader(e):e.type=="POLYLINE"?this.convertPolyline(e):e.type=="POINT"?this.convertPoint(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=="SHAPE"?this.convertShape(e):e.type=="SOLID"?this.convertSolid(e):e.type=="VIEWPORT"?this.convertViewport(e):e.type=="WIPEOUT"?this.convertWipeout(e):e.type=="XLINE"?this.convertXline(e):e.type=="INSERT"?this.convertBlockReference(e):e.type=="ACAD_PROXY_ENTITY"?this.convertProxyEntity(e):null}convertProxyEntity(e){const t=new i.AcDbProxyEntity;if(t.proxyEntityClassId=e.proxyEntityClassId,e.originalDxfName&&(t.originalDxfName=e.originalDxfName),e.objectDrawingFormat!=null&&(t.graphicsMetafileType=e.objectDrawingFormat),e.applicationEntityClassId!=null&&(t.originalClassName=String(e.applicationEntityClassId)),e.graphicsData){const n=i.hexStringsToBytes([e.graphicsData]),a=e.graphicsDataSize??n.length;t.setProxyGraphic(n.subarray(0,a))}return t}convertFace(e){const t=new i.AcDbFace;return e.vertices.forEach((n,a)=>t.setVertexAt(a,n)),t}convertArc(e){const t=e.extrusionDirection??i.AcGeVector3d.Z_AXIS;return new i.AcDbArc(i.transformOcsPointToWcs(e.center,t),e.radius,i.AcGeMathUtil.degToRad(e.startAngle),i.AcGeMathUtil.degToRad(e.endAngle),t)}convertAttributeCommon(e,t){t.textString=e.text,t.height=e.textHeight,t.position.copy(e.startPoint);const n=e.alignmentPoint,a=!n||n.x===0&&n.y===0&&(n.z??0)===0;n&&!a?t.alignmentPoint.copy(n):t.alignmentPoint.copy(e.startPoint),t.rotation=e.rotation,t.oblique=e.obliqueAngle??0,t.thickness=e.thickness,t.tag=e.tag,t.fieldLength=0,t.isInvisible=(e.attributeFlag&i.AcDbAttributeFlags.Invisible)!==0,t.isConst=(e.attributeFlag&i.AcDbAttributeFlags.Const)!==0,t.isVerifiable=(e.attributeFlag&i.AcDbAttributeFlags.Verifiable)!==0,t.isPreset=(e.attributeFlag&i.AcDbAttributeFlags.Preset)!==0,t.isReallyLocked=!!e.isReallyLocked,t.isMTextAttribute=(e.mtextFlag&i.AcDbAttributeMTextFlag.MultiLine)!==0,t.isConstMTextAttribute=(e.mtextFlag&i.AcDbAttributeMTextFlag.ConstMultiLine)!==0}convertAttribute(e){const t=new i.AcDbAttribute;return this.convertAttributeCommon(e,t),t.styleName=e.textStyle,t.horizontalMode=e.horizontalJustification,t.verticalMode=e.verticalJustification,t.widthFactor=e.scale??1,t.lockPositionInBlock=e.lockPositionFlag,t}convertAttributeDefinition(e){const t=new i.AcDbAttributeDefinition;return this.convertAttributeCommon(e,t),t.styleName=e.styleName,t.horizontalMode=e.halign,t.verticalMode=e.valign,t.widthFactor=e.xScale??1,t.prompt=e.prompt,t}convertCirle(e){const t=e.extrusionDirection??i.AcGeVector3d.Z_AXIS;return new i.AcDbCircle(i.transformOcsPointToWcs(e.center,t),e.radius,t)}convertEllipse(e){const t=new i.AcGeVector3d(e.majorAxisEndPoint),n=t.length();return new i.AcDbEllipse(e.center,e.extrusionDirection??i.AcGeVector3d.Z_AXIS,t,n,n*e.axisRatio,e.startAngle,e.endAngle)}convertLine(e){const t=e.startPoint,n=e.endPoint;return new i.AcDbLine(new i.AcGePoint3d(t.x,t.y,t.z||0),new i.AcGePoint3d(n.x,n.y,n.z||0))}convertSpline(e){return i.AcDbSpline.fromDwgSpline(e)}convertPoint(e){const t=new i.AcDbPoint;return t.position=e.position,t}convertShape(e){const t=new i.AcDbShape;return t.position.copy(e.insertionPoint),t.size=e.size,t.name=e.shapeName,t.rotation=i.AcGeMathUtil.degToRad(e.rotation||0),t.widthFactor=e.xScale??1,t.oblique=i.AcGeMathUtil.degToRad(e.obliqueAngle||0),t.thickness=e.thickness??0,t.normal.copy(e.extrusionDirection??{x:0,y:0,z:1}),t}convertSolid(e){const t=new i.AcDbTrace;return e.points.forEach((n,a)=>t.setPointAt(a,n)),t.thickness=e.thickness,t}convertPolyline(e){var u;const t=!!(e.flag&1),n=!!(e.flag&8),a=!!(e.flag&16),r=!!(e.flag&64),o=!!(e.flag&32),l=[],c=[],f=[];if((u=e.vertices)==null||u.map(s=>{s.flag&Qe.SPLINE_CONTROL_POINT||(r&&s.flag&128?s.flag&64?(l.push({x:s.x,y:s.y,z:s.z}),c.push(s.bulge??0)):s.faces&&s.faces.length>=3&&f.push([...s.faces]):(l.push({x:s.x,y:s.y,z:s.z}),c.push(s.bulge??0)))}),a){const s=e.meshMVertexCount,h=e.meshNVertexCount;return new i.AcDbPolygonMesh(s,h,l,t,o)}else{if(r)return new i.AcDbPolyFaceMesh(l,f);if(n){let s=i.AcDbPoly3dType.SimplePoly;return e.flag&4&&(e.smoothType==Ue.CUBIC?s=i.AcDbPoly3dType.CubicSplinePoly:e.smoothType==Ue.QUADRATIC&&(s=i.AcDbPoly3dType.QuadSplinePoly)),new i.AcDb3dPolyline(s,l,t)}else{let s=i.AcDbPoly2dType.SimplePoly;return e.flag&2?s=i.AcDbPoly2dType.FitCurvePoly:e.flag&4&&(e.smoothType==Ue.CUBIC?s=i.AcDbPoly2dType.CubicSplinePoly:e.smoothType==Ue.QUADRATIC&&(s=i.AcDbPoly2dType.QuadSplinePoly)),new i.AcDb2dPolyline(s,l,0,t,e.startWidth,e.endWidth,c)}}}convertLWPolyline(e){var a;const t=new i.AcDbPolyline;t.closed=!!(e.flag&1);const n=e.constantWidth??-1;return(a=e.vertices)==null||a.forEach((r,o)=>{t.addVertexAt(o,new i.AcGePoint2d(r.x,r.y),r.bulge,r.startWidth??n,r.endWidth??n)}),t}convertHatch(e){var a;const t=new i.AcDbHatch;if((a=e.definitionLines)==null||a.forEach(r=>{t.definitionLines.push({angle:i.AcGeMathUtil.degToRad(r.angle||0),base:r.base,offset:r.offset,dashLengths:r.numberOfDashLengths>0?r.dashLengths:[]})}),t.isSolidFill=e.solidFill==qe.SolidFill,t.hatchStyle=e.hatchStyle,t.patternName=e.patternName,t.patternType=e.patternType,t.patternAngle=e.patternAngle==null?0:i.AcGeMathUtil.degToRad(e.patternAngle),t.patternScale=e.patternScale==null?0:e.patternScale,e.boundaryPaths.forEach(r=>{if(r.boundaryPathTypeFlag&2){const l=r,c=new i.AcGePolyline2d;c.closed=l.isClosed,l.vertices.forEach((f,u)=>{c.addVertexAt(u,{x:f.x,y:f.y,bulge:f.bulge})}),t.add(c)}else{const l=r,c=[];l.edges.forEach(u=>{if(u.type==1){const s=u;c.push(new i.AcGeLine2d(s.start,s.end))}else if(u.type==2){const s=u;c.push(new i.AcGeCircArc2d(s.center,s.radius,i.AcGeMathUtil.degToRad(s.startAngle||0),i.AcGeMathUtil.degToRad(s.endAngle||0),!s.isCCW))}else if(u.type==3){const s=u;new i.AcGeVector2d().subVectors(s.end,s.center);const L=Math.sqrt(Math.pow(s.end.x,2)+Math.pow(s.end.y,2)),D=L*s.lengthOfMinorAxis;let E=i.AcGeMathUtil.degToRad(s.startAngle||0),V=i.AcGeMathUtil.degToRad(s.endAngle||0);const ne=Math.atan2(s.end.y,s.end.x);s.isCCW||(E=Math.PI*2-E,V=Math.PI*2-V),c.push(new i.AcGeEllipseArc2d({...s.center,z:0},L,D,E,V,!s.isCCW,ne))}else if(u.type==4){const s=i.AcGeSpline3d.fromDwgSplineEdge(u);s&&c.push(s)}});const f=i.AcGeLoop2d.buildFromEdges(c);f.length==0&&c.length>0?t.add(new i.AcGeLoop2d(c)):f.forEach(u=>t.add(u))}}),e.gradientFlag){const r=e;if(t.hatchObjectType=i.AcDbHatchObjectType.GradientObject,t.gradientName=r.gradientName,t.gradientAngle=r.gradientRotation??0,t.gradientShift=r.gradientDefinition??0,t.gradientOneColorMode=r.gradientColorFlag==1,t.shadeTintValue=r.colorTint??0,r.gradientColors){const o=r.gradientColors.length;o>1?(t.gradientStartColor=r.gradientColors[0].rgb,t.gradientEndColor=r.gradientColors[1].rgb):o>0&&(t.gradientStartColor=r.gradientColors[0].rgb)}}return t}convertTable(e){const t=new i.AcDbTable(e.name,e.rowCount,e.columnCount);return t.tableDataVersion=e.version,t.tableStyleId=e.tableStyleId,t.owningBlockRecordId=e.blockRecordHandle,e.directionVector&&(t.horizontalDirection=new i.AcGeVector3d(e.directionVector)),t.attachmentPoint=e.attachmentPoint,t.position.copy(e.startPoint),t.tableValueFlag=e.tableValue,t.tableOverrideFlag=e.overrideFlag,t.borderColorOverrideFlag=e.borderColorOverrideFlag,t.borderLineweightOverrideFlag=e.borderLineWeightOverrideFlag,t.borderVisibilityOverrideFlag=e.borderVisibilityOverrideFlag,e.columnWidthArr.forEach((n,a)=>t.setColumnWidth(a,n)),e.rowHeightArr.forEach((n,a)=>t.setRowHeight(a,n)),e.cells.forEach((n,a)=>{t.setCell(a,n)}),t}convertText(e){const t=new i.AcDbText;t.textString=e.text,t.styleName=e.styleName,t.height=e.textHeight,t.position.copy(e.startPoint);const n=e.endPoint,a=!n||n.x===0&&n.y===0&&(n.z??0)===0;return n&&!a?t.alignmentPoint.copy(n):t.alignmentPoint.copy(e.startPoint),t.rotation=i.AcGeMathUtil.degToRad(e.rotation||0),t.oblique=e.obliqueAngle??0,t.thickness=e.thickness,t.horizontalMode=e.halign,t.verticalMode=e.valign,t.widthFactor=e.xScale??1,t}convertMText(e){const t=new i.AcDbMText;t.contents=e.text,e.styleName!=null&&(t.styleName=e.styleName),t.height=e.height,t.width=e.width,t.rotation=i.AcGeMathUtil.degToRad(e.rotation||0),t.location=e.insertionPoint,t.attachmentPoint=e.attachmentPoint,e.direction&&(t.direction=new i.AcGeVector3d(e.direction)),t.drawingDirection=e.drawingDirection;const n=this.readMTextExtentsWidth(e);return n!=null&&n>0&&(t.extentsWidth=n),t}readMTextExtentsWidth(e){const t=e;return t.extentsWidth??t.actualWidth}convertLeader(e){var n;const t=new i.AcDbLeader;return(n=e.vertices)==null||n.forEach(a=>{t.appendVertex(a)}),t.hasArrowHead=e.isArrowheadEnabled,t.hasHookLine=e.isHooklineExists,t.isHookLineSameDirection=e.isHooklineSameDirection,t.isSplined=e.isSpline,t.dimensionStyle=e.styleName??"",t.annoType=e.leaderCreationFlag,t.textHeight=e.textHeight??0,t.textWidth=e.textWidth??0,t.byBlockColor=e.byBlockColor,t.associatedAnnotation=e.associatedAnnotation??"",e.normal&&(t.normal=e.normal),e.horizontalDirection&&(t.horizontalDirection=e.horizontalDirection),e.offsetFromBlock&&(t.offsetFromBlock=e.offsetFromBlock),e.offsetFromAnnotation&&(t.offsetFromAnnotation=e.offsetFromAnnotation),t}convertMLine(e){const t=new i.AcDbMLine;return t.styleName=e.name||"STANDARD",t.styleObjectHandle=e.styleObjectHandle,t.scale=e.scale,t.justification=e.justification,t.flags=e.flags,t.styleCount=e.styleCount,t.startPosition=e.startPosition,t.normal=e.extrusionDirection??i.AcGeVector3d.Z_AXIS,t.segments=(e.segments??[]).map(n=>{var a;return{position:n.position,direction:n.direction,miterDirection:n.miterDirection,elements:((a=n.elements)==null?void 0:a.map(r=>({parameterCount:r.parameterCount,parameters:r.parameters??[],fillCount:r.fillCount,fillParameters:r.fillParameters??[]})))??[]}}),t}convertMLeader(e){var Ee,Se;const t=new i.AcDbMLeader,n=e;t.version=e.version,t.leaderStyleId=e.leaderStyleId,e.leaderStyleId&&(t.mleaderStyleId=e.leaderStyleId),t.propertyOverrideFlag=e.propertyOverrideFlag,t.leaderLineType=e.leaderLineType??i.AcDbMLeaderLineType.StraightLeader,e.leaderLineColor!=null&&(t.leaderLineColor=i.decodeMLeaderStyleRawColor(e.leaderLineColor)),t.leaderLineTypeId=e.leaderLineTypeId,t.leaderLineWeight=e.leaderLineWeight,t.landingEnabled=e.landingEnabled,t.doglegEnabled=e.doglegEnabled??!1,t.doglegLength=e.doglegLength??0,t.arrowheadId=e.arrowheadId,t.arrowheadSize=e.arrowheadSize,t.textStyleId=e.textStyleId,t.textLeftAttachmentType=e.textLeftAttachmentType,t.textRightAttachmentType=e.textRightAttachmentType,t.textAngleType=e.textAngleType,t.textAlignmentType=e.textAlignmentType,e.textColor!=null&&(t.textColor=i.decodeMLeaderStyleRawColor(e.textColor)),t.textFrameEnabled=e.textFrameEnabled,t.landingGap=e.landingGap,t.textAttachment=e.textAttachment,t.textFlowDirection=e.textFlowDirection,this.isValidHandleId(e.blockContentId)&&(t.blockContentId=e.blockContentId),e.blockContentColor!=null&&(t.blockContentColor=i.decodeMLeaderStyleRawColor(e.blockContentColor)),t.blockContentRotation=e.blockContentRotation,t.blockContentConnectionType=e.blockContentConnectionType,t.annotativeScaleEnabled=e.annotativeScaleEnabled,t.arrowheadOverrides=e.arrowheadOverrides?e.arrowheadOverrides.map(p=>({...p})):[],t.blockAttributes=e.blockAttributes?e.blockAttributes.map(p=>({...p})):[],t.textDirectionNegative=e.textDirectionNegative,t.textAlignInIPE=e.textAlignInIPE,t.bottomTextAttachmentDirection=e.bottomTextAttachmentDirection,t.topTextAttachmentDirection=e.topTextAttachmentDirection,t.contentScale=e.contentScale,t.textLineSpacingStyle=e.textLineSpacingStyle,e.textBackgroundColor!=null&&(t.textBackgroundColor=i.decodeMLeaderStyleRawColor(e.textBackgroundColor)),t.textBackgroundScaleFactor=e.textBackgroundScaleFactor,t.textBackgroundTransparency=e.textBackgroundTransparency,t.textBackgroundColorOn=e.textBackgroundColorOn,t.textFillOn=e.textFillOn,t.textColumnType=e.textColumnType,t.textUseAutoHeight=e.textUseAutoHeight,t.textColumnWidth=e.textColumnWidth,t.textColumnGutterWidth=e.textColumnGutterWidth,t.textColumnFlowReversed=e.textColumnFlowReversed,t.textColumnHeight=e.textColumnHeight,t.textUseWordBreak=e.textUseWordBreak,t.hasMText=e.hasMText,t.hasBlock=e.hasBlock,t.planeNormalReversed=e.planeNormalReversed,e.blockContentScale&&(t.blockContentScale=new i.AcGeVector3d(e.blockContentScale)),e.contentBasePosition&&(t.contentBasePosition=new i.AcGePoint3d().copy(e.contentBasePosition)),e.textAnchor&&(t.textAnchor=new i.AcGePoint3d().copy(e.textAnchor)),e.planeOrigin&&(t.planeOrigin=new i.AcGePoint3d().copy(e.planeOrigin)),e.planeXAxisDirection&&(t.planeXAxisDirection=new i.AcGeVector3d(e.planeXAxisDirection)),e.planeYAxisDirection&&(t.planeYAxisDirection=new i.AcGeVector3d(e.planeYAxisDirection));const a=n.textContent,r=a&&typeof a=="object"?a:void 0,o=typeof a=="string"&&a.length>0||this.readString(r??{},["text","contents"])!=null||this.readString(n,["text","contents","mtext"])!=null,l=e.contentType??(o?i.AcDbMLeaderContentType.MTextContent:e.blockContent?i.AcDbMLeaderContentType.BlockContent:i.AcDbMLeaderContentType.NoneContent);t.contentType=l;const c=this.readPoint(n,["normal","extrusionDirection"]);c&&(t.normal=c);const f=this.readString(r??{},["styleName","textStyleName","textStyle"])??this.readString(n,["textStyleName","textStyle","styleName"]);f&&(t.textStyleName=f);const u=this.readPositiveNumber(r??{},["textHeight","height"])??this.readPositiveNumber(n,["textHeight","mtextHeight","textContentHeight"])??this.readPositiveNumber(n,["arrowheadSize","contentScale"]);u!=null&&(t.textHeight=u);const s=this.readPositiveNumber(r??{},["textWidth","width"])??this.readPositiveNumber(n,["textWidth","mtextWidth","textContentWidth"]);s!=null&&(t.textWidth=s),t.textLineSpacingFactor=this.readNumber(r??{},["lineSpacingFactor","textLineSpacingFactor"])??this.readNumber(n,["textLineSpacingFactor"])??t.textLineSpacingFactor;const h=this.readNumber(r??{},["textRotation","rotation"])??this.readNumber(n,["textRotation","mtextRotation","textContentRotation"]);h!=null&&(t.textRotation=i.AcGeMathUtil.degToRad(h));const L=this.readPoint(n,["textDirection","mtextDirection","textDirectionVector"]);L&&(t.textDirection=L);const D=this.readNumber(n,["textAttachmentPoint","attachmentPoint"]);D!=null&&D!==0&&(t.textAttachmentPoint=D);const E=e.textAttachmentDirection;E!=null&&(t.textAttachmentDirection=E);const V=this.readNumber(n,["textDrawingDirection","drawingDirection"]);V!=null&&(t.textDrawingDirection=V);const ne=typeof a=="string"?a:this.readString(r??{},["text","contents"])??this.readString(n,["text","contents","mtext"]),U=this.readPoint(r??{},["anchorPoint","textAnchor","textLocation","textPosition","textAnchorPoint"])??this.readPoint(n,["textAnchor","textLocation","textPosition","textAnchorPoint","contentBasePosition"]);if(ne!=null&&U&&(t.mtextContent={text:ne,anchorPoint:U}),e.blockContent){const p=e.blockContent,Xe=e.blockContent.blockContentId;if(this.isValidHandleId(Xe)){const je=this.readNumber(p,["color"]);t.blockContent={blockContentId:Xe,normal:this.readPoint(p,["normal"]),position:e.blockContent.position,scale:this.readPoint(p,["scale"]),rotation:this.readNumber(p,["rotation"]),color:je!=null?i.decodeMLeaderStyleRawColor(je):void 0,transformationMatrix:Array.isArray(e.blockContent.transformationMatrix)?e.blockContent.transformationMatrix:[]}}}else this.isValidHandleId(e.blockContentId)&&(t.blockContent={blockContentId:e.blockContentId,scale:e.blockContentScale,rotation:e.blockContentRotation,color:t.blockContentColor,transformationMatrix:[]});return(Ee=this.readMLeaderLeaders(n))==null||Ee.forEach(p=>{t.addLeader({lastLeaderLinePoint:p.lastLeaderLinePoint,lastLeaderLinePointSet:p.lastLeaderLinePointSet,doglegVector:p.doglegVector,doglegVectorSet:p.doglegVectorSet,doglegLength:p.doglegLength??e.doglegLength,breaks:p.breaks,leaderBranchIndex:p.leaderBranchIndex,leaderLines:p.leaderLines})}),t.numberOfLeaders===0&&((Se=this.readLeaderLineArray(n))==null||Se.forEach(p=>{t.addLeader({doglegLength:e.doglegLength}),t.addLeaderLine(t.numberOfLeaders-1,p)})),t.numberOfLeaders===0&&e.contentBasePosition&&t.addLeader({lastLeaderLinePoint:e.contentBasePosition,lastLeaderLinePointSet:!0,doglegLength:e.doglegLength}),t}convertDimension(e){if(e.subclassMarker=="AcDbAlignedDimension"){const t=e,n=new i.AcDbAlignedDimension(t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return t.insertionPoint&&(n.dimBlockPosition={...t.insertionPoint,z:0}),n.rotation=i.AcGeMathUtil.degToRad(t.rotationAngle||0),this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDbRotatedDimension"){const t=e,n=new i.AcDbRotatedDimension(t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return t.insertionPoint&&(n.dimBlockPosition={...t.insertionPoint,z:0}),n.rotation=i.AcGeMathUtil.degToRad(t.rotationAngle||0),this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDb3PointAngularDimension"){const t=e,n=new i.AcDb3PointAngularDimension(t.centerPoint,t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDb2LineAngularDimension"){const t=e,n=t.centerPoint??t.subDefinitionPoint2??t.definitionPoint,a=t.definitionPoint??t.subDefinitionPoint2;if(!n||!t.subDefinitionPoint1||!t.subDefinitionPoint2||!a)return null;const r=new i.AcDb3PointAngularDimension(n,t.subDefinitionPoint1,t.subDefinitionPoint2,a);return this.processDimensionCommonAttrs(e,r),r}else if(e.subclassMarker=="AcDbOrdinateDimension"){const t=e,n=new i.AcDbOrdinateDimension(t.subDefinitionPoint1,t.subDefinitionPoint2);return this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDbRadialDimension"){const t=e,n=new i.AcDbRadialDimension(t.definitionPoint,t.subDefinitionPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,n),n}else if(e.subclassMarker=="AcDbDiametricDimension"){const t=e,n=new i.AcDbDiametricDimension(t.definitionPoint,t.subDefinitionPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,n),n}return null}processImage(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.imageSize.copy(e.imageSize),t.isShownClipped=(e.flags|4)>0,t.isImageShown=(e.flags|3)>0,t.isImageTransparent=(e.flags|8)>0,t.imageDefId=e.imageDefHandle,t.isClipped=e.isClipped,e.clippingBoundaryPath.forEach(n=>{t.clipBoundary.push(new i.AcGePoint2d(n))}),t.width=Math.sqrt(e.uPixel.x**2+e.uPixel.y**2+e.uPixel.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vPixel.x**2+e.vPixel.y**2+e.vPixel.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uPixel.y,e.uPixel.x)}convertImage(e){const t=new i.AcDbRasterImage;return this.processImage(e,t),t.clipBoundaryType=e.clippingBoundaryType,t}processWipeout(e,t){t.position.copy(e.position),t.brightness=e.brightness,t.contrast=e.contrast,t.fade=e.fade,t.imageSize.copy(e.imageSize),t.isShownClipped=(e.displayFlag|4)>0,t.isImageShown=(e.displayFlag|3)>0,t.isImageTransparent=(e.displayFlag|8)>0,t.imageDefId=e.imageDefHardId,t.isClipped=e.isClipping,e.boundary.forEach(n=>{t.clipBoundary.push(new i.AcGePoint2d(n))}),t.clipBoundaryType=e.boundaryType,t.width=Math.sqrt(e.uDirection.x**2+e.uDirection.y**2+e.uDirection.z**2)*e.imageSize.x,t.height=Math.sqrt(e.vDirection.x**2+e.vDirection.y**2+e.vDirection.z**2)*e.imageSize.y,t.rotation=Math.atan2(e.uDirection.y,e.uDirection.x)}convertWipeout(e){const t=new i.AcDbWipeout;return this.processWipeout(e,t),t}convertViewport(e){const t=new i.AcDbViewport;return t.number=e.viewportId,t.centerPoint.copy(e.viewportCenter),t.height=e.height,t.width=e.width,t.viewCenter.copy(e.displayCenter),t.viewHeight=e.viewHeight,t}convertRay(e){const t=new i.AcDbRay;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertXline(e){const t=new i.AcDbXline;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertBlockReference(e){const t=new i.AcDbBlockReference(e.name);return e.insertionPoint&&t.position.copy(e.insertionPoint),t.scaleFactors.x=e.xScale||1,t.scaleFactors.y=e.yScale||1,t.scaleFactors.z=e.zScale||1,t.rotation=e.rotation!=null?i.AcGeMathUtil.degToRad(e.rotation):0,t.normal.copy(e.extrusionDirection??{x:0,y:0,z:1}),t}processDimensionCommonAttrs(e,t){t.dimBlockId=e.name,t.textPosition.copy(e.textPoint),t.textRotation=e.textRotation||0,e.textLineSpacingFactor&&(t.textLineSpacingFactor=e.textLineSpacingFactor),e.textLineSpacingStyle&&(t.textLineSpacingStyle=e.textLineSpacingStyle),t.dimensionStyleName=e.styleName,t.dimensionText=e.text||"",t.measurement=e.measurement,t.normal.copy(e.extrusionDirection??{x:0,y:0,z:1})}processCommonAttrs(e,t){if(t.layer=e.layer||"0",e.handle&&(t.objectId=e.handle.toString()),t.ownerId=e.ownerBlockRecordSoftId||"",e.lineType!=null&&(t.lineType=e.lineType),e.lineweight!=null&&(t.lineWeight=e.lineweight),e.lineTypeScale!=null&&(t.linetypeScale=e.lineTypeScale),e.color!=null||e.colorIndex!=null||e.colorName){const n=new i.AcCmColor;e.color!=null&&n.setRGBValue(e.color),e.colorIndex!=null&&(n.colorIndex=e.colorIndex),e.colorName&&(n.colorName=e.colorName),t.color=n}e.isVisible!=null&&(t.visibility=!e.isVisible),e.transparency!=null&&(t.transparency=i.AcCmTransparency.deserialize(e.transparency))}isValidHandleId(e){return e!=null&&e!==""&&e!=="0"}readNumber(e,t){for(const n of t){const a=e[n];if(typeof a=="number"&&Number.isFinite(a))return a}}readPositiveNumber(e,t){const n=this.readNumber(e,t);return n!=null&&n>0?n:void 0}readString(e,t){for(const n of t){const a=e[n];if(typeof a=="string")return a}}readBoolean(e,t){for(const n of t){const a=e[n];if(typeof a=="boolean")return a;if(typeof a=="number")return a!==0}}readPoint(e,t){for(const n of t){const a=e[n];if(this.isPointLike(a))return a;if(Array.isArray(a)&&typeof a[0]=="number"&&typeof a[1]=="number")return{x:a[0],y:a[1],z:a[2]??0}}}readLeaderLineArray(e){const t=e.leaderLines;if(Array.isArray(t))return t.map(a=>{if(!a||typeof a!="object")return;const r=a.vertices;return Array.isArray(r)?r.filter(o=>this.isPointLike(o)):void 0}).filter(a=>!!a&&a.length>0);const n=e.vertices;if(Array.isArray(n)){const a=n.filter(r=>this.isPointLike(r));return a.length>0?[a]:void 0}}readMLeaderLeaders(e){const t=e.leaderSections;if(!Array.isArray(t))return;const n=[];return t.forEach(a=>{if(!a||typeof a!="object")return;const r=a,o=r.leaderLines,l=Array.isArray(o)?o.reduce((D,E)=>{const V=this.readMLeaderLine(E);return V&&D.push(V),D},[]):void 0,c={},f=this.readPoint(r,["lastLeaderLinePoint"]),u=this.readPoint(r,["doglegVector"]),s=this.readNumber(r,["doglegLength"]),h=this.readMLeaderBreaks(r.breaks),L=this.readNumber(r,["leaderBranchIndex"]);f&&(c.lastLeaderLinePoint=f),r.lastLeaderLinePointSet!=null&&(c.lastLeaderLinePointSet=this.readBoolean(r,["lastLeaderLinePointSet"])),u&&(c.doglegVector=u),r.doglegVectorSet!=null&&(c.doglegVectorSet=this.readBoolean(r,["doglegVectorSet"])),s!=null&&(c.doglegLength=s),h&&(c.breaks=h),L!=null&&(c.leaderBranchIndex=L),l&&(c.leaderLines=l),n.push(c)}),n}readMLeaderLine(e){if(!e||typeof e!="object")return;const t=e,n=t.vertices,a=Array.isArray(n)?n.filter(c=>this.isPointLike(c)):[],r=this.readMLeaderBreaks(t.breaks),o=Array.isArray(t.breakPointIndexes)?t.breakPointIndexes.filter(c=>typeof c=="number"):void 0,l=this.readNumber(t,["leaderLineIndex"]);return a.length>0||r&&r.length>0?{vertices:a,breakPointIndexes:o,leaderLineIndex:l,breaks:r}:void 0}readMLeaderBreaks(e){if(!Array.isArray(e))return;const t=e.map(n=>{if(!n||typeof n!="object")return;const a=n,r=this.readPoint(a,["start"]),o=this.readPoint(a,["end"]),l=this.readNumber(a,["index"]);if(!r||!o)return;const c={start:r,end:o};return l!=null&&(c.index=l),c}).filter(n=>!!n);return t.length>0?t:void 0}isPointLike(e){return!!e&&typeof e=="object"&&typeof e.x=="number"&&typeof e.y=="number"}}class et{convertLayout(e,t){var r,o;const n=new i.AcDbLayout;n.layoutName=e.layoutName,n.tabOrder=e.tabOrder,n.plotSettingsName=e.pageSetupName,n.plotCfgName=e.configName,n.canonicalMediaName=e.paperSize,n.plotViewName=e.plotViewName,n.currentStyleSheet=e.currentStyleSheet,n.plotPaperMargins={left:e.marginLeft,right:e.marginRight,top:e.marginTop,bottom:e.marginBottom},n.plotPaperSize.copy({x:e.paperWidth,y:e.paperHeight}),n.plotOrigin.copy({x:e.plotOriginX,y:e.plotOriginY}),n.plotWindowArea.min.copy({x:e.windowAreaXMin,y:e.windowAreaYMin}),n.plotWindowArea.max.copy({x:e.windowAreaXMax,y:e.windowAreaYMax}),n.customPrintScale={numerator:e.printScaleNumerator,denominator:e.printScaleDenominator},n.plotPaperUnits=e.plotPaperUnit,n.plotRotation=e.plotRotation,n.plotType=e.plotType,n.stdScaleType=e.standardScaleType,n.shadePlot=(()=>{switch(e.shadePlotMode){case 1:return i.AcDbPlotShadePlotType.kWireframe;case 2:return i.AcDbPlotShadePlotType.kHidden;case 3:return i.AcDbPlotShadePlotType.kRendered;default:return i.AcDbPlotShadePlotType.kAsDisplayed}})(),n.shadePlotResLevel=(()=>{switch(e.shadePlotResolution){case 1:return i.AcDbPlotShadePlotResLevel.kPreview;case 2:return i.AcDbPlotShadePlotResLevel.kNormal;case 3:return i.AcDbPlotShadePlotResLevel.kPresentation;case 4:return i.AcDbPlotShadePlotResLevel.kMaximum;case 5:return i.AcDbPlotShadePlotResLevel.kCustom;default:return i.AcDbPlotShadePlotResLevel.kDraft}})(),e.shadePlotCustomDPI!=null&&(n.shadePlotCustomDPI=e.shadePlotCustomDPI),e.shadePlotId&&(n.shadePlotId=e.shadePlotId);const a=e.layoutFlag??0;if(n.plotViewportBorders=(a&1)!==0,n.showPlotStyles=(a&2)!==0,n.plotCentered=(a&4)!==0,n.plotHidden=(a&8)!==0,n.useStandardScale=(a&16)!==0,n.plotPlotStyles=(a&32)!==0,n.scaleLineweights=(a&64)!==0,n.printLineweights=(a&128)!==0,n.drawViewportsFirst=(a&512)!==0,n.modelType=(a&1024)!==0,e.viewportId&&n.viewportArray.push(e.viewportId),e.layoutName==="Model"){const l=i.AcDbBlockTableRecord.MODEL_SPACE_NAME.toUpperCase();(r=t.tables.BLOCK_RECORD)==null||r.entries.some(c=>c.name.toUpperCase()===l?(n.blockTableRecordId=c.handle,!0):!1)}else(o=t.tables.BLOCK_RECORD)==null||o.entries.some(l=>l.layoutObjects===e.handle?(n.blockTableRecordId=l.handle,!0):!1),n.blockTableRecordId||(n.blockTableRecordId=e.paperSpaceTableId);return e.minLimit&&n.limits.min.copy(e.minLimit),e.maxLimit&&n.limits.max.copy(e.maxLimit),e.minExtent&&n.extents.min.copy(e.minExtent),e.maxExtent&&n.extents.max.copy(e.maxExtent),this.processCommonAttrs(e,n),n}convertImageDef(e){const t=new i.AcDbRasterImageDef;return t.sourceFileName=e.fileName,this.processCommonAttrs(e,t),t}convertMLeaderStyle(e){const t=new i.AcDbMLeaderStyle;return t.unknown1=e.unknown1,e.contentType!=null&&(t.contentType=e.contentType),e.drawMLeaderOrderType!=null&&(t.drawMLeaderOrderType=e.drawMLeaderOrderType),e.drawLeaderOrderType!=null&&(t.drawLeaderOrderType=e.drawLeaderOrderType),e.maxLeaderSegmentPoints!=null&&(t.maxLeaderSegmentPoints=e.maxLeaderSegmentPoints),e.firstSegmentAngleConstraint!=null&&(t.firstSegmentAngleConstraint=e.firstSegmentAngleConstraint),e.secondSegmentAngleConstraint!=null&&(t.secondSegmentAngleConstraint=e.secondSegmentAngleConstraint),e.leaderLineType!=null&&(t.leaderLineType=e.leaderLineType),e.leaderLineColor!=null&&(t.leaderLineColor=i.decodeMLeaderStyleRawColor(e.leaderLineColor)),t.leaderLineTypeId=e.leaderLineTypeId,e.leaderLineWeight!=null&&(t.leaderLineWeight=e.leaderLineWeight),e.landingEnabled!=null&&(t.landingEnabled=e.landingEnabled),e.landingGap!=null&&(t.landingGap=e.landingGap),e.doglegEnabled!=null&&(t.doglegEnabled=e.doglegEnabled),e.doglegLength!=null&&(t.doglegLength=e.doglegLength),e.description!=null&&(t.description=e.description),t.arrowheadId=e.arrowheadId,e.arrowheadSize!=null&&(t.arrowheadSize=e.arrowheadSize),e.defaultMTextContents!=null&&(t.defaultMTextContents=e.defaultMTextContents),t.textStyleId=e.textStyleId,e.textLeftAttachmentType!=null&&(t.textLeftAttachmentType=e.textLeftAttachmentType),e.textAngleType!=null&&(t.textAngleType=e.textAngleType),e.textAlignmentType!=null&&(t.textAlignmentType=e.textAlignmentType),e.textRightAttachmentType!=null&&(t.textRightAttachmentType=e.textRightAttachmentType),e.textColor!=null&&(t.textColor=i.decodeMLeaderStyleRawColor(e.textColor)),e.textHeight!=null&&(t.textHeight=e.textHeight),e.textFrameEnabled!=null&&(t.textFrameEnabled=e.textFrameEnabled),e.textAlignAlwaysLeft!=null&&(t.textAlignAlwaysLeft=e.textAlignAlwaysLeft),e.alignSpace!=null&&(t.alignSpace=e.alignSpace),t.blockContentId=e.blockContentId,e.blockContentColor!=null&&(t.blockContentColor=i.decodeMLeaderStyleRawColor(e.blockContentColor)),e.blockContentScale&&(t.blockContentScale={x:e.blockContentScale.x,y:e.blockContentScale.y,z:e.blockContentScale.z??1}),e.blockContentScaleEnabled!=null&&(t.blockContentScaleEnabled=e.blockContentScaleEnabled),e.blockContentRotation!=null&&(t.blockContentRotation=e.blockContentRotation),e.blockContentRotationEnabled!=null&&(t.blockContentRotationEnabled=e.blockContentRotationEnabled),e.blockContentConnectionType!=null&&(t.blockContentConnectionType=e.blockContentConnectionType),e.scale!=null&&(t.scale=e.scale),e.overwritePropertyValue!=null&&(t.overwritePropertyValue=e.overwritePropertyValue),e.annotative!=null&&(t.annotative=e.annotative),e.breakGapSize!=null&&(t.breakGapSize=e.breakGapSize),e.textAttachmentDirection!=null&&(t.textAttachmentDirection=e.textAttachmentDirection),e.bottomTextAttachmentDirection!=null&&(t.bottomTextAttachmentDirection=e.bottomTextAttachmentDirection),e.topTextAttachmentDirection!=null&&(t.topTextAttachmentDirection=e.topTextAttachmentDirection),t.unknown2=e.unknown2,this.processCommonAttrs(e,t),t}convertMLineStyle(e){var a;const t=new i.AcDbMlineStyle;if(e.styleName!=null&&(t.styleName=e.styleName),e.flags!=null&&(t.flags=e.flags),e.description!=null&&(t.description=e.description),e.fillColor!=null)t.fillColor=new i.AcCmColor().setRGBValue(e.fillColor);else if(e.fillColorIndex!=null){const r=new i.AcCmColor;r.colorIndex=e.fillColorIndex,t.fillColor=r}e.startAngle!=null&&(t.startAngle=e.startAngle),e.endAngle!=null&&(t.endAngle=e.endAngle);const n=Math.max(e.elementCount??0,((a=e.elements)==null?void 0:a.length)??0);return n>0&&(t.elements=Array.from({length:n},(r,o)=>{var l,c,f,u;return{offset:((c=(l=e.elements)==null?void 0:l[o])==null?void 0:c.offset)??0,color:(()=>{var h,L,D,E;const s=new i.AcCmColor;return((L=(h=e.elements)==null?void 0:h[o])==null?void 0:L.color)!=null?s.setRGBValue(e.elements[o].color):s.colorIndex=((E=(D=e.elements)==null?void 0:D[o])==null?void 0:E.colorIndex)??256,s})(),lineType:((u=(f=e.elements)==null?void 0:f[o])==null?void 0:u.lineType)??"BYLAYER"}})),this.processCommonAttrs(e,t),t}processCommonAttrs(e,t){t.objectId=e.handle,e.ownerObjectId!=null&&(t.ownerId=e.ownerObjectId)}}class tt extends i.AcDbDatabaseConverter{constructor(e={}){super(e),this.config.parserWorkerUrl||(this.config.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(e,t){const n=this.config,a=this.getParserWorkerTimeout(e,t);if(n.useWorker&&n.parserWorkerUrl){const r=i.createWorkerApi({workerUrl:n.parserWorkerUrl,timeout:a,maxConcurrentWorkers:1}),o=await r.execute(e);return r.destroy(),i.AcDbOpenDatabaseError.throwOnWorkerParseFailure(o),{model:o.data,data:{unknownEntityCount:0}}}else throw new Error("dxf converter can run in web worker only!")}getFonts(e){var n,a;const t=e.blocks??{};return new i.AcDbFontNameCollector({styles:((n=e.tables.STYLE)==null?void 0:n.entries)??[],textStyleVar:((a=e.header)==null?void 0:a.$TEXTSTYLE)||i.DEFAULT_TEXT_STYLE}).collect(e.entities,{getEntityFontInfo:r=>{if(r.type=="MTEXT"){const o=r;return{styleName:o.styleName,formattedText:o.text,resolveStyle:!0}}if(r.type=="TEXT"||r.type=="ATTRIB")return{styleName:r.styleName,resolveStyle:!0};if(r.type=="MULTILEADER"||r.type=="MLEADER"){const o=r,l=typeof o.textContent=="string"?o.textContent:"";return{styleName:typeof o.textStyleName=="string"?o.textStyleName:typeof o.styleName=="string"?o.styleName:void 0,formattedText:l,resolveStyle:!0}}return r.type=="INSERT"?{blockName:r.name}:null},getBlockEntities:r=>{var o;return(o=t[r])==null?void 0:o.entities}})}async processEntities(e,t,n,a,r){const o=new Ye;let l=e.entities;const c=l.length,f=new i.AcDbBatchProcessing(c,100-a.value,n);this.config.convertByEntityType&&(l=this.groupAndFlattenByType(l));const u=new Map;for(let h=0;h<c;h++){const L=l[h];if(L.type==="ATTRIB"){const D=o.convert(L);if(D&&D.ownerId&&D.ownerId!=="0"){let E=u.get(D==null?void 0:D.ownerId);E==null&&(E=[],u.set(D.ownerId,E)),E.push(D)}}}const s=t.tables.blockTable.modelSpace;await f.processChunk(async(h,L)=>{let D=[],E=h<L?l[h].type:"";for(let ne=h;ne<L;ne++){const U=l[ne];if(!(U.ownerBlockRecordSoftId&&U.ownerBlockRecordSoftId!==s.objectId)&&U.type!=="ATTRIB"){const Ee=o.convert(U);if(Ee){if(this.config.convertByEntityType&&U.type!==E&&(s.appendEntity(D),D=[],E=U.type),U.type==="INSERT"){const Se=u.get(Ee.objectId);Se&&Se.length>0&&Se.forEach(p=>{Ee.appendAttributes(p)})}D.push(Ee)}}}s.appendEntity(D);let V=a.value+L/c*(100-a.value);V>100&&(V=100),r&&await r(V,"ENTITY","IN-PROGRESS")})}async processEntitiesInBlock(e,t,n=!1){const a=new Ye,r=e.length,o=[],l=t.objectId,c=[];for(let f=0;f<r;f++){const u=e[f],s=a.convert(u);s&&(u.type==="ATTRIB"?c.push(s):(!n||u.ownerBlockRecordSoftId===l)&&o.push(s))}t.appendEntity(o),c.forEach(f=>{const u=t.getIdAt(f.ownerId);u&&u.appendAttributes(f)})}processBlocks(e,t){const n=e.blocks;for(const[a,r]of Object.entries(n)){let o=t.tables.blockTable.getAt(r.name);o||(o=new i.AcDbBlockTableRecord,r.handle!=null&&(o.objectId=String(r.handle)),o.name=a,t.tables.blockTable.add(o)),o.origin.copy(r.position),r.entities?this.processEntitiesInBlock(r.entities,o):o.isPaperSapce&&this.processEntitiesInBlock(e.entities,o,!0)}}processHeader(e,t){const n=e.header;n.$ACADVER&&(t.version=n.$ACADVER),t.cecolor.colorIndex=n.$CECOLOR||256,t.angbase=n.$ANGBASE||0,t.angdir=n.$ANGDIR||0,n.$AUNITS!=null&&(t.aunits=n.$AUNITS),n.$AUPREC!=null&&(t.auprec=n.$AUPREC),n.$LUNITS!=null&&(t.lunits=n.$LUNITS),n.$LUPREC!=null&&(t.luprec=n.$LUPREC),n.$UNITMODE!=null&&(t.unitmode=n.$UNITMODE),n.$MEASUREMENT!=null&&(t.measurement=n.$MEASUREMENT),t.celtype=n.$CELTYPE||i.ByLayer,i.AcDbSysVarManager.instance().setVar(i.AcDbSystemVariables.CETRANSPARENCY,n.$CETRANSPARENCY||"ByLayer",t),t.celtscale=n.$CELTSCALE||1;const a=this.normalizeHeaderStringValue(n.$CMLSTYLE)||this.normalizeHeaderStringValue(n.CMLSTYLE)||i.DEFAULT_MLINE_STYLE;t.cmlstyle=a;const r=n.$CMLSCALE??n.CMLSCALE;typeof r=="number"&&Number.isFinite(r)&&(t.cmlscale=r);const o=this.normalizeHeaderStringValue(n.$CMLEADERSTYLE)||this.normalizeHeaderStringValue(n.CMLEADERSTYLE)||i.DEFAULT_MLEADER_STYLE;t.cmleaderstyle=o,t.hplayer=this.normalizeHeaderStringValue(n.$HPLAYER)||this.normalizeHeaderStringValue(n.HPLAYER)||".",t.ltscale=n.$LTSCALE||1,n.$EXTMAX&&(t.extmax=n.$EXTMAX),n.$EXTMIN&&(t.extmin=n.$EXTMIN),n.$INSUNITS!=null&&(t.insunits=n.$INSUNITS),t.osmode=n.$OSMODE||0,t.orthomode=n.$ORTHOMODE||0,t.pdmode=n.$PDMODE||0,t.pdsize=n.$PDSIZE||0,t.textstyle=n.$TEXTSTYLE||i.DEFAULT_TEXT_STYLE,n.$HANDSEED!=null&&t.initializeHandleSeed(String(n.$HANDSEED))}processBlockTables(e,t){var a;const n=(a=e.tables.BLOCK_RECORD)==null?void 0:a.entries;n&&n.length>0&&(t.tables.blockTable.removeAll(),n.forEach(r=>{const o=new i.AcDbBlockTableRecord;o.objectId=r.handle,o.name=r.name,o.layoutId=r.layoutObjects,o.blockInsertUnits=r.insertionUnits,o.explodability=r.explodability,o.blockScaling=r.scalability,r.bmpPreview&&(o.bmpPreview=r.bmpPreview),t.tables.blockTable.add(o)}))}processObjects(e,t){const n=e.objects.byName,a=new et;if("LAYOUT"in n){const r=t.objects.layout;n.LAYOUT.forEach(o=>{const l=a.convertLayout(o,e);r.setAt(l.layoutName,l)})}if("IMAGEDEF"in n){const r=t.objects.imageDefinition;n.IMAGEDEF.forEach(o=>{const l=a.convertImageDef(o);r.setAt(l.objectId,l)})}if("MLEADERSTYLE"in n){const r=t.objects.mleaderStyle;n.MLEADERSTYLE.forEach(o=>{const l=a.convertMLeaderStyle(o);r.setAt(l.objectId,l)})}if("MLINESTYLE"in n){const r=t.objects.mlineStyle;n.MLINESTYLE.forEach(o=>{const l=a.convertMLineStyle(o);r.setAt(l.styleName||l.objectId,l)})}}processViewports(e,t){var a;const n=(a=e.tables)==null?void 0:a.VPORT;if(n){this.processCommonTableAttrs(n,t.tables.viewportTable,t);const r=n.entries;r&&r.length>0&&r.forEach(o=>{const l=new i.AcDbViewportTableRecord;this.processCommonTableEntryAttrs(o,l),o.circleSides&&(l.circleSides=o.circleSides),l.standardFlag=o.standardFlag,l.center.copy(o.center??i.VPORT_FALLBACK_CENTER_2D),l.lowerLeftCorner.copy(o.lowerLeftCorner??i.VPORT_FALLBACK_LLC),l.upperRightCorner.copy(o.upperRightCorner??i.VPORT_FALLBACK_URC),o.snapBasePoint&&l.snapBase.copy(o.snapBasePoint),o.snapRotationAngle&&(l.snapAngle=o.snapRotationAngle),o.snapSpacing&&l.snapIncrements.copy(o.snapSpacing),o.majorGridLines&&(l.gridMajor=o.majorGridLines),o.gridSpacing&&l.gridIncrements.copy(o.gridSpacing),o.backgroundObjectId&&(l.backgroundObjectId=o.backgroundObjectId),l.gsView.center.copy(o.center??i.VPORT_FALLBACK_CENTER_2D),l.gsView.viewDirectionFromTarget.copy(o.viewDirectionFromTarget??i.VPORT_FALLBACK_VIEW_DIR),l.gsView.viewTarget.copy(o.viewTarget??i.VPORT_FALLBACK_VIEW_TARGET),o.lensLength&&(l.gsView.lensLength=o.lensLength),o.frontClippingPlane&&(l.gsView.frontClippingPlane=o.frontClippingPlane),o.backClippingPlane&&(l.gsView.backClippingPlane=o.backClippingPlane),o.viewHeight&&(l.gsView.viewHeight=o.viewHeight),o.aspectRatio!=null&&Number.isFinite(o.aspectRatio)&&o.aspectRatio>0&&(l.gsView.aspectRatio=o.aspectRatio),o.viewTwistAngle&&(l.gsView.viewTwistAngle=o.viewTwistAngle),o.frozenLayers&&(l.gsView.frozenLayers=o.frozenLayers),o.styleSheet&&(l.gsView.styleSheet=o.styleSheet),o.renderMode&&(l.gsView.renderMode=o.renderMode),o.viewMode&&(l.gsView.viewMode=o.viewMode),o.ucsIconSetting&&(l.gsView.ucsIconSetting=o.ucsIconSetting),o.ucsOrigin&&l.gsView.ucsOrigin.copy(o.ucsOrigin),o.ucsXAxis&&l.gsView.ucsXAxis.copy(o.ucsXAxis),o.ucsYAxis&&l.gsView.ucsYAxis.copy(o.ucsYAxis),o.orthographicType&&(l.gsView.orthographicType=o.orthographicType),o.shadePlotSetting&&(l.gsView.shadePlotSetting=o.shadePlotSetting),o.shadePlotObjectId&&(l.gsView.shadePlotObjectId=o.shadePlotObjectId),o.visualStyleObjectId&&(l.gsView.visualStyleObjectId=o.visualStyleObjectId),o.isDefaultLightingOn&&(l.gsView.isDefaultLightingOn=o.isDefaultLightingOn),o.defaultLightingType&&(l.gsView.defaultLightingType=o.defaultLightingType),o.brightness&&(l.gsView.brightness=o.brightness),o.contrast&&(l.gsView.contrast=o.contrast),o.ambientColor&&(l.gsView.ambientColor=o.ambientColor),t.tables.viewportTable.add(l)})}}processLayers(e,t){var a;const n=(a=e.tables)==null?void 0:a.LAYER;if(n){this.processCommonTableAttrs(n,t.tables.layerTable,t);const r=n.entries;r&&r.length>0&&r.forEach(o=>{const l=new i.AcCmColor;l.colorIndex=o.colorIndex;const c=new i.AcDbLayerTableRecord({name:o.name,standardFlags:o.standardFlag,linetype:o.lineType,lineWeight:o.lineweight,isOff:o.colorIndex<0,color:l,isPlottable:o.isPlotting});this.processCommonTableEntryAttrs(o,c),t.tables.layerTable.add(c)})}t.ensureTextStyleDefaults()}processLineTypes(e,t){var a;const n=(a=e.tables)==null?void 0:a.LTYPE;if(n){this.processCommonTableAttrs(n,t.tables.linetypeTable,t);const r=n.entries;r&&r.length>0&&r.forEach(o=>{const l=new i.AcDbLinetypeTableRecord({name:o.name,standardFlag:o.standardFlag,description:o.description,totalPatternLength:o.totalPatternLength,pattern:o.pattern});this.processCommonTableEntryAttrs(o,l),t.tables.linetypeTable.add(l)})}}processTextStyles(e,t){var a;const n=(a=e.tables)==null?void 0:a.STYLE;if(n){this.processCommonTableAttrs(n,t.tables.textStyleTable,t);const r=n.entries;r&&r.length>0&&r.forEach(o=>{const l=new i.AcDbTextStyleTableRecord({name:o.name,standardFlag:o.standardFlag,fixedTextHeight:o.fixedTextHeight,widthFactor:o.widthFactor,obliqueAngle:o.obliqueAngle,textGenerationFlag:o.textGenerationFlag,lastHeight:o.lastHeight,font:o.font,bigFont:o.bigFont,extendedFont:o.extendedFont});this.processCommonTableEntryAttrs(o,l),t.tables.textStyleTable.add(l)})}}processDimStyles(e,t){var a;const n=(a=e.tables)==null?void 0:a.DIMSTYLE;if(n){this.processCommonTableAttrs(n,t.tables.dimStyleTable,t);const r=n.entries;r&&r.length>0&&r.forEach(o=>{const l={name:o.name,ownerId:o.ownerObjectId,dimpost:o.DIMPOST||"",dimapost:o.DIMAPOST||"",dimscale:o.DIMSCALE,dimasz:o.DIMASZ,dimexo:o.DIMEXO,dimdli:o.DIMDLI,dimexe:o.DIMEXE,dimrnd:o.DIMRND,dimdle:o.DIMDLE,dimtp:o.DIMTP,dimtm:o.DIMTM,dimtxt:o.DIMTXT,dimcen:o.DIMCEN,dimtsz:o.DIMTSZ,dimaltf:o.DIMALTF,dimlfac:o.DIMLFAC,dimtvp:o.DIMTVP,dimtfac:o.DIMTFAC,dimgap:o.DIMGAP,dimaltrnd:o.DIMALTRND,dimtol:o.DIMTOL==null||o.DIMTOL==0?0:1,dimlim:o.DIMLIM==null||o.DIMLIM==0?0:1,dimtih:o.DIMTIH==null||o.DIMTIH==0?0:1,dimtoh:o.DIMTOH==null||o.DIMTOH==0?0:1,dimse1:o.DIMSE1==null||o.DIMSE1==0?0:1,dimse2:o.DIMSE2==null||o.DIMSE2==0?0:1,dimtad:o.DIMTAD,dimzin:o.DIMZIN,dimazin:o.DIMAZIN,dimalt:o.DIMALT,dimaltd:o.DIMALTD,dimtofl:o.DIMTOFL,dimsah:o.DIMSAH,dimtix:o.DIMTIX,dimsoxd:o.DIMSOXD,dimclrd:o.DIMCLRD,dimclre:o.DIMCLRE,dimclrt:o.DIMCLRT,dimadec:o.DIMADEC||0,dimunit:o.DIMUNIT||2,dimdec:o.DIMDEC,dimtdec:o.DIMTDEC,dimaltu:o.DIMALTU,dimalttd:o.DIMALTTD,dimaunit:o.DIMAUNIT,dimfrac:o.DIMFRAC,dimlunit:o.DIMLUNIT,dimdsep:o.DIMDSEP?o.DIMDSEP.toString():".",dimtmove:o.DIMTMOVE||0,dimjust:o.DIMJUST,dimsd1:o.DIMSD1,dimsd2:o.DIMSD2,dimtolj:o.DIMTOLJ,dimtzin:o.DIMTZIN,dimaltz:o.DIMALTZ,dimalttz:o.DIMALTTZ,dimfit:o.DIMFIT||0,dimupt:o.DIMUPT,dimatfit:o.DIMATFIT,dimtxsty:o.DIMTXSTY||i.DEFAULT_TEXT_STYLE,dimldrblk:o.DIMLDRBLK||"",dimblk:o.DIMBLK||"",dimblk1:o.DIMBLK1||"",dimblk2:o.DIMBLK2||"",dimlwd:o.DIMLWD,dimlwe:o.DIMLWE},c=new i.AcDbDimStyleTableRecord(l);this.processCommonTableEntryAttrs(o,c),t.tables.dimStyleTable.add(c)})}}processCommonTableAttrs(e,t,n){e.handle!=null&&n.adoptExternalHandle(t,e.handle),e.ownerObjectId!=null&&(t.ownerId=e.ownerObjectId)}processCommonTableEntryAttrs(e,t){t.name="name"in e?e.name:"",e.handle!=null&&(t.objectId=e.handle),e.ownerObjectId!=null&&(t.ownerId=e.ownerObjectId)}groupAndFlattenByType(e){const t={},n=[];for(const a of e)t[a.type]||(t[a.type]=[],n.push(a.type)),t[a.type].push(a);return n.flatMap(a=>t[a])}normalizeHeaderStringValue(e){if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}}oe.AcDbDxfConverter=tt,Object.defineProperty(oe,Symbol.toStringTag,{value:"Module"})});