@mlightcad/data-model 1.7.29 → 1.7.30

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,5 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Qn=(i=>(i[i.Invalid=-9999]="Invalid",i[i.Start=0]="Start",i[i.Text=1]="Text",i[i.AttributeTag=2]="AttributeTag",i[i.BlockName=2]="BlockName",i[i.ShapeName=2]="ShapeName",i[i.SymbolTableName=2]="SymbolTableName",i[i.SymbolTableRecordName=2]="SymbolTableRecordName",i[i.MlineStyleName=2]="MlineStyleName",i[i.AttributePrompt=3]="AttributePrompt",i[i.Description=3]="Description",i[i.DimPostString=3]="DimPostString",i[i.DimStyleName=3]="DimStyleName",i[i.LinetypeProse=3]="LinetypeProse",i[i.TextFontFile=3]="TextFontFile",i[i.CLShapeName=4]="CLShapeName",i[i.DimensionAlternativePrefixSuffix=4]="DimensionAlternativePrefixSuffix",i[i.SymbolTableRecordComments=4]="SymbolTableRecordComments",i[i.TextBigFontFile=4]="TextBigFontFile",i[i.Handle=5]="Handle",i[i.DimensionBlock=5]="DimensionBlock",i[i.LinetypeName=6]="LinetypeName",i[i.DimBlk1=6]="DimBlk1",i[i.TextStyleName=7]="TextStyleName",i[i.DimBlk2=7]="DimBlk2",i[i.LayerName=8]="LayerName",i[i.CLShapeText=9]="CLShapeText",i[i.XCoordinate=10]="XCoordinate",i[i.YCoordinate=20]="YCoordinate",i[i.ZCoordinate=30]="ZCoordinate",i[i.Real=40]="Real",i[i.TxtSize=40]="TxtSize",i[i.ViewportHeight=40]="ViewportHeight",i[i.Angle=50]="Angle",i[i.ViewportSnapAngle=50]="ViewportSnapAngle",i[i.Visibility=60]="Visibility",i[i.Int16=70]="Int16",i[i.Int32=90]="Int32",i[i.Int64=160]="Int64",i[i.Int8=280]="Int8",i[i.Thickness=39]="Thickness",i[i.Elevation=38]="Elevation",i[i.LinetypeScale=48]="LinetypeScale",i[i.DashLength=49]="DashLength",i[i.MlineOffset=49]="MlineOffset",i[i.LinetypeElement=49]="LinetypeElement",i[i.NormalX=210]="NormalX",i[i.NormalY=220]="NormalY",i[i.NormalZ=230]="NormalZ",i[i.UcsOrg=110]="UcsOrg",i[i.UcsOrientationX=111]="UcsOrientationX",i[i.UcsOrientationY=112]="UcsOrientationY",i[i.ViewHeight=45]="ViewHeight",i[i.ViewWidth=41]="ViewWidth",i[i.ViewLensLength=42]="ViewLensLength",i[i.ViewFrontClip=43]="ViewFrontClip",i[i.ViewBackClip=44]="ViewBackClip",i[i.ViewBrightness=141]="ViewBrightness",i[i.ViewContrast=142]="ViewContrast",i[i.ViewMode=71]="ViewMode",i[i.ViewportActive=68]="ViewportActive",i[i.ViewportAspect=41]="ViewportAspect",i[i.ViewportGrid=76]="ViewportGrid",i[i.ViewportIcon=74]="ViewportIcon",i[i.ViewportNumber=69]="ViewportNumber",i[i.ViewportSnap=75]="ViewportSnap",i[i.ViewportSnapPair=78]="ViewportSnapPair",i[i.ViewportSnapStyle=77]="ViewportSnapStyle",i[i.ViewportTwist=51]="ViewportTwist",i[i.ViewportVisibility=67]="ViewportVisibility",i[i.ViewportZoom=73]="ViewportZoom",i[i.Color=62]="Color",i[i.ColorRgb=420]="ColorRgb",i[i.ColorName=430]="ColorName",i[i.LineWeight=370]="LineWeight",i[i.PlotStyleNameType=380]="PlotStyleNameType",i[i.PlotStyleNameId=390]="PlotStyleNameId",i[i.GradientObjType=450]="GradientObjType",i[i.GradientAngle=460]="GradientAngle",i[i.GradientName=470]="GradientName",i[i.GradientColCount=453]="GradientColCount",i[i.GradientPatType=451]="GradientPatType",i[i.GradientTintType=452]="GradientTintType",i[i.GradientShift=461]="GradientShift",i[i.GradientColVal=463]="GradientColVal",i[i.GradientTintVal=462]="GradientTintVal",i[i.SoftPointerId=330]="SoftPointerId",i[i.HardPointerId=340]="HardPointerId",i[i.SoftOwnershipId=350]="SoftOwnershipId",i[i.HardOwnershipId=360]="HardOwnershipId",i[i.ArbitraryHandle=320]="ArbitraryHandle",i[i.ExtendedDataAsciiString=1e3]="ExtendedDataAsciiString",i[i.ExtendedDataRegAppName=1001]="ExtendedDataRegAppName",i[i.ExtendedDataControlString=1002]="ExtendedDataControlString",i[i.ExtendedDataLayerName=1003]="ExtendedDataLayerName",i[i.ExtendedDataBinaryChunk=1004]="ExtendedDataBinaryChunk",i[i.ExtendedDataHandle=1005]="ExtendedDataHandle",i[i.ExtendedDataXCoordinate=1010]="ExtendedDataXCoordinate",i[i.ExtendedDataWorldXCoordinate=1011]="ExtendedDataWorldXCoordinate",i[i.ExtendedDataWorldXDisp=1012]="ExtendedDataWorldXDisp",i[i.ExtendedDataWorldXDir=1013]="ExtendedDataWorldXDir",i[i.ExtendedDataYCoordinate=1020]="ExtendedDataYCoordinate",i[i.ExtendedDataWorldYCoordinate=1021]="ExtendedDataWorldYCoordinate",i[i.ExtendedDataWorldYDisp=1022]="ExtendedDataWorldYDisp",i[i.ExtendedDataWorldYDir=1023]="ExtendedDataWorldYDir",i[i.ExtendedDataZCoordinate=1030]="ExtendedDataZCoordinate",i[i.ExtendedDataWorldZCoordinate=1031]="ExtendedDataWorldZCoordinate",i[i.ExtendedDataWorldZDisp=1032]="ExtendedDataWorldZDisp",i[i.ExtendedDataWorldZDir=1033]="ExtendedDataWorldZDir",i[i.ExtendedDataReal=1040]="ExtendedDataReal",i[i.ExtendedDataDist=1041]="ExtendedDataDist",i[i.ExtendedDataScale=1042]="ExtendedDataScale",i[i.ExtendedDataInteger16=1070]="ExtendedDataInteger16",i[i.ExtendedDataInteger32=1071]="ExtendedDataInteger32",i[i.XTextString=300]="XTextString",i[i.XReal=140]="XReal",i[i.XInt16=170]="XInt16",i[i.XXInt16=270]="XXInt16",i[i.Subclass=100]="Subclass",i[i.ControlString=102]="ControlString",i[i.EmbeddedObjectStart=101]="EmbeddedObjectStart",i[i.End=-1]="End",i[i.FirstEntityId=-2]="FirstEntityId",i[i.HeaderId=-2]="HeaderId",i[i.XDataStart=-3]="XDataStart",i[i.Operator=-4]="Operator",i[i.PReactors=-5]="PReactors",i[i.XDictionary=-6]="XDictionary",i))(Qn||{});const xo=[{name:"AC1.2",value:1},{name:"AC1.40",value:2},{name:"AC1.50",value:3},{name:"AC2.20",value:4},{name:"AC2.10",value:5},{name:"AC2.21",value:6},{name:"AC2.22",value:7},{name:"AC1001",value:8},{name:"AC1002",value:9},{name:"AC1003",value:10},{name:"AC1004",value:11},{name:"AC1005",value:12},{name:"AC1006",value:13},{name:"AC1007",value:14},{name:"AC1008",value:15},{name:"AC1009",value:16},{name:"AC1010",value:17},{name:"AC1011",value:18},{name:"AC1012",value:19},{name:"AC1013",value:20},{name:"AC1014",value:21},{name:"AC1500",value:22},{name:"AC1015",value:23},{name:"AC1800a",value:24},{name:"AC1018",value:25},{name:"AC2100a",value:26},{name:"AC1021",value:27},{name:"AC2400a",value:28},{name:"AC1024",value:29},{name:"AC1027",value:31},{name:"AC3200a",value:32},{name:"AC1032",value:33}];class kt{constructor(t){if(typeof t=="string"){const e=xo.find(s=>s.name===t);if(!e)throw new Error(`Unknown DWG version name: ${t}`);this.name=e.name,this.value=e.value;return}if(typeof t=="number"){const e=xo.find(s=>s.value===t);if(!e)throw new Error(`Unknown DWG version value: ${t}`);this.name=e.name,this.value=e.value;return}throw new Error("Invalid constructor argument for AcDbDwgVersion")}}class Ho{constructor(t={}){this._database=t.database,this._precision=Math.max(0,Math.min(16,t.precision??16)),this._version=t.version instanceof kt?t.version:t.version!=null?new kt(t.version):void 0,this._lines=[],this._handleMap=new Map,this._nextHandle=1}get database(){return this._database}set database(t){this._database=t}get precision(){return this._precision}setPrecision(t){return this._precision=Math.max(0,Math.min(16,t)),this}get version(){return this._version}get nextHandle(){return this._nextHandle}setVersion(t){return this._version=t instanceof kt?t:new kt(t),this}toString(){return this._lines.join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var er=(n=>(n[n.Invalid=-9999]="Invalid",n[n.Start=0]="Start",n[n.Text=1]="Text",n[n.AttributeTag=2]="AttributeTag",n[n.BlockName=2]="BlockName",n[n.ShapeName=2]="ShapeName",n[n.SymbolTableName=2]="SymbolTableName",n[n.SymbolTableRecordName=2]="SymbolTableRecordName",n[n.MlineStyleName=2]="MlineStyleName",n[n.AttributePrompt=3]="AttributePrompt",n[n.Description=3]="Description",n[n.DimPostString=3]="DimPostString",n[n.DimStyleName=3]="DimStyleName",n[n.LinetypeProse=3]="LinetypeProse",n[n.TextFontFile=3]="TextFontFile",n[n.CLShapeName=4]="CLShapeName",n[n.DimensionAlternativePrefixSuffix=4]="DimensionAlternativePrefixSuffix",n[n.SymbolTableRecordComments=4]="SymbolTableRecordComments",n[n.TextBigFontFile=4]="TextBigFontFile",n[n.Handle=5]="Handle",n[n.DimensionBlock=5]="DimensionBlock",n[n.LinetypeName=6]="LinetypeName",n[n.DimBlk1=6]="DimBlk1",n[n.TextStyleName=7]="TextStyleName",n[n.DimBlk2=7]="DimBlk2",n[n.LayerName=8]="LayerName",n[n.CLShapeText=9]="CLShapeText",n[n.XCoordinate=10]="XCoordinate",n[n.YCoordinate=20]="YCoordinate",n[n.ZCoordinate=30]="ZCoordinate",n[n.Real=40]="Real",n[n.TxtSize=40]="TxtSize",n[n.ViewportHeight=40]="ViewportHeight",n[n.Angle=50]="Angle",n[n.ViewportSnapAngle=50]="ViewportSnapAngle",n[n.Visibility=60]="Visibility",n[n.Int16=70]="Int16",n[n.Int32=90]="Int32",n[n.Int64=160]="Int64",n[n.Int8=280]="Int8",n[n.Thickness=39]="Thickness",n[n.Elevation=38]="Elevation",n[n.LinetypeScale=48]="LinetypeScale",n[n.DashLength=49]="DashLength",n[n.MlineOffset=49]="MlineOffset",n[n.LinetypeElement=49]="LinetypeElement",n[n.NormalX=210]="NormalX",n[n.NormalY=220]="NormalY",n[n.NormalZ=230]="NormalZ",n[n.UcsOrg=110]="UcsOrg",n[n.UcsOrientationX=111]="UcsOrientationX",n[n.UcsOrientationY=112]="UcsOrientationY",n[n.ViewHeight=45]="ViewHeight",n[n.ViewWidth=41]="ViewWidth",n[n.ViewLensLength=42]="ViewLensLength",n[n.ViewFrontClip=43]="ViewFrontClip",n[n.ViewBackClip=44]="ViewBackClip",n[n.ViewBrightness=141]="ViewBrightness",n[n.ViewContrast=142]="ViewContrast",n[n.ViewMode=71]="ViewMode",n[n.ViewportActive=68]="ViewportActive",n[n.ViewportAspect=41]="ViewportAspect",n[n.ViewportGrid=76]="ViewportGrid",n[n.ViewportIcon=74]="ViewportIcon",n[n.ViewportNumber=69]="ViewportNumber",n[n.ViewportSnap=75]="ViewportSnap",n[n.ViewportSnapPair=78]="ViewportSnapPair",n[n.ViewportSnapStyle=77]="ViewportSnapStyle",n[n.ViewportTwist=51]="ViewportTwist",n[n.ViewportVisibility=67]="ViewportVisibility",n[n.ViewportZoom=73]="ViewportZoom",n[n.Color=62]="Color",n[n.ColorRgb=420]="ColorRgb",n[n.ColorName=430]="ColorName",n[n.LineWeight=370]="LineWeight",n[n.PlotStyleNameType=380]="PlotStyleNameType",n[n.PlotStyleNameId=390]="PlotStyleNameId",n[n.GradientObjType=450]="GradientObjType",n[n.GradientAngle=460]="GradientAngle",n[n.GradientName=470]="GradientName",n[n.GradientColCount=453]="GradientColCount",n[n.GradientPatType=451]="GradientPatType",n[n.GradientTintType=452]="GradientTintType",n[n.GradientShift=461]="GradientShift",n[n.GradientColVal=463]="GradientColVal",n[n.GradientTintVal=462]="GradientTintVal",n[n.SoftPointerId=330]="SoftPointerId",n[n.HardPointerId=340]="HardPointerId",n[n.SoftOwnershipId=350]="SoftOwnershipId",n[n.HardOwnershipId=360]="HardOwnershipId",n[n.ArbitraryHandle=320]="ArbitraryHandle",n[n.ExtendedDataAsciiString=1e3]="ExtendedDataAsciiString",n[n.ExtendedDataRegAppName=1001]="ExtendedDataRegAppName",n[n.ExtendedDataControlString=1002]="ExtendedDataControlString",n[n.ExtendedDataLayerName=1003]="ExtendedDataLayerName",n[n.ExtendedDataBinaryChunk=1004]="ExtendedDataBinaryChunk",n[n.ExtendedDataHandle=1005]="ExtendedDataHandle",n[n.ExtendedDataXCoordinate=1010]="ExtendedDataXCoordinate",n[n.ExtendedDataWorldXCoordinate=1011]="ExtendedDataWorldXCoordinate",n[n.ExtendedDataWorldXDisp=1012]="ExtendedDataWorldXDisp",n[n.ExtendedDataWorldXDir=1013]="ExtendedDataWorldXDir",n[n.ExtendedDataYCoordinate=1020]="ExtendedDataYCoordinate",n[n.ExtendedDataWorldYCoordinate=1021]="ExtendedDataWorldYCoordinate",n[n.ExtendedDataWorldYDisp=1022]="ExtendedDataWorldYDisp",n[n.ExtendedDataWorldYDir=1023]="ExtendedDataWorldYDir",n[n.ExtendedDataZCoordinate=1030]="ExtendedDataZCoordinate",n[n.ExtendedDataWorldZCoordinate=1031]="ExtendedDataWorldZCoordinate",n[n.ExtendedDataWorldZDisp=1032]="ExtendedDataWorldZDisp",n[n.ExtendedDataWorldZDir=1033]="ExtendedDataWorldZDir",n[n.ExtendedDataReal=1040]="ExtendedDataReal",n[n.ExtendedDataDist=1041]="ExtendedDataDist",n[n.ExtendedDataScale=1042]="ExtendedDataScale",n[n.ExtendedDataInteger16=1070]="ExtendedDataInteger16",n[n.ExtendedDataInteger32=1071]="ExtendedDataInteger32",n[n.XTextString=300]="XTextString",n[n.XReal=140]="XReal",n[n.XInt16=170]="XInt16",n[n.XXInt16=270]="XXInt16",n[n.Subclass=100]="Subclass",n[n.ControlString=102]="ControlString",n[n.EmbeddedObjectStart=101]="EmbeddedObjectStart",n[n.End=-1]="End",n[n.FirstEntityId=-2]="FirstEntityId",n[n.HeaderId=-2]="HeaderId",n[n.XDataStart=-3]="XDataStart",n[n.Operator=-4]="Operator",n[n.PReactors=-5]="PReactors",n[n.XDictionary=-6]="XDictionary",n))(er||{});const fa=[{name:"AC1.2",value:1},{name:"AC1.40",value:2},{name:"AC1.50",value:3},{name:"AC2.20",value:4},{name:"AC2.10",value:5},{name:"AC2.21",value:6},{name:"AC2.22",value:7},{name:"AC1001",value:8},{name:"AC1002",value:9},{name:"AC1003",value:10},{name:"AC1004",value:11},{name:"AC1005",value:12},{name:"AC1006",value:13},{name:"AC1007",value:14},{name:"AC1008",value:15},{name:"AC1009",value:16},{name:"AC1010",value:17},{name:"AC1011",value:18},{name:"AC1012",value:19},{name:"AC1013",value:20},{name:"AC1014",value:21},{name:"AC1500",value:22},{name:"AC1015",value:23},{name:"AC1800a",value:24},{name:"AC1018",value:25},{name:"AC2100a",value:26},{name:"AC1021",value:27},{name:"AC2400a",value:28},{name:"AC1024",value:29},{name:"AC1027",value:31},{name:"AC3200a",value:32},{name:"AC1032",value:33}];class ve{constructor(e){if(typeof e=="string"){const t=fa.find(i=>i.name===e);if(!t)throw new Error(`Unknown DWG version name: ${e}`);this.name=t.name,this.value=t.value;return}if(typeof e=="number"){const t=fa.find(i=>i.value===e);if(!t)throw new Error(`Unknown DWG version value: ${e}`);this.name=t.name,this.value=t.value;return}throw new Error("Invalid constructor argument for AcDbDwgVersion")}}class Ga{constructor(e={}){this._database=e.database,this._precision=Math.max(0,Math.min(16,e.precision??16)),this._version=e.version instanceof ve?e.version:e.version!=null?new ve(e.version):void 0,this._lines=[],this._handleMap=new Map,this._nextHandle=1}get database(){return this._database}set database(e){this._database=e}get precision(){return this._precision}setPrecision(e){return this._precision=Math.max(0,Math.min(16,e)),this}get version(){return this._version}get nextHandle(){return this._nextHandle}setVersion(e){return this._version=e instanceof ve?e:new ve(e),this}toString(){return this._lines.join(`
2
2
  `)+`
3
- `}registerHandle(t){return this._handleMap.has(t)||(/^[0-9A-F]+$/i.test(t)?this._handleMap.set(t,t.toUpperCase()):(this._handleMap.set(t,this._nextHandle.toString(16).toUpperCase()),this._nextHandle+=1)),this._handleMap.get(t)}resolveHandle(t){if(t)return this.registerHandle(t)}writeGroup(t,e){if(e==null)return this;this._lines.push(String(Math.trunc(t)));const s=this.formatValue(e);return this._lines.push(s===""?"0":s),this}writeStart(t){return this.writeString(0,t)}writeSubclassMarker(t){return this.writeString(100,t)}writeString(t,e){return!e&&e!==""?this:this.writeGroup(t,e)}writeInt8(t,e){return e==null?this:this.writeGroup(t,Math.trunc(e))}writeInt16(t,e){return e==null?this:this.writeGroup(t,Math.trunc(e))}writeInt32(t,e){return e==null?this:this.writeGroup(t,Math.trunc(e))}writeInt64(t,e){return e==null?this:this.writeGroup(t,Math.trunc(e))}writeUInt16(t,e){return e==null?this:this.writeGroup(t,Math.max(0,e))}writeUInt32(t,e){return e==null?this:this.writeGroup(t,Math.max(0,e))}writeBoolean(t,e){return e==null?this:this.writeGroup(t,e?1:0)}writeBool(t,e){return this.writeBoolean(t,e)}writeDouble(t,e){return e==null||!Number.isFinite(e)?this:this.writeGroup(t,e)}writeAngle(t,e){return e==null||!Number.isFinite(e)?this:this.writeDouble(t,e*180/Math.PI)}writeHandle(t,e){const s=this.resolveHandle(e);return s?this.writeString(t,s):this}writeObjectId(t,e){return this.writeHandle(t,e)}writePoint2d(t,e){return e?(this.writeDouble(t,e.x),this.writeDouble(t+10,e.y),this):this}writePoint3d(t,e){return e?(this.writeDouble(t,e.x),this.writeDouble(t+10,e.y),this.writeDouble(t+20,e.z??0),this):this}writeVector3d(t,e){return e?(this.writeDouble(t,e.x),this.writeDouble(t+10,e.y),this.writeDouble(t+20,e.z??0),this):this}writeCmColor(t,e=62,s=420){if(!t)return this;const n=t.colorIndex;n!=null&&this.writeInt16(e,n);const r=t.RGB;return r!=null&&t.colorIndex==null&&this.writeInt32(s,r),this}writeTransparency(t,e=440){return t?this.writeInt32(e,t.serialize()):this}writeResultBuffer(t){if(!t)return this;for(const e of t)this.writeGroup(e.code,e.value);return this}startSection(t){return this.writeStart("SECTION"),this.writeString(2,t),this}endSection(){return this.writeStart("ENDSEC"),this}startTable(t){return this.writeStart("TABLE"),this.writeString(2,t),this}endTable(){return this.writeStart("ENDTAB"),this}formatValue(t){if(typeof t=="string")return this.sanitizeStringForDxfLine(t);if(typeof t=="boolean")return t?"1":"0";if(typeof t=="number"){if(!Number.isFinite(t))return"0";if(Number.isInteger(t))return String(t);const s=t.toFixed(this._precision).replace(/\.?0+$/,"");return s===""||s==="-"?"0":s}return String(t)}sanitizeStringForDxfLine(t){return t.replace(/\r\n|\r|\n/g," ").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,"")}}function Qh(i,t){for(var e=0;e<t.length;e++){const s=t[e];if(typeof s!="string"&&!Array.isArray(s)){for(const n in s)if(n!=="default"&&!(n in i)){const r=Object.getOwnPropertyDescriptor(s,n);r&&Object.defineProperty(i,n,r.get?r:{enumerable:!0,get:()=>s[n]})}}}return Object.freeze(Object.defineProperty(i,Symbol.toStringTag,{value:"Module"}))}var P=(i=>(i[i.ByColor=1]="ByColor",i[i.ByACI=2]="ByACI",i[i.ByLayer=3]="ByLayer",i[i.ByBlock=4]="ByBlock",i[i.None=0]="None",i))(P||{});const wo={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},xn=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0];let xe=class{static getColorByIndex(t){return xn[t]}static getIndexByColor(t){const e=xn.length-1;for(let s=1;s<e;++s)if(xn[s]===t)return s}static getColorByName(t){return wo[t.toLowerCase()]}static getNameByColor(t){for(const[e,s]of Object.entries(wo))if(s===t)return e}static getNameByIndex(t){const e=this.getColorByIndex(t);return this.getNameByColor(e)}},j=class le{constructor(t=P.ByLayer,e){this._colorMethod=t,this._colorMethod==P.ByColor&&e==null?this._value=16777215:this._colorMethod==P.ByACI?e==null?this._value=8:e===0?this._colorMethod=P.ByBlock:e===256?this._colorMethod=P.ByLayer:this._value=Math.max(0,Math.min(e,256)):this._value=e}get colorMethod(){return this._colorMethod}set colorMethod(t){this._colorMethod=t}get red(){const t=this.RGB;return t!=null?t>>16&255:void 0}get green(){const t=this.RGB;return t!=null?t>>8&255:void 0}get blue(){const t=this.RGB;return t!=null?t&255:void 0}get RGB(){switch(this._colorMethod){case P.ByColor:case P.ByBlock:case P.ByLayer:return this._value;case P.ByACI:return this._value?xe.getColorByIndex(this._value):this._value;default:return}}setRGB(t,e,s){const n=Math.max(0,Math.min(255,Math.round(t))),r=Math.max(0,Math.min(255,Math.round(e))),o=Math.max(0,Math.min(255,Math.round(s)));return this._value=n<<16|r<<8|o,this._colorMethod=P.ByColor,this}setRGBValue(t){return t==null||!Number.isFinite(t)?this:(this._value=t&16777215,this._colorMethod=P.ByColor,this)}setRGBFromCss(t){if(!t)return this;const e=t.trim().toLowerCase();if(e.startsWith("#")){let r=0,o=0,a=0;if(e.length===7)r=parseInt(e.substr(1,2),16),o=parseInt(e.substr(3,2),16),a=parseInt(e.substr(5,2),16);else if(e.length===4)r=parseInt(e[1]+e[1],16),o=parseInt(e[2]+e[2],16),a=parseInt(e[3]+e[3],16);else return this;return this.setRGB(r,o,a)}const s=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(s){const r=parseInt(s[1],10),o=parseInt(s[2],10),a=parseInt(s[3],10);return this.setRGB(r,o,a)}const n=xe.getColorByName(t);return n!==void 0?this.setRGBValue(n):this}setScalar(t){return this.setRGB(t,t,t)}get hexColor(){const t=this.RGB;return t==null?void 0:"0x"+t.toString(16).padStart(6,"0").toUpperCase()}get cssColor(){const t=this.RGB;if(t!=null)return`rgb(${t>>16&255},${t>>8&255},${t&255})`}cssColorAlpha(t){const e=this.RGB;if(e!=null)return`rgba(${e>>16&255},${e>>8&255},${e&255},${t})`}get colorIndex(){return this._colorMethod===P.ByACI?this._value:this._colorMethod===P.ByLayer?256:this._colorMethod===P.ByBlock?0:void 0}set colorIndex(t){if(t==null)return;const e=Math.max(0,Math.min(256,Math.round(t)));e===0?(this._colorMethod=P.ByBlock,this._value=void 0):e===256?(this._colorMethod=P.ByLayer,this._value=void 0):(this._colorMethod=P.ByACI,this._value=e)}get isByColor(){return this._colorMethod===P.ByColor}get isByACI(){return this._colorMethod===P.ByACI}get isForeground(){return this._colorMethod===P.ByACI&&this._value===7}setForeground(){return this._colorMethod=P.ByACI,this._value=7,this}get isByLayer(){return this._colorMethod===P.ByLayer}setByLayer(t){return this._colorMethod=P.ByLayer,t==null?this._value=256:this._value=t,this}get isByBlock(){return this._colorMethod===P.ByBlock}setByBlock(t){return this._colorMethod=P.ByBlock,t==null?this._value=0:this._value=t,this}get colorName(){switch(this._colorMethod){case P.ByLayer:return"ByLayer";case P.ByBlock:return"ByBlock";case P.ByColor:return this._value?xe.getNameByColor(this._value):"";case P.ByACI:return this._value?xe.getNameByIndex(this._value):"";default:return}}set colorName(t){if(!t)return;const e=xe.getColorByName(t);e!==void 0&&(this._value=e,this._colorMethod=P.ByColor)}clone(){const t=new le;return t._colorMethod=this._colorMethod,t._value=this._value,t}copy(t){return this._colorMethod=t._colorMethod,this._value=t._value,this}equals(t){return this._colorMethod===t._colorMethod&&this._value===t._value}toString(){switch(this._colorMethod){case P.ByLayer:return"ByLayer";case P.ByBlock:return"ByBlock";case P.ByACI:return this._value!==void 0?String(this._value):"";case P.ByColor:return this._value?`${this.red},${this.green},${this.blue}`:"";default:return""}}static fromString(t){if(!t)return;const e=t.trim();if(/^bylayer$/i.test(e))return new le(P.ByLayer);if(/^byblock$/i.test(e))return new le(P.ByBlock);const s=e.match(/^rgb\s*:\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})$/i);if(s){const r=Number(s[1]),o=Number(s[2]),a=Number(s[3]),h=new le(P.ByColor);return h.setRGB(r,o,a),h}if(/^\d{1,3},\d{1,3},\d{1,3}$/.test(e)){const[r,o,a]=e.split(",").map(Number),h=new le(P.ByColor);return h.setRGB(r,o,a),h}if(/^\d+$/.test(e)){const r=parseInt(e,10);return new le(P.ByACI,r)}if(/^book\$/i.test(e)){const r=e.substring(e.indexOf("$")+1),o=xe.getColorByName(r);return o!=null?new le(P.ByColor,o):void 0}const n=xe.getColorByName(e);if(n!=null)return new le(P.ByColor,n)}};class Jh{constructor(t=P.ByColor,e=0){this._colorMethod=t,this._value=e}get colorMethd(){return this._colorMethod}get red(){return this._value>>16&255}set red(t){this._colorMethod=P.ByColor,this._value=this._value&65535|(t&255)<<16}get green(){return this._value>>8&255}set green(t){this._colorMethod=P.ByColor,this._value=this._value&16711935|(t&255)<<8}get blue(){return this._value&255}set blue(t){this._colorMethod=P.ByColor,this._value=this._value&16776960|t&255}setRGB(t,e,s){this._colorMethod=P.ByColor,this._value=(t&255)<<16|(e&255)<<8|s&255}get colorIndex(){return this._value}set colorIndex(t){this._colorMethod=P.ByACI,this._value=t}get layerIndex(){return this._value}set layerIndex(t){this._colorMethod=P.ByLayer,this._value=t}isByColor(){return this._colorMethod===P.ByColor}isByLayer(){return this._colorMethod===P.ByLayer}isByBlock(){return this._colorMethod===P.ByBlock}isByACI(){return this._colorMethod===P.ByACI}isNone(){return this._colorMethod===P.None}get rawValue(){return this._value}set rawValue(t){this._value=t}}const wt={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")},get ZERO_DIVISION(){return new Error("Zero division")},get UNRESOLVED_BOUNDARY_CONFLICT(){return new Error("Unresolved boundary conflict in boolean operation")},get INFINITE_LOOP(){return new Error("Infinite loop")},get CANNOT_INVOKE_ABSTRACT_METHOD(){return new Error("Abstract method cannot be invoked")},get OPERATION_IS_NOT_SUPPORTED(){return new Error("Operation is not supported")},get NOT_IMPLEMENTED(){return new Error("Not implemented yet")}};let tc=class{constructor(){this._listeners={}}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const s=this._listeners;s[t]===void 0&&(s[t]=[]),s[t].indexOf(e)===-1&&s[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const s=this._listeners;return s[t]!==void 0&&s[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const s=this._listeners[t];if(s!==void 0){const n=s.indexOf(e);n!==-1&&s.splice(n,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const e=this._listeners[t.type];if(e!==void 0){t.target=this;const s=e.slice(0);for(let n=0,r=s.length;n<r;n++)s[n].call(this,t)}}},Q=class{constructor(){this.listeners=[]}addEventListener(t){this.listeners.push(t)}removeEventListener(t){this.listeners=this.listeners.filter(e=>e!==t)}replaceEventListener(t){this.removeEventListener(t),this.addEventListener(t)}dispatch(t,...e){for(const s of this.listeners)s.call(null,t,...e)}};function Ms(i){return i===null||typeof i!="object"?i:Array.isArray(i)?[...i]:{...i}}function Nn(i){if(i===null||typeof i!="object")return i;if(i instanceof Date)return new Date(i.getTime());if(i instanceof RegExp)return new RegExp(i.source,i.flags);if(Array.isArray(i))return i.map(Nn);const t={};for(const e in i)Object.prototype.hasOwnProperty.call(i,e)&&(t[e]=Nn(i[e]));return t}function Qs(i,...t){for(const e of t)if(e)for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&i[s]===void 0&&(i[s]=e[s]);return i}function Go(i,t){return i!=null&&Object.prototype.hasOwnProperty.call(i,t)}function Uo(i){return i==null?!0:Array.isArray(i)||typeof i=="string"?i.length===0:i instanceof Map||i instanceof Set?i.size===0:typeof i=="object"?Object.keys(i).length===0:!1}function as(i,t){if(i===t)return!0;if(i==null||t==null)return i===t;if(typeof i!=typeof t)return!1;if(typeof i!="object")return i===t;if(Array.isArray(i)!==Array.isArray(t))return!1;if(Array.isArray(i)){if(i.length!==t.length)return!1;for(let n=0;n<i.length;n++)if(!as(i[n],t[n]))return!1;return!0}const e=Object.keys(i),s=Object.keys(t);if(e.length!==s.length)return!1;for(const n of e)if(!Object.prototype.hasOwnProperty.call(t,n)||!as(i[n],t[n]))return!1;return!0}var ec=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function sc(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Yo={exports:{}};(function(i){(function(t,e){i.exports?i.exports=e():t.log=e()})(ec,function(){var t=function(){},e="undefined",s=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"],r={},o=null;function a(y,b){var x=y[b];if(typeof x.bind=="function")return x.bind(y);try{return Function.prototype.bind.call(x,y)}catch{return function(){return Function.prototype.apply.apply(x,[y,arguments])}}}function h(){console.log&&(console.log.apply||Function.prototype.apply.apply(console.log,[console,arguments]))}function c(y){return y==="debug"&&(y="log"),typeof console===e?!1:y==="trace"&&s?h:console[y]!==void 0?a(console,y):console.log!==void 0?a(console,"log"):t}function d(){for(var y=this.getLevel(),b=0;b<n.length;b++){var x=n[b];this[x]=b<y?t:this.methodFactory(x,y,this.name)}if(this.log=this.debug,typeof console===e&&y<this.levels.SILENT)return"No console available for logging"}function u(y){return function(){typeof console!==e&&(d.call(this),this[y].apply(this,arguments))}}function p(y,b,x){return c(y)||u.apply(this,arguments)}function g(y,b){var x=this,I,S,L,A="loglevel";typeof y=="string"?A+=":"+y:typeof y=="symbol"&&(A=void 0);function H(F){var Y=(n[F]||"silent").toUpperCase();if(!(typeof window===e||!A)){try{window.localStorage[A]=Y;return}catch{}try{window.document.cookie=encodeURIComponent(A)+"="+Y+";"}catch{}}}function M(){var F;if(!(typeof window===e||!A)){try{F=window.localStorage[A]}catch{}if(typeof F===e)try{var Y=window.document.cookie,ke=encodeURIComponent(A),ve=Y.indexOf(ke+"=");ve!==-1&&(F=/^([^;]+)/.exec(Y.slice(ve+ke.length+1))[1])}catch{}return x.levels[F]===void 0&&(F=void 0),F}}function X(){if(!(typeof window===e||!A)){try{window.localStorage.removeItem(A)}catch{}try{window.document.cookie=encodeURIComponent(A)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function R(F){var Y=F;if(typeof Y=="string"&&x.levels[Y.toUpperCase()]!==void 0&&(Y=x.levels[Y.toUpperCase()]),typeof Y=="number"&&Y>=0&&Y<=x.levels.SILENT)return Y;throw new TypeError("log.setLevel() called with invalid level: "+F)}x.name=y,x.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},x.methodFactory=b||p,x.getLevel=function(){return L??S??I},x.setLevel=function(F,Y){return L=R(F),Y!==!1&&H(L),d.call(x)},x.setDefaultLevel=function(F){S=R(F),M()||x.setLevel(F,!1)},x.resetLevel=function(){L=null,X(),d.call(x)},x.enableAll=function(F){x.setLevel(x.levels.TRACE,F)},x.disableAll=function(F){x.setLevel(x.levels.SILENT,F)},x.rebuild=function(){if(o!==x&&(I=R(o.getLevel())),d.call(x),o===x)for(var F in r)r[F].rebuild()},I=R(o?o.getLevel():"WARN");var et=M();et!=null&&(L=R(et)),d.call(x)}o=new g,o.getLogger=function(y){if(typeof y!="symbol"&&typeof y!="string"||y==="")throw new TypeError("You must supply a name when creating a logger.");var b=r[y];return b||(b=r[y]=new g(y,o.methodFactory)),b};var m=typeof window!==e?window.log:void 0;return o.noConflict=function(){return typeof window!==e&&window.log===o&&(window.log=m),o},o.getLoggers=function(){return r},o.default=o,o})})(Yo);var Xo=Yo.exports;const ic=sc(Xo),nc=Qh({__proto__:null,default:ic},[Xo]),rc=!0,Cs=nc;Cs.setLevel("debug");const oc=i=>{try{Cs.setLevel(i)}catch(t){Cs.setLevel("error"),Cs.error(t)}};let $o=class qo{constructor(t,e){this.events={attrChanged:new Q,modelChanged:new Q},this._changing=!1,this._previousAttributes={},this._pending=!1;const s=t||{};e&&Qs(s,e),this.attributes=s,this.changed={}}get(t){return this.attributes[t]}set(t,e,s){if(t==null)return this;let n;typeof t=="object"?(n=t,s=e):(n={},n[t]=e),s||(s={});const r=s.unset,o=s.silent,a=[],h=this._changing;this._changing=!0,h||(this._previousAttributes=Ms(this.attributes),this.changed={});const c=this.attributes,d=this.changed,u=this._previousAttributes;for(const p in n)e=n[p],as(c[p],e)||a.push(p),as(u[p],e)?delete d[p]:d[p]=e,r?delete c[p]:c[p]=e;if(!o){a.length&&(this._pending=s);for(let p=0;p<a.length;p++)this.events.attrChanged.dispatch({object:this,attrName:a[p],attrValue:c[a[p]],options:s})}if(h)return this;if(!o)for(;this._pending;)s=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:s});return this._pending=!1,this._changing=!1,this}has(t){return this.get(t)!=null}hasChanged(t){return t==null?!Uo(this.changed):Go(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?Ms(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,s={};for(const n in t){const r=t[n];as(e[n],r)||(s[n]=r)}return s}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return Ms(this._previousAttributes)}clone(){const t=Ms(this.attributes);return new qo(t)}},Jn=class ks{constructor(){this.entries=new Map}static getInstance(){return ks.instance||(ks.instance=new ks),ks.instance}collect(t){this.entries.set(t.name,t)}printAll(){for(const[t,e]of this.entries);}clear(){this.entries.clear()}getAll(){return Array.from(this.entries.values())}getEntry(t){return this.entries.get(t)}remove(t){return this.entries.delete(t)}};class ac{static formatBytes(t,e=2){if(t===0)return"0 B";const s=1024,n=Math.max(0,e),r=["B","KB","MB","GB","TB"],o=Math.floor(Math.log(t)/Math.log(s)),a=t/Math.pow(s,o);return`${parseFloat(a.toFixed(n))} ${r[o]}`}}var yt=(i=>(i[i.ByLayer=0]="ByLayer",i[i.ByBlock=1]="ByBlock",i[i.ByAlpha=2]="ByAlpha",i[i.ErrorValue=3]="ErrorValue",i))(yt||{});let gn=class zt{constructor(t){t!==void 0?(this._method=yt.ByAlpha,this._alpha=zt.clampAlpha(t)):(this._method=yt.ByLayer,this._alpha=255)}get method(){return this._method}set method(t){this._method=t}get alpha(){return this._alpha}set alpha(t){this._alpha=zt.clampAlpha(t),this._method=yt.ByAlpha}get percentage(){if(this._method===yt.ByAlpha)return Math.round((1-this._alpha/255)*100)}set percentage(t){const e=Math.max(0,Math.min(100,t)),s=Math.round(255*(1-e/100));this.alpha=s}static clampAlpha(t){return Math.max(0,Math.min(255,Math.floor(t)))}get isByAlpha(){return this._method===yt.ByAlpha}get isByBlock(){return this._method===yt.ByBlock}get isByLayer(){return this._method===yt.ByLayer}get isClear(){return this.isByAlpha&&this._alpha===0}get isSolid(){return this.isByAlpha&&this._alpha===255}get isInvalid(){return this._method===yt.ErrorValue}serialize(){return this._method<<24|this._alpha}clone(){const t=new zt;return t._method=this._method,t._alpha=this._alpha,t}equals(t){return this._method===t._method&&this._alpha===t._alpha}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this._alpha.toString()}static fromString(t){const e=t.trim();if(/^bylayer$/i.test(e)){const r=new zt;return r._method=yt.ByLayer,r}if(/^byblock$/i.test(e)){const r=new zt;return r._method=yt.ByBlock,r}const s=Number(e);if(Number.isInteger(s)&&s>=0&&s<=255)return new zt(s);const n=new zt;return n._method=yt.ErrorValue,n}static deserialize(t){const e=t>>>24&255,s=t&255,n=Object.values(yt)[e]??yt.ErrorValue,r=new zt;return r._method=n,r._alpha=zt.clampAlpha(s),r}};class Zo{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}class Ko{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>!1}scheduleTask(t){return new Promise((e,s)=>{const n=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(n):setTimeout(n,0)})}addTask(t){this.tasks.push(t)}setProgressCallback(t){this.onProgress=t}setCompleteCallback(t){this.onComplete=t}setErrorCallback(t){this.onError=t}async run(t){const e=this.tasks.length;let s=t;for(let n=0;n<e;n++){const r=this.tasks[n];try{s=await this.scheduleTask(async()=>{const o=await r.run(s);return this.onProgress((n+1)/e,r),o})}catch(o){if(this.onError({error:o,taskIndex:n,task:r}))return Promise.reject(o)}}this.onComplete(s)}}let Qo=class{constructor(t,e,s){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=s}itemStart(t){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(t,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(t){this.itemsLoaded++,this.onProgress!==void 0&&this.onProgress(t,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,this.onLoad!==void 0&&this.onLoad())}itemError(t){this.onError!==void 0&&this.onError(t)}resolveURL(t){return this.urlModifier?this.urlModifier(t):t}setURLModifier(t){return this.urlModifier=t,this}addHandler(t,e){return this.handlers.push(t,e),this}removeHandler(t){const e=this.handlers.indexOf(t);return e!==-1&&this.handlers.splice(e,2),this}getHandler(t){for(let e=0,s=this.handlers.length;e<s;e+=2){const n=this.handlers[e],r=this.handlers[e+1];if(n.global&&(n.lastIndex=0),n.test(t))return r}return null}};const Jo=new Qo;class lc{constructor(t){this.manager=t!==void 0?t:Jo,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((s,n)=>{this.load(t,s,e,n)})}parse(t){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}}var Ke=256,ta=[],bo=256,gi;for(;Ke--;)ta[Ke]=(Ke+256).toString(16).substring(1);function hc(i){var t=0,e=11;if(!gi||Ke+e>bo*2)for(gi="",Ke=0;t<bo;t++)gi+=ta[Math.random()*256|0];return gi.substring(Ke,Ke+++e)}const Ii="TEMP_";let Bn;function ea(i){Bn=i}class Ft{constructor(t,e){if(t=t||{},this._attrs=new $o(t,e),this._xDataMap=new Map,!this._attrs.get("objectId"))try{this._attrs.set("objectId",this.database.generateHandle())}catch{this._attrs.set("objectId",this.generateTemporaryHandle())}}generateTemporaryHandle(){return Ii+hc()}get attrs(){return this._attrs}getAttr(t){const e=this._attrs.get(t);if(e===void 0)throw new Error(`[AcDbObject] Attribute name '${t}' does't exist in this object!`);return e}getAttrWithoutException(t){return this._attrs.get(t)}setAttr(t,e){this._attrs.set(t,e)}get objectId(){return this.getAttr("objectId")}set objectId(t){this._attrs.set("objectId",t),t&&!t.startsWith(Ii)&&this.database.updateMaxHandle(t)}get isTemp(){const t=this.getAttrWithoutException("objectId");return!!t&&t.startsWith(Ii)}get ownerId(){return this.getAttr("ownerId")}set ownerId(t){this._attrs.set("ownerId",t)}get extensionDictionary(){return this.getAttrWithoutException("extensionDictionary")}set extensionDictionary(t){this._attrs.set("extensionDictionary",t)}get database(){if(this._database)return this._database;if(Bn)return Bn().workingDatabase;throw new Error("The current working database must be set before using it!")}set database(t){this._database=t}getXData(t){return this._xDataMap.get(t)}setXData(t){for(const e of t)e.code===Qn.ExtendedDataRegAppName&&this._xDataMap.set(e.value,t)}removeXData(t){this._xDataMap.delete(t)}createExtensionDictionary(){}close(){}clone(){const t=Object.create(Object.getPrototypeOf(this)),e=this,s=t;for(const n of Object.keys(e))n!=="_database"&&(s[n]=this.cloneValue(e[n]));return t.objectId=this.generateTemporaryHandle(),t}cloneValue(t){if(t==null||typeof t!="object")return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t.source,t.flags);if(Array.isArray(t))return t.map(n=>this.cloneValue(n));if(t instanceof Map){const n=new Map;for(const[r,o]of t.entries())n.set(this.cloneValue(r),this.cloneValue(o));return n}if(t instanceof Set){const n=new Set;for(const r of t.values())n.add(this.cloneValue(r));return n}if(ArrayBuffer.isView(t)){if(t instanceof DataView)return new DataView(t.buffer.slice(0));const n=t.constructor;return new n(t)}if(t instanceof ArrayBuffer)return t.slice(0);if("clone"in t&&typeof t.clone=="function")return t.clone();const e=Object.create(Object.getPrototypeOf(t)),s=t;for(const n of Object.keys(s))e[n]=this.cloneValue(s[n]);return e}dxfOut(...t){const[e,s=!1]=t;if(e.writeHandle(5,this.objectId),e.writeObjectId(330,this.ownerId),e.writeObjectId(360,this.extensionDictionary),this.dxfOutFields(e),s)for(const n of this._xDataMap.values())e.writeResultBuffer(n);return this}dxfOutFields(t){return this}}let Rn;function sa(i){Rn=i}function tr(){return Oi.instance}const cn=class cn{constructor(){this._workingDatabase=null}get workingDatabase(){if(this._workingDatabase==null)throw new Error("The current working database must be set before using it!");return this._workingDatabase}set workingDatabase(t){this._workingDatabase=t}get layoutManager(){if(!this._layoutManager){if(!Rn)throw new Error("The layout manager factory must be registered before using it!");this._layoutManager=Rn()}return this._layoutManager}};cn.instance=new cn;let Oi=cn;ea(tr);var ia=(i=>(i.kForRead="kForRead",i.kForWrite="kForWrite",i))(ia||{});class er{constructor(t){if(this._values=[],t)for(const e of t)this._values.push({...e})}get length(){return this._values.length}at(t){return this._values[t]}add(t){this._values.push(t)}addRange(t){for(const e of t)this._values.push(e)}clear(){this._values.length=0}toArray(){return this._values.map(t=>({...t}))}clone(){return new er(this._values)}[Symbol.iterator](){return this._values[Symbol.iterator]()}}class sr{constructor(t,e,s){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=s,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(t){this._minimumChunkSize=t,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let t=this._count/this._numerOfChunk;t<this._minimumChunkSize&&(t=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=t<1?this._count:Math.floor(t)}scheduleTask(t){return new Promise((e,s)=>{const n=()=>{Promise.resolve(t()).then(e).catch(s)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(n):setTimeout(n,0)})}async processChunk(t,e){if(this._count<=0){await(e==null?void 0:e());return}let s=0;const n=async()=>{const r=s,o=Math.min(s+this._chunkSize,this._count);await t(r,o),s=o,s<this._count&&await this.scheduleTask(n)};await n(),await(e==null?void 0:e())}}var Os=(i=>(i.DXF="dxf",i.DWG="dwg",i))(Os||{});class Vt{constructor(){this.events={registered:new Q,unregistered:new Q},this._converters=new Map,this.register("dxf",new Zh)}static createInstance(){return Vt._instance==null&&(Vt._instance=new Vt),this._instance}static get instance(){return Vt._instance||(Vt._instance=new Vt),Vt._instance}get fileTypes(){return this._converters.keys()}register(t,e){this._converters.set(t,e),this.events.registered.dispatch({fileType:t,converter:e})}get(t){return this._converters.get(t)}unregister(t){const e=this._converters.get(t);e&&(this._converters.delete(t),this.events.unregistered.dispatch({fileType:t,converter:e}))}}var ir=(i=>(i[i.DecimalDegrees=0]="DecimalDegrees",i[i.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",i[i.Gradians=2]="Gradians",i[i.Radians=3]="Radians",i[i.SurveyorsUnits=4]="SurveyorsUnits",i))(ir||{});class es{static get instance(){return this._instance||(this._instance=new es),this._instance}constructor(){this._blocks=new Map}createKey(t,e){return`${t}_${e}`}set(t,e){return e=e.fastDeepClone(),this._blocks.set(t,e),e}get(t){let e=this._blocks.get(t);return e&&(e=e.fastDeepClone()),e}has(t){return this._blocks.has(t)}clear(){this._blocks.clear()}draw(t,e,s,n=[],r=!0,o,a){const h=[];if(e!=null){const c=this.createKey(e.name,s);let d;if(this.has(c))d=this.get(c);else{const u=e.newIterator();for(const p of u)p.color.isByBlock&&s?(fo.copy(p.color),p.color.setRGBValue(s),this.addEntity(p,h,t),p.color.copy(fo)):this.addEntity(p,h,t);d=t.group(h),d&&r&&J.name&&!J.name.startsWith("*U")&&this.set(c,d)}return d&&o&&(d.applyMatrix(o),a&&(a.x!=0||a.y!=0||a.z!=1)&&(o.setFromExtrusionDirection(a),d.applyMatrix(o))),d&&n&&n.length>0&&(d.bakeTransformToChildren(),n.forEach(u=>d.addChild(u))),d}else return t.group(h)}addEntity(t,e,s){const n=t.worldDraw(s);n&&(this.attachEntityInfo(n,t),e.push(n))}attachEntityInfo(t,e){t.objectId=e.objectId,t.ownerId=e.ownerId,t.layerName=e.layer,t.visible=e.visibility}}const fo=new j;var nr=(i=>(i[i.UTF8=0]="UTF8",i[i.US_ASCII=1]="US_ASCII",i[i.ISO_8859_1=2]="ISO_8859_1",i[i.ISO_8859_2=3]="ISO_8859_2",i[i.ISO_8859_3=4]="ISO_8859_3",i[i.ISO_8859_4=5]="ISO_8859_4",i[i.ISO_8859_5=6]="ISO_8859_5",i[i.ISO_8859_6=7]="ISO_8859_6",i[i.ISO_8859_7=8]="ISO_8859_7",i[i.ISO_8859_8=9]="ISO_8859_8",i[i.ISO_8859_9=10]="ISO_8859_9",i[i.CP437=11]="CP437",i[i.CP850=12]="CP850",i[i.CP852=13]="CP852",i[i.CP855=14]="CP855",i[i.CP857=15]="CP857",i[i.CP860=16]="CP860",i[i.CP861=17]="CP861",i[i.CP863=18]="CP863",i[i.CP864=19]="CP864",i[i.CP865=20]="CP865",i[i.CP869=21]="CP869",i[i.CP932=22]="CP932",i[i.MACINTOSH=23]="MACINTOSH",i[i.BIG5=24]="BIG5",i[i.CP949=25]="CP949",i[i.JOHAB=26]="JOHAB",i[i.CP866=27]="CP866",i[i.ANSI_1250=28]="ANSI_1250",i[i.ANSI_1251=29]="ANSI_1251",i[i.ANSI_1252=30]="ANSI_1252",i[i.GB2312=31]="GB2312",i[i.ANSI_1253=32]="ANSI_1253",i[i.ANSI_1254=33]="ANSI_1254",i[i.ANSI_1255=34]="ANSI_1255",i[i.ANSI_1256=35]="ANSI_1256",i[i.ANSI_1257=36]="ANSI_1257",i[i.ANSI_874=37]="ANSI_874",i[i.ANSI_932=38]="ANSI_932",i[i.ANSI_936=39]="ANSI_936",i[i.ANSI_949=40]="ANSI_949",i[i.ANSI_950=41]="ANSI_950",i[i.ANSI_1361=42]="ANSI_1361",i[i.UTF16=43]="UTF16",i[i.ANSI_1258=44]="ANSI_1258",i[i.UNDEFINED=255]="UNDEFINED",i))(nr||{});const cc=["utf-8","utf-8","iso-8859-1","iso-8859-2","iso-8859-3","iso-8859-4","iso-8859-5","iso-8859-6","iso-8859-7","iso-8859-8","iso-8859-9","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","shift-jis","macintosh","big5","utf-8","utf-8","ibm866","windows-1250","windows-1251","windows-1252","gbk","windows-1253","windows-1254","windows-1255","windows-1256","windows-1257","windows-874","shift-jis","gbk","euc-kr","big5","utf-8","utf-16le","windows-1258"],na=i=>cc[i],Se="Continuous",Z="Standard",ce="Standard",de="Standard",dt="ByLayer",fe="ByBlock",Fn="mlightcad",zn="ACAD",ct=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let So=1234567;const rr=Math.PI/180,or=180/Math.PI;function ra(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,s=Math.random()*4294967295|0;return(ct[i&255]+ct[i>>8&255]+ct[i>>16&255]+ct[i>>24&255]+"-"+ct[t&255]+ct[t>>8&255]+"-"+ct[t>>16&15|64]+ct[t>>24&255]+"-"+ct[e&63|128]+ct[e>>8&255]+"-"+ct[e>>16&255]+ct[e>>24&255]+ct[s&255]+ct[s>>8&255]+ct[s>>16&255]+ct[s>>24&255]).toLowerCase()}function he(i,t,e){return Math.max(t,Math.min(e,i))}function ar(i,t){return(i%t+t)%t}function oa(i,t,e,s,n){return s+(i-t)*(n-s)/(e-t)}function aa(i,t,e){return i!==t?(e-i)/(t-i):0}function lr(i,t,e){return(1-e)*i+e*t}function la(i,t,e,s){return lr(i,t,1-Math.exp(-e*s))}function ha(i,t=1){return t-Math.abs(ar(i,t*2)-t)}function ca(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*(3-2*i))}function da(i,t,e){return i<=t?0:i>=e?1:(i=(i-t)/(e-t),i*i*i*(i*(i*6-15)+10))}function ua(i,t){return i+Math.floor(Math.random()*(t-i+1))}function ga(i,t){return i+Math.random()*(t-i)}function pa(i){return i*(.5-Math.random())}function ma(i){i!==void 0&&(So=i);let t=So+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function ya(i){return i*rr}function _a(i){return i*or}function xa(i){return(i&i-1)===0&&i!==0}function wa(i){return Math.pow(2,Math.ceil(Math.log(i)/Math.LN2))}function ba(i){return Math.pow(2,Math.floor(Math.log(i)/Math.LN2))}function Ns(i){const t=Math.PI*2;return(i%t+t)%t}function fa(i,t,e){return i>t&&i<e||i>e&&i<t}function Sa(i,t,e,s=!1){return i=Ns(i),t=Ns(t),e=Ns(e),s?t>e?i<=t&&i>=e:i<=t||i>=e:t<e?i>=t&&i<=e:i>=t||i<=e}function hr(i){return i=Math.abs(i),i<1?0:Math.ceil(Math.log10(Math.abs(i)+1))}function Ia(i,t=1e-7){const e=hr(i);return Math.max(Math.pow(10,e)*t,t)}const k={DEG2RAD:rr,RAD2DEG:or,generateUUID:ra,clamp:he,euclideanModulo:ar,mapLinear:oa,inverseLerp:aa,lerp:lr,damp:la,pingpong:ha,smoothstep:ca,smootherstep:da,randInt:ua,randFloat:ga,randFloatSpread:pa,seededRandom:ma,degToRad:ya,radToDeg:_a,isPowerOfTwo:xa,ceilPowerOfTwo:wa,floorPowerOfTwo:ba,normalizeAngle:Ns,isBetween:fa,isBetweenAngle:Sa,intPartLength:hr,relativeEps:Ia},Vn=class Aa{constructor(t,e){this.x=0,this.y=0;const s=+(t!==void 0)+ +(e!==void 0);if(s!==0){if(s===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(s===1){const{x:n,y:r}=t;this.x=n,this.y=r;return}if(s===2){this.x=t,this.y=e;return}throw wt.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}}clone(){return new Aa(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix2d(t){const e=this.x,s=this.y,n=t.elements;return this.x=n[0]*e+n[3]*s+n[6],this.y=n[1]*e+n[4]*s+n[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y;return e*e+s*s}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}rotateAround(t,e){const s=Math.cos(e),n=Math.sin(e),r=this.x-t.x,o=this.y-t.y;return this.x=r*s-o*n+t.x,this.y=r*n+o*s+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(k.relativeEps(this.x,t),k.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};Vn.EMPTY=Object.freeze(new Vn(0,0));let $=Vn;const Dn=class Pa{constructor(t,e,s,n,r,o,a,h,c){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&s!=null&&n!=null&&r!=null&&o!=null&&a!=null&&h!=null&&c!=null&&this.set(t,e,s,n,r,o,a,h,c)}set(t,e,s,n,r,o,a,h,c){const d=this.elements;return d[0]=t,d[1]=n,d[2]=a,d[3]=e,d[4]=r,d[5]=h,d[6]=s,d[7]=o,d[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],this}extractBasis(t,e,s){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),s.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,n=e.elements,r=this.elements,o=s[0],a=s[3],h=s[6],c=s[1],d=s[4],u=s[7],p=s[2],g=s[5],m=s[8],y=n[0],b=n[3],x=n[6],I=n[1],S=n[4],L=n[7],A=n[2],H=n[5],M=n[8];return r[0]=o*y+a*I+h*A,r[3]=o*b+a*S+h*H,r[6]=o*x+a*L+h*M,r[1]=c*y+d*I+u*A,r[4]=c*b+d*S+u*H,r[7]=c*x+d*L+u*M,r[2]=p*y+g*I+m*A,r[5]=p*b+g*S+m*H,r[8]=p*x+g*L+m*M,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[1],n=t[2],r=t[3],o=t[4],a=t[5],h=t[6],c=t[7],d=t[8];return e*o*d-e*a*c-s*r*d+s*a*h+n*r*c-n*o*h}invert(){const t=this.elements,e=t[0],s=t[1],n=t[2],r=t[3],o=t[4],a=t[5],h=t[6],c=t[7],d=t[8],u=d*o-a*c,p=a*h-d*r,g=c*r-o*h,m=e*u+s*p+n*g;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/m;return t[0]=u*y,t[1]=(n*c-d*s)*y,t[2]=(a*s-n*o)*y,t[3]=p*y,t[4]=(d*e-n*h)*y,t[5]=(n*r-a*e)*y,t[6]=g*y,t[7]=(s*h-c*e)*y,t[8]=(o*e-s*r)*y,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t.elements[0]=e[0],t.elements[1]=e[3],t.elements[2]=e[6],t.elements[3]=e[1],t.elements[4]=e[4],t.elements[5]=e[7],t.elements[6]=e[2],t.elements[7]=e[5],t.elements[8]=e[8],this}setUvTransform(t,e,s,n,r,o,a){const h=Math.cos(r),c=Math.sin(r);return this.set(s*h,s*c,-s*(h*o+c*a)+o+t,-n*c,n*h,-n*(-c*o+h*a)+a+e,0,0,1),this}scale(t,e){return this.premultiply(wn.makeScale(t,e)),this}rotate(t){return this.premultiply(wn.makeRotation(-t)),this}translate(t,e){return this.premultiply(wn.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof $?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,s,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,s=t.elements;for(let n=0;n<9;n++)if(e[n]!==s[n])return!1;return!0}fromArray(t,e=0){for(let s=0;s<9;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t}clone(){return new Pa().fromArray(this.elements)}};Dn.IDENTITY=Object.freeze(new Dn);let Js=Dn;const wn=new Js,qe=1e-6,G=2*Math.PI,dc={x:0,y:0},cr={x:0,y:0,z:0};class ti{constructor(){this.equalPointTol=qe,this.equalVectorTol=qe}clone(){const t=new ti;return t.equalPointTol=this.equalPointTol,t.equalVectorTol=this.equalVectorTol,t}equalPoint2d(t,e){return new $(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new _(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=qe){return t<e&&t>-e}static equal(t,e,s=qe){return Math.abs(t-e)<s}static great(t,e,s=qe){return t-e>s}static less(t,e,s=qe){return t-e<s}}const dr=new ti;class ss{constructor(t=0,e=0,s=0,n=1){this._x=t,this._y=e,this._z=s,this._w=n}static slerpFlat(t,e,s,n,r,o,a){let h=s[n+0],c=s[n+1],d=s[n+2],u=s[n+3];const p=r[o+0],g=r[o+1],m=r[o+2],y=r[o+3];if(a===0){t[e+0]=h,t[e+1]=c,t[e+2]=d,t[e+3]=u;return}if(a===1){t[e+0]=p,t[e+1]=g,t[e+2]=m,t[e+3]=y;return}if(u!==y||h!==p||c!==g||d!==m){let b=1-a;const x=h*p+c*g+d*m+u*y,I=x>=0?1:-1,S=1-x*x;if(S>Number.EPSILON){const A=Math.sqrt(S),H=Math.atan2(A,x*I);b=Math.sin(b*H)/A,a=Math.sin(a*H)/A}const L=a*I;if(h=h*b+p*L,c=c*b+g*L,d=d*b+m*L,u=u*b+y*L,b===1-a){const A=1/Math.sqrt(h*h+c*c+d*d+u*u);h*=A,c*=A,d*=A,u*=A}}t[e]=h,t[e+1]=c,t[e+2]=d,t[e+3]=u}static multiplyQuaternionsFlat(t,e,s,n,r,o){const a=s[n],h=s[n+1],c=s[n+2],d=s[n+3],u=r[o],p=r[o+1],g=r[o+2],m=r[o+3];return t[e]=a*m+d*u+h*g-c*p,t[e+1]=h*m+d*p+c*u-a*g,t[e+2]=c*m+d*g+a*p-h*u,t[e+3]=d*m-a*u-h*p-c*g,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,s,n){return this._x=t,this._y=e,this._z=s,this._w=n,this._onChangeCallback(),this}clone(){return new ss(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const s=t.x,n=t.y,r=t.z,o=t.order,a=Math.cos,h=Math.sin,c=a(s/2),d=a(n/2),u=a(r/2),p=h(s/2),g=h(n/2),m=h(r/2);switch(o){case"XYZ":this._x=p*d*u+c*g*m,this._y=c*g*u-p*d*m,this._z=c*d*m+p*g*u,this._w=c*d*u-p*g*m;break;case"YXZ":this._x=p*d*u+c*g*m,this._y=c*g*u-p*d*m,this._z=c*d*m-p*g*u,this._w=c*d*u+p*g*m;break;case"ZXY":this._x=p*d*u-c*g*m,this._y=c*g*u+p*d*m,this._z=c*d*m+p*g*u,this._w=c*d*u-p*g*m;break;case"ZYX":this._x=p*d*u-c*g*m,this._y=c*g*u+p*d*m,this._z=c*d*m-p*g*u,this._w=c*d*u+p*g*m;break;case"YZX":this._x=p*d*u+c*g*m,this._y=c*g*u+p*d*m,this._z=c*d*m-p*g*u,this._w=c*d*u-p*g*m;break;case"XZY":this._x=p*d*u-c*g*m,this._y=c*g*u-p*d*m,this._z=c*d*m+p*g*u,this._w=c*d*u+p*g*m;break}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const s=e/2,n=Math.sin(s);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(s),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,s=e[0],n=e[4],r=e[8],o=e[1],a=e[5],h=e[9],c=e[2],d=e[6],u=e[10],p=s+a+u;if(p>0){const g=.5/Math.sqrt(p+1);this._w=.25/g,this._x=(d-h)*g,this._y=(r-c)*g,this._z=(o-n)*g}else if(s>a&&s>u){const g=2*Math.sqrt(1+s-a-u);this._w=(d-h)/g,this._x=.25*g,this._y=(n+o)/g,this._z=(r+c)/g}else if(a>u){const g=2*Math.sqrt(1+a-s-u);this._w=(r-c)/g,this._x=(n+o)/g,this._y=.25*g,this._z=(h+d)/g}else{const g=2*Math.sqrt(1+u-s-a);this._w=(o-n)/g,this._x=(r+c)/g,this._y=(h+d)/g,this._z=.25*g}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let s=t.dot(e)+1;return s<Number.EPSILON?(s=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=s):(this._x=0,this._y=-t.z,this._z=t.y,this._w=s)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=s),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(he(this.dot(t),-1,1)))}rotateTowards(t,e){const s=this.angleTo(t);if(s===0)return this;const n=Math.min(1,e/s);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const s=t._x,n=t._y,r=t._z,o=t._w,a=e._x,h=e._y,c=e._z,d=e._w;return this._x=s*d+o*a+n*c-r*h,this._y=n*d+o*h+r*a-s*c,this._z=r*d+o*c+s*h-n*a,this._w=o*d-s*a-n*h-r*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const s=this._x,n=this._y,r=this._z,o=this._w;let a=o*t._w+s*t._x+n*t._y+r*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=s,this._y=n,this._z=r,this;const h=1-a*a;if(h<=Number.EPSILON){const g=1-e;return this._w=g*o+e*this._w,this._x=g*s+e*this._x,this._y=g*n+e*this._y,this._z=g*r+e*this._z,this.normalize(),this}const c=Math.sqrt(h),d=Math.atan2(c,a),u=Math.sin((1-e)*d)/c,p=Math.sin(e*d)/c;return this._w=o*u+this._w*p,this._x=s*u+this._x*p,this._y=n*u+this._y*p,this._z=r*u+this._z*p,this._onChangeCallback(),this}slerpQuaternions(t,e,s){return this.copy(t).slerp(e,s)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),s=Math.random(),n=Math.sqrt(1-s),r=Math.sqrt(s);return this.set(n*Math.sin(t),n*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const mt=class Ta{constructor(t,e,s){this.x=0,this.y=0,this.z=0;const n=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0);if(n!==0){if(n===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(n===1){const{x:r,y:o,z:a}=t;this.x=r,this.y=o,this.z=a||0;return}if(n===3){this.x=t,this.y=e,this.z=s;return}throw wt.ILLEGAL_PARAMETERS}}set(t,e,s){return s===void 0&&(s=this.z),this.x=t,this.y=e,this.z=s,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+t)}}clone(){return new Ta(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Io.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Io.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,s=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[3]*s+r[6]*n,this.y=r[1]*e+r[4]*s+r[7]*n,this.z=r[2]*e+r[5]*s+r[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,s=this.y,n=this.z,r=t.elements,o=1/(r[3]*e+r[7]*s+r[11]*n+r[15]);return this.x=(r[0]*e+r[4]*s+r[8]*n+r[12])*o,this.y=(r[1]*e+r[5]*s+r[9]*n+r[13])*o,this.z=(r[2]*e+r[6]*s+r[10]*n+r[14])*o,this}applyQuaternion(t){const e=this.x,s=this.y,n=this.z,r=t.x,o=t.y,a=t.z,h=t.w,c=2*(o*n-a*s),d=2*(a*e-r*n),u=2*(r*s-o*e);return this.x=e+h*c+o*u-a*d,this.y=s+h*d+a*c-r*u,this.z=n+h*u+r*d-o*c,this}transformDirection(t){const e=this.x,s=this.y,n=this.z,r=t.elements;return this.x=r[0]*e+r[4]*s+r[8]*n,this.y=r[1]*e+r[5]*s+r[9]*n,this.z=r[2]*e+r[6]*s+r[10]*n,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Math.max(t.x,Math.min(e.x,this.x)),this.y=Math.max(t.y,Math.min(e.y,this.y)),this.z=Math.max(t.z,Math.min(e.z,this.z)),this}clampScalar(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this.z=Math.max(t,Math.min(e,this.z)),this}clampLength(t,e){const s=this.length();return this.divideScalar(s||1).multiplyScalar(Math.max(t,Math.min(e,s)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}isParallelTo(t){const e=this.dot(t),s=this.length(),n=t.length();return Math.abs(e)===s*n}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,s){return this.x=t.x+(e.x-t.x)*s,this.y=t.y+(e.y-t.y)*s,this.z=t.z+(e.z-t.z)*s,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const s=t.x,n=t.y,r=t.z,o=e.x,a=e.y,h=e.z;return this.x=n*h-r*a,this.y=r*o-s*h,this.z=s*a-n*o,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const s=t.dot(this)/e;return this.copy(t).multiplyScalar(s)}projectOnPlane(t){return bn.copy(this).projectOnVector(t),this.sub(bn)}reflect(t){return this.sub(bn.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const s=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,s)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,s=this.y-t.y,n=this.z-t.z;return e*e+s*s+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),s=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=s,this.z=n,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,s=Math.sqrt(1-e*e);return this.x=s*Math.cos(t),this.y=e,this.z=s*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};mt.ORIGIN=Object.freeze(new mt(0,0,0)),mt.X_AXIS=Object.freeze(new mt(1,0,0)),mt.NEGATIVE_X_AXIS=Object.freeze(new mt(-1,0,0)),mt.Y_AXIS=Object.freeze(new mt(0,1,0)),mt.NEGATIVE_Y_AXIS=Object.freeze(new mt(0,-1,0)),mt.Z_AXIS=Object.freeze(new mt(0,0,1)),mt.NEGATIVE_Z_AXIS=Object.freeze(new mt(0,0,-1));let _=mt;const bn=new _,Io=new ss,jn=class Ea{constructor(t,e,s,n,r,o,a,h,c,d,u,p,g,m,y,b){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&s!=null&&n!=null&&r!=null&&o!=null&&a!=null&&h!=null&&c!=null&&d!=null&&u!=null&&p!=null&&g!=null&&m!=null&&y!=null&&b!=null&&this.set(t,e,s,n,r,o,a,h,c,d,u,p,g,m,y,b)}set(t,e,s,n,r,o,a,h,c,d,u,p,g,m,y,b){const x=this.elements;return x[0]=t,x[4]=e,x[8]=s,x[12]=n,x[1]=r,x[5]=o,x[9]=a,x[13]=h,x[2]=c,x[6]=d,x[10]=u,x[14]=p,x[3]=g,x[7]=m,x[11]=y,x[15]=b,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Ea().fromArray(this.elements)}copy(t){const e=this.elements,s=t.elements;return e[0]=s[0],e[1]=s[1],e[2]=s[2],e[3]=s[3],e[4]=s[4],e[5]=s[5],e[6]=s[6],e[7]=s[7],e[8]=s[8],e[9]=s[9],e[10]=s[10],e[11]=s[11],e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],this}copyPosition(t){const e=this.elements,s=t.elements;return e[12]=s[12],e[13]=s[13],e[14]=s[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}setFromExtrusionDirection(t){if(dr.equalPoint3d(t,_.Z_AXIS))this.identity();else{const e=new _(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?e.crossVectors(_.Y_AXIS,t).normalize():e.crossVectors(_.Z_AXIS,t).normalize();const s=t.clone().cross(e).normalize();this.set(e.x,e.y,e.z,0,s.x,s.y,s.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,e,s){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),s.setFromMatrixColumn(this,2),this}makeBasis(t,e,s){return this.set(t.x,e.x,s.x,0,t.y,e.y,s.y,0,t.z,e.z,s.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,s=t.elements,n=1/is.setFromMatrixColumn(t,0).length(),r=1/is.setFromMatrixColumn(t,1).length(),o=1/is.setFromMatrixColumn(t,2).length();return e[0]=s[0]*n,e[1]=s[1]*n,e[2]=s[2]*n,e[3]=0,e[4]=s[4]*r,e[5]=s[5]*r,e[6]=s[6]*r,e[7]=0,e[8]=s[8]*o,e[9]=s[9]*o,e[10]=s[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(uc,t,gc)}lookAt(t,e,s){const n=this.elements;return bt.subVectors(t,e),bt.lengthSq()===0&&(bt.z=1),bt.normalize(),_e.crossVectors(s,bt),_e.lengthSq()===0&&(Math.abs(s.z)===1?bt.x+=1e-4:bt.z+=1e-4,bt.normalize(),_e.crossVectors(s,bt)),_e.normalize(),pi.crossVectors(bt,_e),n[0]=_e.x,n[4]=pi.x,n[8]=bt.x,n[1]=_e.y,n[5]=pi.y,n[9]=bt.y,n[2]=_e.z,n[6]=pi.z,n[10]=bt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const s=t.elements,n=e.elements,r=this.elements,o=s[0],a=s[4],h=s[8],c=s[12],d=s[1],u=s[5],p=s[9],g=s[13],m=s[2],y=s[6],b=s[10],x=s[14],I=s[3],S=s[7],L=s[11],A=s[15],H=n[0],M=n[4],X=n[8],R=n[12],et=n[1],F=n[5],Y=n[9],ke=n[13],ve=n[2],oi=n[6],ai=n[10],li=n[14],hi=n[3],ci=n[7],di=n[11],ui=n[15];return r[0]=o*H+a*et+h*ve+c*hi,r[4]=o*M+a*F+h*oi+c*ci,r[8]=o*X+a*Y+h*ai+c*di,r[12]=o*R+a*ke+h*li+c*ui,r[1]=d*H+u*et+p*ve+g*hi,r[5]=d*M+u*F+p*oi+g*ci,r[9]=d*X+u*Y+p*ai+g*di,r[13]=d*R+u*ke+p*li+g*ui,r[2]=m*H+y*et+b*ve+x*hi,r[6]=m*M+y*F+b*oi+x*ci,r[10]=m*X+y*Y+b*ai+x*di,r[14]=m*R+y*ke+b*li+x*ui,r[3]=I*H+S*et+L*ve+A*hi,r[7]=I*M+S*F+L*oi+A*ci,r[11]=I*X+S*Y+L*ai+A*di,r[15]=I*R+S*ke+L*li+A*ui,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],s=t[4],n=t[8],r=t[12],o=t[1],a=t[5],h=t[9],c=t[13],d=t[2],u=t[6],p=t[10],g=t[14],m=t[3],y=t[7],b=t[11],x=t[15];return m*(+r*h*u-n*c*u-r*a*p+s*c*p+n*a*g-s*h*g)+y*(+e*h*g-e*c*p+r*o*p-n*o*g+n*c*d-r*h*d)+b*(+e*c*u-e*a*g-r*o*u+s*o*g+r*a*d-s*c*d)+x*(-n*a*d-e*h*u+e*a*p+n*o*u-s*o*p+s*h*d)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,s){const n=this.elements;return t instanceof _?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=s),this}invert(){const t=this.elements,e=t[0],s=t[1],n=t[2],r=t[3],o=t[4],a=t[5],h=t[6],c=t[7],d=t[8],u=t[9],p=t[10],g=t[11],m=t[12],y=t[13],b=t[14],x=t[15],I=u*b*c-y*p*c+y*h*g-a*b*g-u*h*x+a*p*x,S=m*p*c-d*b*c-m*h*g+o*b*g+d*h*x-o*p*x,L=d*y*c-m*u*c+m*a*g-o*y*g-d*a*x+o*u*x,A=m*u*h-d*y*h-m*a*p+o*y*p+d*a*b-o*u*b,H=e*I+s*S+n*L+r*A;if(H===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/H;return t[0]=I*M,t[1]=(y*p*r-u*b*r-y*n*g+s*b*g+u*n*x-s*p*x)*M,t[2]=(a*b*r-y*h*r+y*n*c-s*b*c-a*n*x+s*h*x)*M,t[3]=(u*h*r-a*p*r-u*n*c+s*p*c+a*n*g-s*h*g)*M,t[4]=S*M,t[5]=(d*b*r-m*p*r+m*n*g-e*b*g-d*n*x+e*p*x)*M,t[6]=(m*h*r-o*b*r-m*n*c+e*b*c+o*n*x-e*h*x)*M,t[7]=(o*p*r-d*h*r+d*n*c-e*p*c-o*n*g+e*h*g)*M,t[8]=L*M,t[9]=(m*u*r-d*y*r-m*s*g+e*y*g+d*s*x-e*u*x)*M,t[10]=(o*y*r-m*a*r+m*s*c-e*y*c-o*s*x+e*a*x)*M,t[11]=(d*a*r-o*u*r-d*s*c+e*u*c+o*s*g-e*a*g)*M,t[12]=A*M,t[13]=(d*y*n-m*u*n+m*s*p-e*y*p-d*s*b+e*u*b)*M,t[14]=(m*a*n-o*y*n-m*s*h+e*y*h+o*s*b-e*a*b)*M,t[15]=(o*u*n-d*a*n+d*s*h-e*u*h-o*s*p+e*a*p)*M,this}scale(t){const e=this.elements,s=t.x,n=t.y,r=t.z;return e[0]*=s,e[4]*=n,e[8]*=r,e[1]*=s,e[5]*=n,e[9]*=r,e[2]*=s,e[6]*=n,e[10]*=r,e[3]*=s,e[7]*=n,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],s=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,s,n))}makeTranslation(t,e,s){return t instanceof _?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,s,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),s=Math.sin(t);return this.set(1,0,0,0,0,e,-s,0,0,s,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,0,s,0,0,1,0,0,-s,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),s=Math.sin(t);return this.set(e,-s,0,0,s,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const s=Math.cos(e),n=Math.sin(e),r=1-s,o=t.x,a=t.y,h=t.z,c=r*o,d=r*a;return this.set(c*o+s,c*a-n*h,c*h+n*a,0,c*a+n*h,d*a+s,d*h-n*o,0,c*h-n*a,d*h+n*o,r*h*h+s,0,0,0,0,1),this}makeScale(t,e,s){return this.set(t,0,0,0,0,e,0,0,0,0,s,0,0,0,0,1),this}makeShear(t,e,s,n,r,o){return this.set(1,s,r,0,t,1,o,0,e,n,1,0,0,0,0,1),this}compose(t,e,s){const n=this.elements,r=e.x,o=e.y,a=e.z,h=e.w,c=r+r,d=o+o,u=a+a,p=r*c,g=r*d,m=r*u,y=o*d,b=o*u,x=a*u,I=h*c,S=h*d,L=h*u,A=s.x,H=s.y,M=s.z;return n[0]=(1-(y+x))*A,n[1]=(g+L)*A,n[2]=(m-S)*A,n[3]=0,n[4]=(g-L)*H,n[5]=(1-(p+x))*H,n[6]=(b+I)*H,n[7]=0,n[8]=(m+S)*M,n[9]=(b-I)*M,n[10]=(1-(p+y))*M,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,s){const n=this.elements;let r=is.set(n[0],n[1],n[2]).length();const o=is.set(n[4],n[5],n[6]).length(),a=is.set(n[8],n[9],n[10]).length();this.determinant()<0&&(r=-r),t.x=n[12],t.y=n[13],t.z=n[14],vt.copy(this);const h=1/r,c=1/o,d=1/a;return vt.elements[0]*=h,vt.elements[1]*=h,vt.elements[2]*=h,vt.elements[4]*=c,vt.elements[5]*=c,vt.elements[6]*=c,vt.elements[8]*=d,vt.elements[9]*=d,vt.elements[10]*=d,e.setFromRotationMatrix(vt),s.x=r,s.y=o,s.z=a,this}equals(t){const e=this.elements,s=t.elements;for(let n=0;n<16;n++)if(e[n]!==s[n])return!1;return!0}fromArray(t,e=0){for(let s=0;s<16;s++)this.elements[s]=t[s+e];return this}toArray(t=[],e=0){const s=this.elements;return t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3],t[e+4]=s[4],t[e+5]=s[5],t[e+6]=s[6],t[e+7]=s[7],t[e+8]=s[8],t[e+9]=s[9],t[e+10]=s[10],t[e+11]=s[11],t[e+12]=s[12],t[e+13]=s[13],t[e+14]=s[14],t[e+15]=s[15],t}};jn.IDENTITY=Object.freeze(new jn);let D=jn;const is=new _,vt=new D,uc=new _(0,0,0),gc=new _(1,1,1),_e=new _,pi=new _,bt=new _;let N=class La{constructor(t=void 0,e=void 0){this.min=t==null?new _(1/0,1/0,1/0):new _(t.x,t.y,t.z),this.max=e==null?new _(-1/0,-1/0,-1/0):new _(e.x,e.y,e.z)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e+=3)this.expandByPoint(fn.fromArray(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=fn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new La().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new _(0,0,0):new _(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new _(0,0,0):new _(0,0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y||t.z<this.min.z||t.z>this.max.z)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y||t.max.z<this.min.z||t.min.z>this.max.z)}intersectsPlane(t){let e,s;return t.normal.x>0?(e=t.normal.x*this.min.x,s=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,s=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,s+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,s+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,s+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,s+=t.normal.z*this.min.z),e<=-t.constant&&s>=-t.constant}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,fn).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Ut[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ut[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ut[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ut[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ut[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ut[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ut[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ut[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ut),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}};const Ut=[new _,new _,new _,new _,new _,new _,new _,new _],fn=new _,Ao=new $;let _t=class Ma{constructor(t=void 0,e=void 0){this.min=t==null?new $(1/0,1/0):new $(t.x,t.y),this.max=e==null?new $(-1/0,-1/0):new $(e.x,e.y)}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromPoints(t){this.makeEmpty();for(let e=0,s=t.length;e<s;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const s=Ao.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(s),this.max.copy(t).add(s),this}clone(){return new Ma().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new $(0,0):new $(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new $(0,0):new $(0,0).subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}containsPoint(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(t){return!(t.max.x<this.min.x||t.min.x>this.max.x||t.max.y<this.min.y||t.min.y>this.max.y)}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Ao).distanceTo(t)}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}};const Po=new _,pc=new _,mc=new Js;class ei{constructor(t=new _(1,0,0),e=0){this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,s,n){return this.normal.set(t,e,s),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,s){const n=Po.subVectors(s,e).cross(pc.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectsBox(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const s=e||mc.getNormalMatrix(t),n=this.coplanarPoint(Po).applyMatrix4(t),r=this.normal.applyMatrix3(s).normalize();return this.constant=-n.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new ei().copy(this)}}let v=class ka extends ${clone(){return new ka(this.x,this.y)}static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((s,n)=>{s.toArray(e,n*2)}),e}},w=class va extends _{clone(){return new va(this.x,this.y,this.z)}static pointArrayToNumberArray(t,e=!0){const s=e?3:2,n=new Array(t.length*s);return t.forEach((r,o)=>{r.toArray(n,o*s)}),n}};const To=new D,Eo=new ss,Ca=class Wn{constructor(t=0,e=0,s=0,n=Wn.DEFAULT_ORDER){this._x=t,this._y=e,this._z=s,this._order=n}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,s,n=this._order){return this._x=t,this._y=e,this._z=s,this._order=n,this._onChangeCallback(),this}clone(){return new Wn(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,s=!0){const n=t.elements,r=n[0],o=n[4],a=n[8],h=n[1],c=n[5],d=n[9],u=n[2],p=n[6],g=n[10];switch(e){case"XYZ":this._y=Math.asin(he(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-d,g),this._z=Math.atan2(-o,r)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-he(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(a,g),this._z=Math.atan2(h,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(he(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-u,g),this._z=Math.atan2(-o,c)):(this._y=0,this._z=Math.atan2(h,r));break;case"ZYX":this._y=Math.asin(-he(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(p,g),this._z=Math.atan2(h,r)):(this._x=0,this._z=Math.atan2(-o,c));break;case"YZX":this._z=Math.asin(he(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(a,g));break;case"XZY":this._z=Math.asin(-he(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(a,r)):(this._x=Math.atan2(-d,g),this._y=0);break}return this._order=e,s===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,s=!0){return To.makeRotationFromQuaternion(t),this.setFromRotationMatrix(To,e,s)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Eo.setFromEuler(this),this.setFromQuaternion(Eo,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Ca.DEFAULT_ORDER="XYZ";let yc=Ca;function ur(i,t,e=!1){const s=i.x,n=i.y;let r=!1;const o=t.length;for(let a=0,h=o-1;a<o;h=a++){const c=t[a].x,d=t[a].y,u=t[h].x,p=t[h].y;let g=d>n!=p>n;e&&(g=d>=n!=p>=n),g&&s<(u-c)*(n-d)/(p-d)+c&&(r=!r)}return r}function Oa(i,t){if(i.length===0||t.length===0)return!1;const e=new _t().setFromPoints(i),s=new _t().setFromPoints(t);if(!e.intersectsBox(s))return!1;for(let n=0;n<i.length;){if(ur(i[n],t,!0))return!0;n<i.length-1&&dr.equalPoint2d(i[n+1],i[n])&&++n,++n}return!1}const Na={isPointInPolygon:ur,isPolygonIntersect:Oa};function _c(i,t){const e=[],s=t-1,n=i;for(let r=0;r<=n;r++)e.push(0);for(let r=1;r<=s-n;r++)e.push(r);for(let r=0;r<=n;r++)e.push(s-n+1);return e}function xc(i,t){const e=t.length-1,s=i,n=[0];let r=0;for(let a=1;a<=e;a++){const h=t[a][0]-t[a-1][0],c=t[a][1]-t[a-1][1],d=t[a][2]-t[a-1][2],u=Math.sqrt(h*h+c*c+d*d);r+=u,n.push(r)}const o=[];for(let a=0;a<=s;a++)o.push(0);for(let a=1;a<=e-s;a++){const h=n[a]/r;o.push(h*(e-s+1))}for(let a=0;a<=s;a++)o.push(e-s+1);return o}function Ba(i,t="Uniform"){const e=i.length;if(e===0)return[];if(e===1)return[0];const s=e-1;if(t==="Uniform")return new Array(e).fill(0).map((o,a)=>a/s);const n=[0];let r=0;for(let o=1;o<=s;o++){const a=i[o][0]-i[o-1][0],h=i[o][1]-i[o-1][1],c=i[o][2]-i[o-1][2],d=Math.sqrt(a*a+h*h+c*c),u=t==="SqrtChord"?Math.sqrt(d):d;r+=u,n.push(r)}return r<1e-12?new Array(e).fill(0).map((o,a)=>a/s):n.map(o=>o/r)}function Ra(i,t){const e=t.length-1,s=i,n=e+s+1,r=new Array(n+1).fill(0),o=t[t.length-1];for(let a=n-s;a<=n;a++)r[a]=o;for(let a=1;a<=e-s;a++){let h=0;for(let c=a;c<a+s;c++)h+=t[c];r[a+s]=h/s}return r}function wc(i,t){const e=t.length-1,s=i,n=[0];let r=0;for(let a=1;a<=e;a++){const h=t[a][0]-t[a-1][0],c=t[a][1]-t[a-1][1],d=t[a][2]-t[a-1][2],u=Math.sqrt(h*h+c*c+d*d),p=Math.sqrt(u);r+=p,n.push(r)}const o=[];for(let a=0;a<=s;a++)o.push(0);for(let a=1;a<=e-s;a++){const h=n[a]/r;o.push(h*(e-s+1))}for(let a=0;a<=s;a++)o.push(e-s+1);return o}function Sn(i,t){const e=i.length,s=i.map(o=>o.slice()),n=t.slice();for(let o=0;o<e;o++){let a=o,h=Math.abs(s[o][o]);for(let c=o+1;c<e;c++){const d=Math.abs(s[c][o]);d>h&&(h=d,a=c)}if(h<1e-12)throw new Error("Interpolation matrix is singular.");if(a!==o){const c=s[o];s[o]=s[a],s[a]=c;const d=n[o];n[o]=n[a],n[a]=d}for(let c=o+1;c<e;c++){const d=s[c][o]/s[o][o];if(!(Math.abs(d)<1e-14)){for(let u=o;u<e;u++)s[c][u]-=d*s[o][u];n[c]-=d*n[o]}}}const r=new Array(e).fill(0);for(let o=e-1;o>=0;o--){let a=n[o];for(let h=o+1;h<e;h++)a-=s[o][h]*r[h];r[o]=a/s[o][o]}return r}function gr(i,t,e="Uniform",s,n){if(i.length===0)return{controlPoints:[],knots:[],weights:[]};const r=i.map(R=>[R[0],R[1],R[2]??0]),o=!!s,a=!!n,h=(o?1:0)+(a?1:0),c=r.length-1,d=c+h;if(d<t)throw new Error("Not enough points to interpolate a curve of this degree.");const u=Ba(r,e),p=u.slice();o&&p.unshift(u[0]),a&&p.push(u[u.length-1]);const g=Ra(t,p),m=d+1,y=new Array(m),b=new Array(m),x=new Array(m),I=new Array(m);let S=0;y[S]=new Array(m).fill(0),y[S][0]=1,b[S]=r[0][0],x[S]=r[0][1],I[S]=r[0][2],S++;for(let R=1;R<=c-1;R++){const et=u[R];y[S]=new Array(m).fill(0);for(let F=0;F<=d;F++)y[S][F]=js(F,t,et,g);b[S]=r[R][0],x[S]=r[R][1],I[S]=r[R][2],S++}if(y[S]=new Array(m).fill(0),y[S][d]=1,b[S]=r[c][0],x[S]=r[c][1],I[S]=r[c][2],S++,o){const R=g[t+1]-g[0],et=R!==0?t/R:0;y[S]=new Array(m).fill(0),y[S][0]=-et,y[S][1]=et,b[S]=(s==null?void 0:s[0])??0,x[S]=(s==null?void 0:s[1])??0,I[S]=(s==null?void 0:s[2])??0,S++}if(a){const R=g[d+t+1]-g[d],et=R!==0?t/R:0;y[S]=new Array(m).fill(0),y[S][d-1]=-et,y[S][d]=et,b[S]=(n==null?void 0:n[0])??0,x[S]=(n==null?void 0:n[1])??0,I[S]=(n==null?void 0:n[2])??0,S++}const L=Sn(y,b),A=Sn(y,x),H=Sn(y,I),M=new Array(m);for(let R=0;R<m;R++)M[R]=[L[R],A[R],H[R]];const X=new Array(m).fill(1);return{controlPoints:M,knots:g,weights:X}}function js(i,t,e,s){if(t===0)return e>=s[i]&&e<s[i+1]?1:0;const n=s[i+t]-s[i],r=s[i+t+1]-s[i+1],o=n>1e-10?(e-s[i])/n:0,a=r>1e-10?(s[i+t+1]-e)/r:0;return o*js(i,t-1,e,s)+a*js(i+1,t-1,e,s)}function Bs(i,t,e,s,n){const r=s.length-1,o=t;if(i=Math.max(e[o],Math.min(e[r+1],i)),Math.abs(i-e[r+1])<1e-8)return[...s[r]];if(Math.abs(i-e[o])<1e-8)return[...s[0]];const a=[0,0,0];let h=0;for(let c=0;c<=r;c++){const d=js(c,o,i,e),u=n[c]*d;a[0]+=s[c][0]*u,a[1]+=s[c][1]*u,a[2]+=s[c][2]*u,h+=u}if(Math.abs(h)<1e-10){const c=e[e.length-o-1];if(Math.abs(i-c)<1e-8)return[...s[r]];if(Math.abs(i-e[o])<1e-8)return[...s[0]]}return Math.abs(h)>=1e-10&&(a[0]/=h,a[1]/=h,a[2]/=h),a}function Fa(i,t,e,s){const n=i,r=t[n],o=t[t.length-n-1];let a=0;const h=1e3,c=(o-r)/h;let d=Bs(r,i,t,e,s);for(let y=1;y<=h;y++){const b=r+y*c,x=Bs(b,i,t,e,s),I=x[0]-d[0],S=x[1]-d[1],L=x[2]-d[2];a+=Math.sqrt(I*I+S*S+L*L),d=x}const u=Bs(o,i,t,e,s),p=u[0]-d[0],g=u[1]-d[1],m=u[2]-d[2];return a+=Math.sqrt(p*p+g*g+m*m),a}function bc(i,t=3,e="Uniform",s,n){return i.length===0?[]:gr(i,t,e,s,n).controlPoints}const Lo=new D,Mo=new _,fc=new _,Sc=new _,In=new w;function za(i){return new D().setFromExtrusionDirection(new _(i.x,i.y,i.z))}function pr(i){return Lo.setFromExtrusionDirection(new _(i.x,i.y,i.z)),Lo.extractBasis(Mo,fc,Sc),Mo.clone()}function Hn(i,t){return new w(i.x,i.y,i.z??0).applyMatrix4(za(t))}function Ws(i,t){return new w(i.x,i.y,i.z??0).applyMatrix4(za(t).invert())}function Gn(i,t,e){const s=Ws(i,e),n=Ws(t,e);return In.set(n.x-s.x,n.y-s.y,(n.z??0)-(s.z??0)),k.normalizeAngle(Math.atan2(In.y,In.x))}class Va{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class mr extends Va{translate(t){return this.transform(new Js().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}let Pe=class Da extends mr{constructor(){super(),this._loops=[]}add(t){this._loops.push(t),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const t=this.outter;return t?t.box:new _t}transform(t){return this._loops.forEach(e=>{e.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){const t=new Da;return this._loops.forEach(e=>{t.add(e.clone())}),t}getPoints(t){const e=[];for(let s=0;s<this.loops.length;++s){const n=this.loops[s].getPoints(t);e.push(n)}return e}buildHierarchy(){var t;const e=this.getPoints(100),s=this.calculateBoundaryBoxes(e),n=this.sortBoundaryBoxesByAreas(s),r=new Map,o=n.length;for(let h=0;h<o;h++)r.set(n[h],{index:n[h],children:[]});const a={index:-1,children:[]};for(let h=0;h<o;h++){const c=n[h],d=e[c],u=s[c];let p=h+1;for(;p<o;p++){const g=n[p],m=e[g];if(s[g].containsBox(u)&&Na.isPointInPolygon(d[k.randInt(0,d.length-1)],m)){(t=r.get(g))==null||t.children.push(r.get(c));break}}p===o&&a.children.push(r.get(c))}return a}get area(){if(this._loops.length===0)return 0;let t=0;for(let e=0;e<this._loops.length;e++){const s=this._loops[e].getPoints(128),n=this.polygonArea(s);e===0?t+=Math.abs(n):t-=Math.abs(n)}return t}polygonArea(t){const e=t.length;if(e<3)return 0;let s=0;for(let n=0,r=e-1;n<e;r=n++){const o=t[r],a=t[n];s+=o.x*a.y-a.x*o.y}return s*.5}calculateBoundaryBoxes(t){const e=[];return t.forEach(s=>{e.push(new _t().setFromPoints(s))}),e}sortBoundaryBoxesByAreas(t){const e=[];t.forEach((n,r)=>{const o=n.size,a=o.width*o.height;e.push({area:a,index:r})}),e.sort((n,r)=>n.area-r.area);const s=[];return e.forEach(n=>{s.push(n.index)}),s}},ds=class extends mr{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(t){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(t){const e=this.getUtoTmapping(t);return this.getPoint(e)}getPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}getSpacedPoints(t=5){const e=[];for(let s=0;s<=t;s++)e.push(this.getPointAt(s/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const e=[];let s,n=this.getPoint(0),r=0;e.push(0);for(let o=1;o<=t;o++)s=this.getPoint(o/t),r+=s.distanceTo(n),e.push(r),n=s;return e}getUtoTmapping(t,e){const s=this.getLengths();let n=0;const r=s.length;let o;e?o=e:o=t*s[r-1];let a=0,h=r-1,c;for(;a<=h;)if(n=Math.floor(a+(h-a)/2),c=s[n]-o,c<0)a=n+1;else if(c>0)h=n-1;else{h=n;break}if(n=h,s[n]===o)return n/(r-1);const d=s[n],u=s[n+1]-d,p=(o-d)/u;return(n+p)/(r-1)}getTangent(t){let e=t-1e-4,s=t+1e-4;e<0&&(e=0),s>1&&(s=1);const n=this.getPoint(e),r=this.getPoint(s),o=new v;return o.copy(r).sub(n).normalize(),o}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}},Te=class Un extends ds{constructor(t,e,s,n,r){super();const o=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(n!==void 0)+ +(r!==void 0);if(o==3)typeof t=="object"&&typeof e=="object"&&typeof s=="object"?this.createByThreePoints(t,e,s):this.createByStartEndPointsAndBulge(t,e,s);else if(o==5){const a=t;this.center=new v(a.x,a.y),this.radius=e,this._clockwise=r,this._startAngle=this._clockwise?this._mirrorAngle(k.normalizeAngle(s)):k.normalizeAngle(s),this._endAngle=this._clockwise?this._mirrorAngle(k.normalizeAngle(n)):k.normalizeAngle(n)}else throw wt.ILLEGAL_PARAMETERS}createByThreePoints(t,e,s){const n=(M,X)=>({x:(M.x+X.x)/2,y:(M.y+X.y)/2}),r=(M,X)=>(X.y-M.y)/(X.x-M.x),o=M=>-1/M,a=n(t,e),h=n(e,s),c=r(t,e),d=r(e,s),u=o(c),p=o(d),g=(M,X,R,et)=>{const F=(et-X)/(M-R),Y=M*F+X;return{x:F,y:Y}},m=a.y-u*a.x,y=h.y-p*h.x,b=g(u,m,p,y),x=Math.sqrt(Math.pow(t.x-b.x,2)+Math.pow(t.y-b.y,2)),I=(M,X)=>Math.atan2(M.y-X.y,M.x-X.x),S=I(t,b),L=I(e,b),A=I(s,b),H=A>S&&A<L||S>A&&S<L||L>A&&L<S;this.center=b,this.radius=x,this._clockwise=!H,this._startAngle=S,this._endAngle=A}createByStartEndPointsAndBulge(t,e,s){let n,r,o;s<0?(n=Math.atan(-s)*4,r=new $(t),o=new $(e)):(n=Math.atan(s)*4,r=new $(e),o=new $(t));const a=new $().subVectors(o,r),h=a.length(),c=new $().addVectors(r,a.multiplyScalar(.5)),d=Math.abs(h/2/Math.tan(n/2)),u=a.normalize(),p=s<0?-Math.PI/2:Math.PI/2,g=new $(u.x*Math.cos(p)-u.y*Math.sin(p),u.y*Math.cos(p)+u.x*Math.sin(p));let m;n<Math.PI?s<0?m=c.add(g.multiplyScalar(d)):m=c.add(g.multiplyScalar(-d)):s<0?m=c.add(g.multiplyScalar(-d)):m=c.add(g.multiplyScalar(d)),s<0?(this._startAngle=Math.atan2(r.y-m.y,r.x-m.x),this._endAngle=Math.atan2(o.y-m.y,o.x-m.x)):(this._startAngle=Math.atan2(o.y-m.y,o.x-m.x),this._endAngle=Math.atan2(r.y-m.y,r.x-m.x)),this._clockwise=s<0,this.center=m,this.radius=o.sub(m).length()}get center(){return this._center}set center(t){this._center=new v(t.x,t.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle}set startAngle(t){this._startAngle=this._clockwise?this._mirrorAngle(k.normalizeAngle(t)):k.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle}set endAngle(t){const e=this.startAngle==0&&t==G?t:k.normalizeAngle(t);this._endAngle=this._clockwise?this._mirrorAngle(e):e,this._boundingBoxNeedsUpdate=!0}_mirrorAngle(t){return(360-t*180/Math.PI)%360*Math.PI/180}_getInternalAngle(t){return this._clockwise?this._mirrorAngle(t):t}get deltaAngle(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle);return this.clockwise?k.normalizeAngle(t-e):k.normalizeAngle(e-t)}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const t=this._getInternalAngle(this.startAngle),e=this._clockwise?k.normalizeAngle(t-this.deltaAngle/2):k.normalizeAngle(t+this.deltaAngle/2),s=this._clockwise?this._mirrorAngle(e):e;return this.getPointAtAngle(s)}get closed(){const t=this._getInternalAngle(this.startAngle),e=this._getInternalAngle(this.endAngle);return Math.abs(e-t)/Math.PI%2==0}calculateBoundingBox(){const t=[this.startPoint,this.endPoint],e=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const r of e){const o=this._getInternalAngle(r);k.isBetweenAngle(o,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(r))}const s=t.map(r=>r.x),n=t.map(r=>r.y);return new _t(new v(Math.min(...s),Math.min(...n)),new v(Math.max(...s),Math.max(...n)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){const e=t,s=this.center.clone().applyMatrix2d(e),n=this.startPoint.clone().applyMatrix2d(e);if(this.closed)return this.center=s,this.radius=s.distanceTo(n),this._startAngle=Math.atan2(n.y-s.y,n.x-s.x),this._endAngle=this._startAngle,this._clockwise=e.determinant()<0?!this._clockwise:this._clockwise,this._boundingBoxNeedsUpdate=!0,this;const r=this.midPoint.clone().applyMatrix2d(e),o=this.endPoint.clone().applyMatrix2d(e),a=new Un(n,r,o),h=e.determinant()<0?!this.clockwise:this.clockwise,c=d=>{const u=k.normalizeAngle(d);return h?this._mirrorAngle(u):u};return this.center=a.center,this.radius=a.radius,this.clockwise=h,this.startAngle=c(Math.atan2(n.y-a.center.y,n.x-a.center.x)),this.endAngle=c(Math.atan2(o.y-a.center.y,o.x-a.center.x)),this._boundingBoxNeedsUpdate=!0,this}clone(){return new Un(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const e=this._getInternalAngle(t),s=this.center.x+this.radius*Math.cos(e),n=this.center.y+this.radius*Math.sin(e);return new v(s,n)}getPoints(t=100){const e=[];let s=this.deltaAngle,n=this._getInternalAngle(this.startAngle);if(this.closed&&(s=G,n=0),this.clockwise)for(let r=0;r<=t;r++){const o=n-s*(r/t),a=this._clockwise?this._mirrorAngle(o):o,h=this.getPointAtAngle(a);e.push(new v(h.x,h.y))}else for(let r=0;r<=t;r++){const o=n+s*(r/t),a=this._clockwise?this._mirrorAngle(o):o,h=this.getPointAtAngle(a);e.push(new v(h.x,h.y))}return e}};class Ic extends Va{translate(t){return this.transform(new D().makeTranslation(t.x,t.y,t.z))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class si extends Ic{}class Ee extends si{constructor(t,e){super(),this._start=new w(t),this._end=new w(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}get direction(){return new _().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new w((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)}nearestPoint(t){return this.project(t)}get length(){return this.startPoint.distanceTo(this.endPoint)}isPointOnLine(t){return this.project(t).distanceTo(t)<1e-6}at(t,e){return this.delta(e).multiplyScalar(t).add(this._start)}atLength(t,e=!1){if(e){const s=this.delta(Ce).normalize();return new w(this._start).addScaledVector(s,t)}else{const s=this.delta(Ce).normalize();return new w(this._end).addScaledVector(s,t)}}extend(t,e=!1){if(e){const s=Ce.subVectors(this._start,this._end).normalize();this._start=new w(this._start).addScaledVector(s,t)}else{const s=this.delta(Ce).normalize();this._end=new w(this._end).addScaledVector(s,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,e){ko.subVectors(t,this._start),mi.subVectors(this.endPoint,this.startPoint);const s=mi.dot(mi);let n=mi.dot(ko)/s;return e&&(n=k.clamp(n,0,1)),n}closestPointToPoint(t,e,s){const n=this.closestPointToPointParameter(t,e);return this.delta(s).multiplyScalar(n).add(this._start)}delta(t){return t.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(t){const e=this.direction,s=Ce.subVectors(t,this.startPoint).dot(e);return new w().copy(e).multiplyScalar(s).add(this.startPoint)}perpPoint(t){const e=this.direction,s=this.startPoint,n=Ce.subVectors(t,s).dot(e),r=Ce.copy(e).multiplyScalar(n);return new w().addVectors(s,r)}calculateBoundingBox(){const t=new w(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),e=new w(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y),Math.max(this._start.z,this._end.z));return new N(t,e)}transform(t){return this._start.applyMatrix4(t),this._end.applyMatrix4(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Ee(this._start.clone(),this._end.clone())}}const Ce=new _,ko=new _,mi=new _;class Ie extends si{static computeCenterPoint(t,e,s){const n=new _().addVectors(t,e).multiplyScalar(.5),r=new _().addVectors(t,s).multiplyScalar(.5),o=new _().subVectors(e,t),a=new _().subVectors(s,t),h=new _().crossVectors(o,a).normalize();if(h.lengthSq()===0)return null;const c=new _().crossVectors(o,h).normalize(),d=new _().crossVectors(a,h).normalize(),u=c.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),p=d.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),g=new Ee(n,n.clone().add(u)),m=new Ee(r,r.clone().add(p)),y=new _;return g.closestPointToPoint(m.startPoint,!0,y)?y:null}static createByThreePoints(t,e,s){const n=Ie.computeCenterPoint(t,e,s);if(n){const r=n.distanceTo(t),o=new _().subVectors(t,n),a=new _().subVectors(e,n),h=Math.atan2(o.y,o.x),c=Math.atan2(a.y,a.x);return new Ie(n,r,h,c,_.Z_AXIS)}}constructor(t,e,s,n,r,o=_.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=s,this.endAngle=n,this.normal=r,this.refVec=o,(n-s)%G==0?(this.startAngle=0,this.endAngle=G):(this.startAngle=s,this.endAngle=n)}get center(){return this._center}set center(t){this._center=new w(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw wt.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=k.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==G?t:k.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return k.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new _(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new _(t.x,t.y,t.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let t=this.startAngle,e=this.deltaAngle;this.closed&&(t=0,e=G);const s=t+e*.5;return this.getPointAtAngle(s)}get length(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)}get area(){return this.closed?Math.PI*this.radius*this.radius:Math.abs(this.deltaAngle*this.radius*this.radius)}nearestPoint(t){const e=new _(t.x,t.y,t.z||0),s=this.center,n=this.normal,r=e.clone().sub(s).dot(n),o=e.clone().sub(n.clone().multiplyScalar(r)).clone().sub(s);if(o.lengthSq()===0)return this.startPoint.clone();o.normalize().multiplyScalar(this.radius);const a=s.clone().add(o),h=this.getAngle(a.clone()),c=this.startAngle,d=this.deltaAngle;let u=k.normalizeAngle(h-c);u<0&&(u=0),u>d&&(u=d);const p=this.getPointAtAngle(c+u),g=p.distanceTo(e),m=this.startPoint.distanceTo(e),y=this.endPoint.distanceTo(e);return m<g&&m<=y?this.startPoint.clone():y<g&&y<m?this.endPoint.clone():p}tangentPoints(t){const e=[],s=new _(t.x,t.y,t.z||0),n=this.center,r=this.normal,o=this.radius,a=s.clone().sub(n).dot(r),h=s.clone().sub(r.clone().multiplyScalar(a)),c=n.clone(),d=h.clone().sub(c).length();if(d<o)return e;const u=Math.acos(o/d),p=this.getAngle(h.clone()),g=[p+u,p-u];for(const m of g){const y=k.normalizeAngle(m-this.startAngle);y>=0&&y<=this.deltaAngle&&e.push(this.getPointAtAngle(this.startAngle+y))}return e}nearestTangentPoint(t){const e=this.tangentPoints(t);if(e.length===0)return null;const s=new w(t.x,t.y,t.z||0);return e.length===1||e[0].distanceTo(s)<e[1].distanceTo(s)?e[0]:e[1]}calculateBoundingBox(){const t=[this.startAngle,this.endAngle];for(let h=0;h<2*Math.PI;h+=Math.PI/2)k.isBetweenAngle(h,this.startAngle,this.endAngle)&&t.push(h);let e=1/0,s=1/0,n=1/0,r=-1/0,o=-1/0,a=-1/0;for(const h of t){const c=this.getPointAtAngle(h);c.x<e&&(e=c.x),c.y<s&&(s=c.y),c.z<n&&(n=c.z),c.x>r&&(r=c.x),c.y>o&&(o=c.y),c.z>a&&(a=c.z)}return new N({x:e,y:s,z:n},{x:r,y:o,z:a})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const e=[];let s=this.deltaAngle,n=this.startAngle;this.closed&&(s=G,n=0);for(let r=0;r<=t;r++){const o=n+s*(r/t),a=this.getPointAtAngle(o);e.push(a)}return e}transform(t){const e=this.center.clone().applyMatrix4(t),s=this.startPoint.clone().applyMatrix4(t),n=this.endPoint.clone().applyMatrix4(t),r=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(t),o=new _(s).sub(e).normalize(),a=e.distanceTo(s);let h=new _().crossVectors(new _(s).sub(e),new _(r).sub(e)).normalize();h.lengthSq()===0&&(h=this.normal.clone().transformDirection(t));const c=d=>{const u=new _(d).sub(e);return Math.atan2(u.dot(vo.crossVectors(h,o)),u.dot(o))};return this.center=e,this.radius=a,this.normal=h,this.refVec=o,this.startAngle=0,this.endAngle=this.closed?G:c(n),this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.radius=t.radius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.normal=t.normal,this.refVec=t.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Ie(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(vo.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,s=this.refVec,n={x:e.y*s.z-e.z*s.y,y:e.z*s.x-e.x*s.z,z:e.x*s.y-e.y*s.x},r=this.center,o=this.radius;return new w(r.x+o*(s.x*Math.cos(t)+n.x*Math.sin(t)),r.y+o*(s.y*Math.cos(t)+n.y*Math.sin(t)),r.z+o*(s.z*Math.cos(t)+n.z*Math.sin(t)))}get plane(){const t=new _(this.center).distanceTo(cr);return new ei(this.normal,t)}}const vo=new _;let Hs=class Ai extends ds{constructor(t,e,s,n=0,r=G,o=!1,a=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=s,(r-n)%G==0?(this.startAngle=0,this.endAngle=G):(this.startAngle=n,this.endAngle=r),this.clockwise=o,this.rotation=a}get center(){return this._center}set center(t){this._center=new w(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw wt.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw wt.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=k.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==G?t:k.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(t){this._clockwise=t,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(t){this._rotation=t,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return k.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let t=1/0,e=1/0,s=-1/0,n=-1/0;for(let r=0;r<=100;r++){const o=this.getPoint(r/100);t=Math.min(t,o.x),e=Math.min(e,o.y),s=Math.max(s,o.x),n=Math.max(n,o.y)}return new _t({x:t,y:e},{x:s,y:n})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let s=this.endAngle-this.startAngle;const n=Math.abs(s)<Number.EPSILON;for(;s<0;)s+=e;for(;s>e;)s-=e;s<Number.EPSILON&&(n?s=0:s=e),this.clockwise===!0&&!n&&(s===e?s=-e:s=s-e);const r=this.startAngle+t*s;let o=this.center.x+this.majorAxisRadius*Math.cos(r),a=this.center.y+this.minorAxisRadius*Math.sin(r);if(this.rotation!==0){const h=Math.cos(this.rotation),c=Math.sin(this.rotation),d=o-this.center.x,u=a-this.center.y;o=d*h-u*c+this.center.x,a=d*c+u*h+this.center.y}return new v(o,a)}transform(t){const e=t,s=new v(this.center).applyMatrix2d(e),n=new w(s.x,s.y,this.center.z),r=this.getPointAtAngle(0).clone().applyMatrix2d(e),o=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(e),a=new v(r).sub(s),h=new v(o).sub(s),c=a.length(),d=h.length(),u=Math.atan2(a.y,a.x),p=a.clone().normalize(),g=h.clone().normalize(),m=x=>{const I=new v(x).sub(s),S=I.dot(p),L=I.dot(g);return k.normalizeAngle(Math.atan2(L/d,S/c))},y=e.determinant()<0?!this.clockwise:this.clockwise,b=this.closed?new Ai(n,c,d,0,G,y,u):new Ai(n,c,d,m(this.startPoint.clone().applyMatrix2d(e)),m(this.endPoint.clone().applyMatrix2d(e)),y,u);return this.center=b.center,this.majorAxisRadius=b.majorAxisRadius,this.minorAxisRadius=b.minorAxisRadius,this._startAngle=b._startAngle,this._endAngle=b._endAngle,this._clockwise=b._clockwise,this.rotation=b.rotation,this._boundingBoxNeedsUpdate=!0,this}getPointAtAngle(t){return this.getPoint(this.closed?t/G:k.normalizeAngle(t-this.startAngle)/this.deltaAngle)}copy(t){return this.center=t.center,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this.clockwise=t.clockwise,this.rotation=t.rotation,this}clone(){return new Ai(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}};class ls extends si{constructor(t,e,s,n,r,o=0,a=G){super(),this.center=t,this.normal=e,this.majorAxis=s,this.majorAxisRadius=n,this.minorAxisRadius=r;const h=Math.abs(a-o);Math.abs(h-G)<1e-10||Math.abs(h-2*G)<1e-10?(this.startAngle=0,this.endAngle=G):(this.startAngle=o,this.endAngle=a)}get center(){return this._center}set center(t){this._center=new w(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw wt.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw wt.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=k.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==G?t:k.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-G)<1e-10?G:k.normalizeAngle(t)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(t){this._normal=new _(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new _(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new _().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let t=this.startAngle,e=this.deltaAngle;(this.closed||Math.abs(e-G)<1e-10)&&(t=0,e=G);const s=t+e/2;return this.getPointAtAngle(s)}get isCircular(){return ti.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const t=1e3,e=this.deltaAngle/t;let s=0,n=this.getPointAtAngle(this.startAngle);for(let r=1;r<=t;r++){const o=this.startAngle+r*e,a=this.getPointAtAngle(o),h=a.x-n.x,c=a.y-n.y,d=a.z-n.z;s+=Math.sqrt(h*h+c*c+d*d),n=a}return s}get area(){const t=this.majorAxisRadius,e=this.minorAxisRadius,s=this.startAngle,n=s+this.deltaAngle;if(Math.abs(this.deltaAngle-G)<1e-10)return Math.PI*t*e;const r=t*e/2*(n-s-(Math.sin(n)*Math.cos(n)-Math.sin(s)*Math.cos(s)));return Math.abs(r)}calculateBoundingBox(){if(this.majorAxis.equals(_.X_AXIS)||this.majorAxis.equals(_.Y_AXIS)||this.majorAxis.isParallelTo(_.X_AXIS)||this.majorAxis.isParallelTo(_.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let h=0;h<2*Math.PI;h+=Math.PI/2)k.isBetweenAngle(h,this.startAngle,this.endAngle)&&t.push(h);let e=1/0,s=1/0,n=1/0,r=-1/0,o=-1/0,a=-1/0;for(const h of t){const c=this.getPointAtAngle(h);c.x<e&&(e=c.x),c.y<s&&(s=c.y),c.z<n&&(n=c.z),c.x>r&&(r=c.x),c.y>o&&(o=c.y),c.z>a&&(a=c.z)}return new N({x:e,y:s,z:n},{x:r,y:o,z:a})}else{let t=1/0,e=1/0,s=1/0,n=-1/0,r=-1/0,o=-1/0;for(let a=0;a<=100;a++){const h=this.startAngle+this.deltaAngle*(a/100),c=this.getPointAtAngle(h);t=Math.min(t,c.x),e=Math.min(e,c.y),s=Math.min(s,c.z),n=Math.max(n,c.x),r=Math.max(r,c.y),o=Math.max(o,c.z)}return new N({x:t,y:e,z:s},{x:n,y:r,z:o})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let s=this.deltaAngle,n=this.startAngle;this.closed&&(s=G,n=0);for(let r=0;r<=t;r++){const o=n+s*(r/t),a=this.getPointAtAngle(o);e.push(a)}return e}getPointAtAngle(t){const e=Math.cos(t),s=Math.sin(t),n=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(s),r=this.majorAxis.clone().multiplyScalar(e*this.majorAxisRadius).add(n);return new w(this.center.x+r.x,this.center.y+r.y,this.center.z+r.z)}contains(t){const e=new _(t).sub(this.center),s=e.dot(this.majorAxis),n=e.dot(this.minorAxis),r=s/this.majorAxisRadius,o=n/this.minorAxisRadius;return r*r+o*o<=1}transform(t){const e=t,s=this.center.clone().applyMatrix4(e),n=this.getPointAtAngle(0).clone().applyMatrix4(e),r=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(e),o=new _(n).sub(s),a=new _(r).sub(s),h=o.length(),c=a.length(),d=o.clone().normalize(),u=new _().crossVectors(o,a).normalize();let p=new _().crossVectors(u,d).normalize();p.dot(a)<0&&(u.negate(),p=new _().crossVectors(u,d).normalize());const g=y=>{const b=new _(y).sub(s),x=b.dot(d),I=b.dot(p);return k.normalizeAngle(Math.atan2(I/c,x/h))},m=this.closed?new ls(s,u,d,h,c,0,G):new ls(s,u,d,h,c,g(this.startPoint.clone().applyMatrix4(e)),g(this.endPoint.clone().applyMatrix4(e)));return this.center=m.center,this.normal=m.normal,this.majorAxis=m.majorAxis,this.majorAxisRadius=m.majorAxisRadius,this.minorAxisRadius=m.minorAxisRadius,this._startAngle=m._startAngle,this._endAngle=m._endAngle,this._boundingBoxNeedsUpdate=!0,this}copy(t){return this.center=t.center,this.normal=t.normal,this.majorAxis=t.majorAxis,this.majorAxisRadius=t.majorAxisRadius,this.minorAxisRadius=t.minorAxisRadius,this.startAngle=t.startAngle,this.endAngle=t.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new ls(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new _(this.center).distanceTo(cr);return new ei(this.normal,t)}}class at extends ds{constructor(t=null,e=!1){super(),this._vertices=t||new Array,this._closed=e}get vertices(){return this._vertices}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const t=this._vertices[0];return new v(t.x,t.y)}throw new Error("Start point does not exist in an empty polyline.")}get endPoint(){const t=this.numberOfVertices;if(t>0)if(this.closed){const e=this._vertices[0];return new v(e.x,e.y)}else{const e=this._vertices[t-1];return new v(e.x,e.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let t=0;const e=this._vertices.length;for(let s=0;s<e;++s){const n=this._vertices[s];let r=null;if(s<e-1?r=this._vertices[s+1]:s==e-1&&this.closed&&(r=this._vertices[0]),r)if(n.bulge){const o=new Te(n,r,n.bulge);t+=o.length}else t+=new v(n.x,n.y).distanceTo(r)}return t}set closed(t){this._closed=t,this._boundingBoxNeedsUpdate=!0}addVertexAt(t,e){t<=0?this._vertices.unshift(e):this._vertices.splice(t,0,e),this._boundingBoxNeedsUpdate=!0}removeVertexAt(t){if(t<0||t>=this._vertices.length)throw new Error(`Index ${t} is out of bounds. Valid range is 0 to ${this._vertices.length-1}.`);this._vertices.splice(t,1),this._boundingBoxNeedsUpdate=!0}reset(t,e){t?e!==void 0&&e>=0&&e<this._vertices.length&&(this._vertices=this._vertices.slice(0,e),this._boundingBoxNeedsUpdate=!0):(this._vertices=new Array,this._boundingBoxNeedsUpdate=!0)}getPointAt(t){const e=this._vertices[t];return new v(e.x,e.y)}calculateBoundingBox(){const t=this.getPoints(100);return new _t().setFromPoints(t)}transform(t){const e=t.determinant()<0;return this._vertices.forEach(s=>{const n=new v(s).applyMatrix2d(t);s.x=n.x,s.y=n.y,e&&s.bulge!=null&&(s.bulge=-s.bulge)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new at(this._vertices.map(t=>({...t})),this._closed)}getPoints3d(t,e){const s=[];return this.getPoints(t).forEach(n=>s.push(new w().set(n.x,n.y,e))),s}getPoints(t){const e=[],s=this._vertices.length;for(let n=0;n<s;++n){const r=this._vertices[n];if(r.bulge){let o=null;if(n<s-1?o=this._vertices[n+1]:n==s-1&&this.closed&&(o=this._vertices[0]),o){const a=new Te(r,o,r.bulge).getPoints(t),h=a.length;for(let c=0;c<h;++c){const d=a[c];e.push(new v(d.x,d.y))}}}else e.push(new v(r.x,r.y)),n==s-1&&this.closed&&e.push(e[0])}return e}}class Wt extends ds{constructor(t,e){super(),this._start=new v(t),this._end=new v(e)}get startPoint(){return this._start}set startPoint(t){this._start.copy(t),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(t){this._end.copy(t),this._boundingBoxNeedsUpdate=!0}getPoints(){return[this.startPoint,this.endPoint]}get length(){return this.startPoint.distanceTo(this.endPoint)}calculateBoundingBox(){const t=new v(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),e=new v(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new _t(t,e)}transform(t){return this._start.applyMatrix2d(t),this._end.applyMatrix2d(t),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(t){return this.startPoint=t.startPoint,this.endPoint=t.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Wt(this._start.clone(),this._end.clone())}}let Gs=class Bt extends ds{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}static buildFromEdges(t,e=.001){if(t.length===0)return[];const s=[...t],n=[],r=e*e,o=(a,h)=>{const c=a.x-h.x,d=a.y-h.y;return c*c+d*d<=r};for(;s.length>0;){const a=[],h=s.shift();a.push(h);const c=Bt.getEdgeStartPoint(h);let d=Bt.getEdgeEndPoint(h);if(!o(c,d))for(;s.length>0;){const u=Bt.findConnectingEdge(s,d,r);if(u.index<0)break;let p=s.splice(u.index,1)[0];if(u.reverse&&(p=Bt.reverseEdge(p)),a.push(p),d=Bt.getEdgeEndPoint(p),o(d,c))break}n.push(new Bt(a))}return n}add(t){this._curves.push(t),this._boundingBoxNeedsUpdate=!0}get numberOfEdges(){return this._curves.length}get startPoint(){if(this._curves.length>0){const t=this._curves[0].startPoint;return new v(t.x,t.y)}throw new Error("Start point does not exist in an empty loop.")}get endPoint(){return this.startPoint}get length(){let t=0;return this._curves.forEach(e=>{t+=e.length}),t}calculateBoundingBox(){const t=this.getPoints(100),e=new _t;return e.setFromPoints(t),e}transform(t){const e=new D().set(t.elements[0],t.elements[3],0,t.elements[6],t.elements[1],t.elements[4],0,t.elements[7],0,0,1,0,0,0,0,1);return this._curves.forEach(s=>{s instanceof Ht?s.transform(e):s.transform(t)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new Bt(this._curves.map(t=>t.clone()))}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(s=>{s.getPoints(t).forEach(n=>{e.push(new v(n.x,n.y))})}),e}static findConnectingEdge(t,e,s){let n=-1,r=!1,o=Number.POSITIVE_INFINITY;for(let a=0;a<t.length;a++){const h=t[a],c=Bt.getEdgeStartPoint(h),d=Bt.getEdgeEndPoint(h),u=e.x-c.x,p=e.y-c.y,g=u*u+p*p;g<o&&(o=g,n=a,r=!1);const m=e.x-d.x,y=e.y-d.y,b=m*m+y*y;b<o&&(o=b,n=a,r=!0)}return o>s?{index:-1,reverse:!1}:{index:n,reverse:r}}static getEdgeStartPoint(t){const e=t.startPoint;return new v(e.x,e.y)}static getEdgeEndPoint(t){const e=t.endPoint;return new v(e.x,e.y)}static reverseEdge(t){return t instanceof Wt?new Wt(t.endPoint,t.startPoint):t instanceof Te?new Te(t.center,t.radius,t.endAngle,t.startAngle,!t.clockwise):t instanceof Hs?new Hs(t.center,t.majorAxisRadius,t.minorAxisRadius,t.endAngle,t.startAngle,!t.clockwise,t.rotation):t instanceof Ht?Bt.reverseSplineEdge(t):t}static reverseSplineEdge(t){const e=[...t.controlPoints].reverse(),s=t.knots,n=s[0],r=s[s.length-1],o=s.map(c=>n+r-c).reverse(),a=t.weights,h=a.length>0?[...a].reverse():void 0;return new Ht(e,o,h,t.degree,t.closed)}};class An{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,s,n){this.c0=t,this.c1=s,this.c2=-3*t+3*e-2*s-n,this.c3=2*t-2*e+s+n}initCatmullRom(t,e,s,n,r){this.init(e,s,r*(s-t),r*(n-e))}initNonuniformCatmullRom(t,e,s,n,r,o,a){let h=(e-t)/r-(s-t)/(r+o)+(s-e)/o,c=(s-e)/o-(n-e)/(o+a)+(n-s)/a;h*=o,c*=o,this.init(e,s,h,c)}calc(t){const e=t*t,s=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*s}}class pn extends si{constructor(t=[],e=!1,s="centripetal",n=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new _,this._px=new An,this._py=new An,this._pz=new An,this._points=t.map(r=>new w(r)),this._closed=e,this._curveType=s,this._tension=n}get points(){return this._points}get closed(){return this._closed}get curveType(){return this._curveType}get tension(){return this._tension}get startPoint(){return this._points.length>0?this._points[0]:new w}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new w}get length(){if(this._points.length<2)return 0;let t=0;for(let e=1;e<this._points.length;e++)t+=this._points[e-1].distanceTo(this._points[e]);return this._closed&&this._points.length>2&&(t+=this._points[this._points.length-1].distanceTo(this._points[0])),t}getPoint(t,e=new w){const s=e,n=this._points,r=n.length;if(r===0)return s.set(0,0,0);if(r===1)return s.copy(n[0]);const o=(r-(this._closed?0:1))*t;let a=Math.floor(o),h=o-a;this._closed?a+=a>0?0:(Math.floor(Math.abs(a)/r)+1)*r:h===0&&a===r-1&&(a=r-2,h=1);let c,d;this._closed||a>0?c=n[(a-1)%r]:(this._tmp.subVectors(n[0],n[1]).add(n[0]),c=new w(this._tmp.x,this._tmp.y,this._tmp.z));const u=n[a%r],p=n[(a+1)%r];if(this._closed||a+2<r?d=n[(a+2)%r]:(this._tmp.subVectors(n[r-1],n[r-2]).add(n[r-1]),d=new w(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const g=this._curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(u),g),y=Math.pow(u.distanceToSquared(p),g),b=Math.pow(p.distanceToSquared(d),g);y<1e-4&&(y=1),m<1e-4&&(m=y),b<1e-4&&(b=y),this._px.initNonuniformCatmullRom(c.x,u.x,p.x,d.x,m,y,b),this._py.initNonuniformCatmullRom(c.y,u.y,p.y,d.y,m,y,b),this._pz.initNonuniformCatmullRom(c.z,u.z,p.z,d.z,m,y,b)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(c.x,u.x,p.x,d.x,this._tension),this._py.initCatmullRom(c.y,u.y,p.y,d.y,this._tension),this._pz.initCatmullRom(c.z,u.z,p.z,d.z,this._tension));return s.set(this._px.calc(h),this._py.calc(h),this._pz.calc(h)),s}getPoints(t){const e=[];for(let s=0;s<=t;s++)e.push(this.getPoint(s/t));return e}setPoints(t){this._points=t.map(e=>new w(e)),this._boundingBoxNeedsUpdate=!0}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0)}setCurveType(t){this._curveType=t}setTension(t){this._tension=t}clone(){return new pn(this._points.map(t=>t.clone()),this._closed,this._curveType,this._tension)}transform(t){return this._points=this._points.map(e=>{const s=new w;return s.copy(e),s.applyMatrix4(t),s}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new N;const t=new N;return this._points.forEach(e=>{t.expandByPoint(e)}),t}}let Rt=class vs{constructor(t,e,s,n){this._degree=t,this._knots=[...e],this._controlPoints=s.map(r=>({x:r.x,y:r.y,z:r.z})),this._weights=n?[...n]:new Array(s.length).fill(1)}degree(){return this._degree}knots(){return[...this._knots]}controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z}))}weights(){return[...this._weights]}clone(){return new vs(this._degree,this._knots,this._controlPoints,this._weights)}point(t){const e=this._controlPoints.map(s=>[s.x,s.y,s.z]);return Bs(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return Fa(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,s,n){return new vs(t,e,s,n)}static byPoints(t,e,s="Uniform",n,r){const o=gr(t,e,s,n,r),a=o.controlPoints.map(h=>({x:h[0],y:h[1],z:h[2]}));return new vs(e,o.knots,a,o.weights)}getParameterRange(){const t=this._knots[this._degree],e=this._knots[this._knots.length-this._degree-1];return{start:t,end:e}}getPoints(t){const e=[],{start:s,end:n}=this.getParameterRange();for(let r=0;r<=t;r++){const o=s+(n-s)*(r/t);e.push(this.point(o))}return e}isClosed(t=1e-6){const{start:e,end:s}=this.getParameterRange(),n=this.point(e),r=this.point(s),o=n[0]-r[0],a=n[1]-r[1],h=n[2]-r[2];return Math.sqrt(o*o+a*a+h*h)<t}static createFitPointsForClosedCurve(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const e=new pn(t,!0,"centripetal"),s=Math.max(50,t.length*2);return e.getPoints(s)}static createClosedCurve(t,e,s="Chord"){const n=this.createFitPointsForClosedCurve(t).map(r=>[r.x,r.y,r.z]);return vs.byPoints(n,e,s)}},Ht=class Pi extends si{constructor(t,e,s,n,r,o){super();const a=arguments.length;if(this._degree=3,this._closed=!1,Array.isArray(e)){if(a<2||a>5)throw wt.ILLEGAL_PARAMETERS;this._controlPoints=t;let h,c=3,d=!1;if(a>=3&&(Array.isArray(s)?(h=s,a>=4&&(c=n||3),a>=5&&(d=r)):s!==void 0&&(c=s||3,a>=4&&(d=n))),s===void 0&&a>=4&&(c=n||3,a>=5&&(d=r)),this._degree=c,this._closed=d,this._controlPoints.length<this._degree+1)throw wt.ILLEGAL_PARAMETERS;this._nurbsCurve=Rt.byKnotsControlPointsWeights(this._degree,e,this._controlPoints,h)}else{if(a<2||a>6)throw wt.ILLEGAL_PARAMETERS;this._fitPoints=t,this._knotParameterization=e,a>=3&&(this._degree=s||3);const h=typeof n=="boolean";a>=4&&h&&(this._closed=n),h?(a>=5&&(this._startTangent=r),a>=6&&(this._endTangent=o)):(a>=4&&(this._startTangent=n),a>=5&&(this._endTangent=r)),this._closed&&(this._startTangent=void 0,this._endTangent=void 0);const c=(this._startTangent?1:0)+(this._endTangent?1:0);if(this._fitPoints.length+c<this._degree+1)throw wt.ILLEGAL_PARAMETERS;if(this._closed)this._nurbsCurve=Rt.createClosedCurve(this._fitPoints,this._degree,this._knotParameterization);else{const d=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Rt.byPoints(d,this._degree,this._knotParameterization,this._startTangent?this.toNurbsPoint(this._startTangent):void 0,this._endTangent?this.toNurbsPoint(this._endTangent):void 0)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(d=>[d.x,d.y,d.z||0]))}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const t=Rt.createFitPointsForClosedCurve(this._fitPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Rt.byPoints(e,this._degree,this._knotParameterization)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Rt.byPoints(t,this._degree,this._knotParameterization,this._startTangent?this.toNurbsPoint(this._startTangent):void 0,this._endTangent?this.toNurbsPoint(this._endTangent):void 0)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(t=>[t.x,t.y,t.z||0]))}else if(this._controlPoints)if(this._closed){const t=Rt.createFitPointsForClosedCurve(this._controlPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Rt.byPoints(e,this._degree,this._knotParameterization),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(s=>[s.x,s.y,s.z||0]))}else{const t=this._nurbsCurve.knots(),e=this._nurbsCurve.weights();this._nurbsCurve=Rt.byKnotsControlPointsWeights(this._degree,t,this._controlPoints,e)}}setClosed(t){this._closed!==t&&(this._closed=t,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._degree}get knotParameterization(){return this._knotParameterization}get controlPoints(){return this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z||0}))}get fitPoints(){var t;return(t=this._fitPoints)==null?void 0:t.map(e=>({x:e.x,y:e.y,z:e.z||0}))}get knots(){return[...this._nurbsCurve.knots()]}get weights(){return[...this._nurbsCurve.weights()]}get startPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[e],n=this._nurbsCurve.point(s);return new w(n[0],n[1],n[2])}get endPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),s=t[t.length-e-1],n=this._nurbsCurve.point(s);return new w(n[0],n[1],n[2])}get length(){return this._nurbsCurve.length()}getFitPointAt(t){if(!this._fitPoints)throw new Error("No fit points in this spline");const e=this._fitPoints.length,s=t<0||t>=e?e-1:t,n=this._fitPoints[s];return{x:n.x,y:n.y,z:n.z||0}}getControlPointAt(t){const e=this._controlPoints.length,s=t<0||t>=e?e-1:t;return this._controlPoints[s]}getPoints(t=100){const e=this._nurbsCurve,s=[],n=e.knots(),r=this._nurbsCurve.degree(),o=n[r],a=n[n.length-r-1],h=(a-o)/(t-1);for(let c=0;c<t;c++){const d=c===t-1?a:o+c*h,u=e.point(d);s.push(new w(u[0],u[1],u[2]))}return s}getCurvePoints(t,e){const s=[],n=t.knots(),r=t.degree(),o=n[r],a=(n[n.length-r-1]-o)/(e-1);for(let h=0;h<e;h++){const c=o+h*a;s.push(t.point(c))}return s}calculateBoundingBox(){const t=this.getPoints(100);return new N().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){if(this._fitPoints&&this._knotParameterization)this._fitPoints=this._fitPoints.map(e=>new w(e).applyMatrix4(t)),this._startTangent&&(this._startTangent=new w(this._startTangent).transformDirection(t)),this._endTangent&&(this._endTangent=new w(this._endTangent).transformDirection(t)),this.buildCurve();else{const e=this._nurbsCurve.knots(),s=this._nurbsCurve.weights();this._controlPoints=this._controlPoints.map(n=>new w(n).applyMatrix4(t)),this._nurbsCurve=Rt.byKnotsControlPointsWeights(this._degree,e,this._controlPoints,s.length>0?s:void 0)}return this._boundingBoxNeedsUpdate=!0,this}clone(){return this._fitPoints&&this._knotParameterization?new Pi(this._fitPoints.map(t=>({x:t.x,y:t.y,z:t.z||0})),this._knotParameterization,this._degree,this._closed,this._startTangent?{x:this._startTangent.x,y:this._startTangent.y,z:this._startTangent.z||0}:void 0,this._endTangent?{x:this._endTangent.x,y:this._endTangent.y,z:this._endTangent.z||0}:void 0):new Pi(this._controlPoints.map(t=>({x:t.x,y:t.y,z:t.z||0})),this._nurbsCurve.knots(),this._nurbsCurve.weights(),this._degree,this._closed)}toNurbsPoints(t){const e=new Array(t.length);return t.forEach((s,n)=>{e[n]=[s.x,s.y,s.z||0]}),e}toGePoints(t){const e=new Array(t.length);return t.forEach((s,n)=>{e[n]={x:s[0],y:s[1],z:s[2]}}),e}toNurbsPoint(t){return[t.x,t.y,t.z||0]}static createClosedSpline(t,e="Uniform",s=3){if(t.length<s+1)throw new Error(`At least ${s+1} points are required for a degree ${s} closed spline`);return new Pi(t,e,s,!0)}};var yr=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))(yr||{}),Qe=(i=>(i[i.ByBlock=-2]="ByBlock",i[i.ByDIPs=-4]="ByDIPs",i[i.ByLayer=-1]="ByLayer",i[i.ByLineWeightDefault=-3]="ByLineWeightDefault",i[i.LineWeight000=0]="LineWeight000",i[i.LineWeight005=5]="LineWeight005",i[i.LineWeight009=9]="LineWeight009",i[i.LineWeight013=13]="LineWeight013",i[i.LineWeight015=15]="LineWeight015",i[i.LineWeight018=18]="LineWeight018",i[i.LineWeight020=20]="LineWeight020",i[i.LineWeight025=25]="LineWeight025",i[i.LineWeight030=30]="LineWeight030",i[i.LineWeight035=35]="LineWeight035",i[i.LineWeight040=40]="LineWeight040",i[i.LineWeight050=50]="LineWeight050",i[i.LineWeight053=53]="LineWeight053",i[i.LineWeight060=60]="LineWeight060",i[i.LineWeight070=70]="LineWeight070",i[i.LineWeight080=80]="LineWeight080",i[i.LineWeight090=90]="LineWeight090",i[i.LineWeight100=100]="LineWeight100",i[i.LineWeight106=106]="LineWeight106",i[i.LineWeight120=120]="LineWeight120",i[i.LineWeight140=140]="LineWeight140",i[i.LineWeight158=158]="LineWeight158",i[i.LineWeight200=200]="LineWeight200",i[i.LineWeight211=211]="LineWeight211",i))(Qe||{}),Dt=(i=>(i[i.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",i[i.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",i[i.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",i[i.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",i[i.BY_STYLE=5]="BY_STYLE",i))(Dt||{}),ot=(i=>(i[i.TopLeft=1]="TopLeft",i[i.TopCenter=2]="TopCenter",i[i.TopRight=3]="TopRight",i[i.MiddleLeft=4]="MiddleLeft",i[i.MiddleCenter=5]="MiddleCenter",i[i.MiddleRight=6]="MiddleRight",i[i.BottomLeft=7]="BottomLeft",i[i.BottomCenter=8]="BottomCenter",i[i.BottomRight=9]="BottomRight",i))(ot||{}),_r=(i=>(i[i.OPTIMIZED_2D=0]="OPTIMIZED_2D",i[i.WIREFRAME=1]="WIREFRAME",i[i.HIDDEN_LINE=2]="HIDDEN_LINE",i[i.FLAT_SHADED=3]="FLAT_SHADED",i[i.GOURAUD_SHADED=4]="GOURAUD_SHADED",i[i.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",i[i.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",i))(_r||{}),xr=(i=>(i[i.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",i[i.TOP=1]="TOP",i[i.BOTTOM=2]="BOTTOM",i[i.FRONT=3]="FRONT",i[i.BACK=4]="BACK",i[i.LEFT=5]="LEFT",i[i.RIGHT=6]="RIGHT",i))(xr||{}),wr=(i=>(i[i.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",i[i.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",i))(wr||{});let ja=class Wa{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new w,this._height=0,this._width=0,this._viewCenter=new w,this._viewHeight=0}get number(){return this._number}set number(t){this._number=t}get id(){return this._id}set id(t){this._id=t}get groupId(){return this._groupId}set groupId(t){this._groupId=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get box(){const t=new _t;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter.copy(t)}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const t=new _t;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new Wa;return t.id=this.id,t.groupId=this.groupId,t.number=this.number,t.centerPoint.copy(this.centerPoint),t.height=this.height,t.width=this.width,t.viewCenter.copy(this.viewCenter),t.viewHeight=this.viewHeight,t}copy(t){return this.id=t.id,this.groupId=t.groupId,this.number=t.number,this.centerPoint.copy(t.centerPoint),this.height=t.height,this.width=t.width,this.viewCenter.copy(t.viewCenter),this.viewHeight=t.viewHeight,this}};const Cr=class Cr extends Ft{constructor(){super(...arguments),this._visibility=!0,this._transparency=new gn}get type(){return this.constructor.typeName}get layer(){return this._layer==null&&(this._layer=this.database.clayer??"0"),this._layer}set layer(t){this._layer=t}get color(){return this._color==null&&(this._color=new j,this.database.cecolor&&this._color.copy(this.database.cecolor)),this._color}set color(t){this._color==null&&(this._color=new j),this._color.copy(t)}get resolvedColor(){var e;let t=this.color;if(t.isByLayer){const s=this.getLayerColor();s&&s.RGB!=null&&(t=s)}else if(t.isByBlock){const s=this.database.cecolor;if(s&&(t=s,t.isByLayer)){const n=this.database.clayer||this.layer,r=this.database.tables.layerTable.getAt(n);((e=r==null?void 0:r.color)==null?void 0:e.RGB)!=null&&(t=r.color)}}return t}get rgbColor(){const e=this.resolvedColor.RGB;return e??16777215}get lineType(){var t;return this._lineType==null&&(this._lineType=((t=this.database)==null?void 0:t.celtype)??dt),this._lineType}set lineType(t){t?t.toUpperCase()==="BYLAYER"?this._lineType=dt:t.toUpperCase()==="BYBLOCK"?this._lineType=fe:this._lineType=t:this._lineType=dt}get lineWeight(){return this._lineWeight==null&&(this._lineWeight=this.database.celweight??Qe.ByLayer),this._lineWeight}set lineWeight(t){this._lineWeight=t}get linetypeScale(){return this._linetypeScale==null&&(this._linetypeScale=this.database.celtscale??-1),this._linetypeScale}set linetypeScale(t){this._linetypeScale=t}get visibility(){return this._visibility}set visibility(t){this._visibility=t}get transparency(){return this._transparency}set transparency(t){this._transparency=t.clone()}dxfOutFields(t){t.writeSubclassMarker("AcDbEntity"),t.writeString(8,this.layer),t.writeString(6,this.lineType),t.writeDouble(48,this.linetypeScale),t.writeInt16(60,this.visibility?0:1),t.writeCmColor(this.color),t.writeInt16(370,this.lineWeight),t.writeTransparency(this.transparency);const e=this.database.tables.blockTable.getIdAt(this.ownerId);return e!=null&&e.isPaperSapce&&t.writeInt16(67,1),this}resolveEffectiveProperties(){this._layer==null&&(this._layer=this.database.clayer??"0"),this._color==null&&(this._color=new j,this.database.cecolor&&this._color.copy(this.database.cecolor)),this._lineType==null&&(this._lineType=this.database.celtype??dt),this._linetypeScale==null&&(this._linetypeScale=this.database.celtscale??-1),this._lineWeight==null&&(this._lineWeight=this.database.celweight??Qe.ByLayer)}get properties(){return{type:this.type,groups:[this.getGeneralProperties()]}}subGetGripPoints(){return new Array}subGetOsnapPoints(t,e,s,n,r,o){}transformBy(t){return this}erase(){return this.database.tables.blockTable.removeEntity(this.objectId)}worldDraw(t,e){const s=t.subEntityTraits;s.color=this.resolvedColor,s.rgbColor=this.rgbColor,s.lineType=this.lineStyle,s.lineTypeScale=this.linetypeScale,s.lineWeight=this.lineWeight,s.transparency=this.transparency,s.layer=this.layer,s.drawOrder=0,"thickness"in this&&(s.thickness=this.thickness);const n=this.subWorldDraw(t,e);return this.attachEntityInfo(n),n}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}getGeneralProperties(){return{groupName:"general",properties:[{name:"handle",type:"int",editable:!1,accessor:{get:()=>this.objectId}},{name:"color",type:"color",editable:!0,accessor:{get:()=>this.color,set:t=>{this.color.copy(t)}}},{name:"layer",type:"string",editable:!0,accessor:{get:()=>this.layer,set:t=>{this.layer=t}}},{name:"linetype",type:"linetype",editable:!0,accessor:{get:()=>this.lineType,set:t=>{this.lineType=t}}},{name:"linetypeScale",type:"float",editable:!0,accessor:{get:()=>this.linetypeScale,set:t=>{this.linetypeScale=t}}},{name:"lineWeight",type:"lineweight",editable:!0,accessor:{get:()=>this.lineWeight,set:t=>{this.lineWeight=t}}},{name:"transparency",type:"transparency",editable:!0,accessor:{get:()=>this.transparency,set:t=>{this.transparency=t}}}]}}get lineStyle(){var n;const{type:t,name:e}=this.getLineType(),s=(n=this.database)==null?void 0:n.tables.linetypeTable.getAt(e);return s?{type:t,...s.linetype}:{type:t,name:e,standardFlag:0,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==dt){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return{type:"ByLayer",name:t.linetype}}else return this.lineType==fe?{type:"ByBlock",name:Se}:{type:"UserSpecified",name:this.lineType};return{type:"UserSpecified",name:Se}}getLayerColor(){const t=this.database.tables.layerTable.getAt(this.layer);return t!=null?t.color:null}attachEntityInfo(t){t&&(t.objectId=this.objectId,this.attrs.has("ownerId")&&(t.ownerId=this.ownerId),t.layerName=this.layer,t.visible=this.visibility)}};Cr.typeName="Entity";let lt=Cr;const Or=class Or extends lt{};Or.typeName="Curve";let ht=Or;var rs=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.FitCurvePoly=1]="FitCurvePoly",i[i.QuadSplinePoly=2]="QuadSplinePoly",i[i.CubicSplinePoly=3]="CubicSplinePoly",i))(rs||{});const Nr=class Nr extends ht{get dxfTypeName(){return"POLYLINE"}constructor(t,e,s=0,n=!1,r=0,o=0,a=null){super(),this._polyType=t,this._elevation=s;const h=a&&(a==null?void 0:a.length)===e.length,c=e.map((d,u)=>({x:d.x,y:d.y,bulge:h?a[u]:void 0}));this._geo=new at(c,n)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get numberOfVertices(){return this._geo.numberOfVertices}getPointAt(t){return this._geo.getPointAt(t)}getBulgeAt(t){const e=this._geo.vertices[t];return(e==null?void 0:e.bulge)||0}get geometricExtents(){const t=this._geo.box;return new N({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this._geo.numberOfVertices;++e){const s=this._geo.getPointAt(e);t.push(new w(s.x,s.y,0))}return t}subGetOsnapPoints(t,e,s,n){switch(t){case z.EndPoint:for(let r=0;r<this._geo.numberOfVertices;++r){const o=this._geo.getPointAt(r);n.push(new w(o.x,o.y,0))}break}}transformBy(t){const e=t.determinant()<0;let s=this._elevation;return this._geo.vertices.forEach(n=>{const r=new w(n.x,n.y,this._elevation).applyMatrix4(t);n.x=r.x,n.y=r.y,s=r.z,e&&n.bulge!=null&&(n.bulge=-n.bulge)}),this._elevation=s,this._geo._boundingBoxNeedsUpdate=!0,this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=[];return this._geo.getPoints(100).forEach(n=>e.push(new w().set(n.x,n.y,this.elevation))),t.lines(e)}dxfOut(t,e=!1){super.dxfOut(t,e);for(let s=0;s<this.numberOfVertices;++s)t.writeStart("VERTEX"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbVertex"),t.writeSubclassMarker("AcDb2dVertex"),t.writePoint3d(10,{x:this.getPointAt(s).x,y:this.getPointAt(s).y,z:this.elevation}),t.writeDouble(42,this.getBulgeAt(s)),t.writeInt16(70,0);return t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDb2dPolyline");let e=this.closed?1:0;return this.polyType===1&&(e|=2),this.polyType===2&&(e|=4),this.polyType===3&&(e|=8),t.writeInt16(66,this.numberOfVertices>0?1:0),t.writeInt16(70,e),t.writeDouble(10,0),t.writeDouble(20,0),t.writeDouble(30,this.elevation),this}};Nr.typeName="2dPolyline";let Ni=Nr;var Ha=(i=>(i[i.Vertex=0]="Vertex",i[i.CurveFitVertex=1]="CurveFitVertex",i[i.SplineFitVertex=8]="SplineFitVertex",i[i.SplineCtlVertex=9]="SplineCtlVertex",i))(Ha||{});const Br=class Br extends lt{get dxfTypeName(){return"VERTEX"}constructor(){super(),this._position=new w,this._bulge=0,this._startWidth=0,this._endWidth=0,this._vertexType=0}get position(){return this._position}set position(t){this._position.copy(t)}get bulge(){return this._bulge}set bulge(t){this._bulge=t}get startWidth(){return this._startWidth}set startWidth(t){this._startWidth=t}get endWidth(){return this._endWidth}set endWidth(t){this._endWidth=t}get vertexType(){return this._vertexType}set vertexType(t){this._vertexType=t}get geometricExtents(){return new N().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subGetOsnapPoints(t,e,s,n){n.push(this._position)}transformBy(t){return this._position.applyMatrix4(t),this}subWorldDraw(t){}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbVertex"),t.writeSubclassMarker("AcDb2dVertex"),t.writePoint2d(10,this.position),t.writeDouble(40,this.startWidth),t.writeDouble(41,this.endWidth),t.writeDouble(42,this.bulge),t.writeInt16(70,this.vertexType),this}};Br.typeName="2dVertex";let Yn=Br;var Rs=(i=>(i[i.SimplePoly=0]="SimplePoly",i[i.QuadSplinePoly=1]="QuadSplinePoly",i[i.CubicSplinePoly=2]="CubicSplinePoly",i))(Rs||{});const Rr=class Rr extends ht{get dxfTypeName(){return"POLYLINE"}constructor(t,e,s=!1){super(),this._polyType=t,this._geo=new at(e,s)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}get numberOfVertices(){return this._geo.numberOfVertices}getPointAt(t){const e=this._geo.vertices[t];return new w(e.x,e.y,e.z||0)}get geometricExtents(){const t=this._geo.vertices.map(e=>new w(e.x,e.y,e.z||0));return new N().setFromPoints(t)}subGetGripPoints(){const t=new Array;for(let e=0;e<this._geo.numberOfVertices;++e){const s=this._geo.getPointAt(e);t.push(new w(s.x,s.y,0))}return t}subGetOsnapPoints(t,e,s,n){switch(t){case z.EndPoint:for(let r=0;r<this._geo.numberOfVertices;++r)n.push(this.getPointAt(r));break}}transformBy(t){return this._geo.vertices.forEach(e=>{const s=new w(e.x,e.y,e.z||0).applyMatrix4(t);e.x=s.x,e.y=s.y,e.z=s.z}),this._geo._boundingBoxNeedsUpdate=!0,this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=this._geo.vertices.map(s=>new w(s.x,s.y,s.z||0));return t.lines(e)}dxfOut(t,e=!1){super.dxfOut(t,e);for(let s=0;s<this.numberOfVertices;++s){const n=this.getPointAt(s);t.writeStart("VERTEX"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbVertex"),t.writeSubclassMarker("AcDb3dPolylineVertex"),t.writePoint3d(10,{x:n.x,y:n.y,z:n.z}),t.writeInt16(70,32)}return t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDb3dPolyline");let e=this.closed?1:0;return e|=8,this.polyType===1&&(e|=16),this.polyType===2&&(e|=32),t.writeInt16(66,this.numberOfVertices>0?1:0),t.writeInt16(70,e),this}};Rr.typeName="3dPolyline";let Bi=Rr;var Ga=(i=>(i[i.SimpleVertex=0]="SimpleVertex",i[i.ControlVertex=1]="ControlVertex",i[i.FitVertex=2]="FitVertex",i))(Ga||{});const Fr=class Fr extends lt{get dxfTypeName(){return"VERTEX"}constructor(){super(),this._position=new w,this._vertexType=0}get position(){return this._position}set position(t){this._position.copy(t)}get vertexType(){return this._vertexType}set vertexType(t){this._vertexType=t}get geometricExtents(){return new N().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subGetOsnapPoints(t,e,s,n){n.push(this._position)}transformBy(t){return this._position.applyMatrix4(t),this}subWorldDraw(t){}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbVertex"),t.writeSubclassMarker("AcDb3dPolylineVertex"),t.writePoint3d(10,this.position),t.writeInt16(70,this.vertexType|32),this}};Fr.typeName="3dVertex";let Xn=Fr;const zr=class zr extends ht{get dxfTypeName(){return"ARC"}constructor(t,e,s,n,r=_.Z_AXIS){super();const o=pr(r);this._geo=new Ie(t,e,s,n,r,o)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get startAngle(){return this._geo.startAngle}set startAngle(t){this._geo.startAngle=t}get endAngle(){return this._geo.endAngle}set endAngle(t){this._geo.endAngle=t}get normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get startPoint(){return this._geo.startPoint}get endPoint(){return this._geo.endPoint}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"arcLength",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"totalAngle",type:"float",editable:!1,accessor:{get:()=>k.radToDeg(Math.abs(this._geo.deltaAngle))}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.center),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,s,n){const r=this.startPoint,o=this.endPoint;switch(t){case z.EndPoint:n.push(r),n.push(o);break;case z.MidPoint:n.push(this.midPoint);break;case z.Nearest:{const a=this._geo.nearestPoint(e);n.push(a)}break;case z.Perpendicular:break;case z.Tangent:{const a=this._geo.tangentPoints(e);n.push(...a);break}}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){return t.circularArc(this._geo)}dxfOutFields(t){super.dxfOutFields(t);const e=Ws(this.center,this.normal);return t.writeSubclassMarker("AcDbArc"),t.writePoint3d(10,e),t.writeDouble(40,this.radius),t.writeAngle(50,Gn(this.center,this.startPoint,this.normal)),t.writeAngle(51,Gn(this.center,this.endPoint,this.normal)),t.writeVector3d(210,this.normal),this}};zr.typeName="Arc";let Ri=zr;var Ua=(i=>(i[i.LEFT=0]="LEFT",i[i.CENTER=1]="CENTER",i[i.RIGHT=2]="RIGHT",i[i.ALIGNED=3]="ALIGNED",i[i.MIDDLE=4]="MIDDLE",i[i.FIT=5]="FIT",i))(Ua||{}),Ya=(i=>(i[i.BASELINE=0]="BASELINE",i[i.BOTTOM=1]="BOTTOM",i[i.MIDDLE=2]="MIDDLE",i[i.TOP=3]="TOP",i))(Ya||{});const Vr=class Vr extends lt{get dxfTypeName(){return"TEXT"}constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new w,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=2,this._styleName="",this._widthFactor=1}get textString(){return this._textString}set textString(t){this._textString=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get height(){return this._height}set height(t){this._height=t}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get horizontalMode(){return this._horizontalMode}set horizontalMode(t){this._horizontalMode=t}get verticalMode(){return this._verticalModel}set verticalMode(t){this._verticalModel=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get widthFactor(){return this._widthFactor}set widthFactor(t){this._widthFactor=t}get geometricExtents(){return new N}subGetOsnapPoints(t,e,s,n){z.Insertion===t&&n.push(this._position)}transformBy(t){const e=this._position.clone(),s=this._position.clone().add(new _(Math.cos(this._rotation),Math.sin(this._rotation),0)),n=this._position.clone().add(new _(-Math.sin(this._rotation),Math.cos(this._rotation),0)),r=this._position.clone().add(new _(0,0,1));e.applyMatrix4(t),s.applyMatrix4(t),n.applyMatrix4(t),r.applyMatrix4(t);const o=new _(s).sub(e),a=new _(n).sub(e),h=new _(r).sub(e),c=a.length(),d=o.length(),u=h.length();return this._position.copy(e),d>0&&(this._rotation=Math.atan2(o.y,o.x)),c>0&&(this._height*=c,d>0&&(this._widthFactor*=d/c)),u>0&&(this._thickness*=u),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.textString,set:t=>{this.textString=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"widthFactor",type:"float",editable:!0,accessor:{get:()=>this.widthFactor,set:t=>{this.widthFactor=t}}},{name:"oblique",type:"float",editable:!0,accessor:{get:()=>this.oblique,set:t=>{this.oblique=t}}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable,e=t.getAt(this.styleName)??t.getAt(this.database.textstyle)??t.getAt(Z);if(!e)throw new Error("No valid text style found in text style table.");return e.textStyle}subWorldDraw(t,e){const s={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:Dt.BOTTOM_TO_TOP,attachmentPoint:ot.BottomLeft};return t.mtext(s,this.getTextStyle(),e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbText"),t.writePoint3d(10,this.position),t.writeDouble(39,this.thickness),t.writeDouble(40,this.height),t.writeString(1,this.textString),t.writeAngle(50,this.rotation),t.writeDouble(41,this.widthFactor),t.writeAngle(51,this.oblique),t.writeString(7,this.styleName),t.writeInt16(72,this.horizontalMode),t.writeInt16(73,this.verticalMode),t.writePoint3d(11,this.position),this}};Vr.typeName="Text";let cs=Vr;var tt=(i=>(i[i.Invisible=1]="Invisible",i[i.Const=2]="Const",i[i.Verifiable=4]="Verifiable",i[i.Preset=8]="Preset",i))(tt||{}),jt=(i=>(i[i.MultiLine=2]="MultiLine",i[i.ConstMultiLine=4]="ConstMultiLine",i))(jt||{});const Dr=class Dr extends cs{get dxfTypeName(){return"ATTDEF"}constructor(){super(),this._flags=0,this._prompt="",this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&1)!==0}set isInvisible(t){t?this._flags|=1:this._flags&=-2}get prompt(){return this._prompt}set prompt(t){this._prompt=t}get isConst(){return(this._flags&2)!==0}set isConst(t){t?this._flags|=2:this._flags&=-3}get isVerifiable(){return(this._flags&4)!==0}set isVerifiable(t){t?this._flags|=4:this._flags&=-5}get isPreset(){return(this._flags&8)!==0}set isPreset(t){t?this._flags|=8:this._flags&=-9}get isMTextAttribute(){return(this._mtextFlag&2)!==0}set isMTextAttribute(t){t?this._mtextFlag|=2:this._mtextFlag&=-3}get isConstMTextAttribute(){return(this._mtextFlag&4)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=4:this._mtextFlag&=-5}get tag(){return this._tag}set tag(t){this._tag=t}get fieldLength(){return this._fieldLength}set fieldLength(t){this._fieldLength=t}get lockPositionInBlock(){return this._lockPositionInBlock}set lockPositionInBlock(t){this._lockPositionInBlock=t}get isReallyLocked(){return this._isReallyLocked}set isReallyLocked(t){this._isReallyLocked=t}get mtext(){return this._mtext}set mtext(t){this._mtext=t,this.isMTextAttribute=t!=null}subWorldDraw(t){}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbAttributeDefinition"),t.writeString(3,this.prompt),t.writeString(2,this.tag),t.writeInt16(70,this.isInvisible?1:0),t.writeInt16(73,this.fieldLength),t.writeInt16(74,this.isReallyLocked?1:0),this}};Dr.typeName="AttDef";let Fi=Dr;const jr=class jr extends cs{get dxfTypeName(){return"ATTRIB"}constructor(){super(),this._flags=0,this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&tt.Invisible)!==0}set isInvisible(t){t?this._flags|=tt.Invisible:this._flags&=~tt.Invisible}get isConst(){return(this._flags&tt.Const)!==0}set isConst(t){t?this._flags|=tt.Const:this._flags&=~tt.Const}get isVerifiable(){return(this._flags&tt.Verifiable)!==0}set isVerifiable(t){t?this._flags|=tt.Verifiable:this._flags&=~tt.Verifiable}get isPreset(){return(this._flags&tt.Preset)!==0}set isPreset(t){t?this._flags|=tt.Preset:this._flags&=~tt.Preset}get isMTextAttribute(){return(this._mtextFlag&jt.MultiLine)!==0}set isMTextAttribute(t){t?this._mtextFlag|=jt.MultiLine:this._mtextFlag&=~jt.MultiLine}get isConstMTextAttribute(){return(this._mtextFlag&jt.ConstMultiLine)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=jt.ConstMultiLine:this._mtextFlag&=~jt.ConstMultiLine}get tag(){return this._tag}set tag(t){this._tag=t}get fieldLength(){return this._fieldLength}set fieldLength(t){this._fieldLength=t}get lockPositionInBlock(){return this._lockPositionInBlock}set lockPositionInBlock(t){this._lockPositionInBlock=t}get isReallyLocked(){return this._isReallyLocked}set isReallyLocked(t){this._isReallyLocked=t}get mtext(){return this._mtext}set mtext(t){this._mtext=t,this.isMTextAttribute=t!=null}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbAttribute"),t.writeInt16(70,this.isInvisible?1:0),t.writeInt16(73,this.fieldLength),t.writeString(2,this.tag),t.writeInt16(74,this.isReallyLocked?1:0),this.mtext&&t.writeInt16(71,this.isMTextAttribute?1:0),this}};jr.typeName="Attrib";let zi=jr;const Ds=class Ds extends lt{get dxfTypeName(){return"INSERT"}constructor(t){super(),this._blockName=t,this._position=new w,this._rotation=0,this._normal=new _(0,0,1),this._scaleFactors=new w(1,1,1),this._attribs=new Map}get position(){return this._position}set position(t){this._position.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scaleFactors(){return this._scaleFactors}set scaleFactors(t){this._scaleFactors.copy(t)}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}get blockName(){return this._blockName}get blockTableRecord(){return this.database.tables.blockTable.getAt(this._blockName)}appendAttributes(t){this._attribs.set(t.objectId,t),t.ownerId=this.objectId}attributeIterator(){return new ni(this._attribs)}get blockTransform(){const t=this.blockTableRecord,e=(t==null?void 0:t.origin)??w.ORIGIN,s=new D().makeTranslation(-e.x,-e.y,-e.z),n=new D().makeScale(this._scaleFactors.x,this._scaleFactors.y,this._scaleFactors.z),r=new ss().setFromAxisAngle(_.Z_AXIS,this._rotation),o=new D().makeRotationFromQuaternion(r),a=new D().makeTranslation(this._position.x,this._position.y,this._position.z);return new D().multiplyMatrices(a,o).multiply(n).multiply(s)}subGetOsnapPoints(t,e,s,n,r,o){const a=o??new D;z.Insertion===t?n.push(this.getInsertionPoint(a)):r&&this.subEntityGetOsnapPoints(t,e,s,n,r,a)}transformBy(t){const e=new D().setFromExtrusionDirection(this._normal),s=new D().makeRotationZ(this._rotation),n=new D().multiplyMatrices(e,s),r=this._position.clone(),o=new w(this._scaleFactors.x,0,0).applyMatrix4(n).add(r),a=new w(0,this._scaleFactors.y,0).applyMatrix4(n).add(r),h=new w(0,0,this._scaleFactors.z).applyMatrix4(n).add(r);r.applyMatrix4(t),o.applyMatrix4(t),a.applyMatrix4(t),h.applyMatrix4(t);const c=new _(o).sub(r),d=new _(a).sub(r),u=new _(h).sub(r);let p=new _().crossVectors(c,d);p.lengthSq()===0?p=this._normal.clone().transformDirection(t):p.normalize();const m=new D().setFromExtrusionDirection(p).clone().invert(),y=c.clone().applyMatrix4(m);return this._position.copy(r),this._normal.copy(p),this._rotation=Math.atan2(y.y,y.x),this._scaleFactors.set(c.length(),d.length(),u.length()),this._attribs.forEach(b=>b.transformBy(t)),this}get properties(){const t={type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"blockName",type:"float",editable:!1,accessor:{get:()=>this._blockName}},{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:e=>{this.position.x=e}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:e=>{this.position.y=e}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:e=>{this.position.z=e}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:e=>{this.rotation=e}}},{name:"scaleFactorsX",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.x,set:e=>{this.scaleFactors.x=e}}},{name:"scaleFactorsY",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.y,set:e=>{this.scaleFactors.y=e}}},{name:"scaleFactorsZ",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.z,set:e=>{this.scaleFactors.z=e}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:e=>{this.normal.x=e}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:e=>{this.normal.y=e}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:e=>{this.normal.z=e}}}]}]};if(this._attribs.size>0){const e={groupName:"attribute",properties:[]};t.groups.push(e),this._attribs.forEach(s=>{e.properties.push({name:s.tag,type:"string",editable:!s.isConst,skipTranslation:!0,accessor:{get:()=>s.textString,set:n=>{s.textString=n}}})})}return t}get geometricExtents(){const t=new N,e=this.blockTableRecord;if(e!=null){const n=e.newIterator();for(const r of n)t.union(r.geometricExtents)}const s=this.blockTransform;return t.applyMatrix4(s),t}subWorldDraw(t){const e=this.blockTableRecord;if(e!=null){const s=this.blockTransform,n=[];return this._attribs.forEach(o=>{if(!o.isInvisible){const a=o.worldDraw(t);a&&n.push(a)}}),es.instance.draw(t,e,this.rgbColor,n,!0,s,this._normal)}else return t.group([])}dxfOut(t,e=!1){super.dxfOut(t,e);let s=!1;for(const n of this.attributeIterator())s=!0,t.writeStart("ATTRIB"),n.dxfOut(t);return s&&(t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity")),this}subEntityGetOsnapPoints(t,e,s,n,r,o,a=new Set){if(r===this.objectId||a.has(this.objectId))return!1;a.add(this.objectId);try{const h=this.blockTableRecord;if(h==null)return!1;const c=new D().multiplyMatrices(o,this.getFullInsertionTransform());for(const d of h.newIterator()){if(d.objectId===r){const u=new w(e).applyMatrix4(c.clone().invert()),p=new w(s).applyMatrix4(c.clone().invert()),g=[];return d.subGetOsnapPoints(t,u,p,g,r,c),d instanceof Ds?g.forEach(m=>{n.push(m.clone())}):g.forEach(m=>{n.push(new w(m).applyMatrix4(c))}),!0}if(d instanceof Ds&&d.subEntityGetOsnapPoints(t,e,s,n,r,c,a))return!0}return!1}finally{a.delete(this.objectId)}}getInsertionPoint(t){var n;const e=((n=this.blockTableRecord)==null?void 0:n.origin)??w.ORIGIN,s=new D().multiplyMatrices(t,this.getFullInsertionTransform());return new w(e).applyMatrix4(s)}getFullInsertionTransform(){const t=new D().setFromExtrusionDirection(this._normal);return new D().multiplyMatrices(t,this.blockTransform)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbBlockReference"),t.writePoint3d(10,this.position),t.writeString(2,this.blockName),t.writeDouble(41,this.scaleFactors.x),t.writeDouble(42,this.scaleFactors.y),t.writeDouble(43,this.scaleFactors.z),t.writeAngle(50,this.rotation),t.writeVector3d(210,this.normal),this}};Ds.typeName="BlockReference";let Je=Ds;const Wr=class Wr extends ht{get dxfTypeName(){return"CIRCLE"}constructor(t,e,s=_.Z_AXIS){super();const n=pr(s);this._geo=new Ie(t,e,0,G,s,n)}get center(){return this._geo.center}set center(t){this._geo.center=t}get radius(){return this._geo.radius}set radius(t){this._geo.radius=t}get normal(){return this._geo.normal}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetOsnapPoints(t,e,s,n){switch(t){case z.Center:case z.Centroid:n.push(this._geo.center);break;case z.Quadrant:n.push(this._geo.getPointAtAngle(0)),n.push(this._geo.getPointAtAngle(Math.PI/2)),n.push(this._geo.getPointAtAngle(Math.PI)),n.push(this._geo.getPointAtAngle(Math.PI/2*3));break;case z.Nearest:{const r=this._geo.nearestPoint(e);n.push(r)}break;case z.Tangent:{const r=this._geo.tangentPoints(e);n.push(...r);break}}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:t=>{this.radius=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"diameter",type:"float",editable:!1,accessor:{get:()=>this._geo.radius*2}},{name:"perimeter",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.center),t}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){return t.circularArc(this._geo)}dxfOutFields(t){super.dxfOutFields(t);const e=Ws(this.center,this.normal);return t.writeSubclassMarker("AcDbCircle"),t.writePoint3d(10,e),t.writeDouble(40,this.radius),t.writeVector3d(210,this.normal),this}};Wr.typeName="Circle";let Vi=Wr;const Hr=class Hr extends ht{get dxfTypeName(){return"ELLIPSE"}constructor(t,e,s,n,r,o,a){super(),this._geo=new ls(t,e,s,n,r,o,a)}get center(){return this._geo.center}set center(t){this._geo.center=t}get majorAxisRadius(){return this._geo.majorAxisRadius}set majorAxisRadius(t){this._geo.majorAxisRadius=t}get minorAxisRadius(){return this._geo.minorAxisRadius}set minorAxisRadius(t){this._geo.minorAxisRadius=t}get startAngle(){return this._geo.startAngle}set startAngle(t){this._geo.startAngle=t}get endAngle(){return this._geo.endAngle}set endAngle(t){this._geo.endAngle=t}get normal(){return this._geo.normal}set normal(t){this._geo.normal=t}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetOsnapPoints(t,e,s,n){switch(t){case z.EndPoint:this.closed||(n.push(this._geo.startPoint),n.push(this._geo.endPoint));break;case z.MidPoint:this.closed||n.push(this._geo.midPoint);break;case z.Quadrant:this.closed&&(n.push(this._geo.getPointAtAngle(0)),n.push(this._geo.getPointAtAngle(Math.PI/2)),n.push(this._geo.getPointAtAngle(Math.PI)),n.push(this._geo.getPointAtAngle(Math.PI/2*3)));break}}transformBy(t){return this._geo.transform(t),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"majorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.majorAxisRadius,set:t=>{this.center.x=t}}},{name:"minorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.minorAxisRadius,set:t=>{this.minorAxisRadius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subWorldDraw(t){return t.ellipticalArc(this._geo)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbEllipse"),t.writePoint3d(10,this.center);const e=this._geo.majorAxis,s=this.majorAxisRadius;return t.writePoint3d(11,{x:e.x*s,y:e.y*s,z:e.z*s}),t.writeVector3d(210,this.normal),t.writeDouble(40,this.minorAxisRadius/this.majorAxisRadius),t.writeDouble(41,this.startAngle),t.writeDouble(42,this.endAngle),this}};Hr.typeName="Ellipse";let Di=Hr;const Gr=class Gr extends lt{get dxfTypeName(){return"3DFACE"}constructor(){super(),this._vertices=[new w,new w,new w],this._edgeInvisibilities=0}getVertexAt(t){return t<0?this._vertices[0]:t>this._vertices.length?this._vertices[this._vertices.length-1]:this._vertices[t]}setVertexAt(t,e){if(t<0&&this._vertices[0].copy(e),t>=3)return this._vertices.length===3&&this._vertices.push(new w),this._vertices[3].copy(e);this._vertices[t].copy(e)}setEdgeInvisibilities(t){this._edgeInvisibilities=t}isEdgeVisibleAt(t){if(t<0||t>3)throw new Error("Index out of range");return(this._edgeInvisibilities&1<<t)===0}makeEdgeInvisibleAt(t){if(t<0||t>3)throw new Error("Index out of range");this._edgeInvisibilities=this._edgeInvisibilities|1<<t}get geometricExtents(){return new N().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subGetOsnapPoints(t,e,s,n){switch(t){case z.EndPoint:n.push(...this._vertices);break}}transformBy(t){return this._vertices.forEach(e=>e.applyMatrix4(t)),this}subWorldDraw(t){const e=this._vertices.length,s=new Float32Array(e*3),n=new Uint16Array(e*2);for(let r=0;r<e;r++)s[r*3]=this._vertices[r].x,s[r*3+1]=this._vertices[r].y,s[r*3+2]=this._vertices[r].z,this.isEdgeVisibleAt(r)&&(n[r*2]=r,n[r*2+1]=(r+1)%4);return t.lineSegments(s,3,n)}dxfOutFields(t){super.dxfOutFields(t);const e=this.getVertexAt(0),s=this.getVertexAt(1),n=this.getVertexAt(2),r=this.getVertexAt(3);t.writeSubclassMarker("AcDbFace"),t.writePoint3d(10,e),t.writePoint3d(11,s),t.writePoint3d(12,n),t.writePoint3d(13,r);let o=0;for(let a=0;a<4;++a)this.isEdgeVisibleAt(a)||(o|=1<<a);return t.writeInt16(70,o),this}};Gr.typeName="Face";let ji=Gr;var Fs=(i=>(i[i.UserDefined=0]="UserDefined",i[i.Predefined=1]="Predefined",i[i.Custom=2]="Custom",i))(Fs||{}),Xa=(i=>(i[i.Normal=0]="Normal",i[i.Outer=1]="Outer",i[i.Ignore=2]="Ignore",i))(Xa||{}),br=(i=>(i[i.HatchObject=0]="HatchObject",i[i.GradientObject=1]="GradientObject",i))(br||{}),$a=(i=>(i[i.PreDefinedGradient=0]="PreDefinedGradient",i[i.UserDefinedGradient=1]="UserDefinedGradient",i))($a||{});const Ur=class Ur extends lt{constructor(){super(),this._gradientAngle=0,this._elevation=0,this._geo=new Pe,this._isSolidFill=!1,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0,this._hatchObjectType=0,this._gradientAngle=0,this._gradientShift=0,this._shadeTintValue=0,this._gradientStartColor=void 0,this._gradientEndColor=void 0,this._gradientType=0,this._gradientName="",this._gradientOneColorMode=!1}get dxfTypeName(){return"HATCH"}get isGradient(){return this._hatchObjectType===1}get isHatch(){return this._hatchObjectType===0}get isSolidFill(){return this._isSolidFill||this._patternName.toUpperCase()==="SOLID"}set isSolidFill(t){this._isSolidFill=t}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t}get patternType(){return this._patternType}set patternType(t){this._patternType=t}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get hatchObjectType(){return this._hatchObjectType}set hatchObjectType(t){this._hatchObjectType=t}get gradientAngle(){return this._gradientAngle}set gradientAngle(t){this._gradientAngle=t}get gradientShift(){return this._gradientShift}set gradientShift(t){this._gradientShift=t}get gradientType(){return this._gradientType}set gradientType(t){this._gradientType=t}get gradientName(){return this._gradientName}set gradientName(t){this._gradientName=t}get gradientOneColorMode(){return this._gradientOneColorMode}set gradientOneColorMode(t){this._gradientOneColorMode=t}get shadeTintValue(){return this._shadeTintValue}set shadeTintValue(t){this._shadeTintValue=t}get gradientStartColor(){return this._gradientStartColor}set gradientStartColor(t){this._gradientStartColor=t==null||!Number.isFinite(t)?void 0:t&16777215}get gradientEndColor(){return this._gradientEndColor}set gradientEndColor(t){this._gradientEndColor=t==null||!Number.isFinite(t)?void 0:t&16777215}add(t){this._geo.add(t)}buildAreasFromLoops(){const t=this._geo.loops;if(t.length===0)return[];if(t.length===1)return[this._geo];const e=this._geo.buildHierarchy(),s=[],n=(r,o)=>{if(r.index>=0&&o%2===0){const a=new Pe;a.add(t[r.index]),r.children.forEach(h=>{h.index>=0&&a.add(t[h.index])}),s.push(a)}r.children.forEach(a=>n(a,o+1))};return e.children.forEach(r=>n(r,0)),s.length>0?s:[this._geo]}getCalculatedAreaValue(){const t=this.buildAreasFromLoops();return t.length===0?0:t.reduce((e,s)=>e+s.area,0)}get geometricExtents(){const t=this.buildAreasFromLoops();if(t.length===0)return new N;const e=new N;return t.forEach(s=>{const n=s.box;e.union(new N({x:n.min.x,y:n.min.y,z:this._elevation},{x:n.max.x,y:n.max.y,z:this._elevation}))}),e}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"pattern",properties:[{name:"patternType",type:"enum",editable:!0,options:[{label:Fs[0],value:0},{label:Fs[1],value:1},{label:Fs[2],value:2}],accessor:{get:()=>this.patternType,set:t=>{this.patternType=t}}},{name:"patternName",type:"string",editable:!0,accessor:{get:()=>this.patternName,set:t=>{this.patternName=t}}},{name:"patternAngle",type:"float",editable:!0,accessor:{get:()=>this.patternAngle,set:t=>{this.patternAngle=t}}},{name:"patternScale",type:"float",editable:!0,accessor:{get:()=>this.patternScale,set:t=>{this.patternScale=t}}}]},{groupName:"geometry",properties:[{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this.getCalculatedAreaValue()}}]}]}}subWorldDraw(t){const e=t.subEntityTraits;e.fillType={solidFill:this.isSolidFill,patternAngle:this.patternAngle,definitionLines:this.definitionLines,gradient:this.isGradient?{name:this.gradientName,angle:this.gradientAngle,shift:this.gradientShift,oneColorMode:this.gradientOneColorMode,shadeTintValue:this.shadeTintValue,startColor:this.gradientStartColor,endColor:this.gradientEndColor}:void 0},e.drawOrder=-1;const s=this.buildAreasFromLoops();if(s.length===0)return t.area(this._geo);if(s.length===1)return t.area(s[0]);const n=s.map(r=>t.area(r));return t.group(n)}transformBy(t){const e=t.elements,s=new Js(e[0],e[4],e[12],e[1],e[5],e[13],0,0,1);this._geo.transform(s),this._elevation=new w(0,0,this._elevation).applyMatrix4(t).z;const n=new w(1,0,0).applyMatrix4(t),r=new w().applyMatrix4(t),o=new w(n).sub(r);if(o.length()>0){const a=Math.atan2(o.y,o.x);this._patternAngle+=a,this._gradientAngle+=a,this._patternScale*=o.length()}return this}dxfOutFields(t){super.dxfOutFields(t);const e=this._geo.loops;return t.writeSubclassMarker("AcDbHatch"),t.writePoint3d(10,{x:0,y:0,z:this.elevation}),t.writeVector3d(210,{x:0,y:0,z:1}),t.writeString(2,this.patternName||(this.isSolidFill?"SOLID":"USER")),t.writeInt16(70,this.isSolidFill?1:0),t.writeInt16(71,0),t.writeInt16(91,e.length),e.forEach((s,n)=>{const r=n===0;if(s instanceof at){const o=s.vertices,a=o.some(c=>(c.bulge??0)!==0);t.writeInt16(92,2),t.writeInt16(72,a?1:0),t.writeInt16(73,s.closed?1:0),t.writeInt16(93,o.length);for(const c of o)t.writePoint2d(10,c),a&&t.writeDouble(42,c.bulge??0);t.writeInt16(97,0);return}if(s instanceof Gs){const o=r?1:0;t.writeInt16(92,o),t.writeInt16(93,s.numberOfEdges);for(const a of s.curves){if(a instanceof Wt){t.writeInt16(72,1),t.writePoint2d(10,a.startPoint),t.writePoint2d(11,a.endPoint);continue}if(a instanceof Te){t.writeInt16(72,2),t.writePoint2d(10,a.center),t.writeDouble(40,a.radius),t.writeAngle(50,a.startAngle),t.writeAngle(51,a.endAngle),t.writeInt16(73,a.clockwise?0:1);continue}if(a instanceof Hs){t.writeInt16(72,3),t.writePoint2d(10,a.center);const h=new v(a.majorAxisRadius*Math.cos(a.rotation),a.majorAxisRadius*Math.sin(a.rotation));t.writePoint2d(11,h);const c=a.majorAxisRadius===0?0:a.minorAxisRadius/a.majorAxisRadius;t.writeDouble(40,c),t.writeAngle(50,a.startAngle),t.writeAngle(51,a.endAngle),t.writeInt16(73,a.clockwise?0:1);continue}if(a instanceof Ht){const h=a.knots,c=a.controlPoints,d=a.weights,u=a.fitPoints,p=d.some(g=>g!==1);t.writeInt16(72,4),t.writeInt16(94,a.degree),t.writeInt16(73,p?1:0),t.writeInt16(74,a.closed?1:0),t.writeInt16(95,h.length),t.writeInt16(96,c.length),h.forEach(g=>t.writeDouble(40,g)),c.forEach((g,m)=>{t.writePoint2d(10,g),p&&t.writeDouble(42,d[m]??1)}),t.writeInt16(97,(u==null?void 0:u.length)??0),u==null||u.forEach(g=>t.writePoint2d(11,g))}}t.writeInt16(97,0)}}),t.writeInt16(75,this.hatchStyle),t.writeInt16(76,this.patternType),t.writeAngle(52,this.patternAngle),t.writeDouble(41,this.patternScale),t.writeInt16(77,0),t.writeInt16(78,this.definitionLines.length),this.definitionLines.forEach(s=>{t.writeAngle(53,s.angle),t.writePoint2d(43,s.base),t.writePoint2d(45,s.offset),t.writeInt16(79,s.dashLengths.length),s.dashLengths.forEach(n=>t.writeDouble(49,n))}),this.isGradient&&(t.writeInt16(450,this._hatchObjectType),t.writeInt16(451,0),t.writeInt16(452,this._gradientOneColorMode?1:0),t.writeAngle(460,this._gradientAngle),t.writeDouble(461,this._gradientShift),t.writeString(470,this._gradientName)),t.writeInt16(98,0),this}};Ur.typeName="Hatch";let Us=Ur;var qa=(i=>(i[i.MText=0]="MText",i[i.Fcf=1]="Fcf",i[i.BlockReference=2]="BlockReference",i[i.NoAnnotation=3]="NoAnnotation",i))(qa||{});const Yr=class Yr extends ht{get dxfTypeName(){return"LEADER"}constructor(){super(),this._isSplined=!1,this._updated=!1,this._hasArrowHead=!1,this._vertices=[],this._dimensionStyle="",this._hasHookLine=!1,this._isHookLineSameDirection=!1,this._annoType=3,this._textHeight=0,this._textWidth=0,this._associatedAnnotation="",this._normal=new _(0,0,1),this._horizontalDirection=new _(1,0,0)}get isSplined(){return this._isSplined}set isSplined(t){this._isSplined=t}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(t){this._hasArrowHead=t}get hasHookLine(){return this._hasHookLine}set hasHookLine(t){this._hasHookLine=t}get isHookLineSameDirection(){return this._isHookLineSameDirection}set isHookLineSameDirection(t){this._isHookLineSameDirection=t}get numVertices(){return this._vertices.length}get vertices(){return this._vertices.map(t=>t.clone())}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t}get annoType(){return this._annoType}set annoType(t){this._annoType=t}get textHeight(){return this._textHeight}set textHeight(t){this._textHeight=t}get textWidth(){return this._textWidth}set textWidth(t){this._textWidth=t}get byBlockColor(){return this._byBlockColor}set byBlockColor(t){this._byBlockColor=t}get associatedAnnotation(){return this._associatedAnnotation}set associatedAnnotation(t){this._associatedAnnotation=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get horizontalDirection(){return this._horizontalDirection}set horizontalDirection(t){this._horizontalDirection.copy(t)}get offsetFromBlock(){var t;return(t=this._offsetFromBlock)==null?void 0:t.clone()}set offsetFromBlock(t){this._offsetFromBlock=t?new _(t):void 0}get offsetFromAnnotation(){var t;return(t=this._offsetFromAnnotation)==null?void 0:t.clone()}set offsetFromAnnotation(t){this._offsetFromAnnotation=t?new _(t):void 0}appendVertex(t){this._vertices.push(new w().copy(t)),this._updated=!0}setVertexAt(t,e){if(t<0||t>=this._vertices.length)throw new Error("The vertex index is out of range!");return this._vertices[t].copy(e),this._updated=!0,this}vertexAt(t){if(t<0||t>=this._vertices.length)throw new Error("The vertex index is out of range!");return this._vertices[t].clone()}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new N().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}transformBy(t){return this._vertices.forEach(e=>e.applyMatrix4(t)),this.transformVector(this._normal,t),this.transformVector(this._horizontalDirection,t),this._offsetFromBlock&&this.transformVector(this._offsetFromBlock,t),this._offsetFromAnnotation&&this.transformVector(this._offsetFromAnnotation,t),this._splineGeo?(this._splineGeo.transform(t),this._updated=!1):this._updated=!0,this}subWorldDraw(t){if(this.isSplined&&this.splineGeo){const e=this.splineGeo.getPoints(100);return t.lines(e)}else return t.lines(this._vertices)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new Ht(this._vertices,"Uniform"),this._updated=!1)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLeader"),t.writeString(3,this.dimensionStyle),t.writeInt16(71,this.hasArrowHead?1:0),t.writeInt16(72,this.isSplined?1:0),t.writeInt16(73,this.annoType),t.writeInt16(74,this.isHookLineSameDirection?1:0),t.writeInt16(75,this.hasHookLine?1:0),t.writeInt16(76,this.numVertices),this.textHeight!==0&&t.writeDouble(40,this.textHeight),this.textWidth!==0&&t.writeDouble(41,this.textWidth),this.byBlockColor!=null&&t.writeInt16(77,this.byBlockColor),this.associatedAnnotation&&t.writeHandle(340,this.associatedAnnotation);for(const e of this.vertices)t.writePoint3d(10,e);return t.writeVector3d(210,this.normal),t.writeVector3d(211,this.horizontalDirection),this._offsetFromBlock&&t.writeVector3d(212,this._offsetFromBlock),this._offsetFromAnnotation&&t.writeVector3d(213,this._offsetFromAnnotation),this}transformVector(t,e){const s=new w,n=new w(t.x,t.y,t.z);s.applyMatrix4(e),n.applyMatrix4(e),t.set(n.x-s.x,n.y-s.y,n.z-s.z)}};Yr.typeName="Leader";let Wi=Yr;var z=(i=>(i[i.EndPoint=1]="EndPoint",i[i.MidPoint=2]="MidPoint",i[i.Center=3]="Center",i[i.Node=4]="Node",i[i.Quadrant=5]="Quadrant",i[i.Insertion=7]="Insertion",i[i.Perpendicular=8]="Perpendicular",i[i.Tangent=9]="Tangent",i[i.Nearest=10]="Nearest",i[i.Centroid=11]="Centroid",i))(z||{});function Ac(i){let t=0;for(const e of i)t|=1<<e-1;return t}function Pc(i){const t=[];for(const e of Object.values(z)){if(typeof e!="number")continue;const s=1<<e-1;i&s&&t.push(e)}return t}function Tc(i,t){return i^1<<t-1}function Ec(i,t){return(i&1<<t-1)!==0}function Lc(i,t){return i|1<<t-1}function Mc(i,t){return i&~(1<<t-1)}const Xr=class Xr extends ht{get dxfTypeName(){return"LINE"}constructor(t,e){super(),this._geo=new Ee(t,e)}get startPoint(){return this._geo.startPoint}set startPoint(t){this._geo.startPoint=t}get endPoint(){return this._geo.endPoint}set endPoint(t){this._geo.endPoint=t}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"startX",type:"float",editable:!0,accessor:{get:()=>this.startPoint.x,set:t=>{this.startPoint.x=t}}},{name:"startY",type:"float",editable:!0,accessor:{get:()=>this.startPoint.y,set:t=>{this.startPoint.y=t}}},{name:"startZ",type:"float",editable:!0,accessor:{get:()=>this.startPoint.z,set:t=>{this.startPoint.z=t}}},{name:"endX",type:"float",editable:!0,accessor:{get:()=>this.endPoint.x,set:t=>{this.endPoint.x=t}}},{name:"endY",type:"float",editable:!0,accessor:{get:()=>this.endPoint.y,set:t=>{this.endPoint.y=t}}},{name:"endZ",type:"float",editable:!0,accessor:{get:()=>this.endPoint.z,set:t=>{this.endPoint.z=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.midPoint),t.push(this.startPoint),t.push(this.endPoint),t}subGetOsnapPoints(t,e,s,n){const r=this.startPoint,o=this.endPoint;switch(t){case z.EndPoint:n.push(r),n.push(o);break;case z.MidPoint:n.push(this.midPoint);break;case z.Nearest:{const a=this._geo.project(e);n.push(a)}break;case z.Perpendicular:{const a=this._geo.perpPoint(e);n.push(a)}break;case z.Tangent:break}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){const e=this.startPoint,s=this.endPoint,n=[new w(e.x,e.y,0),new w(s.x,s.y,0)];return t.lines(n)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbLine"),t.writePoint3d(10,this.startPoint),t.writePoint3d(11,this.endPoint),this}};Xr.typeName="Line";let Ys=Xr;var Za=(i=>(i[i.Top=0]="Top",i[i.Zero=1]="Zero",i[i.Bottom=2]="Bottom",i))(Za||{}),Ka=(i=>(i[i.HasVertex=1]="HasVertex",i[i.Closed=2]="Closed",i[i.SuppressStartCaps=4]="SuppressStartCaps",i[i.SuppressEndCaps=8]="SuppressEndCaps",i))(Ka||{});const $r=class $r extends lt{get dxfTypeName(){return"MLINE"}constructor(){super(),this._styleName="",this._styleObjectHandle="",this._scale=1,this._justification=1,this._flags=0,this._styleCount=0,this._startPosition=new w,this._normal=new _(0,0,1),this._segments=[]}get styleName(){return this._styleName||this.getDefaultStyleName()}set styleName(t){this._styleName=t}get styleObjectHandle(){return this._styleObjectHandle}set styleObjectHandle(t){this._styleObjectHandle=t}get scale(){return this._scale}set scale(t){this._scale=t}get justification(){return this._justification}set justification(t){this._justification=t}get flags(){return this._flags}set flags(t){this._flags=t}get styleCount(){return this._styleCount}set styleCount(t){this._styleCount=Math.max(0,t)}get startPosition(){return this._startPosition}set startPosition(t){this._startPosition.copy(t)}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get segments(){return this._segments.map(t=>this.cloneSegment(t))}set segments(t){this._segments=t.map(e=>this.createSegment(e)),this.updateHasVertexFlag()}get vertexCount(){return this._segments.length}get closed(){return(this._flags&2)!==0}set closed(t){this.setFlag(2,t)}get suppressStartCaps(){return(this._flags&4)!==0}set suppressStartCaps(t){this.setFlag(4,t)}get suppressEndCaps(){return(this._flags&8)!==0}set suppressEndCaps(t){this.setFlag(8,t)}appendSegment(t){this._segments.push(this.createSegment(t)),this.updateHasVertexFlag()}clearSegments(){this._segments=[],this.updateHasVertexFlag()}get geometricExtents(){const t=this.collectGeometryPoints();return new N().setFromPoints(t)}transformBy(t){return this._startPosition.applyMatrix4(t),this._segments.forEach(e=>{e.position.applyMatrix4(t),this.transformVector(e.direction,t),this.transformVector(e.miterDirection,t)}),this.transformVector(this._normal,t),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"mline",properties:[{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"scale",type:"float",editable:!0,accessor:{get:()=>this.scale,set:t=>{this.scale=t}}},{name:"justification",type:"int",editable:!0,accessor:{get:()=>this.justification,set:t=>{this.justification=t}}},{name:"closed",type:"boolean",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}},{name:"vertexCount",type:"int",editable:!1,accessor:{get:()=>this.vertexCount}}]}]}}subWorldDraw(t){if(this._segments.length===0)return;const e=[],s=this.getMLineStyle(),n=this.getRenderableElementCount(s),r=t.subEntityTraits,o=r.color,a=r.rgbColor,h=r.lineType,c=r.fillType,d=r.drawOrder,u=this.createFillArea(s,n);if(u&&(r.color=o,r.rgbColor=a,this.applyFillTraits(s,r),r.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},r.drawOrder=-1,e.push(t.area(u)),r.fillType=c,r.drawOrder=d),n<=0){const p=this.getReferencePath();p.length>=2&&e.push(t.lines(p))}else{for(let p=0;p<n;p++){r.color=o,r.rgbColor=a,r.lineType=h,this.applyStyleElementTraits(s,p,r);const g=this.getElementPath(p,s);g.length>=2&&e.push(t.lines(g))}this.appendStyleDrivenJointAndCapEntities(t,e,s,n,o,a,h)}if(r.color=o,r.rgbColor=a,r.lineType=h,r.fillType=c,r.drawOrder=d,e.length!==0)return e.length===1?e[0]:t.group(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMline"),t.writeString(2,this.styleName),t.writeHandle(340,this._styleObjectHandle),t.writeDouble(40,this._scale),t.writeInt16(70,this._justification),t.writeInt16(71,this._flags),t.writeInt16(72,this.vertexCount),t.writeInt16(73,this._styleCount),t.writePoint3d(10,this._startPosition),t.writeVector3d(210,this._normal),this._segments.forEach(e=>{t.writePoint3d(11,e.position),t.writeVector3d(12,e.direction),t.writeVector3d(13,e.miterDirection),e.elements.forEach(s=>{t.writeInt16(74,s.parameterCount),s.parameters.forEach(n=>t.writeDouble(41,n)),t.writeInt16(75,s.fillCount),s.fillParameters.forEach(n=>t.writeDouble(42,n))})}),this}setFlag(t,e){e?this._flags|=t:this._flags&=~t}updateHasVertexFlag(){this.setFlag(1,this._segments.length>0)}createSegment(t){var e;return{position:new w().copy(t.position),direction:new _().copy(t.direction),miterDirection:new _().copy(t.miterDirection),elements:((e=t.elements)==null?void 0:e.map(s=>this.createElement(s)))??[]}}createElement(t){const e=t.parameters?[...t.parameters]:[],s=t.fillParameters?[...t.fillParameters]:[];return{parameterCount:t.parameterCount??e.length,parameters:e,fillCount:t.fillCount??s.length,fillParameters:s}}cloneSegment(t){return{position:t.position.clone(),direction:t.direction.clone(),miterDirection:t.miterDirection.clone(),elements:t.elements.map(e=>({parameterCount:e.parameterCount,parameters:[...e.parameters],fillCount:e.fillCount,fillParameters:[...e.fillParameters]}))}}collectGeometryPoints(){const t=[this._startPosition];if(this._segments.length===0)return t;const e=this.getMLineStyle(),s=this.getRenderableElementCount(e);if(s<=0)return this._segments.forEach(n=>t.push(n.position)),t;for(let n=0;n<s;n++)t.push(...this.getElementPath(n,e));return t}getRenderableElementCount(t){const e=(t==null?void 0:t.elementCount)??0;return Math.max(this._styleCount,e,...this._segments.map(s=>s.elements.length),0)}getReferencePath(){const t=[this._startPosition.clone(),...this._segments.map(e=>e.position.clone())];return this.closePathIfNeeded(t)}getElementPath(t,e){const s=[],n=this._segments[0];return s.push(this.getElementBoundaryPoint("start",n,t,e)),this._segments.forEach(r=>{s.push(this.offsetPoint(r.position,r.miterDirection,this.getElementMiterOffset(r,t,e)))}),s[s.length-1]=this.getElementBoundaryPoint("end",this._segments[this._segments.length-1],t,e),this.closePathIfNeeded(s)}getElementMiterOffset(t,e,s){var r;const n=t.elements[e];return(r=n==null?void 0:n.parameters)!=null&&r.length?n.parameters[0]:this.getStyleElementOffset(e,s)}getElementBoundaryPoint(t,e,s,n){const r=this.getElementMiterOffset(e,s,n),o=t==="start"?this._startPosition:e.position,a=this.offsetPoint(o,e.miterDirection,r);if(!this.shouldApplyCapCutAtSide(t,n))return a;const h=t==="start"?n==null?void 0:n.startAngle:n==null?void 0:n.endAngle,c=this.computeCapCutDistance(r,h,t);if(c===0)return a;const d=t==="start"?this.getStartSegmentDirection():this.getEndSegmentDirection();return d.lengthSq()===0?a:a.add(d.multiplyScalar(c))}shouldApplyCapCutAtSide(t,e){return!e||this.closed?!1:t==="start"?this.suppressStartCaps?!1:(e.flags&112)!==0:this.suppressEndCaps?!1:(e.flags&1792)!==0}computeCapCutDistance(t,e,s){const n=this.normalizeCapAngle(e),r=Math.tan(n);if(Math.abs(r)<1e-6)return 0;const o=t/r;return o}normalizeCapAngle(t){if(t==null||!Number.isFinite(t))return Math.PI/2;let e=t%180;return e<0&&(e+=180),(e<1||e>179)&&(e=90),e*Math.PI/180}getStartSegmentDirection(){const t=this._segments[0],e=new _;return t&&(e.subVectors(t.position,this._startPosition),e.lengthSq()===0&&e.copy(t.direction)),e.lengthSq()>0&&e.normalize(),e}getEndSegmentDirection(){const t=this._segments[this._segments.length-1];if(!t)return new _;const e=new _,s=this._segments.length>1?this._segments[this._segments.length-2].position:this._startPosition;return e.subVectors(t.position,s),e.lengthSq()===0&&e.copy(t.direction),e.lengthSq()>0&&e.normalize(),e}createFillArea(t,e){if(!t||!(t.flags&1)||e<2)return;const s=this.getFillBoundaryElementIndices(e,t);if(!s)return;const n=this.getElementPath(s.outerIndex,t),r=this.getElementPath(s.innerIndex,t),o=this.stripClosingPoint(n),a=this.stripClosingPoint(r);if(o.length<2||a.length<2)return;const h=new Pe;if(this.closed){if(o.length<3||a.length<3)return;h.add(new at(o.map(c=>({x:c.x,y:c.y})),!0)),h.add(new at(a.map(c=>({x:c.x,y:c.y})),!0))}else{const c=[...o,...a.slice().reverse()].map(d=>({x:d.x,y:d.y}));if(c.length<3)return;h.add(new at(c,!0))}return h}getFillBoundaryElementIndices(t,e){let s=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,r=-1,o=-1;for(let a=0;a<t;a++){const h=this.getElementReferenceOffset(a,e);h<s&&(s=h,r=a),h>n&&(n=h,o=a)}if(!(r<0||o<0||r===o))return{outerIndex:o,innerIndex:r}}getElementReferenceOffset(t,e){var n;const s=this._segments[0];if(s){const r=s.elements[t];if((n=r==null?void 0:r.parameters)!=null&&n.length)return r.parameters[0]}return this.getStyleElementOffset(t,e)}getStyleElementOffset(t,e){const s=e==null?void 0:e.elements[t];if(!s)return 0;const n=this.getStyleJustificationShift(e);return(s.offset+n)*this._scale}getStyleJustificationShift(t){const e=(t==null?void 0:t.elements)??[];if(e.length<=0)return 0;let s=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;for(const r of e){const o=r.offset;o<s&&(s=o),o>n&&(n=o)}return this._justification===0?-n:this._justification===2?-s:0}stripClosingPoint(t){if(t.length<2)return t;const e=t[0],s=t[t.length-1],n=1e-9;return Math.abs(e.x-s.x)<=n&&Math.abs(e.y-s.y)<=n&&Math.abs(e.z-s.z)<=n?t.slice(0,-1):t}offsetPoint(t,e,s){if(s===0||e.lengthSq()===0)return t.clone();const n=e.clone().normalize().multiplyScalar(s);return t.clone().add(n)}closePathIfNeeded(t){if(!this.closed||t.length<2)return t;const e=t[0],s=t[t.length-1],n=1e-9;return Math.abs(e.x-s.x)<=n&&Math.abs(e.y-s.y)<=n&&Math.abs(e.z-s.z)<=n||t.push(e.clone()),t}appendStyleDrivenJointAndCapEntities(t,e,s,n,r,o,a){!s||n<2||(e.push(...this.drawMiterJointEntities(t,s,n,r,o,a)),e.push(...this.drawCapEntities(t,s,n,r,o,a)))}drawMiterJointEntities(t,e,s,n,r,o){if(this.closed||this._segments.length<2||!(e.flags&2))return[];const a=[],h=t.subEntityTraits;for(let c=0;c<this._segments.length-1;c++){const d=this._segments[c],u=Array.from({length:s},(p,g)=>{const m=this.getElementMiterOffset(d,g,e);return{elementIndex:g,offset:m,point:this.offsetPoint(d.position,d.miterDirection,m)}}).sort((p,g)=>g.offset-p.offset);for(let p=0;p<u.length-1;p++)this.applyElementDrawTraits(h,n,r,o,e,u[p].elementIndex),a.push(t.lines([u[p].point,u[p+1].point]))}return a}drawCapEntities(t,e,s,n,r,o){if(this.closed||this._segments.length<=0)return[];const a=[];return a.push(...this.drawCapEntitiesForSide(t,"start",e,s,n,r,o)),a.push(...this.drawCapEntitiesForSide(t,"end",e,s,n,r,o)),a}drawCapEntitiesForSide(t,e,s,n,r,o,a){if(e==="start"&&this.suppressStartCaps)return[];if(e==="end"&&this.suppressEndCaps)return[];const h=s.flags,c=e==="start",d=c?(h&16)!==0:(h&256)!==0,u=c?(h&64)!==0:(h&1024)!==0,p=c?(h&32)!==0:(h&512)!==0;if(!d&&!u&&!p)return[];const g=this.getCapElementPoints(e,n,s);if(g.length<2)return[];const m=[],y=t.subEntityTraits;if(d)for(let x=0;x<g.length-1;x++)this.applyElementDrawTraits(y,r,o,a,s,g[x].elementIndex),m.push(t.lines([g[x].point,g[x+1].point]));const b=c?this.getStartSegmentDirection().multiplyScalar(-1):this.getEndSegmentDirection().clone();if(u){const x=this.drawCapArcBetweenElements(t,e,g[0],g[g.length-1],b,y,r,o,a,s);x&&m.push(x)}if(p)for(let x=1;x<Math.floor(g.length/2);x++){const I=g[x],S=g[g.length-1-x];if(!I||!S||I===S)continue;const L=this.drawCapArcBetweenElements(t,e,I,S,b,y,r,o,a,s);L&&m.push(L)}return m}getCapElementPoints(t,e,s){const n=t==="start"?this._segments[0]:this._segments[this._segments.length-1];return n?Array.from({length:e},(r,o)=>({elementIndex:o,offset:this.getElementMiterOffset(n,o,s),point:this.getElementBoundaryPoint(t,n,o,s)})).sort((r,o)=>o.offset-r.offset):[]}drawCapArcBetweenElements(t,e,s,n,r,o,a,h,c,d){const u=e==="end"?n.point:s.point,p=e==="end"?s.point:n.point,g=u.distanceTo(p);if(g<=1e-9||r.lengthSq()===0)return;const y=u.clone().add(new _().subVectors(p,u).multiplyScalar(.5)).add(r.clone().normalize().multiplyScalar(g/2)),b=Ie.createByThreePoints(u,p,y);if(b)return this.applyElementDrawTraits(o,a,h,c,d,e==="end"?n.elementIndex:s.elementIndex),t.circularArc(b)}applyElementDrawTraits(t,e,s,n,r,o){t.color=e,t.rgbColor=s,t.lineType=n,this.applyStyleElementTraits(r,o,t)}transformVector(t,e){const s=new w,n=new w(t.x,t.y,t.z);s.applyMatrix4(e),n.applyMatrix4(e),t.set(n.x-s.x,n.y-s.y,n.z-s.z)}getMLineStyle(){var r;const t=this.database.objects.mlineStyle,e=this.styleObjectHandle?t.getIdAt(this.styleObjectHandle):void 0;if(e)return e;const s=this.styleName?t.getAt(this.styleName):void 0;if(s)return s;const n=(r=this.styleName)==null?void 0:r.toUpperCase();if(n)for(const[o,a]of t.entries()){const h=(a.styleName||o).toUpperCase();if(o.toUpperCase()===n||h===n)return a}}applyStyleElementTraits(t,e,s){const n=t==null?void 0:t.elements[e];if(!n)return;const r=this.resolveStyleElementLineType(n.lineType);r&&(s.lineType=r),!(n.color.isByBlock||n.color.isByLayer)&&(s.color=n.color.clone(),s.rgbColor=n.color.RGB??this.rgbColor)}applyFillTraits(t,e){const s=t==null?void 0:t.fillColor;!s||s.isByBlock||s.isByLayer||(e.color=s.clone(),e.rgbColor=s.RGB??this.rgbColor)}resolveStyleElementLineType(t){var c;const e=t==null?void 0:t.trim();if(!e)return;const s=e.toUpperCase(),n=dt.toUpperCase(),r=fe.toUpperCase();let o="UserSpecified",a=e;if(s===n){o="ByLayer";const d=(c=this.database.tables.layerTable.getAt(this.layer))==null?void 0:c.linetype;a=d&&d.toUpperCase()!==n&&d.toUpperCase()!==r?d:Se}else s===r&&(o="ByBlock",a=Se);const h=this.database.tables.linetypeTable.getAt(a);return h?{type:o,...h.linetype}:{type:o,name:a,standardFlag:0,description:"",totalPatternLength:0}}resolveEffectiveProperties(){super.resolveEffectiveProperties(),this._styleName||(this._styleName=this.getDefaultStyleName())}getDefaultStyleName(){try{return this.database.cmlstyle||ce}catch{return ce}}};$r.typeName="MLine";let Hi=$r;var hs=(i=>(i[i.InvisibleLeader=0]="InvisibleLeader",i[i.StraightLeader=1]="StraightLeader",i[i.SplineLeader=2]="SplineLeader",i))(hs||{}),ue=(i=>(i[i.NoneContent=0]="NoneContent",i[i.BlockContent=1]="BlockContent",i[i.MTextContent=2]="MTextContent",i[i.ToleranceContent=3]="ToleranceContent",i))(ue||{}),Qa=(i=>(i[i.Horizontal=0]="Horizontal",i[i.Vertical=1]="Vertical",i))(Qa||{}),Ja=(i=>(i[i.Unknown=0]="Unknown",i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.Top=3]="Top",i[i.Bottom=4]="Bottom",i))(Ja||{});const kc=1,vc=2,Cc=4,Oc=8,Nc=64,Bc=128,Rc=32768,qr=class qr extends lt{get dxfTypeName(){return"MULTILEADER"}constructor(){super(),this._leaders=[],this._leaderLineType=1,this._contentType=0,this._doglegEnabled=!1,this._doglegLength=0,this._doglegVector=new _(1,0,0),this._normal=new _(0,0,1),this._mleaderStyleId="",this._textHeight=2.5,this._textWidth=0,this._textRotation=0,this._textDirection=new _(1,0,0),this._textStyleName="",this._textAttachmentPoint=ot.MiddleLeft,this._textDrawingDirection=Dt.LEFT_TO_RIGHT,this._textLineSpacingFactor=1,this._textAttachmentDirection=0,this._arrowheadOverrides=[],this._blockAttributes=[]}get leaders(){return this._leaders.map(t=>this.cloneLeader(t))}get numberOfLeaders(){return this._leaders.length}get leaderLineType(){return this._leaderLineType}set leaderLineType(t){this._leaderLineType=t}get contentType(){return this._contentType}set contentType(t){this._contentType=t}get doglegEnabled(){return this._doglegEnabled}set doglegEnabled(t){this._doglegEnabled=t}get doglegLength(){return this._doglegLength}set doglegLength(t){this._doglegLength=t}get doglegVector(){return this._doglegVector}set doglegVector(t){this._doglegVector.copy(t)}get landingPoint(){return this._landingPoint}set landingPoint(t){this._landingPoint=t?this.createPoint(t):void 0}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get mleaderStyleId(){return this._mleaderStyleId}set mleaderStyleId(t){this._mleaderStyleId=t}get version(){return this._version}set version(t){this._version=t}get leaderStyleId(){return this._leaderStyleId}set leaderStyleId(t){this._leaderStyleId=t}get propertyOverrideFlag(){return this._propertyOverrideFlag}set propertyOverrideFlag(t){this._propertyOverrideFlag=t}get leaderLineColor(){return this._leaderLineColor}set leaderLineColor(t){this._leaderLineColor=t}get leaderLineTypeId(){return this._leaderLineTypeId}set leaderLineTypeId(t){this._leaderLineTypeId=t}get leaderLineWeight(){return this._leaderLineWeight}set leaderLineWeight(t){this._leaderLineWeight=t}get landingEnabled(){return this._landingEnabled}set landingEnabled(t){this._landingEnabled=t}get arrowheadId(){return this._arrowheadId}set arrowheadId(t){this._arrowheadId=t}get arrowheadSize(){return this._arrowheadSize}set arrowheadSize(t){this._arrowheadSize=t}get textStyleId(){return this._textStyleId}set textStyleId(t){this._textStyleId=t}get textLeftAttachmentType(){return this._textLeftAttachmentType}set textLeftAttachmentType(t){this._textLeftAttachmentType=t}get textRightAttachmentType(){return this._textRightAttachmentType}set textRightAttachmentType(t){this._textRightAttachmentType=t}get textAngleType(){return this._textAngleType}set textAngleType(t){this._textAngleType=t}get textAlignmentType(){return this._textAlignmentType}set textAlignmentType(t){this._textAlignmentType=t}get textColor(){return this._textColor}set textColor(t){this._textColor=t}get textFrameEnabled(){return this._textFrameEnabled}set textFrameEnabled(t){this._textFrameEnabled=t}get landingGap(){return this._landingGap}set landingGap(t){this._landingGap=t}get textAttachment(){return this._textAttachment}set textAttachment(t){this._textAttachment=t}get textFlowDirection(){return this._textFlowDirection}set textFlowDirection(t){this._textFlowDirection=t}get blockContentId(){return this._blockContentId}set blockContentId(t){this._blockContentId=t}get blockContentColor(){return this._blockContentColor}set blockContentColor(t){this._blockContentColor=t}get blockContentScale(){return this._blockContentScale}set blockContentScale(t){this._blockContentScale=t}get blockContentRotation(){return this._blockContentRotation}set blockContentRotation(t){this._blockContentRotation=t}get blockContentConnectionType(){return this._blockContentConnectionType}set blockContentConnectionType(t){this._blockContentConnectionType=t}get annotativeScaleEnabled(){return this._annotativeScaleEnabled}set annotativeScaleEnabled(t){this._annotativeScaleEnabled=t}get arrowheadOverrides(){return this._arrowheadOverrides}set arrowheadOverrides(t){this._arrowheadOverrides=t}get blockAttributes(){return this._blockAttributes}set blockAttributes(t){this._blockAttributes=t}get textDirectionNegative(){return this._textDirectionNegative}set textDirectionNegative(t){this._textDirectionNegative=t}get textAlignInIPE(){return this._textAlignInIPE}set textAlignInIPE(t){this._textAlignInIPE=t}get bottomTextAttachmentDirection(){return this._bottomTextAttachmentDirection}set bottomTextAttachmentDirection(t){this._bottomTextAttachmentDirection=t}get topTextAttachmentDirection(){return this._topTextAttachmentDirection}set topTextAttachmentDirection(t){this._topTextAttachmentDirection=t}get contentScale(){return this._contentScale}set contentScale(t){this._contentScale=t}get contentBasePosition(){return this._contentBasePosition}set contentBasePosition(t){this._contentBasePosition=t}get textAnchor(){return this._textAnchor}set textAnchor(t){this._textAnchor=t}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(t){this._textLineSpacingStyle=t}get textBackgroundColor(){return this._textBackgroundColor}set textBackgroundColor(t){this._textBackgroundColor=t}get textBackgroundScaleFactor(){return this._textBackgroundScaleFactor}set textBackgroundScaleFactor(t){this._textBackgroundScaleFactor=t}get textBackgroundTransparency(){return this._textBackgroundTransparency}set textBackgroundTransparency(t){this._textBackgroundTransparency=t}get textBackgroundColorOn(){return this._textBackgroundColorOn}set textBackgroundColorOn(t){this._textBackgroundColorOn=t}get textFillOn(){return this._textFillOn}set textFillOn(t){this._textFillOn=t}get textColumnType(){return this._textColumnType}set textColumnType(t){this._textColumnType=t}get textUseAutoHeight(){return this._textUseAutoHeight}set textUseAutoHeight(t){this._textUseAutoHeight=t}get textColumnWidth(){return this._textColumnWidth}set textColumnWidth(t){this._textColumnWidth=t}get textColumnGutterWidth(){return this._textColumnGutterWidth}set textColumnGutterWidth(t){this._textColumnGutterWidth=t}get textColumnFlowReversed(){return this._textColumnFlowReversed}set textColumnFlowReversed(t){this._textColumnFlowReversed=t}get textColumnHeight(){return this._textColumnHeight}set textColumnHeight(t){this._textColumnHeight=t}get textUseWordBreak(){return this._textUseWordBreak}set textUseWordBreak(t){this._textUseWordBreak=t}get hasMText(){return this._hasMText}set hasMText(t){this._hasMText=t}get hasBlock(){return this._hasBlock}set hasBlock(t){this._hasBlock=t}get planeOrigin(){return this._planeOrigin}set planeOrigin(t){this._planeOrigin=t}get planeXAxisDirection(){return this._planeXAxisDirection}set planeXAxisDirection(t){this._planeXAxisDirection=t}get planeYAxisDirection(){return this._planeYAxisDirection}set planeYAxisDirection(t){this._planeYAxisDirection=t}get planeNormalReversed(){return this._planeNormalReversed}set planeNormalReversed(t){this._planeNormalReversed=t}get leaderSections(){return this.leaders}get blockContentData(){return this.blockContent}get mtextContent(){return this._mtextContent?{text:this._mtextContent.text,anchorPoint:this._mtextContent.anchorPoint.clone()}:void 0}set mtextContent(t){if(!t){this._mtextContent=void 0,this._contentType===2&&(this._contentType=0);return}this._mtextContent={text:t.text,anchorPoint:this.createPoint(t.anchorPoint)},this._contentType=2}get contents(){var t;return((t=this._mtextContent)==null?void 0:t.text)??""}set contents(t){this._mtextContent?this._mtextContent.text=t:this._mtextContent={text:t,anchorPoint:new w},this._contentType=2}get textLocation(){var t;return(t=this._mtextContent)==null?void 0:t.anchorPoint}set textLocation(t){if(!t){this._mtextContent=void 0;return}this._mtextContent?this._mtextContent.anchorPoint.copy(t):this._mtextContent={text:"",anchorPoint:this.createPoint(t)},this._contentType=2}get textHeight(){return this._textHeight}set textHeight(t){this._textHeight=t}get textWidth(){return this._textWidth}set textWidth(t){this._textWidth=t}get textRotation(){return this._textRotation}set textRotation(t){this._textRotation=t}get textDirection(){return this._textDirection}set textDirection(t){this._textDirection.copy(t)}get textStyleName(){return this._textStyleName}set textStyleName(t){this._textStyleName=t}get textAttachmentPoint(){return this._textAttachmentPoint}set textAttachmentPoint(t){this._textAttachmentPoint=t}get textDrawingDirection(){return this._textDrawingDirection}set textDrawingDirection(t){this._textDrawingDirection=t}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(t){this._textLineSpacingFactor=t}get textAttachmentDirection(){return this._textAttachmentDirection}set textAttachmentDirection(t){this._textAttachmentDirection=t}get blockContent(){var t,e;return this._blockContent?{blockContentId:this._blockContent.blockContentId,blockHandle:this._blockContent.blockHandle,normal:(t=this._blockContent.normal)==null?void 0:t.clone(),position:(e=this._blockContent.position)==null?void 0:e.clone(),scale:this._blockContent.scale.clone(),rotation:this._blockContent.rotation,color:this._blockContent.color,transformationMatrix:[...this._blockContent.transformationMatrix]}:void 0}set blockContent(t){if(!t){this._blockContent=void 0,this._contentType===1&&(this._contentType=0);return}this._blockContent={blockContentId:t.blockContentId??t.blockHandle,blockHandle:t.blockHandle,normal:t.normal?new _(t.normal):void 0,position:t.position?this.createPoint(t.position):void 0,scale:new _(t.scale??{x:1,y:1,z:1}),rotation:t.rotation??0,color:t.color,transformationMatrix:t.transformationMatrix?[...t.transformationMatrix]:[]},this.blockContentId=this._blockContent.blockContentId,this._contentType=1}addLeader(t={}){var s,n;const e={lastLeaderLinePoint:t.lastLeaderLinePoint?this.createPoint(t.lastLeaderLinePoint):void 0,lastLeaderLinePointSet:t.lastLeaderLinePointSet,landingPoint:t.landingPoint?this.createPoint(t.landingPoint):void 0,doglegVector:t.doglegVector?new _(t.doglegVector):void 0,doglegVectorSet:t.doglegVectorSet,doglegLength:t.doglegLength,breaks:((s=t.breaks)==null?void 0:s.map(r=>({index:r.index,start:this.createPoint(r.start),end:this.createPoint(r.end)})))??[],leaderBranchIndex:t.leaderBranchIndex,directionType:t.directionType,leaderLines:[]};return(n=t.leaderLines)==null||n.forEach(r=>{e.leaderLines.push(this.createLeaderLine(r))}),this._leaders.push(e),this._leaders.length-1}removeLeader(t){return this.checkLeaderIndex(t),this._leaders.splice(t,1),this}addLeaderLine(t,e=[]){return this.checkLeaderIndex(t),this._leaders[t].leaderLines.push(this.createLeaderLine({vertices:e})),this._leaders[t].leaderLines.length-1}appendVertex(t,e,s){return this.getMutableLeaderLine(t,e).vertices.push(this.createPoint(s)),this}setLeaderLineVertices(t,e,s){return this.getMutableLeaderLine(t,e).vertices=s.map(n=>this.createPoint(n)),this}getLeaderLineVertices(t,e){return this.getMutableLeaderLine(t,e).vertices.map(s=>s.clone())}addBreak(t,e,s,n){return this.getMutableLeaderLine(t,e).breaks.push({start:this.createPoint(s),end:this.createPoint(n)}),this}setLandingPoint(t,e){return this.checkLeaderIndex(t),this._leaders[t].landingPoint=e?this.createPoint(e):void 0,this}setDoglegDirection(t,e){return this.checkLeaderIndex(t),this._leaders[t].doglegVector=new _(e),this}setDoglegLength(t,e){return this.checkLeaderIndex(t),this._leaders[t].doglegLength=e,this}get geometricExtents(){const t=this.collectGeometryPoints();return t.length>0?new N().setFromPoints(t):new N}subGetGripPoints(){return this.collectGeometryPoints().map(t=>t.clone())}transformBy(t){var e,s,n,r,o,a,h,c;return this._leaders.forEach(d=>{var u,p;(u=d.lastLeaderLinePoint)==null||u.applyMatrix4(t),(p=d.landingPoint)==null||p.applyMatrix4(t),d.doglegVector&&this.transformVector(d.doglegVector,t),d.breaks.forEach(g=>{g.start.applyMatrix4(t),g.end.applyMatrix4(t)}),d.leaderLines.forEach(g=>{g.vertices.forEach(m=>m.applyMatrix4(t)),g.breaks.forEach(m=>{m.start.applyMatrix4(t),m.end.applyMatrix4(t)})})}),(e=this._landingPoint)==null||e.applyMatrix4(t),(s=this.contentBasePosition)==null||s.applyMatrix4(t),this.transformVector(this._doglegVector,t),this.transformVector(this._normal,t),(n=this.textAnchor)==null||n.applyMatrix4(t),(r=this._mtextContent)==null||r.anchorPoint.applyMatrix4(t),this.transformVector(this._textDirection,t),(a=(o=this._blockContent)==null?void 0:o.position)==null||a.applyMatrix4(t),(h=this._blockContent)!=null&&h.normal&&this.transformVector(this._blockContent.normal,t),this.blockContentScale&&this.transformVector(this.blockContentScale,t),(c=this.planeOrigin)==null||c.applyMatrix4(t),this.planeXAxisDirection&&this.transformVector(this.planeXAxisDirection,t),this.planeYAxisDirection&&this.transformVector(this.planeYAxisDirection,t),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"leader",properties:[{name:"contentType",type:"enum",editable:!0,options:[{label:ue[0],value:0},{label:ue[1],value:1},{label:ue[2],value:2},{label:ue[3],value:3}],accessor:{get:()=>this.contentType,set:t=>{this.contentType=t}}},{name:"leaderLineType",type:"enum",editable:!0,options:[{label:hs[0],value:0},{label:hs[1],value:1},{label:hs[2],value:2}],accessor:{get:()=>this.leaderLineType,set:t=>{this.leaderLineType=t}}},{name:"doglegEnabled",type:"boolean",editable:!0,accessor:{get:()=>this.doglegEnabled,set:t=>{this.doglegEnabled=t}}},{name:"doglegLength",type:"float",editable:!0,accessor:{get:()=>this.doglegLength,set:t=>{this.doglegLength=t}}},{name:"leaderCount",type:"int",editable:!1,accessor:{get:()=>this.numberOfLeaders}}]},{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:t=>{this.contents=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.textHeight,set:t=>{this.textHeight=t}}},{name:"textWidth",type:"float",editable:!0,accessor:{get:()=>this.textWidth,set:t=>{this.textWidth=t}}},{name:"textStyleName",type:"string",editable:!0,accessor:{get:()=>this.textStyleName,set:t=>{this.textStyleName=t}}}]}]}}resolveEffectiveProperties(){if(super.resolveEffectiveProperties(),this._mleaderStyleId)return;const t=this.getDefaultMLeaderStyle();t&&(this._mleaderStyleId=t.objectId)}subWorldDraw(t){const e=[],s=t.subEntityTraits,n=s.color,r=s.rgbColor,o=s.lineType,a=s.lineWeight,h=this.getResolvedLeaderLineColor(),c=this.getResolvedLeaderLineStyle(),d=this.getResolvedLeaderLineWeight(),u=this.getResolvedTextColor();this.getResolvedLeaderLineType()!==0&&(this.applyColorTraits(s,h,n,r),this.applyLineTraits(s,c,d),this._leaders.forEach(g=>{g.leaderLines.forEach(y=>{const b=this.getLeaderLineDrawPoints(g,y);if(b.length>0){const x=this.drawLeaderLine(t,b);x&&e.push(x)}});const m=this.getDoglegPoints(g);m&&e.push(t.lines(m))}));const p=this.getRenderableMTextContent();if(this.contentType===2&&p){this.applyColorTraits(s,u,n,r);const g=this.getResolvedTextHeight(),m={text:p.text,height:g,width:this.getMTextRenderWidth(p.text,g),position:p.anchorPoint,rotation:this.textRotation,directionVector:this.textDirection,attachmentPoint:this.textAttachmentPoint,drawingDirection:this.textDrawingDirection,lineSpaceFactor:this.textLineSpacingFactor};e.push(t.mtext(m,this.getTextStyle(),!1))}if(s.color=n,s.rgbColor=r,s.lineType=o,s.lineWeight=a,e.length!==0)return e.length===1?e[0]:t.group(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMLeader"),t.writeInt16(170,this.leaderLineType),t.writeBoolean(290,this.doglegEnabled),t.writeDouble(41,this.doglegLength),t.writeInt16(172,this.contentType),t.writeVector3d(210,this.normal),t.writeHandle(340,this.mleaderStyleId),this._landingPoint&&t.writePoint3d(10,this._landingPoint),t.writeVector3d(11,this.doglegVector),this._mtextContent&&(t.writeString(1,this._mtextContent.text),t.writePoint3d(12,this._mtextContent.anchorPoint),t.writeDouble(40,this.textHeight),t.writeDouble(42,this.textWidth),t.writeAngle(50,this.textRotation),t.writeString(7,this.textStyleName)),this._blockContent&&(t.writeHandle(341,this._blockContent.blockContentId??""),this._blockContent.position&&t.writePoint3d(15,this._blockContent.position),t.writeVector3d(16,this._blockContent.scale),t.writeAngle(52,this._blockContent.rotation)),this._leaders.forEach(e=>{e.landingPoint&&t.writePoint3d(110,e.landingPoint),e.doglegVector&&t.writeVector3d(111,e.doglegVector),t.writeDouble(140,e.doglegLength),t.writeInt16(171,e.leaderLines.length),e.leaderLines.forEach(s=>{t.writeInt16(90,s.vertices.length),s.vertices.forEach(n=>t.writePoint3d(10,n))})}),this}createPoint(t){return new w().copy(t)}createLeaderLine(t){var e,s;return{vertices:((e=t.vertices)==null?void 0:e.map(n=>this.createPoint(n)))??[],breakPointIndexes:t.breakPointIndexes?[...t.breakPointIndexes]:[],leaderLineIndex:t.leaderLineIndex,breaks:((s=t.breaks)==null?void 0:s.map(n=>({index:n.index,start:this.createPoint(n.start),end:this.createPoint(n.end)})))??[]}}cloneLeader(t){var e,s,n;return{lastLeaderLinePoint:(e=t.lastLeaderLinePoint)==null?void 0:e.clone(),lastLeaderLinePointSet:t.lastLeaderLinePointSet,landingPoint:(s=t.landingPoint)==null?void 0:s.clone(),doglegVector:(n=t.doglegVector)==null?void 0:n.clone(),doglegVectorSet:t.doglegVectorSet,doglegLength:t.doglegLength,breaks:t.breaks.map(r=>({index:r.index,start:r.start.clone(),end:r.end.clone()})),leaderBranchIndex:t.leaderBranchIndex,directionType:t.directionType,leaderLines:t.leaderLines.map(r=>({vertices:r.vertices.map(o=>o.clone()),breakPointIndexes:[...r.breakPointIndexes],leaderLineIndex:r.leaderLineIndex,breaks:r.breaks.map(o=>({index:o.index,start:o.start.clone(),end:o.end.clone()}))}))}}checkLeaderIndex(t){if(t<0||t>=this._leaders.length)throw new Error("The leader index is out of range!")}getMutableLeaderLine(t,e){this.checkLeaderIndex(t);const s=this._leaders[t].leaderLines[e];if(!s)throw new Error("The leader line index is out of range!");return s}collectGeometryPoints(){var e;const t=[];return this._leaders.forEach(s=>{s.lastLeaderLinePoint&&t.push(s.lastLeaderLinePoint),s.landingPoint&&t.push(s.landingPoint),s.breaks.forEach(r=>t.push(r.start,r.end)),s.leaderLines.forEach(r=>{t.push(...r.vertices),r.breaks.forEach(o=>t.push(o.start,o.end))});const n=this.getDoglegPoints(s);n&&t.push(...n),s.leaderLines.forEach(r=>{const o=this.getArrowheadPoints(this.getLeaderLineDrawPoints(s,r));o&&t.push(...o)})}),this._landingPoint&&t.push(this._landingPoint),this.contentBasePosition&&t.push(this.contentBasePosition),this.textAnchor&&t.push(this.textAnchor),this._mtextContent&&t.push(this._mtextContent.anchorPoint),(e=this._blockContent)!=null&&e.position&&t.push(this._blockContent.position),this.planeOrigin&&t.push(this.planeOrigin),t}getLeaderLineDrawPoints(t,e){if(e.vertices.length>=2)return e.vertices;if(e.vertices.length===0)return[];const s=t.lastLeaderLinePoint??t.landingPoint??this._landingPoint??this.contentBasePosition;return!s||e.vertices[0].equals(s)?e.vertices:[e.vertices[0],s]}getDoglegPoints(t){if(!this.getResolvedDoglegEnabled())return;const e=t.lastLeaderLinePoint??t.landingPoint??this._landingPoint,s=t.doglegVector??this._doglegVector,n=t.doglegLength??this.getResolvedDoglegLength();if(!e||n==null||n===0||s.lengthSq()===0)return;const r=e.clone().add(s.clone().normalize().multiplyScalar(n));return[e,r]}getArrowheadPoints(t){if(!this.isArrowheadVisible()||t.length<2)return;const e=this.getArrowheadFrame(t);if(!e)return;const s=this.getResolvedArrowheadSize(),{tip:n,unit:r}=e,o=n.clone().add(r.clone().multiplyScalar(s)),a=s/6,h=new _(-r.y,r.x,0),c=o.clone().add(h.clone().multiplyScalar(a)),d=o.clone().add(h.clone().multiplyScalar(-a));return[n,c,d,n]}isArrowheadVisible(){const t=this.getResolvedArrowheadId();return(t==null?void 0:t.toUpperCase())==="_NONE"?!1:this.getResolvedArrowheadSize()>0}drawLeaderLine(t,e){const s=[],n=this.getLeaderLinePointsForDraw(e);n.length>=2&&s.push(t.lines(n));const r=this.drawArrowhead(t,e);if(r&&s.push(r),s.length!==0)return s.length===1?s[0]:t.group(s)}getLeaderLinePointsForDraw(t){const e=this.getArrowheadLeaderLineTrimDistance();return e<=0?t:this.trimPolylineStart(t,e)}getArrowheadLeaderLineTrimDistance(){if(!this.isArrowheadVisible())return 0;const t=this.getResolvedArrowheadBlockTableRecord();if(!t)return 0;const e=this.getResolvedArrowheadSize();if(e<=0)return 0;const s=t.origin??w.ORIGIN;let n=s.x;for(const r of t.newIterator()){const o=r.geometricExtents;o.isEmpty()||o.max.x>n&&(n=o.max.x)}return Math.max(0,(n-s.x)*e)}trimPolylineStart(t,e){if(t.length<2||e<=0)return t;let s=e;for(let n=0;n<t.length-1;n++){const r=t[n],o=t[n+1],a=o.distanceTo(r);if(!(a<=0)){if(s<a){const h=new _().subVectors(o,r);return[r.clone().add(h.multiplyScalar(s/a)),...t.slice(n+1)]}s-=a}}return[t[t.length-1]]}drawArrowhead(t,e){if(!this.isArrowheadVisible())return;const s=this.drawArrowheadBlock(t,e);if(s)return s;const n=this.getArrowheadPoints(e);if(!n)return;const r=new Pe;r.add(new at(n,!0));const o=t.subEntityTraits,a=o.fillType;o.fillType={solidFill:!0,patternAngle:0,definitionLines:[]};const h=t.area(r);return o.fillType=a,h}drawArrowheadBlock(t,e){const s=this.getResolvedArrowheadBlockTableRecord();if(!s)return;const n=this.getArrowheadFrame(e);if(!n)return;const{tip:r,unit:o}=n,a=this.getResolvedArrowheadSize(),h=Math.atan2(o.y,o.x),c=s.origin??w.ORIGIN,d=new D().makeTranslation(-c.x,-c.y,-c.z),u=new D().makeScale(a,a,a),p=new D().makeRotationZ(h),g=new D().makeTranslation(r.x,r.y,r.z),m=new D().multiplyMatrices(g,p).multiply(u).multiply(d);return es.instance.draw(t,s,this.rgbColor,[],!0,m,new _(this.normal))}getArrowheadFrame(t){if(t.length<2)return;const e=t[0],s=t.find(r=>!r.equals(e));if(!s)return;const n=new _().subVectors(s,e);if(n.lengthSq()!==0)return{tip:e,unit:n.normalize()}}getResolvedArrowheadId(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.arrowSymbolId;return this.arrowheadId??t}getResolvedArrowheadBlockTableRecord(){const t=this.getResolvedArrowheadId();if(t)return this.database.tables.blockTable.getIdAt(t)}getResolvedArrowheadSize(){const t=this.getMLeaderStyle(),e=(t==null?void 0:t.arrowSize)??(t==null?void 0:t.scale);return this.arrowheadSize??this.contentScale??e??this.getResolvedTextHeight()}getResolvedTextHeight(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.textHeight;return this.textHeight>0?this.textHeight:t!=null&&t>0?t:2.5}getRenderableMTextContent(){var s;if(this._mtextContent)return{text:this._mtextContent.text,anchorPoint:this._mtextContent.anchorPoint};const t=(s=this.getMLeaderStyle())==null?void 0:s.defaultMTextContents,e=this.textAnchor??this.contentBasePosition??this._landingPoint;if(!(!t||!e))return{text:t,anchorPoint:e}}getMTextRenderWidth(t,e){if(this._textWidth>0)return this._textWidth;if(!t)return this._textWidth;const s=t.replace(/\\[PpNn]/g,`
4
- `).replace(/\\[A-Za-z][^;]*;/g,"").replace(/[{}]/g,""),n=Math.max(...s.split(/\r\n|\r|\n/g).map(r=>r.length),1);return Math.max(e,n*e)}transformVector(t,e){const s=new w,n=new w(t.x,t.y,t.z);s.applyMatrix4(e),n.applyMatrix4(e),t.set(n.x-s.x,n.y-s.y,n.z-s.z)}getMLeaderStyle(){const t=this.database.objects.mleaderStyle,e=this.mleaderStyleId||this.leaderStyleId;if(e){const s=t.getIdAt(e);if(s)return s}return this.getDefaultMLeaderStyle()}getDefaultMLeaderStyle(){const t=this.resolveMLeaderStyleByName(this.getDefaultMLeaderStyleName());return t||this.database.objects.mleaderStyle.newIterator().toArray()[0]}resolveMLeaderStyleByName(t){const e=t==null?void 0:t.trim();if(!e)return;const s=this.database.objects.mleaderStyle,n=s.getAt(e);if(n)return n;const r=s.getIdAt(e);if(r)return r;const o=e.toUpperCase();for(const[a,h]of s.entries())if(a.toUpperCase()===o)return h}getDefaultMLeaderStyleName(){try{return this.database.cmleaderstyle||de}catch{return de}}getResolvedTextStyleName(){var r,o;const t=this.database.tables.textStyleTable,e=(r=this.getMLeaderStyle())==null?void 0:r.textStyleId,s=e?(o=t.getIdAt(e))==null?void 0:o.name:void 0;if(this.textStyleName)return this.textStyleName;const n=this.textStyleId?t.getIdAt(this.textStyleId):void 0;return n!=null&&n.name?n.name:s}getTextStyle(){const t=this.database.tables.textStyleTable,e=this.getResolvedTextStyleName(),s=(e?t.getAt(e):void 0)??t.getAt(this.database.textstyle)??t.getAt(Z);if(!s)throw new Error("No valid text style found in text style table.");return s.textStyle}getResolvedLeaderLineColor(){var t;return this.getResolvedComponentColor(this.leaderLineColor,(t=this.getMLeaderStyle())==null?void 0:t.leaderLineColor,vc)}getResolvedLeaderLineType(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.leaderLineType;return this.getResolvedStyleDrivenValue(this.leaderLineType,t,kc)}getResolvedLeaderLineTypeId(){var t;return this.getResolvedStyleDrivenValue(this.leaderLineTypeId,(t=this.getMLeaderStyle())==null?void 0:t.leaderLineTypeId,Cc)}getResolvedLeaderLineStyle(){const t=this.getResolvedLeaderLineTypeId();if(!t)return;const e=this.database.tables.linetypeTable.getIdAt(t);if(e)return{type:"UserSpecified",...e.linetype}}getResolvedLeaderLineWeight(){var s;const t=(s=this.getMLeaderStyle())==null?void 0:s.leaderLineWeight,e=this.getResolvedStyleDrivenValue(this.leaderLineWeight,t,Oc);if(e!=null)return e}getResolvedDoglegEnabled(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.doglegEnabled;return this.getResolvedStyleDrivenValue(this.doglegEnabled,t,Nc)}getResolvedDoglegLength(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.doglegLength;return this.getResolvedStyleDrivenValue(this.doglegLength,t,Bc)}getResolvedTextColor(){var t;return this.getResolvedComponentColor(this.textColor,(t=this.getMLeaderStyle())==null?void 0:t.textColor,Rc)}getResolvedComponentColor(t,e,s){const n=t!=null?zs(t):void 0;if(!n)return e;const r=this.isPropertyOverrideEnabled(s);return r===!0?n:r===!1?e??n:!n.isByBlock&&!n.isByLayer?n:e??n}getResolvedStyleDrivenValue(t,e,s){const n=this.isPropertyOverrideEnabled(s);return n===!0?t??e:e??t}isPropertyOverrideEnabled(t){if(this.propertyOverrideFlag!=null)return(this.propertyOverrideFlag&t)!==0}applyColorTraits(t,e,s,n){t.color=s,t.rgbColor=n,e&&(t.color=e,t.rgbColor=this.resolveColorToRgb(e))}applyLineTraits(t,e,s){e&&(t.lineType=e),s!=null&&(t.lineWeight=s)}resolveColorToRgb(t){if(t.isByLayer){const e=this.getLayerColor();return(e==null?void 0:e.RGB)!=null?e.RGB:this.rgbColor}return t.isByBlock?this.rgbColor:t.RGB??this.rgbColor}};qr.typeName="MLeader";let Gi=qr;const Zr=class Zr extends lt{get dxfTypeName(){return"MTEXT"}constructor(){super(),this._contents="",this._height=0,this._width=0,this._lineSpacingFactor=.25,this._lineSpacingStyle=0,this._backgroundFill=!1,this._backgroundFillColor=13158600,this._backgroundFillTransparency=1,this._backgroundScaleFactor=1,this._rotation=0,this._styleName="",this._location=new w,this._attachmentPoint=ot.TopLeft,this._direction=new _(1,0,0),this._drawingDirection=Dt.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(t){this._contents=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(t){this._lineSpacingFactor=t}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(t){this._lineSpacingStyle=t}get backgroundFill(){return this._backgroundFill}set backgroundFill(t){this._backgroundFill=t,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(t){this._backgroundFillColor=t}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(t){this._backgroundFillTransparency=t}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(t){this._backgroundScaleFactor=t}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get location(){return this._location}set location(t){this._location.copy(t)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get direction(){return this._direction}set direction(t){this._direction.copy(t)}get drawingDirection(){return this._drawingDirection}set drawingDirection(t){this._drawingDirection=t}get geometricExtents(){return new N}subGetOsnapPoints(t,e,s,n){z.Insertion===t&&n.push(this._location)}transformBy(t){const e=this._location.clone(),s=this._direction.lengthSq()>0?this._direction.clone().normalize():new _(Math.cos(this._rotation),Math.sin(this._rotation),0),n=new _(-s.y,s.x,s.z);n.lengthSq()===0&&n.set(0,1,0),n.normalize();const r=e.clone().add(s),o=e.clone().add(n);e.applyMatrix4(t),r.applyMatrix4(t),o.applyMatrix4(t);const a=new _(r).sub(e),h=new _(o).sub(e),c=a.length(),d=h.length();return this._location.copy(e),c>0&&(this._direction.copy(a).normalize(),this._rotation=Math.atan2(this._direction.y,this._direction.x),this._width*=c),d>0&&(this._height*=d),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:t=>{this.contents=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"attachmentPoint",type:"enum",editable:!0,options:[{label:ot[1],value:1},{label:ot[2],value:2},{label:ot[3],value:3},{label:ot[4],value:4},{label:ot[5],value:5},{label:ot[6],value:6},{label:ot[7],value:7},{label:ot[8],value:8},{label:ot[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:t=>{this.attachmentPoint=t}}},{name:"drawingDirection",type:"enum",editable:!0,options:[{label:Dt[1],value:1},{label:Dt[2],value:2},{label:Dt[3],value:3},{label:Dt[4],value:4},{label:Dt[5],value:5}],accessor:{get:()=>this.drawingDirection,set:t=>{this.drawingDirection=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"lineSpacingFactor",type:"float",editable:!0,accessor:{get:()=>this.lineSpacingFactor,set:t=>{this.lineSpacingFactor=t}}},{name:"definedWidth",type:"float",editable:!0,accessor:{get:()=>this.width,set:t=>{this.width=t}}},{name:"directionX",type:"float",editable:!0,accessor:{get:()=>this.direction.x,set:t=>{this.direction.x=t}}},{name:"directionY",type:"float",editable:!0,accessor:{get:()=>this.direction.y,set:t=>{this.direction.y=t}}},{name:"directionZ",type:"float",editable:!0,accessor:{get:()=>this.direction.z,set:t=>{this.direction.z=t}}}]},{groupName:"geometry",properties:[{name:"locationX",type:"float",editable:!0,accessor:{get:()=>this.location.x,set:t=>{this.location.x=t}}},{name:"locationY",type:"float",editable:!0,accessor:{get:()=>this.location.y,set:t=>{this.location.y=t}}},{name:"locationZ",type:"float",editable:!0,accessor:{get:()=>this.location.z,set:t=>{this.location.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable,e=t.getAt(this.styleName)??t.getAt(this.database.textstyle)??t.getAt(Z);if(!e)throw new Error("No valid text style found in text style table.");return e.textStyle}subWorldDraw(t,e){const s={text:this.contents,height:this.height,width:this.width,position:this.location,rotation:this.rotation,directionVector:this.direction,attachmentPoint:this.attachmentPoint,drawingDirection:this.drawingDirection,lineSpaceFactor:this.lineSpacingFactor};return t.mtext(s,this.getTextStyle(),e)}encodeMTextContentsForDxf(t){return t.replace(/\r\n|\r|\n/g,"\\P")}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMText"),t.writePoint3d(10,this.location),t.writeDouble(40,this.height),t.writeDouble(41,this.width),t.writeString(1,this.encodeMTextContentsForDxf(this.contents)),t.writeString(7,this.styleName),t.writeAngle(50,this.rotation),t.writeVector3d(11,this.direction),t.writeInt16(71,this.attachmentPoint),t.writeInt16(72,this.drawingDirection),t.writeInt16(73,this.lineSpacingStyle),t.writeDouble(44,this.lineSpacingFactor),this.backgroundFill&&(t.writeInt16(90,1),t.writeInt32(63,this.backgroundFillColor),t.writeInt32(441,this.backgroundFillTransparency),t.writeDouble(45,this.backgroundScaleFactor)),this}};Zr.typeName="MText";let Xs=Zr;const Kr=class Kr extends ht{get dxfTypeName(){return"SPLINE"}constructor(t,e,s,n,r){super(),this.rebuild(t,e,s,n,r)}rebuild(t,e,s,n,r){const o=+(t!==void 0)+ +(e!==void 0)+ +(s!==void 0)+ +(n!==void 0)+ +(r!==void 0);if(o<2||o>5)throw wt.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new Ht(t,e,s,n):this._geo=new Ht(t,e,s,n,r)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}subGetOsnapPoints(t,e,s,n){switch(t){case z.EndPoint:n.push(this._geo.startPoint),n.push(this._geo.endPoint);break}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){const e=this._geo.getPoints(100);return t.lines(e)}dxfOutFields(t){var s;const e=this._geo;super.dxfOutFields(t),t.writeSubclassMarker("AcDbSpline"),t.writeInt16(70,this.closed?1:0),t.writeInt16(71,e.degree),t.writeInt16(72,e.knots.length),t.writeInt16(73,e.controlPoints.length),t.writeInt16(74,((s=e.fitPoints)==null?void 0:s.length)??0);for(const n of e.knots)t.writeDouble(40,n);for(const n of e.weights)t.writeDouble(41,n);for(const n of e.controlPoints)t.writePoint3d(10,n);for(const n of e.fitPoints??[])t.writePoint3d(11,n);return this}};Kr.typeName="Spline";let $s=Kr;const Fc=new _,Qr=class Qr extends Je{get dxfTypeName(){return"ACAD_TABLE"}constructor(t,e,s){super(t),this._attachmentPoint=ot.TopLeft,this._numColumns=s,this._numRows=e,this._columnWidth=new Array(s),this._rowHeight=new Array(e),this._cells=new Array(e*s)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get numRows(){return this._numRows}set numRows(t){this._numRows=t}get numColumns(){return this._numColumns}set numColumns(t){this._numColumns=t}numContents(t,e){return 1}rowHeight(t){return this._rowHeight[t]}setRowHeight(t,e){this._rowHeight[t]=e}setUniformRowHeight(t){this._rowHeight.fill(t)}columnWidth(t){return this._columnWidth[t]}setUniformColumnWidth(t){this._columnWidth.fill(t)}setColumnWidth(t,e){this._columnWidth[t]=e}cell(t){if(!(t<0||t>=this._cells.length))return this._cells[t]}setCell(t,e){this._cells[t]=e}textString(t,e,s){var r;const n=t*this._numColumns+e;return(r=this._cells[n])==null?void 0:r.text}setTextString(t,e,s){const n=t*this._numColumns+e;if(!this._cells[n]){this._cells[n]={text:s,attachmentPoint:this._attachmentPoint,cellType:1,textHeight:0};return}this._cells[n].text=s}isEmpty(t,e){var n;const s=t*this._numColumns+e;return!((n=this._cells[s])!=null&&n.text)}get geometricExtents(){return new N}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"table",properties:[{name:"numRows",type:"string",editable:!0,accessor:{get:()=>this.numRows,set:t=>{this.numRows=t}}},{name:"numColumns",type:"float",editable:!0,accessor:{get:()=>this.numColumns,set:t=>{this.numColumns=t}}},{name:"tableWidth",type:"float",editable:!1,accessor:{get:()=>this._columnWidth.reduce((t,e)=>t+e,0)}},{name:"tableHeight",type:"float",editable:!1,accessor:{get:()=>this._rowHeight.reduce((t,e)=>t+e,0)}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}subWorldDraw(t){const e=this.blockTableRecord;if(!this.hasRenderableCellContent()&&e&&e.newIterator().count>0){const g=this.drawAnonymousTableBlock(t,e);if(g)return g}let s=0,n=0;const r=new Uint16Array(this.numColumns*this.numRows*8),o=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let a=0;for(let g=0;g<=this.numRows;g++){s-=g>0?this.rowHeight(g-1):0,n=0;for(let m=0;m<=this.numColumns;m++)n+=m>0?this.columnWidth(m-1):0,o[a++]=n,o[a++]=s,o[a++]=0}const h=[],c=new Array(this.numRows*this.numColumns).fill(!1);n=0,a=0;let d=0;for(let g=0;g<this.numColumns;g++){n+=g>0?this.columnWidth(g-1):0,s=0;for(let m=0;m<this.numRows;m++){s+=m>0?this.rowHeight(m-1):0;const y=this.cell(m*this.numColumns+g);if(d=m*this.numColumns+g,y&&!c[d]){const b=y.borderWidth??1,x=y.borderHeight??1;this.fillVisited(c,d,this.numColumns,b,x),r[a++]=g+m*(this.numColumns+1),r[a++]=g+m*(this.numColumns+1)+b;const I=o[r[a-1]*3]-n,S=g+(m+x)*(this.numColumns+1)+b;g+b==this.numColumns&&(r[a++]=g+m*(this.numColumns+1)+b,r[a++]=S);const L=-o[S*3+1]-s;if(m+x==this.numRows&&(r[a++]=g+(m+x)*(this.numColumns+1)+x,r[a++]=g+(m+x)*(this.numColumns+1)),r[a++]=g+(m+x)*(this.numColumns+1),r[a++]=g+m*(this.numColumns+1),y.text){const A=y.attachmentPoint||this.attachmentPoint||ot.MiddleCenter,H=this.getTableTextOffset(A,I,L),M={text:y.text,height:this.getCellTextHeight(y,L),width:I,position:Fc.set(n,-s,0).clone().add(H),rotation:this.rotation,attachmentPoint:A},X=this.getTextStyle(y);h.push(t.mtext(M,X))}}}}h.push(t.lineSegments(o,3,r));const u=t.group(h),p=new ss;return p.setFromAxisAngle(_.Z_AXIS,this.rotation),yi.compose(this.position,p,this.scaleFactors),u.applyMatrix(yi),u}hasRenderableCellContent(){return this._cells.some(t=>!!t&&(!!t.text||!!t.blockTableRecordId))}drawAnonymousTableBlock(t,e){const s=[],n=e.newIterator();for(const a of n){let h;a.color.isByBlock&&this.rgbColor?(Co.copy(a.color),a.color.setRGBValue(this.rgbColor),h=a.worldDraw(t),a.color.copy(Co)):h=a.worldDraw(t),h&&(h.objectId=this.objectId,h.ownerId=this.ownerId,h.layerName=this.layer,h.visible=this.visibility&&a.visibility,s.push(h))}const r=t.group(s);r.applyMatrix(this.blockTransform);const o=this.normal;return o&&(o.x!==0||o.y!==0||o.z!==1)&&(yi.setFromExtrusionDirection(o),r.applyMatrix(yi)),r}fillVisited(t,e,s,n,r){if(r==1&&n==1)t[e]=!0;else for(let o=0;o<n;++o)for(let a=0;a<r;++a)t[e+o+a*s]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable,s=(t.textStyle?e.getAt(t.textStyle):void 0)??e.getAt(this.database.textstyle)??e.getAt(Z);if(!s)throw new Error("No valid text style found in text style table.");return s.textStyle}getTableTextOffset(t,e,s){const n=new _;switch(t){case 1:break;case 2:n.setX(e/2);break;case 3:n.setX(e);break;case 4:n.setY(-s/2);break;case 5:n.set(e/2,-s/2,0);break;case 6:n.set(e,-s/2,0);break;case 7:n.setY(-s);break;case 8:n.set(e/2,-s,0);break;case 9:n.set(e,-s,0);break}return n}getCellTextHeight(t,e){return t.textHeight&&t.textHeight>0?t.textHeight:Math.max(e/2,1)}dxfOutFields(t){var r,o,a,h,c,d,u;super.dxfOutFields(t),t.writeSubclassMarker("AcDbTable");const e=t.version??((r=t.database)==null?void 0:r.version)??((o=this.database)==null?void 0:o.version),s=(e==null?void 0:e.value)!=null?e.value>=27:!1;t.writeInt16(280,this.tableDataVersion),t.writeObjectId(342,this.tableStyleId),t.writeObjectId(343,this.owningBlockRecordId),t.writeVector3d(11,this.horizontalDirection),t.writeUInt32(90,this.tableValueFlag),t.writeUInt32(93,this.tableOverrideFlag),t.writeUInt32(94,this.borderColorOverrideFlag),t.writeUInt32(95,this.borderLineweightOverrideFlag),t.writeUInt32(96,this.borderVisibilityOverrideFlag),t.writeInt16(71,this.attachmentPoint),t.writeInt32(91,this.numRows),t.writeInt32(92,this.numColumns);for(let p=0;p<this.numRows;++p)t.writeDouble(141,this.rowHeight(p));for(let p=0;p<this.numColumns;++p)t.writeDouble(142,this.columnWidth(p));const n=this._cells.length>0?this._cells.length:this.numRows*this.numColumns;for(let p=0;p<n;p++){const g=this._cells[p],m=(g==null?void 0:g.cellType)??(g!=null&&g.blockTableRecordId?2:1);if(t.writeInt16(171,m),t.writeInt16(172,(g==null?void 0:g.flagValue)??0),t.writeInt16(173,(g==null?void 0:g.mergedValue)??0),t.writeBoolean(174,g==null?void 0:g.autoFit),t.writeInt16(175,g==null?void 0:g.borderWidth),t.writeInt16(176,g==null?void 0:g.borderHeight),(g==null?void 0:g.overrideFlag)!=null&&(s?t.writeInt32(91,g.overrideFlag):t.writeInt16(177,g.overrideFlag)),t.writeInt16(178,g==null?void 0:g.virtualEdgeFlag),t.writeAngle(145,g==null?void 0:g.rotation),s&&t.writeInt16(92,g==null?void 0:g.extendedCellFlags),m===1)g!=null&&g.fieldObjetId?t.writeObjectId(344,g.fieldObjetId):this.writeCellText(t,(g==null?void 0:g.text)??"",s,g==null?void 0:g.cellValueBlockBegin);else if(m===2){if(t.writeObjectId(340,g==null?void 0:g.blockTableRecordId),t.writeDouble(144,g==null?void 0:g.blockScale),t.writeInt16(179,g==null?void 0:g.blockAttrNum),(a=g==null?void 0:g.attrDefineId)!=null&&a.length)for(const y of g.attrDefineId)t.writeObjectId(331,y);if((g==null?void 0:g.attrText)!=null)if(Array.isArray(g.attrText))for(const y of g.attrText)t.writeString(300,y);else t.writeString(300,g.attrText)}g!=null&&g.textStyle&&t.writeString(7,g.textStyle),(g==null?void 0:g.textHeight)!=null&&t.writeDouble(140,g.textHeight),(g==null?void 0:g.attachmentPoint)!=null&&t.writeInt16(170,g.attachmentPoint),(g==null?void 0:g.topBorderVisibility)!=null&&t.writeInt16(289,g.topBorderVisibility?1:0),(g==null?void 0:g.rightBorderVisibility)!=null&&t.writeInt16(285,g.rightBorderVisibility?1:0),(g==null?void 0:g.bottomBorderVisibility)!=null&&t.writeInt16(286,g.bottomBorderVisibility?1:0),(g==null?void 0:g.leftBorderVisibility)!=null&&t.writeInt16(288,g.leftBorderVisibility?1:0)}if(t.writeInt16(70,this.flowDirection),t.writeDouble(40,this.horizontalCellMargin),t.writeDouble(41,this.verticalCellMargin),this.suppressTitle!=null&&t.writeInt16(280,this.suppressTitle?1:0),this.suppressHeader!=null&&t.writeInt16(281,this.suppressHeader?1:0),(h=this.cellTypeOverrides)!=null&&h.length)for(const p of this.cellTypeOverrides){t.writeString(7,p.textStyle),t.writeDouble(140,p.textHeight),t.writeInt16(170,p.alignment),t.writeInt16(63,p.backgroundColor),t.writeInt16(64,p.contentColor),p.backgroundColorEnabled!=null&&t.writeInt16(283,p.backgroundColorEnabled?1:0);const g=p.borderLineweights;g&&(t.writeInt16(274,g.top),t.writeInt16(275,g.right),t.writeInt16(276,g.bottom),t.writeInt16(277,g.left),t.writeInt16(278,g.insideHorizontal),t.writeInt16(279,g.insideVertical));const m=p.borderVisibility;m&&(t.writeInt16(284,m.top?1:0),t.writeInt16(285,m.right?1:0),t.writeInt16(286,m.bottom?1:0),t.writeInt16(287,m.left?1:0),t.writeInt16(288,m.insideHorizontal?1:0),t.writeInt16(289,m.insideVertical?1:0))}if(this.tableBorderColors&&(t.writeInt16(63,this.tableBorderColors.left),t.writeInt16(64,this.tableBorderColors.top),t.writeInt16(65,this.tableBorderColors.insideHorizontal),t.writeInt16(66,this.tableBorderColors.bottom),t.writeInt16(68,this.tableBorderColors.insideVertical),t.writeInt16(69,this.tableBorderColors.right)),(c=this.rowDataTypes)!=null&&c.length)for(const p of this.rowDataTypes)t.writeInt16(97,p);if((d=this.rowUnitTypes)!=null&&d.length)for(const p of this.rowUnitTypes)t.writeInt16(98,p);if((u=this.rowFormats)!=null&&u.length)for(const p of this.rowFormats)t.writeString(4,p);return this}writeCellText(t,e,s,n){if(!s){if(e.length<=250){t.writeString(1,e);return}const a=Math.ceil(e.length/250);for(let h=0;h<a;h++){const c=h*250,d=c+250,u=e.slice(c,d);h===a-1?t.writeString(1,u):t.writeString(2,u)}return}if(t.writeString(301,n??"CELL_VALUE"),e.length<=250){t.writeString(302,e),t.writeString(304,"ACVALUE_END");return}const o=Math.ceil(e.length/250);for(let a=0;a<o;a++){const h=a*250,c=h+250,d=e.slice(h,c);a===o-1?t.writeString(302,d):t.writeString(303,d)}t.writeString(304,"ACVALUE_END")}};Qr.typeName="Table";let Ui=Qr;const yi=new D,Co=new j,Jr=class Jr extends ht{get dxfTypeName(){return"TRACE"}constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new w,new w,new w,new w]}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return!0}get thickness(){return this._thickness}set thickness(t){this._thickness=t}getPointAt(t){return t<0?this._vertices[0]:t>3?this._vertices[3]:this._vertices[t]}setPointAt(t,e){if(t<0&&this._vertices[0].copy(e),t>3)return this._vertices[3].copy(e);this._vertices[t].copy(e)}get geometricExtents(){return new N().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subGetOsnapPoints(t,e,s,n){switch(t){case z.EndPoint:n.push(...this._vertices);break}}transformBy(t){return this._vertices.forEach(e=>e.applyMatrix4(t)),this._elevation=this._vertices[0].z,this}subWorldDraw(t){const e=new at(this._vertices,!0),s=new Pe;s.add(e);const n=t.subEntityTraits;return n.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},t.area(s)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbTrace"),t.writeDouble(38,this.elevation),t.writeDouble(39,this.thickness),t.writePoint3d(10,this.getPointAt(0)),t.writePoint3d(11,this.getPointAt(1)),t.writePoint3d(12,this.getPointAt(2)),t.writePoint3d(13,this.getPointAt(3)),this}};Jr.typeName="Trace";let Yi=Jr;const to=class to extends ht{get dxfTypeName(){return"LWPOLYLINE"}constructor(){super(),this._elevation=0,this._geo=new at}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}addVertexAt(t,e,s=0,n=-1,r=-1){const o=n<0?void 0:n,a=r<0?void 0:r,h={x:e.x,y:e.y,bulge:s,startWidth:o,endWidth:a};this._geo.addVertexAt(t,h)}removeVertexAt(t){this._geo.removeVertexAt(t)}reset(t,e){this._geo.reset(t,e)}getPoint2dAt(t){return this._geo.getPointAt(t)}getPoint3dAt(t){const e=this.getPoint2dAt(t);return new w(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new N({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetGripPoints(){const t=new Array;for(let e=0;e<this.numberOfVertices;++e)t.push(this.getPoint3dAt(e));return t}subGetOsnapPoints(t,e,s,n){const r=new Array;for(let o=0;o<this.numberOfVertices;++o)r.push(this.getPoint3dAt(o));switch(t){case z.EndPoint:n.push(...r);break}}transformBy(t){const e=t.determinant()<0;let s=this._elevation;return this._geo.vertices.forEach(n=>{const r=new w(n.x,n.y,this._elevation).applyMatrix4(t);n.x=r.x,n.y=r.y,s=r.z,e&&n.bulge!=null&&(n.bulge=-n.bulge)}),this._elevation=s,this._geo._boundingBoxNeedsUpdate=!0,this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=this._geo.getPoints(100),s=this.createWidthProfile();if(s!=null){const r=zc(s,this.closed);if(r!=null){const o=t.subEntityTraits;return o.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},t.area(r)}}const n=[];return e.forEach(r=>n.push(new w().set(r.x,r.y,this.elevation))),t.lines(n)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPolyline"),t.writeInt32(90,this.numberOfVertices),t.writeInt16(70,this.closed?1:0),t.writeDouble(38,this.elevation);for(let e=0;e<this.numberOfVertices;++e)t.writePoint2d(10,this.getPoint2dAt(e));return this}createWidthProfile(){const t=this._geo.vertices,e=t.length;if(e<2)return null;const s=this.closed?e:e-1,n=[];let r=!1;for(let o=0;o<s;o++){const a=t[o],h=t[(o+1)%e],c=Math.max(0,a.startWidth??0),d=Math.max(0,a.endWidth??0);(c>Mt||d>Mt)&&(r=!0);const u=this.sampleSegment(a,h),p=u.length-1;for(let g=0;g<=p;g++){if(g===0&&n.length>0||this.closed&&o===s-1&&g===p)continue;const m=p>0?g/p:0;n.push({x:u[g].x,y:u[g].y,width:Wc(c,d,m)})}}return r&&n.length>=2?n:null}sampleSegment(t,e){if(t.bulge&&Math.abs(t.bulge)>Mt){const n=new Te(t,e,t.bulge).getPoints(32);if(n.length>1)return n.map(r=>new v(r.x,r.y))}return[new v(t.x,t.y),new v(e.x,e.y)]}};to.typeName="Polyline";let Xi=to;const Mt=1e-6,Oo=4;function zc(i,t){if(i.length<2)return null;const e=Dc(i,t);if(e.length<2)return null;const{left:s,right:n}=Vc(e,t);if(s.length<2||n.length<2)return null;const r=new Pe;if(t){if(!Pn(s)||!Pn(n))return null;const a=Math.abs($n(s)),h=Math.abs($n(n)),[c,d]=a>=h?[s,n]:[n,s];return r.add(new at(c,!0)),r.add(new at(d,!0)),r}const o=[...s,...n.reverse()];return Pn(o)?(r.add(new at(o,!0)),r):null}function Vc(i,t){const e=[],s=[];for(let n=0;n<i.length;n++){const r=i[n],o=Math.max(0,r.width)/2;if(o<=Mt)continue;const a=jc(i,n,t);a!=null&&(e.push({x:r.x+a.x*o,y:r.y+a.y*o}),s.push({x:r.x-a.x*o,y:r.y-a.y*o}))}return{left:e,right:s}}function Dc(i,t){const e=[];if(i.forEach(s=>{const n=e[e.length-1];(!n||Math.abs(n.x-s.x)>Mt||Math.abs(n.y-s.y)>Mt||Math.abs(n.width-s.width)>Mt)&&e.push(s)}),t&&e.length>1){const s=e[0],n=e[e.length-1];Math.abs(s.x-n.x)<=Mt&&Math.abs(s.y-n.y)<=Mt&&e.pop()}return e}function jc(i,t,e){const s=i.length,n=i[t],r=i[(t-1+s)%s],o=i[(t+1)%s];let a=No(n.x-r.x,n.y-r.y),h=No(o.x-n.x,o.y-n.y);if(e||(t===0&&(a=h),t===s-1&&(h=a)),a==null&&h==null)return null;if(a==null)return _i(h);if(h==null)return _i(a);const c=_i(a),d=_i(h),u=c.x+d.x,p=c.y+d.y,g=Math.hypot(u,p);if(g<=Mt)return d;const m={x:u/g,y:p/g},y=Math.abs(m.x*d.x+m.y*d.y),b=y<=Mt?Oo:Math.min(1/y,Oo);return{x:m.x*b,y:m.y*b}}function No(i,t){const e=Math.hypot(i,t);return e<=Mt?null:{x:i/e,y:t/e}}function _i(i){return{x:-i.y,y:i.x}}function $n(i){let t=0;const e=i.length;for(let s=0;s<e;s++){const n=i[s],r=i[(s+1)%e];t+=n.x*r.y-r.x*n.y}return t/2}function Pn(i){return i.length>=3&&Math.abs($n(i))>Mt}function Wc(i,t,e){return i+(t-i)*e}const eo=class eo extends lt{get dxfTypeName(){return"POINT"}constructor(){super(),this._geo=new w}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new N().expandByPoint(this._geo)}subGetOsnapPoints(t,e,s,n){z.Node===t&&n.push(this._geo)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}transformBy(t){return this._geo.applyMatrix4(t),this}subWorldDraw(t){return t.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize})}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbPoint"),t.writePoint3d(10,this.position),this}};eo.typeName="Point";let $i=eo;var tl=(i=>(i[i.Invalid=0]="Invalid",i[i.Rect=1]="Rect",i[i.Poly=2]="Poly",i))(tl||{}),el=(i=>(i[i.Show=1]="Show",i[i.ShowUnAligned=2]="ShowUnAligned",i[i.Clip=4]="Clip",i[i.Transparent=8]="Transparent",i))(el||{});const so=class so extends lt{get dxfTypeName(){return"IMAGE"}constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new w,this._scale=new $(1,1),this._rotation=0,this._imageSize=new v,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isShownClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(t){this._brightness=t}get contrast(){return this._contrast}set contrast(t){this._contrast=t}get fade(){return this._fade}set fade(t){this._fade=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get position(){return this._position}set position(t){this._position=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get scale(){return this._scale}set scale(t){this._scale.copy(t)}get imageSize(){return this._imageSize}set imageSize(t){this._imageSize.copy(t)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(t){this._clipBoundaryType=t}get clipBoundary(){return this._clipBoundary}set clipBoundary(t){this._clipBoundary=[],this._clipBoundary.push(...t)}get isClipped(){return this._isClipped}set isClipped(t){this._isClipped=t}get isShownClipped(){return this._isShownClipped}set isShownClipped(t){this._isShownClipped=t}get isImageShown(){return this._isImageShown}set isImageShown(t){this._isImageShown=t}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(t){this._isImageTransparent=t}get image(){return this._image}set image(t){this._image=t}get imageDefId(){return this._imageDefId}set imageDefId(t){this._imageDefId=t}get imageFileName(){if(this._imageDefId){const t=this.database.objects.imageDefinition.getIdAt(this._imageDefId);if(t)return t.sourceFileName}return""}get geometricExtents(){const t=new N;return t.min.copy(this._position),t.max.set(this._position.x+this._width,this._position.y+this._height,0),t}subGetGripPoints(){return this.boundaryPath()}subWorldDraw(t){const e=this.boundaryPath();return this._image?t.image(this._image,{boundary:e,roation:this._rotation}):t.lines(e)}transformBy(t){const e=this._width*this._scale.x,s=this._height*this._scale.y,n=new _(e*Math.cos(this._rotation),e*Math.sin(this._rotation),0),r=new _(-s*Math.sin(this._rotation),s*Math.cos(this._rotation),0),o=this._position.clone(),a=this._position.clone().add(n),h=this._position.clone().add(r);o.applyMatrix4(t),a.applyMatrix4(t),h.applyMatrix4(t);const c=new _(a).sub(o),d=new _(h).sub(o);return this._position.copy(o),this._rotation=Math.atan2(c.y,c.x),this._width=c.length(),this._height=d.length(),this._scale.set(1,1),this}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,s=this._height,n=new _t;n.setFromPoints(this._clipBoundary);const r=new v;r.setX(this._position.x-n.min.x*e),r.setY(this._position.y-n.min.y*s),this._clipBoundary.forEach(o=>{const a=o.x*e+r.x,h=o.y*s+r.y;t.push(new w(a,h,this._position.z))})}else{if(t.push(this._position),t.push(this._position.clone().setX(this._position.x+this._width)),t.push(this._position.clone().set(this._position.x+this._width,this._position.y+this._height,this._position.z)),t.push(this._position.clone().setY(this._position.y+this._height)),this._rotation>0){Bo.copy(t[1]);for(let e=1;e<4;e++)xi.copy(t[e]),xi.rotateAround(Bo,this._rotation),t[e].setX(xi.x),t[e].setY(xi.y)}t.push(t[0])}return t}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbRasterImage"),t.writePoint3d(10,this.position);const e=this.width*this.scale.x,s=this.height*this.scale.y,n=this._imageSize.x>0&&this._imageSize.y>0?this._imageSize:{x:e,y:s},r=n.x>0?e/n.x:e,o=n.y>0?s/n.y:s,a=Math.cos(this._rotation),h=Math.sin(this._rotation);t.writePoint3d(11,{x:r*a,y:r*h,z:0}),t.writePoint3d(12,{x:-o*h,y:o*a,z:0}),t.writePoint2d(13,n),t.writeObjectId(340,this.imageDefId);const c=(this.isImageShown?1:0)|(this.isShownClipped?4:0)|(this.isImageTransparent?8:0);if(t.writeInt16(70,c),t.writeInt16(280,this.isClipped?1:0),t.writeInt16(281,this.brightness),t.writeInt16(282,this.contrast),t.writeInt16(283,this.fade),t.writeInt16(71,this.clipBoundaryType),this.isClipped){t.writeInt16(91,this.clipBoundary.length);for(const d of this.clipBoundary)t.writePoint2d(14,d)}return this}};so.typeName="RasterImage";let qs=so;const Bo=new v,xi=new v,io=class io extends ht{get dxfTypeName(){return"RAY"}constructor(){super(),this._basePoint=new w,this._unitDir=new _}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new N;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}subGetOsnapPoints(t,e,s,n){switch(t){case z.EndPoint:n.push(this.basePoint);break}}transformBy(t){return this._basePoint.applyMatrix4(t),this._unitDir.transformDirection(t),this}subWorldDraw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRay"),t.writePoint3d(10,this.basePoint),t.writeVector3d(11,this.unitDir),this}};io.typeName="Ray";let qi=io;const no=class no extends lt{get dxfTypeName(){return"VIEWPORT"}constructor(){super(),this._centerPoint=new w,this._height=0,this._width=0,this._viewCenter=new w,this._viewHeight=0,this._number=-1}get number(){return this._number}set number(t){this._number=t}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint=t}get height(){return this._height}set height(t){this._height=t}get width(){return this._width}set width(t){this._width=t}get viewCenter(){return this._viewCenter}set viewCenter(t){this._viewCenter=t}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get geometricExtents(){return new N}transformBy(t){const e=this._centerPoint.clone(),s=this._centerPoint.clone().add(new _(this._width,0,0)),n=this._centerPoint.clone().add(new _(0,this._height,0));e.applyMatrix4(t),s.applyMatrix4(t),n.applyMatrix4(t);const r=new _(s).sub(e),o=new _(n).sub(e),a=this._height!==0?o.length()/this._height:1;return this._centerPoint.copy(e),this._width=r.length(),this._height=o.length(),this._viewHeight*=a,this}subWorldDraw(t){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const e=this.toGiViewport();return t.group(this.createViewportRect(e,t))}}toGiViewport(){const t=new ja;return t.id=this.objectId,t.groupId=this.ownerId,t.number=this.number,t.centerPoint=this.centerPoint,t.width=this.width,t.height=this.height,t.viewHeight=this.viewHeight,t.viewCenter=this.viewCenter,t}createViewportRect(t,e){const s=[];return s.push(e.lines([new w(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new w(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)])),s.push(e.lines([new w(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new w(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)])),s.push(e.lines([new w(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new w(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)])),s.push(e.lines([new w(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new w(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)])),s}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbViewport"),t.writePoint3d(10,this.centerPoint),t.writeDouble(40,this.height),t.writeDouble(41,this.width),t.writePoint3d(12,this.viewCenter),t.writeDouble(45,this.viewHeight),t.writeInt32(69,this.number),this}};no.typeName="Viewport";let Zi=no;const ro=class ro extends qs{get dxfTypeName(){return"WIPEOUT"}subWorldDraw(t){const e=this.boundaryPath(),s=new Pe;return s.add(new at(e)),t.area(s)}dxfOutFields(t){return super.dxfOutFields(t),this}};ro.typeName="Wipeout";let Ki=ro;const oo=class oo extends ht{get dxfTypeName(){return"XLINE"}constructor(){super(),this._basePoint=new w,this._unitDir=new _}get basePoint(){return this._basePoint}set basePoint(t){this._basePoint.copy(t)}get unitDir(){return this._unitDir}set unitDir(t){this._unitDir.copy(t)}get closed(){return!1}get geometricExtents(){const t=new N;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:t=>{this.basePoint.x=t}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:t=>{this.basePoint.y=t}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:t=>{this.basePoint.z=t}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:t=>{this.unitDir.x=t}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:t=>{this.unitDir.y=t}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:t=>{this.unitDir.z=t}}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.basePoint),t}transformBy(t){return this._basePoint.applyMatrix4(t),this._unitDir.transformDirection(t),this}subWorldDraw(t){const e=[];return e.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbXline"),t.writePoint3d(10,this.basePoint),t.writeVector3d(11,this.unitDir),this}};oo.typeName="Xline";let Qi=oo;class sl{constructor(t){this.position=new w(t.x,t.y,t.z||0)}}const ao=class ao extends ht{get dxfTypeName(){return"POLYLINE"}constructor(t,e,s,n=!1,r=!1){super(),this._mCount=t,this._nCount=e,this._closedM=n,this._closedN=r,this._vertices=s.map(o=>new sl(o))}get mCount(){return this._mCount}get nCount(){return this._nCount}get closedM(){return this._closedM}get closedN(){return this._closedN}get closed(){return this._closedM}set closed(t){this._closedM=t}get numberOfVertices(){return this._vertices.length}getVertexAt(t){if(t<0||t>=this._vertices.length)throw new Error("Vertex index out of bounds");return this._vertices[t]}getVertexAtMN(t,e){const s=t*this._nCount+e;return this.getVertexAt(s)}get geometricExtents(){if(this._vertices.length===0)return new N(new w(0,0,0),new w(0,0,0));let t=Number.MAX_VALUE,e=Number.MAX_VALUE,s=Number.MAX_VALUE,n=-Number.MAX_VALUE,r=-Number.MAX_VALUE,o=-Number.MAX_VALUE;return this._vertices.forEach(a=>{t=Math.min(t,a.position.x),e=Math.min(e,a.position.y),s=Math.min(s,a.position.z),n=Math.max(n,a.position.x),r=Math.max(r,a.position.y),o=Math.max(o,a.position.z)}),new N(new w(t,e,s),new w(n,r,o))}subGetGripPoints(){const t=new Array;return this._vertices.forEach(e=>{t.push(e.position)}),t}subGetOsnapPoints(t,e,s,n){switch(t){case z.EndPoint:this._vertices.forEach(r=>{n.push(r.position)});break}}transformBy(t){return this._vertices.forEach(e=>{e.position.applyMatrix4(t)}),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"mCount",type:"float",editable:!1,accessor:{get:()=>this._mCount}},{name:"nCount",type:"float",editable:!1,accessor:{get:()=>this._nCount}},{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._vertices.map(t=>({x:t.position.x,y:t.position.y,z:t.position.z}))}}]},{groupName:"others",properties:[{name:"closedM",type:"boolean",editable:!0,accessor:{get:()=>this._closedM,set:t=>{this._closedM=t}}},{name:"closedN",type:"boolean",editable:!0,accessor:{get:()=>this._closedN,set:t=>{this._closedN=t}}}]}]}}subWorldDraw(t){const e=[];for(let s=0;s<this._mCount;s++)for(let n=0;n<this._nCount;n++){const r=this.getVertexAtMN(s,n);let o=n+1;if(o>=this._nCount)if(this._closedN)o=0;else continue;const a=this.getVertexAtMN(s,o);e.push(r.position),e.push(a.position)}for(let s=0;s<this._nCount;s++)for(let n=0;n<this._mCount;n++){const r=this.getVertexAtMN(n,s);let o=n+1;if(o>=this._mCount)if(this._closedM)o=0;else continue;const a=this.getVertexAtMN(o,s);e.push(r.position),e.push(a.position)}return t.lines(e)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPolygonMesh");let e=16;return this._closedM&&(e|=1),this._closedN&&(e|=32),t.writeInt16(66,1),t.writeInt16(70,e),t.writeInt32(71,this._mCount),t.writeInt32(72,this._nCount),this}dxfOut(t,e=!1){super.dxfOut(t,e);for(let s=0;s<this.numberOfVertices;s++){const n=this.getVertexAt(s);t.writeStart("VERTEX"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbVertex"),t.writeSubclassMarker("AcDbPolygonMeshVertex"),t.writePoint3d(10,n.position),t.writeInt16(70,16)}return t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}};ao.typeName="PolygonMesh";let Ji=ao;class il{constructor(t){this.position=new w(t.x,t.y,t.z||0)}}class nl{constructor(t){this.vertexIndices=t}}const lo=class lo extends ht{get dxfTypeName(){return"POLYLINE"}constructor(t,e){super(),this._vertices=t.map(s=>new il(s)),this._faces=e.map(s=>new nl(s))}get numberOfVertices(){return this._vertices.length}get numberOfFaces(){return this._faces.length}get closed(){return!1}set closed(t){}getVertexAt(t){if(t<0||t>=this._vertices.length)throw new Error("Vertex index out of bounds");return this._vertices[t]}getFaceAt(t){if(t<0||t>=this._faces.length)throw new Error("Face index out of bounds");return this._faces[t]}get geometricExtents(){if(this._vertices.length===0)return new N(new w(0,0,0),new w(0,0,0));let t=Number.MAX_VALUE,e=Number.MAX_VALUE,s=Number.MAX_VALUE,n=-Number.MAX_VALUE,r=-Number.MAX_VALUE,o=-Number.MAX_VALUE;return this._vertices.forEach(a=>{t=Math.min(t,a.position.x),e=Math.min(e,a.position.y),s=Math.min(s,a.position.z),n=Math.max(n,a.position.x),r=Math.max(r,a.position.y),o=Math.max(o,a.position.z)}),new N(new w(t,e,s),new w(n,r,o))}subGetGripPoints(){const t=new Array;return this._vertices.forEach(e=>{t.push(e.position)}),t}subGetOsnapPoints(t,e,s,n){switch(t){case z.EndPoint:this._vertices.forEach(r=>{n.push(r.position)});break}}transformBy(t){return this._vertices.forEach(e=>{e.position.applyMatrix4(t)}),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._vertices.map(t=>({x:t.position.x,y:t.position.y,z:t.position.z}))}},{name:"faces",type:"array",editable:!1,itemSchema:{properties:[{name:"vertexIndices",type:"array",editable:!1,itemSchema:{properties:[{name:"index",type:"int",editable:!1}]}}]},accessor:{get:()=>this._faces.map(t=>({vertexIndices:t.vertexIndices}))}}]}]}}subWorldDraw(t){const e=[];return this._faces.forEach(s=>{const n=[];if(s.vertexIndices.forEach(r=>{const o=Math.abs(r)-1;o>=0&&o<this._vertices.length&&n.push(this._vertices[o].position)}),n.length>=3)for(let r=0;r<n.length;r++){const o=n[r],a=n[(r+1)%n.length];e.push(o),e.push(a)}}),t.lines(e)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPolyFaceMesh");const e=64;return t.writeInt16(66,1),t.writeInt16(70,e),this}dxfOut(t,e=!1){super.dxfOut(t,e);for(let s=0;s<this.numberOfVertices;s++){const n=this.getVertexAt(s);t.writeStart("VERTEX"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbVertex"),t.writeSubclassMarker("AcDbPolyFaceMeshVertex"),t.writePoint3d(10,n.position),t.writeInt16(70,64)}for(let s=0;s<this.numberOfFaces;s++){const n=this.getFaceAt(s);t.writeStart("VERTEX"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbVertex"),t.writeSubclassMarker("AcDbPolyFaceMeshVertex"),t.writeInt16(70,128),n.vertexIndices.forEach((r,o)=>{t.writeInt32(10+o,r)})}return t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}};lo.typeName="PolyFaceMesh";let tn=lo;var en=(i=>(i[i.AtLeast=1]="AtLeast",i[i.Exactly=2]="Exactly",i))(en||{});const ho=class ho extends lt{get dxfTypeName(){return"DIMENSION"}constructor(){super(),this._dimBlockId=null,this._dimBlockPosition=new w,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new w,this._textRotation=0,this._normal=new _(0,0,1)}get dimBlockId(){return this._dimBlockId}set dimBlockId(t){this._dimBlockId=t}get dimBlockPosition(){return this._dimBlockPosition}set dimBlockPosition(t){this._dimBlockPosition.copy(t)}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(t){this._dimensionStyleName=t,this._dimStyle=void 0}get dimensionStyle(){if(this._dimStyle==null){let t;this.dimensionStyleName&&(t=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),t==null&&(t=new ts),this._dimStyle=t}return this._dimStyle}get dimensionText(){return this._dimensionText}set dimensionText(t){this._dimensionText=t}get measurement(){return this._measurement}set measurement(t){this._measurement=t}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(t){this._textLineSpacingFactor=t}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(t){this._textLineSpacingStyle=t}get textPosition(){return this._textPosition}set textPosition(t){this._textPosition.copy(t)}get textRotation(){return this._textRotation}set textRotation(t){this._textRotation=t}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}get properties(){return this.getBaseProperties()}getBaseProperties(){return{type:this.type,groups:[this.getGeneralProperties(),this.getDimensionProperties()]}}transformBy(t){const e=this._textPosition.clone(),s=this._textPosition.clone().add(new _(Math.cos(this._textRotation),Math.sin(this._textRotation),0));this._dimBlockPosition.applyMatrix4(t),this._textPosition.applyMatrix4(t),this._normal.transformDirection(t),e.applyMatrix4(t),s.applyMatrix4(t);const n=new _(s).sub(e);return n.lengthSq()>0&&(this._textRotation=Math.atan2(n.y,n.x)),this.subTransformBy(t),this}subGetOsnapPoints(t,e,s,n,r){const o=this.getDimBlockTableRecord();if(!o)return;const a=this.getFullDimBlockTransform(),h=new w(e).applyMatrix4(a.clone().invert()),c=new w(s).applyMatrix4(a.clone().invert()),d=(u,p)=>{const g=[];u.subGetOsnapPoints(t,h,c,g,p,a),u instanceof Je?g.forEach(m=>n.push(m.clone())):g.forEach(m=>n.push(new w(m).applyMatrix4(a)))};if(r){const u=o.getIdAt(r);if(u&&(d(u,r),n.length>0))return}for(const u of o.newIterator())d(u)}subWorldDraw(t){const e=this.getDimBlockTableRecord();if(e){const n=this.computeDimBlockTransform();return es.instance.draw(t,e,this.rgbColor,[],!1,n,this._normal)}return t.group([])}getDimBlockGeometricExtents(){const t=new N,e=this.getDimBlockTableRecord();if(!e)return t;for(const s of e.newIterator())t.union(s.geometricExtents);return t.applyMatrix4(this.getFullDimBlockTransform()),t}getDimBlockTableRecord(){return this.dimBlockId?this.database.tables.blockTable.getAt(this.dimBlockId):void 0}getDimensionProperties(){return{groupName:"dimension",properties:[this.createProperty("dimensionStyleName","string",()=>this.dimensionStyleName??"",t=>{this.dimensionStyleName=t.trim()===""?null:t}),this.createProperty("dimensionText","string",()=>this.dimensionText??"",t=>{this.dimensionText=t}),this.createProperty("measurement","float",()=>this.getMeasurementPropertyValue()),this.createProperty("dimBlockId","string",()=>this.dimBlockId??""),...this.createPoint3dProperties("dimBlockPosition",()=>this.dimBlockPosition),...this.createPoint3dProperties("textPosition",()=>this.textPosition),this.createProperty("textRotation","float",()=>this.textRotation,t=>{this.textRotation=t}),this.createProperty("textLineSpacingFactor","float",()=>this.textLineSpacingFactor,t=>{this.textLineSpacingFactor=t}),this.createProperty("textLineSpacingStyle","enum",()=>this.textLineSpacingStyle,t=>{this.textLineSpacingStyle=t},[{label:en[1],value:1},{label:en[2],value:2}]),...this.createPoint3dProperties("normal",()=>this.normal)]}}createProperty(t,e,s,n,r){return{name:t,type:e,editable:n!=null,options:r,accessor:n?{get:s,set:n}:{get:s}}}createPoint3dProperties(t,e){return[this.createProperty(`${t}X`,"float",()=>e().x,s=>{e().x=s}),this.createProperty(`${t}Y`,"float",()=>e().y,s=>{e().y=s}),this.createProperty(`${t}Z`,"float",()=>e().z,s=>{e().z=s})]}getMeasurementPropertyValue(){return this.measurement}getFullDimBlockTransform(){const t=this.computeDimBlockTransform();if(this._normal.x===0&&this._normal.y===0&&this._normal.z===1)return t;const e=new D().setFromExtrusionDirection(this._normal);return new D().multiplyMatrices(e,t)}get arrowScaleFactor(){return this.dimensionStyle.dimasz}get firstArrowStyle(){return{type:this.firstArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse1==0}}get secondArrowStyle(){return{type:this.secondArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse2==0}}get isAppendArrow(){return!0}get firstArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk1}get firstArrowType(){const t=this.firstArrowTypeBtrId;return this.getArrowName(t)}get secondArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk2}get secondArrowType(){const t=this.secondArrowTypeBtrId;return this.getArrowName(t)}get arrowLineCount(){return 1}findPointOnLine1(t,e,s){const n=new w().subVectors(e,t).normalize();return new w(e).addScaledVector(n,s)}findPointOnLine2(t,e,s){const n=t.x+s*Math.cos(e),r=t.y+s*Math.sin(e);return{x:n,y:r}}adjustExtensionLine(t){const e=this.dimensionStyle;t.extend(e.dimexe),t.extend(-e.dimexo,!0)}getArrowName(t){const e=this.database.tables.blockTable.getIdAt(t);return e?e.name.toUpperCase():yr.Closed}computeDimBlockTransform(){const t=this.dimBlockId?this.database.tables.blockTable.getAt(this.dimBlockId):void 0,e=(t==null?void 0:t.origin)??w.ORIGIN,s=new D().makeTranslation(-e.x,-e.y,-e.z),n=new D().makeTranslation(this._dimBlockPosition.x,this._dimBlockPosition.y,this._dimBlockPosition.z);return new D().multiplyMatrices(n,s)}subTransformBy(t){}dxfOutFields(t){super.dxfOutFields(t);const e=this.dimensionStyleName!=null?this.database.tables.dimStyleTable.getAt(this.dimensionStyleName):void 0;return t.writeSubclassMarker("AcDbDimension"),t.writeInt16(280,0),t.writeString(2,this.dimBlockId??void 0),t.writeString(3,this.dimensionStyleName??this.dimensionStyle.name),t.writePoint3d(10,this.dimBlockPosition),t.writeString(1,this.dimensionText??""),t.writeAngle(53,this.textRotation),t.writePoint3d(11,this.textPosition),t.writeInt16(70,0),t.writeInt16(72,this.textLineSpacingStyle),t.writeDouble(41,this.textLineSpacingFactor),t.writeDouble(42,this.measurement),t.writeVector3d(210,this.normal),t.writeObjectId(340,e==null?void 0:e.objectId),this}};ho.typeName="Dimension";let ge=ho;const co=class co extends ge{constructor(t,e,s,n,r=null,o=null){super(),this._centerPoint=new w().copy(t),this._xLine1Point=new w().copy(e),this._xLine2Point=new w().copy(s),this._arcPoint=new w().copy(n),this.dimensionText=r,this.dimensionStyleName=o}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("centerPoint",()=>this.centerPoint),...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("arcPoint",()=>this.arcPoint)]}]}}subTransformBy(t){this._arcPoint.applyMatrix4(t),this._centerPoint.applyMatrix4(t),this._xLine1Point.applyMatrix4(t),this._xLine2Point.applyMatrix4(t)}get geometricExtents(){return new N}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDb3PointAngularDimension"),t.writePoint3d(13,this.xLine1Point),t.writePoint3d(14,this.xLine2Point),t.writePoint3d(15,this.centerPoint),t.writePoint3d(16,this.arcPoint),this}};co.typeName="3PointAngularDimension";let sn=co;const uo=class uo extends ge{constructor(t,e,s,n=null,r=null){super(),this._dimLinePoint=new w().copy(s),this._xLine1Point=new w().copy(t),this._xLine2Point=new w().copy(e),this._oblique=0,this._rotation=0,this.calculateRotation(),n?this.dimensionText=n:this.dimensionText=this._xLine1Point.distanceTo(this._xLine2Point).toFixed(3),this.dimensionStyleName=r}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(t){this._dimLinePoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("dimLinePoint",()=>this.dimLinePoint),this.createProperty("rotation","float",()=>this.rotation,e=>{this.rotation=e}),this.createProperty("oblique","float",()=>this.oblique,e=>{this.oblique=e})]}]}}subTransformBy(t){this._dimLinePoint.applyMatrix4(t),this._xLine1Point.applyMatrix4(t),this._xLine2Point.applyMatrix4(t),this.calculateRotation()}get geometricExtents(){return this.getDimBlockGeometricExtents()}get isAppendArrow(){return!1}createDimBlock(t){const e=new J;e.name=t;const s=this.createLines();s.forEach(a=>e.appendEntity(new Ys(a.startPoint,a.endPoint))),this.createArrows(s[0]).forEach(a=>e.appendEntity(a));const r=s[0].midPoint,o=this.createMText(r,this._rotation);return o&&e.appendEntity(o),e}createMText(t,e){const s=n=>({x:Math.cos(n),y:Math.sin(n),z:0});if(this.dimensionText){const n=new Xs;return n.attachmentPoint=ot.MiddleLeft,n.layer="0",n.color=new j(P.ByBlock),n.location=t,n.contents=this.dimensionText??"",n.height=10,n.direction=s(e),n.styleName=this.dimensionStyle.dimtxsty,n}}createArrows(t){const e=[];return e.push(this.createArrow(t.startPoint,this.rotation+Math.PI,10)),e.push(this.createArrow(t.endPoint,this.rotation,10)),e}createArrow(t,e,s){const n="_CAXARROW",r=new Je(n);return r.position=t,r.rotation=e,r.scaleFactors={x:s,y:s,z:s},r}createLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),s=this.createExtensionLine(this._xLine2Point),n=this.findIntersectionPoint(e,this._dimLinePoint),r=this.findIntersectionPoint(s,this._dimLinePoint),o=new Ee(n,r);return t.push(o),e.endPoint=n,this.adjustExtensionLine(e),t.push(e),s.endPoint=r,this.adjustExtensionLine(s),t.push(s),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,s=this.findPointOnLine2(t,e,100);return new Ee(t,{...s,z:t.z})}findIntersectionPoint(t,e){const s=t.startPoint,n=t.endPoint,r=new _().subVectors(n,s).normalize(),a=new _().subVectors(e,s).dot(r),h=new _().copy(r).multiplyScalar(a);return new _().addVectors(s,h)}calculateRotation(){const t=this._xLine1Point,e=this._xLine2Point,s=e.x-t.x,n=e.y-t.y;this._rotation=Math.atan2(n,s)}get dxfSubclassMarker(){return"AcDbAlignedDimension"}getMeasurementPropertyValue(){return this.measurement??this.xLine1Point.distanceTo(this.xLine2Point)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker(this.dxfSubclassMarker),t.writePoint3d(13,this.xLine1Point),t.writePoint3d(14,this.xLine2Point),t.writePoint3d(15,this.dimLinePoint),t.writeAngle(50,this.rotation),t.writeAngle(52,this.oblique),this}};uo.typeName="AlignedDimension";let Zs=uo;const go=class go extends ge{constructor(t,e,s,n,r=null,o=null){super(),this._arcPoint=new w().copy(n),this._xLine1Point=new w().copy(e),this._xLine2Point=new w().copy(s),this._centerPoint=new w().copy(t),this.dimensionText=r,this.dimensionStyleName=o}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("centerPoint",()=>this.centerPoint),...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("arcPoint",()=>this.arcPoint)]}]}}subTransformBy(t){this._arcPoint.applyMatrix4(t),this._centerPoint.applyMatrix4(t),this._xLine1Point.applyMatrix4(t),this._xLine2Point.applyMatrix4(t)}get geometricExtents(){return new N}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbArcDimension"),t.writePoint3d(13,this.xLine1Point),t.writePoint3d(14,this.xLine2Point),t.writePoint3d(15,this.centerPoint),t.writePoint3d(16,this.arcPoint),this}};go.typeName="ArcDimension";let qn=go;const po=class po extends ge{constructor(t,e,s=0,n=null,r=null){super(),this._chordPoint=new w().copy(t),this._farChordPoint=new w().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=s,this.dimensionText=n,this.dimensionStyleName=r}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get farChordPoint(){return this._farChordPoint}set farChordPoint(t){this._farChordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}set leaderLength(t){this._leaderLength=t}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("chordPoint",()=>this.chordPoint),...this.createPoint3dProperties("farChordPoint",()=>this.farChordPoint),this.createProperty("leaderLength","float",()=>this.leaderLength,e=>{this.leaderLength=e}),this.createProperty("extArcStartAngle","float",()=>this.extArcStartAngle,e=>{this.extArcStartAngle=e}),this.createProperty("extArcEndAngle","float",()=>this.extArcEndAngle,e=>{this.extArcEndAngle=e})]}]}}subTransformBy(t){this._chordPoint.applyMatrix4(t),this._farChordPoint.applyMatrix4(t)}getMeasurementPropertyValue(){return this.measurement??this.chordPoint.distanceTo(this.farChordPoint)}get geometricExtents(){return new N}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbDiametricDimension"),t.writePoint3d(15,this.chordPoint),t.writePoint3d(16,this.farChordPoint),t.writeDouble(40,this.leaderLength),t.writeAngle(52,this.extArcStartAngle),t.writeAngle(53,this.extArcEndAngle),this}};po.typeName="DiametricDimension";let nn=po;const mo=class mo extends ge{constructor(t,e,s=null,n=null){super(),this._definingPoint=new w().copy(t),this._leaderEndPoint=new w().copy(e),this.dimensionText=s,this.dimensionStyleName=n}get definingPoint(){return this._definingPoint}set definingPoint(t){this._definingPoint.copy(t)}get leaderEndPoint(){return this._leaderEndPoint}set leaderEndPoint(t){this._leaderEndPoint.copy(t)}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("definingPoint",()=>this.definingPoint),...this.createPoint3dProperties("leaderEndPoint",()=>this.leaderEndPoint)]}]}}subTransformBy(t){this._definingPoint.applyMatrix4(t),this._leaderEndPoint.applyMatrix4(t)}get geometricExtents(){return new N}get arrowLineCount(){return 0}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbOrdinateDimension"),t.writePoint3d(13,this.definingPoint),t.writePoint3d(14,this.leaderEndPoint),this}};mo.typeName="OrdinateDimension";let rn=mo;const yo=class yo extends ge{constructor(t,e,s,n=null,r=null){super(),this._center=new w().copy(t),this._chordPoint=new w().copy(e),this._leaderLength=s,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=n,this.dimensionStyleName=r}get center(){return this._center}set center(t){this._center.copy(t)}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}set leaderLength(t){this._leaderLength=t}set leaderLenght(t){this._leaderLength=t}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("center",()=>this.center),...this.createPoint3dProperties("chordPoint",()=>this.chordPoint),this.createProperty("leaderLength","float",()=>this.leaderLength,e=>{this.leaderLength=e}),this.createProperty("extArcStartAngle","float",()=>this.extArcStartAngle,e=>{this.extArcStartAngle=e}),this.createProperty("extArcEndAngle","float",()=>this.extArcEndAngle,e=>{this.extArcEndAngle=e})]}]}}subTransformBy(t){this._center.applyMatrix4(t),this._chordPoint.applyMatrix4(t)}getMeasurementPropertyValue(){return this.measurement??this.center.distanceTo(this.chordPoint)}get geometricExtents(){return new N}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRadialDimension"),t.writePoint3d(15,this.center),t.writePoint3d(13,this.chordPoint),t.writeDouble(40,this.leaderLength),t.writeAngle(52,this.extArcStartAngle),t.writeAngle(53,this.extArcEndAngle),this}};yo.typeName="RadialDimension";let on=yo;const _o=class _o extends Zs{get dxfSubclassMarker(){return"AcDbRotatedDimension"}};_o.typeName="RotatedDimension";let an=_o;var rl=(i=>(i[i.kInches=0]="kInches",i[i.kMillimeters=1]="kMillimeters",i[i.kPixels=2]="kPixels",i))(rl||{}),ol=(i=>(i[i.k0degrees=0]="k0degrees",i[i.k90degrees=1]="k90degrees",i[i.k180degrees=2]="k180degrees",i[i.k270degrees=3]="k270degrees",i))(ol||{}),al=(i=>(i[i.kDisplay=0]="kDisplay",i[i.kExtents=1]="kExtents",i[i.kLimits=2]="kLimits",i[i.kView=3]="kView",i[i.kWindow=4]="kWindow",i[i.kLayout=5]="kLayout",i))(al||{}),we=(i=>(i[i.kDraft=0]="kDraft",i[i.kPreview=1]="kPreview",i[i.kNormal=2]="kNormal",i[i.kPresentation=3]="kPresentation",i[i.kMaximum=4]="kMaximum",i[i.kCustom=5]="kCustom",i))(we||{}),os=(i=>(i[i.kAsDisplayed=0]="kAsDisplayed",i[i.kWireframe=1]="kWireframe",i[i.kHidden=2]="kHidden",i[i.kRendered=3]="kRendered",i[i.kVisualStyle=4]="kVisualStyle",i[i.kRenderPreset=5]="kRenderPreset",i))(os||{}),ll=(i=>(i[i.kScaleToFit=0]="kScaleToFit",i[i.k1_128in_1ft=1]="k1_128in_1ft",i[i.k1_64in_1ft=2]="k1_64in_1ft",i[i.k1_32in_1ft=3]="k1_32in_1ft",i[i.k1_16in_1ft=4]="k1_16in_1ft",i[i.k3_32in_1ft=5]="k3_32in_1ft",i[i.k1_8in_1ft=6]="k1_8in_1ft",i[i.k3_16in_1ft=7]="k3_16in_1ft",i[i.k1_4in_1ft=8]="k1_4in_1ft",i[i.k3_8in_1ft=9]="k3_8in_1ft",i[i.k1_2in_1ft=10]="k1_2in_1ft",i[i.k3_4in_1ft=11]="k3_4in_1ft",i[i.k1in_1ft=12]="k1in_1ft",i[i.k3in_1ft=13]="k3in_1ft",i[i.k6in_1ft=14]="k6in_1ft",i[i.k1ft_1ft=15]="k1ft_1ft",i[i.k1_1=16]="k1_1",i[i.k1_2=17]="k1_2",i[i.k1_4=18]="k1_4",i[i.k1_5=19]="k1_5",i[i.k1_8=20]="k1_8",i[i.k1_10=21]="k1_10",i[i.k1_16=22]="k1_16",i[i.k1_20=23]="k1_20",i[i.k1_30=24]="k1_30",i[i.k1_40=25]="k1_40",i[i.k1_50=26]="k1_50",i[i.k1_100=27]="k1_100",i[i.k2_1=28]="k2_1",i[i.k4_1=29]="k4_1",i[i.k8_1=30]="k8_1",i[i.k10_1=31]="k10_1",i[i.k100_1=32]="k100_1",i[i.k1000_1=33]="k1000_1",i[i.k1and1_2in_1ft=34]="k1and1_2in_1ft",i))(ll||{});const Hc={0:0,1:1/1536,2:1/768,3:1/384,4:1/192,5:1/128,6:1/96,7:1/64,8:1/48,9:1/32,10:1/24,11:1/16,12:1/12,13:1/4,14:1/2,15:1,16:1,17:1/2,18:1/4,19:1/5,20:1/8,21:1/10,22:1/16,23:1/20,24:1/30,25:1/40,26:1/50,27:1/100,28:2,29:4,30:8,31:10,32:100,33:1e3,34:1/8};class hl extends Ft{constructor(t=!1){super(),this._plotSettingsName="",this._plotCfgName="",this._canonicalMediaName="",this._currentStyleSheet="",this._plotOrigin=new v,this._customPrintScale={numerator:1,denominator:1},this._plotPaperSize=new v,this._plotPaperMargins={left:0,right:0,top:0,bottom:0},this._plotViewName="",this._plotWindowArea=new _t,this._modelType=t,this._plotCentered=!1,this._plotHidden=!1,this._plotPaperUnits=1,this._plotPlotStyles=!0,this._plotRotation=0,this._plotType=5,this._plotViewportBorders=!1,this._printLineweights=!0,this._scaleLineweights=!1,this._drawViewportsFirst=!1,this._showPlotStyles=!0,this._shadePlotType=0,this._shadePlotResLevel=2,this._shadePlotCustomDpi=300,this._shadePlotId=void 0,this._stdScaleType=0,this._useStandardScale=!0}get plotSettingsName(){return this._plotSettingsName}set plotSettingsName(t){this._plotSettingsName=t}getPlotSettingsName(){return this._plotSettingsName}setPlotSettingsName(t){this._plotSettingsName=t}get plotCfgName(){return this._plotCfgName}set plotCfgName(t){this._plotCfgName=t}getPlotCfgName(){return this._plotCfgName}get canonicalMediaName(){return this._canonicalMediaName}set canonicalMediaName(t){this._canonicalMediaName=t}getCanonicalMediaName(){return this._canonicalMediaName}get currentStyleSheet(){return this._currentStyleSheet}set currentStyleSheet(t){this._currentStyleSheet=t}getCurrentStyleSheet(){return this._currentStyleSheet}get plotOrigin(){return this._plotOrigin}set plotOrigin(t){this._plotOrigin=t}getPlotOrigin(){return this._plotOrigin}get customPrintScale(){return this._customPrintScale}set customPrintScale(t){this._customPrintScale=t}getCustomPrintScale(){return this._customPrintScale}get plotPaperSize(){return this._plotPaperSize}set plotPaperSize(t){this._plotPaperSize=t}getPlotPaperSize(){return this._plotPaperSize}get plotPaperMargins(){return this._plotPaperMargins}set plotPaperMargins(t){this._plotPaperMargins=t}getPlotPaperMargins(){return this._plotPaperMargins}get plotViewName(){return this._plotViewName}set plotViewName(t){this._plotViewName=t}getPlotViewName(){return this._plotViewName}get plotWindowArea(){return this._plotWindowArea}set plotWindowArea(t){this._plotWindowArea=t}getPlotWindowArea(){return this._plotWindowArea}get modelType(){return this._modelType}set modelType(t){this._modelType=t}getModelType(){return this._modelType}setModelType(t){this._modelType=t}get drawViewportsFirst(){return this._drawViewportsFirst}set drawViewportsFirst(t){this._drawViewportsFirst=t}setDrawViewportsFirst(t){this._drawViewportsFirst=t}get plotCentered(){return this._plotCentered}set plotCentered(t){this._plotCentered=t}setPlotCentered(t){this._plotCentered=t}get plotHidden(){return this._plotHidden}set plotHidden(t){this._plotHidden=t}setPlotHidden(t){this._plotHidden=t}get plotPaperUnits(){return this._plotPaperUnits}set plotPaperUnits(t){this._plotPaperUnits=t}get plotPlotStyles(){return this._plotPlotStyles}set plotPlotStyles(t){this._plotPlotStyles=t}setPlotPlotStyles(t){this._plotPlotStyles=t}get plotRotation(){return this._plotRotation}set plotRotation(t){this._plotRotation=t}get plotType(){return this._plotType}set plotType(t){this._plotType=t}get plotViewportBorders(){return this._plotViewportBorders}set plotViewportBorders(t){this._plotViewportBorders=t}setPlotViewportBorders(t){this._plotViewportBorders=t}get printLineweights(){return this._printLineweights}set printLineweights(t){this._printLineweights=t}setPrintLineweights(t){this._printLineweights=t}get scaleLineweights(){return this._scaleLineweights}set scaleLineweights(t){this._scaleLineweights=t}setScaleLineweights(t){this._scaleLineweights=t}get showPlotStyles(){return this._showPlotStyles}set showPlotStyles(t){this._showPlotStyles=t}setShowPlotStyles(t){this._showPlotStyles=t}get shadePlot(){return this._shadePlotType}set shadePlot(t){this._shadePlotType=t}setShadePlot(t){this._shadePlotType=t}get shadePlotResLevel(){return this._shadePlotResLevel}set shadePlotResLevel(t){this._shadePlotResLevel=t}setShadePlotResLevel(t){this._shadePlotResLevel=t}get shadePlotCustomDPI(){return this._shadePlotCustomDpi}set shadePlotCustomDPI(t){this._shadePlotCustomDpi=t}setShadePlotCustomDPI(t){this._shadePlotCustomDpi=t}get shadePlotId(){return this._shadePlotId}set shadePlotId(t){this._shadePlotId=t}get plotWireframe(){return this._shadePlotType===1}get plotAsRaster(){return this._shadePlotType===3||this._shadePlotType===4||this._shadePlotType===5}get stdScaleType(){return this._stdScaleType}set stdScaleType(t){this._stdScaleType=t}get stdScale(){return Hc[this._stdScaleType]??1}get useStandardScale(){return this._useStandardScale}set useStandardScale(t){this._useStandardScale=t}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPlotSettings"),t.writeString(1,this.plotSettingsName),t.writeString(2,this.plotCfgName),t.writeString(4,this.canonicalMediaName),t.writeString(6,this.plotViewName),t.writeDouble(40,this.plotPaperMargins.left),t.writeDouble(41,this.plotPaperMargins.bottom),t.writeDouble(42,this.plotPaperMargins.right),t.writeDouble(43,this.plotPaperMargins.top),t.writeDouble(44,this.plotPaperSize.x),t.writeDouble(45,this.plotPaperSize.y),t.writeDouble(46,this.plotOrigin.x),t.writeDouble(47,this.plotOrigin.y),t.writeDouble(48,this.plotWindowArea.min.x),t.writeDouble(49,this.plotWindowArea.min.y),t.writeDouble(140,this.plotWindowArea.max.x),t.writeDouble(141,this.plotWindowArea.max.y),t.writeDouble(142,this.customPrintScale.numerator),t.writeDouble(143,this.customPrintScale.denominator);let e=0;return this.plotViewportBorders&&(e|=1),this.showPlotStyles&&(e|=2),this.plotCentered&&(e|=4),this.plotHidden&&(e|=8),this.useStandardScale&&(e|=16),this.plotPlotStyles&&(e|=32),this.scaleLineweights&&(e|=64),this.printLineweights&&(e|=128),this.drawViewportsFirst&&(e|=512),this.modelType&&(e|=1024),t.writeInt16(70,e),t.writeInt16(72,this.plotPaperUnits),t.writeInt16(73,this.plotRotation),t.writeInt16(74,this.plotType),t.writeString(7,this.currentStyleSheet),t.writeInt16(75,this.stdScaleType),t.writeInt16(76,this.shadePlot),t.writeInt16(77,this.shadePlotResLevel),t.writeInt16(78,this.shadePlotCustomDPI),t.writeDouble(147,this.stdScale),t.writeObjectId(333,this.shadePlotId),this}}class ii extends hl{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new _t,this._extents=new N,this._viewportArray=[]}get layoutName(){return this._layoutName}set layoutName(t){this._layoutName=t.length>256?t.slice(0,256):t}get tabOrder(){return this._tabOrder}set tabOrder(t){this._tabOrder=t}get tabSelected(){return this._tabSelected}set tabSelected(t){this._tabSelected=t}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(t){this._blockTableRecordId=t}get limits(){return this._limits}set limits(t){this._limits.copy(t)}get extents(){return this._extents}set extents(t){this._extents.copy(t)}get viewportArray(){return this._viewportArray}set viewportArray(t){this._viewportArray=t.slice()}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayout"),t.writeString(1,this.layoutName),t.writeInt16(70,this.tabSelected?1:0),t.writeInt16(71,this.tabOrder),t.writeObjectId(330,this.blockTableRecordId),t.writeObjectId(331,this._viewportArray.length>0?this._viewportArray[0]:"0"),t.writePoint2d(10,this.limits.min),t.writePoint2d(11,this.limits.max),t.writePoint3d(14,this.extents.min),t.writePoint3d(15,this.extents.max),this}}class ni{constructor(t){this.i=0,this._records=t,this._keys=Array.from(t.keys())}get count(){return this._records.size}toArray(){return Array.from(this._records.values())}[Symbol.iterator](){return this}next(){for(;this.i<this._keys.length;){const t=this._records.get(this._keys[this.i]);return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}}}class Ze extends Ft{constructor(t){super(),this.database=t,this.objectId=t.generateHandle(),this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}setAt(t,e){e.database=this.database,e.ownerId=this.objectId,this.database.commitObjectHandle(e,s=>this.hasId(s)),this._recordsByName.set(t,e),this._recordsById.set(e.objectId,e),this.database.events.dictObjetSet.dispatch({database:this.database,object:e,key:t})}remove(t){const e=this.getAt(t);return e?(this._recordsByName.delete(t.toUpperCase()),this._recordsById.delete(this.objectId),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:t}),!0):!1}removeId(t){const e=this.getIdAt(t);return e?(this._recordsById.delete(this.objectId),this._recordsByName.forEach((s,n)=>{s===e&&(this._recordsByName.delete(n),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:n}))}),!0):!1}removeAll(){this._recordsByName.forEach((t,e)=>{this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:e})}),this._recordsByName.clear(),this._recordsById.clear()}has(t){return this._recordsByName.has(t.toUpperCase())}hasId(t){return this._recordsById.has(t)}getAt(t){return this._recordsByName.get(t)}getIdAt(t){return this._recordsById.get(t)}newIterator(){return new ni(this._recordsByName)}entries(){return this._recordsByName.entries()}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbDictionary"),t.writeInt16(280,1),t.writeInt16(281,1);for(const[e,s]of this._recordsByName)t.writeString(3,e),t.writeObjectId(350,s.objectId);return this}}class cl extends Ze{getBtrIdAt(t){for(const[e,s]of this._recordsByName)if(s.blockTableRecordId==t)return s}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class Me extends Ft{constructor(t,e){t=t||{},Qs(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbSymbolTableRecord"),this}}var dl=(i=>(i[i.Any=0]="Any",i[i.Uniform=1]="Uniform",i))(dl||{});const be=class be extends Me{static isModelSapceName(t){return t.toLowerCase()==be.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(be.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new w,this._layoutId="",this._entities=new Map,this._blockInsertUnits=0,this._explodability=1,this._blockScaling=1,this._bmpPreview=void 0}get isModelSapce(){return be.isModelSapceName(this.name)}get isPaperSapce(){return be.isPaperSapceName(this.name)}get origin(){return this._origin}set origin(t){this._origin.copy(t)}get layoutId(){return this._layoutId}set layoutId(t){this._layoutId=t}get blockInsertUnits(){return this._blockInsertUnits}set blockInsertUnits(t){this._blockInsertUnits=t}get explodability(){return this._explodability}set explodability(t){this._explodability=t}get blockScaling(){return this._blockScaling}set blockScaling(t){this._blockScaling=t}get bmpPreview(){return this._bmpPreview}set bmpPreview(t){this._bmpPreview=t}appendEntity(t){const e=s=>{s.database=this.database,s.ownerId=this.objectId,this.database.ensureEntityStyleDefaults(s),this.database.commitObjectHandle(s,n=>this._entities.has(n)),s.resolveEffectiveProperties(),this._entities.set(s.objectId,s)};if(Array.isArray(t))for(let s=0;s<t.length;++s)e(t[s]);else e(t);(this.isModelSapce||this.isPaperSapce)&&this.database.events.entityAppended.dispatch({database:this.database,entity:t})}removeEntity(t){const e=Array.isArray(t)?t:[t],s=[];return e.forEach(n=>{const r=this._entities.get(n);r&&s.push(r),this._entities.delete(n)}),s.length>0&&this.database.events.entityErased.dispatch({database:this.database,entity:s}),s.length>0}newIterator(){return new ni(this._entities)}getIdAt(t){return this._entities.get(t)}dxfOutBlockRecord(t){return t.writeStart("BLOCK_RECORD"),this.dxfOut(t),this}dxfOutBlockBegin(t){return t.writeStart("BLOCK"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeString(8,"0"),t.writeSubclassMarker("AcDbBlockBegin"),t.writeString(2,this.name),t.writeInt16(70,0),t.writePoint3d(10,this.origin),t.writeString(3,this.name),this}dxfOutBlockEnd(t){return t.writeStart("ENDBLK"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbBlockEnd"),this}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbBlockTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.blockInsertUnits),t.writeInt16(280,this.explodability),t.writeInt16(281,this.blockScaling),(this.isModelSapce||this.isPaperSapce)&&t.writeObjectId(340,this.layoutId),this}};be.MODEL_SPACE_NAME="*Model_Space",be.PAPER_SPACE_NAME_PREFIX="*Paper_Space";let J=be;class ul{constructor(){this.events={layoutCreated:new Q,layoutRemoved:new Q,layoutRenamed:new Q,layoutSwitched:new Q}}countLayouts(t){return this.getWorkingDatabase(t).objects.layout.numEntries}findLayoutNamed(t,e){return this.getWorkingDatabase(e).objects.layout.getAt(t)}findActiveLayout(){const t=this.getActiveLayout();return t?t.layoutName:"Model"}setCurrentLayoutId(t,e){const s=this.getWorkingDatabase(e),n=s.objects.layout.getIdAt(t);return this.setCurrentLayoutInternal(n,s)}setCurrentLayoutBtrId(t,e){const s=this.getWorkingDatabase(e),n=s.objects.layout.getBtrIdAt(t);return this.setCurrentLayoutInternal(n,s)}setCurrentLayout(t,e){const s=this.getWorkingDatabase(e),n=s.objects.layout.getAt(t);return this.setCurrentLayoutInternal(n,s)}renameLayout(t,e,s){const r=this.getWorkingDatabase(s).objects.layout.getAt(t);return r?(r.layoutName=e,this.events.layoutRenamed.dispatch({layout:r,oldName:t,newName:e}),!0):!1}layoutExists(t,e){return this.getWorkingDatabase(e).objects.layout.has(t)}deleteLayout(t,e){const s=this.getWorkingDatabase(e).objects.layout,n=s.getAt(t);let r=!1;return n&&(r=s.remove(t),r&&this.events.layoutRemoved.dispatch({layout:n})),r}createLayout(t,e){const s=this.getWorkingDatabase(e),n=new ii;n.layoutName=t,n.tabOrder=s.objects.layout.maxTabOrder;const r=new J;return r.name=`*Paper_Space${n.tabOrder}`,s.tables.blockTable.add(r),s.objects.layout.setAt(t,n),this.events.layoutCreated.dispatch({layout:n}),{layout:n,btr:r}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.objects.layout.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||tr().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}sa(()=>new ul);class fr extends Ft{constructor(){super(),this._contentType=2,this._drawMLeaderOrderType=1,this._drawLeaderOrderType=0,this._bitFlags=0,this._maxLeaderSegmentsPoints=-1,this._firstSegmentAngleConstraint=0,this._secondSegmentAngleConstraint=0,this._leaderLineType=1,this._leaderLineColor=new j(P.ByLayer),this._leaderLineWeight=-2,this._enableLanding=!0,this._landingGap=2,this._enableDogleg=!0,this._doglegLength=8,this._description="",this._arrowSize=4,this._defaultMTextContents="",this._textLeftAttachmentType=1,this._textAngleType=1,this._textAlignmentType=0,this._textRightAttachmentType=1,this._textColor=new j(P.ByLayer),this._textHeight=4,this._enableFrameText=!1,this._textAlignAlwaysLeft=!1,this._alignSpace=0,this._blockColor=new j(P.ByBlock),this._blockScale=new _(1,1,1),this._enableBlockScale=!0,this._blockRotation=0,this._enableBlockRotation=!1,this._blockConnectionType=0,this._scale=1,this._overwritePropChanged=!1,this._annotative=!1,this._breakSize=0,this._textAttachmentDirection=0,this._bottomTextAttachmentType=9,this._topTextAttachmentType=9,this._extendLeaderToText=!1}get unknown1(){return this._unknown1}set unknown1(t){this._unknown1=t}get contentType(){return this._contentType}set contentType(t){this._contentType=t}get drawMLeaderOrderType(){return this._drawMLeaderOrderType}set drawMLeaderOrderType(t){this._drawMLeaderOrderType=t}get drawLeaderOrderType(){return this._drawLeaderOrderType}set drawLeaderOrderType(t){this._drawLeaderOrderType=t}get bitFlags(){return this._bitFlags}set bitFlags(t){this._bitFlags=t}get maxLeaderSegmentsPoints(){return this._maxLeaderSegmentsPoints}set maxLeaderSegmentsPoints(t){this._maxLeaderSegmentsPoints=t}get maxLeaderSegmentPoints(){return this.maxLeaderSegmentsPoints}set maxLeaderSegmentPoints(t){this.maxLeaderSegmentsPoints=t}get firstSegmentAngleConstraint(){return this._firstSegmentAngleConstraint}set firstSegmentAngleConstraint(t){this._firstSegmentAngleConstraint=t}get secondSegmentAngleConstraint(){return this._secondSegmentAngleConstraint}set secondSegmentAngleConstraint(t){this._secondSegmentAngleConstraint=t}get leaderLineType(){return this._leaderLineType}set leaderLineType(t){this._leaderLineType=t}get leaderLineColor(){return this._leaderLineColor}set leaderLineColor(t){this._leaderLineColor.copy(t)}get leaderLineTypeId(){return this._leaderLineTypeId}set leaderLineTypeId(t){this._leaderLineTypeId=t}get leaderLineWeight(){return this._leaderLineWeight}set leaderLineWeight(t){this._leaderLineWeight=t}get enableLanding(){return this._enableLanding}set enableLanding(t){this._enableLanding=t}get landingEnabled(){return this.enableLanding}set landingEnabled(t){this.enableLanding=t}get landingGap(){return this._landingGap}set landingGap(t){this._landingGap=t}get enableDogleg(){return this._enableDogleg}set enableDogleg(t){this._enableDogleg=t}get doglegEnabled(){return this.enableDogleg}set doglegEnabled(t){this.enableDogleg=t}get doglegLength(){return this._doglegLength}set doglegLength(t){this._doglegLength=t}get description(){return this._description}set description(t){this._description=t}get arrowSymbolId(){return this._arrowSymbolId}set arrowSymbolId(t){this._arrowSymbolId=t}get arrowheadId(){return this.arrowSymbolId}set arrowheadId(t){this.arrowSymbolId=t}get arrowSize(){return this._arrowSize}set arrowSize(t){this._arrowSize=t}get arrowheadSize(){return this.arrowSize}set arrowheadSize(t){this.arrowSize=t}get defaultMTextContents(){return this._defaultMTextContents}set defaultMTextContents(t){this._defaultMTextContents=t}get defaultMText(){return this.defaultMTextContents}set defaultMText(t){this.defaultMTextContents=t}get textString(){return this.defaultMTextContents}set textString(t){this.defaultMTextContents=t}get textStyleId(){return this._textStyleId}set textStyleId(t){this._textStyleId=t}get textStyle(){return this.textStyleId}set textStyle(t){this.textStyleId=t}get textLeftAttachmentType(){return this._textLeftAttachmentType}set textLeftAttachmentType(t){this._textLeftAttachmentType=t}get textAngleType(){return this._textAngleType}set textAngleType(t){this._textAngleType=t}get textAlignmentType(){return this._textAlignmentType}set textAlignmentType(t){this._textAlignmentType=t}get textRightAttachmentType(){return this._textRightAttachmentType}set textRightAttachmentType(t){this._textRightAttachmentType=t}get textColor(){return this._textColor}set textColor(t){this._textColor.copy(t)}get textHeight(){return this._textHeight}set textHeight(t){this._textHeight=t}get enableFrameText(){return this._enableFrameText}set enableFrameText(t){this._enableFrameText=t}get textFrameEnabled(){return this.enableFrameText}set textFrameEnabled(t){this.enableFrameText=t}get textAlignAlwaysLeft(){return this._textAlignAlwaysLeft}set textAlignAlwaysLeft(t){this._textAlignAlwaysLeft=t}get alignSpace(){return this._alignSpace}set alignSpace(t){this._alignSpace=t}get blockId(){return this._blockId}set blockId(t){this._blockId=t}get blockContentId(){return this.blockId}set blockContentId(t){this.blockId=t}get blockColor(){return this._blockColor}set blockColor(t){this._blockColor.copy(t)}get blockContentColor(){return this.blockColor}set blockContentColor(t){this.blockColor=t}get blockScale(){return this._blockScale.clone()}set blockScale(t){this._blockScale.copy(t)}get blockContentScale(){return this.blockScale}set blockContentScale(t){this.blockScale=t}get enableBlockScale(){return this._enableBlockScale}set enableBlockScale(t){this._enableBlockScale=t}get blockContentScaleEnabled(){return this.enableBlockScale}set blockContentScaleEnabled(t){this.enableBlockScale=t}get blockRotation(){return this._blockRotation}set blockRotation(t){this._blockRotation=t}get blockContentRotation(){return this.blockRotation}set blockContentRotation(t){this.blockRotation=t}get enableBlockRotation(){return this._enableBlockRotation}set enableBlockRotation(t){this._enableBlockRotation=t}get blockContentRotationEnabled(){return this.enableBlockRotation}set blockContentRotationEnabled(t){this.enableBlockRotation=t}get blockConnectionType(){return this._blockConnectionType}set blockConnectionType(t){this._blockConnectionType=t}get blockContentConnectionType(){return this.blockConnectionType}set blockContentConnectionType(t){this.blockConnectionType=t}get scale(){return this._scale}set scale(t){this._scale=t}get scaleFactor(){return this.scale}set scaleFactor(t){this.scale=t}get overwritePropChanged(){return this._overwritePropChanged}set overwritePropChanged(t){this._overwritePropChanged=t}get overwritePropertyValue(){return this.overwritePropChanged}set overwritePropertyValue(t){this.overwritePropChanged=t}get annotative(){return this._annotative}set annotative(t){this._annotative=t}get breakSize(){return this._breakSize}set breakSize(t){this._breakSize=t}get breakGapSize(){return this.breakSize}set breakGapSize(t){this.breakSize=t}get textAttachmentDirection(){return this._textAttachmentDirection}set textAttachmentDirection(t){this._textAttachmentDirection=t}get bottomTextAttachmentType(){return this._bottomTextAttachmentType}set bottomTextAttachmentType(t){this._bottomTextAttachmentType=t}get bottomTextAttachmentDirection(){return this.bottomTextAttachmentType}set bottomTextAttachmentDirection(t){this.bottomTextAttachmentType=t}get topTextAttachmentType(){return this._topTextAttachmentType}set topTextAttachmentType(t){this._topTextAttachmentType=t}get topTextAttachmentDirection(){return this.topTextAttachmentType}set topTextAttachmentDirection(t){this.topTextAttachmentType=t}get extendLeaderToText(){return this._extendLeaderToText}set extendLeaderToText(t){this._extendLeaderToText=t}get unknown2(){return this._unknown2}set unknown2(t){this._unknown2=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMLeaderStyle"),t.writeInt16(179,this.unknown1),t.writeInt16(170,this.contentType),t.writeInt16(171,this.drawMLeaderOrderType),t.writeInt16(172,this.drawLeaderOrderType),t.writeInt32(90,this.maxLeaderSegmentsPoints),t.writeDouble(40,this.firstSegmentAngleConstraint),t.writeDouble(41,this.secondSegmentAngleConstraint),t.writeInt16(173,this.leaderLineType),t.writeInt32(91,Ti(this.leaderLineColor)),t.writeHandle(340,this.leaderLineTypeId),t.writeInt32(92,this.leaderLineWeight),t.writeBoolean(290,this.enableLanding),t.writeDouble(42,this.landingGap),t.writeBoolean(291,this.enableDogleg),t.writeDouble(43,this.doglegLength),t.writeString(3,this.description),t.writeHandle(341,this.arrowSymbolId),t.writeDouble(44,this.arrowSize),t.writeString(300,this.defaultMTextContents),t.writeHandle(342,this.textStyleId),t.writeInt16(174,this.textLeftAttachmentType),t.writeInt16(175,this.textAngleType),t.writeInt16(176,this.textAlignmentType),t.writeInt16(178,this.textRightAttachmentType),t.writeInt32(93,Ti(this.textColor)),t.writeDouble(45,this.textHeight),t.writeBoolean(292,this.enableFrameText),t.writeBoolean(297,this.textAlignAlwaysLeft),t.writeDouble(46,this.alignSpace),t.writeHandle(343,this.blockId),t.writeInt32(94,Ti(this.blockColor)),t.writeDouble(47,this._blockScale.x),t.writeDouble(49,this._blockScale.y),t.writeDouble(140,this._blockScale.z),t.writeBoolean(293,this.enableBlockScale),t.writeDouble(141,this.blockRotation),t.writeBoolean(294,this.enableBlockRotation),t.writeInt16(177,this.blockConnectionType),t.writeDouble(142,this.scale),t.writeBoolean(295,this.overwritePropChanged),t.writeBoolean(296,this.annotative),t.writeDouble(143,this.breakSize),t.writeInt16(271,this.textAttachmentDirection),t.writeInt16(272,this.bottomTextAttachmentType),t.writeInt16(273,this.topTextAttachmentType),t.writeBoolean(298,this.unknown2),this}}class Sr extends Ft{constructor(){super(),this._styleName="STANDARD",this._flags=0,this._description="",this._fillColor=new j,this._startAngle=90,this._endAngle=90,this._elements=[]}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get flags(){return this._flags}set flags(t){this._flags=t}get description(){return this._description}set description(t){this._description=t}get fillColor(){return this._fillColor}set fillColor(t){this._fillColor.copy(t)}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=t}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=t}get elementCount(){return this._elements.length}get elements(){return this._elements.map(t=>({offset:t.offset,color:t.color.clone(),lineType:t.lineType}))}set elements(t){this._elements=t.map(e=>({offset:e.offset,color:e.color.clone(),lineType:e.lineType}))}addElement(t){this._elements.push({offset:t.offset,color:t.color.clone(),lineType:t.lineType})}removeElementAt(t){if(t<0||t>=this._elements.length)throw new Error("The element index is out of range!");this._elements.splice(t,1)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMlineStyle"),t.writeString(2,this.styleName),t.writeInt16(70,this.flags),t.writeString(3,this.description),t.writeCmColor(this.fillColor),t.writeDouble(51,this.startAngle),t.writeDouble(52,this.endAngle),t.writeInt16(71,this.elementCount),this._elements.forEach(e=>{t.writeDouble(49,e.offset),t.writeCmColor(e.color),t.writeString(6,e.lineType)}),this}}class gl extends Ft{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRasterImageDef"),t.writeString(1,this.sourceFileName),t.writeInt16(280,1),t.writeInt16(281,0),this}}var pl=(i=>(i[i.NotApplicable=0]="NotApplicable",i[i.Ignore=1]="Ignore",i[i.Replace=2]="Replace",i[i.XrefMangleName=3]="XrefMangleName",i[i.MangleName=4]="MangleName",i))(pl||{});class Gc extends Ft{constructor(){super(...arguments),this._data=null}get data(){return this._data}set data(t){this._data=t}clear(){var t;(t=this._data)==null||t.clear()}clone(){return super.clone()}getDuplicateRecordCloning(){return 0}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbXrecord"),t.writeInt16(280,1),t.writeResultBuffer(this.data),this}}class ml{constructor(t){this.db=t}createDefaultLayer(){const t=new j;return t.colorIndex=7,this.db.tables.layerTable.add(new mn({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new Ae({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new Ae({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new Ae({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new yn({name:Z,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new ts({name:Z,dimtxsty:Z}))}createDefaultLayout(){const t=new ii;t.layoutName="Model",t.tabOrder=0,t.blockTableRecordId=this.db.tables.blockTable.modelSpace.objectId,t.limits.min.copy({x:0,y:0}),t.limits.max.copy({x:1e6,y:1e6}),t.extents.min.copy({x:0,y:0,z:0}),t.extents.max.copy({x:1e6,y:1e6,z:0}),this.db.objects.layout.setAt(t.layoutName,t),this.db.tables.blockTable.modelSpace.layoutId=t.objectId}createArrowBlock(){if(!this.db.tables.blockTable.getAt("_CAXARROW")){const e=new Us;e.patternName="SOLID";const s=new Gs;s.add(new Wt({x:0,y:0},{x:-1,y:.125})),s.add(new Wt({x:-1,y:.125},{x:-1,y:-.125})),s.add(new Wt({x:-1,y:-.125},{x:0,y:0})),e.add(s);const n=new J;n.name="_CAXARROW",n.appendEntity(e),this.db.tables.blockTable.add(n)}}}var yl=(i=>(i.ClosedFilled="",i.Dot="_DOT",i.DotSmall="_DOTSMALL",i.DotBlank="_DOTBLANK",i.Origin="_ORIGIN",i.Origin2="_ORIGIN2",i.Open="_OPEN",i.Open90="_OPEN90",i.Open30="_OPEN30",i.Closed="_CLOSED",i.Small="_SMALL",i.None="_NONE",i.Oblique="_OBLIQUE",i.BoxFilled="_BOXFILLED",i.Box="_BOXBLANK",i.ClosedBlank="_CLOSEDBLANK",i.DatumBlank="_DATUMBLANK",i.DatumFilled="_DATUMFILLED",i.Integral="_INTEGRAL",i.ArchTick="_ARCHTICK",i))(yl||{});const Ir=192,ln=193,Ar=194,Pr=195,_l=200;function Ti(i){if(i.isByBlock)return ln<<24>>0;if(i.isByLayer)return Ir<<24>>0;const t=i.colorIndex;if(t!=null&&t>0&&t<256)return(Pr<<24|t&255)>>0;const e=i.RGB;return e!=null?(Ar<<24|e&16777215)>>0:ln<<24>>0}function zs(i){const t=new j(P.ByBlock);switch(i>>>24&255){case Ir:t.setByLayer();break;case ln:case _l:t.setByBlock();break;case Pr:t.colorIndex=i&255;break;case Ar:t.setRGBValue(i&16777215);break;default:i>=0&&i<=256&&(t.colorIndex=i);break}return t}var Tr=(i=>(i[i.Undefined=0]="Undefined",i[i.Inches=1]="Inches",i[i.Feet=2]="Feet",i[i.Miles=3]="Miles",i[i.Millimeters=4]="Millimeters",i[i.Centimeters=5]="Centimeters",i[i.Meters=6]="Meters",i[i.Kilometers=7]="Kilometers",i[i.Microinches=8]="Microinches",i[i.Mils=9]="Mils",i[i.Yards=10]="Yards",i[i.Angstroms=11]="Angstroms",i[i.Nanometers=12]="Nanometers",i[i.Microns=13]="Microns",i[i.Decimeters=14]="Decimeters",i[i.Dekameters=15]="Dekameters",i[i.Hectometers=16]="Hectometers",i[i.Gigameters=17]="Gigameters",i[i.Astronomical=18]="Astronomical",i[i.LightYears=19]="LightYears",i[i.Parsecs=20]="Parsecs",i[i.USSurveyFeet=21]="USSurveyFeet",i[i.USSurveyInch=22]="USSurveyInch",i[i.USSurveyYard=23]="USSurveyYard",i[i.USSurveyMile=24]="USSurveyMile",i[i.Max=24]="Max",i))(Tr||{});function Uc(i){return i==4||i==5||i==6||i==7||i==12||i==13||i==14||i==15||i==16||i==17}function Yc(i){return i==1||i==2||i==3||i==8||i==9||i==10||i==21}class pe extends Ft{constructor(t){super(),this.database=t,this.objectId=t.generateHandle(),this.ownerId=t.objectId,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}add(t){t.database=this.database,t.ownerId=this.objectId,this.database.commitObjectHandle(t,s=>this.hasId(s));const e=this.normalizeName(t.name);this._recordsByName.set(e,t),this._recordsById.set(t.objectId,t)}remove(t){const e=this.normalizeName(t),s=this._recordsByName.get(e);return s?(this._recordsById.delete(s.objectId),this._recordsByName.delete(e),!0):!1}removeId(t){const e=this._recordsById.get(t);return e?(this._recordsByName.delete(this.normalizeName(e.name)),this._recordsById.delete(t),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(t){const e=this.normalizeName(t);return this._recordsByName.has(e)}hasId(t){return this._recordsById.has(t)}getAt(t){const e=this.normalizeName(t);return this._recordsByName.get(e)}getIdAt(t){return this._recordsById.get(t)}getOwnerIdAt(t){return this._recordsById.get(t)}newIterator(){return new ni(this._recordsByName)}normalizeName(t){return t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbSymbolTable"),t.writeInt16(70,this.numEntries),this}}class xl extends pe{constructor(t){super(t)}get modelSpace(){let t=this.getAt(J.MODEL_SPACE_NAME);return t||(t=new J,t.name=J.MODEL_SPACE_NAME,this.add(t)),t}getEntityById(t){for(const e of this.database.tables.blockTable.newIterator()){const s=e.getIdAt(t);if(s)return s}}removeEntity(t){let e=!1;for(const s of this.database.tables.blockTable.newIterator())if(s.removeEntity(t)){e=!0;break}return e}normalizeName(t){let e=t;if(J.isModelSapceName(t))e=J.MODEL_SPACE_NAME;else if(J.isPaperSapceName(t)){const s=J.PAPER_SPACE_NAME_PREFIX,n=t.substring(s.length);e=s+n}return e}}class wl extends pe{constructor(t){super(t)}}var bl=(i=>(i[i.Center=0]="Center",i[i.Left=1]="Left",i[i.Right=2]="Right",i[i.OverFirst=3]="OverFirst",i[i.OverSecond=4]="OverSecond",i))(bl||{}),fl=(i=>(i[i.Center=0]="Center",i[i.Above=1]="Above",i[i.Outside=2]="Outside",i[i.JIS=3]="JIS",i[i.Below=4]="Below",i))(fl||{}),Sl=(i=>(i[i.Feet=0]="Feet",i[i.None=1]="None",i[i.Inch=2]="Inch",i[i.FeetAndInch=3]="FeetAndInch",i[i.Leading=4]="Leading",i[i.Trailing=8]="Trailing",i[i.LeadingAndTrailing=12]="LeadingAndTrailing",i))(Sl||{}),Il=(i=>(i[i.None=0]="None",i[i.Leading=1]="Leading",i[i.Trailing=2]="Trailing",i[i.LeadingAndTrailing=3]="LeadingAndTrailing",i))(Il||{}),Al=(i=>(i[i.Bottom=0]="Bottom",i[i.Middle=1]="Middle",i[i.Top=2]="Top",i))(Al||{});const dn=class dn extends Me{constructor(t,e){t=t||{},Qs(t,dn.DEFAULT_DIM_VALUES),super(t,e)}get dimpost(){return this.getAttr("dimpost")}set dimpost(t){this.setAttr("dimpost",t)}get dimapost(){return this.getAttr("dimapost")}set dimapost(t){this.setAttr("dimapost",t)}get dimscale(){return this.getAttr("dimscale")}set dimscale(t){this.setAttr("dimscale",t)}get dimasz(){return this.getAttr("dimasz")}set dimasz(t){this.setAttr("dimasz",t)}get dimexo(){return this.getAttr("dimexo")}set dimexo(t){this.setAttr("dimexo",t)}get dimdli(){return this.getAttr("dimdli")}set dimdli(t){this.setAttr("dimdli",t)}get dimexe(){return this.getAttr("dimexe")}set dimexe(t){this.setAttr("dimexe",t)}get dimrnd(){return this.getAttr("dimrnd")}set dimrnd(t){this.setAttr("dimrnd",t)}get dimdle(){return this.getAttr("dimdle")}set dimdle(t){this.setAttr("dimdle",t)}get dimtp(){return this.getAttr("dimtp")}set dimtp(t){this.setAttr("dimtp",t)}get dimtm(){return this.getAttr("dimtm")}set dimtm(t){this.setAttr("dimtm",t)}get dimtxt(){return this.getAttr("dimtxt")}set dimtxt(t){this.setAttr("dimtxt",t)}get dimcen(){return this.getAttr("dimcen")}set dimcen(t){this.setAttr("dimcen",t)}get dimtsz(){return this.getAttr("dimtsz")}set dimtsz(t){this.setAttr("dimtsz",t)}get dimaltf(){return this.getAttr("dimaltf")}set dimaltf(t){this.setAttr("dimaltf",t)}get dimlfac(){return this.getAttr("dimlfac")}set dimlfac(t){this.setAttr("dimlfac",t)}get dimtvp(){return this.getAttr("dimtvp")}set dimtvp(t){this.setAttr("dimtvp",t)}get dimtfac(){return this.getAttr("dimtfac")}set dimtfac(t){this.setAttr("dimtfac",t)}get dimgap(){return this.getAttr("dimgap")}set dimgap(t){this.setAttr("dimgap",t)}get dimaltrnd(){return this.getAttr("dimaltrnd")}set dimaltrnd(t){this.setAttr("dimaltrnd",t)}get dimtol(){return this.getAttr("dimtol")}set dimtol(t){this.setAttr("dimtol",t)}get dimlim(){return this.getAttr("dimlim")}set dimlim(t){this.setAttr("dimlim",t)}get dimtih(){return this.getAttr("dimtih")}set dimtih(t){this.setAttr("dimtih",t)}get dimtoh(){return this.getAttr("dimtoh")}set dimtoh(t){this.setAttr("dimtoh",t)}get dimse1(){return this.getAttr("dimse1")}set dimse1(t){this.setAttr("dimse1",t)}get dimse2(){return this.getAttr("dimse2")}set dimse2(t){this.setAttr("dimse2",t)}get dimtad(){return this.getAttr("dimtad")}set dimtad(t){this.setAttr("dimtad",t)}get dimzin(){return this.getAttr("dimzin")}set dimzin(t){this.setAttr("dimzin",t)}get dimazin(){return this.getAttr("dimazin")}set dimazin(t){this.setAttr("dimazin",t)}get dimalt(){return this.getAttr("dimalt")}set dimalt(t){this.setAttr("dimalt",t)}get dimaltd(){return this.getAttr("dimaltd")}set dimaltd(t){this.setAttr("dimaltd",t)}get dimtofl(){return this.getAttr("dimtofl")}set dimtofl(t){this.setAttr("dimtofl",t)}get dimsah(){return this.getAttr("dimsah")}set dimsah(t){this.setAttr("dimsah",t)}get dimtix(){return this.getAttr("dimtix")}set dimtix(t){this.setAttr("dimtix",t)}get dimsoxd(){return this.getAttr("dimsoxd")}set dimsoxd(t){this.setAttr("dimsoxd",t)}get dimclrd(){return this.getAttr("dimclrd")}set dimclrd(t){this.setAttr("dimclrd",t)}get dimclre(){return this.getAttr("dimclre")}set dimclre(t){this.setAttr("dimclre",t)}get dimclrt(){return this.getAttr("dimclrt")}set dimclrt(t){this.setAttr("dimclrt",t)}get dimadec(){return this.getAttr("dimadec")}set dimadec(t){this.setAttr("dimadec",t)}get dimunit(){return this.getAttr("dimunit")}set dimunit(t){this.setAttr("dimunit",t)}get dimdec(){return this.getAttr("dimdec")}set dimdec(t){this.setAttr("dimdec",t)}get dimtdec(){return this.getAttr("dimtdec")}set dimtdec(t){this.setAttr("dimtdec",t)}get dimaltu(){return this.getAttr("dimaltu")}set dimaltu(t){this.setAttr("dimaltu",t)}get dimalttd(){return this.getAttr("dimalttd")}set dimalttd(t){this.setAttr("dimalttd",t)}get dimaunit(){return this.getAttr("dimaunit")}set dimaunit(t){this.setAttr("dimaunit",t)}get dimfrac(){return this.getAttr("dimfrac")}set dimfrac(t){this.setAttr("dimfrac",t)}get dimlunit(){return this.getAttr("dimlunit")}set dimlunit(t){this.setAttr("dimlunit",t)}get dimdsep(){return this.getAttr("dimdsep")}set dimdsep(t){this.setAttr("dimdsep",t)}get dimtmove(){return this.getAttr("dimtmove")}set dimtmove(t){this.setAttr("dimtmove",t)}get dimjust(){return this.getAttr("dimjust")}set dimjust(t){this.setAttr("dimjust",t)}get dimsd1(){return this.getAttr("dimsd1")}set dimsd1(t){this.setAttr("dimsd1",t)}get dimsd2(){return this.getAttr("dimsd2")}set dimsd2(t){this.setAttr("dimsd2",t)}get dimtolj(){return this.getAttr("dimtolj")}set dimtolj(t){this.setAttr("dimtolj",t)}get dimtzin(){return this.getAttr("dimtzin")}set dimtzin(t){this.setAttr("dimtzin",t)}get dimaltz(){return this.getAttr("dimaltz")}set dimaltz(t){this.setAttr("dimaltz",t)}get dimalttz(){return this.getAttr("dimalttz")}set dimalttz(t){this.setAttr("dimalttz",t)}get dimfit(){return this.getAttr("dimfit")}set dimfit(t){this.setAttr("dimfit",t)}get dimupt(){return this.getAttr("dimupt")}set dimupt(t){this.setAttr("dimupt",t)}get dimatfit(){return this.getAttr("dimatfit")}set dimatfit(t){this.setAttr("dimatfit",t)}get dimtxsty(){return this.getAttr("dimtxsty")}set dimtxsty(t){this.setAttr("dimtxsty",t)}get dimldrblk(){return this.getAttr("dimldrblk")}set dimldrblk(t){this.setAttr("dimldrblk",t)}get dimblk(){return this.getAttr("dimblk")}set dimblk(t){this.setAttr("dimblk",t)}get dimblk1(){return this.getAttr("dimblk1")}set dimblk1(t){this.setAttr("dimblk1",t)}get dimblk2(){return this.getAttr("dimblk2")}set dimblk2(t){this.setAttr("dimblk2",t)}get dimlwd(){return this.getAttr("dimlwd")}set dimlwd(t){this.setAttr("dimlwd",t)}get dimlwe(){return this.getAttr("dimlwe")}set dimlwe(t){this.setAttr("dimlwe",t)}dxfOutFields(t){super.dxfOutFields(t);const e=this.database.tables.textStyleTable.getAt(this.dimtxsty),s=this.database.tables.blockTable.getAt(this.dimldrblk),n=this.database.tables.blockTable.getAt(this.dimblk),r=this.database.tables.blockTable.getAt(this.dimblk1),o=this.database.tables.blockTable.getAt(this.dimblk2);return t.writeSubclassMarker("AcDbDimStyleTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),t.writeString(3,this.dimpost),t.writeString(4,this.dimapost),t.writeDouble(40,this.dimscale),t.writeDouble(41,this.dimasz),t.writeDouble(42,this.dimexo),t.writeDouble(43,this.dimdli),t.writeDouble(44,this.dimexe),t.writeDouble(140,this.dimtxt),t.writeDouble(147,this.dimgap),t.writeInt16(170,this.dimalt),t.writeInt16(171,this.dimtol),t.writeInt16(172,this.dimlim),t.writeInt16(173,this.dimtih),t.writeInt16(174,this.dimtoh),t.writeObjectId(340,e==null?void 0:e.objectId),t.writeObjectId(341,s==null?void 0:s.objectId),t.writeObjectId(342,n==null?void 0:n.objectId),t.writeObjectId(343,r==null?void 0:r.objectId),t.writeObjectId(344,o==null?void 0:o.objectId),t.writeInt16(371,this.dimlwd),t.writeInt16(372,this.dimlwe),this}};dn.DEFAULT_DIM_VALUES={name:"",dimpost:"",dimapost:"",dimscale:1,dimasz:2.5,dimexo:.625,dimdli:.38,dimexe:.18,dimrnd:0,dimdle:0,dimtp:0,dimtm:0,dimtxt:2.5,dimcen:2.5,dimtsz:0,dimaltf:0,dimlfac:1,dimtvp:0,dimtfac:1,dimgap:1,dimaltrnd:0,dimtol:0,dimlim:0,dimtih:0,dimtoh:0,dimse1:0,dimse2:0,dimtad:0,dimzin:0,dimazin:0,dimalt:0,dimaltd:2,dimtofl:0,dimsah:0,dimtix:0,dimsoxd:0,dimclrd:0,dimclre:0,dimclrt:0,dimadec:0,dimunit:2,dimdec:4,dimtdec:4,dimaltu:2,dimalttd:2,dimaunit:0,dimfrac:0,dimlunit:2,dimdsep:".",dimtmove:0,dimjust:0,dimsd1:0,dimsd2:0,dimtolj:0,dimtzin:0,dimaltz:0,dimalttz:0,dimfit:0,dimupt:0,dimatfit:3,dimtxsty:Z,dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let ts=dn;class Pl extends pe{constructor(t){super(t)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class mn extends Me{constructor(t,e){t=t||{},Qs(t,{color:new j,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:new gn,linetype:"",lineWeight:1,materialId:-1}),super(t,e),this.attrs.events.attrChanged.addEventListener(s=>{this.database.events.layerModified.dispatch({database:this.database,layer:this,changes:s.object.changedAttributes()})})}get color(){return this.getAttr("color")}set color(t){this.setAttr("color",t.clone())}get description(){return this.getAttr("description")}set description(t){this.setAttr("description",t)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(t){const e=t?1:0;this.standardFlags=this.standardFlags|e}get isHidden(){return this.getAttr("isHidden")}set isHidden(t){this.setAttr("isHidden",t)}get isInUse(){return this.getAttr("isInUse")}set isInUse(t){this.setAttr("isInUse",t)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(t){const e=t?4:0;this.standardFlags=this.standardFlags|e}get isOff(){return this.getAttr("isOff")}set isOff(t){this.setAttr("isOff",t)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(t){this.setAttr("isPlottable",t)}get transparency(){return this.getAttr("transparency")}set transparency(t){this.setAttr("transparency",t.clone())}get linetype(){return this.getAttr("linetype")}set linetype(t){this.setAttr("linetype",t)}get lineStyle(){var e;const t=(e=this.database)==null?void 0:e.tables.linetypeTable.getAt(this.linetype);if(t)return{type:"UserSpecified",...t.linetype}}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(t){this.setAttr("lineWeight",t)}get materialId(){return this.getAttr("materialId")}set materialId(t){this.setAttr("materialId",t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayerTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.standardFlags),t.writeCmColor(this.color),t.writeString(6,this.linetype),t.writeInt16(290,this.isPlottable?1:0),t.writeInt16(370,this.lineWeight),t.writeTransparency(this.transparency),this.description&&t.writeString(4,this.description),this}}class Tl extends pe{constructor(t){super(t)}}class Ae extends Me{constructor(t){super(),this.name=t.name,this._linetype=t}get numDashes(){return this._linetype.pattern?this._linetype.pattern.length:0}get patternLength(){return this._linetype.totalPatternLength}get comments(){return this._linetype.description}get linetype(){return this._linetype}dashLengthAt(t){if(t<0||t>=this.numDashes)throw new Error('Index must be greater than or equal to zero, but less than the value of property "numDashes".');return this._linetype.pattern[t].elementLength}toPreviewSvgString(t){const e=Math.max((t==null?void 0:t.width)??220,1),s=Math.max((t==null?void 0:t.height)??36,1),n=Math.min(Math.max((t==null?void 0:t.padding)??8,0),Math.floor(e/2)),r=Math.max((t==null?void 0:t.strokeWidth)??2,.5),o=this.escapeSvgAttribute((t==null?void 0:t.stroke)??"currentColor"),a=Math.max((t==null?void 0:t.repeats)??4,1),h=s/2,c=n,d=Math.max(e-n,c+1),u=d-c,p=this._linetype.pattern??[];if(p.length===0||this.patternLength<=0||!p.some(S=>S.elementLength!==0))return this.buildSvgString({width:e,height:s,stroke:o,strokeWidth:r,lineSegments:[[c,d]],dots:[],y:h});const g=[],m=[],y=u/(this.patternLength*a),b=.5,x=Math.max(r*2,2);let I=c;for(;I<d;)for(const S of p){if(I>=d)break;const L=S.elementLength;if(L===0){m.push(I),I=Math.min(I+x,d);continue}const A=Math.max(Math.abs(L)*y,b),H=Math.min(I+A,d);L>0&&H>I&&g.push([I,H]),I=H}return this.buildSvgString({width:e,height:s,stroke:o,strokeWidth:r,lineSegments:g,dots:m,y:h})}buildSvgString(t){const{width:e,height:s,stroke:n,strokeWidth:r,lineSegments:o,dots:a,y:h}=t,c=o.map(([u,p])=>`<line x1="${u.toFixed(2)}" y1="${h.toFixed(2)}" x2="${p.toFixed(2)}" y2="${h.toFixed(2)}" stroke="${n}" stroke-width="${r.toFixed(2)}" stroke-linecap="round" />`).join(""),d=a.map(u=>`<circle cx="${u.toFixed(2)}" cy="${h.toFixed(2)}" r="${(r/2).toFixed(2)}" fill="${n}" />`).join("");return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${s}" viewBox="0 0 ${e} ${s}" role="img" aria-label="${this.escapeSvgAttribute(this.name)} linetype preview">${c}${d}</svg>`}escapeSvgAttribute(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;")}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLinetypeTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.linetype.standardFlag),t.writeString(3,this.comments),t.writeInt16(72,65),t.writeInt16(73,this.numDashes),t.writeDouble(40,this.patternLength);for(const e of this.linetype.pattern??[])t.writeDouble(49,e.elementLength),t.writeInt16(74,e.elementTypeFlag);return this}}class El extends pe{constructor(t){super(t)}get fonts(){const t=new Set,e=n=>{if(n){const r=n.lastIndexOf(".");if(r>=0){const o=n.substring(0,r).toLowerCase();t.add(o)}else t.add(n.toLowerCase())}},s=this.newIterator();for(const n of s)e(n.fileName),e(n.bigFontFileName);return Array.from(t)}}class yn extends Me{constructor(t){super(),this.name=t.name,this._textStyle=t,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(t){this._textStyle.obliqueAngle=t}get priorSize(){return this._textStyle.lastHeight}set priorSize(t){this._textStyle.lastHeight=t}get textSize(){return this._textStyle.fixedTextHeight}set textSize(t){this._textStyle.fixedTextHeight=t}get xScale(){return this._textStyle.widthFactor}set xScale(t){this._textStyle.widthFactor=t}get isVertical(){return this._isVertical}set isVertical(t){this._isVertical=t}get fileName(){return this._textStyle.font}set fileName(t){this._textStyle.font=t}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(t){this._textStyle.bigFont=t}get textStyle(){return this._textStyle}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const s=e.lastIndexOf(".");return s===-1?e:e.substring(0,s)}return t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbTextStyleTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.textStyle.standardFlag),t.writeDouble(40,this.textSize),t.writeDouble(41,this.xScale),t.writeAngle(50,this.obliquingAngle),t.writeInt16(71,this.isVertical?4:this.textStyle.textGenerationFlag),t.writeDouble(42,this.priorSize),t.writeString(3,this.fileName),t.writeString(4,this.bigFontFileName),this}}class Ll extends pe{constructor(t){super(t)}}class Ml extends pe{constructor(t){super(t)}}const Xc=()=>({center:new v,viewDirectionFromTarget:new w(0,0,1),viewTarget:new w(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:_r.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new w(0,0,0),ucsXAxis:new w(1,0,0),ucsYAxis:new w(0,1,0),orthographicType:xr.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:wr.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0});class Er extends Me{constructor(){super(),this._gsView=Xc(),this._centerPoint=this._gsView.center}get gsView(){return this._gsView}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get viewDirectionFromTarget(){return this._gsView.viewDirectionFromTarget}set viewDirectionFromTarget(t){this._gsView.viewDirectionFromTarget.copy(t)}get viewTarget(){return this._gsView.viewTarget}set viewTarget(t){this._gsView.viewTarget.copy(t)}get viewHeight(){return this._gsView.viewHeight}set viewHeight(t){this._gsView.viewHeight=t}get viewTwistAngle(){return this._gsView.viewTwistAngle}set viewTwistAngle(t){this._gsView.viewTwistAngle=t}get lensLength(){return this._gsView.lensLength}set lensLength(t){this._gsView.lensLength=t}get frontClippingPlane(){return this._gsView.frontClippingPlane}set frontClippingPlane(t){this._gsView.frontClippingPlane=t}get backClippingPlane(){return this._gsView.backClippingPlane}set backClippingPlane(t){this._gsView.backClippingPlane=t}get renderMode(){return this._gsView.renderMode}set renderMode(t){this._gsView.renderMode=t}get viewMode(){return this._gsView.viewMode}set viewMode(t){this._gsView.viewMode=t}get ucsIconSetting(){return this._gsView.ucsIconSetting}set ucsIconSetting(t){this._gsView.ucsIconSetting=t}get ucsOrigin(){return this._gsView.ucsOrigin}set ucsOrigin(t){this._gsView.ucsOrigin.copy(t)}get ucsXAxis(){return this._gsView.ucsXAxis}set ucsXAxis(t){this._gsView.ucsXAxis.copy(t)}get ucsYAxis(){return this._gsView.ucsYAxis}set ucsYAxis(t){this._gsView.ucsYAxis.copy(t)}get orthographicType(){return this._gsView.orthographicType}set orthographicType(t){this._gsView.orthographicType=t}get shadePlotSetting(){return this._gsView.shadePlotSetting}set shadePlotSetting(t){this._gsView.shadePlotSetting=t}get shadePlotObjectId(){return this._gsView.shadePlotObjectId}set shadePlotObjectId(t){this._gsView.shadePlotObjectId=t}get visualStyleObjectId(){return this._gsView.visualStyleObjectId}set visualStyleObjectId(t){this._gsView.visualStyleObjectId=t}get isDefaultLightingOn(){return this._gsView.isDefaultLightingOn}set isDefaultLightingOn(t){this._gsView.isDefaultLightingOn=t}get defaultLightingType(){return this._gsView.defaultLightingType}set defaultLightingType(t){this._gsView.defaultLightingType=t}get brightness(){return this._gsView.brightness}set brightness(t){this._gsView.brightness=t}get contrast(){return this._gsView.contrast}set contrast(t){this._gsView.contrast=t}get ambientColor(){return this._gsView.ambientColor}set ambientColor(t){this._gsView.ambientColor=t}}class Lr extends Er{constructor(){super(),this._circleSides=100,this._lowerLeftCorner=new v(0,0),this._upperRightCorner=new v(1,1),this._snapBase=new v(0,0),this._snapAngle=0,this._snapSpacing=new v(0,0),this._standardFlag=0,this._gridSpacing=new v,this._gridMajor=10}get circleSides(){return this._circleSides}set circleSides(t){this._circleSides=t}get center(){return this.centerPoint}set center(t){this.centerPoint=t}get lowerLeftCorner(){return this._lowerLeftCorner}set lowerLeftCorner(t){this._lowerLeftCorner.copy(t)}get upperRightCorner(){return this._upperRightCorner}set upperRightCorner(t){this._upperRightCorner.copy(t)}get snapBase(){return this._snapBase}set snapBase(t){this._snapBase.copy(t)}get snapAngle(){return this._snapAngle}set snapAngle(t){this._snapAngle=t}get snapIncrements(){return this._snapSpacing}set snapIncrements(t){this._snapSpacing.copy(t)}get gridMajor(){return this._gridMajor}set gridMajor(t){this._gridMajor=t}get gridIncrements(){return this._gridSpacing}set gridIncrements(t){this._gridSpacing.copy(t)}get standardFlag(){return this._standardFlag}set standardFlag(t){this._standardFlag=t}get snapEnabled(){return!!(this._standardFlag&256)}get backgroundObjectId(){return this._backgroundObjectId}set backgroundObjectId(t){this._backgroundObjectId=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbViewportTableRecord"),t.writeString(2,this.name),t.writeDouble(45,this.gsView.viewHeight),t.writePoint2d(10,this.lowerLeftCorner),t.writePoint2d(11,this.upperRightCorner),t.writePoint2d(12,this.center),t.writePoint2d(13,this.snapBase),t.writePoint2d(14,this.snapIncrements),t.writePoint2d(15,this.gridIncrements),t.writeInt16(70,this.standardFlag),t.writeInt16(71,this.circleSides),t.writeDouble(42,this.gsView.lensLength),t.writePoint3d(16,this.gsView.viewDirectionFromTarget),t.writePoint3d(17,this.gsView.viewTarget),t.writeAngle(50,this.snapAngle),t.writeAngle(51,this.gsView.viewTwistAngle),t.writeInt16(61,this.gridMajor),t.writeInt16(281,this.backgroundObjectId?1:0),t.writeObjectId(332,this.backgroundObjectId),this}}class kl extends pe{constructor(t){super(t)}}class Zn extends Me{constructor(t){super(),this.name=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRegAppTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),this}}const B={ACADVER:"ACADVER",ANGBASE:"ANGBASE",ANGDIR:"ANGDIR",AUNITS:"AUNITS",CECOLOR:"CECOLOR",CELTYPE:"CELTYPE",CELTSCALE:"CELTSCALE",CELWEIGHT:"CELWEIGHT",CLAYER:"CLAYER",CMLSTYLE:"CMLSTYLE",CMLSCALE:"CMLSCALE",CMLEADERSTYLE:"CMLEADERSTYLE",COLORTHEME:"COLORTHEME",DYNMODE:"DYNMODE",DYNPROMPT:"DYNPROMPT",EXTMAX:"EXTMAX",EXTMIN:"EXTMIN",INSUNITS:"INSUNITS",LTSCALE:"LTSCALE",LWDISPLAY:"LWDISPLAY",MEASUREMENTCOLOR:"MEASUREMENTCOLOR",OSMODE:"OSMODE",PDMODE:"PDMODE",PDSIZE:"PDSIZE",PICKBOX:"PICKBOX",SHORTCUTMENU:"SHORTCUTMENU",TEXTSTYLE:"TEXTSTYLE",WHITEBKCOLOR:"WHITEBKCOLOR"},$c=Object.freeze(Object.values(B)),un=class un{constructor(){this.registry=new Map,this.cache=new Map,this.events={sysVarChanged:new Q},this.registerVar({name:B.CECOLOR,type:"color",isDbVar:!0,defaultValue:new j(P.ByLayer)}),this.registerVar({name:B.CELTSCALE,type:"number",isDbVar:!0,defaultValue:-1}),this.registerVar({name:B.CELTYPE,type:"string",isDbVar:!0,defaultValue:dt}),this.registerVar({name:B.CELWEIGHT,type:"number",isDbVar:!0,defaultValue:Qe.ByLayer}),this.registerVar({name:B.CLAYER,type:"string",isDbVar:!0,defaultValue:"0"}),this.registerVar({name:B.CMLSTYLE,type:"string",isDbVar:!0,defaultValue:ce}),this.registerVar({name:B.CMLSCALE,type:"number",isDbVar:!0,defaultValue:1}),this.registerVar({name:B.CMLEADERSTYLE,type:"string",isDbVar:!0,defaultValue:de}),this.registerVar({name:B.COLORTHEME,type:"number",isDbVar:!1,defaultValue:"0"}),this.registerVar({name:B.DYNMODE,type:"number",isDbVar:!1,defaultValue:3}),this.registerVar({name:B.DYNPROMPT,type:"boolean",isDbVar:!1,defaultValue:!0}),this.registerVar({name:B.LWDISPLAY,type:"boolean",isDbVar:!0,defaultValue:!1}),this.registerVar({name:B.MEASUREMENTCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new j(P.ByColor);return t.setRGB(96,165,250),t})()}),this.registerVar({name:B.OSMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:B.PICKBOX,type:"number",isDbVar:!1,defaultValue:10}),this.registerVar({name:B.SHORTCUTMENU,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:B.TEXTSTYLE,type:"string",isDbVar:!0,defaultValue:Z}),this.registerVar({name:B.WHITEBKCOLOR,type:"boolean",isDbVar:!1,defaultValue:!1})}static instance(){return this._instance||(this._instance=new un),this._instance}registerVar(t){const e=this.normalizeName(t.name);this.registry.set(e,{...t,name:e}),t.isDbVar||this.cache.set(e,t.defaultValue)}registerMany(t){t.forEach(e=>this.registerVar(e))}getVar(t,e){t=this.normalizeName(t);const s=this.getDescriptor(t);if(!s)throw new Error(`System variable ${t} not found!`);if(s.isDbVar)return e[t.toLowerCase()];if(this.cache.has(t))return this.cache.get(t)}getDefaultValue(t){t=this.normalizeName(t);const e=this.getDescriptor(t);if(!e)throw new Error(`System variable ${t} not found!`);return e.defaultValue}setVar(t,e,s){t=this.normalizeName(t);const n=this.getDescriptor(t);if(n){const r=this.getVar(t,s);if(n.type!=="string"&&(typeof e=="string"||e instanceof String)){if(n.type==="number"){const o=Number(e);if(Number.isNaN(o))throw new Error("Invalid number input!");e=o}else if(n.type==="boolean")e=this.parseBoolean(e);else if(n.type==="color"){const o=j.fromString(e);if(o==null)throw new Error("Invalid color value!");e=o}}n.isDbVar?s[t.toLowerCase()]=e:(this.cache.set(t,e),this.hasValueChanged(r,e)&&this.events.sysVarChanged.dispatch({database:s,name:t,newVal:e,oldVal:r}))}else throw new Error(`System variable ${t} not found!`)}getDescriptor(t){return this.registry.get(this.normalizeName(t))}getAllDescriptors(){return[...this.registry.values()]}parseBoolean(t){if(t==null)return!1;const e=String(t).trim().toLowerCase(),s=new Set(["true","t","1","yes","y"]),n=new Set(["false","f","0","no","n"]);return s.has(e)?!0:(n.has(e),!1)}hasValueChanged(t,e){return t instanceof j&&e instanceof j?!t.equals(e):!Object.is(t,e)}normalizeName(t){return t.toLowerCase()}};un._instance=null;let Ks=un;class qc extends Ft{constructor(){super({objectId:"0"}),this.events={dictObjetSet:new Q,dictObjectErased:new Q,entityAppended:new Q,entityModified:new Q,entityErased:new Q,layerAppended:new Q,layerModified:new Q,layerErased:new Q,openProgress:new Q},this._version=new kt("AC1014"),this._angBase=0,this._angDir=0,this._aunits=ir.DecimalDegrees,this._celtscale=1,this._cecolor=new j,this._celtype=dt,this._celweight=Qe.ByLayer,this._clayer="0",this._cmlstyle=ce,this._cmlscale=1,this._cmleaderstyle=de,this._textstyle=Z,this._extents=new N,this._insunits=Tr.Millimeters,this._ltscale=1,this._lwdisplay=!1,this._pdmode=0,this._pdsize=0,this._osmode=0,this._maxHandle=0,this._tables={appIdTable:new kl(this),blockTable:new xl(this),dimStyleTable:new wl(this),linetypeTable:new Tl(this),textStyleTable:new El(this),viewTable:new Ll(this),layerTable:new Pl(this),viewportTable:new Ml(this)},this._objects={dictionary:new Ze(this),imageDefinition:new Ze(this),layout:new cl(this),mleaderStyle:new Ze(this),mlineStyle:new Ze(this),xrecord:new Ze(this)}}get tables(){return this._tables}get objects(){return this._objects}generateHandle(){return this._maxHandle++,this._maxHandle.toString(16).toUpperCase()}updateMaxHandle(t){const e=parseInt(t,16);!isNaN(e)&&e>this._maxHandle&&(this._maxHandle=e)}commitObjectHandle(t,e){const s=t.getAttrWithoutException("objectId");!s||t.isTemp||e&&e(s)?t.objectId=this.generateHandle():this.updateMaxHandle(s)}get currentSpaceId(){return this._currentSpace||(this._currentSpace=this._tables.blockTable.modelSpace),this._currentSpace.objectId}set currentSpaceId(t){const e=this.tables.blockTable.getIdAt(t);if(e==null)throw new Error(`[AcDbDatabase] The specified block table record id '${t}' doesn't exist in the drawing database!`);this._currentSpace=e}get aunits(){return this._aunits}set aunits(t){this.updateSysVar(B.AUNITS,this._aunits,t??0,e=>{this._aunits=e})}get version(){return this._version}set version(t){this.updateSysVar(B.ACADVER,this._version,new kt(t),e=>{this._version=e})}get insunits(){return this._insunits}set insunits(t){this.updateSysVar(B.INSUNITS,this._insunits,t??4,e=>{this._insunits=e})}get ltscale(){return this._ltscale}set ltscale(t){this.updateSysVar(B.LTSCALE,this._ltscale,t??1,e=>{this._ltscale=e})}get lwdisplay(){return this._lwdisplay}set lwdisplay(t){this.updateSysVar(B.LWDISPLAY,this._lwdisplay,t??!1,e=>{this._lwdisplay=e})}get cecolor(){return this._cecolor}set cecolor(t){this.updateSysVar(B.CECOLOR,this._cecolor,t||0,e=>{this._cecolor=e.clone()})}get celtscale(){return this._celtscale}set celtscale(t){this.updateSysVar(B.CELTSCALE,this._celtscale,t??1,e=>{this._celtscale=e})}get celtype(){return this._celtype}set celtype(t){const e=this.normalizeLinetypeName(t??dt);this.updateSysVar(B.CELTYPE,this._celtype,e,s=>{this._celtype=s})}get celweight(){return this._celweight}set celweight(t){this.updateSysVar(B.CELWEIGHT,this._celweight,t??Qe.ByLayer,e=>{this._celweight=e})}get clayer(){return this._clayer}set clayer(t){this.updateSysVar(B.CLAYER,this._clayer,t??"0",e=>{this._clayer=e})}get cmlstyle(){return this._cmlstyle}set cmlstyle(t){this.updateSysVar(B.CMLSTYLE,this._cmlstyle,t??ce,e=>{this._cmlstyle=e})}get cmlscale(){return this._cmlscale}set cmlscale(t){this.updateSysVar(B.CMLSCALE,this._cmlscale,t??1,e=>{this._cmlscale=e})}get cmleaderstyle(){return this._cmleaderstyle}set cmleaderstyle(t){this.updateSysVar(B.CMLEADERSTYLE,this._cmleaderstyle,t??de,e=>{this._cmleaderstyle=e})}get textstyle(){return this._textstyle}set textstyle(t){this.updateSysVar(B.TEXTSTYLE,this._textstyle,t??Z,e=>{this._textstyle=e})}get angBase(){return this._angBase}set angBase(t){this.updateSysVar(B.ANGBASE,this._angBase,t??0,e=>{this._angBase=e})}get angDir(){return this._angDir}set angDir(t){this.updateSysVar(B.ANGDIR,this._angDir,t??0,e=>{this._angDir=e})}get extmax(){return this._extents.max}set extmax(t){if(t){const e=this._extents.max.clone();this._extents.expandByPoint(t),this._extents.max.equals(e)||this.triggerSysVarChangedEvent(B.EXTMAX,e,this._extents.max)}}get extmin(){return this._extents.min}set extmin(t){if(t){const e=this._extents.min.clone();this._extents.expandByPoint(t),this._extents.min.equals(e)||this.triggerSysVarChangedEvent(B.EXTMIN,e,this._extents.min)}}get extents(){return this._extents}get pdmode(){return this._pdmode}set pdmode(t){this.updateSysVar(B.PDMODE,this._pdmode,t??0,e=>{this._pdmode=e})}get pdsize(){return this._pdsize}set pdsize(t){this.updateSysVar(B.PDSIZE,this._pdsize,t??0,e=>{this._pdsize=e})}get osmode(){return this._osmode}set osmode(t){this.updateSysVar(B.OSMODE,this._osmode,t??0,e=>{this._osmode=e})}async read(t,e,s=Os.DXF){const n=Vt.instance.get(s);if(n==null)throw new Error(`Database converter for file type '${s}' isn't registered and can can't read this file!`);this.clear(),await n.read(t,this,e&&e.minimumChunkSize||10,async(r,o,a,h)=>{if(this.events.openProgress.dispatch({database:this,percentage:r,stage:"CONVERSION",subStage:o,subStageStatus:a,data:h}),e&&e.fontLoader&&o=="FONT"&&a=="END"){const c=h||this.tables.textStyleTable.fonts;await e.fontLoader.load(c)}},e==null?void 0:e.timeout,e==null?void 0:e.sysVars),this.ensureDatabaseDefaults()}async openUri(t,e){var g;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",subStageStatus:"START"});const s=await fetch(t);if(!s.ok)throw this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"ERROR"}),new Error(`Failed to fetch file '${t}' with HTTP status code '${s.status}'!`);const n=s.headers.get("content-length"),r=n?parseInt(n,10):null;let o=0;const a=(g=s.body)==null?void 0:g.getReader();if(!a)throw new Error("Failed to get response reader");const h=[];for(;;){const{done:m,value:y}=await a.read();if(m)break;if(h.push(y),o+=y.length,r!==null){const b=Math.round(o/r*100);this.events.openProgress.dispatch({database:this,percentage:b,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const c=new Uint8Array(o);let d=0;for(const m of h)c.set(m,d),d+=m.length;const p=this.getFileNameFromUri(t).toLowerCase().split(".").pop();p==="dwg"?await this.read(c.buffer,e,Os.DWG):p==="dxf"?await this.read(c.buffer,e,Os.DXF):await this.read(c.buffer,e,p),this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}dxfOut(t,e=16,s=this.version.name,n=!1){this.ensureDatabaseDefaults();const r=s instanceof kt?s:new kt(s),o=new Ho({database:this,precision:e,version:r});return this.writeDxfHeaderSection(o),this.writeDxfTablesSection(o,r),this.writeDxfBlocksSection(o),this.writeDxfEntitiesSection(o),this.writeDxfObjectsSection(o),o.writeStart("EOF"),o.toString()}async regen(){await new Kh(this).read(null,this,500,async(e,s,n,r)=>{this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:s,subStageStatus:n,data:r})})}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){const e=new ml(this);t.layer&&e.createDefaultLayer(),t.lineType&&e.createDefaultLineType(),t.textStyle&&e.createDefaultTextStyle(),t.dimStyle&&e.createDefaultDimStyle(),t.layout&&e.createDefaultLayout()}ensureEntityStyleDefaults(t){if(t.dxfTypeName==="MLINE"){this.ensureMLineStyle(this._cmlstyle||ce);return}t.dxfTypeName==="MULTILEADER"&&this.ensureMLeaderStyle(this._cmleaderstyle||de)}ensureDatabaseDefaults(){if(!this.tables.layerTable.has("0")){const e=new j;e.colorIndex=7,this.tables.layerTable.add(new mn({name:"0",standardFlags:0,linetype:Se,lineWeight:0,isOff:!1,color:e,isPlottable:!0}))}if(this.tables.linetypeTable.has(fe)||this.tables.linetypeTable.add(new Ae({name:fe,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(dt)||this.tables.linetypeTable.add(new Ae({name:dt,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(Se)||this.tables.linetypeTable.add(new Ae({name:Se,standardFlag:0,description:"Solid line",totalPatternLength:0})),this.tables.textStyleTable.has(Z)||this.tables.textStyleTable.add(new yn({name:Z,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"})),this.tables.dimStyleTable.has(Z)||this.tables.dimStyleTable.add(new ts({name:Z,dimtxsty:Z})),!this.tables.viewportTable.has("*Active")){const e=new Lr;e.name="*Active",this.tables.viewportTable.add(e)}this.ensureMLineStyle(this._cmlstyle||ce),this.ensureMLeaderStyle(this._cmleaderstyle||de);const t=this.tables.blockTable.modelSpace;if(!this.objects.layout.getAt("Model")){const e=new ii;e.layoutName="Model",e.tabOrder=0,e.blockTableRecordId=t.objectId,e.limits.min.copy({x:0,y:0}),e.limits.max.copy({x:1e6,y:1e6}),e.extents.min.copy({x:0,y:0,z:0}),e.extents.max.copy({x:1e6,y:1e6,z:0}),this.objects.layout.setAt(e.layoutName,e),t.layoutId=e.objectId}this.tables.appIdTable.has(zn)||this.tables.appIdTable.add(new Zn(zn)),this.tables.appIdTable.has(Fn)||this.tables.appIdTable.add(new Zn(Fn))}ensureMLineStyle(t){const e=this.objects.mlineStyle,s=t.trim();if(!s||e.getAt(s))return;for(const[r,o]of e.entries())if(r.toUpperCase()===s.toUpperCase()||o.styleName.toUpperCase()===s.toUpperCase())return;const n=new Sr;n.styleName=s,n.elements=[{offset:.5,color:new j().setByLayer(),lineType:dt},{offset:-.5,color:new j().setByLayer(),lineType:dt}],e.setAt(s,n)}ensureMLeaderStyle(t){const e=this.objects.mleaderStyle,s=t.trim();if(!s||e.getAt(s))return;for(const[a]of e.entries())if(a.toUpperCase()===s.toUpperCase())return;const n=new fr;n.unknown1=2,n.maxLeaderSegmentsPoints=2,n.leaderLineColor=new j().setByBlock(),n.textColor=new j().setByBlock(),n.blockColor=new j().setByBlock(),n.alignSpace=4,n.breakSize=3.75,n.enableBlockRotation=!0,n.unknown2=!1;const r=this.tables.linetypeTable.getAt(fe);n.leaderLineTypeId=r==null?void 0:r.objectId;const o=this.tables.textStyleTable.getAt(Z);n.textStyleId=o==null?void 0:o.objectId,e.setAt(s,n)}writeDxfHeaderSection(t){var e;t.startSection("HEADER"),t.writeString(9,"$ACADVER"),t.writeString(1,((e=t.version)==null?void 0:e.name)??this.version.name),t.writeString(9,"$HANDSEED"),t.writeString(5,t.nextHandle.toString(16).toUpperCase()),t.version!=null&&t.version.value>=27&&(t.writeString(9,"$DWGCODEPAGE"),t.writeString(3,"UTF-8")),t.writeString(9,"$INSUNITS"),t.writeInt16(70,this.insunits),t.writeString(9,"$LTSCALE"),t.writeDouble(40,this.ltscale),t.writeString(9,"$LWDISPLAY"),t.writeInt16(70,this.lwdisplay?1:0),t.writeString(9,"$CLAYER"),t.writeString(8,this.clayer),t.writeString(9,"$CELTYPE"),t.writeString(6,this.celtype),t.writeString(9,"$CMLSTYLE"),t.writeString(2,this.cmlstyle),t.writeString(9,"$CMLSCALE"),t.writeDouble(40,this.cmlscale),t.writeString(9,"$CMLEADERSTYLE"),t.writeString(2,this.cmleaderstyle),t.writeString(9,"$TEXTSTYLE"),t.writeString(7,this.textstyle),t.writeString(9,"$ANGBASE"),t.writeAngle(50,this.angBase),t.writeString(9,"$ANGDIR"),t.writeInt16(70,this.angDir),t.writeString(9,"$EXTMIN"),t.writePoint3d(10,this.extmin),t.writeString(9,"$EXTMAX"),t.writePoint3d(10,this.extmax),t.writeString(9,"$PDMODE"),t.writeInt32(70,this.pdmode),t.writeString(9,"$PDSIZE"),t.writeDouble(40,this.pdsize),t.writeString(9,"$OSMODE"),t.writeInt32(70,this.osmode),t.endSection()}writeDxfTablesSection(t,e){t.startSection("TABLES"),this.writeDxfTable(t,"VPORT",this.tables.viewportTable,this.tables.viewportTable.newIterator(),"VPORT"),this.writeDxfTable(t,"VIEW",this.tables.viewTable,this.tables.viewTable.newIterator(),"VIEW"),this.writeDxfTable(t,"LTYPE",this.tables.linetypeTable,this.tables.linetypeTable.newIterator(),"LTYPE"),this.writeDxfTable(t,"LAYER",this.tables.layerTable,this.tables.layerTable.newIterator(),"LAYER"),this.writeDxfTable(t,"STYLE",this.tables.textStyleTable,this.tables.textStyleTable.newIterator(),"STYLE"),this.writeDxfTable(t,"APPID",this.tables.appIdTable,this.tables.appIdTable.newIterator(),"APPID"),this.writeDxfTable(t,"DIMSTYLE",this.tables.dimStyleTable,this.tables.dimStyleTable.newIterator(),"DIMSTYLE"),e.value>=19&&this.writeDxfTable(t,"BLOCK_RECORD",this.tables.blockTable,this.tables.blockTable.newIterator(),"BLOCK_RECORD"),t.endSection()}writeDxfBlocksSection(t){t.startSection("BLOCKS");for(const e of this.tables.blockTable.newIterator()){if(e.dxfOutBlockBegin(t),!e.isModelSapce&&!e.isPaperSapce)for(const s of e.newIterator())this.writeDxfEntity(t,s);e.dxfOutBlockEnd(t)}t.endSection()}writeDxfEntitiesSection(t){t.startSection("ENTITIES");for(const e of this.tables.blockTable.newIterator())if(!(!e.isModelSapce&&!e.isPaperSapce))for(const s of e.newIterator())this.writeDxfEntity(t,s);t.endSection()}writeDxfObjectsSection(t){t.startSection("OBJECTS");const e=this.objects.dictionary;e.ownerId="0";const s=o=>{t.writeStart("DICTIONARY"),o.dxfOut(t)},n=(o,a)=>{e.getAt(o)!==a&&e.setAt(o,a)},r=o=>{e.getAt(o)&&e.remove(o)};n("ACAD_LAYOUT",this.objects.layout),this.objects.mleaderStyle.numEntries>0?n("ACAD_MLEADERSTYLE",this.objects.mleaderStyle):r("ACAD_MLEADERSTYLE"),this.objects.mlineStyle.numEntries>0?n("ACAD_MLINESTYLE",this.objects.mlineStyle):r("ACAD_MLINESTYLE"),this.objects.imageDefinition.numEntries>0?n("ISM_RASTER_IMAGE_DICT",this.objects.imageDefinition):r("ISM_RASTER_IMAGE_DICT"),this.objects.xrecord.numEntries>0?n("MLIGHT_XRECORD",this.objects.xrecord):r("MLIGHT_XRECORD"),s(e),s(this.objects.layout),this.objects.mleaderStyle.numEntries>0&&s(this.objects.mleaderStyle),this.objects.mlineStyle.numEntries>0&&s(this.objects.mlineStyle),this.objects.imageDefinition.numEntries>0&&s(this.objects.imageDefinition),this.objects.xrecord.numEntries>0&&s(this.objects.xrecord);for(const[o,a]of this.objects.layout.entries())t.writeStart("LAYOUT"),a.dxfOut(t);for(const[o,a]of this.objects.imageDefinition.entries())t.writeStart("IMAGEDEF"),a.dxfOut(t);for(const[o,a]of this.objects.mleaderStyle.entries())t.writeStart("MLEADERSTYLE"),a.dxfOut(t);for(const[o,a]of this.objects.mlineStyle.entries())t.writeStart("MLINESTYLE"),a.dxfOut(t);for(const[o,a]of this.objects.xrecord.entries())t.writeStart("XRECORD"),a.dxfOut(t);t.endSection()}writeDxfTable(t,e,s,n,r){const o=[...n];t.startTable(e),s.dxfOut(t);for(const a of o){if(r==="BLOCK_RECORD"&&a instanceof J){a.dxfOutBlockRecord(t);continue}t.writeStart(r),a.dxfOut(t)}t.endTable()}writeDxfEntity(t,e){t.writeStart(e.dxfTypeName),e.dxfOut(t)}clear(){this._tables.blockTable.removeAll(),this._tables.dimStyleTable.removeAll(),this._tables.linetypeTable.removeAll(),this._tables.textStyleTable.removeAll(),this._tables.viewTable.removeAll(),this._tables.layerTable.removeAll(),this._tables.viewportTable.removeAll(),this._objects.layout.removeAll(),this._objects.imageDefinition.removeAll(),this._objects.mleaderStyle.removeAll(),this._objects.mlineStyle.removeAll(),this._objects.xrecord.removeAll(),this._currentSpace=void 0,this._extents.makeEmpty()}updateSysVar(t,e,s,n){this.hasSysVarValueChanged(e,s)&&(n(s),this.triggerSysVarChangedEvent(t,e,s))}hasSysVarValueChanged(t,e){return t instanceof j&&e instanceof j?!t.equals(e):t instanceof kt&&e instanceof kt?t.value!==e.value:!Object.is(t,e)}normalizeLinetypeName(t){const e=t.trim();return e.toUpperCase()==="BYLAYER"?dt:e.toUpperCase()==="BYBLOCK"?fe:e}triggerSysVarChangedEvent(t,e,s){const n=Ks.instance(),r=t.toLowerCase();n.getDescriptor(r)!=null&&n.events.sysVarChanged.dispatch({database:this,name:r,oldVal:e,newVal:s})}getFileNameFromUri(t){try{const s=new URL(t).pathname.split("/");return s[s.length-1]||""}catch{return""}}}const vl="Load Database",Ro=3e4,Zc=12e4,Kc=1024*1024;class xt extends Zo{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=Jn.getInstance().getEntry(vl),s=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const n=await this.data.task(t);return this.progress&&(await this.progress(this.data.progress.value,this.data.stage,"END",n?n.data:null),this.data.progress.value+=this.data.step,this.data.progress.value>100&&(this.data.progress.value=100)),e&&(e.data[this.name]=Date.now()-s),n}}class Mr{constructor(t={}){this.config=t}async read(t,e,s,n,r,o){const a={name:vl,data:{total:0},format(){let u="";return Object.keys(this.data).forEach(p=>{p!=="total"&&(u+=`- ${p}: ${this.data[p]} ms
5
- `)}),u+=`- total: ${this.data.total} ms`,u}};Jn.getInstance().collect(a),this.progress=n;const h={value:0},c=new Ko;c.setCompleteCallback(()=>this.onFinished()),c.setErrorCallback(u=>this.onError(u)),c.addTask(new xt({stage:"START",step:1,progress:h,task:async u=>u},n)),c.addTask(new xt({stage:"PARSE",step:5,progress:h,task:async u=>await this.parse(u,r)},n)),c.addTask(new xt({stage:"FONT",step:5,progress:h,task:async u=>{const p=this.getFonts(u.model);return{model:u.model,data:p}}},n)),c.addTask(new xt({stage:"LTYPE",step:1,progress:h,task:async u=>(this.processLineTypes(u.model,e),u)},n)),c.addTask(new xt({stage:"STYLE",step:1,progress:h,task:async u=>(this.processTextStyles(u.model,e),u)},n)),c.addTask(new xt({stage:"DIMSTYLE",step:1,progress:h,task:async u=>(this.processDimStyles(u.model,e),u)},n)),c.addTask(new xt({stage:"LAYER",step:1,progress:h,task:async u=>(this.processLayers(u.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),u)},n)),c.addTask(new xt({stage:"VPORT",step:1,progress:h,task:async u=>(this.processViewports(u.model,e),u)},n)),c.addTask(new xt({stage:"HEADER",step:1,progress:h,task:async u=>{if(this.processHeader(u.model,e),o){const p=Ks.instance();for(const[g,m]of Object.entries(o))p.setVar(g,m,e)}return u}},n)),c.addTask(new xt({stage:"BLOCK_RECORD",step:5,progress:h,task:async u=>(this.processBlockTables(u.model,e),u)},n)),c.addTask(new xt({stage:"OBJECT",step:5,progress:h,task:async u=>(this.processObjects(u.model,e),e.objects.layout.numEntries===0&&e.createDefaultData({layout:!0}),u)},n)),c.addTask(new xt({stage:"BLOCK",step:5,progress:h,task:async u=>(await this.processBlocks(u.model,e),u)},n)),c.addTask(new xt({stage:"ENTITY",step:100,progress:h,task:async u=>(await this.processEntities(u.model,e,s,h,n),u)},n)),c.addTask(new xt({stage:"END",step:0,progress:h,task:async u=>u},n));const d=Date.now();await c.run(t),a.data.total=Date.now()-d}onError(t){if(this.progress){const e=t.task;this.progress(e.data.progress.value,e.data.stage,"ERROR",void 0,t)}return t.task.name==="ENTITY"?!1:(this.onFinished(),!0)}onFinished(){this.progress&&(this.progress(100,"END","END"),es.instance.clear())}getParserWorkerTimeout(t,e){const s=e??this.config.timeout;if(s!=null)return s;const n=Math.ceil(t.byteLength/Kc),r=Ro+n*1e3;return Math.min(Zc,Math.max(Ro,r))}async parse(t,e){throw new Error("Not impelemented yet!")}getFonts(t){throw new Error("Not impelemented yet!")}processLineTypes(t,e){throw new Error("Not impelemented yet!")}processTextStyles(t,e){throw new Error("Not impelemented yet!")}processDimStyles(t,e){throw new Error("Not impelemented yet!")}processLayers(t,e){throw new Error("Not impelemented yet!")}processViewports(t,e){throw new Error("Not impelemented yet!")}processHeader(t,e){throw new Error("Not impelemented yet!")}processBlockTables(t,e){throw new Error("Not impelemented yet!")}processObjects(t,e){throw new Error("Not impelemented yet!")}processBlocks(t,e){throw new Error("Not impelemented yet!")}processEntities(t,e,s,n,r){throw new Error("Not impelemented yet!")}}class Qc extends Er{constructor(){super(),this._standardFlags=0,this._viewWidth=this.viewHeight,this._ucsAssociated=!1,this._cameraPlottable=!1,this._ucsElevation=0}get standardFlags(){return this._standardFlags}set standardFlags(t){this._standardFlags=t}get viewWidth(){return this._viewWidth}set viewWidth(t){this._viewWidth=t}get ucsAssociated(){return this._ucsAssociated}set ucsAssociated(t){this._ucsAssociated=t}get cameraPlottable(){return this._cameraPlottable}set cameraPlottable(t){this._cameraPlottable=t}get ucsElevation(){return this._ucsElevation}set ucsElevation(t){this._ucsElevation=t}get ucsObjectId(){return this._ucsObjectId}set ucsObjectId(t){this._ucsObjectId=t}get ucsBaseObjectId(){return this._ucsBaseObjectId}set ucsBaseObjectId(t){this._ucsBaseObjectId=t}get backgroundObjectId(){return this._backgroundObjectId}set backgroundObjectId(t){this._backgroundObjectId=t}get liveSectionObjectId(){return this._liveSectionObjectId}set liveSectionObjectId(t){this._liveSectionObjectId=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbViewTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.standardFlags),t.writeDouble(40,this.gsView.viewHeight),t.writePoint2d(10,this.centerPoint),t.writeDouble(41,this.viewWidth),t.writePoint3d(11,this.gsView.viewDirectionFromTarget),t.writePoint3d(12,this.gsView.viewTarget),t.writeDouble(42,this.gsView.lensLength),t.writeDouble(43,this.gsView.frontClippingPlane),t.writeDouble(44,this.gsView.backClippingPlane),t.writeAngle(50,this.gsView.viewTwistAngle),t.writeInt16(71,this.gsView.viewMode),t.writeInt16(281,this.gsView.renderMode),t.writeInt16(72,this.ucsAssociated?1:0),t.writeInt16(73,this.cameraPlottable?1:0),t.writeObjectId(332,this.backgroundObjectId),t.writeObjectId(334,this.liveSectionObjectId),t.writeObjectId(348,this.gsView.visualStyleObjectId),this.ucsAssociated&&(t.writePoint3d(110,this.gsView.ucsOrigin),t.writePoint3d(111,this.gsView.ucsXAxis),t.writePoint3d(112,this.gsView.ucsYAxis),t.writeInt16(79,this.gsView.orthographicType),t.writeDouble(146,this.ucsElevation),t.writeObjectId(345,this.ucsObjectId),t.writeObjectId(346,this.ucsBaseObjectId)),this}}var st,us,q,K,gs,Ct,Oe,Yt,ut,Xt,Ot,Ne,Be,Re,ft,$t,ps,ms,Fe,ze,ys,_s,xs,St,qt,U,Ve,ws,C,gt,bs,pt,fs,Zt,W,Ss,Kt,De,Tn,En,Nt,Is,je,It,Qt,Jt,te,As,Ps,ee,We,He,Ln,Ts,Ge,se,Ue,it,ie,At,Mn,nt,kn,ne,Pt,Ye,Es,Xe,Tt,re,Et,oe,vn,$e,Lt;(st={})[st.None=0]="None",st[st.Anonymous=1]="Anonymous",st[st.NonConstant=2]="NonConstant",st[st.Xref=4]="Xref",st[st.XrefOverlay=8]="XrefOverlay",st[st.ExternallyDependent=16]="ExternallyDependent",st[st.ResolvedOrDependent=32]="ResolvedOrDependent",st[st.ReferencedXref=64]="ReferencedXref";(us={})[us.BYBLOCK=0]="BYBLOCK",us[us.BYLAYER=256]="BYLAYER";(q={})[q.Rotated=0]="Rotated",q[q.Aligned=1]="Aligned",q[q.Angular=2]="Angular",q[q.Diameter=3]="Diameter",q[q.Radius=4]="Radius",q[q.Angular3Point=5]="Angular3Point",q[q.Ordinate=6]="Ordinate",q[q.ReferenceIsExclusive=32]="ReferenceIsExclusive",q[q.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",q[q.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(K={})[K.TopLeft=1]="TopLeft",K[K.TopCenter=2]="TopCenter",K[K.TopRight=3]="TopRight",K[K.MiddleLeft=4]="MiddleLeft",K[K.MiddleCenter=5]="MiddleCenter",K[K.MiddleRight=6]="MiddleRight",K[K.BottomLeft=7]="BottomLeft",K[K.BottomCenter=8]="BottomCenter",K[K.BottomRight=9]="BottomRight";(gs={})[gs.AtLeast=1]="AtLeast",gs[gs.Exact=2]="Exact";var Fo=((Ct={})[Ct.Center=0]="Center",Ct[Ct.Above=1]="Above",Ct[Ct.Outside=2]="Outside",Ct[Ct.JIS=3]="JIS",Ct[Ct.Below=4]="Below",Ct);(Oe={})[Oe.WithDimension=0]="WithDimension",Oe[Oe.AddLeader=1]="AddLeader",Oe[Oe.Independent=2]="Independent";(Yt={})[Yt.BothOutside=0]="BothOutside",Yt[Yt.ArrowFirst=1]="ArrowFirst",Yt[Yt.TextFirst=2]="TextFirst",Yt[Yt.Auto=3]="Auto";var ns=((ut={})[ut.Feet=0]="Feet",ut[ut.None=1]="None",ut[ut.Inch=2]="Inch",ut[ut.FeetAndInch=3]="FeetAndInch",ut[ut.Leading=4]="Leading",ut[ut.Trailing=8]="Trailing",ut[ut.LeadingAndTrailing=12]="LeadingAndTrailing",ut),Jc=((Xt={})[Xt.None=0]="None",Xt[Xt.Leading=1]="Leading",Xt[Xt.Trailing=2]="Trailing",Xt[Xt.LeadingAndTrailing=3]="LeadingAndTrailing",Xt),td=((Ot={})[Ot.Center=0]="Center",Ot[Ot.First=1]="First",Ot[Ot.Second=2]="Second",Ot[Ot.OverFirst=3]="OverFirst",Ot[Ot.OverSecond=4]="OverSecond",Ot),ed=((Ne={})[Ne.Bottom=0]="Bottom",Ne[Ne.Center=1]="Center",Ne[Ne.Top=2]="Top",Ne);(Be={})[Be.None=0]="None",Be[Be.UseDrawingBackground=1]="UseDrawingBackground",Be[Be.Custom=2]="Custom";(Re={})[Re.Horizontal=0]="Horizontal",Re[Re.Diagonal=1]="Diagonal",Re[Re.NotStacked=2]="NotStacked";(ft={})[ft.Scientific=1]="Scientific",ft[ft.Decimal=2]="Decimal",ft[ft.Engineering=3]="Engineering",ft[ft.Architectural=4]="Architectural",ft[ft.Fractional=5]="Fractional",ft[ft.WindowDesktop=6]="WindowDesktop";($t={})[$t.Decimal=0]="Decimal",$t[$t.DegreesMinutesSecond=1]="DegreesMinutesSecond",$t[$t.Gradian=2]="Gradian",$t[$t.Radian=3]="Radian";var sd=((ps={})[ps.PatternFill=0]="PatternFill",ps[ps.SolidFill=1]="SolidFill",ps);(ms={})[ms.NonAssociative=0]="NonAssociative",ms[ms.Associative=1]="Associative";(Fe={})[Fe.Normal=0]="Normal",Fe[Fe.Outer=1]="Outer",Fe[Fe.Ignore=2]="Ignore";(ze={})[ze.UserDefined=0]="UserDefined",ze[ze.Predefined=1]="Predefined",ze[ze.Custom=2]="Custom";(ys={})[ys.NotAnnotated=0]="NotAnnotated",ys[ys.Annotated=1]="Annotated";(_s={})[_s.Solid=0]="Solid",_s[_s.Gradient=1]="Gradient";(xs={})[xs.TwoColor=0]="TwoColor",xs[xs.OneColor=1]="OneColor";var id=((St={})[St.Default=0]="Default",St[St.External=1]="External",St[St.Polyline=2]="Polyline",St[St.Derived=4]="Derived",St[St.Textbox=8]="Textbox",St[St.Outermost=16]="Outermost",St),wi=((qt={})[qt.Line=1]="Line",qt[qt.Circular=2]="Circular",qt[qt.Elliptic=3]="Elliptic",qt[qt.Spline=4]="Spline",qt),nd=((U={})[U.Off=0]="Off",U[U.Solid=1]="Solid",U[U.Dashed=2]="Dashed",U[U.Dotted=3]="Dotted",U[U.ShotDash=4]="ShotDash",U[U.MediumDash=5]="MediumDash",U[U.LongDash=6]="LongDash",U[U.DoubleShortDash=7]="DoubleShortDash",U[U.DoubleMediumDash=8]="DoubleMediumDash",U[U.DoubleLongDash=9]="DoubleLongDash",U[U.DoubleMediumLongDash=10]="DoubleMediumLongDash",U[U.SparseDot=11]="SparseDot",U);nd.Off;(Ve={})[Ve.Standard=-3]="Standard",Ve[Ve.ByLayer=-2]="ByLayer",Ve[Ve.ByBlock=-1]="ByBlock";(ws={})[ws.English=0]="English",ws[ws.Metric=1]="Metric";(C={})[C.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",C[C.FRONT_CLIPPING=2]="FRONT_CLIPPING",C[C.BACK_CLIPPING=4]="BACK_CLIPPING",C[C.UCS_FOLLOW=8]="UCS_FOLLOW",C[C.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",C[C.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",C[C.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",C[C.FAST_ZOOM=128]="FAST_ZOOM",C[C.SNAP_MODE=256]="SNAP_MODE",C[C.GRID_MODE=512]="GRID_MODE",C[C.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",C[C.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",C[C.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",C[C.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",C[C.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",C[C.UNUSED=32768]="UNUSED",C[C.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",C[C.VIEWPORT_OFF=131072]="VIEWPORT_OFF",C[C.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",C[C.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",C[C.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",C[C.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE";(gt={})[gt.OPTIMIZED_2D=0]="OPTIMIZED_2D",gt[gt.WIREFRAME=1]="WIREFRAME",gt[gt.HIDDEN_LINE=2]="HIDDEN_LINE",gt[gt.FLAT_SHADED=3]="FLAT_SHADED",gt[gt.GOURAUD_SHADED=4]="GOURAUD_SHADED",gt[gt.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",gt[gt.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME";(bs={})[bs.UCS_UNCHANGED=0]="UCS_UNCHANGED",bs[bs.HAS_OWN_UCS=1]="HAS_OWN_UCS";(pt={})[pt.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",pt[pt.TOP=1]="TOP",pt[pt.BOTTOM=2]="BOTTOM",pt[pt.FRONT=3]="FRONT",pt[pt.BACK=4]="BACK",pt[pt.LEFT=5]="LEFT",pt[pt.RIGHT=6]="RIGHT";(fs={})[fs.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",fs[fs.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(Zt={})[Zt.ByLayer=0]="ByLayer",Zt[Zt.ByBlock=1]="ByBlock",Zt[Zt.ByDictionaryDefault=2]="ByDictionaryDefault",Zt[Zt.ByObject=3]="ByObject";(W={})[W.NotAllowed=0]="NotAllowed",W[W.AllowErase=1]="AllowErase",W[W.AllowTransform=2]="AllowTransform",W[W.AllowChangeColor=4]="AllowChangeColor",W[W.AllowChangeLayer=8]="AllowChangeLayer",W[W.AllowChangeLinetype=16]="AllowChangeLinetype",W[W.AllowChangeLinetypeScale=32]="AllowChangeLinetypeScale",W[W.AllowChangeVisibility=64]="AllowChangeVisibility",W[W.AllowClone=128]="AllowClone",W[W.AllowChangeLineweight=256]="AllowChangeLineweight",W[W.AllowChangePlotStyleName=512]="AllowChangePlotStyleName",W[W.AllowAllExceptClone=895]="AllowAllExceptClone",W[W.AllowAll=1023]="AllowAll",W[W.DisableProxyWarning=1024]="DisableProxyWarning",W[W.R13FormatProxy=32768]="R13FormatProxy";function O(i,t,e){return i.code===t&&(e==null||i.value===e)}function Le(i){let t={};i.rewind();let e=i.next(),s=e.code;if(t.x=e.value,(e=i.next()).code!==s+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=i.next()).code!==s+20?i.rewind():t.z=e.value,t}let ri=Symbol();function E(i,t){return(e,s,n)=>{let r=function(h,c=!1){return h.reduce((d,u)=>{u.pushContext&&d.push({});let p=d[d.length-1];for(let g of typeof u.code=="number"?[u.code]:u.code){let m=p[g]??(p[g]=[]);u.isMultiple&&m.length,m.push(u)}return d},[{}])}(i,s.debug),o=!1,a=r.length-1;for(;!O(e,0,"EOF");){let h=function(b,x,I){return b.find((S,L)=>{var A;return L>=I&&((A=S[x])==null?void 0:A.length)})}(r,e.code,a),c=h==null?void 0:h[e.code],d=c==null?void 0:c[c.length-1];if(!h||!d){s.rewind();break}d.isMultiple||h[e.code].pop();let{name:u,parser:p,isMultiple:g,isReducible:m}=d,y=p==null?void 0:p(e,s,n);if(y===ri){s.rewind();break}if(u){let[b,x]=rd(n,u);g&&!m?(Object.prototype.hasOwnProperty.call(b,x)||(b[x]=[]),b[x].push(y)):b[x]=y}d.pushContext&&(a-=1),o=!0,e=s.next()}return t&&Object.setPrototypeOf(n,t),o}}function rd(i,t){let e=t.split(".");if(!e.length)throw Error("[parserGenerator::getObjectByPath] Invalid empty path");let s=i;for(let n=0;n<e.length-1;++n){let r=Cn(e[n]),o=Cn(e[n+1]);Object.prototype.hasOwnProperty.call(s,r)||(typeof o=="number"?s[r]=[]:s[r]={}),s=s[r]}return[s,Cn(e[e.length-1])]}function Cn(i){let t=Number.parseInt(i);return Number.isNaN(t)?i:t}function l({value:i}){return i}function f(i,t){return Le(t)}function T({value:i}){return!!i}function od({value:i}){return i.trim()}let ad=[{code:281,name:"isEntity",parser:T},{code:280,name:"wasProxy",parser:T},{code:91,name:"instanceCount",parser:l},{code:90,name:"proxyFlag",parser:l},{code:3,name:"appName",parser:l},{code:2,name:"cppClassName",parser:l},{code:1,name:"name",parser:l}],ld=E(ad),hd=[{code:0,name:"classes",isMultiple:!0,parser(i,t){if(i.value!=="CLASS")return ri;i=t.next();let e={};return ld(i,t,e),e}}],cd=E(hd);(Ss={})[Ss.RayTrace=0]="RayTrace",Ss[Ss.ShadowMap=1]="ShadowMap";function Gt(i,t,e){for(;O(i,102);){var s;let n=i.value;if(i=t.next(),!n.startsWith("{")){t.debug,function(o,a){for(;!O(o,102)&&!O(o,0,"EOF");)o=a.next()}(i,t),i=t.next();continue}let r=n.slice(1).trim();e.extensions??(e.extensions={}),(s=e.extensions)[r]??(s[r]=[]),function(o,a,h){for(;!O(o,102,"}")&&!O(o,0,"EOF");)h.push(o),o=a.next()}(i,t,e.extensions[r]),i=t.next()}t.rewind()}let dd=[{code:1001,name:"xdata",isMultiple:!0,parser:Cl}],ud=new Set([1010,1011,1012,1013]);function Cl(i,t){var n;if(!O(i,1001))throw Error("XData must starts with code 1001");let e={appName:i.value,value:[]};i=t.next();let s=[e.value];for(;!O(i,0,"EOF")&&!O(i,1001)&&i.code>=1e3;){let r=s[s.length-1];if(i.code===1002){i.value==="{"?s.push([]):(s.pop(),(n=s[s.length-1])==null||n.push(r)),i=t.next();continue}ud.has(i.code)?r.push(Le(t)):r.push(i.value),i=t.next()}return t.rewind(),e}(Kt={})[Kt.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",Kt[Kt.CAST=1]="CAST",Kt[Kt.RECEIVE=2]="RECEIVE",Kt[Kt.IGNORE=3]="IGNORE";let V=[...dd,{code:284,name:"shadowMode",parser:l},{code:390,name:"plotStyleHardId",parser:l},{code:380,name:"plotStyleType",parser:l},{code:440,name:"transparency",parser:l},{code:430,name:"colorName",parser:l},{code:420,name:"color",parser:l},{code:310,name:"proxyEntity",isMultiple:!0,isReducible:!0,parser:(i,t,e)=>(e.proxyEntity??"")+i.value},{code:[92,160],name:"proxyByte",parser:l},{code:60,name:"isVisible",parser:T},{code:48,name:"lineTypeScale",parser:l},{code:370,name:"lineweight",parser:l},{code:62,name:"colorIndex",parser:l},{code:347,name:"materialObjectHardId",parser:l},{code:6,name:"lineType",parser:l},{code:8,name:"layer",parser:l},{code:410,name:"layoutTabName",parser:l},{code:67,name:"isInPaperSpace",parser:T},{code:100},{code:330,name:"ownerBlockRecordSoftId",parser:l},{code:102,parser:Gt},{code:102,parser:Gt},{code:102,parser:Gt},{code:5,name:"handle",parser:l}];function _n(i){return[{code:3,name:i,parser:(t,e,s)=>(s._code3text=(s._code3text??"")+t.value,s._code3text+(s._code1text??"")),isMultiple:!0,isReducible:!0},{code:1,name:i,parser:(t,e,s)=>(s._code1text=t.value,(s._code3text??"")+s._code1text)}]}function Ol(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let gd={extrusionDirection:{x:0,y:0,z:1}},pd=[{code:210,name:"extrusionDirection",parser:f},{code:51,name:"endAngle",parser:l},{code:50,name:"startAngle",parser:l},{code:100,name:"subclassMarker",parser:l},{code:40,name:"radius",parser:l},{code:10,name:"center",parser:f},{code:39,name:"thickness",parser:l},{code:100},...V];class Nl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ol(this,"parser",E(pd,gd))}}Ol(Nl,"ForEntityName","ARC");(De={})[De.BeforeText=0]="BeforeText",De[De.AboveText=1]="AboveText",De[De.None=2]="None";let kr=[{name:"DIMPOST",code:3},{name:"DIMAPOST",code:4,defaultValue:""},{name:"DIMBLK_OBSOLETE",code:5},{name:"DIMBLK1_OBSOLETE",code:6},{name:"DIMBLK2_OBSOLETE",code:7},{name:"DIMSCALE",code:40,defaultValue:1},{name:"DIMASZ",code:41,defaultValue:.25},{name:"DIMEXO",code:42,defaultValue:.625,defaultValueImperial:.0625},{name:"DIMDLI",code:43,defaultValue:3.75,defaultValueImperial:.38},{name:"DIMEXE",code:44,defaultValue:2.25,defaultValueImperial:.28},{name:"DIMRND",code:45,defaultValue:0},{name:"DIMDLE",code:46,defaultValue:0},{name:"DIMTP",code:47,defaultValue:0},{name:"DIMTM",code:48,defaultValue:0},{name:"DIMFXL",code:49,defaultValue:1},{name:"DIMJOGANG",code:50,defaultValue:45},{name:"DIMTFILL",code:69,defaultValue:0},{name:"DIMTFILLCLR",code:70,defaultValue:0},{name:"DIMTOL",code:71,defaultValue:0,defaultValueImperial:1},{name:"DIMLIM",code:72,defaultValue:0},{name:"DIMTIH",code:73,defaultValue:0,defaultValueImperial:1},{name:"DIMTOH",code:74,defaultValue:0,defaultValueImperial:1},{name:"DIMSE1",code:75,defaultValue:0},{name:"DIMSE2",code:76,defaultValue:0},{name:"DIMTAD",code:77,defaultValue:Fo.Above,defaultValueImperial:Fo.Center},{name:"DIMZIN",code:78,defaultValue:ns.Trailing,defaultValueImperial:ns.Feet},{name:"DIMAZIN",code:79,defaultValue:Jc.None},{name:"DIMARCSYM",code:90,defaultValue:0},{name:"DIMTXT",code:140,defaultValue:2.5,defaultValueImperial:.28},{name:"DIMCEN",code:141,defaultValue:2.5,defaultValueImperial:.09},{name:"DIMTSZ",code:142,defaultValue:0},{name:"DIMALTF",code:143,defaultValue:25.4},{name:"DIMLFAC",code:144,defaultValue:1},{name:"DIMTVP",code:145,defaultValue:0},{name:"DIMTFAC",code:146,defaultValue:1},{name:"DIMGAP",code:147,defaultValue:.625,defaultValueImperial:.09},{name:"DIMALTRND",code:148,defaultValue:0},{name:"DIMALT",code:170,defaultValue:0},{name:"DIMALTD",code:171,defaultValue:3,defaultValueImperial:2},{name:"DIMTOFL",code:172,defaultValue:1,defaultValueImperial:0},{name:"DIMSAH",code:173,defaultValue:0},{name:"DIMTIX",code:174,defaultValue:0},{name:"DIMSOXD",code:175,defaultValue:0},{name:"DIMCLRD",code:176,defaultValue:0},{name:"DIMCLRE",code:177,defaultValue:0},{name:"DIMCLRT",code:178,defaultValue:0},{name:"DIMADEC",code:179,defaultValue:0},{name:"DIMUNIT",code:270},{name:"DIMDEC",code:271,defaultValue:2,defaultValueImperial:4},{name:"DIMTDEC",code:272,defaultValue:2,defaultValueImperial:4},{name:"DIMALTU",code:273,defaultValue:2},{name:"DIMALTTD",code:274,defaultValue:3,defaultValueImperial:2},{name:"DIMAUNIT",code:275,defaultValue:0},{name:"DIMFRAC",code:276,defaultValue:0},{name:"DIMLUNIT",code:277,defaultValue:2},{name:"DIMDSEP",code:278,defaultValue:44,defaultValueImperial:46},{name:"DIMTMOVE",code:279,defaultValue:0},{name:"DIMJUST",code:280,defaultValue:td.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:ed.Center},{name:"DIMTZIN",code:284,defaultValue:ns.Trailing,defaultValueImperial:ns.Feet},{name:"DIMALTZ",code:285,defaultValue:ns.Trailing},{name:"DIMALTTZ",code:286,defaultValue:ns.Trailing},{name:"DIMFIT",code:287},{name:"DIMUPT",code:288,defaultValue:0},{name:"DIMATFIT",code:289,defaultValue:3},{name:"DIMFXLON",code:290,defaultValue:0},{name:"DIMTXTDIRECTION",code:294,defaultValue:0},{name:"DIMTXSTY",code:340,defaultValue:"Standard"},{name:"DIMLDRBLK",code:341,defaultValue:""},{name:"DIMBLK",code:342,defaultValue:""},{name:"DIMBLK1",code:343,defaultValue:""},{name:"DIMBLK2",code:344,defaultValue:""},{name:"DIMLTYPE",code:345,defaultValue:""},{name:"DIMLTEX1",code:346,defaultValue:""},{name:"DIMLTEX2",code:347,defaultValue:""},{name:"DIMLWD",code:371,defaultValue:-2},{name:"DIMLWE",code:372,defaultValue:-2}],Bl=[{code:3,name:"styleName",parser:l},{code:210,name:"extrusionDirection",parser:f},{code:51,name:"ocsRotation",parser:l},{code:53,name:"textRotation",parser:l},{code:1,name:"text",parser:l},{code:42,name:"measurement",parser:l},{code:72,name:"textLineSpacingStyle",parser:l},{code:71,name:"attachmentPoint",parser:l},{code:70,name:"dimensionType",parser:l},{code:11,name:"textPoint",parser:f},{code:10,name:"definitionPoint",parser:f},{code:2,name:"name",parser:l},{code:280,name:"version",parser:l},{code:100}],md=[{code:100},{code:52,name:"obliqueAngle",parser:l},{code:50,name:"rotationAngle",parser:l},{code:14,name:"subDefinitionPoint2",parser:f},{code:13,name:"subDefinitionPoint1",parser:f},{code:12,name:"insertionPoint",parser:f},{code:100,name:"subclassMarker",parser:l}],yd=[{code:16,name:"arcPoint",parser:f},{code:15,name:"centerPoint",parser:f},{code:14,name:"subDefinitionPoint2",parser:f},{code:13,name:"subDefinitionPoint1",parser:f},{code:100,name:"subclassMarker",parser:l}],_d=[{code:14,name:"subDefinitionPoint2",parser:f},{code:13,name:"subDefinitionPoint1",parser:f},{code:100,name:"subclassMarker",parser:l}],xd=[{code:40,name:"leaderLength",parser:l},{code:15,name:"subDefinitionPoint",parser:f},{code:100,name:"subclassMarker",parser:l}],wd=[{code:100,parser(i,t,e){let s=function(n){switch(n){case"AcDbAlignedDimension":return E(md);case"AcDb3PointAngularDimension":case"AcDb2LineAngularDimension":return E(yd);case"AcDbOrdinateDimension":return E(_d);case"AcDbRadialDimension":case"AcDbDiametricDimension":return E(xd)}return null}(i.value);if(!s)return ri;s(i,t,e)},pushContext:!0},...kr.map(i=>({...i,parser:l})),...Bl,...V];class Ei{parseEntity(t,e){let s={};return E(wd)(e,t,s),s}}(Tn="ForEntityName")in Ei?Object.defineProperty(Ei,Tn,{value:"DIMENSION",enumerable:!0,configurable:!0,writable:!0}):Ei[Tn]="DIMENSION";let bd=[{code:73},{code:17,name:"leaderEnd",parser:f},{code:16,name:"leaderStart",parser:f},{code:71,name:"hasLeader",parser:T},{code:41,name:"endAngle",parser:l},{code:40,name:"startAngle",parser:l},{code:70,name:"isPartial",parser:T},{code:15,name:"centerPoint",parser:f},{code:14,name:"xline2Point",parser:f},{code:13,name:"xline1Point",parser:f},{code:100,name:"subclassMarker",parser:l,pushContext:!0},...kr.map(i=>({...i,parser:l})),...Bl,...V];class Li{parseEntity(t,e){let s={};return E(bd)(e,t,s),s}}(En="ForEntityName")in Li?Object.defineProperty(Li,En,{value:"ARC_DIMENSION",enumerable:!0,configurable:!0,writable:!0}):Li[En]="ARC_DIMENSION";(Nt={})[Nt.NONE=0]="NONE",Nt[Nt.INVISIBLE=1]="INVISIBLE",Nt[Nt.CONSTANT=2]="CONSTANT",Nt[Nt.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",Nt[Nt.PRESET=8]="PRESET";(Is={})[Is.MULTILINE=2]="MULTILINE",Is[Is.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(je={})[je.NONE=0]="NONE",je[je.MIRRORED_X=2]="MIRRORED_X",je[je.MIRRORED_Y=4]="MIRRORED_Y";var fd=((It={})[It.LEFT=0]="LEFT",It[It.CENTER=1]="CENTER",It[It.RIGHT=2]="RIGHT",It[It.ALIGNED=3]="ALIGNED",It[It.MIDDLE=4]="MIDDLE",It[It.FIT=5]="FIT",It),Sd=((Qt={})[Qt.BASELINE=0]="BASELINE",Qt[Qt.BOTTOM=1]="BOTTOM",Qt[Qt.MIDDLE=2]="MIDDLE",Qt[Qt.TOP=3]="TOP",Qt);function Rl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Fl={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:fd.LEFT,valign:Sd.BASELINE,extrusionDirection:{x:0,y:0,z:1}},zl=[{code:73,name:"valign",parser:l},{code:100},{code:210,name:"extrusionDirection",parser:f},{code:11,name:"endPoint",parser:f},{code:72,name:"valign",parser:l},{code:72,name:"halign",parser:l},{code:71,name:"generationFlag",parser:l},{code:7,name:"styleName",parser:l},{code:51,name:"obliqueAngle",parser:l},{code:41,name:"xScale",parser:l},{code:50,name:"rotation",parser:l},{code:1,name:"text",parser:l},{code:40,name:"textHeight",parser:l},{code:10,name:"startPoint",parser:f},{code:39,name:"thickness",parser:l},{code:100,name:"subclassMarker",parser:l},...V];class Vl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Rl(this,"parser",E(zl,Fl))}}function Dl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Rl(Vl,"ForEntityName","TEXT");let Id={...Fl},Ad=[{code:2},{code:40,name:"annotationScale",parser:l},{code:10,name:"alignmentPoint",parser:f},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:l},{code:70,name:"numberOfSecondaryAttributes",parser:l},{code:70,name:"isReallyLocked",parser:T},{code:70,name:"mtextFlag",parser:l},{code:280,name:"isDuplicatedRecord",parser:T},{code:100},{code:280,name:"isLocked",parser:T},{code:74,name:"valign",parser:l},{code:73},{code:70,name:"attributeFlag",parser:l},{code:2,name:"tag",parser:l},{code:3,name:"prompt",parser:l},{code:280},{code:100,name:"subclassMarker",parser:l},...zl.slice(2)];class jl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Dl(this,"parser",E(Ad,Id))}}function Pd(i,t){let e={};for(let s of i){let n=t(s);n!=null&&(e[n]??(e[n]=[]),e[n].push(s))}return e}function*hn(i,t=1/0,e=1){for(let s=i;s!==t;s+=e)yield s}function Kn(i){return{x:i.x??0,y:i.y??0,z:i.z??0}}Dl(jl,"ForEntityName","ATTDEF");var Td=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function Ed(i){return Td[i]}function Ld(i){i.rewind();let t=i.next();if(t.code!==101)throw Error("Bad call for skipEmbeddedObject()");do t=i.next();while(t.code!==0);i.rewind()}function Md(i,t,e){if(O(t,102))return Gt(t,e,i),!0;switch(t.code){case 0:i.type=t.value;break;case 5:i.handle=t.value;break;case 330:i.ownerBlockRecordSoftId=t.value;break;case 67:i.isInPaperSpace=!!t.value;break;case 8:i.layer=t.value;break;case 6:i.lineType=t.value;break;case 347:i.materialObjectHardId=t.value;break;case 62:i.colorIndex=t.value,i.color=Ed(Math.abs(t.value));break;case 370:i.lineweight=t.value;break;case 48:i.lineTypeScale=t.value;break;case 60:i.isVisible=!!t.value;break;case 92:i.proxyByte=t.value;break;case 310:i.proxyEntity=t.value;break;case 100:break;case 420:i.color=t.value;break;case 430:i.transparency=t.value;break;case 390:i.plotStyleHardId=t.value;break;case 284:i.shadowMode=t.value;break;case 1001:(i.xdata??(i.xdata=[])).push(Cl(t,e));break;default:return!1}return!0}function Wl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let kd={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},Mi=[{code:46,name:"annotationHeight",parser:l},{code:101,parser(i,t){Ld(t)}},{code:50,name:"columnHeight",parser:l},{code:49,name:"columnGutter",parser:l},{code:48,name:"columnWidth",parser:l},{code:79,name:"columnAutoHeight",parser:l},{code:78,name:"columnFlowReversed",parser:l},{code:76,name:"columnCount",parser:l},{code:75,name:"columnType",parser:l},{code:441,name:"backgroundFillTransparency",parser:l},{code:63,name:"backgroundFillColor",parser:l},{code:45,name:"fillBoxScale",parser:l},{code:[...hn(430,440)],name:"backgroundColor",parser:l},{code:[...hn(420,430)],name:"backgroundColor",parser:l},{code:90,name:"backgroundFill",parser:l},{code:44,name:"lineSpacing",parser:l},{code:73,name:"lineSpacingStyle",parser:l},{code:50,name:"rotation",parser:l},{code:43},{code:42},{code:11,name:"direction",parser:f},{code:210,name:"extrusionDirection",parser:f},{code:7,name:"styleName",parser:l},..._n("text"),{code:72,name:"drawingDirection",parser:l},{code:71,name:"attachmentPoint",parser:l},{code:41,name:"width",parser:l},{code:40,name:"height",parser:l},{code:10,name:"insertionPoint",parser:f},{code:100,name:"subclassMarker",parser:l},...V];class Hl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Wl(this,"parser",E(Mi,kd))}}function Gl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Wl(Hl,"ForEntityName","MTEXT");let vd={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},Cd=[...Mi.slice(Mi.findIndex(({name:i})=>i==="columnType"),Mi.findIndex(({name:i})=>i==="subclassMarker")+1),{code:100},{code:0,parser(i){if(!O(i,0,"MTEXT"))return ri}},{code:2,name:"definitionTag",parser:l},{code:40,name:"annotationScale",parser:l},{code:10,name:"alignmentPoint",parser:f},{code:340,name:"secondaryAttributesHardId",parser:l},{code:70,name:"numberOfSecondaryAttributes",parser:l},{code:70,name:"isReallyLocked",parser:T},{code:70,name:"mtextFlag",parser:l},{code:280,name:"isDuplicatedEntriesKeep",parser:T},{code:100},{code:280,name:"lockPositionFlag",parser:T},{code:210,name:"extrusionDirection",parser:f},{code:11,name:"alignmentPoint",parser:f},{code:74,name:"verticalJustification",parser:l},{code:72,name:"horizontalJustification",parser:l},{code:71,name:"textGenerationFlag",parser:l},{code:7,name:"textStyle",parser:l},{code:51,name:"obliqueAngle",parser:l},{code:41,name:"scale",parser:l},{code:50,name:"rotation",parser:l},{code:73},{code:70,name:"attributeFlag",parser:l},{code:2,name:"tag",parser:l},{code:280},{code:100,name:"subclassMarker",parser:l},{code:1,name:"text",parser:l},{code:40,name:"textHeight",parser:l},{code:10,name:"startPoint",parser:f},{code:39,name:"thickness",parser:l},{code:100},...V];class Ul{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Gl(this,"parser",E(Cd,vd))}}function Yl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Gl(Ul,"ForEntityName","ATTRIB");let Od=[..._n("data"),{code:70,name:"version",parser:l},{code:100,name:"subclassMarker",parser:l},...V];class Xl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Yl(this,"parser",E(Od))}}function $l(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Yl(Xl,"ForEntityName","BODY");let Nd={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Bd=[{code:210,name:"extrusionDirection",parser:f},{code:40,name:"radius",parser:l},{code:10,name:"center",parser:f},{code:39,name:"thickness",parser:l},{code:100,name:"subclassMarker",parser:l},...V];class ql{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){$l(this,"parser",E(Bd,Nd))}}function Zl(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}$l(ql,"ForEntityName","CIRCLE");let Rd={extrusionDirection:{x:0,y:0,z:1}},Fd=[{code:42,name:"endAngle",parser:l},{code:41,name:"startAngle",parser:l},{code:40,name:"axisRatio",parser:l},{code:210,name:"extrusionDirection",parser:f},{code:11,name:"majorAxisEndPoint",parser:f},{code:10,name:"center",parser:f},{code:100,name:"subclassMarker",parser:l},...V];class Kl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Zl(this,"parser",E(Fd,Rd))}}function Ql(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Zl(Kl,"ForEntityName","ELLIPSE");let zd=[{code:13,name:"vertices.3",parser:f},{code:12,name:"vertices.2",parser:f},{code:11,name:"vertices.1",parser:f},{code:10,name:"vertices.0",parser:f},{code:100,name:"subclassMarker",parser:l},...V];class Jl{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ql(this,"parser",E(zd))}}Ql(Jl,"ForEntityName","3DFACE");(Jt={})[Jt.First=1]="First",Jt[Jt.Second=2]="Second",Jt[Jt.Third=4]="Third",Jt[Jt.Fourth=8]="Fourth";let th=[{code:330,name:"sourceBoundaryObjects",parser:l,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:l}],Vd=[{code:11,name:"end",parser:f},{code:10,name:"start",parser:f}],Dd=[{code:73,name:"isCCW",parser:T},{code:51,name:"endAngle",parser:l},{code:50,name:"startAngle",parser:l},{code:40,name:"radius",parser:l},{code:10,name:"center",parser:f}],jd=[{code:73,name:"isCCW",parser:T},{code:51,name:"endAngle",parser:l},{code:50,name:"startAngle",parser:l},{code:40,name:"lengthOfMinorAxis",parser:l},{code:11,name:"end",parser:f},{code:10,name:"center",parser:f}],Wd=[{code:13,name:"endTangent",parser:f},{code:12,name:"startTangent",parser:f},{code:11,name:"fitDatum",isMultiple:!0,parser:f},{code:97,name:"numberOfFitData",parser:l},{code:10,name:"controlPoints",isMultiple:!0,parser(i,t){let e={...Le(t),weight:1};return(i=t.next()).code===42?e.weight=i.value:t.rewind(),e}},{code:40,name:"knots",isMultiple:!0,parser:l},{code:96,name:"numberOfControlPoints",parser:l},{code:95,name:"numberOfKnots",parser:l},{code:74,name:"isPeriodic",parser:T},{code:73,name:"splineFlag",parser:l},{code:94,name:"degree",parser:l}],Hd={[wi.Line]:Vd,[wi.Circular]:Dd,[wi.Elliptic]:jd,[wi.Spline]:Wd},Gd=[...th,{code:72,name:"edges",parser(i,t){let e={type:i.value},s=E(Hd[e.type]);if(!s)throw Error(`Invalid edge type ${e.type}`);return s(i=t.next(),t,e),e},isMultiple:!0},{code:93,name:"numberOfEdges",parser:l}],Ud=[...th,{code:10,name:"vertices",parser(i,t){let e={...Le(t),bulge:0};return(i=t.next()).code===42?e.bulge=i.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:l},{code:73,name:"isClosed",parser:T},{code:72,name:"hasBulge",parser:T}];function Yd(i,t){let e={boundaryPathTypeFlag:i.value},s=e.boundaryPathTypeFlag&id.Polyline;return i=t.next(),s?E(Ud)(i,t,e):E(Gd)(i,t,e),e}let Xd=[{code:49,name:"dashLengths",parser:l,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:l},{code:45,name:"offset",parser:zo},{code:43,name:"base",parser:zo},{code:53,name:"angle",parser:l}];function zo(i,t){let e=i.code+1,s={x:i.value,y:1};return(i=t.next()).code===e?s.y=i.value:t.rewind(),s}function $d(i,t){let e={};return E(Xd)(i,t,e),e}function qd(i,t){let e=[];for(;i.code===463;){let s={reservedField:i.value};if((i=t.next()).code===63&&(s.colorIndex=i.value,i=t.next()),i.code===421)s.rgb=i.value,e.push(s),i=t.next();else{t.rewind();break}}return i.code!==463&&e.length>0&&t.rewind(),e}function eh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Zd={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},Kd=[{code:470,name:"gradientName",parser:l},{code:463,name:"gradientColors",parser:qd},{code:462,name:"colorTint",parser:l},{code:461,name:"gradientDefinition",parser:l},{code:460,name:"gradientRotation",parser:l},{code:453,name:"numberOfColors",parser:l},{code:452,name:"gradientColorFlag",parser:l},{code:451},{code:450,name:"gradientFlag",parser:l},{code:10,name:"seedPoints",parser:f,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:f},{code:98,name:"numberOfSeedPoints",parser:l},{code:47,name:"pixelSize",parser:l},{code:53,name:"definitionLines",parser:$d,isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:l},{code:77,name:"isDouble",parser:T},{code:73,name:"isAnnotated",parser:T},{code:41,name:"patternScale",parser:l},{code:52,name:"patternAngle",parser:l},{code:76,name:"patternType",parser:l},{code:75,name:"hatchStyle",parser:l},{code:92,name:"boundaryPaths",parser:Yd,isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:l},{code:71,name:"associativity",parser:l},{code:63,name:"patternFillColor",parser:l},{code:70,name:"solidFill",parser:l},{code:2,name:"patternName",parser:l},{code:210,name:"extrusionDirection",parser:f},{code:10,name:"elevationPoint",parser:f},{code:100,name:"subclassMarker",parser:l,pushContext:!0},...V];class sh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){eh(this,"parser",E(Kd,Zd))}}function ih(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}eh(sh,"ForEntityName","HATCH");let Qd={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},Jd=[{code:290,name:"clipMode",parser:l},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:f},{code:91,name:"countBoundaryPoints",parser:l},{code:71,name:"clippingBoundaryType",parser:l},{code:360,name:"imageDefReactorHandle",parser:l},{code:283,name:"fade",parser:l},{code:282,name:"contrast",parser:l},{code:281,name:"brightness",parser:l},{code:280,name:"isClipped",parser:T},{code:70,name:"flags",parser:l},{code:340,name:"imageDefHandle",parser:l},{code:13,name:"imageSize",parser:f},{code:12,name:"vPixel",parser:f},{code:11,name:"uPixel",parser:f},{code:10,name:"position",parser:f},{code:90,name:"version",parser:l},{code:100,name:"subclassMarker",parser:l},...V];class nh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ih(this,"parser",E(Jd,Qd))}}ih(nh,"ForEntityName","IMAGE");(te={})[te.ShowImage=1]="ShowImage",te[te.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",te[te.UseClippingBoundary=4]="UseClippingBoundary",te[te.TransparencyIsOn=8]="TransparencyIsOn";(As={})[As.Rectangular=1]="Rectangular",As[As.Polygonal=2]="Polygonal";(Ps={})[Ps.Outside=0]="Outside",Ps[Ps.Inside=1]="Inside";function rh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let tu={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},eu=[{code:210,name:"extrusionDirection",parser:f},{code:45,name:"rowSpacing",parser:l},{code:44,name:"columnSpacing",parser:l},{code:71,name:"rowCount",parser:l},{code:70,name:"columnCount",parser:l},{code:50,name:"rotation",parser:l},{code:43,name:"zScale",parser:l},{code:42,name:"yScale",parser:l},{code:41,name:"xScale",parser:l},{code:10,name:"insertionPoint",parser:f},{code:2,name:"name",parser:l},{code:66,name:"isVariableAttributes",parser:T},{code:100,name:"subclassMarker",parser:l},...V];class oh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){rh(this,"parser",E(eu,tu))}}function ah(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}rh(oh,"ForEntityName","INSERT");let su={isArrowheadEnabled:!0},iu=[{code:213,name:"offsetFromAnnotation",parser:f},{code:212,name:"offsetFromBlock",parser:f},{code:211,name:"horizontalDirection",parser:f},{code:210,name:"normal",parser:f},{code:340,name:"associatedAnnotation",parser:l},{code:77,name:"byBlockColor",parser:l},{code:10,name:"vertices",parser:f,isMultiple:!0},{code:76,name:"numberOfVertices",parser:l},{code:41,name:"textWidth",parser:l},{code:40,name:"textHeight",parser:l},{code:75,name:"isHooklineExists",parser:T},{code:74,name:"isHooklineSameDirection",parser:T},{code:73,name:"leaderCreationFlag",parser:l},{code:72,name:"isSpline",parser:T},{code:71,name:"isArrowheadEnabled",parser:T},{code:3,name:"styleName",parser:l},{code:100,name:"subclassMarker",parser:l},...V];class lh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){ah(this,"parser",E(iu,su))}}ah(lh,"ForEntityName","LEADER");(ee={})[ee.TextAnnotation=0]="TextAnnotation",ee[ee.ToleranceAnnotation=1]="ToleranceAnnotation",ee[ee.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",ee[ee.NoAnnotation=3]="NoAnnotation";function hh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let nu={thickness:0,extrusionDirection:{x:0,y:0,z:1}},ru=[{code:210,name:"extrusionDirection",parser:f},{code:11,name:"endPoint",parser:f},{code:10,name:"startPoint",parser:f},{code:39,name:"thickness",parser:l},{code:100,name:"subclassMarker",parser:l},...V];class ch{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){hh(this,"parser",E(ru,nu))}}function dh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}hh(ch,"ForEntityName","LINE");let ou=[{code:280,name:"shadowMapSoftness",parser:l},{code:91,name:"shadowMapSize",parser:l},{code:73,name:"shadowType",parser:l},{code:293,name:"isShadowCast",parser:T},{code:51,name:"falloffAngle",parser:l},{code:50,name:"hotspotAngle",parser:l},{code:42,name:"limitEnd",parser:l},{code:41,name:"limitStart",parser:l},{code:292,name:"isAttenuationLimited",parser:T},{code:72,name:"attenuationType",parser:l},{code:11,name:"target",parser:f},{code:10,name:"position",parser:f},{code:40,name:"intensity",parser:l},{code:291,name:"isPlotGlyph",parser:T},{code:290,name:"isOn",parser:T},{code:421,name:"lightColorInstance",parser:l},{code:63,name:"lightColorIndex",parser:l},{code:70,name:"lightType",parser:l},{code:1,name:"name",parser:l},{code:90,name:"version",parser:l},{code:100,name:"subclassMarker",parser:l},...V];class uh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){dh(this,"parser",E(ou))}}dh(uh,"ForEntityName","LIGHT");(We={})[We.Distant=1]="Distant",We[We.Point=2]="Point",We[We.Spot=3]="Spot";(He={})[He.None=0]="None",He[He.InverseLinear=1]="InverseLinear",He[He.InverseSquare=2]="InverseSquare";let au={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},lu={bulge:0},hu=[{code:42,name:"bulge",parser:l},{code:41,name:"endWidth",parser:l},{code:40,name:"startWidth",parser:l},{code:91,name:"id",parser:l},{code:20,name:"y",parser:l},{code:10,name:"x",parser:l}],cu=[{code:210,name:"extrusionDirection",parser:f},{code:10,name:"vertices",isMultiple:!0,parser(i,t){let e={};return E(hu,lu)(i,t,e),e}},{code:39,name:"thickness",parser:l},{code:38,name:"elevation",parser:l},{code:43,name:"constantWidth",parser:l},{code:70,name:"flag",parser:l},{code:90,name:"numberOfVertices",parser:l},{code:100,name:"subclassMarker",parser:l},...V];class ki{parseEntity(t,e){let s={};return E(cu,au)(e,t,s),s}}(Ln="ForEntityName")in ki?Object.defineProperty(ki,Ln,{value:"LWPOLYLINE",enumerable:!0,configurable:!0,writable:!0}):ki[Ln]="LWPOLYLINE";(Ts={})[Ts.IS_CLOSED=1]="IS_CLOSED",Ts[Ts.PLINE_GEN=128]="PLINE_GEN";function gh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let du=[{code:90,name:"overridenSubEntityCount",parser:l},{code:140,name:"edgeCreaseWeights",parser:l,isMultiple:!0},{code:95,name:"edgeCreaseCount",parser:l},{code:94,parser(i,t,e){e.edgeCount=i.value,e.edgeIndices=[];for(let s=0;s<e.edgeCount;++s){let n=[];i=t.next(),n[0]=i.value,i=t.next(),n[1]=i.value,e.edgeIndices.push(n)}}},{code:93,parser(i,t,e){e.totalFaceIndices=i.value,e.faceIndices=[];let s=[];for(let r=0;r<e.totalFaceIndices&&!O(i,0);++r)i=t.next(),s.push(i.value);let n=0;for(;n<s.length;){let r=s[n++],o=[];for(let a=0;a<r;++a)o.push(s[n++]);e.faceIndices.push(o)}}},{code:10,name:"vertices",parser:f,isMultiple:!0},{code:92,name:"verticesCount",parser:l},{code:91,name:"subdivisionLevel",parser:l},{code:40,name:"blendCrease",parser:l},{code:72,name:"isBlendCreased",parser:T},{code:71,name:"version",parser:l},{code:100,name:"subclassMarker",parser:od,pushContext:!0},...V];class ph{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){gh(this,"parser",E(du))}}function mh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}gh(ph,"ForEntityName","MESH");let uu=[{code:42,name:"fillParameters",parser:l,isMultiple:!0},{code:75,name:"fillCount",parser:l},{code:41,name:"parameters",parser:l,isMultiple:!0},{code:74,name:"parameterCount",parser:l}],gu=[{code:[74,41,75,42],name:"elements",parser(i,t){let e=E(uu),s={};return e(i,t,s),s},isMultiple:!0},{code:13,name:"miterDirection",parser:f},{code:12,name:"direction",parser:f},{code:11,name:"position",parser:f}],pu=[{code:[11,12,13],name:"segments",parser(i,t){let e=E(gu),s={};return e(i,t,s),s},isMultiple:!0},{code:210,name:"extrusionDirection",parser:f},{code:10,name:"startPosition",parser:f},{code:73,name:"styleCount",parser:l},{code:72,name:"vertexCount",parser:l},{code:71,name:"flags",parser:l},{code:70,name:"justification",parser:l},{code:40,name:"scale",parser:l},{code:340,name:"styleObjectHandle",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l,pushContext:!0},...V];class yh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){mh(this,"parser",E(pu))}}mh(yh,"ForEntityName","MLINE");(Ge={})[Ge.Top=0]="Top",Ge[Ge.Zero=1]="Zero",Ge[Ge.Bottom=2]="Bottom";(se={})[se.HasVertex=1]="HasVertex",se[se.Closed=2]="Closed",se[se.SuppressStartCaps=4]="SuppressStartCaps",se[se.SuppressEndCaps=8]="SuppressEndCaps";(Ue={})[Ue.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",Ue[Ue.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",Ue[Ue.BY_STYLE=5]="BY_STYLE";function _h(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let mu={},yu=[{code:300,parser:function(i,t,e){var r;let s;if(i.value==="CONTEXT_DATA{")for(;t.hasNext();){var n;if((s=t.next()).code===301)break;switch(s.code){case 10:e.contentBasePosition=rt(s,t);break;case 11:e.normal=rt(s,t);break;case 12:e.textAnchor=rt(s,t);break;case 13:e.textDirection=rt(s,t);break;case 14:ae(e).normal=rt(s,t);break;case 15:ae(e).position=rt(s,t);break;case 16:ae(e).scale=rt(s,t);break;case 40:e.contentScale=s.value;break;case 41:case 44:e.textHeight=s.value;break;case 42:e.textRotation=s.value;break;case 43:e.textWidth=s.value;break;case 45:e.textLineSpacingFactor=s.value;break;case 46:ae(e).rotation=s.value;break;case 47:(n=ae(e)).transformationMatrix??(n.transformationMatrix=[]),(r=ae(e).transformationMatrix)==null||r.push(s.value);break;case 90:e.textColor=s.value;break;case 91:e.textBackgroundColor=s.value;break;case 92:e.textBackgroundTransparency=s.value;break;case 93:ae(e).color=s.value;break;case 110:e.planeOrigin=rt(s,t);break;case 111:e.planeXAxisDirection=rt(s,t);break;case 112:e.planeYAxisDirection=rt(s,t);break;case 140:e.arrowheadSize=s.value;break;case 141:e.textBackgroundScaleFactor=s.value;break;case 142:e.textColumnWidth=s.value;break;case 143:e.textColumnGutterWidth=s.value;break;case 144:e.textColumnHeight=s.value;break;case 145:e.landingGap=s.value;break;case 170:e.textLineSpacingStyle=s.value;break;case 171:e.textAttachment=s.value;break;case 172:e.textFlowDirection=s.value;break;case 173:e.textColumnType=s.value;break;case 290:e.hasMText=s.value;break;case 291:e.textBackgroundColorOn=s.value;break;case 292:e.textFillOn=s.value;break;case 293:e.textUseAutoHeight=s.value;break;case 294:e.textColumnFlowReversed=s.value;break;case 295:e.textUseWordBreak=s.value;break;case 296:e.hasBlock=s.value;break;case 297:e.planeNormalReversed=s.value;break;case 302:s.value==="LEADER{"&&(e.leaderSections??(e.leaderSections=[]),e.leaderSections.push(function(o,a){let h,c;if(o.value!=="LEADER{")return{leaderLines:[]};let d={leaderLines:[]};for(;a.hasNext();){if((c=a.next()).code===303){bi(d,h);break}switch(c.code){case 290:d.lastLeaderLinePointSet=c.value;break;case 291:d.doglegVectorSet=c.value;break;case 10:d.lastLeaderLinePoint=rt(c,a);break;case 11:d.doglegVector=rt(c,a);break;case 12:h??(h={}),h.start=rt(c,a);break;case 13:h??(h={}),h.end=rt(c,a),bi(d,h),h=void 0;break;case 90:d.leaderBranchIndex=c.value;break;case 40:d.doglegLength=c.value;break;case 304:c.value==="LEADER_LINE{"&&d.leaderLines.push(function(u,p){let g,m;if(u.value!=="LEADER_LINE{")return{vertices:[]};let y={vertices:[]};for(;p.hasNext();){if((m=p.next()).code===305){bi(y,g);break}switch(m.code){case 10:y.vertices.push(rt(m,p));break;case 11:g??(g={}),g.start=rt(m,p);break;case 12:g??(g={}),g.end=rt(m,p),bi(y,g),g=void 0;break;case 90:y.breakPointIndexes??(y.breakPointIndexes=[]),y.breakPointIndexes.push(m.value),g??(g={}),g.index=m.value;break;case 91:y.leaderLineIndex=m.value}}return y}(c,a))}}return d}(s,t)));break;case 304:s.value!=="LEADER_LINE{"&&(e.textContent=s.value,e.contentType??(e.contentType=2));break;case 340:e.textStyleId=s.value;break;case 341:e.blockContentId=s.value,ae(e).blockContentId=s.value}}}},{code:270,name:"version",parser:l},{code:340,name:"leaderStyleId",parser:l},{code:90,name:"propertyOverrideFlag",parser:l},{code:170,name:"leaderLineType",parser:l},{code:91,name:"leaderLineColor",parser:l},{code:341,name:"leaderLineTypeId",parser:l},{code:171,name:"leaderLineWeight",parser:l},{code:290,name:"landingEnabled",parser:T},{code:291,name:"doglegEnabled",parser:T},{code:[40,41],name:"doglegLength",parser:l},{code:342,name:"arrowheadId",parser:l},{code:42,name:"arrowheadSize",parser:l},{code:172,name:"contentType",parser:l},{code:343,name:"textStyleId",parser:l},{code:173,name:"textLeftAttachmentType",parser:l},{code:95,name:"textRightAttachmentType",parser:l},{code:174,name:"textAngleType",parser:l},{code:175,name:"textAlignmentType",parser:l},{code:92,name:"textColor",parser:l},{code:292,name:"textFrameEnabled",parser:T},{code:344,parser:function(i,t,e){e.blockContentId=i.value,ae(e).blockContentId=i.value}},{code:93,name:"blockContentColor",parser:l},{code:10,name:"blockContentScale",parser:f},{code:43,name:"blockContentRotation",parser:l},{code:176,name:"blockContentConnectionType",parser:l},{code:293,name:"annotativeScaleEnabled",parser:T},{code:94,parser:function(i,t,e){e.arrowheadOverrides??(e.arrowheadOverrides=[]),e.arrowheadOverrides.push({index:i.value})},isMultiple:!0},{code:345,parser:function(i,t,e){var s;((s=e).arrowheadOverrides??(s.arrowheadOverrides=[]),s.arrowheadOverrides.length||s.arrowheadOverrides.push({}),s.arrowheadOverrides[s.arrowheadOverrides.length-1]).handle=i.value},isMultiple:!0},{code:330,parser:function(i,t,e){e.blockAttributes??(e.blockAttributes=[]),e.blockAttributes.push({id:i.value})},isMultiple:!0},{code:177,parser:function(i,t,e){On(e).index=i.value},isMultiple:!0},{code:44,parser:function(i,t,e){On(e).width=i.value},isMultiple:!0},{code:302,parser:function(i,t,e){On(e).text=i.value},isMultiple:!0},{code:294,name:"textDirectionNegative",parser:T},{code:178,name:"textAlignInIPE",parser:l},{code:179,name:"textAttachmentPoint",parser:l},{code:271,name:"textAttachmentDirection",parser:l},{code:272,name:"bottomTextAttachmentDirection",parser:l},{code:273,name:"topTextAttachmentDirection",parser:l},{code:100,name:"subclassMarker",parser:l},...V];function rt(i,t){return Kn(f(i,t))}function bi(i,t){(t!=null&&t.start||t!=null&&t.end)&&(i.breaks??(i.breaks=[]),i.breaks.push(t))}function ae(i){return i.blockContent??(i.blockContent={})}function On(i){return i.blockAttributes??(i.blockAttributes=[]),i.blockAttributes.length||i.blockAttributes.push({}),i.blockAttributes[i.blockAttributes.length-1]}class xh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){_h(this,"parser",E(yu,mu))}}function wh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}_h(xh,"ForEntityName","MULTILEADER");let _u={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},xu=[{code:50,name:"angle",parser:l},{code:210,name:"extrusionDirection",parser:f},{code:39,name:"thickness",parser:l},{code:10,name:"position",parser:f},{code:100,name:"subclassMarker",parser:l},...V];class bh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){wh(this,"parser",E(xu,_u))}}function fh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}wh(bh,"ForEntityName","POINT");let wu={startWidth:0,endWidth:0,bulge:0},bu=[{code:91,name:"id",parser:l},{code:[...hn(71,75)],name:"faces",isMultiple:!0,parser:l},{code:50,name:"tangentDirection",parser:l},{code:70,name:"flag",parser:l},{code:42,name:"bulge",parser:l},{code:41,name:"endWidth",parser:l},{code:40,name:"startWidth",parser:l},{code:30,name:"z",parser:l},{code:20,name:"y",parser:l},{code:10,name:"x",parser:l},{code:100,name:"subclassMarker",parser:l},{code:100},...V];class vr{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){fh(this,"parser",E(bu,wu))}}function Sh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}fh(vr,"ForEntityName","VERTEX");let fu={thickness:0,flag:0,startWidth:0,endWidth:0,meshMVertexCount:0,meshNVertexCount:0,surfaceMDensity:0,surfaceNDensity:0,smoothType:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},Su=[{code:0,name:"vertices",isMultiple:!0,parser:(i,t)=>O(i,0,"VERTEX")?(i=t.next(),new vr().parseEntity(t,i)):ri},{code:210,name:"extrusionDirection",parser:f},{code:75,name:"smoothType",parser:l},{code:74,name:"surfaceNDensity",parser:l},{code:73,name:"surfaceMDensity",parser:l},{code:72,name:"meshNVertexCount",parser:l},{code:71,name:"meshMVertexCount",parser:l},{code:41,name:"endWidth",parser:l},{code:40,name:"startWidth",parser:l},{code:70,name:"flag",parser:l},{code:39,name:"thickness",parser:l},{code:30,name:"elevation",parser:l},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:l},...V];class Ih{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Sh(this,"parser",E(Su,fu))}}Sh(Ih,"ForEntityName","POLYLINE");(it={})[it.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",it[it.CURVE_FIT=2]="CURVE_FIT",it[it.SPLINE_FIT=4]="SPLINE_FIT",it[it.POLYLINE_3D=8]="POLYLINE_3D",it[it.POLYGON_3D=16]="POLYGON_3D",it[it.CLOSED_POLYGON=32]="CLOSED_POLYGON",it[it.POLYFACE=64]="POLYFACE",it[it.CONTINUOUS=128]="CONTINUOUS";var fi=((ie={})[ie.NONE=0]="NONE",ie[ie.QUADRATIC=5]="QUADRATIC",ie[ie.CUBIC=6]="CUBIC",ie[ie.BEZIER=8]="BEZIER",ie);function Ah(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Iu=[{code:11,name:"direction",parser:f},{code:10,name:"position",parser:f},{code:100,name:"subclassMarker",parser:l},...V];class Ph{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ah(this,"parser",E(Iu))}}function Th(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ah(Ph,"ForEntityName","RAY");let Au=[..._n("data"),{code:70,name:"version",parser:l},{code:100,name:"subclassMarker",parser:l},...V];class Eh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Th(this,"parser",E(Au))}}function Lh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Th(Eh,"ForEntityName","REGION");let Pu={vertices:[],backLineVertices:[]},Tu=[{code:360,name:"geometrySettingHardId",parser:l},{code:12,name:"backLineVertices",isMultiple:!0,parser:f},{code:93,name:"numberOfBackLineVertices",parser:l},{code:11,name:"vertices",isMultiple:!0,parser:f},{code:92,name:"verticesCount",parser:l},{code:[63,411],name:"indicatorColor",parser:l},{code:70,name:"indicatorTransparency",parser:l},{code:41,name:"bottomHeight",parser:l},{code:40,name:"topHeight",parser:l},{code:10,name:"verticalDirection",parser:f},{code:1,name:"name",parser:l},{code:91,name:"flag",parser:l},{code:90,name:"state",parser:l},{code:100,name:"subclassMarker",parser:l},...V];class Mh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Lh(this,"parser",E(Tu,Pu))}}function kh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Lh(Mh,"ForEntityName","SECTION");let Eu={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},Lu=[{code:210,name:"extrusionDirection",parser:f},{code:39,name:"thickness",parser:l},{code:[...hn(10,14)],name:"points",isMultiple:!0,parser:f},{code:100,name:"subclassMarker",parser:l},...V];class vh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){kh(this,"parser",E(Lu,Eu))}}function Ch(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}kh(vh,"ForEntityName","SOLID");let Mu=[{code:350,name:"historyObjectSoftId",parser:l},{code:100,name:"subclassMarker",parser:l},..._n("data"),{code:70,name:"version",parser:l},{code:100},...V];class Oh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Ch(this,"parser",E(Mu))}}function Nh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}Ch(Oh,"ForEntityName","3DSOLID");let ku={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},vu=[{code:11,name:"fitPoints",isMultiple:!0,parser:f},{code:10,name:"controlPoints",isMultiple:!0,parser:f},{code:41,name:"weights",isMultiple:!0,parser:l},{code:40,name:"knots",isMultiple:!0,parser:l},{code:13,name:"endTangent",parser:f},{code:12,name:"startTangent",parser:f},{code:44,name:"fitTolerance",parser:l},{code:43,name:"controlTolerance",parser:l},{code:42,name:"knotTolerance",parser:l},{code:74,name:"numberOfFitPoints",parser:l},{code:73,name:"numberOfControlPoints",parser:l},{code:72,name:"numberOfKnots",parser:l},{code:71,name:"degree",parser:l},{code:70,name:"flag",parser:l},{code:210,name:"normal",parser:f},{code:100,name:"subclassMarker",parser:l},...V];class Bh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Nh(this,"parser",E(vu,ku))}}Nh(Bh,"ForEntityName","SPLINE");(At={})[At.NONE=0]="NONE",At[At.CLOSED=1]="CLOSED",At[At.PERIODIC=2]="PERIODIC",At[At.RATIONAL=4]="RATIONAL",At[At.PLANAR=8]="PLANAR",At[At.LINEAR=16]="LINEAR";function Rh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let Cu=[{code:280,name:"shadowMapSoftness",parser:l},{code:71,name:"shadowMapSize",parser:l},{code:70,name:"shadowType",parser:l},{code:292,name:"isSummerTime",parser:T},{code:92,name:"time",parser:l},{code:91,name:"julianDay",parser:l},{code:291,name:"hasShadow",parser:T},{code:40,name:"intensity",parser:l},{code:421,name:"lightColorInstance",parser:l},{code:63,name:"lightColorIndex",parser:l},{code:290,name:"isOn",parser:T},{code:90,name:"version",parser:l},{code:100,name:"subclassMarker",parser:l,pushContext:!0},...V.filter(i=>i.code!==100)];class Fh{parseEntity(t,e){let s={layer:""};return this.parser(e,t,s),s}constructor(){Rh(this,"parser",E(Cu))}}Rh(Fh,"ForEntityName","SUN");class vi{parseEntity(t,e){let s={};for(;!t.isEOF();){if(e.code===0){t.rewind();break}switch(e.code){case 100:s.subclassMarker=e.value,e=t.next();break;case 2:s.name=e.value,e=t.next();break;case 5:s.handle=e.value,e=t.next();break;case 10:s.startPoint=Kn(Le(t)),e=t.lastReadGroup;break;case 11:s.directionVector=Kn(Le(t)),e=t.lastReadGroup;break;case 90:s.tableValue=e.value,e=t.next();break;case 91:s.rowCount=e.value,e=t.next();break;case 92:s.columnCount=e.value,e=t.next();break;case 93:s.overrideFlag=e.value,e=t.next();break;case 94:s.borderColorOverrideFlag=e.value,e=t.next();break;case 95:s.borderLineWeightOverrideFlag=e.value,e=t.next();break;case 96:s.borderVisibilityOverrideFlag=e.value,e=t.next();break;case 141:s.rowHeightArr??(s.rowHeightArr=[]),s.rowHeightArr.push(e.value),e=t.next();break;case 142:s.columnWidthArr??(s.columnWidthArr=[]),s.columnWidthArr.push(e.value),e=t.next();break;case 280:s.version=e.value,e=t.next();break;case 310:s.bmpPreview??(s.bmpPreview=""),s.bmpPreview+=e.value,e=t.next();break;case 330:s.ownerBlockRecordSoftId=e.value,e=t.next();break;case 342:s.tableStyleId=e.value,e=t.next();break;case 343:s.blockRecordHandle=e.value,e=t.next();break;case 170:s.attachmentPoint=e.value,e=t.next();break;case 171:s.cells??(s.cells=[]),s.cells.push(function(n,r){let o=!1,a=!1,h={};for(;!n.isEOF()&&r.code!==0&&!a;)switch(r.code){case 171:if(o){a=!0;continue}h.cellType=r.value,o=!0,r=n.next();break;case 172:h.flagValue=r.value,r=n.next();break;case 173:h.mergedValue=r.value,r=n.next();break;case 174:h.autoFit=r.value,r=n.next();break;case 175:h.borderWidth=r.value,r=n.next();break;case 176:h.borderHeight=r.value,r=n.next();break;case 91:h.overrideFlag=r.value,r=n.next();break;case 178:h.virtualEdgeFlag=r.value,r=n.next();break;case 145:h.rotation=r.value,r=n.next();break;case 345:h.fieldObjetId=r.value,r=n.next();break;case 340:h.blockTableRecordId=r.value,r=n.next();break;case 146:h.blockScale=r.value,r=n.next();break;case 177:h.blockAttrNum=r.value,r=n.next();break;case 7:h.textStyle=r.value,r=n.next();break;case 140:h.textHeight=r.value,r=n.next();break;case 170:h.attachmentPoint=r.value,r=n.next();break;case 92:h.extendedCellFlags=r.value,r=n.next();break;case 285:h.rightBorderVisibility=!!(r.value??!0),r=n.next();break;case 286:h.bottomBorderVisibility=!!(r.value??!0),r=n.next();break;case 288:h.leftBorderVisibility=!!(r.value??!0),r=n.next();break;case 289:h.topBorderVisibility=!!(r.value??!0),r=n.next();break;case 301:(function(c,d,u){for(;u.code!==304;)switch(u.code){case 301:case 93:case 90:case 94:u=d.next();break;case 1:c.text=u.value,u=d.next();break;case 300:c.attrText=u.value,u=d.next();break;case 302:c.text=u.value?u.value:c.text,u=d.next();break;default:u=d.next()}})(h,n,r),r=n.next();break;default:return h}return o=!1,a=!1,h}(t,e)),e=t.lastReadGroup;break;default:Md(s,e,t),e=t.next()}}return s}}function zh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}(Mn="ForEntityName")in vi?Object.defineProperty(vi,Mn,{value:"ACAD_TABLE",enumerable:!0,configurable:!0,writable:!0}):vi[Mn]="ACAD_TABLE";let Ou=[{code:11,name:"xAxisDirection",parser:f},{code:210,name:"extrusionDirection",parser:f},{code:1,name:"text",parser:l},{code:10,name:"position",parser:f},{code:3,name:"styleName",parser:l},{code:100,name:"subclassMarker",parser:l},...V];class Vh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){zh(this,"parser",E(Ou))}}zh(Vh,"ForEntityName","TOLERANCE");var Nu=((nt={})[nt.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",nt[nt.TANGENT_DEFINED=2]="TANGENT_DEFINED",nt[nt.NOT_USED=4]="NOT_USED",nt[nt.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",nt[nt.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",nt[nt.FOR_POLYLINE=32]="FOR_POLYLINE",nt[nt.FOR_POLYGON=64]="FOR_POLYGON",nt[nt.POLYFACE=128]="POLYFACE",nt);let Bu=[{code:[335,343,344,91],name:"softPointers",isMultiple:!0,parser:l},{code:361,name:"sunId",parser:l},{code:431,name:"ambientLightColorName",parser:l},{code:421,name:"ambientLightColorInstance",parser:l},{code:63,name:"ambientLightColorIndex",parser:l},{code:142,name:"contrast",parser:l},{code:141,name:"brightness",parser:l},{code:282,name:"defaultLightingType",parser:l},{code:292,name:"isDefaultLighting",parser:T},{code:348,name:"visualStyleId",parser:l},{code:333,name:"shadePlotId",parser:l},{code:332,name:"backgroundId",parser:l},{code:61,name:"majorGridFrequency",parser:l},{code:170,name:"shadePlotMode",parser:l},{code:146,name:"elevation",parser:l},{code:79,name:"orthographicType",parser:l},{code:346,name:"ucsBaseId",parser:l},{code:345,name:"ucsId",parser:l},{code:112,name:"ucsYAxis",parser:f},{code:111,name:"ucsXAxis",parser:f},{code:110,name:"ucsOrigin",parser:f},{code:74,name:"iconFlag",parser:l},{code:71,name:"ucsPerViewport",parser:l},{code:281,name:"renderMode",parser:l},{code:1,name:"sheetName",parser:l},{code:340,name:"clippingBoundaryId",parser:l},{code:90,name:"statusBitFlags",parser:l},{code:331,name:"frozenLayerIds",isMultiple:!0,parser:l},{code:72,name:"circleZoomPercent",parser:l},{code:51,name:"viewTwistAngle",parser:l},{code:50,name:"snapAngle",parser:l},{code:45,name:"viewHeight",parser:l},{code:44,name:"backClipZ",parser:l},{code:43,name:"frontClipZ",parser:l},{code:42,name:"perspectiveLensLength",parser:l},{code:17,name:"targetPoint",parser:f},{code:16,name:"viewDirection",parser:f},{code:15,name:"gridSpacing",parser:f},{code:14,name:"snapSpacing",parser:f},{code:13,name:"snapBase",parser:f},{code:12,name:"displayCenter",parser:f},{code:69,name:"viewportId",parser:l},{code:68,name:"status",parser:l},{code:41,name:"height",parser:l},{code:40,name:"width",parser:l},{code:10,name:"viewportCenter",parser:f},{code:100,name:"subclassMarker",parser:l,pushContext:!0},...V];class Ci{parseEntity(t,e){let s={};return E(Bu)(e,t,s),s}}function Dh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}(kn="ForEntityName")in Ci?Object.defineProperty(Ci,kn,{value:"VIEWPORT",enumerable:!0,configurable:!0,writable:!0}):Ci[kn]="VIEWPORT";let Ru={brightness:50,constrast:50,fade:0},Fu=[{code:14,name:"boundary",isMultiple:!0,parser:f},{code:91,name:"numberOfVertices",parser:l},{code:71,name:"boundaryType",parser:l},{code:360,name:"imageDefReactorHardId",parser:l},{code:283,name:"fade",parser:l},{code:282,name:"contrast",parser:l},{code:281,name:"brightness",parser:l},{code:280,name:"isClipping",parser:T},{code:70,name:"displayFlag",parser:l},{code:340,name:"imageDefHardId",parser:l},{code:13,name:"imageSize",parser:f},{code:12,name:"vDirection",parser:f},{code:11,name:"uDirection",parser:f},{code:10,name:"position",parser:f},{code:90,name:"classVersion",parser:l},{code:100,name:"subclassMarker",parser:l},...V];class jh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Dh(this,"parser",E(Fu,Ru))}}Dh(jh,"ForEntityName","WIPEOUT");(ne={})[ne.ShowImage=1]="ShowImage",ne[ne.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",ne[ne.UseClippingBoundary=4]="UseClippingBoundary",ne[ne.Transparency=8]="Transparency";function Wh(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}let zu=[{code:11,name:"direction",parser:f},{code:10,name:"position",parser:f},{code:100,name:"subclassMarker",parser:l},...V];class Hh{parseEntity(t,e){let s={};return this.parser(e,t,s),s}constructor(){Wh(this,"parser",E(zu))}}Wh(Hh,"ForEntityName","XLINE");let Vu=0;function Gh(i){if(!i)throw TypeError("entity cannot be undefined or null");i.handle||(i.handle=Vu++)}let Du=Object.fromEntries([Nl,Li,jl,Ul,Xl,ql,Ei,Kl,Jl,nh,oh,lh,ch,uh,ki,ph,yh,Hl,xh,bh,Ih,Ph,Eh,Mh,vh,Oh,Bh,Fh,vi,Vl,Vh,sh,vr,Ci,jh,Hh].map(i=>[i.ForEntityName,new i]));function Uh(i,t){let e=[];for(;!O(i,0,"EOF");){if(i.code===0){if(i.value==="ENDBLK"||i.value==="ENDSEC"){t.rewind();break}let s=Du[i.value];if(s){let n=i.value;i=t.next();let r=s.parseEntity(t,i);r.type=n,Gh(r),e.push(r)}else t.debug}i=t.next()}return e}function Ls(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}class Vo{next(){if(!this.hasNext())return this._eof?this.debug:this.debug,{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=Do(t,this._data[this._pointer++],this.debug),s={code:t,value:e};return O(s,0,"EOF")&&(this._eof=!0),this.lastReadGroup=s,s}peek(){if(!this.hasNext())throw this._eof?Error("Cannot call 'next' after EOF group has been read"):Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);let t={code:parseInt(this._data[this._pointer]),value:0};return t.value=Do(t.code,this._data[this._pointer+1],this.debug),t}rewind(t){t=t||1,this._pointer=this._pointer-2*t}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(t,e=!1){Ls(this,"_data",void 0),Ls(this,"debug",void 0),Ls(this,"_pointer",void 0),Ls(this,"_eof",void 0),Ls(this,"lastReadGroup",void 0),this._data=t,this.debug=e,this.lastReadGroup={code:0,value:0},this._pointer=0,this._eof=!1}}function Do(i,t,e=!1){var s;let n=(s=t).endsWith("\r")?s.slice(0,-1):s;return i<=9?n:i>=10&&i<=59?parseFloat(t.trim()):i>=60&&i<=99?parseInt(t.trim()):i>=100&&i<=109?n:i>=110&&i<=149?parseFloat(t.trim()):i>=160&&i<=179?parseInt(t.trim()):i>=210&&i<=239?parseFloat(t.trim()):i>=270&&i<=289?parseInt(t.trim()):i>=290&&i<=299?function(r){if(r==="0")return!1;if(r==="1")return!0;throw TypeError("String '"+r+"' cannot be cast to Boolean type")}(t.trim()):i>=300&&i<=369?n:i>=370&&i<=389?parseInt(t.trim()):i>=390&&i<=399?n:i>=400&&i<=409?parseInt(t.trim()):i>=410&&i<=419?n:i>=420&&i<=429?parseInt(t.trim()):i>=430&&i<=439?n:i>=440&&i<=459?parseInt(t.trim()):i>=460&&i<=469?parseFloat(t.trim()):i>=470&&i<=481||i===999||i>=1e3&&i<=1009?n:i>=1010&&i<=1059?parseFloat(t.trim()):i>=1060&&i<=1071?parseInt(t.trim()):n}function ju(i,t){let e=null,s={};for(;!O(i,0,"EOF")&&!O(i,0,"ENDSEC");)i.code===9?e=typeof i.value=="string"?i.value:null:e!=null&&(i.code===10?s[e]=Le(t):s[e]=i.value),i=t.next();return s}let me=[{code:100,name:"subclassMarker",parser:l},{code:330,name:"ownerObjectId",parser:l},{code:102,isMultiple:!0,parser(i,t){for(;!O(i,0,"EOF")&&!O(i,102,"}");)i=t.next()}},{code:5,name:"handle",parser:l}],Wu=[{code:70,name:"flag",parser:l},{code:2,name:"appName",parser:l},{code:100,name:"subclassMarker",parser:l},...me],Hu=E(Wu),Gu=E([{code:310,name:"bmpPreview",parser:l},{code:281,name:"scalability",parser:l},{code:280,name:"explodability",parser:l},{code:70,name:"insertionUnits",parser:l},{code:340,name:"layoutObjects",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...me]),Uu=E([...kr.map(i=>({...i,parser:l})),{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},{code:105,name:"handle",parser:l},...me.filter(i=>i.code!==5)]),Yu=E([{code:347,name:"materialObjectId",parser:l},{code:390,name:"plotStyleNameObjectId",parser:l},{code:370,name:"lineweight",parser:l},{code:290,name:"isPlotting",parser:T},{code:6,name:"lineType",parser:l},{code:62,name:"colorIndex",parser:l},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...me]),Xu=E([{code:9,name:"text",parser:l},{code:45,name:"offsetY",parser:l},{code:44,name:"offsetX",parser:l},{code:50,name:"rotation",parser:l},{code:46,name:"scale",parser:l},{code:340,name:"styleObjectId",parser:l},{code:75,name:"shapeNumber",parser:l},{code:74,name:"elementTypeFlag",parser:l},{code:49,name:"elementLength",parser:l}],{elementTypeFlag:0,elementLength:0}),$u=E([{code:49,name:"pattern",parser(i,t){let e={};return Xu(i,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:l},{code:73,name:"numberOfLineTypes",parser:l},{code:72,parser:l},{code:3,name:"description",parser:l},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...me]),qu=E([{code:1e3,name:"extendedFont",parser:l},{code:1001},{code:4,name:"bigFont",parser:l},{code:3,name:"font",parser:l},{code:42,name:"lastHeight",parser:l},{code:71,name:"textGenerationFlag",parser:l},{code:50,name:"obliqueAngle",parser:l},{code:41,name:"widthFactor",parser:l},{code:40,name:"fixedTextHeight",parser:l},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...me]),Zu=[{code:13,name:"orthographicOrigin",parser:f},{code:71,name:"orthographicType",parser:l},{code:346,name:"baseUcsHandle",parser:l},{code:146,name:"elevation",parser:l},{code:79,name:"isOrthographic",parser:T},{code:12,name:"yAxis",parser:f},{code:11,name:"xAxis",parser:f},{code:10,name:"origin",parser:f},{code:70,name:"flag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...me],Ku=E(Zu),Qu=[{code:346,name:"baseUcsId",parser:l},{code:345,name:"ucsId",parser:l},{code:146,name:"elevation",parser:l},{code:79,name:"orthographicType",parser:l},{code:112,name:"ucsYAxis",parser:f},{code:111,name:"ucsXAxis",parser:f},{code:110,name:"ucsOrigin",parser:f},{code:361,name:"sunHardId",parser:l},{code:348,name:"styleHardId",parser:l},{code:334,name:"liveSectionSoftId",parser:l},{code:332,name:"backgroundSoftId",parser:l},{code:73,name:"isPlottable",parser:T},{code:72,name:"isUcsAssociated",parser:T},{code:281,name:"renderMode",parser:l},{code:71,name:"viewMode",parser:l},{code:50,name:"twistAngle",parser:l},{code:44,name:"backClippingPlane",parser:l},{code:43,name:"frontClippingPlane",parser:l},{code:42,name:"lensLength",parser:l},{code:12,name:"target",parser:f},{code:11,name:"direction",parser:f},{code:10,name:"center",parser:f},{code:41,name:"width",parser:l},{code:40,name:"height",parser:l},{code:70,name:"flag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...me],Ju=E(Qu),tg=E([{code:[63,421,431],name:"ambientColor",parser:l},{code:142,name:"contrast",parser:l},{code:141,name:"brightness",parser:l},{code:282,name:"defaultLightingType",parser:l},{code:292,name:"isDefaultLightingOn",parser:T},{code:348,name:"visualStyleObjectId",parser:l},{code:333,name:"shadePlotObjectId",parser:l},{code:332,name:"backgroundObjectId",parser:l},{code:61,name:"majorGridLines",parser:l},{code:170,name:"shadePlotSetting",parser:l},{code:146,name:"elevation",parser:l},{code:79,name:"orthographicType",parser:l},{code:112,name:"ucsYAxis",parser:f},{code:111,name:"ucsXAxis",parser:f},{code:110,name:"ucsOrigin",parser:f},{code:74,name:"ucsIconSetting",parser:l},{code:71,name:"viewMode",parser:l},{code:281,name:"renderMode",parser:l},{code:1,name:"styleSheet",parser:l},{code:[331,441],name:"frozenLayers",parser:l,isMultiple:!0},{code:72,name:"circleSides",parser:l},{code:51,name:"viewTwistAngle",parser:l},{code:50,name:"snapRotationAngle",parser:l},{code:45,name:"viewHeight",parser:l},{code:44,name:"backClippingPlane",parser:l},{code:43,name:"frontClippingPlane",parser:l},{code:42,name:"lensLength",parser:l},{code:17,name:"viewTarget",parser:f},{code:16,name:"viewDirectionFromTarget",parser:f},{code:15,name:"gridSpacing",parser:f},{code:14,name:"snapSpacing",parser:f},{code:13,name:"snapBasePoint",parser:f},{code:12,name:"center",parser:f},{code:11,name:"upperRightCorner",parser:f},{code:10,name:"lowerLeftCorner",parser:f},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...me]),eg={APPID:Hu,BLOCK_RECORD:Gu,DIMSTYLE:Uu,LAYER:Yu,LTYPE:$u,STYLE:qu,UCS:Ku,VIEW:Ju,VPORT:tg},sg=E([{code:70,name:"maxNumberOfEntries",parser:l},{code:100,name:"subclassMarker",parser:l},{code:330,name:"ownerObjectId",parser:l},{code:102,parser:Gt},{code:102,parser:Gt},{code:102,parser:Gt},{code:360,isMultiple:!0},{code:5,name:"handle",parser:l},{code:2,name:"name",parser:l}]);function ig(i,t){var s;let e={};for(;!O(i,0,"EOF")&&!O(i,0,"ENDSEC");){if(O(i,0,"TABLE")){i=t.next();let n={entries:[]};sg(i,t,n),e[n.name]=n}if(O(i,0)&&!O(i,0,"ENDTAB")){let n=i.value;i=t.next();let r=eg[n];if(!r){t.debug,i=t.next();continue}let o={};r(i,t,o),(s=e[n])==null||s.entries.push(o)}i=t.next()}return e}function ng(i,t){let e={};for(;!O(i,0,"EOF")&&!O(i,0,"ENDSEC");){if(O(i,0,"BLOCK")){let s=rg(i=t.next(),t);Gh(s),s.name&&(e[s.name]=s)}i=t.next()}return e}function rg(i,t){let e={};for(;!O(i,0,"EOF");){if(O(i,0,"ENDBLK")){for(i=t.next();!O(i,0,"EOF");){if(O(i,100,"AcDbBlockEnd"))return e;i=t.next()}break}switch(i.code){case 1:e.xrefPath=i.value;break;case 2:e.name=i.value;break;case 3:e.name2=i.value;break;case 5:e.handle=i.value;break;case 8:e.layer=i.value;break;case 10:e.position=Le(t);break;case 67:e.paperSpace=!!i.value&&i.value==1;break;case 70:i.value!==0&&(e.type=i.value);break;case 100:break;case 330:e.ownerHandle=i.value;break;case 0:e.entities=Uh(i,t)}i=t.next()}return e}let ye=[{code:330,name:"ownerObjectId",parser:l},{code:102,parser:Gt},{code:102,parser:Gt},{code:102,parser:Gt},{code:5,name:"handle",parser:l}],Yh=[{code:333,name:"shadePlotId",parser:l},{code:149,name:"imageOriginY",parser:l},{code:148,name:"imageOriginX",parser:l},{code:147,name:"scaleFactor",parser:l},{code:78,name:"shadePlotCustomDPI",parser:l},{code:77,name:"shadePlotResolution",parser:l},{code:76,name:"shadePlotMode",parser:l},{code:75,name:"standardScaleType",parser:l},{code:7,name:"currentStyleSheet",parser:l},{code:74,name:"plotType",parser:l},{code:73,name:"plotRotation",parser:l},{code:72,name:"plotPaperUnit",parser:l},{code:70,name:"layoutFlag",parser:l},{code:143,name:"printScaleDenominator",parser:l},{code:142,name:"printScaleNumerator",parser:l},{code:141,name:"windowAreaYMax",parser:l},{code:140,name:"windowAreaXMax",parser:l},{code:49,name:"windowAreaYMin",parser:l},{code:48,name:"windowAreaXMin",parser:l},{code:47,name:"plotOriginY",parser:l},{code:46,name:"plotOriginX",parser:l},{code:45,name:"paperHeight",parser:l},{code:44,name:"paperWidth",parser:l},{code:43,name:"marginTop",parser:l},{code:42,name:"marginRight",parser:l},{code:41,name:"marginBottom",parser:l},{code:40,name:"marginLeft",parser:l},{code:6,name:"plotViewName",parser:l},{code:4,name:"paperSize",parser:l},{code:2,name:"configName",parser:l},{code:1,name:"pageSetupName",parser:l},{code:100,name:"subclassMarker",parser:l},...ye],og=[{code:346,name:"orthographicUcsId",parser:l},{code:345,name:"namedUcsId",parser:l},{code:331,name:"viewportId",parser:l},{code:330,name:"paperSpaceTableId",parser:l},{code:76,name:"orthographicType",parser:l},{code:17,name:"ucsYAxis",parser:f},{code:16,name:"ucsXAxis",parser:f},{code:13,name:"ucsOrigin",parser:f},{code:146,name:"elevation",parser:l},{code:15,name:"maxExtent",parser:f},{code:14,name:"minExtent",parser:f},{code:12,name:"insertionPoint",parser:f},{code:11,name:"maxLimit",parser:f},{code:10,name:"minLimit",parser:f},{code:71,name:"tabOrder",parser:l},{code:70,name:"controlFlag",parser:l},{code:1,name:"layoutName",parser:l},{code:100,name:"subclassMarker",parser:l},...Yh],ag=[{code:3,name:"entries",parser:(i,t)=>{let e={name:i.value};return(i=t.next()).code===350?e.objectSoftId=i.value:i.code===360?e.objectHardId=i.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:l},{code:280,name:"isHardOwned",parser:T},{code:100,name:"subclassMarker",parser:l},...ye],lg=[{code:40,name:"wcsToOCSTransform",parser:jo},{code:40,name:"ocsToWCSTransform",parser:jo},{code:41,name:"backClippingDistance",parser:l},{code:73,name:"isBackClipping",parser:T,pushContext:!0},{code:40,name:"frontClippingDistance",parser:l},{code:72,name:"isFrontClipping",parser:T,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:T},{code:11,name:"position",parser:f},{code:210,name:"normal",parser:f},{code:10,name:"boundaryVertices",parser:f,isMultiple:!0},{code:70,name:"boundaryCount",parser:l},{code:100,name:"subclassMarker",parser:l},{code:100},...ye];function jo(i,t){let e=[];for(let s=0;s<3&&O(i,40);++s){let n=[];for(let r=0;r<4&&O(i,40);++r)n.push(i.value),i=t.next();e.push(n)}return t.rewind(),e}let hg=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:l},{code:90,name:"version",parser:l},{code:1,name:"fileName",parser:l},{code:10,name:"size",parser:f},{code:11,name:"sizeOfOnePixel",parser:f},{code:280,name:"isLoaded",parser:l},{code:281,name:"resolutionUnits",parser:l},{code:100,name:"subclassMarker",parser:l}],cg=[{code:179,name:"unknown1",parser:l},{code:170,name:"contentType",parser:l},{code:171,name:"drawMLeaderOrderType",parser:l},{code:172,name:"drawLeaderOrderType",parser:l},{code:90,name:"maxLeaderSegmentPoints",parser:l},{code:40,name:"firstSegmentAngleConstraint",parser:l},{code:41,name:"secondSegmentAngleConstraint",parser:l},{code:173,name:"leaderLineType",parser:l},{code:91,name:"leaderLineColor",parser:l},{code:340,name:"leaderLineTypeId",parser:l},{code:92,name:"leaderLineWeight",parser:l},{code:290,name:"landingEnabled",parser:T},{code:42,name:"landingGap",parser:l},{code:291,name:"doglegEnabled",parser:T},{code:43,name:"doglegLength",parser:l},{code:3,name:"description",parser:l},{code:341,name:"arrowheadId",parser:l},{code:44,name:"arrowheadSize",parser:l},{code:300,name:"defaultMTextContents",parser:l},{code:342,name:"textStyleId",parser:l},{code:174,name:"textLeftAttachmentType",parser:l},{code:175,name:"textAngleType",parser:l},{code:176,name:"textAlignmentType",parser:l},{code:178,name:"textRightAttachmentType",parser:l},{code:93,name:"textColor",parser:l},{code:45,name:"textHeight",parser:l},{code:292,name:"textFrameEnabled",parser:T},{code:297,name:"textAlignAlwaysLeft",parser:T},{code:46,name:"alignSpace",parser:l},{code:343,name:"blockContentId",parser:l},{code:94,name:"blockContentColor",parser:l},{code:47,name:"blockContentScale.x",parser:l},{code:49,name:"blockContentScale.y",parser:l},{code:140,name:"blockContentScale.z",parser:l},{code:293,name:"blockContentScaleEnabled",parser:T},{code:141,name:"blockContentRotation",parser:l},{code:294,name:"blockContentRotationEnabled",parser:T},{code:177,name:"blockContentConnectionType",parser:l},{code:142,name:"scale",parser:l},{code:295,name:"overwritePropertyValue",parser:T},{code:296,name:"annotative",parser:T},{code:143,name:"breakGapSize",parser:l},{code:271,name:"textAttachmentDirection",parser:l},{code:272,name:"bottomTextAttachmentDirection",parser:l},{code:273,name:"topTextAttachmentDirection",parser:l},{code:298,name:"unknown2",parser:l},{code:100,name:"subclassMarker",parser:l},...ye];function Si(i,t,e){i.elements||(i.elements=[]);let s=i.elements.find(n=>n[t]===void 0);if(s){s[t]=e;return}i.elements.push({[t]:e})}let dg=[{code:6,parser:function({value:i},t,e){Si(e,"lineType",i)},isMultiple:!0},{code:62,parser:function({value:i},t,e){var s;if(e.fillColorIndex===void 0&&!((s=e.elements)!=null&&s.length)){e.fillColorIndex=i;return}Si(e,"colorIndex",i)},isMultiple:!0},{code:420,parser:function({value:i},t,e){var s;if(e.fillColor===void 0&&!((s=e.elements)!=null&&s.length)){e.fillColor=i;return}Si(e,"color",i)},isMultiple:!0},{code:49,parser:function({value:i},t,e){Si(e,"offset",i)},isMultiple:!0},{code:71,name:"elementCount",parser:l},{code:52,name:"endAngle",parser:l},{code:51,name:"startAngle",parser:l},{code:3,name:"description",parser:l},{code:70,name:"flags",parser:l},{code:2,name:"styleName",parser:l},{code:100,name:"subclassMarker",parser:l},...ye],ug=[{code:340,name:"entityIds",parser:l,isMultiple:!0},{code:71,name:"isSelectable",parser:T},{code:70,name:"isUnnamed",parser:T},{code:300,name:"description",parser:l},{code:100,name:"subclassMarker",parser:l},...ye],gg=[{code:8,name:"layerNames",parser:l,isMultiple:!0},{code:100,name:"subclassMarker",parser:l},{code:100,name:"filterSubclassMarker",parser:l},...ye],pg=[{code:90,name:"idBufferEntryCounts",parser:l,isMultiple:!0},{code:360,name:"idBufferIds",parser:l,isMultiple:!0},{code:8,name:"layerNames",parser:l,isMultiple:!0},{code:100,name:"subclassMarker",parser:l},{code:40,name:"timeStamp",parser:l},{code:100,name:"indexSubclassMarker",parser:l},...ye],mg=[{code:75,name:"hasLastPointRef",parser:T},{code:1,name:"pointRefs",parser:function(i,t){let e={className:i.value};for(;;)switch((i=t.next()).code){case 72:e.objectOsnapType=i.value;continue;case 331:e.mainObjectId=i.value;continue;case 73:e.mainObjectSubentityType=i.value;continue;case 91:e.mainObjectGsMarker=i.value;continue;case 301:e.mainObjectXrefHandle=i.value;continue;case 40:e.nearOsnapGeometryParameter=i.value;continue;case 10:{let s=f(i,t);e.osnapPoint="z"in s?s:{...s,z:0}}continue;case 332:e.intersectionObjectId=i.value;continue;case 74:e.intersectionObjectSubentityType=i.value;continue;case 92:e.intersectionObjectGsMarker=i.value;continue;case 302:e.intersectionObjectXrefHandle=i.value;continue;default:return t.rewind(),e}},isMultiple:!0},{code:71,name:"rotatedDimensionType",parser:l},{code:70,name:"transSpaceFlag",parser:T},{code:90,name:"associativityFlag",parser:l},{code:330,name:"dimensionObjectId",parser:l},{code:100,name:"subclassMarker",parser:l},...ye],yg={LAYOUT:og,PLOTSETTINGS:Yh,DICTIONARY:ag,SPATIAL_FILTER:lg,IMAGEDEF:hg,MLEADERSTYLE:cg,MLINESTYLE:dg,GROUP:ug,LAYER_FILTER:gg,LAYER_INDEX:pg,DIMASSOC:mg};function _g(i,t){let e=[];for(;i.code!==0||!["EOF","ENDSEC"].includes(i.value);){let s=i.value,n=yg[s];if(i.code===0&&(n!=null&&n.length)){let r=E(n),o={name:s};r(i=t.next(),t,o)?(e.push(o),i=t.peek()):i=t.next()}else i=t.next()}return{byName:Pd(e,({name:s})=>s)}}function Vs(i,t,e){return t in i?Object.defineProperty(i,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):i[t]=e,i}class xg{constructor(){Vs(this,"encoding","utf-8"),Vs(this,"encodingFailureFatal",!1),Vs(this,"thumbnailImageFormat","base64")}}class wg extends EventTarget{parseSync(t,e=!1){let s=new Vo(t.split(/\r\n|\r|\n/g),e);if(!s.hasNext())throw Error("Empty file");return this.parseAll(s)}parseStream(t){let e="",s=this;return new Promise((n,r)=>{t.on("data",o=>{e+=o}),t.on("end",()=>{try{let o=e.split(/\r\n|\r|\n/g),a=new Vo(o);if(!a.hasNext())throw Error("Empty file");n(s.parseAll(a))}catch(o){r(o)}}),t.on("error",o=>{r(o)})})}async parseFromUrl(t,e){let s=await fetch(t,e);if(!s.body)return null;let n=s.body.getReader(),r="";for(;;){let{done:o,value:a}=await n.read();if(o){r+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}r+=this._decoder.decode(a,{stream:!0})}return this.parseSync(r)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},s=t.next();for(;!O(s,0,"EOF");)O(s,0,"SECTION")&&(O(s=t.next(),2,"HEADER")?e.header=ju(s=t.next(),t):O(s,2,"CLASSES")?cd(s=t.next(),t,e):O(s,2,"BLOCKS")?e.blocks=ng(s=t.next(),t):O(s,2,"ENTITIES")?e.entities=Uh(s=t.next(),t):O(s,2,"TABLES")?e.tables=ig(s=t.next(),t):O(s,2,"OBJECTS")?e.objects=_g(s=t.next(),t):O(s,2,"THUMBNAILIMAGE")&&(e.thumbnailImage=function(n,r,o="base64"){let a,h="",c=0;for(;!O(n,0,"EOF")&&!O(n,0,"ENDSEC");)n.code===90?c=n.value:n.code===310&&(h+=n.value),n=r.next();if(o==="hex")a=h;else{let d=function(u){let p=u.length/2,g=new Uint8Array(p);for(let m=0;m<p;m++)g[m]=parseInt(u.substr(2*m,2),16);return g}(h);a=o==="buffer"?d:function(u){let p="";for(let g=0;g<u.length;g++)p+=String.fromCharCode(u[g]);return btoa(p)}(d)}return{size:c,data:a}}(s=t.next(),t,this._options.thumbnailImageFormat))),s=t.next();return e}constructor(t={}){super(),Vs(this,"_decoder",void 0),Vs(this,"_options",void 0);let e=new xg;this._options=Object.assign(e,t),this._decoder=new TextDecoder(this._options.encoding,{fatal:this._options.encodingFailureFatal})}}(Pt={})[Pt.NOT_APPLICABLE=0]="NOT_APPLICABLE",Pt[Pt.KEEP_EXISTING=1]="KEEP_EXISTING",Pt[Pt.USE_CLONE=2]="USE_CLONE",Pt[Pt.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",Pt[Pt.VALUE_NAME=4]="VALUE_NAME",Pt[Pt.UNMANGLE_NAME=5]="UNMANGLE_NAME";(Ye={})[Ye.NOUNIT=0]="NOUNIT",Ye[Ye.CENTIMETERS=2]="CENTIMETERS",Ye[Ye.INCH=5]="INCH";(Es={})[Es.PSLTSCALE=1]="PSLTSCALE",Es[Es.LIMCHECK=2]="LIMCHECK";(Xe={})[Xe.INCHES=0]="INCHES",Xe[Xe.MILLIMETERS=1]="MILLIMETERS",Xe[Xe.PIXELS=2]="PIXELS";(Tt={})[Tt.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",Tt[Tt.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",Tt[Tt.DRAWING_LIMITS=2]="DRAWING_LIMITS",Tt[Tt.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",Tt[Tt.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",Tt[Tt.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(re={})[re.AS_DISPLAYED=0]="AS_DISPLAYED",re[re.WIREFRAME=1]="WIREFRAME",re[re.HIDDEN=2]="HIDDEN",re[re.RENDERED=3]="RENDERED";(Et={})[Et.DRAFT=0]="DRAFT",Et[Et.PREVIEW=1]="PREVIEW",Et[Et.NORMAL=2]="NORMAL",Et[Et.PRESENTATION=3]="PRESENTATION",Et[Et.MAXIMUM=4]="MAXIMUM",Et[Et.CUSTOM=5]="CUSTOM";(oe={})[oe.NONE=0]="NONE",oe[oe.AbsoluteRotation=1]="AbsoluteRotation",oe[oe.TextEmbedded=2]="TextEmbedded",oe[oe.ShapeEmbedded=4]="ShapeEmbedded";(vn={})[vn.PaperSpace=1]="PaperSpace";($e={})[$e.XrefDependent=16]="XrefDependent",$e[$e.XrefResolved=32]="XrefResolved",$e[$e.Referenced=64]="Referenced";(Lt={})[Lt.Off=0]="Off",Lt[Lt.Perspective=1]="Perspective",Lt[Lt.ClipFront=2]="ClipFront",Lt[Lt.ClipBack=4]="ClipBack",Lt[Lt.UcsFollow=8]="UcsFollow",Lt[Lt.ClipFrontByFrontZ=16]="ClipFrontByFrontZ";class bg{parse(t){const e=new wg,s=this.getDxfInfoFromBuffer(t);let n="";return s.version&&s.version.value<=23&&s.encoding?n=new TextDecoder(s.encoding).decode(t):n=new TextDecoder().decode(t),e.parseSync(n)}getDxfInfoFromBuffer(t){var c,d,u;const s=new TextDecoder("utf-8");let n=0,r="",o=null,a=null,h=!1;for(;n<t.byteLength;){const p=Math.min(n+65536,t.byteLength),g=t.slice(n,p);n=p;const y=(r+s.decode(g,{stream:!0})).split(/\r?\n/);r=y.pop()??"";for(let b=0;b<y.length;b++){const x=y[b].trim();if(x==="SECTION"&&((c=y[b+2])==null?void 0:c.trim())==="HEADER")h=!0;else if(x==="ENDSEC"&&h)return{version:o,encoding:a};if(h&&x==="$ACADVER"){const I=(d=y[b+2])==null?void 0:d.trim();I&&(o=new kt(I))}else if(h&&x==="$DWGCODEPAGE"){const I=(u=y[b+2])==null?void 0:u.trim();if(I){const S=nr[I];a=na(S)}}if(o&&a)return{version:o,encoding:a}}}return{version:o,encoding:a}}}class Wo{convert(t){const e=this.createEntity(t);return e&&this.processCommonAttrs(t,e),e}createEntity(t){return t.type=="3DFACE"?this.convertFace(t):t.type=="ARC"?this.convertArc(t):t.type=="ATTDEF"?this.convertAttributeDefinition(t):t.type=="ATTRIB"?this.convertAttribute(t):t.type=="CIRCLE"?this.convertCirle(t):t.type=="DIMENSION"?this.convertDimension(t):t.type=="ELLIPSE"?this.convertEllipse(t):t.type=="HATCH"?this.convertHatch(t):t.type=="IMAGE"?this.convertImage(t):t.type=="LEADER"?this.convertLeader(t):t.type=="LINE"?this.convertLine(t):t.type=="LWPOLYLINE"?this.convertLWPolyline(t):t.type=="MTEXT"?this.convertMText(t):t.type=="MLINE"?this.convertMLine(t):t.type=="MULTILEADER"||t.type=="MLEADER"?this.convertMLeader(t):t.type=="POLYLINE"?this.convertPolyline(t):t.type=="POINT"?this.convertPoint(t):t.type=="RAY"?this.convertRay(t):t.type=="SPLINE"?this.convertSpline(t):t.type=="ACAD_TABLE"?this.convertTable(t):t.type=="TEXT"?this.convertText(t):t.type=="SOLID"?this.convertSolid(t):t.type=="VIEWPORT"?this.convertViewport(t):t.type=="WIPEOUT"?this.convertWipeout(t):t.type=="XLINE"?this.convertXline(t):t.type=="INSERT"?this.convertBlockReference(t):null}convertFace(t){const e=new ji;return t.vertices.forEach((s,n)=>e.setVertexAt(n,s)),e}convertArc(t){const e=t.extrusionDirection??_.Z_AXIS;return new Ri(Hn(t.center,e),t.radius,k.degToRad(t.startAngle),k.degToRad(t.endAngle),e)}convertAttributeCommon(t,e){e.textString=t.text,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=t.rotation,e.oblique=t.obliqueAngle??0,e.thickness=t.thickness,e.tag=t.tag,e.fieldLength=0,e.isInvisible=(t.attributeFlag&tt.Invisible)!==0,e.isConst=(t.attributeFlag&tt.Const)!==0,e.isVerifiable=(t.attributeFlag&tt.Verifiable)!==0,e.isPreset=(t.attributeFlag&tt.Preset)!==0,e.isReallyLocked=!!t.isReallyLocked,e.isMTextAttribute=(t.mtextFlag&jt.MultiLine)!==0,e.isConstMTextAttribute=(t.mtextFlag&jt.ConstMultiLine)!==0}convertAttribute(t){const e=new zi;return this.convertAttributeCommon(t,e),e.styleName=t.textStyle,e.horizontalMode=t.horizontalJustification,e.verticalMode=t.verticalJustification,e.widthFactor=t.scale??1,e.lockPositionInBlock=t.lockPositionFlag,e}convertAttributeDefinition(t){const e=new Fi;return this.convertAttributeCommon(t,e),e.styleName=t.styleName,e.horizontalMode=t.halign,e.verticalMode=t.valign,e.widthFactor=t.xScale??1,e.prompt=t.prompt,e}convertCirle(t){const e=t.extrusionDirection??_.Z_AXIS;return new Vi(Hn(t.center,e),t.radius,e)}convertEllipse(t){const e=new _(t.majorAxisEndPoint),s=e.length();return new Di(t.center,t.extrusionDirection??_.Z_AXIS,e,s,s*t.axisRatio,t.startAngle,t.endAngle)}convertLine(t){const e=t.startPoint,s=t.endPoint;return new Ys(new w(e.x,e.y,e.z||0),new w(s.x,s.y,s.z||0))}convertSpline(t){try{if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new $s(t.controlPoints,t.knots,t.weights,t.degree,!!(t.flag&1));if(t.numberOfFitPoints>0)return new $s(t.fitPoints,"Uniform",t.degree,!!(t.flag&1))}catch{}return null}convertPoint(t){const e=new $i;return e.position=t.position,e}convertSolid(t){const e=new Yi;return t.points.forEach((s,n)=>e.setPointAt(n,s)),e.thickness=t.thickness,e}convertPolyline(t){var d;const e=!!(t.flag&1),s=!!(t.flag&8),n=!!(t.flag&16),r=!!(t.flag&64),o=!!(t.flag&32),a=[],h=[],c=[];if((d=t.vertices)==null||d.map(u=>{u.flag&Nu.SPLINE_CONTROL_POINT||(r&&u.flag&128?u.flag&64?(a.push({x:u.x,y:u.y,z:u.z}),h.push(u.bulge??0)):u.faces&&u.faces.length>=3&&c.push([...u.faces]):(a.push({x:u.x,y:u.y,z:u.z}),h.push(u.bulge??0)))}),n){const u=t.meshMVertexCount,p=t.meshNVertexCount;return new Ji(u,p,a,e,o)}else{if(r)return new tn(a,c);if(s){let u=Rs.SimplePoly;return t.flag&4&&(t.smoothType==fi.CUBIC?u=Rs.CubicSplinePoly:t.smoothType==fi.QUADRATIC&&(u=Rs.QuadSplinePoly)),new Bi(u,a,e)}else{let u=rs.SimplePoly;return t.flag&2?u=rs.FitCurvePoly:t.flag&4&&(t.smoothType==fi.CUBIC?u=rs.CubicSplinePoly:t.smoothType==fi.QUADRATIC&&(u=rs.QuadSplinePoly)),new Ni(u,a,0,e,t.startWidth,t.endWidth,h)}}}convertLWPolyline(t){var n;const e=new Xi;e.closed=!!(t.flag&1);const s=t.constantWidth??-1;return(n=t.vertices)==null||n.forEach((r,o)=>{e.addVertexAt(o,new v(r.x,r.y),r.bulge,r.startWidth??s,r.endWidth??s)}),e}convertHatch(t){var n;const e=new Us;if((n=t.definitionLines)==null||n.forEach(r=>{e.definitionLines.push({angle:k.degToRad(r.angle||0),base:r.base,offset:r.offset,dashLengths:r.numberOfDashLengths>0?r.dashLengths:[]})}),e.isSolidFill=t.solidFill==sd.SolidFill,e.hatchStyle=t.hatchStyle,e.patternName=t.patternName,e.patternType=t.patternType,e.patternAngle=t.patternAngle==null?0:k.degToRad(t.patternAngle),e.patternScale=t.patternScale==null?0:t.patternScale,t.boundaryPaths.forEach(r=>{if(r.boundaryPathTypeFlag&2){const a=r,h=new at;h.closed=a.isClosed,a.vertices.forEach((c,d)=>{h.addVertexAt(d,{x:c.x,y:c.y,bulge:c.bulge})}),e.add(h)}else{const a=r,h=[];a.edges.forEach(d=>{if(d.type==1){const u=d;h.push(new Wt(u.start,u.end))}else if(d.type==2){const u=d;h.push(new Te(u.center,u.radius,k.degToRad(u.startAngle||0),k.degToRad(u.endAngle||0),!u.isCCW))}else if(d.type==3){const u=d;new $().subVectors(u.end,u.center);const g=Math.sqrt(Math.pow(u.end.x,2)+Math.pow(u.end.y,2)),m=g*u.lengthOfMinorAxis;let y=k.degToRad(u.startAngle||0),b=k.degToRad(u.endAngle||0);const x=Math.atan2(u.end.y,u.end.x);u.isCCW||(y=Math.PI*2-y,b=Math.PI*2-b),h.push(new Hs({...u.center,z:0},g,m,y,b,!u.isCCW,x))}else if(d.type==4){const u=d;if(u.numberOfControlPoints>0&&u.numberOfKnots>0){const p=u.controlPoints.map(y=>({x:y.x,y:y.y,z:0}));let g=!0;const m=u.controlPoints.map(y=>(y.weight==null&&(g=!1),y.weight||1));h.push(new Ht(p,u.knots,g?m:void 0))}else if(u.numberOfFitData>0){const p=u.fitDatum.map(g=>({x:g.x,y:g.y,z:0}));h.push(new Ht(p,"Uniform"))}}});const c=Gs.buildFromEdges(h);c.length==0&&h.length>0?e.add(new Gs(h)):c.forEach(d=>e.add(d))}}),t.gradientFlag){const r=t;if(e.hatchObjectType=br.GradientObject,e.gradientName=r.gradientName,e.gradientAngle=r.gradientRotation??0,e.gradientShift=r.gradientDefinition??0,e.gradientOneColorMode=r.gradientColorFlag==1,e.shadeTintValue=r.colorTint??0,r.gradientColors){const o=r.gradientColors.length;o>1?(e.gradientStartColor=r.gradientColors[0].rgb,e.gradientEndColor=r.gradientColors[1].rgb):o>0&&(e.gradientStartColor=r.gradientColors[0].rgb)}}return e}convertTable(t){const e=new Ui(t.name,t.rowCount,t.columnCount);return e.tableDataVersion=t.version,e.tableStyleId=t.tableStyleId,e.owningBlockRecordId=t.blockRecordHandle,t.directionVector&&(e.horizontalDirection=new _(t.directionVector)),e.attachmentPoint=t.attachmentPoint,e.position.copy(t.startPoint),e.tableValueFlag=t.tableValue,e.tableOverrideFlag=t.overrideFlag,e.borderColorOverrideFlag=t.borderColorOverrideFlag,e.borderLineweightOverrideFlag=t.borderLineWeightOverrideFlag,e.borderVisibilityOverrideFlag=t.borderVisibilityOverrideFlag,t.columnWidthArr.forEach((s,n)=>e.setColumnWidth(n,s)),t.rowHeightArr.forEach((s,n)=>e.setRowHeight(n,s)),t.cells.forEach((s,n)=>{e.setCell(n,s)}),e}convertText(t){const e=new cs;return e.textString=t.text,e.styleName=t.styleName,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=k.degToRad(t.rotation||0),e.oblique=t.obliqueAngle??0,e.thickness=t.thickness,e.horizontalMode=t.halign,e.verticalMode=t.valign,e.widthFactor=t.xScale??1,e}convertMText(t){const e=new Xs;return e.contents=t.text,t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=k.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new _(t.direction)),e.drawingDirection=t.drawingDirection,e}convertLeader(t){var s;const e=new Wi;return(s=t.vertices)==null||s.forEach(n=>{e.appendVertex(n)}),e.hasArrowHead=t.isArrowheadEnabled,e.hasHookLine=t.isHooklineExists,e.isHookLineSameDirection=t.isHooklineSameDirection,e.isSplined=t.isSpline,e.dimensionStyle=t.styleName??"",e.annoType=t.leaderCreationFlag,e.textHeight=t.textHeight??0,e.textWidth=t.textWidth??0,e.byBlockColor=t.byBlockColor,e.associatedAnnotation=t.associatedAnnotation??"",t.normal&&(e.normal=t.normal),t.horizontalDirection&&(e.horizontalDirection=t.horizontalDirection),t.offsetFromBlock&&(e.offsetFromBlock=t.offsetFromBlock),t.offsetFromAnnotation&&(e.offsetFromAnnotation=t.offsetFromAnnotation),e}convertMLine(t){const e=new Hi;return e.styleName=t.name||"STANDARD",e.styleObjectHandle=t.styleObjectHandle,e.scale=t.scale,e.justification=t.justification,e.flags=t.flags,e.styleCount=t.styleCount,e.startPosition=t.startPosition,e.normal=t.extrusionDirection??_.Z_AXIS,e.segments=(t.segments??[]).map(s=>{var n;return{position:s.position,direction:s.direction,miterDirection:s.miterDirection,elements:((n=s.elements)==null?void 0:n.map(r=>({parameterCount:r.parameterCount,parameters:r.parameters??[],fillCount:r.fillCount,fillParameters:r.fillParameters??[]})))??[]}}),e}convertMLeader(t){var S,L;const e=new Gi,s=t;e.version=t.version,e.leaderStyleId=t.leaderStyleId,t.leaderStyleId&&(e.mleaderStyleId=t.leaderStyleId),e.propertyOverrideFlag=t.propertyOverrideFlag,e.leaderLineType=t.leaderLineType??hs.StraightLeader,e.leaderLineColor=t.leaderLineColor,e.leaderLineTypeId=t.leaderLineTypeId,e.leaderLineWeight=t.leaderLineWeight,e.landingEnabled=t.landingEnabled,e.doglegEnabled=t.doglegEnabled??!1,e.doglegLength=t.doglegLength??0,e.arrowheadId=t.arrowheadId,e.arrowheadSize=t.arrowheadSize,e.textStyleId=t.textStyleId,e.textLeftAttachmentType=t.textLeftAttachmentType,e.textRightAttachmentType=t.textRightAttachmentType,e.textAngleType=t.textAngleType,e.textAlignmentType=t.textAlignmentType,e.textColor=t.textColor,e.textFrameEnabled=t.textFrameEnabled,e.landingGap=t.landingGap,e.textAttachment=t.textAttachment,e.textFlowDirection=t.textFlowDirection,e.blockContentId=t.blockContentId,e.blockContentColor=t.blockContentColor,e.blockContentRotation=t.blockContentRotation,e.blockContentConnectionType=t.blockContentConnectionType,e.annotativeScaleEnabled=t.annotativeScaleEnabled,e.arrowheadOverrides=t.arrowheadOverrides?t.arrowheadOverrides.map(A=>({...A})):[],e.blockAttributes=t.blockAttributes?t.blockAttributes.map(A=>({...A})):[],e.textDirectionNegative=t.textDirectionNegative,e.textAlignInIPE=t.textAlignInIPE,e.bottomTextAttachmentDirection=t.bottomTextAttachmentDirection,e.topTextAttachmentDirection=t.topTextAttachmentDirection,e.contentScale=t.contentScale,e.textLineSpacingStyle=t.textLineSpacingStyle,e.textBackgroundColor=t.textBackgroundColor,e.textBackgroundScaleFactor=t.textBackgroundScaleFactor,e.textBackgroundTransparency=t.textBackgroundTransparency,e.textBackgroundColorOn=t.textBackgroundColorOn,e.textFillOn=t.textFillOn,e.textColumnType=t.textColumnType,e.textUseAutoHeight=t.textUseAutoHeight,e.textColumnWidth=t.textColumnWidth,e.textColumnGutterWidth=t.textColumnGutterWidth,e.textColumnFlowReversed=t.textColumnFlowReversed,e.textColumnHeight=t.textColumnHeight,e.textUseWordBreak=t.textUseWordBreak,e.hasMText=t.hasMText,e.hasBlock=t.hasBlock,e.planeNormalReversed=t.planeNormalReversed,t.blockContentScale&&(e.blockContentScale=new _(t.blockContentScale)),t.contentBasePosition&&(e.contentBasePosition=new w().copy(t.contentBasePosition)),t.textAnchor&&(e.textAnchor=new w().copy(t.textAnchor)),t.planeOrigin&&(e.planeOrigin=new w().copy(t.planeOrigin)),t.planeXAxisDirection&&(e.planeXAxisDirection=new _(t.planeXAxisDirection)),t.planeYAxisDirection&&(e.planeYAxisDirection=new _(t.planeYAxisDirection));const n=s.textContent,r=n&&typeof n=="object"?n:void 0,o=typeof n=="string"&&n.length>0||this.readString(r??{},["text","contents"])!=null||this.readString(s,["text","contents","mtext"])!=null,a=t.contentType??(o?ue.MTextContent:t.blockContent?ue.BlockContent:ue.NoneContent);e.contentType=a;const h=this.readPoint(s,["normal","extrusionDirection"]);h&&(e.normal=h);const c=this.readString(r??{},["styleName","textStyleName","textStyle"])??this.readString(s,["textStyleName","textStyle","styleName","textStyleId"]);c&&(e.textStyleName=c);const d=this.readPositiveNumber(r??{},["textHeight","height"])??this.readPositiveNumber(s,["textHeight","mtextHeight","textContentHeight"])??this.readPositiveNumber(s,["arrowheadSize","contentScale"]);d!=null&&(e.textHeight=d);const u=this.readPositiveNumber(r??{},["textWidth","width"])??this.readPositiveNumber(s,["textWidth","mtextWidth","textContentWidth"]);u!=null&&(e.textWidth=u),e.textLineSpacingFactor=this.readNumber(r??{},["lineSpacingFactor","textLineSpacingFactor"])??this.readNumber(s,["textLineSpacingFactor"])??e.textLineSpacingFactor;const p=this.readNumber(r??{},["textRotation","rotation"])??this.readNumber(s,["textRotation","mtextRotation","textContentRotation"]);p!=null&&(e.textRotation=k.degToRad(p));const g=this.readPoint(s,["textDirection","mtextDirection","textDirectionVector"]);g&&(e.textDirection=g);const m=this.readNumber(s,["textAttachmentPoint","attachmentPoint"]);m!=null&&(e.textAttachmentPoint=m);const y=t.textAttachmentDirection;y!=null&&(e.textAttachmentDirection=y);const b=this.readNumber(s,["textDrawingDirection","drawingDirection"]);b!=null&&(e.textDrawingDirection=b);const x=typeof n=="string"?n:this.readString(r??{},["text","contents"])??this.readString(s,["text","contents","mtext"]),I=this.readPoint(r??{},["anchorPoint","textAnchor","textLocation","textPosition","textAnchorPoint"])??this.readPoint(s,["textAnchor","textLocation","textPosition","textAnchorPoint","contentBasePosition"]);if(x!=null&&I&&(e.mtextContent={text:x,anchorPoint:I}),t.blockContent){const A=t.blockContent;e.blockContent={blockContentId:t.blockContent.blockContentId,normal:this.readPoint(A,["normal"]),position:t.blockContent.position,scale:this.readPoint(A,["scale"]),rotation:this.readNumber(A,["rotation"]),color:this.readNumber(A,["color"]),transformationMatrix:Array.isArray(t.blockContent.transformationMatrix)?t.blockContent.transformationMatrix:[]}}else t.blockContentId&&(e.blockContent={blockContentId:t.blockContentId,scale:t.blockContentScale,rotation:t.blockContentRotation,color:t.blockContentColor,transformationMatrix:[]});return(S=this.readMLeaderLeaders(s))==null||S.forEach(A=>{e.addLeader({lastLeaderLinePoint:A.lastLeaderLinePoint,lastLeaderLinePointSet:A.lastLeaderLinePointSet,doglegVector:A.doglegVector,doglegVectorSet:A.doglegVectorSet,doglegLength:A.doglegLength??t.doglegLength,breaks:A.breaks,leaderBranchIndex:A.leaderBranchIndex,leaderLines:A.leaderLines})}),e.numberOfLeaders===0&&((L=this.readLeaderLineArray(s))==null||L.forEach(A=>{e.addLeader({doglegLength:t.doglegLength}),e.addLeaderLine(e.numberOfLeaders-1,A)})),e.numberOfLeaders===0&&t.contentBasePosition&&e.addLeader({lastLeaderLinePoint:t.contentBasePosition,lastLeaderLinePointSet:!0,doglegLength:t.doglegLength}),e}convertDimension(t){if(t.subclassMarker=="AcDbAlignedDimension"){const e=t,s=new Zs(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return e.insertionPoint&&(s.dimBlockPosition={...e.insertionPoint,z:0}),s.rotation=k.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbRotatedDimension"){const e=t,s=new an(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return e.insertionPoint&&(s.dimBlockPosition={...e.insertionPoint,z:0}),s.rotation=k.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,s=new sn(e.centerPoint,e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbOrdinateDimension"){const e=t,s=new rn(e.subDefinitionPoint1,e.subDefinitionPoint2);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbRadialDimension"){const e=t,s=new on(e.definitionPoint,e.subDefinitionPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,s=new nn(e.definitionPoint,e.subDefinitionPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,s),s}return null}processImage(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.imageSize.copy(t.imageSize),e.isShownClipped=(t.flags|4)>0,e.isImageShown=(t.flags|3)>0,e.isImageTransparent=(t.flags|8)>0,e.imageDefId=t.imageDefHandle,e.isClipped=t.isClipped,t.clippingBoundaryPath.forEach(s=>{e.clipBoundary.push(new v(s))}),e.width=Math.sqrt(t.uPixel.x**2+t.uPixel.y**2+t.uPixel.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vPixel.x**2+t.vPixel.y**2+t.vPixel.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uPixel.y,t.uPixel.x)}convertImage(t){const e=new qs;return this.processImage(t,e),e.clipBoundaryType=t.clippingBoundaryType,e}processWipeout(t,e){e.position.copy(t.position),e.brightness=t.brightness,e.contrast=t.contrast,e.fade=t.fade,e.imageSize.copy(t.imageSize),e.isShownClipped=(t.displayFlag|4)>0,e.isImageShown=(t.displayFlag|3)>0,e.isImageTransparent=(t.displayFlag|8)>0,e.imageDefId=t.imageDefHardId,e.isClipped=t.isClipping,t.boundary.forEach(s=>{e.clipBoundary.push(new v(s))}),e.clipBoundaryType=t.boundaryType,e.width=Math.sqrt(t.uDirection.x**2+t.uDirection.y**2+t.uDirection.z**2)*t.imageSize.x,e.height=Math.sqrt(t.vDirection.x**2+t.vDirection.y**2+t.vDirection.z**2)*t.imageSize.y,e.rotation=Math.atan2(t.uDirection.y,t.uDirection.x)}convertWipeout(t){const e=new Ki;return this.processWipeout(t,e),e}convertViewport(t){const e=new Zi;return e.number=t.viewportId,e.centerPoint.copy(t.viewportCenter),e.height=t.height,e.width=t.width,e.viewCenter.copy(t.displayCenter),e.viewHeight=t.viewHeight,e}convertRay(t){const e=new qi;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertXline(t){const e=new Qi;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertBlockReference(t){const e=new Je(t.name);return t.insertionPoint&&e.position.copy(t.insertionPoint),e.scaleFactors.x=t.xScale||1,e.scaleFactors.y=t.yScale||1,e.scaleFactors.z=t.zScale||1,e.rotation=t.rotation!=null?k.degToRad(t.rotation):0,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1}),e}processDimensionCommonAttrs(t,e){e.dimBlockId=t.name,e.textPosition.copy(t.textPoint),e.textRotation=t.textRotation||0,t.textLineSpacingFactor&&(e.textLineSpacingFactor=t.textLineSpacingFactor),t.textLineSpacingStyle&&(e.textLineSpacingStyle=t.textLineSpacingStyle),e.dimensionStyleName=t.styleName,e.dimensionText=t.text||"",e.measurement=t.measurement,e.normal.copy(t.extrusionDirection??{x:0,y:0,z:1})}processCommonAttrs(t,e){e.layer=t.layer||"0",t.handle&&(e.objectId=t.handle.toString()),e.ownerId=t.ownerBlockRecordSoftId||"",t.lineType!=null&&(e.lineType=t.lineType),t.lineweight!=null&&(e.lineWeight=t.lineweight),t.lineTypeScale!=null&&(e.linetypeScale=t.lineTypeScale),t.color!=null&&e.color.setRGBValue(t.color),t.colorIndex!=null&&(e.color.colorIndex=t.colorIndex),t.colorName&&(e.color.colorName=t.colorName),t.isVisible!=null&&(e.visibility=!t.isVisible),t.transparency!=null&&(e.transparency=gn.deserialize(t.transparency))}readNumber(t,e){for(const s of e){const n=t[s];if(typeof n=="number"&&Number.isFinite(n))return n}}readPositiveNumber(t,e){const s=this.readNumber(t,e);return s!=null&&s>0?s:void 0}readString(t,e){for(const s of e){const n=t[s];if(typeof n=="string")return n}}readBoolean(t,e){for(const s of e){const n=t[s];if(typeof n=="boolean")return n;if(typeof n=="number")return n!==0}}readPoint(t,e){for(const s of e){const n=t[s];if(this.isPointLike(n))return n;if(Array.isArray(n)&&typeof n[0]=="number"&&typeof n[1]=="number")return{x:n[0],y:n[1],z:n[2]??0}}}readLeaderLineArray(t){const e=t.leaderLines;if(Array.isArray(e))return e.map(n=>{if(!n||typeof n!="object")return;const r=n.vertices;return Array.isArray(r)?r.filter(o=>this.isPointLike(o)):void 0}).filter(n=>!!n&&n.length>0);const s=t.vertices;if(Array.isArray(s)){const n=s.filter(r=>this.isPointLike(r));return n.length>0?[n]:void 0}}readMLeaderLeaders(t){const e=t.leaderSections;if(!Array.isArray(e))return;const s=[];return e.forEach(n=>{if(!n||typeof n!="object")return;const r=n,o=r.leaderLines,a=Array.isArray(o)?o.reduce((m,y)=>{const b=this.readMLeaderLine(y);return b&&m.push(b),m},[]):void 0,h={},c=this.readPoint(r,["lastLeaderLinePoint"]),d=this.readPoint(r,["doglegVector"]),u=this.readNumber(r,["doglegLength"]),p=this.readMLeaderBreaks(r.breaks),g=this.readNumber(r,["leaderBranchIndex"]);c&&(h.lastLeaderLinePoint=c),r.lastLeaderLinePointSet!=null&&(h.lastLeaderLinePointSet=this.readBoolean(r,["lastLeaderLinePointSet"])),d&&(h.doglegVector=d),r.doglegVectorSet!=null&&(h.doglegVectorSet=this.readBoolean(r,["doglegVectorSet"])),u!=null&&(h.doglegLength=u),p&&(h.breaks=p),g!=null&&(h.leaderBranchIndex=g),a&&(h.leaderLines=a),s.push(h)}),s}readMLeaderLine(t){if(!t||typeof t!="object")return;const e=t,s=e.vertices,n=Array.isArray(s)?s.filter(h=>this.isPointLike(h)):[],r=this.readMLeaderBreaks(e.breaks),o=Array.isArray(e.breakPointIndexes)?e.breakPointIndexes.filter(h=>typeof h=="number"):void 0,a=this.readNumber(e,["leaderLineIndex"]);return n.length>0||r&&r.length>0?{vertices:n,breakPointIndexes:o,leaderLineIndex:a,breaks:r}:void 0}readMLeaderBreaks(t){if(!Array.isArray(t))return;const e=t.map(s=>{if(!s||typeof s!="object")return;const n=s,r=this.readPoint(n,["start"]),o=this.readPoint(n,["end"]),a=this.readNumber(n,["index"]);if(!r||!o)return;const h={start:r,end:o};return a!=null&&(h.index=a),h}).filter(s=>!!s);return e.length>0?e:void 0}isPointLike(t){return!!t&&typeof t=="object"&&typeof t.x=="number"&&typeof t.y=="number"}}class fg{convertLayout(t,e){var r,o;const s=new ii;s.layoutName=t.layoutName,s.tabOrder=t.tabOrder,s.plotSettingsName=t.pageSetupName,s.plotCfgName=t.configName,s.canonicalMediaName=t.paperSize,s.plotViewName=t.plotViewName,s.currentStyleSheet=t.currentStyleSheet,s.plotPaperMargins={left:t.marginLeft,right:t.marginRight,top:t.marginTop,bottom:t.marginBottom},s.plotPaperSize.copy({x:t.paperWidth,y:t.paperHeight}),s.plotOrigin.copy({x:t.plotOriginX,y:t.plotOriginY}),s.plotWindowArea.min.copy({x:t.windowAreaXMin,y:t.windowAreaYMin}),s.plotWindowArea.max.copy({x:t.windowAreaXMax,y:t.windowAreaYMax}),s.customPrintScale={numerator:t.printScaleNumerator,denominator:t.printScaleDenominator},s.plotPaperUnits=t.plotPaperUnit,s.plotRotation=t.plotRotation,s.plotType=t.plotType,s.stdScaleType=t.standardScaleType,s.shadePlot=(()=>{switch(t.shadePlotMode){case 1:return os.kWireframe;case 2:return os.kHidden;case 3:return os.kRendered;default:return os.kAsDisplayed}})(),s.shadePlotResLevel=(()=>{switch(t.shadePlotResolution){case 1:return we.kPreview;case 2:return we.kNormal;case 3:return we.kPresentation;case 4:return we.kMaximum;case 5:return we.kCustom;default:return we.kDraft}})(),t.shadePlotCustomDPI!=null&&(s.shadePlotCustomDPI=t.shadePlotCustomDPI),t.shadePlotId&&(s.shadePlotId=t.shadePlotId);const n=t.layoutFlag??0;if(s.plotViewportBorders=(n&1)!==0,s.showPlotStyles=(n&2)!==0,s.plotCentered=(n&4)!==0,s.plotHidden=(n&8)!==0,s.useStandardScale=(n&16)!==0,s.plotPlotStyles=(n&32)!==0,s.scaleLineweights=(n&64)!==0,s.printLineweights=(n&128)!==0,s.drawViewportsFirst=(n&512)!==0,s.modelType=(n&1024)!==0,t.viewportId&&s.viewportArray.push(t.viewportId),t.layoutName==="Model"){const a=J.MODEL_SPACE_NAME.toUpperCase();(r=e.tables.BLOCK_RECORD)==null||r.entries.some(h=>h.name.toUpperCase()===a?(s.blockTableRecordId=h.handle,!0):!1)}else(o=e.tables.BLOCK_RECORD)==null||o.entries.some(a=>a.layoutObjects===t.handle?(s.blockTableRecordId=a.handle,!0):!1),s.blockTableRecordId||(s.blockTableRecordId=t.paperSpaceTableId);return t.minLimit&&s.limits.min.copy(t.minLimit),t.maxLimit&&s.limits.max.copy(t.maxLimit),t.minExtent&&s.extents.min.copy(t.minExtent),t.maxExtent&&s.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,s),s}convertImageDef(t){const e=new gl;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}convertMLeaderStyle(t){const e=new fr;return e.unknown1=t.unknown1,t.contentType!=null&&(e.contentType=t.contentType),t.drawMLeaderOrderType!=null&&(e.drawMLeaderOrderType=t.drawMLeaderOrderType),t.drawLeaderOrderType!=null&&(e.drawLeaderOrderType=t.drawLeaderOrderType),t.maxLeaderSegmentPoints!=null&&(e.maxLeaderSegmentPoints=t.maxLeaderSegmentPoints),t.firstSegmentAngleConstraint!=null&&(e.firstSegmentAngleConstraint=t.firstSegmentAngleConstraint),t.secondSegmentAngleConstraint!=null&&(e.secondSegmentAngleConstraint=t.secondSegmentAngleConstraint),t.leaderLineType!=null&&(e.leaderLineType=t.leaderLineType),t.leaderLineColor!=null&&(e.leaderLineColor=zs(t.leaderLineColor)),e.leaderLineTypeId=t.leaderLineTypeId,t.leaderLineWeight!=null&&(e.leaderLineWeight=t.leaderLineWeight),t.landingEnabled!=null&&(e.landingEnabled=t.landingEnabled),t.landingGap!=null&&(e.landingGap=t.landingGap),t.doglegEnabled!=null&&(e.doglegEnabled=t.doglegEnabled),t.doglegLength!=null&&(e.doglegLength=t.doglegLength),t.description!=null&&(e.description=t.description),e.arrowheadId=t.arrowheadId,t.arrowheadSize!=null&&(e.arrowheadSize=t.arrowheadSize),t.defaultMTextContents!=null&&(e.defaultMTextContents=t.defaultMTextContents),e.textStyleId=t.textStyleId,t.textLeftAttachmentType!=null&&(e.textLeftAttachmentType=t.textLeftAttachmentType),t.textAngleType!=null&&(e.textAngleType=t.textAngleType),t.textAlignmentType!=null&&(e.textAlignmentType=t.textAlignmentType),t.textRightAttachmentType!=null&&(e.textRightAttachmentType=t.textRightAttachmentType),t.textColor!=null&&(e.textColor=zs(t.textColor)),t.textHeight!=null&&(e.textHeight=t.textHeight),t.textFrameEnabled!=null&&(e.textFrameEnabled=t.textFrameEnabled),t.textAlignAlwaysLeft!=null&&(e.textAlignAlwaysLeft=t.textAlignAlwaysLeft),t.alignSpace!=null&&(e.alignSpace=t.alignSpace),e.blockContentId=t.blockContentId,t.blockContentColor!=null&&(e.blockContentColor=zs(t.blockContentColor)),t.blockContentScale&&(e.blockContentScale={x:t.blockContentScale.x,y:t.blockContentScale.y,z:t.blockContentScale.z??1}),t.blockContentScaleEnabled!=null&&(e.blockContentScaleEnabled=t.blockContentScaleEnabled),t.blockContentRotation!=null&&(e.blockContentRotation=t.blockContentRotation),t.blockContentRotationEnabled!=null&&(e.blockContentRotationEnabled=t.blockContentRotationEnabled),t.blockContentConnectionType!=null&&(e.blockContentConnectionType=t.blockContentConnectionType),t.scale!=null&&(e.scale=t.scale),t.overwritePropertyValue!=null&&(e.overwritePropertyValue=t.overwritePropertyValue),t.annotative!=null&&(e.annotative=t.annotative),t.breakGapSize!=null&&(e.breakGapSize=t.breakGapSize),t.textAttachmentDirection!=null&&(e.textAttachmentDirection=t.textAttachmentDirection),t.bottomTextAttachmentDirection!=null&&(e.bottomTextAttachmentDirection=t.bottomTextAttachmentDirection),t.topTextAttachmentDirection!=null&&(e.topTextAttachmentDirection=t.topTextAttachmentDirection),e.unknown2=t.unknown2,this.processCommonAttrs(t,e),e}convertMLineStyle(t){var n;const e=new Sr;if(t.styleName!=null&&(e.styleName=t.styleName),t.flags!=null&&(e.flags=t.flags),t.description!=null&&(e.description=t.description),t.fillColor!=null)e.fillColor=new j().setRGBValue(t.fillColor);else if(t.fillColorIndex!=null){const r=new j;r.colorIndex=t.fillColorIndex,e.fillColor=r}t.startAngle!=null&&(e.startAngle=t.startAngle),t.endAngle!=null&&(e.endAngle=t.endAngle);const s=Math.max(t.elementCount??0,((n=t.elements)==null?void 0:n.length)??0);return s>0&&(e.elements=Array.from({length:s},(r,o)=>{var a,h,c,d;return{offset:((h=(a=t.elements)==null?void 0:a[o])==null?void 0:h.offset)??0,color:(()=>{var p,g,m,y;const u=new j;return((g=(p=t.elements)==null?void 0:p[o])==null?void 0:g.color)!=null?u.setRGBValue(t.elements[o].color):u.colorIndex=((y=(m=t.elements)==null?void 0:m[o])==null?void 0:y.colorIndex)??256,u})(),lineType:((d=(c=t.elements)==null?void 0:c[o])==null?void 0:d.lineType)??"BYLAYER"}})),this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,t.ownerObjectId!=null&&(e.ownerId=t.ownerObjectId)}}class Xh{constructor(t){this.taskId=0,this.workers=new Map,this.pendingTasks=new Map,this.config={workerUrl:t.workerUrl,timeout:t.timeout??3e4,maxConcurrentWorkers:t.maxConcurrentWorkers??4}}async execute(t,e){const s=Date.now(),n=this.generateTaskId();try{return await this.executeInWorker(n,t,e||this.config.workerUrl)}catch(r){const o=Date.now()-s;return{success:!1,error:r instanceof Error?r.message:String(r),duration:o}}}async executeInWorker(t,e,s){const n=Date.now();return new Promise((r,o)=>{const a=this.getAvailableWorker(s),h=setTimeout(()=>{this.cleanupTask(t),this.releaseWorker(a),o(new Error(`Worker operation timed out after ${this.config.timeout}ms`))},this.config.timeout);this.pendingTasks.set(t,{resolve:u=>{clearTimeout(h),this.releaseWorker(a),r(u)},reject:u=>{clearTimeout(h),this.releaseWorker(a),o(u)},timeout:h});const c=u=>{const{id:p,success:g,data:m,error:y}=u.data;if(p!==t)return;this.cleanupTask(t);const b=Date.now()-n;r(g?{success:!0,data:m,duration:b}:{success:!1,error:y,duration:b})},d=u=>{this.cleanupTask(t),o(new Error(`Worker error: ${u.message}`))};a.addEventListener("message",c),a.addEventListener("error",d),a.postMessage({id:t,input:e})})}cleanupTask(t){const e=this.pendingTasks.get(t);e&&(clearTimeout(e.timeout),this.pendingTasks.delete(t))}generateTaskId(){return`task_${++this.taskId}_${Date.now()}`}detectWorkerSupport(){return typeof Worker<"u"}getAvailableWorker(t){for(const[s,n]of this.workers)if(!n.isBusy)return n.isBusy=!0,n.worker;if(this.workers.size<this.config.maxConcurrentWorkers){const s=new Worker(t,{type:"module"}),n=this.generateWorkerId(),r={worker:s,isBusy:!0,id:n,createdAt:new Date};return this.workers.set(n,r),s}const e=Array.from(this.workers.values()).sort((s,n)=>s.createdAt.getTime()-n.createdAt.getTime())[0];return e.isBusy=!0,e.worker}releaseWorker(t){for(const[e,s]of this.workers)if(s.worker===t){s.isBusy=!1;break}}generateWorkerId(){return`worker_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}getStats(){return{totalWorkers:this.workers.size,busyWorkers:Array.from(this.workers.values()).filter(t=>t.isBusy).length,pendingTasks:this.pendingTasks.size,config:this.config}}destroy(){for(const[t,e]of this.pendingTasks)clearTimeout(e.timeout),e.reject(new Error("Framework destroyed"));this.pendingTasks.clear();for(const[t,e]of this.workers)e.worker.terminate();this.workers.clear()}}class $h{constructor(t){this.framework=new Xh(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function qh(i){return new $h(i)}class Sg{constructor(){this.setupMessageHandler()}setupMessageHandler(){self.onmessage=async t=>{const{id:e,input:s}=t.data;try{const n=await this.executeTask(s);this.sendResponse(e,!0,n)}catch(n){this.sendResponse(e,!1,void 0,n instanceof Error?n.message:String(n))}}}sendResponse(t,e,s,n){const r={id:t,success:e,data:s,error:n};self.postMessage(r)}}class Zh extends Mr{constructor(t={}){super(t),t.parserWorkerUrl||(t.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(t,e){const s=this.config,n=this.getParserWorkerTimeout(t,e);if(s.useWorker&&s.parserWorkerUrl){const r=qh({workerUrl:s.parserWorkerUrl,timeout:n,maxConcurrentWorkers:1}),o=await r.execute(t);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 return{model:new bg().parse(t),data:{unknownEntityCount:0}}}getFonts(t){var r;const e=new Map,s=o=>{if(o){const a=o.lastIndexOf(".");return a>=0?o.substring(0,a).toLowerCase():o.toLowerCase()}};(r=t.tables.STYLE)==null||r.entries.forEach(o=>{const a=[];if(o.font){const h=s(o.font);h&&a.push(h)}if(o.bigFont){const h=s(o.bigFont);h&&a.push(h)}if(o.extendedFont){const h=s(o.extendedFont);h&&a.push(h)}e.set(o.name,a)});const n=new Set;return this.getFontsInBlock(t.entities,t.blocks,e,n),Array.from(n)}getFontsInBlock(t,e,s,n){const r=/\\f(.*?)\|/g;t.forEach(o=>{if(o.type=="MTEXT"){const a=o;[...a.text.matchAll(r)].forEach(d=>{n.add(d[1].toLowerCase())});const c=s.get(a.styleName);c==null||c.forEach(d=>n.add(d))}else if(o.type=="TEXT"){const a=o,h=s.get(a.styleName);h==null||h.forEach(c=>n.add(c))}else if(o.type=="MULTILEADER"||o.type=="MLEADER"){const a=o;[...(typeof a.textContent=="string"?a.textContent:"").matchAll(r)].forEach(u=>{n.add(u[1].toLowerCase())});const c=typeof a.textStyleName=="string"?a.textStyleName:typeof a.styleName=="string"?a.styleName:void 0,d=c?s.get(c):void 0;d==null||d.forEach(u=>n.add(u))}else if(o.type=="INSERT"){const h=e[o.name];h&&h.entities&&this.getFontsInBlock(h.entities,e,s,n)}})}async processEntities(t,e,s,n,r){const o=new Wo;let a=t.entities;const h=a.length,c=new sr(h,100-n.value,s);this.config.convertByEntityType&&(a=this.groupAndFlattenByType(a));const d=new Map;for(let p=0;p<h;p++){const g=a[p];if(g.type==="ATTRIB"){const m=o.convert(g);if(m&&m.ownerId&&m.ownerId!=="0"){let y=d.get(m==null?void 0:m.ownerId);y==null&&(y=[],d.set(m.ownerId,y)),y.push(m)}}}const u=e.tables.blockTable.modelSpace;await c.processChunk(async(p,g)=>{let m=[],y=p<g?a[p].type:"";for(let x=p;x<g;x++){const I=a[x];if(!(I.ownerBlockRecordSoftId&&I.ownerBlockRecordSoftId!==u.objectId)&&I.type!=="ATTRIB"){const S=o.convert(I);if(S){if(this.config.convertByEntityType&&I.type!==y&&(u.appendEntity(m),m=[],y=I.type),I.type==="INSERT"){const L=d.get(S.objectId);L&&L.length>0&&L.forEach(A=>{S.appendAttributes(A)})}m.push(S)}}}u.appendEntity(m);let b=n.value+g/h*(100-n.value);b>100&&(b=100),r&&await r(b,"ENTITY","IN-PROGRESS")})}async processEntitiesInBlock(t,e,s=!1){const n=new Wo,r=t.length,o=[],a=e.objectId,h=[];for(let c=0;c<r;c++){const d=t[c],u=n.convert(d);u&&(d.type==="ATTRIB"?h.push(u):(!s||d.ownerBlockRecordSoftId===a)&&o.push(u))}e.appendEntity(o),h.forEach(c=>{const d=e.getIdAt(c.ownerId);d&&d.appendAttributes(c)})}processBlocks(t,e){const s=t.blocks;for(const[n,r]of Object.entries(s)){let o=e.tables.blockTable.getAt(r.name);o||(o=new J,o.objectId=r.handle,o.name=n,o.origin.copy(r.position),e.tables.blockTable.add(o)),r.entities?this.processEntitiesInBlock(r.entities,o):o.isPaperSapce&&this.processEntitiesInBlock(t.entities,o,!0)}}processHeader(t,e){const s=t.header;s.$ACADVER&&(e.version=s.$ACADVER),e.cecolor.colorIndex=s.$CECOLOR||256,e.angBase=s.$ANGBASE||0,e.angDir=s.$ANGDIR||0,s.$AUNITS!=null&&(e.aunits=s.$AUNITS),e.celtype=s.$CELTYPE||dt,e.celtscale=s.$CELTSCALE||1;const n=this.normalizeHeaderStringValue(s.$CMLSTYLE)||this.normalizeHeaderStringValue(s.CMLSTYLE)||ce;e.cmlstyle=n;const r=s.$CMLSCALE??s.CMLSCALE;typeof r=="number"&&Number.isFinite(r)&&(e.cmlscale=r);const o=this.normalizeHeaderStringValue(s.$CMLEADERSTYLE)||this.normalizeHeaderStringValue(s.CMLEADERSTYLE)||de;e.cmleaderstyle=o,e.ltscale=s.$LTSCALE||1,s.$EXTMAX&&(e.extmax=s.$EXTMAX),s.$EXTMIN&&(e.extmin=s.$EXTMIN),s.$INSUNITS!=null&&(e.insunits=s.$INSUNITS),e.osmode=s.$OSMODE||0,e.pdmode=s.$PDMODE||0,e.pdsize=s.$PDSIZE||0,e.textstyle=s.$TEXTSTYLE||Z}processBlockTables(t,e){var n;const s=(n=t.tables.BLOCK_RECORD)==null?void 0:n.entries;s&&s.length>0&&(e.tables.blockTable.removeAll(),s.forEach(r=>{const o=new J;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),e.tables.blockTable.add(o)}))}processObjects(t,e){const s=t.objects.byName,n=new fg;if("LAYOUT"in s){const r=e.objects.layout;s.LAYOUT.forEach(o=>{const a=n.convertLayout(o,t);r.setAt(a.layoutName,a)})}if("IMAGEDEF"in s){const r=e.objects.imageDefinition;s.IMAGEDEF.forEach(o=>{const a=n.convertImageDef(o);r.setAt(a.objectId,a)})}if("MLEADERSTYLE"in s){const r=e.objects.mleaderStyle;s.MLEADERSTYLE.forEach(o=>{const a=n.convertMLeaderStyle(o);r.setAt(a.objectId,a)})}if("MLINESTYLE"in s){const r=e.objects.mlineStyle;s.MLINESTYLE.forEach(o=>{const a=n.convertMLineStyle(o);r.setAt(a.styleName||a.objectId,a)})}}processViewports(t,e){var n;const s=(n=t.tables)==null?void 0:n.VPORT;if(s){this.processCommonTableAttrs(s,e.tables.viewportTable);const r=s.entries;r&&r.length>0&&r.forEach(o=>{const a=new Lr;this.processCommonTableEntryAttrs(o,a),o.circleSides&&(a.circleSides=o.circleSides),a.standardFlag=o.standardFlag,a.center.copy(o.center),a.lowerLeftCorner.copy(o.lowerLeftCorner),a.upperRightCorner.copy(o.upperRightCorner),o.snapBasePoint&&a.snapBase.copy(o.snapBasePoint),o.snapRotationAngle&&(a.snapAngle=o.snapRotationAngle),o.snapSpacing&&a.snapIncrements.copy(o.snapSpacing),o.majorGridLines&&(a.gridMajor=o.majorGridLines),o.gridSpacing&&a.gridIncrements.copy(o.gridSpacing),o.backgroundObjectId&&(a.backgroundObjectId=o.backgroundObjectId),a.gsView.center.copy(o.center),a.gsView.viewDirectionFromTarget.copy(o.viewDirectionFromTarget),a.gsView.viewTarget.copy(o.viewTarget),o.lensLength&&(a.gsView.lensLength=o.lensLength),o.frontClippingPlane&&(a.gsView.frontClippingPlane=o.frontClippingPlane),o.backClippingPlane&&(a.gsView.backClippingPlane=o.backClippingPlane),o.viewHeight&&(a.gsView.viewHeight=o.viewHeight),o.viewTwistAngle&&(a.gsView.viewTwistAngle=o.viewTwistAngle),o.frozenLayers&&(a.gsView.frozenLayers=o.frozenLayers),o.styleSheet&&(a.gsView.styleSheet=o.styleSheet),o.renderMode&&(a.gsView.renderMode=o.renderMode),o.viewMode&&(a.gsView.viewMode=o.viewMode),o.ucsIconSetting&&(a.gsView.ucsIconSetting=o.ucsIconSetting),o.ucsOrigin&&a.gsView.ucsOrigin.copy(o.ucsOrigin),o.ucsXAxis&&a.gsView.ucsXAxis.copy(o.ucsXAxis),o.ucsYAxis&&a.gsView.ucsYAxis.copy(o.ucsYAxis),o.orthographicType&&(a.gsView.orthographicType=o.orthographicType),o.shadePlotSetting&&(a.gsView.shadePlotSetting=o.shadePlotSetting),o.shadePlotObjectId&&(a.gsView.shadePlotObjectId=o.shadePlotObjectId),o.visualStyleObjectId&&(a.gsView.visualStyleObjectId=o.visualStyleObjectId),o.isDefaultLightingOn&&(a.gsView.isDefaultLightingOn=o.isDefaultLightingOn),o.defaultLightingType&&(a.gsView.defaultLightingType=o.defaultLightingType),o.brightness&&(a.gsView.brightness=o.brightness),o.contrast&&(a.gsView.contrast=o.contrast),o.ambientColor&&(a.gsView.ambientColor=o.ambientColor),e.tables.viewportTable.add(a)})}}processLayers(t,e){var n;const s=(n=t.tables)==null?void 0:n.LAYER;if(s){this.processCommonTableAttrs(s,e.tables.layerTable);const r=s.entries;r&&r.length>0&&r.forEach(o=>{const a=new j;a.colorIndex=o.colorIndex;const h=new mn({name:o.name,standardFlags:o.standardFlag,linetype:o.lineType,lineWeight:o.lineweight,isOff:o.colorIndex<0,color:a,isPlottable:o.isPlotting});this.processCommonTableEntryAttrs(o,h),e.tables.layerTable.add(h)})}}processLineTypes(t,e){var n;const s=(n=t.tables)==null?void 0:n.LTYPE;if(s){this.processCommonTableAttrs(s,e.tables.linetypeTable);const r=s.entries;r&&r.length>0&&r.forEach(o=>{const a=new Ae(o);this.processCommonTableEntryAttrs(o,a),a.name=o.name,e.tables.linetypeTable.add(a)})}}processTextStyles(t,e){var n;const s=(n=t.tables)==null?void 0:n.STYLE;if(s){this.processCommonTableAttrs(s,e.tables.textStyleTable);const r=s.entries;r&&r.length>0&&r.forEach(o=>{const a=new yn(o);this.processCommonTableEntryAttrs(o,a),e.tables.textStyleTable.add(a)})}}processDimStyles(t,e){var n;const s=(n=t.tables)==null?void 0:n.DIMSTYLE;if(s){this.processCommonTableAttrs(s,e.tables.dimStyleTable);const r=s.entries;r&&r.length>0&&r.forEach(o=>{const a={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||Z,dimldrblk:o.DIMLDRBLK||"",dimblk:o.DIMBLK||"",dimblk1:o.DIMBLK1||"",dimblk2:o.DIMBLK2||"",dimlwd:o.DIMLWD,dimlwe:o.DIMLWE},h=new ts(a);this.processCommonTableEntryAttrs(o,h),e.tables.dimStyleTable.add(h)})}}processCommonTableAttrs(t,e){t.handle!=null&&(e.objectId=t.handle),t.ownerObjectId!=null&&(e.ownerId=t.ownerObjectId)}processCommonTableEntryAttrs(t,e){e.name="name"in t?t.name:"",t.handle!=null&&(e.objectId=t.handle),t.ownerObjectId!=null&&(e.ownerId=t.ownerObjectId)}groupAndFlattenByType(t){const e={},s=[];for(const n of t)e[n.type]||(e[n.type]=[],s.push(n.type)),e[n.type].push(n);return s.flatMap(n=>e[n])}normalizeHeaderStringValue(t){if(typeof t!="string")return;const e=t.trim();return e.length>0?e:void 0}}class Kh extends Mr{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}getFonts(){return[]}async processEntities(t,e,s,n,r){let o=t.tables.blockTable.modelSpace.newIterator().toArray();const a=o.length,h=new sr(a,100-n.value,s);this.config.convertByEntityType&&(o=this.groupAndFlattenByType(o));const c=e.tables.blockTable.modelSpace;await h.processChunk(async(d,u)=>{let p=[],g=d<u?o[d].type:"";for(let m=d;m<u;m++){const y=o[m];this.config.convertByEntityType&&y.type!==g&&(this.triggerEvents(c,p),p=[],g=y.type),p.push(y)}if(this.triggerEvents(c,p),r){let m=n.value+u/a*(100-n.value);m>100&&(m=100),await r(m,"ENTITY","IN-PROGRESS")}})}processBlocks(){const t=this._database.tables.blockTable.newIterator();for(const e of t){const s=e.newIterator().toArray();this.triggerEvents(e,s)}}processHeader(){}processBlockTables(){}processObjects(){const t=this._database.objects.layout.newIterator();for(const n of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:n,key:n.layoutName});const e=this._database.objects.imageDefinition.newIterator();for(const n of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:n,key:n.objectId});const s=this._database.objects.mleaderStyle.newIterator();for(const n of s)this._database.events.dictObjetSet.dispatch({database:this._database,object:n,key:n.objectId})}processViewports(){}processLayers(){this._database.tables.layerTable.newIterator().toArray().forEach(e=>{this._database.events.layerAppended.dispatch({database:this._database,layer:e})})}processLineTypes(){}processTextStyles(){}processDimStyles(){}groupAndFlattenByType(t){const e={},s=[];for(const n of t)e[n.type]||(e[n.type]=[],s.push(n.type)),e[n.type].push(n);return s.flatMap(n=>e[n])}triggerEvents(t,e){(t.isModelSapce||t.isPaperSapce)&&t.database.events.entityAppended.dispatch({database:t.database,entity:e})}}exports.ACAD_APPID=zn;exports.AC_DB_SYSTEM_VARIABLE_NAMES=$c;exports.AcCmColor=j;exports.AcCmColorMethod=P;exports.AcCmColorUtil=xe;exports.AcCmEntityColor=Jh;exports.AcCmErrors=wt;exports.AcCmEventDispatcher=tc;exports.AcCmEventManager=Q;exports.AcCmLoader=lc;exports.AcCmLoadingManager=Qo;exports.AcCmObject=$o;exports.AcCmPerformanceCollector=Jn;exports.AcCmTask=Zo;exports.AcCmTaskScheduler=Ko;exports.AcCmTransparency=gn;exports.AcCmTransparencyMethod=yt;exports.AcDb2dPolyline=Ni;exports.AcDb2dVertex=Yn;exports.AcDb2dVertexType=Ha;exports.AcDb3PointAngularDimension=sn;exports.AcDb3dPolyline=Bi;exports.AcDb3dVertex=Xn;exports.AcDb3dVertexType=Ga;exports.AcDbAbstractViewTableRecord=Er;exports.AcDbAlignedDimension=Zs;exports.AcDbAngleUnits=ir;exports.AcDbArc=Ri;exports.AcDbArcDimension=qn;exports.AcDbAttribute=zi;exports.AcDbAttributeDefinition=Fi;exports.AcDbAttributeFlags=tt;exports.AcDbAttributeMTextFlag=jt;exports.AcDbBaseWorker=Sg;exports.AcDbBatchProcessing=sr;exports.AcDbBlockReference=Je;exports.AcDbBlockScaling=dl;exports.AcDbBlockTable=xl;exports.AcDbBlockTableRecord=J;exports.AcDbCircle=Vi;exports.AcDbCodePage=nr;exports.AcDbCurve=ht;exports.AcDbDataGenerator=ml;exports.AcDbDatabase=qc;exports.AcDbDatabaseConverter=Mr;exports.AcDbDatabaseConverterManager=Vt;exports.AcDbDiametricDimension=nn;exports.AcDbDictionary=Ze;exports.AcDbDimArrowType=yl;exports.AcDbDimStyleTable=wl;exports.AcDbDimStyleTableRecord=ts;exports.AcDbDimTextHorizontal=bl;exports.AcDbDimTextVertical=fl;exports.AcDbDimVerticalJustification=Al;exports.AcDbDimZeroSuppression=Sl;exports.AcDbDimZeroSuppressionAngular=Il;exports.AcDbDimension=ge;exports.AcDbDuplicateRecordCloning=pl;exports.AcDbDwgVersion=kt;exports.AcDbDxfCode=Qn;exports.AcDbDxfConverter=Zh;exports.AcDbDxfFiler=Ho;exports.AcDbEllipse=Di;exports.AcDbEntity=lt;exports.AcDbFace=ji;exports.AcDbFileType=Os;exports.AcDbGradientPatternType=$a;exports.AcDbHatch=Us;exports.AcDbHatchObjectType=br;exports.AcDbHatchPatternType=Fs;exports.AcDbHatchStyle=Xa;exports.AcDbHostApplicationServices=Oi;exports.AcDbLayerTable=Pl;exports.AcDbLayerTableRecord=mn;exports.AcDbLayout=ii;exports.AcDbLayoutDictionary=cl;exports.AcDbLayoutManager=ul;exports.AcDbLeader=Wi;exports.AcDbLeaderAnnotationType=qa;exports.AcDbLine=Ys;exports.AcDbLineSpacingStyle=en;exports.AcDbLinetypeTable=Tl;exports.AcDbLinetypeTableRecord=Ae;exports.AcDbMLeader=Gi;exports.AcDbMLeaderContentType=ue;exports.AcDbMLeaderDirectionType=Ja;exports.AcDbMLeaderLineType=hs;exports.AcDbMLeaderStyle=fr;exports.AcDbMLeaderTextAttachmentDirection=Qa;exports.AcDbMLine=Hi;exports.AcDbMLineFlags=Ka;exports.AcDbMLineJustification=Za;exports.AcDbMText=Xs;exports.AcDbMlineStyle=Sr;exports.AcDbObject=Ft;exports.AcDbObjectIterator=ni;exports.AcDbOpenMode=ia;exports.AcDbOrdinateDimension=rn;exports.AcDbOsnapMode=z;exports.AcDbPlotPaperUnits=rl;exports.AcDbPlotRotation=ol;exports.AcDbPlotSettings=hl;exports.AcDbPlotShadePlotResLevel=we;exports.AcDbPlotShadePlotType=os;exports.AcDbPlotStdScaleType=ll;exports.AcDbPlotType=al;exports.AcDbPoint=$i;exports.AcDbPoly2dType=rs;exports.AcDbPoly3dType=Rs;exports.AcDbPolyFaceMesh=tn;exports.AcDbPolyFaceMeshFace=nl;exports.AcDbPolyFaceMeshVertex=il;exports.AcDbPolygonMesh=Ji;exports.AcDbPolygonMeshVertex=sl;exports.AcDbPolyline=Xi;exports.AcDbRadialDimension=on;exports.AcDbRasterImage=qs;exports.AcDbRasterImageClipBoundaryType=tl;exports.AcDbRasterImageDef=gl;exports.AcDbRasterImageImageDisplayOpt=el;exports.AcDbRay=qi;exports.AcDbRegAppTable=kl;exports.AcDbRegAppTableRecord=Zn;exports.AcDbRegenerator=Kh;exports.AcDbRenderingCache=es;exports.AcDbResultBuffer=er;exports.AcDbRotatedDimension=an;exports.AcDbSpline=$s;exports.AcDbSymbolTable=pe;exports.AcDbSymbolTableRecord=Me;exports.AcDbSysVarManager=Ks;exports.AcDbSystemVariables=B;exports.AcDbTable=Ui;exports.AcDbText=cs;exports.AcDbTextHorizontalMode=Ua;exports.AcDbTextStyleTable=El;exports.AcDbTextStyleTableRecord=yn;exports.AcDbTextVerticalMode=Ya;exports.AcDbTrace=Yi;exports.AcDbUnitsValue=Tr;exports.AcDbViewTable=Ll;exports.AcDbViewTableRecord=Qc;exports.AcDbViewport=Zi;exports.AcDbViewportTable=Ml;exports.AcDbViewportTableRecord=Lr;exports.AcDbWipeout=Ki;exports.AcDbWorkerApi=$h;exports.AcDbWorkerManager=Xh;exports.AcDbXline=Qi;exports.AcDbXrecord=Gc;exports.AcGeArea2d=Pe;exports.AcGeBox2d=_t;exports.AcGeBox3d=N;exports.AcGeCatmullRomCurve3d=pn;exports.AcGeCircArc2d=Te;exports.AcGeCircArc3d=Ie;exports.AcGeCurve2d=ds;exports.AcGeEllipseArc2d=Hs;exports.AcGeEllipseArc3d=ls;exports.AcGeEuler=yc;exports.AcGeGeometryUtil=Na;exports.AcGeLine2d=Wt;exports.AcGeLine3d=Ee;exports.AcGeLoop2d=Gs;exports.AcGeMathUtil=k;exports.AcGeMatrix2d=Js;exports.AcGeMatrix3d=D;exports.AcGeNurbsCurve=Rt;exports.AcGePlane=ei;exports.AcGePoint2d=v;exports.AcGePoint3d=w;exports.AcGePolyline2d=at;exports.AcGeQuaternion=ss;exports.AcGeShape2d=mr;exports.AcGeSpline3d=Ht;exports.AcGeTol=ti;exports.AcGeVector2d=$;exports.AcGeVector3d=_;exports.AcGiArrowType=yr;exports.AcGiDefaultLightingType=wr;exports.AcGiLineWeight=Qe;exports.AcGiMTextAttachmentPoint=ot;exports.AcGiMTextFlowDirection=Dt;exports.AcGiOrthographicType=xr;exports.AcGiRenderMode=_r;exports.AcGiViewport=ja;exports.AcTrStringUtil=ac;exports.ByBlock=fe;exports.ByLayer=dt;exports.DEBUG_MODE=rc;exports.DEFAULT_LINE_TYPE=Se;exports.DEFAULT_MLEADER_STYLE=de;exports.DEFAULT_MLINE_STYLE=ce;exports.DEFAULT_TEXT_STYLE=Z;exports.DEFAULT_TOL=dr;exports.DEG2RAD=rr;exports.DefaultLoadingManager=Jo;exports.FLOAT_TOL=qe;exports.MLIGHTCAD_APPID=Fn;exports.ORIGIN_POINT_2D=dc;exports.ORIGIN_POINT_3D=cr;exports.RAD2DEG=or;exports.RAW_COLOR_TYPE_ACI=Pr;exports.RAW_COLOR_TYPE_BY_BLOCK=ln;exports.RAW_COLOR_TYPE_BY_LAYER=Ir;exports.RAW_COLOR_TYPE_RGB=Ar;exports.RAW_COLOR_TYPE_WINDOW_BG=_l;exports.TAU=G;exports.TEMP_OBJECT_ID_PREFIX=Ii;exports.acdbDisableOsnapMode=Mc;exports.acdbEnableOsnapMode=Lc;exports.acdbHasOsnapMode=Ec;exports.acdbHostApplicationServices=tr;exports.acdbMaskToOsnapModes=Pc;exports.acdbOsnapModesToMask=Ac;exports.acdbToggleOsnapMode=Tc;exports.basisFunction=js;exports.calculateCurveLength=Fa;exports.ceilPowerOfTwo=wa;exports.clamp=he;exports.clone=Ms;exports.computeParameterValues=Ba;exports.createWorkerApi=qh;exports.damp=la;exports.decodeMLeaderStyleRawColor=zs;exports.deepClone=Nn;exports.defaults=Qs;exports.degToRad=ya;exports.dwgCodePageToEncoding=na;exports.encodeMLeaderStyleRawColor=Ti;exports.euclideanModulo=ar;exports.evaluateNurbsPoint=Bs;exports.floorPowerOfTwo=ba;exports.generateAveragedKnots=Ra;exports.generateChordKnots=xc;exports.generateSqrtChordKnots=wc;exports.generateUUID=ra;exports.generateUniformKnots=_c;exports.getOcsAngle=Gn;exports.getOcsReferenceVector=pr;exports.has=Go;exports.intPartLength=hr;exports.interpolateControlPoints=bc;exports.interpolateNurbsCurve=gr;exports.inverseLerp=aa;exports.isBetween=fa;exports.isBetweenAngle=Sa;exports.isEmpty=Uo;exports.isEqual=as;exports.isImperialUnits=Yc;exports.isMetricUnits=Uc;exports.isPointInPolygon=ur;exports.isPolygonIntersect=Oa;exports.isPowerOfTwo=xa;exports.lerp=lr;exports.log=Cs;exports.mapLinear=oa;exports.normalizeAngle=Ns;exports.pingpong=ha;exports.radToDeg=_a;exports.randFloat=ga;exports.randFloatSpread=pa;exports.randInt=ua;exports.relativeEps=Ia;exports.seededRandom=ma;exports.setAcDbHostApplicationServicesProvider=ea;exports.setAcDbLayoutManagerFactory=sa;exports.setLogLevel=oc;exports.smootherstep=da;exports.smoothstep=ca;exports.transformOcsPointToWcs=Hn;exports.transformWcsPointToOcs=Ws;
3
+ `}registerHandle(e){return this._handleMap.has(e)||(/^[0-9A-F]+$/i.test(e)?this._handleMap.set(e,e.toUpperCase()):(this._handleMap.set(e,this._nextHandle.toString(16).toUpperCase()),this._nextHandle+=1)),this._handleMap.get(e)}resolveHandle(e){if(e)return this.registerHandle(e)}writeGroup(e,t){if(t==null)return this;this._lines.push(String(Math.trunc(e)));const i=this.formatValue(t);return this._lines.push(i===""?"0":i),this}writeStart(e){return this.writeString(0,e)}writeSubclassMarker(e){return this.writeString(100,e)}writeString(e,t){return!t&&t!==""?this:this.writeGroup(e,t)}writeInt8(e,t){return t==null?this:this.writeGroup(e,Math.trunc(t))}writeInt16(e,t){return t==null?this:this.writeGroup(e,Math.trunc(t))}writeInt32(e,t){return t==null?this:this.writeGroup(e,Math.trunc(t))}writeInt64(e,t){return t==null?this:this.writeGroup(e,Math.trunc(t))}writeUInt16(e,t){return t==null?this:this.writeGroup(e,Math.max(0,t))}writeUInt32(e,t){return t==null?this:this.writeGroup(e,Math.max(0,t))}writeBoolean(e,t){return t==null?this:this.writeGroup(e,t?1:0)}writeBool(e,t){return this.writeBoolean(e,t)}writeDouble(e,t){return t==null||!Number.isFinite(t)?this:this.writeGroup(e,t)}writeAngle(e,t){return t==null||!Number.isFinite(t)?this:this.writeDouble(e,t*180/Math.PI)}writeHandle(e,t){const i=this.resolveHandle(t);return i?this.writeString(e,i):this}writeObjectId(e,t){return this.writeHandle(e,t)}writePoint2d(e,t){return t?(this.writeDouble(e,t.x),this.writeDouble(e+10,t.y),this):this}writePoint3d(e,t){return t?(this.writeDouble(e,t.x),this.writeDouble(e+10,t.y),this.writeDouble(e+20,t.z??0),this):this}writeVector3d(e,t){return t?(this.writeDouble(e,t.x),this.writeDouble(e+10,t.y),this.writeDouble(e+20,t.z??0),this):this}writeCmColor(e,t=62,i=420){if(!e)return this;const s=e.colorIndex;s!=null&&this.writeInt16(t,s);const r=e.RGB;return r!=null&&e.colorIndex==null&&this.writeInt32(i,r),this}writeTransparency(e,t=440){return e?this.writeInt32(t,e.serialize()):this}writeResultBuffer(e){if(!e)return this;for(const t of e)this.writeGroup(t.code,t.value);return this}startSection(e){return this.writeStart("SECTION"),this.writeString(2,e),this}endSection(){return this.writeStart("ENDSEC"),this}startTable(e){return this.writeStart("TABLE"),this.writeString(2,e),this}endTable(){return this.writeStart("ENDTAB"),this}formatValue(e){if(typeof e=="string")return this.sanitizeStringForDxfLine(e);if(typeof e=="boolean")return e?"1":"0";if(typeof e=="number"){if(!Number.isFinite(e))return"0";if(Number.isInteger(e))return String(e);const i=e.toFixed(this._precision).replace(/\.?0+$/,"");return i===""||i==="-"?"0":i}return String(e)}sanitizeStringForDxfLine(e){return e.replace(/\r\n|\r|\n/g," ").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,"")}}function tc(n,e){for(var t=0;t<e.length;t++){const i=e[t];if(typeof i!="string"&&!Array.isArray(i)){for(const s in i)if(s!=="default"&&!(s in n)){const r=Object.getOwnPropertyDescriptor(i,s);r&&Object.defineProperty(n,s,r.get?r:{enumerable:!0,get:()=>i[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var A=(n=>(n[n.ByColor=1]="ByColor",n[n.ByACI=2]="ByACI",n[n.ByLayer=3]="ByLayer",n[n.ByBlock=4]="ByBlock",n[n.None=0]="None",n))(A||{});const ba={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},ws=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215,0];let wt=class{static getColorByIndex(e){return ws[e]}static getIndexByColor(e){const t=ws.length-1;for(let i=1;i<t;++i)if(ws[i]===e)return i}static getColorByName(e){return ba[e.toLowerCase()]}static getNameByColor(e){for(const[t,i]of Object.entries(ba))if(i===e)return t}static getNameByIndex(e){const t=this.getColorByIndex(e);return this.getNameByColor(t)}},z=class ht{constructor(e=A.ByLayer,t){this._colorMethod=e,this._colorMethod==A.ByColor&&t==null?this._value=16777215:this._colorMethod==A.ByACI?t==null?this._value=8:t===0?this._colorMethod=A.ByBlock:t===256?this._colorMethod=A.ByLayer:this._value=Math.max(0,Math.min(t,256)):this._value=t}get colorMethod(){return this._colorMethod}set colorMethod(e){this._colorMethod=e}get red(){const e=this.RGB;return e!=null?e>>16&255:void 0}get green(){const e=this.RGB;return e!=null?e>>8&255:void 0}get blue(){const e=this.RGB;return e!=null?e&255:void 0}get RGB(){switch(this._colorMethod){case A.ByColor:case A.ByBlock:case A.ByLayer:return this._value;case A.ByACI:return this._value?wt.getColorByIndex(this._value):this._value;default:return}}setRGB(e,t,i){const s=Math.max(0,Math.min(255,Math.round(e))),r=Math.max(0,Math.min(255,Math.round(t))),a=Math.max(0,Math.min(255,Math.round(i)));return this._value=s<<16|r<<8|a,this._colorMethod=A.ByColor,this}setRGBValue(e){return e==null||!Number.isFinite(e)?this:(this._value=e&16777215,this._colorMethod=A.ByColor,this)}setRGBFromCss(e){if(!e)return this;const t=e.trim().toLowerCase();if(t.startsWith("#")){let r=0,a=0,o=0;if(t.length===7)r=parseInt(t.substr(1,2),16),a=parseInt(t.substr(3,2),16),o=parseInt(t.substr(5,2),16);else if(t.length===4)r=parseInt(t[1]+t[1],16),a=parseInt(t[2]+t[2],16),o=parseInt(t[3]+t[3],16);else return this;return this.setRGB(r,a,o)}const i=t.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(i){const r=parseInt(i[1],10),a=parseInt(i[2],10),o=parseInt(i[3],10);return this.setRGB(r,a,o)}const s=wt.getColorByName(e);return s!==void 0?this.setRGBValue(s):this}setScalar(e){return this.setRGB(e,e,e)}get hexColor(){const e=this.RGB;return e==null?void 0:"0x"+e.toString(16).padStart(6,"0").toUpperCase()}get cssColor(){const e=this.RGB;if(e!=null)return`rgb(${e>>16&255},${e>>8&255},${e&255})`}cssColorAlpha(e){const t=this.RGB;if(t!=null)return`rgba(${t>>16&255},${t>>8&255},${t&255},${e})`}get colorIndex(){return this._colorMethod===A.ByACI?this._value:this._colorMethod===A.ByLayer?256:this._colorMethod===A.ByBlock?0:void 0}set colorIndex(e){if(e==null)return;const t=Math.max(0,Math.min(256,Math.round(e)));t===0?(this._colorMethod=A.ByBlock,this._value=void 0):t===256?(this._colorMethod=A.ByLayer,this._value=void 0):(this._colorMethod=A.ByACI,this._value=t)}get isByColor(){return this._colorMethod===A.ByColor}get isByACI(){return this._colorMethod===A.ByACI}get isForeground(){return this._colorMethod===A.ByACI&&this._value===7}setForeground(){return this._colorMethod=A.ByACI,this._value=7,this}get isByLayer(){return this._colorMethod===A.ByLayer}setByLayer(e){return this._colorMethod=A.ByLayer,e==null?this._value=256:this._value=e,this}get isByBlock(){return this._colorMethod===A.ByBlock}setByBlock(e){return this._colorMethod=A.ByBlock,e==null?this._value=0:this._value=e,this}get colorName(){switch(this._colorMethod){case A.ByLayer:return"ByLayer";case A.ByBlock:return"ByBlock";case A.ByColor:return this._value?wt.getNameByColor(this._value):"";case A.ByACI:return this._value?wt.getNameByIndex(this._value):"";default:return}}set colorName(e){if(!e)return;const t=wt.getColorByName(e);t!==void 0&&(this._value=t,this._colorMethod=A.ByColor)}clone(){const e=new ht;return e._colorMethod=this._colorMethod,e._value=this._value,e}copy(e){return this._colorMethod=e._colorMethod,this._value=e._value,this}equals(e){return this._colorMethod===e._colorMethod&&this._value===e._value}toString(){switch(this._colorMethod){case A.ByLayer:return"ByLayer";case A.ByBlock:return"ByBlock";case A.ByACI:return this._value!==void 0?String(this._value):"";case A.ByColor:return this._value?`${this.red},${this.green},${this.blue}`:"";default:return""}}static fromString(e){if(!e)return;const t=e.trim();if(/^bylayer$/i.test(t))return new ht(A.ByLayer);if(/^byblock$/i.test(t))return new ht(A.ByBlock);const i=t.match(/^rgb\s*:\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})$/i);if(i){const r=Number(i[1]),a=Number(i[2]),o=Number(i[3]),h=new ht(A.ByColor);return h.setRGB(r,a,o),h}if(/^\d{1,3},\d{1,3},\d{1,3}$/.test(t)){const[r,a,o]=t.split(",").map(Number),h=new ht(A.ByColor);return h.setRGB(r,a,o),h}if(/^\d+$/.test(t)){const r=parseInt(t,10);return new ht(A.ByACI,r)}if(/^book\$/i.test(t)){const r=t.substring(t.indexOf("$")+1),a=wt.getColorByName(r);return a!=null?new ht(A.ByColor,a):void 0}const s=wt.getColorByName(t);if(s!=null)return new ht(A.ByColor,s)}};class ic{constructor(e=A.ByColor,t=0){this._colorMethod=e,this._value=t}get colorMethd(){return this._colorMethod}get red(){return this._value>>16&255}set red(e){this._colorMethod=A.ByColor,this._value=this._value&65535|(e&255)<<16}get green(){return this._value>>8&255}set green(e){this._colorMethod=A.ByColor,this._value=this._value&16711935|(e&255)<<8}get blue(){return this._value&255}set blue(e){this._colorMethod=A.ByColor,this._value=this._value&16776960|e&255}setRGB(e,t,i){this._colorMethod=A.ByColor,this._value=(e&255)<<16|(t&255)<<8|i&255}get colorIndex(){return this._value}set colorIndex(e){this._colorMethod=A.ByACI,this._value=e}get layerIndex(){return this._value}set layerIndex(e){this._colorMethod=A.ByLayer,this._value=e}isByColor(){return this._colorMethod===A.ByColor}isByLayer(){return this._colorMethod===A.ByLayer}isByBlock(){return this._colorMethod===A.ByBlock}isByACI(){return this._colorMethod===A.ByACI}isNone(){return this._colorMethod===A.None}get rawValue(){return this._value}set rawValue(e){this._value=e}}const fe={get ILLEGAL_PARAMETERS(){return new ReferenceError("Illegal Parameters")},get ZERO_DIVISION(){return new Error("Zero division")},get UNRESOLVED_BOUNDARY_CONFLICT(){return new Error("Unresolved boundary conflict in boolean operation")},get INFINITE_LOOP(){return new Error("Infinite loop")},get CANNOT_INVOKE_ABSTRACT_METHOD(){return new Error("Abstract method cannot be invoked")},get OPERATION_IS_NOT_SUPPORTED(){return new Error("Operation is not supported")},get NOT_IMPLEMENTED(){return new Error("Not implemented yet")}};let nc=class{constructor(){this._listeners={}}addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){if(this._listeners===void 0)return!1;const i=this._listeners;return i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){if(this._listeners===void 0)return;const i=this._listeners[e];if(i!==void 0){const s=i.indexOf(t);s!==-1&&i.splice(s,1)}}dispatchEvent(e){if(this._listeners===void 0)return;const t=this._listeners[e.type];if(t!==void 0){e.target=this;const i=t.slice(0);for(let s=0,r=i.length;s<r;s++)i[s].call(this,e)}}},J=class{constructor(){this.listeners=[]}addEventListener(e){this.listeners.push(e)}removeEventListener(e){this.listeners=this.listeners.filter(t=>t!==e)}replaceEventListener(e){this.removeEventListener(e),this.addEventListener(e)}dispatch(e,...t){for(const i of this.listeners)i.call(null,e,...t)}};function ki(n){return n===null||typeof n!="object"?n:Array.isArray(n)?[...n]:{...n}}function Ys(n){if(n===null||typeof n!="object")return n;if(n instanceof Date)return new Date(n.getTime());if(n instanceof RegExp)return new RegExp(n.source,n.flags);if(Array.isArray(n))return n.map(Ys);const e={};for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e[t]=Ys(n[t]));return e}function Qi(n,...e){for(const t of e)if(t)for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&n[i]===void 0&&(n[i]=t[i]);return n}function Ha(n,e){return n!=null&&Object.prototype.hasOwnProperty.call(n,e)}function Ua(n){return n==null?!0:Array.isArray(n)||typeof n=="string"?n.length===0:n instanceof Map||n instanceof Set?n.size===0:typeof n=="object"?Object.keys(n).length===0:!1}function li(n,e){if(n===e)return!0;if(n==null||e==null)return n===e;if(typeof n!=typeof e)return!1;if(typeof n!="object")return n===e;if(Array.isArray(n)!==Array.isArray(e))return!1;if(Array.isArray(n)){if(n.length!==e.length)return!1;for(let s=0;s<n.length;s++)if(!li(n[s],e[s]))return!1;return!0}const t=Object.keys(n),i=Object.keys(e);if(t.length!==i.length)return!1;for(const s of t)if(!Object.prototype.hasOwnProperty.call(e,s)||!li(n[s],e[s]))return!1;return!0}var sc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function rc(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var $a={exports:{}};(function(n){(function(e,t){n.exports?n.exports=t():e.log=t()})(sc,function(){var e=function(){},t="undefined",i=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),s=["trace","debug","info","warn","error"],r={},a=null;function o(y,x){var _=y[x];if(typeof _.bind=="function")return _.bind(y);try{return Function.prototype.bind.call(_,y)}catch{return function(){return Function.prototype.apply.apply(_,[y,arguments])}}}function h(){console.log&&(console.log.apply||Function.prototype.apply.apply(console.log,[console,arguments]))}function c(y){return y==="debug"&&(y="log"),typeof console===t?!1:y==="trace"&&i?h:console[y]!==void 0?o(console,y):console.log!==void 0?o(console,"log"):e}function d(){for(var y=this.getLevel(),x=0;x<s.length;x++){var _=s[x];this[_]=x<y?e:this.methodFactory(_,y,this.name)}if(this.log=this.debug,typeof console===t&&y<this.levels.SILENT)return"No console available for logging"}function u(y){return function(){typeof console!==t&&(d.call(this),this[y].apply(this,arguments))}}function p(y,x,_){return c(y)||u.apply(this,arguments)}function g(y,x){var _=this,S,L,T,I="loglevel";typeof y=="string"?I+=":"+y:typeof y=="symbol"&&(I=void 0);function j(R){var H=(s[R]||"silent").toUpperCase();if(!(typeof window===t||!I)){try{window.localStorage[I]=H;return}catch{}try{window.document.cookie=encodeURIComponent(I)+"="+H+";"}catch{}}}function M(){var R;if(!(typeof window===t||!I)){try{R=window.localStorage[I]}catch{}if(typeof R===t)try{var H=window.document.cookie,vt=encodeURIComponent(I),Ct=H.indexOf(vt+"=");Ct!==-1&&(R=/^([^;]+)/.exec(H.slice(Ct+vt.length+1))[1])}catch{}return _.levels[R]===void 0&&(R=void 0),R}}function U(){if(!(typeof window===t||!I)){try{window.localStorage.removeItem(I)}catch{}try{window.document.cookie=encodeURIComponent(I)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function X(R){var H=R;if(typeof H=="string"&&_.levels[H.toUpperCase()]!==void 0&&(H=_.levels[H.toUpperCase()]),typeof H=="number"&&H>=0&&H<=_.levels.SILENT)return H;throw new TypeError("log.setLevel() called with invalid level: "+R)}_.name=y,_.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},_.methodFactory=x||p,_.getLevel=function(){return T??L??S},_.setLevel=function(R,H){return T=X(R),H!==!1&&j(T),d.call(_)},_.setDefaultLevel=function(R){L=X(R),M()||_.setLevel(R,!1)},_.resetLevel=function(){T=null,U(),d.call(_)},_.enableAll=function(R){_.setLevel(_.levels.TRACE,R)},_.disableAll=function(R){_.setLevel(_.levels.SILENT,R)},_.rebuild=function(){if(a!==_&&(S=X(a.getLevel())),d.call(_),a===_)for(var R in r)r[R].rebuild()},S=X(a?a.getLevel():"WARN");var te=M();te!=null&&(T=X(te)),d.call(_)}a=new g,a.getLogger=function(y){if(typeof y!="symbol"&&typeof y!="string"||y==="")throw new TypeError("You must supply a name when creating a logger.");var x=r[y];return x||(x=r[y]=new g(y,a.methodFactory)),x};var m=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=m),a},a.getLoggers=function(){return r},a.default=a,a})})($a);var qa=$a.exports;const ac=rc(qa),oc=tc({__proto__:null,default:ac},[qa]),lc=!0,Oi=oc;Oi.setLevel("debug");const hc=n=>{try{Oi.setLevel(n)}catch(e){Oi.setLevel("error"),Oi.error(e)}};let Za=class Ka{constructor(e,t){this.events={attrChanged:new J,modelChanged:new J},this._changing=!1,this._previousAttributes={},this._pending=!1;const i=e||{};t&&Qi(i,t),this.attributes=i,this.changed={}}get(e){return this.attributes[e]}set(e,t,i){if(e==null)return this;let s;typeof e=="object"?(s=e,i=t):(s={},s[e]=t),i||(i={});const r=i.unset,a=i.silent,o=[],h=this._changing;this._changing=!0,h||(this._previousAttributes=ki(this.attributes),this.changed={});const c=this.attributes,d=this.changed,u=this._previousAttributes;for(const p in s)t=s[p],li(c[p],t)||o.push(p),li(u[p],t)?delete d[p]:d[p]=t,r?delete c[p]:c[p]=t;if(!a){o.length&&(this._pending=i);for(let p=0;p<o.length;p++)this.events.attrChanged.dispatch({object:this,attrName:o[p],attrValue:c[o[p]],options:i})}if(h)return this;if(!a)for(;this._pending;)i=this._pending,this._pending=!1,this.events.modelChanged.dispatch({object:this,options:i});return this._pending=!1,this._changing=!1,this}has(e){return this.get(e)!=null}hasChanged(e){return e==null?!Ua(this.changed):Ha(this.changed,e)}changedAttributes(e){if(!e)return this.hasChanged()?ki(this.changed):{};const t=this._changing?this._previousAttributes:this.attributes,i={};for(const s in e){const r=e[s];li(t[s],r)||(i[s]=r)}return i}previous(e){return e==null||!this._previousAttributes?null:this._previousAttributes[e]}previousAttributes(){return ki(this._previousAttributes)}clone(){const e=ki(this.attributes);return new Ka(e)}},tr=class vi{constructor(){this.entries=new Map}static getInstance(){return vi.instance||(vi.instance=new vi),vi.instance}collect(e){this.entries.set(e.name,e)}printAll(){for(const[e,t]of this.entries);}clear(){this.entries.clear()}getAll(){return Array.from(this.entries.values())}getEntry(e){return this.entries.get(e)}remove(e){return this.entries.delete(e)}};class cc{static formatBytes(e,t=2){if(e===0)return"0 B";const i=1024,s=Math.max(0,t),r=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(e)/Math.log(i)),o=e/Math.pow(i,a);return`${parseFloat(o.toFixed(s))} ${r[a]}`}}var ye=(n=>(n[n.ByLayer=0]="ByLayer",n[n.ByBlock=1]="ByBlock",n[n.ByAlpha=2]="ByAlpha",n[n.ErrorValue=3]="ErrorValue",n))(ye||{});let ps=class Fe{constructor(e){e!==void 0?(this._method=ye.ByAlpha,this._alpha=Fe.clampAlpha(e)):(this._method=ye.ByLayer,this._alpha=255)}get method(){return this._method}set method(e){this._method=e}get alpha(){return this._alpha}set alpha(e){this._alpha=Fe.clampAlpha(e),this._method=ye.ByAlpha}get percentage(){if(this._method===ye.ByAlpha)return Math.round((1-this._alpha/255)*100)}set percentage(e){const t=Math.max(0,Math.min(100,e)),i=Math.round(255*(1-t/100));this.alpha=i}static clampAlpha(e){return Math.max(0,Math.min(255,Math.floor(e)))}get isByAlpha(){return this._method===ye.ByAlpha}get isByBlock(){return this._method===ye.ByBlock}get isByLayer(){return this._method===ye.ByLayer}get isClear(){return this.isByAlpha&&this._alpha===0}get isSolid(){return this.isByAlpha&&this._alpha===255}get isInvalid(){return this._method===ye.ErrorValue}serialize(){return this._method<<24|this._alpha}clone(){const e=new Fe;return e._method=this._method,e._alpha=this._alpha,e}equals(e){return this._method===e._method&&this._alpha===e._alpha}toString(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this._alpha.toString()}static fromString(e){const t=e.trim();if(/^bylayer$/i.test(t)){const r=new Fe;return r._method=ye.ByLayer,r}if(/^byblock$/i.test(t)){const r=new Fe;return r._method=ye.ByBlock,r}const i=Number(t);if(Number.isInteger(i)&&i>=0&&i<=255)return new Fe(i);const s=new Fe;return s._method=ye.ErrorValue,s}static deserialize(e){const t=e>>>24&255,i=e&255,s=Object.values(ye)[t]??ye.ErrorValue,r=new Fe;return r._method=s,r._alpha=Fe.clampAlpha(i),r}};class Ja{constructor(e){this.name=e}run(e){throw new Error("run() must be implemented by subclass")}}class Qa{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>!1}scheduleTask(e){return new Promise((t,i)=>{const s=()=>{Promise.resolve(e()).then(t).catch(i)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(s):setTimeout(s,0)})}addTask(e){this.tasks.push(e)}setProgressCallback(e){this.onProgress=e}setCompleteCallback(e){this.onComplete=e}setErrorCallback(e){this.onError=e}async run(e){const t=this.tasks.length;let i=e;for(let s=0;s<t;s++){const r=this.tasks[s];try{i=await this.scheduleTask(async()=>{const a=await r.run(i);return this.onProgress((s+1)/t,r),a})}catch(a){if(this.onError({error:a,taskIndex:s,task:r}))return Promise.reject(a)}}this.onComplete(i)}}let eo=class{constructor(e,t,i){this.isLoading=!1,this.itemsLoaded=0,this.itemsTotal=0,this.urlModifier=void 0,this.handlers=[],this.onStart=void 0,this.onLoad=e,this.onProgress=t,this.onError=i}itemStart(e){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(e,this.itemsLoaded,this.itemsTotal),this.isLoading=!0}itemEnd(e){this.itemsLoaded++,this.onProgress!==void 0&&this.onProgress(e,this.itemsLoaded,this.itemsTotal),this.itemsLoaded===this.itemsTotal&&(this.isLoading=!1,this.onLoad!==void 0&&this.onLoad())}itemError(e){this.onError!==void 0&&this.onError(e)}resolveURL(e){return this.urlModifier?this.urlModifier(e):e}setURLModifier(e){return this.urlModifier=e,this}addHandler(e,t){return this.handlers.push(e,t),this}removeHandler(e){const t=this.handlers.indexOf(e);return t!==-1&&this.handlers.splice(t,2),this}getHandler(e){for(let t=0,i=this.handlers.length;t<i;t+=2){const s=this.handlers[t],r=this.handlers[t+1];if(s.global&&(s.lastIndex=0),s.test(e))return r}return null}};const to=new eo;class dc{constructor(e){this.manager=e!==void 0?e:to,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(e,t){return new Promise((i,s)=>{this.load(e,i,t,s)})}parse(e){}setCrossOrigin(e){return this.crossOrigin=e,this}setWithCredentials(e){return this.withCredentials=e,this}setPath(e){return this.path=e,this}setResourcePath(e){return this.resourcePath=e,this}setRequestHeader(e){return this.requestHeader=e,this}}var Jt=256,io=[],La=256,mn;for(;Jt--;)io[Jt]=(Jt+256).toString(16).substring(1);function uc(n){var e=0,t=11;if(!mn||Jt+t>La*2)for(mn="",Jt=0;e<La;e++)mn+=io[Math.random()*256|0];return mn.substring(Jt,Jt+++t)}const An="TEMP_";let Xs;function no(n){Xs=n}class Be{constructor(e,t){if(e=e||{},this._attrs=new Za(e,t),this._xDataMap=new Map,!this._attrs.get("objectId"))try{this._attrs.set("objectId",this.database.generateHandle())}catch{this._attrs.set("objectId",this.generateTemporaryHandle())}}generateTemporaryHandle(){return An+uc()}get attrs(){return this._attrs}getAttr(e){const t=this._attrs.get(e);if(t===void 0)throw new Error(`[AcDbObject] Attribute name '${e}' does't exist in this object!`);return t}getAttrWithoutException(e){return this._attrs.get(e)}setAttr(e,t){this._attrs.set(e,t)}get objectId(){return this.getAttr("objectId")}set objectId(e){this._attrs.set("objectId",e),e&&!e.startsWith(An)&&this.database.updateMaxHandle(e)}get isTemp(){const e=this.getAttrWithoutException("objectId");return!!e&&e.startsWith(An)}get ownerId(){return this.getAttr("ownerId")}set ownerId(e){this._attrs.set("ownerId",e)}get extensionDictionary(){return this.getAttrWithoutException("extensionDictionary")}set extensionDictionary(e){this._attrs.set("extensionDictionary",e)}get database(){if(this._database)return this._database;if(Xs)return Xs().workingDatabase;throw new Error("The current working database must be set before using it!")}set database(e){this._database=e}getXData(e){return this._xDataMap.get(e)}setXData(e){for(const t of e)t.code===er.ExtendedDataRegAppName&&this._xDataMap.set(t.value,e)}removeXData(e){this._xDataMap.delete(e)}createExtensionDictionary(){}close(){}clone(){const e=Object.create(Object.getPrototypeOf(this)),t=this,i=e;for(const s of Object.keys(t))s!=="_database"&&(i[s]=this.cloneValue(t[s]));return e.objectId=this.generateTemporaryHandle(),e}cloneValue(e){if(e==null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(Array.isArray(e))return e.map(s=>this.cloneValue(s));if(e instanceof Map){const s=new Map;for(const[r,a]of e.entries())s.set(this.cloneValue(r),this.cloneValue(a));return s}if(e instanceof Set){const s=new Set;for(const r of e.values())s.add(this.cloneValue(r));return s}if(ArrayBuffer.isView(e)){if(e instanceof DataView)return new DataView(e.buffer.slice(0));const s=e.constructor;return new s(e)}if(e instanceof ArrayBuffer)return e.slice(0);if("clone"in e&&typeof e.clone=="function")return e.clone();const t=Object.create(Object.getPrototypeOf(e)),i=e;for(const s of Object.keys(i))t[s]=this.cloneValue(i[s]);return t}dxfOut(...e){const[t,i=!1]=e;if(t.writeHandle(5,this.objectId),t.writeObjectId(330,this.ownerId),t.writeObjectId(360,this.extensionDictionary),this.dxfOutFields(t),i)for(const s of this._xDataMap.values())t.writeResultBuffer(s);return this}dxfOutFields(e){return this}}let Rs;function so(n){Rs=n}function ir(){return Yn.instance}const ds=class ds{constructor(){this._workingDatabase=null}get workingDatabase(){if(this._workingDatabase==null)throw new Error("The current working database must be set before using it!");return this._workingDatabase}set workingDatabase(e){this._workingDatabase=e}get layoutManager(){if(!this._layoutManager){if(!Rs)throw new Error("The layout manager factory must be registered before using it!");this._layoutManager=Rs()}return this._layoutManager}};ds.instance=new ds;let Yn=ds;no(ir);var ro=(n=>(n.kForRead="kForRead",n.kForWrite="kForWrite",n))(ro||{});class nr{constructor(e){if(this._values=[],e)for(const t of e)this._values.push({...t})}get length(){return this._values.length}at(e){return this._values[e]}add(e){this._values.push(e)}addRange(e){for(const t of e)this._values.push(t)}clear(){this._values.length=0}toArray(){return this._values.map(e=>({...e}))}clone(){return new nr(this._values)}[Symbol.iterator](){return this._values[Symbol.iterator]()}}class sr{constructor(e,t,i){this._chunkSize=-1,this._minimumChunkSize=50,this._count=e,this._numerOfChunk=t<1?1:t,this._minimumChunkSize=i,this.calculateChunkSize()}get count(){return this._count}get numerOfChunk(){return this._numerOfChunk}get minimumChunkSize(){return this._minimumChunkSize}set minimumChunkSize(e){this._minimumChunkSize=e,this.calculateChunkSize()}get chunkSize(){return this._chunkSize}calculateChunkSize(){let e=this._count/this._numerOfChunk;e<this._minimumChunkSize&&(e=Math.min(this._minimumChunkSize,this._count)),this._chunkSize=e<1?this._count:Math.floor(e)}scheduleTask(e){return new Promise((t,i)=>{const s=()=>{Promise.resolve(e()).then(t).catch(i)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(s):setTimeout(s,0)})}async processChunk(e,t){if(this._count<=0){await(t==null?void 0:t());return}let i=0;const s=async()=>{const r=i,a=Math.min(i+this._chunkSize,this._count);await e(r,a),i=a,i<this._count&&await this.scheduleTask(s)};await s(),await(t==null?void 0:t())}}var Ni=(n=>(n.DXF="dxf",n.DWG="dwg",n))(Ni||{});class De{constructor(){this.events={registered:new J,unregistered:new J},this._converters=new Map,this.register("dxf",new Qh)}static createInstance(){return De._instance==null&&(De._instance=new De),this._instance}static get instance(){return De._instance||(De._instance=new De),De._instance}get fileTypes(){return this._converters.keys()}register(e,t){this._converters.set(e,t),this.events.registered.dispatch({fileType:e,converter:t})}get(e){return this._converters.get(e)}unregister(e){const t=this._converters.get(e);t&&(this._converters.delete(e),this.events.unregistered.dispatch({fileType:e,converter:t}))}}var rr=(n=>(n[n.DecimalDegrees=0]="DecimalDegrees",n[n.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",n[n.Gradians=2]="Gradians",n[n.Radians=3]="Radians",n[n.SurveyorsUnits=4]="SurveyorsUnits",n))(rr||{});class ii{static get instance(){return this._instance||(this._instance=new ii),this._instance}constructor(){this._blocks=new Map}createKey(e,t){return`${e}_${t}`}set(e,t){return t=t.fastDeepClone(),this._blocks.set(e,t),t}get(e){let t=this._blocks.get(e);return t&&(t=t.fastDeepClone()),t}has(e){return this._blocks.has(e)}clear(){this._blocks.clear()}draw(e,t,i,s=[],r=!0,a,o){const h=[];if(t!=null){const c=this.createKey(t.name,i);let d;if(this.has(c))d=this.get(c);else{const u=t.newIterator();for(const p of u)p.color.isByBlock&&i?(Sa.copy(p.color),p.color.setRGBValue(i),this.addEntity(p,h,e),p.color.copy(Sa)):this.addEntity(p,h,e);d=e.group(h),d&&r&&Q.name&&!Q.name.startsWith("*U")&&this.set(c,d)}return d&&a&&(d.applyMatrix(a),o&&(o.x!=0||o.y!=0||o.z!=1)&&(a.setFromExtrusionDirection(o),d.applyMatrix(a))),d&&s&&s.length>0&&(d.bakeTransformToChildren(),s.forEach(u=>d.addChild(u))),d}else return e.group(h)}addEntity(e,t,i){const s=e.worldDraw(i);s&&(this.attachEntityInfo(s,e),t.push(s))}attachEntityInfo(e,t){e.objectId=t.objectId,e.ownerId=t.ownerId,e.layerName=t.layer,e.visible=t.visibility}}const Sa=new z;var ar=(n=>(n[n.UTF8=0]="UTF8",n[n.US_ASCII=1]="US_ASCII",n[n.ISO_8859_1=2]="ISO_8859_1",n[n.ISO_8859_2=3]="ISO_8859_2",n[n.ISO_8859_3=4]="ISO_8859_3",n[n.ISO_8859_4=5]="ISO_8859_4",n[n.ISO_8859_5=6]="ISO_8859_5",n[n.ISO_8859_6=7]="ISO_8859_6",n[n.ISO_8859_7=8]="ISO_8859_7",n[n.ISO_8859_8=9]="ISO_8859_8",n[n.ISO_8859_9=10]="ISO_8859_9",n[n.CP437=11]="CP437",n[n.CP850=12]="CP850",n[n.CP852=13]="CP852",n[n.CP855=14]="CP855",n[n.CP857=15]="CP857",n[n.CP860=16]="CP860",n[n.CP861=17]="CP861",n[n.CP863=18]="CP863",n[n.CP864=19]="CP864",n[n.CP865=20]="CP865",n[n.CP869=21]="CP869",n[n.CP932=22]="CP932",n[n.MACINTOSH=23]="MACINTOSH",n[n.BIG5=24]="BIG5",n[n.CP949=25]="CP949",n[n.JOHAB=26]="JOHAB",n[n.CP866=27]="CP866",n[n.ANSI_1250=28]="ANSI_1250",n[n.ANSI_1251=29]="ANSI_1251",n[n.ANSI_1252=30]="ANSI_1252",n[n.GB2312=31]="GB2312",n[n.ANSI_1253=32]="ANSI_1253",n[n.ANSI_1254=33]="ANSI_1254",n[n.ANSI_1255=34]="ANSI_1255",n[n.ANSI_1256=35]="ANSI_1256",n[n.ANSI_1257=36]="ANSI_1257",n[n.ANSI_874=37]="ANSI_874",n[n.ANSI_932=38]="ANSI_932",n[n.ANSI_936=39]="ANSI_936",n[n.ANSI_949=40]="ANSI_949",n[n.ANSI_950=41]="ANSI_950",n[n.ANSI_1361=42]="ANSI_1361",n[n.UTF16=43]="UTF16",n[n.ANSI_1258=44]="ANSI_1258",n[n.UNDEFINED=255]="UNDEFINED",n))(ar||{});const gc=["utf-8","utf-8","iso-8859-1","iso-8859-2","iso-8859-3","iso-8859-4","iso-8859-5","iso-8859-6","iso-8859-7","iso-8859-8","iso-8859-9","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","utf-8","shift-jis","macintosh","big5","utf-8","utf-8","ibm866","windows-1250","windows-1251","windows-1252","gbk","windows-1253","windows-1254","windows-1255","windows-1256","windows-1257","windows-874","shift-jis","gbk","euc-kr","big5","utf-8","utf-16le","windows-1258"],ao=n=>gc[n],St="Continuous",Z="Standard",dt="Standard",ut="Standard",de="ByLayer",Lt="ByBlock",Bs="mlightcad",Fs="ACAD",ce=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let Ia=1234567;const or=Math.PI/180,lr=180/Math.PI;function oo(){const n=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(ce[n&255]+ce[n>>8&255]+ce[n>>16&255]+ce[n>>24&255]+"-"+ce[e&255]+ce[e>>8&255]+"-"+ce[e>>16&15|64]+ce[e>>24&255]+"-"+ce[t&63|128]+ce[t>>8&255]+"-"+ce[t>>16&255]+ce[t>>24&255]+ce[i&255]+ce[i>>8&255]+ce[i>>16&255]+ce[i>>24&255]).toLowerCase()}function ct(n,e,t){return Math.max(e,Math.min(t,n))}function hr(n,e){return(n%e+e)%e}function lo(n,e,t,i,s){return i+(n-e)*(s-i)/(t-e)}function ho(n,e,t){return n!==e?(t-n)/(e-n):0}function cr(n,e,t){return(1-t)*n+t*e}function co(n,e,t,i){return cr(n,e,1-Math.exp(-t*i))}function uo(n,e=1){return e-Math.abs(hr(n,e*2)-e)}function go(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*(3-2*n))}function po(n,e,t){return n<=e?0:n>=t?1:(n=(n-e)/(t-e),n*n*n*(n*(n*6-15)+10))}function mo(n,e){return n+Math.floor(Math.random()*(e-n+1))}function yo(n,e){return n+Math.random()*(e-n)}function _o(n){return n*(.5-Math.random())}function xo(n){n!==void 0&&(Ia=n);let e=Ia+=1831565813;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}function wo(n){return n*or}function fo(n){return n*lr}function bo(n){return(n&n-1)===0&&n!==0}function Lo(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function So(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function Yi(n){const e=Math.PI*2;return(n%e+e)%e}function Io(n,e,t){return n>e&&n<t||n>t&&n<e}function Ao(n,e,t,i=!1){return n=Yi(n),e=Yi(e),t=Yi(t),i?e>t?n<=e&&n>=t:n<=e||n>=t:e<t?n>=e&&n<=t:n>=e||n<=t}function dr(n){return n=Math.abs(n),n<1?0:Math.ceil(Math.log10(Math.abs(n)+1))}function Po(n,e=1e-7){const t=dr(n);return Math.max(Math.pow(10,t)*e,e)}const k={DEG2RAD:or,RAD2DEG:lr,generateUUID:oo,clamp:ct,euclideanModulo:hr,mapLinear:lo,inverseLerp:ho,lerp:cr,damp:co,pingpong:uo,smoothstep:go,smootherstep:po,randInt:mo,randFloat:yo,randFloatSpread:_o,seededRandom:xo,degToRad:wo,radToDeg:fo,isPowerOfTwo:bo,ceilPowerOfTwo:Lo,floorPowerOfTwo:So,normalizeAngle:Yi,isBetween:Io,isBetweenAngle:Ao,intPartLength:dr,relativeEps:Po},Ds=class Eo{constructor(e,t){this.x=0,this.y=0;const i=+(e!==void 0)+ +(t!==void 0);if(i!==0){if(i===1&&e instanceof Array){this.x=e[0],this.y=e[1];return}if(i===1){const{x:s,y:r}=e;this.x=s,this.y=r;return}if(i===2){this.x=e,this.y=t;return}throw fe.ILLEGAL_PARAMETERS}}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}}clone(){return new Eo(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix2d(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Math.max(-1,Math.min(1,i)))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}rotateAround(e,t){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*s+e.x,this.y=r*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(e=1e-7){return Math.min(k.relativeEps(this.x,e),k.relativeEps(this.y,e))}*[Symbol.iterator](){yield this.x,yield this.y}};Ds.EMPTY=Object.freeze(new Ds(0,0));let $=Ds;const zs=class To{constructor(e,t,i,s,r,a,o,h,c){this.elements=[1,0,0,0,1,0,0,0,1],e!=null&&t!=null&&i!=null&&s!=null&&r!=null&&a!=null&&o!=null&&h!=null&&c!=null&&this.set(e,t,i,s,r,a,o,h,c)}set(e,t,i,s,r,a,o,h,c){const d=this.elements;return d[0]=e,d[1]=s,d[2]=o,d[3]=t,d[4]=r,d[5]=h,d[6]=i,d[7]=a,d[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[3],h=i[6],c=i[1],d=i[4],u=i[7],p=i[2],g=i[5],m=i[8],y=s[0],x=s[3],_=s[6],S=s[1],L=s[4],T=s[7],I=s[2],j=s[5],M=s[8];return r[0]=a*y+o*S+h*I,r[3]=a*x+o*L+h*j,r[6]=a*_+o*T+h*M,r[1]=c*y+d*S+u*I,r[4]=c*x+d*L+u*j,r[7]=c*_+d*T+u*M,r[2]=p*y+g*S+m*I,r[5]=p*x+g*L+m*j,r[8]=p*_+g*T+m*M,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],h=e[6],c=e[7],d=e[8];return t*a*d-t*o*c-i*r*d+i*o*h+s*r*c-s*a*h}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],h=e[6],c=e[7],d=e[8],u=d*a-o*c,p=o*h-d*r,g=c*r-a*h,m=t*u+i*p+s*g;if(m===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/m;return e[0]=u*y,e[1]=(s*c-d*i)*y,e[2]=(o*i-s*a)*y,e[3]=p*y,e[4]=(d*t-s*h)*y,e[5]=(s*r-o*t)*y,e[6]=g*y,e[7]=(i*h-c*t)*y,e[8]=(a*t-i*r)*y,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e.elements[0]=t[0],e.elements[1]=t[3],e.elements[2]=t[6],e.elements[3]=t[1],e.elements[4]=t[4],e.elements[5]=t[7],e.elements[6]=t[2],e.elements[7]=t[5],e.elements[8]=t[8],this}setUvTransform(e,t,i,s,r,a,o){const h=Math.cos(r),c=Math.sin(r);return this.set(i*h,i*c,-i*(h*a+c*o)+a+e,-s*c,s*h,-s*(-c*a+h*o)+o+t,0,0,1),this}scale(e,t){return this.premultiply(fs.makeScale(e,t)),this}rotate(e){return this.premultiply(fs.makeRotation(-e)),this}translate(e,t){return this.premultiply(fs.makeTranslation(e,t)),this}makeTranslation(e,t){return e instanceof $?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new To().fromArray(this.elements)}};zs.IDENTITY=Object.freeze(new zs);let en=zs;const fs=new en,Zt=1e-6,W=2*Math.PI,pc={x:0,y:0},ur={x:0,y:0,z:0};class tn{constructor(){this.equalPointTol=Zt,this.equalVectorTol=Zt}clone(){const e=new tn;return e.equalPointTol=this.equalPointTol,e.equalVectorTol=this.equalVectorTol,e}equalPoint2d(e,t){return new $(e).sub(t).length()<this.equalPointTol}equalPoint3d(e,t){return new w(e).sub(t).length()<this.equalPointTol}static equalToZero(e,t=Zt){return e<t&&e>-t}static equal(e,t,i=Zt){return Math.abs(e-t)<i}static great(e,t,i=Zt){return e-t>i}static less(e,t,i=Zt){return e-t<i}}const gr=new tn;class ni{constructor(e=0,t=0,i=0,s=1){this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,a,o){let h=i[s+0],c=i[s+1],d=i[s+2],u=i[s+3];const p=r[a+0],g=r[a+1],m=r[a+2],y=r[a+3];if(o===0){e[t+0]=h,e[t+1]=c,e[t+2]=d,e[t+3]=u;return}if(o===1){e[t+0]=p,e[t+1]=g,e[t+2]=m,e[t+3]=y;return}if(u!==y||h!==p||c!==g||d!==m){let x=1-o;const _=h*p+c*g+d*m+u*y,S=_>=0?1:-1,L=1-_*_;if(L>Number.EPSILON){const I=Math.sqrt(L),j=Math.atan2(I,_*S);x=Math.sin(x*j)/I,o=Math.sin(o*j)/I}const T=o*S;if(h=h*x+p*T,c=c*x+g*T,d=d*x+m*T,u=u*x+y*T,x===1-o){const I=1/Math.sqrt(h*h+c*c+d*d+u*u);h*=I,c*=I,d*=I,u*=I}}e[t]=h,e[t+1]=c,e[t+2]=d,e[t+3]=u}static multiplyQuaternionsFlat(e,t,i,s,r,a){const o=i[s],h=i[s+1],c=i[s+2],d=i[s+3],u=r[a],p=r[a+1],g=r[a+2],m=r[a+3];return e[t]=o*m+d*u+h*g-c*p,e[t+1]=h*m+d*p+c*u-o*g,e[t+2]=c*m+d*g+o*p-h*u,e[t+3]=d*m-o*u-h*p-c*g,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new ni(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e.x,s=e.y,r=e.z,a=e.order,o=Math.cos,h=Math.sin,c=o(i/2),d=o(s/2),u=o(r/2),p=h(i/2),g=h(s/2),m=h(r/2);switch(a){case"XYZ":this._x=p*d*u+c*g*m,this._y=c*g*u-p*d*m,this._z=c*d*m+p*g*u,this._w=c*d*u-p*g*m;break;case"YXZ":this._x=p*d*u+c*g*m,this._y=c*g*u-p*d*m,this._z=c*d*m-p*g*u,this._w=c*d*u+p*g*m;break;case"ZXY":this._x=p*d*u-c*g*m,this._y=c*g*u+p*d*m,this._z=c*d*m+p*g*u,this._w=c*d*u-p*g*m;break;case"ZYX":this._x=p*d*u-c*g*m,this._y=c*g*u+p*d*m,this._z=c*d*m-p*g*u,this._w=c*d*u+p*g*m;break;case"YZX":this._x=p*d*u+c*g*m,this._y=c*g*u+p*d*m,this._z=c*d*m-p*g*u,this._w=c*d*u-p*g*m;break;case"XZY":this._x=p*d*u-c*g*m,this._y=c*g*u-p*d*m,this._z=c*d*m+p*g*u,this._w=c*d*u+p*g*m;break}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],a=t[1],o=t[5],h=t[9],c=t[2],d=t[6],u=t[10],p=i+o+u;if(p>0){const g=.5/Math.sqrt(p+1);this._w=.25/g,this._x=(d-h)*g,this._y=(r-c)*g,this._z=(a-s)*g}else if(i>o&&i>u){const g=2*Math.sqrt(1+i-o-u);this._w=(d-h)/g,this._x=.25*g,this._y=(s+a)/g,this._z=(r+c)/g}else if(o>u){const g=2*Math.sqrt(1+o-i-u);this._w=(r-c)/g,this._x=(s+a)/g,this._y=.25*g,this._z=(h+d)/g}else{const g=2*Math.sqrt(1+u-i-o);this._w=(a-s)/g,this._x=(r+c)/g,this._y=(h+d)/g,this._z=.25*g}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<Number.EPSILON?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(ct(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,s=e._y,r=e._z,a=e._w,o=t._x,h=t._y,c=t._z,d=t._w;return this._x=i*d+a*o+s*c-r*h,this._y=s*d+a*h+r*o-i*c,this._z=r*d+a*c+i*h-s*o,this._w=a*d-i*o-s*h-r*c,this._onChangeCallback(),this}slerp(e,t){if(t===0)return this;if(t===1)return this.copy(e);const i=this._x,s=this._y,r=this._z,a=this._w;let o=a*e._w+i*e._x+s*e._y+r*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=i,this._y=s,this._z=r,this;const h=1-o*o;if(h<=Number.EPSILON){const g=1-t;return this._w=g*a+t*this._w,this._x=g*i+t*this._x,this._y=g*s+t*this._y,this._z=g*r+t*this._z,this.normalize(),this}const c=Math.sqrt(h),d=Math.atan2(c,o),u=Math.sin((1-t)*d)/c,p=Math.sin(t*d)/c;return this._w=a*u+this._w*p,this._x=i*u+this._x*p,this._y=s*u+this._y*p,this._z=r*u+this._z*p,this._onChangeCallback(),this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const me=class Mo{constructor(e,t,i){this.x=0,this.y=0,this.z=0;const s=+(e!==void 0)+ +(t!==void 0)+ +(i!==void 0);if(s!==0){if(s===1&&e instanceof Array){this.x=e[0],this.y=e[1],this.z=e[2];return}if(s===1){const{x:r,y:a,z:o}=e;this.x=r,this.y=a,this.z=o||0;return}if(s===3){this.x=e,this.y=t,this.z=i;return}throw fe.ILLEGAL_PARAMETERS}}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}}clone(){return new Mo(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z||0,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z||0,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Aa.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Aa.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,a=e.y,o=e.z,h=e.w,c=2*(a*s-o*i),d=2*(o*t-r*s),u=2*(r*i-a*t);return this.x=t+h*c+a*u-o*d,this.y=i+h*d+o*c-r*u,this.z=s+h*u+r*d-a*c,this}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this}clampScalar(e,t){return this.x=Math.max(e,Math.min(t,this.x)),this.y=Math.max(e,Math.min(t,this.y)),this.z=Math.max(e,Math.min(t,this.z)),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(e,Math.min(t,i)))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}isParallelTo(e){const t=this.dot(e),i=this.length(),s=e.length();return Math.abs(t)===i*s}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,a=t.x,o=t.y,h=t.z;return this.x=s*h-r*o,this.y=r*a-i*h,this.z=i*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return bs.copy(this).projectOnVector(e),this.sub(bs)}reflect(e){return this.sub(bs.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Math.max(-1,Math.min(1,i)))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};me.ORIGIN=Object.freeze(new me(0,0,0)),me.X_AXIS=Object.freeze(new me(1,0,0)),me.NEGATIVE_X_AXIS=Object.freeze(new me(-1,0,0)),me.Y_AXIS=Object.freeze(new me(0,1,0)),me.NEGATIVE_Y_AXIS=Object.freeze(new me(0,-1,0)),me.Z_AXIS=Object.freeze(new me(0,0,1)),me.NEGATIVE_Z_AXIS=Object.freeze(new me(0,0,-1));let w=me;const bs=new w,Aa=new ni,Vs=class ko{constructor(e,t,i,s,r,a,o,h,c,d,u,p,g,m,y,x){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!=null&&t!=null&&i!=null&&s!=null&&r!=null&&a!=null&&o!=null&&h!=null&&c!=null&&d!=null&&u!=null&&p!=null&&g!=null&&m!=null&&y!=null&&x!=null&&this.set(e,t,i,s,r,a,o,h,c,d,u,p,g,m,y,x)}set(e,t,i,s,r,a,o,h,c,d,u,p,g,m,y,x){const _=this.elements;return _[0]=e,_[4]=t,_[8]=i,_[12]=s,_[1]=r,_[5]=a,_[9]=o,_[13]=h,_[2]=c,_[6]=d,_[10]=u,_[14]=p,_[3]=g,_[7]=m,_[11]=y,_[15]=x,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ko().fromArray(this.elements)}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){const t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}setFromExtrusionDirection(e){if(gr.equalPoint3d(e,w.Z_AXIS))this.identity();else{const t=new w(1,0,0);Math.abs(e.x)<1/64&&Math.abs(e.y)<1/64?t.crossVectors(w.Y_AXIS,e).normalize():t.crossVectors(w.Z_AXIS,e).normalize();const i=e.clone().cross(t).normalize();this.set(t.x,t.y,t.z,0,i.x,i.y,i.z,0,e.x,e.y,e.z,0,0,0,0,1)}return this}extractBasis(e,t,i){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){const t=this.elements,i=e.elements,s=1/si.setFromMatrixColumn(e,0).length(),r=1/si.setFromMatrixColumn(e,1).length(),a=1/si.setFromMatrixColumn(e,2).length();return t[0]=i[0]*s,t[1]=i[1]*s,t[2]=i[2]*s,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*a,t[9]=i[9]*a,t[10]=i[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(mc,e,yc)}lookAt(e,t,i){const s=this.elements;return be.subVectors(e,t),be.lengthSq()===0&&(be.z=1),be.normalize(),xt.crossVectors(i,be),xt.lengthSq()===0&&(Math.abs(i.z)===1?be.x+=1e-4:be.z+=1e-4,be.normalize(),xt.crossVectors(i,be)),xt.normalize(),yn.crossVectors(be,xt),s[0]=xt.x,s[4]=yn.x,s[8]=be.x,s[1]=xt.y,s[5]=yn.y,s[9]=be.y,s[2]=xt.z,s[6]=yn.z,s[10]=be.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[4],h=i[8],c=i[12],d=i[1],u=i[5],p=i[9],g=i[13],m=i[2],y=i[6],x=i[10],_=i[14],S=i[3],L=i[7],T=i[11],I=i[15],j=s[0],M=s[4],U=s[8],X=s[12],te=s[1],R=s[5],H=s[9],vt=s[13],Ct=s[2],ln=s[6],hn=s[10],cn=s[14],dn=s[3],un=s[7],gn=s[11],pn=s[15];return r[0]=a*j+o*te+h*Ct+c*dn,r[4]=a*M+o*R+h*ln+c*un,r[8]=a*U+o*H+h*hn+c*gn,r[12]=a*X+o*vt+h*cn+c*pn,r[1]=d*j+u*te+p*Ct+g*dn,r[5]=d*M+u*R+p*ln+g*un,r[9]=d*U+u*H+p*hn+g*gn,r[13]=d*X+u*vt+p*cn+g*pn,r[2]=m*j+y*te+x*Ct+_*dn,r[6]=m*M+y*R+x*ln+_*un,r[10]=m*U+y*H+x*hn+_*gn,r[14]=m*X+y*vt+x*cn+_*pn,r[3]=S*j+L*te+T*Ct+I*dn,r[7]=S*M+L*R+T*ln+I*un,r[11]=S*U+L*H+T*hn+I*gn,r[15]=S*X+L*vt+T*cn+I*pn,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[4],s=e[8],r=e[12],a=e[1],o=e[5],h=e[9],c=e[13],d=e[2],u=e[6],p=e[10],g=e[14],m=e[3],y=e[7],x=e[11],_=e[15];return m*(+r*h*u-s*c*u-r*o*p+i*c*p+s*o*g-i*h*g)+y*(+t*h*g-t*c*p+r*a*p-s*a*g+s*c*d-r*h*d)+x*(+t*c*u-t*o*g-r*a*u+i*a*g+r*o*d-i*c*d)+_*(-s*o*d-t*h*u+t*o*p+s*a*u-i*a*p+i*h*d)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){const s=this.elements;return e instanceof w?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=i),this}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],h=e[6],c=e[7],d=e[8],u=e[9],p=e[10],g=e[11],m=e[12],y=e[13],x=e[14],_=e[15],S=u*x*c-y*p*c+y*h*g-o*x*g-u*h*_+o*p*_,L=m*p*c-d*x*c-m*h*g+a*x*g+d*h*_-a*p*_,T=d*y*c-m*u*c+m*o*g-a*y*g-d*o*_+a*u*_,I=m*u*h-d*y*h-m*o*p+a*y*p+d*o*x-a*u*x,j=t*S+i*L+s*T+r*I;if(j===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const M=1/j;return e[0]=S*M,e[1]=(y*p*r-u*x*r-y*s*g+i*x*g+u*s*_-i*p*_)*M,e[2]=(o*x*r-y*h*r+y*s*c-i*x*c-o*s*_+i*h*_)*M,e[3]=(u*h*r-o*p*r-u*s*c+i*p*c+o*s*g-i*h*g)*M,e[4]=L*M,e[5]=(d*x*r-m*p*r+m*s*g-t*x*g-d*s*_+t*p*_)*M,e[6]=(m*h*r-a*x*r-m*s*c+t*x*c+a*s*_-t*h*_)*M,e[7]=(a*p*r-d*h*r+d*s*c-t*p*c-a*s*g+t*h*g)*M,e[8]=T*M,e[9]=(m*u*r-d*y*r-m*i*g+t*y*g+d*i*_-t*u*_)*M,e[10]=(a*y*r-m*o*r+m*i*c-t*y*c-a*i*_+t*o*_)*M,e[11]=(d*o*r-a*u*r-d*i*c+t*u*c+a*i*g-t*o*g)*M,e[12]=I*M,e[13]=(d*y*s-m*u*s+m*i*p-t*y*p-d*i*x+t*u*x)*M,e[14]=(m*o*s-a*y*s-m*i*h+t*y*h+a*i*x-t*o*x)*M,e[15]=(a*u*s-d*o*s+d*i*h-t*u*h-a*i*p+t*o*p)*M,this}scale(e){const t=this.elements,i=e.x,s=e.y,r=e.z;return t[0]*=i,t[4]*=s,t[8]*=r,t[1]*=i,t[5]*=s,t[9]*=r,t[2]*=i,t[6]*=s,t[10]*=r,t[3]*=i,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,s))}makeTranslation(e,t,i){return e instanceof w?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const i=Math.cos(t),s=Math.sin(t),r=1-i,a=e.x,o=e.y,h=e.z,c=r*a,d=r*o;return this.set(c*a+i,c*o-s*h,c*h+s*o,0,c*o+s*h,d*o+i,d*h-s*a,0,c*h-s*o,d*h+s*a,r*h*h+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,s,r,a){return this.set(1,i,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,i){const s=this.elements,r=t.x,a=t.y,o=t.z,h=t.w,c=r+r,d=a+a,u=o+o,p=r*c,g=r*d,m=r*u,y=a*d,x=a*u,_=o*u,S=h*c,L=h*d,T=h*u,I=i.x,j=i.y,M=i.z;return s[0]=(1-(y+_))*I,s[1]=(g+T)*I,s[2]=(m-L)*I,s[3]=0,s[4]=(g-T)*j,s[5]=(1-(p+_))*j,s[6]=(x+S)*j,s[7]=0,s[8]=(m+L)*M,s[9]=(x-S)*M,s[10]=(1-(p+y))*M,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,i){const s=this.elements;let r=si.set(s[0],s[1],s[2]).length();const a=si.set(s[4],s[5],s[6]).length(),o=si.set(s[8],s[9],s[10]).length();this.determinant()<0&&(r=-r),e.x=s[12],e.y=s[13],e.z=s[14],Ce.copy(this);const h=1/r,c=1/a,d=1/o;return Ce.elements[0]*=h,Ce.elements[1]*=h,Ce.elements[2]*=h,Ce.elements[4]*=c,Ce.elements[5]*=c,Ce.elements[6]*=c,Ce.elements[8]*=d,Ce.elements[9]*=d,Ce.elements[10]*=d,t.setFromRotationMatrix(Ce),i.x=r,i.y=a,i.z=o,this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<16;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}};Vs.IDENTITY=Object.freeze(new Vs);let D=Vs;const si=new w,Ce=new D,mc=new w(0,0,0),yc=new w(1,1,1),xt=new w,yn=new w,be=new w;let N=class vo{constructor(e=void 0,t=void 0){this.min=e==null?new w(1/0,1/0,1/0):new w(e.x,e.y,e.z),this.max=t==null?new w(-1/0,-1/0,-1/0):new w(t.x,t.y,t.z)}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t+=3)this.expandByPoint(Ls.fromArray(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Ls.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new vo().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new w(0,0,0):new w(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new w(0,0,0):new w(0,0,0).subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y||e.z<this.min.z||e.z>this.max.z)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y||e.max.z<this.min.z||e.min.z>this.max.z)}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Ls).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(He[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),He[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),He[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),He[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),He[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),He[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),He[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),He[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(He),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}};const He=[new w,new w,new w,new w,new w,new w,new w,new w],Ls=new w,Pa=new $;let _e=class Co{constructor(e=void 0,t=void 0){this.min=e==null?new $(1/0,1/0):new $(e.x,e.y),this.max=t==null?new $(-1/0,-1/0):new $(t.x,t.y)}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromPoints(e){this.makeEmpty();for(let t=0,i=e.length;t<i;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const i=Pa.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(i),this.max.copy(e).add(i),this}clone(){return new Co().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y}getCenter(e){return this.isEmpty()?e.set(0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0):e.subVectors(this.max,this.min)}get center(){return this.isEmpty()?new $(0,0):new $(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new $(0,0):new $(0,0).subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}containsPoint(e){return!(e.x<this.min.x||e.x>this.max.x||e.y<this.min.y||e.y>this.max.y)}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y))}intersectsBox(e){return!(e.max.x<this.min.x||e.min.x>this.max.x||e.max.y<this.min.y||e.min.y>this.max.y)}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Pa).distanceTo(e)}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}};const Ea=new w,_c=new w,xc=new en;class nn{constructor(e=new w(1,0,0),t=0){this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,s){return this.normal.set(e,t,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const s=Ea.subVectors(i,t).cross(_c.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectsBox(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||xc.getNormalMatrix(e),s=this.coplanarPoint(Ea).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new nn().copy(this)}}let v=class Oo extends ${clone(){return new Oo(this.x,this.y)}static pointArrayToNumberArray(e){const t=new Array(e.length*2);return e.forEach((i,s)=>{i.toArray(t,s*2)}),t}},f=class No extends w{clone(){return new No(this.x,this.y,this.z)}static pointArrayToNumberArray(e,t=!0){const i=t?3:2,s=new Array(e.length*i);return e.forEach((r,a)=>{r.toArray(s,a*i)}),s}};const Ta=new D,Ma=new ni,Yo=class js{constructor(e=0,t=0,i=0,s=js.DEFAULT_ORDER){this._x=e,this._y=t,this._z=i,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,i,s=this._order){return this._x=e,this._y=t,this._z=i,this._order=s,this._onChangeCallback(),this}clone(){return new js(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,i=!0){const s=e.elements,r=s[0],a=s[4],o=s[8],h=s[1],c=s[5],d=s[9],u=s[2],p=s[6],g=s[10];switch(t){case"XYZ":this._y=Math.asin(ct(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,g),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(p,c),this._z=0);break;case"YXZ":this._x=Math.asin(-ct(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,g),this._z=Math.atan2(h,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(ct(p,-1,1)),Math.abs(p)<.9999999?(this._y=Math.atan2(-u,g),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(h,r));break;case"ZYX":this._y=Math.asin(-ct(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(p,g),this._z=Math.atan2(h,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(ct(h,-1,1)),Math.abs(h)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,g));break;case"XZY":this._z=Math.asin(-ct(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(p,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-d,g),this._y=0);break}return this._order=t,i===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,i=!0){return Ta.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ta,t,i)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Ma.setFromEuler(this),this.setFromQuaternion(Ma,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}};Yo.DEFAULT_ORDER="XYZ";let wc=Yo;function pr(n,e,t=!1){const i=n.x,s=n.y;let r=!1;const a=e.length;for(let o=0,h=a-1;o<a;h=o++){const c=e[o].x,d=e[o].y,u=e[h].x,p=e[h].y;let g=d>s!=p>s;t&&(g=d>=s!=p>=s),g&&i<(u-c)*(s-d)/(p-d)+c&&(r=!r)}return r}function Xo(n,e){if(n.length===0||e.length===0)return!1;const t=new _e().setFromPoints(n),i=new _e().setFromPoints(e);if(!t.intersectsBox(i))return!1;for(let s=0;s<n.length;){if(pr(n[s],e,!0))return!0;s<n.length-1&&gr.equalPoint2d(n[s+1],n[s])&&++s,++s}return!1}const Ro={isPointInPolygon:pr,isPolygonIntersect:Xo};function fc(n,e){const t=[],i=e-1,s=n;for(let r=0;r<=s;r++)t.push(0);for(let r=1;r<=i-s;r++)t.push(r);for(let r=0;r<=s;r++)t.push(i-s+1);return t}function bc(n,e){const t=e.length-1,i=n,s=[0];let r=0;for(let o=1;o<=t;o++){const h=e[o][0]-e[o-1][0],c=e[o][1]-e[o-1][1],d=e[o][2]-e[o-1][2],u=Math.sqrt(h*h+c*c+d*d);r+=u,s.push(r)}const a=[];for(let o=0;o<=i;o++)a.push(0);for(let o=1;o<=t-i;o++){const h=s[o]/r;a.push(h*(t-i+1))}for(let o=0;o<=i;o++)a.push(t-i+1);return a}function Bo(n,e="Uniform"){const t=n.length;if(t===0)return[];if(t===1)return[0];const i=t-1;if(e==="Uniform")return new Array(t).fill(0).map((a,o)=>o/i);const s=[0];let r=0;for(let a=1;a<=i;a++){const o=n[a][0]-n[a-1][0],h=n[a][1]-n[a-1][1],c=n[a][2]-n[a-1][2],d=Math.sqrt(o*o+h*h+c*c),u=e==="SqrtChord"?Math.sqrt(d):d;r+=u,s.push(r)}return r<1e-12?new Array(t).fill(0).map((a,o)=>o/i):s.map(a=>a/r)}function Fo(n,e){const t=e.length-1,i=n,s=t+i+1,r=new Array(s+1).fill(0),a=e[e.length-1];for(let o=s-i;o<=s;o++)r[o]=a;for(let o=1;o<=t-i;o++){let h=0;for(let c=o;c<o+i;c++)h+=e[c];r[o+i]=h/i}return r}function Lc(n,e){const t=e.length-1,i=n,s=[0];let r=0;for(let o=1;o<=t;o++){const h=e[o][0]-e[o-1][0],c=e[o][1]-e[o-1][1],d=e[o][2]-e[o-1][2],u=Math.sqrt(h*h+c*c+d*d),p=Math.sqrt(u);r+=p,s.push(r)}const a=[];for(let o=0;o<=i;o++)a.push(0);for(let o=1;o<=t-i;o++){const h=s[o]/r;a.push(h*(t-i+1))}for(let o=0;o<=i;o++)a.push(t-i+1);return a}function Ss(n,e){const t=n.length,i=n.map(a=>a.slice()),s=e.slice();for(let a=0;a<t;a++){let o=a,h=Math.abs(i[a][a]);for(let c=a+1;c<t;c++){const d=Math.abs(i[c][a]);d>h&&(h=d,o=c)}if(h<1e-12)throw new Error("Interpolation matrix is singular.");if(o!==a){const c=i[a];i[a]=i[o],i[o]=c;const d=s[a];s[a]=s[o],s[o]=d}for(let c=a+1;c<t;c++){const d=i[c][a]/i[a][a];if(!(Math.abs(d)<1e-14)){for(let u=a;u<t;u++)i[c][u]-=d*i[a][u];s[c]-=d*s[a]}}}const r=new Array(t).fill(0);for(let a=t-1;a>=0;a--){let o=s[a];for(let h=a+1;h<t;h++)o-=i[a][h]*r[h];r[a]=o/i[a][a]}return r}function mr(n,e,t="Uniform",i,s){if(n.length===0)return{controlPoints:[],knots:[],weights:[]};const r=n.map(X=>[X[0],X[1],X[2]??0]),a=!!i,o=!!s,h=(a?1:0)+(o?1:0),c=r.length-1,d=c+h;if(d<e)throw new Error("Not enough points to interpolate a curve of this degree.");const u=Bo(r,t),p=u.slice();a&&p.unshift(u[0]),o&&p.push(u[u.length-1]);const g=Fo(e,p),m=d+1,y=new Array(m),x=new Array(m),_=new Array(m),S=new Array(m);let L=0;y[L]=new Array(m).fill(0),y[L][0]=1,x[L]=r[0][0],_[L]=r[0][1],S[L]=r[0][2],L++;for(let X=1;X<=c-1;X++){const te=u[X];y[L]=new Array(m).fill(0);for(let R=0;R<=d;R++)y[L][R]=Vi(R,e,te,g);x[L]=r[X][0],_[L]=r[X][1],S[L]=r[X][2],L++}if(y[L]=new Array(m).fill(0),y[L][d]=1,x[L]=r[c][0],_[L]=r[c][1],S[L]=r[c][2],L++,a){const X=g[e+1]-g[0],te=X!==0?e/X:0;y[L]=new Array(m).fill(0),y[L][0]=-te,y[L][1]=te,x[L]=(i==null?void 0:i[0])??0,_[L]=(i==null?void 0:i[1])??0,S[L]=(i==null?void 0:i[2])??0,L++}if(o){const X=g[d+e+1]-g[d],te=X!==0?e/X:0;y[L]=new Array(m).fill(0),y[L][d-1]=-te,y[L][d]=te,x[L]=(s==null?void 0:s[0])??0,_[L]=(s==null?void 0:s[1])??0,S[L]=(s==null?void 0:s[2])??0,L++}const T=Ss(y,x),I=Ss(y,_),j=Ss(y,S),M=new Array(m);for(let X=0;X<m;X++)M[X]=[T[X],I[X],j[X]];const U=new Array(m).fill(1);return{controlPoints:M,knots:g,weights:U}}function Vi(n,e,t,i){if(e===0)return t>=i[n]&&t<i[n+1]?1:0;const s=i[n+e]-i[n],r=i[n+e+1]-i[n+1],a=s>1e-10?(t-i[n])/s:0,o=r>1e-10?(i[n+e+1]-t)/r:0;return a*Vi(n,e-1,t,i)+o*Vi(n+1,e-1,t,i)}function Xi(n,e,t,i,s){const r=i.length-1,a=e;if(n=Math.max(t[a],Math.min(t[r+1],n)),Math.abs(n-t[r+1])<1e-8)return[...i[r]];if(Math.abs(n-t[a])<1e-8)return[...i[0]];const o=[0,0,0];let h=0;for(let c=0;c<=r;c++){const d=Vi(c,a,n,t),u=s[c]*d;o[0]+=i[c][0]*u,o[1]+=i[c][1]*u,o[2]+=i[c][2]*u,h+=u}if(Math.abs(h)<1e-10){const c=t[t.length-a-1];if(Math.abs(n-c)<1e-8)return[...i[r]];if(Math.abs(n-t[a])<1e-8)return[...i[0]]}return Math.abs(h)>=1e-10&&(o[0]/=h,o[1]/=h,o[2]/=h),o}function Do(n,e,t,i){const s=n,r=e[s],a=e[e.length-s-1];let o=0;const h=1e3,c=(a-r)/h;let d=Xi(r,n,e,t,i);for(let y=1;y<=h;y++){const x=r+y*c,_=Xi(x,n,e,t,i),S=_[0]-d[0],L=_[1]-d[1],T=_[2]-d[2];o+=Math.sqrt(S*S+L*L+T*T),d=_}const u=Xi(a,n,e,t,i),p=u[0]-d[0],g=u[1]-d[1],m=u[2]-d[2];return o+=Math.sqrt(p*p+g*g+m*m),o}function Sc(n,e=3,t="Uniform",i,s){return n.length===0?[]:mr(n,e,t,i,s).controlPoints}const ka=new D,va=new w,Ic=new w,Ac=new w,Is=new f;function zo(n){return new D().setFromExtrusionDirection(new w(n.x,n.y,n.z))}function yr(n){return ka.setFromExtrusionDirection(new w(n.x,n.y,n.z)),ka.extractBasis(va,Ic,Ac),va.clone()}function Ws(n,e){return new f(n.x,n.y,n.z??0).applyMatrix4(zo(e))}function ji(n,e){return new f(n.x,n.y,n.z??0).applyMatrix4(zo(e).invert())}function Gs(n,e,t){const i=ji(n,t),s=ji(e,t);return Is.set(s.x-i.x,s.y-i.y,(s.z??0)-(i.z??0)),k.normalizeAngle(Math.atan2(Is.y,Is.x))}class Vo{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class _r extends Vo{translate(e){return this.transform(new en().makeTranslation(e.x,e.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}let Pt=class jo extends _r{constructor(){super(),this._loops=[]}add(e){this._loops.push(e),this._boundingBoxNeedsUpdate=!0}get loops(){return this._loops}get outter(){if(this._loops.length>0)return this._loops[0]}calculateBoundingBox(){const e=this.outter;return e?e.box:new _e}transform(e){return this._loops.forEach(t=>{t.transform(e)}),this._boundingBoxNeedsUpdate=!0,this}clone(){const e=new jo;return this._loops.forEach(t=>{e.add(t.clone())}),e}getPoints(e){const t=[];for(let i=0;i<this.loops.length;++i){const s=this.loops[i].getPoints(e);t.push(s)}return t}buildHierarchy(){var e;const t=this.getPoints(100),i=this.calculateBoundaryBoxes(t),s=this.sortBoundaryBoxesByAreas(i),r=new Map,a=s.length;for(let h=0;h<a;h++)r.set(s[h],{index:s[h],children:[]});const o={index:-1,children:[]};for(let h=0;h<a;h++){const c=s[h],d=t[c],u=i[c];let p=h+1;for(;p<a;p++){const g=s[p],m=t[g];if(i[g].containsBox(u)&&Ro.isPointInPolygon(d[k.randInt(0,d.length-1)],m)){(e=r.get(g))==null||e.children.push(r.get(c));break}}p===a&&o.children.push(r.get(c))}return o}get area(){if(this._loops.length===0)return 0;let e=0;for(let t=0;t<this._loops.length;t++){const i=this._loops[t].getPoints(128),s=this.polygonArea(i);t===0?e+=Math.abs(s):e-=Math.abs(s)}return e}polygonArea(e){const t=e.length;if(t<3)return 0;let i=0;for(let s=0,r=t-1;s<t;r=s++){const a=e[r],o=e[s];i+=a.x*o.y-o.x*a.y}return i*.5}calculateBoundaryBoxes(e){const t=[];return e.forEach(i=>{t.push(new _e().setFromPoints(i))}),t}sortBoundaryBoxesByAreas(e){const t=[];e.forEach((s,r)=>{const a=s.size,o=a.width*a.height;t.push({area:o,index:r})}),t.sort((s,r)=>s.area-r.area);const i=[];return t.forEach(s=>{i.push(s.index)}),i}},ui=class extends _r{constructor(){super(),this.arcLengthDivisions=100}get startPoint(){return this.getPoint(0)}get endPoint(){return this.getPoint(1)}get length(){return this.getLength()}getPoint(e){throw new Error("AcGeCurve2d: .getPoint() not implemented.")}getPointAt(e){const t=this.getUtoTmapping(e);return this.getPoint(t)}getPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}getSpacedPoints(e=5){const t=[];for(let i=0;i<=e;i++)t.push(this.getPointAt(i/e));return t}getLength(){const e=this.getLengths();return e[e.length-1]}getLengths(e=this.arcLengthDivisions){const t=[];let i,s=this.getPoint(0),r=0;t.push(0);for(let a=1;a<=e;a++)i=this.getPoint(a/e),r+=i.distanceTo(s),t.push(r),s=i;return t}getUtoTmapping(e,t){const i=this.getLengths();let s=0;const r=i.length;let a;t?a=t:a=e*i[r-1];let o=0,h=r-1,c;for(;o<=h;)if(s=Math.floor(o+(h-o)/2),c=i[s]-a,c<0)o=s+1;else if(c>0)h=s-1;else{h=s;break}if(s=h,i[s]===a)return s/(r-1);const d=i[s],u=i[s+1]-d,p=(a-d)/u;return(s+p)/(r-1)}getTangent(e){let t=e-1e-4,i=e+1e-4;t<0&&(t=0),i>1&&(i=1);const s=this.getPoint(t),r=this.getPoint(i),a=new v;return a.copy(r).sub(s).normalize(),a}getTangentAt(e){const t=this.getUtoTmapping(e);return this.getTangent(t)}},Et=class Hs extends ui{constructor(e,t,i,s,r){super();const a=+(e!==void 0)+ +(t!==void 0)+ +(i!==void 0)+ +(s!==void 0)+ +(r!==void 0);if(a==3)typeof e=="object"&&typeof t=="object"&&typeof i=="object"?this.createByThreePoints(e,t,i):this.createByStartEndPointsAndBulge(e,t,i);else if(a==5){const o=e;this.center=new v(o.x,o.y),this.radius=t,this._clockwise=r,this._startAngle=this._clockwise?this._mirrorAngle(k.normalizeAngle(i)):k.normalizeAngle(i),this._endAngle=this._clockwise?this._mirrorAngle(k.normalizeAngle(s)):k.normalizeAngle(s)}else throw fe.ILLEGAL_PARAMETERS}createByThreePoints(e,t,i){const s=(M,U)=>({x:(M.x+U.x)/2,y:(M.y+U.y)/2}),r=(M,U)=>(U.y-M.y)/(U.x-M.x),a=M=>-1/M,o=s(e,t),h=s(t,i),c=r(e,t),d=r(t,i),u=a(c),p=a(d),g=(M,U,X,te)=>{const R=(te-U)/(M-X),H=M*R+U;return{x:R,y:H}},m=o.y-u*o.x,y=h.y-p*h.x,x=g(u,m,p,y),_=Math.sqrt(Math.pow(e.x-x.x,2)+Math.pow(e.y-x.y,2)),S=(M,U)=>Math.atan2(M.y-U.y,M.x-U.x),L=S(e,x),T=S(t,x),I=S(i,x),j=I>L&&I<T||L>I&&L<T||T>I&&T<L;this.center=x,this.radius=_,this._clockwise=!j,this._startAngle=L,this._endAngle=I}createByStartEndPointsAndBulge(e,t,i){let s,r,a;i<0?(s=Math.atan(-i)*4,r=new $(e),a=new $(t)):(s=Math.atan(i)*4,r=new $(t),a=new $(e));const o=new $().subVectors(a,r),h=o.length(),c=new $().addVectors(r,o.multiplyScalar(.5)),d=Math.abs(h/2/Math.tan(s/2)),u=o.normalize(),p=i<0?-Math.PI/2:Math.PI/2,g=new $(u.x*Math.cos(p)-u.y*Math.sin(p),u.y*Math.cos(p)+u.x*Math.sin(p));let m;s<Math.PI?i<0?m=c.add(g.multiplyScalar(d)):m=c.add(g.multiplyScalar(-d)):i<0?m=c.add(g.multiplyScalar(-d)):m=c.add(g.multiplyScalar(d)),i<0?(this._startAngle=Math.atan2(r.y-m.y,r.x-m.x),this._endAngle=Math.atan2(a.y-m.y,a.x-m.x)):(this._startAngle=Math.atan2(a.y-m.y,a.x-m.x),this._endAngle=Math.atan2(r.y-m.y,r.x-m.x)),this._clockwise=i<0,this.center=m,this.radius=a.sub(m).length()}get center(){return this._center}set center(e){this._center=new v(e.x,e.y),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(e){this._radius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle}set startAngle(e){this._startAngle=this._clockwise?this._mirrorAngle(k.normalizeAngle(e)):k.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle}set endAngle(e){const t=this.startAngle==0&&e==W?e:k.normalizeAngle(e);this._endAngle=this._clockwise?this._mirrorAngle(t):t,this._boundingBoxNeedsUpdate=!0}_mirrorAngle(e){return(360-e*180/Math.PI)%360*Math.PI/180}_getInternalAngle(e){return this._clockwise?this._mirrorAngle(e):e}get deltaAngle(){const e=this._getInternalAngle(this.startAngle),t=this._getInternalAngle(this.endAngle);return this.clockwise?k.normalizeAngle(e-t):k.normalizeAngle(t-e)}get clockwise(){return this._clockwise}set clockwise(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this.startAngle)}get endPoint(){return this.getPointAtAngle(this.endAngle)}get midPoint(){const e=this._getInternalAngle(this.startAngle),t=this._clockwise?k.normalizeAngle(e-this.deltaAngle/2):k.normalizeAngle(e+this.deltaAngle/2),i=this._clockwise?this._mirrorAngle(t):t;return this.getPointAtAngle(i)}get closed(){const e=this._getInternalAngle(this.startAngle),t=this._getInternalAngle(this.endAngle);return Math.abs(t-e)/Math.PI%2==0}calculateBoundingBox(){const e=[this.startPoint,this.endPoint],t=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const r of t){const a=this._getInternalAngle(r);k.isBetweenAngle(a,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&e.push(this.getPointAtAngle(r))}const i=e.map(r=>r.x),s=e.map(r=>r.y);return new _e(new v(Math.min(...i),Math.min(...s)),new v(Math.max(...i),Math.max(...s)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(e){const t=e,i=this.center.clone().applyMatrix2d(t),s=this.startPoint.clone().applyMatrix2d(t);if(this.closed)return this.center=i,this.radius=i.distanceTo(s),this._startAngle=Math.atan2(s.y-i.y,s.x-i.x),this._endAngle=this._startAngle,this._clockwise=t.determinant()<0?!this._clockwise:this._clockwise,this._boundingBoxNeedsUpdate=!0,this;const r=this.midPoint.clone().applyMatrix2d(t),a=this.endPoint.clone().applyMatrix2d(t),o=new Hs(s,r,a),h=t.determinant()<0?!this.clockwise:this.clockwise,c=d=>{const u=k.normalizeAngle(d);return h?this._mirrorAngle(u):u};return this.center=o.center,this.radius=o.radius,this.clockwise=h,this.startAngle=c(Math.atan2(s.y-o.center.y,s.x-o.center.x)),this.endAngle=c(Math.atan2(a.y-o.center.y,a.x-o.center.x)),this._boundingBoxNeedsUpdate=!0,this}clone(){return new Hs(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(e){const t=this._getInternalAngle(e),i=this.center.x+this.radius*Math.cos(t),s=this.center.y+this.radius*Math.sin(t);return new v(i,s)}getPoints(e=100){const t=[];let i=this.deltaAngle,s=this._getInternalAngle(this.startAngle);if(this.closed&&(i=W,s=0),this.clockwise)for(let r=0;r<=e;r++){const a=s-i*(r/e),o=this._clockwise?this._mirrorAngle(a):a,h=this.getPointAtAngle(o);t.push(new v(h.x,h.y))}else for(let r=0;r<=e;r++){const a=s+i*(r/e),o=this._clockwise?this._mirrorAngle(a):a,h=this.getPointAtAngle(o);t.push(new v(h.x,h.y))}return t}};class Pc extends Vo{translate(e){return this.transform(new D().makeTranslation(e.x,e.y,e.z))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class sn extends Pc{}class Tt extends sn{constructor(e,t){super(),this._start=new f(e),this._end=new f(t)}get startPoint(){return this._start}set startPoint(e){this._start.copy(e),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(e){this._end.copy(e),this._boundingBoxNeedsUpdate=!0}get direction(){return new w().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new f((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)}nearestPoint(e){return this.project(e)}get length(){return this.startPoint.distanceTo(this.endPoint)}isPointOnLine(e){return this.project(e).distanceTo(e)<1e-6}at(e,t){return this.delta(t).multiplyScalar(e).add(this._start)}atLength(e,t=!1){if(t){const i=this.delta(Ot).normalize();return new f(this._start).addScaledVector(i,e)}else{const i=this.delta(Ot).normalize();return new f(this._end).addScaledVector(i,e)}}extend(e,t=!1){if(t){const i=Ot.subVectors(this._start,this._end).normalize();this._start=new f(this._start).addScaledVector(i,e)}else{const i=this.delta(Ot).normalize();this._end=new f(this._end).addScaledVector(i,e)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(e,t){Ca.subVectors(e,this._start),_n.subVectors(this.endPoint,this.startPoint);const i=_n.dot(_n);let s=_n.dot(Ca)/i;return t&&(s=k.clamp(s,0,1)),s}closestPointToPoint(e,t,i){const s=this.closestPointToPointParameter(e,t);return this.delta(i).multiplyScalar(s).add(this._start)}delta(e){return e.subVectors(this._end,this._start)}distanceSq(){return this._start.distanceToSquared(this._end)}distance(){return this._start.distanceTo(this._end)}project(e){const t=this.direction,i=Ot.subVectors(e,this.startPoint).dot(t);return new f().copy(t).multiplyScalar(i).add(this.startPoint)}perpPoint(e){const t=this.direction,i=this.startPoint,s=Ot.subVectors(e,i).dot(t),r=Ot.copy(t).multiplyScalar(s);return new f().addVectors(i,r)}calculateBoundingBox(){const e=new f(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),t=new f(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y),Math.max(this._start.z,this._end.z));return new N(e,t)}transform(e){return this._start.applyMatrix4(e),this._end.applyMatrix4(e),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(e){return this.startPoint=e.startPoint,this.endPoint=e.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new Tt(this._start.clone(),this._end.clone())}}const Ot=new w,Ca=new w,_n=new w;class It extends sn{static computeCenterPoint(e,t,i){const s=new w().addVectors(e,t).multiplyScalar(.5),r=new w().addVectors(e,i).multiplyScalar(.5),a=new w().subVectors(t,e),o=new w().subVectors(i,e),h=new w().crossVectors(a,o).normalize();if(h.lengthSq()===0)return null;const c=new w().crossVectors(a,h).normalize(),d=new w().crossVectors(o,h).normalize(),u=c.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),p=d.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),g=new Tt(s,s.clone().add(u)),m=new Tt(r,r.clone().add(p)),y=new w;return g.closestPointToPoint(m.startPoint,!0,y)?y:null}static createByThreePoints(e,t,i){const s=It.computeCenterPoint(e,t,i);if(s){const r=s.distanceTo(e),a=new w().subVectors(e,s),o=new w().subVectors(t,s),h=Math.atan2(a.y,a.x),c=Math.atan2(o.y,o.x);return new It(s,r,h,c,w.Z_AXIS)}}constructor(e,t,i,s,r,a=w.X_AXIS){super(),this.center=e,this.radius=t,this.startAngle=i,this.endAngle=s,this.normal=r,this.refVec=a,(s-i)%W==0?(this.startAngle=0,this.endAngle=W):(this.startAngle=i,this.endAngle=s)}get center(){return this._center}set center(e){this._center=new f(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(e){if(e<0)throw fe.ILLEGAL_PARAMETERS;this._radius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(e){this._startAngle=k.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(e){this._endAngle=this.startAngle==0&&e==W?e:k.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return k.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(e){this._normal=new w(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(e){this._refVec=new w(e.x,e.y,e.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let e=this.startAngle,t=this.deltaAngle;this.closed&&(e=0,t=W);const i=e+t*.5;return this.getPointAtAngle(i)}get length(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)}get area(){return this.closed?Math.PI*this.radius*this.radius:Math.abs(this.deltaAngle*this.radius*this.radius)}nearestPoint(e){const t=new w(e.x,e.y,e.z||0),i=this.center,s=this.normal,r=t.clone().sub(i).dot(s),a=t.clone().sub(s.clone().multiplyScalar(r)).clone().sub(i);if(a.lengthSq()===0)return this.startPoint.clone();a.normalize().multiplyScalar(this.radius);const o=i.clone().add(a),h=this.getAngle(o.clone()),c=this.startAngle,d=this.deltaAngle;let u=k.normalizeAngle(h-c);u<0&&(u=0),u>d&&(u=d);const p=this.getPointAtAngle(c+u),g=p.distanceTo(t),m=this.startPoint.distanceTo(t),y=this.endPoint.distanceTo(t);return m<g&&m<=y?this.startPoint.clone():y<g&&y<m?this.endPoint.clone():p}tangentPoints(e){const t=[],i=new w(e.x,e.y,e.z||0),s=this.center,r=this.normal,a=this.radius,o=i.clone().sub(s).dot(r),h=i.clone().sub(r.clone().multiplyScalar(o)),c=s.clone(),d=h.clone().sub(c).length();if(d<a)return t;const u=Math.acos(a/d),p=this.getAngle(h.clone()),g=[p+u,p-u];for(const m of g){const y=k.normalizeAngle(m-this.startAngle);y>=0&&y<=this.deltaAngle&&t.push(this.getPointAtAngle(this.startAngle+y))}return t}nearestTangentPoint(e){const t=this.tangentPoints(e);if(t.length===0)return null;const i=new f(e.x,e.y,e.z||0);return t.length===1||t[0].distanceTo(i)<t[1].distanceTo(i)?t[0]:t[1]}calculateBoundingBox(){const e=[this.startAngle,this.endAngle];for(let h=0;h<2*Math.PI;h+=Math.PI/2)k.isBetweenAngle(h,this.startAngle,this.endAngle)&&e.push(h);let t=1/0,i=1/0,s=1/0,r=-1/0,a=-1/0,o=-1/0;for(const h of e){const c=this.getPointAtAngle(h);c.x<t&&(t=c.x),c.y<i&&(i=c.y),c.z<s&&(s=c.z),c.x>r&&(r=c.x),c.y>a&&(a=c.y),c.z>o&&(o=c.z)}return new N({x:t,y:i,z:s},{x:r,y:a,z:o})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(e){const t=[];let i=this.deltaAngle,s=this.startAngle;this.closed&&(i=W,s=0);for(let r=0;r<=e;r++){const a=s+i*(r/e),o=this.getPointAtAngle(a);t.push(o)}return t}transform(e){const t=this.center.clone().applyMatrix4(e),i=this.startPoint.clone().applyMatrix4(e),s=this.endPoint.clone().applyMatrix4(e),r=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(e),a=new w(i).sub(t).normalize(),o=t.distanceTo(i);let h=new w().crossVectors(new w(i).sub(t),new w(r).sub(t)).normalize();h.lengthSq()===0&&(h=this.normal.clone().transformDirection(e));const c=d=>{const u=new w(d).sub(t);return Math.atan2(u.dot(Oa.crossVectors(h,a)),u.dot(a))};return this.center=t,this.radius=o,this.normal=h,this.refVec=a,this.startAngle=0,this.endAngle=this.closed?W:c(s),this._boundingBoxNeedsUpdate=!0,this}copy(e){return this.center=e.center,this.radius=e.radius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.normal=e.normal,this.refVec=e.refVec,this._boundingBoxNeedsUpdate=!0,this}clone(){return new It(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(e){return e.sub(this.center),Math.atan2(e.dot(Oa.crossVectors(this.refVec,this.normal)),e.dot(this.refVec))}getPointAtAngle(e){const t=this.normal,i=this.refVec,s={x:t.y*i.z-t.z*i.y,y:t.z*i.x-t.x*i.z,z:t.x*i.y-t.y*i.x},r=this.center,a=this.radius;return new f(r.x+a*(i.x*Math.cos(e)+s.x*Math.sin(e)),r.y+a*(i.y*Math.cos(e)+s.y*Math.sin(e)),r.z+a*(i.z*Math.cos(e)+s.z*Math.sin(e)))}get plane(){const e=new w(this.center).distanceTo(ur);return new nn(this.normal,e)}}const Oa=new w;let Wi=class Pn extends ui{constructor(e,t,i,s=0,r=W,a=!1,o=0){super(),this.center=e,this.majorAxisRadius=t,this.minorAxisRadius=i,(r-s)%W==0?(this.startAngle=0,this.endAngle=W):(this.startAngle=s,this.endAngle=r),this.clockwise=a,this.rotation=o}get center(){return this._center}set center(e){this._center=new f(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(e){if(e<0)throw fe.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(e){if(e<0)throw fe.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(e){this._startAngle=k.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(e){this._endAngle=this.startAngle==0&&e==W?e:k.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get clockwise(){return this._clockwise}set clockwise(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0}get rotation(){return this._rotation}set rotation(e){this._rotation=e,this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return k.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let e=1/0,t=1/0,i=-1/0,s=-1/0;for(let r=0;r<=100;r++){const a=this.getPoint(r/100);e=Math.min(e,a.x),t=Math.min(t,a.y),i=Math.max(i,a.x),s=Math.max(s,a.y)}return new _e({x:e,y:t},{x:i,y:s})}get closed(){return this.deltaAngle==0}getPoint(e){const t=Math.PI*2;let i=this.endAngle-this.startAngle;const s=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=t;for(;i>t;)i-=t;i<Number.EPSILON&&(s?i=0:i=t),this.clockwise===!0&&!s&&(i===t?i=-t:i=i-t);const r=this.startAngle+e*i;let a=this.center.x+this.majorAxisRadius*Math.cos(r),o=this.center.y+this.minorAxisRadius*Math.sin(r);if(this.rotation!==0){const h=Math.cos(this.rotation),c=Math.sin(this.rotation),d=a-this.center.x,u=o-this.center.y;a=d*h-u*c+this.center.x,o=d*c+u*h+this.center.y}return new v(a,o)}transform(e){const t=e,i=new v(this.center).applyMatrix2d(t),s=new f(i.x,i.y,this.center.z),r=this.getPointAtAngle(0).clone().applyMatrix2d(t),a=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(t),o=new v(r).sub(i),h=new v(a).sub(i),c=o.length(),d=h.length(),u=Math.atan2(o.y,o.x),p=o.clone().normalize(),g=h.clone().normalize(),m=_=>{const S=new v(_).sub(i),L=S.dot(p),T=S.dot(g);return k.normalizeAngle(Math.atan2(T/d,L/c))},y=t.determinant()<0?!this.clockwise:this.clockwise,x=this.closed?new Pn(s,c,d,0,W,y,u):new Pn(s,c,d,m(this.startPoint.clone().applyMatrix2d(t)),m(this.endPoint.clone().applyMatrix2d(t)),y,u);return this.center=x.center,this.majorAxisRadius=x.majorAxisRadius,this.minorAxisRadius=x.minorAxisRadius,this._startAngle=x._startAngle,this._endAngle=x._endAngle,this._clockwise=x._clockwise,this.rotation=x.rotation,this._boundingBoxNeedsUpdate=!0,this}getPointAtAngle(e){return this.getPoint(this.closed?e/W:k.normalizeAngle(e-this.startAngle)/this.deltaAngle)}copy(e){return this.center=e.center,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this}clone(){return new Pn(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}};class hi extends sn{constructor(e,t,i,s,r,a=0,o=W){super(),this.center=e,this.normal=t,this.majorAxis=i,this.majorAxisRadius=s,this.minorAxisRadius=r;const h=Math.abs(o-a);Math.abs(h-W)<1e-10||Math.abs(h-2*W)<1e-10?(this.startAngle=0,this.endAngle=W):(this.startAngle=a,this.endAngle=o)}get center(){return this._center}set center(e){this._center=new f(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(e){if(e<0)throw fe.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(e){if(e<0)throw fe.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(e){this._startAngle=k.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(e){this._endAngle=this.startAngle==0&&e==W?e:k.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const e=this.endAngle-this.startAngle;return Math.abs(e-W)<1e-10?W:k.normalizeAngle(e)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}get clockwise(){return this.deltaAngle<=0}get normal(){return this._normal}set normal(e){this._normal=new w(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(e){this._majorAxis=new w(e.x,e.y,e.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new w().crossVectors(this.normal,this.majorAxis).normalize()}get startPoint(){return this.getPointAtAngle(this._startAngle)}get endPoint(){return this.getPointAtAngle(this._endAngle)}get midPoint(){let e=this.startAngle,t=this.deltaAngle;(this.closed||Math.abs(t-W)<1e-10)&&(e=0,t=W);const i=e+t/2;return this.getPointAtAngle(i)}get isCircular(){return tn.equal(this.majorAxisRadius,this.minorAxisRadius)}get length(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);const e=1e3,t=this.deltaAngle/e;let i=0,s=this.getPointAtAngle(this.startAngle);for(let r=1;r<=e;r++){const a=this.startAngle+r*t,o=this.getPointAtAngle(a),h=o.x-s.x,c=o.y-s.y,d=o.z-s.z;i+=Math.sqrt(h*h+c*c+d*d),s=o}return i}get area(){const e=this.majorAxisRadius,t=this.minorAxisRadius,i=this.startAngle,s=i+this.deltaAngle;if(Math.abs(this.deltaAngle-W)<1e-10)return Math.PI*e*t;const r=e*t/2*(s-i-(Math.sin(s)*Math.cos(s)-Math.sin(i)*Math.cos(i)));return Math.abs(r)}calculateBoundingBox(){if(this.majorAxis.equals(w.X_AXIS)||this.majorAxis.equals(w.Y_AXIS)||this.majorAxis.isParallelTo(w.X_AXIS)||this.majorAxis.isParallelTo(w.Y_AXIS)){const e=[this.startAngle,this.endAngle];for(let h=0;h<2*Math.PI;h+=Math.PI/2)k.isBetweenAngle(h,this.startAngle,this.endAngle)&&e.push(h);let t=1/0,i=1/0,s=1/0,r=-1/0,a=-1/0,o=-1/0;for(const h of e){const c=this.getPointAtAngle(h);c.x<t&&(t=c.x),c.y<i&&(i=c.y),c.z<s&&(s=c.z),c.x>r&&(r=c.x),c.y>a&&(a=c.y),c.z>o&&(o=c.z)}return new N({x:t,y:i,z:s},{x:r,y:a,z:o})}else{let e=1/0,t=1/0,i=1/0,s=-1/0,r=-1/0,a=-1/0;for(let o=0;o<=100;o++){const h=this.startAngle+this.deltaAngle*(o/100),c=this.getPointAtAngle(h);e=Math.min(e,c.x),t=Math.min(t,c.y),i=Math.min(i,c.z),s=Math.max(s,c.x),r=Math.max(r,c.y),a=Math.max(a,c.z)}return new N({x:e,y:t,z:i},{x:s,y:r,z:a})}}get closed(){return this.deltaAngle==0}getPoints(e=100){const t=[];let i=this.deltaAngle,s=this.startAngle;this.closed&&(i=W,s=0);for(let r=0;r<=e;r++){const a=s+i*(r/e),o=this.getPointAtAngle(a);t.push(o)}return t}getPointAtAngle(e){const t=Math.cos(e),i=Math.sin(e),s=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(i),r=this.majorAxis.clone().multiplyScalar(t*this.majorAxisRadius).add(s);return new f(this.center.x+r.x,this.center.y+r.y,this.center.z+r.z)}contains(e){const t=new w(e).sub(this.center),i=t.dot(this.majorAxis),s=t.dot(this.minorAxis),r=i/this.majorAxisRadius,a=s/this.minorAxisRadius;return r*r+a*a<=1}transform(e){const t=e,i=this.center.clone().applyMatrix4(t),s=this.getPointAtAngle(0).clone().applyMatrix4(t),r=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(t),a=new w(s).sub(i),o=new w(r).sub(i),h=a.length(),c=o.length(),d=a.clone().normalize(),u=new w().crossVectors(a,o).normalize();let p=new w().crossVectors(u,d).normalize();p.dot(o)<0&&(u.negate(),p=new w().crossVectors(u,d).normalize());const g=y=>{const x=new w(y).sub(i),_=x.dot(d),S=x.dot(p);return k.normalizeAngle(Math.atan2(S/c,_/h))},m=this.closed?new hi(i,u,d,h,c,0,W):new hi(i,u,d,h,c,g(this.startPoint.clone().applyMatrix4(t)),g(this.endPoint.clone().applyMatrix4(t)));return this.center=m.center,this.normal=m.normal,this.majorAxis=m.majorAxis,this.majorAxisRadius=m.majorAxisRadius,this.minorAxisRadius=m.minorAxisRadius,this._startAngle=m._startAngle,this._endAngle=m._endAngle,this._boundingBoxNeedsUpdate=!0,this}copy(e){return this.center=e.center,this.normal=e.normal,this.majorAxis=e.majorAxis,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this._boundingBoxNeedsUpdate=!0,this}clone(){return new hi(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const e=new w(this.center).distanceTo(ur);return new nn(this.normal,e)}}class oe extends ui{constructor(e=null,t=!1){super(),this._vertices=e||new Array,this._closed=t}get vertices(){return this._vertices}get numberOfVertices(){return this._vertices.length}get closed(){return this._closed}get startPoint(){if(this.numberOfVertices>0){const e=this._vertices[0];return new v(e.x,e.y)}throw new Error("Start point does not exist in an empty polyline.")}get endPoint(){const e=this.numberOfVertices;if(e>0)if(this.closed){const t=this._vertices[0];return new v(t.x,t.y)}else{const t=this._vertices[e-1];return new v(t.x,t.y)}throw new Error("End point does not exist in an empty polyline.")}get length(){let e=0;const t=this._vertices.length;for(let i=0;i<t;++i){const s=this._vertices[i];let r=null;if(i<t-1?r=this._vertices[i+1]:i==t-1&&this.closed&&(r=this._vertices[0]),r)if(s.bulge){const a=new Et(s,r,s.bulge);e+=a.length}else e+=new v(s.x,s.y).distanceTo(r)}return e}set closed(e){this._closed=e,this._boundingBoxNeedsUpdate=!0}addVertexAt(e,t){e<=0?this._vertices.unshift(t):this._vertices.splice(e,0,t),this._boundingBoxNeedsUpdate=!0}removeVertexAt(e){if(e<0||e>=this._vertices.length)throw new Error(`Index ${e} is out of bounds. Valid range is 0 to ${this._vertices.length-1}.`);this._vertices.splice(e,1),this._boundingBoxNeedsUpdate=!0}reset(e,t){e?t!==void 0&&t>=0&&t<this._vertices.length&&(this._vertices=this._vertices.slice(0,t),this._boundingBoxNeedsUpdate=!0):(this._vertices=new Array,this._boundingBoxNeedsUpdate=!0)}getPointAt(e){const t=this._vertices[e];return new v(t.x,t.y)}calculateBoundingBox(){const e=this.getPoints(100);return new _e().setFromPoints(e)}transform(e){const t=e.determinant()<0;return this._vertices.forEach(i=>{const s=new v(i).applyMatrix2d(e);i.x=s.x,i.y=s.y,t&&i.bulge!=null&&(i.bulge=-i.bulge)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new oe(this._vertices.map(e=>({...e})),this._closed)}getPoints3d(e,t){const i=[];return this.getPoints(e).forEach(s=>i.push(new f().set(s.x,s.y,t))),i}getPoints(e){const t=[],i=this._vertices.length;for(let s=0;s<i;++s){const r=this._vertices[s];if(r.bulge){let a=null;if(s<i-1?a=this._vertices[s+1]:s==i-1&&this.closed&&(a=this._vertices[0]),a){const o=new Et(r,a,r.bulge).getPoints(e),h=o.length;for(let c=0;c<h;++c){const d=o[c];t.push(new v(d.x,d.y))}}}else t.push(new v(r.x,r.y)),s==i-1&&this.closed&&t.push(t[0])}return t}}class je extends ui{constructor(e,t){super(),this._start=new v(e),this._end=new v(t)}get startPoint(){return this._start}set startPoint(e){this._start.copy(e),this._boundingBoxNeedsUpdate=!0}get endPoint(){return this._end}set endPoint(e){this._end.copy(e),this._boundingBoxNeedsUpdate=!0}getPoints(){return[this.startPoint,this.endPoint]}get length(){return this.startPoint.distanceTo(this.endPoint)}calculateBoundingBox(){const e=new v(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),t=new v(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new _e(e,t)}transform(e){return this._start.applyMatrix2d(e),this._end.applyMatrix2d(e),this._boundingBoxNeedsUpdate=!0,this}get closed(){return!1}copy(e){return this.startPoint=e.startPoint,this.endPoint=e.endPoint,this._boundingBoxNeedsUpdate=!0,this}clone(){return new je(this._start.clone(),this._end.clone())}}let Gi=class Xe extends ui{constructor(e=[]){super(),this._curves=e}get curves(){return this._curves}static buildFromEdges(e,t=.001){if(e.length===0)return[];const i=[...e],s=[],r=t*t,a=(o,h)=>{const c=o.x-h.x,d=o.y-h.y;return c*c+d*d<=r};for(;i.length>0;){const o=[],h=i.shift();o.push(h);const c=Xe.getEdgeStartPoint(h);let d=Xe.getEdgeEndPoint(h);if(!a(c,d))for(;i.length>0;){const u=Xe.findConnectingEdge(i,d,r);if(u.index<0)break;let p=i.splice(u.index,1)[0];if(u.reverse&&(p=Xe.reverseEdge(p)),o.push(p),d=Xe.getEdgeEndPoint(p),a(d,c))break}s.push(new Xe(o))}return s}add(e){this._curves.push(e),this._boundingBoxNeedsUpdate=!0}get numberOfEdges(){return this._curves.length}get startPoint(){if(this._curves.length>0){const e=this._curves[0].startPoint;return new v(e.x,e.y)}throw new Error("Start point does not exist in an empty loop.")}get endPoint(){return this.startPoint}get length(){let e=0;return this._curves.forEach(t=>{e+=t.length}),e}calculateBoundingBox(){const e=this.getPoints(100),t=new _e;return t.setFromPoints(e),t}transform(e){const t=new D().set(e.elements[0],e.elements[3],0,e.elements[6],e.elements[1],e.elements[4],0,e.elements[7],0,0,1,0,0,0,0,1);return this._curves.forEach(i=>{i instanceof We?i.transform(t):i.transform(e)}),this._boundingBoxNeedsUpdate=!0,this}clone(){return new Xe(this._curves.map(e=>e.clone()))}get closed(){return!0}getPoints(e){const t=[];return this.curves.forEach(i=>{i.getPoints(e).forEach(s=>{t.push(new v(s.x,s.y))})}),t}static findConnectingEdge(e,t,i){let s=-1,r=!1,a=Number.POSITIVE_INFINITY;for(let o=0;o<e.length;o++){const h=e[o],c=Xe.getEdgeStartPoint(h),d=Xe.getEdgeEndPoint(h),u=t.x-c.x,p=t.y-c.y,g=u*u+p*p;g<a&&(a=g,s=o,r=!1);const m=t.x-d.x,y=t.y-d.y,x=m*m+y*y;x<a&&(a=x,s=o,r=!0)}return a>i?{index:-1,reverse:!1}:{index:s,reverse:r}}static getEdgeStartPoint(e){const t=e.startPoint;return new v(t.x,t.y)}static getEdgeEndPoint(e){const t=e.endPoint;return new v(t.x,t.y)}static reverseEdge(e){return e instanceof je?new je(e.endPoint,e.startPoint):e instanceof Et?new Et(e.center,e.radius,e.endAngle,e.startAngle,!e.clockwise):e instanceof Wi?new Wi(e.center,e.majorAxisRadius,e.minorAxisRadius,e.endAngle,e.startAngle,!e.clockwise,e.rotation):e instanceof We?Xe.reverseSplineEdge(e):e}static reverseSplineEdge(e){const t=[...e.controlPoints].reverse(),i=e.knots,s=i[0],r=i[i.length-1],a=i.map(c=>s+r-c).reverse(),o=e.weights,h=o.length>0?[...o].reverse():void 0;return new We(t,a,h,e.degree,e.closed)}};class As{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(e,t,i,s){this.c0=e,this.c1=i,this.c2=-3*e+3*t-2*i-s,this.c3=2*e-2*t+i+s}initCatmullRom(e,t,i,s,r){this.init(t,i,r*(i-e),r*(s-t))}initNonuniformCatmullRom(e,t,i,s,r,a,o){let h=(t-e)/r-(i-e)/(r+a)+(i-t)/a,c=(i-t)/a-(s-t)/(a+o)+(s-i)/o;h*=a,c*=a,this.init(t,i,h,c)}calc(e){const t=e*e,i=t*e;return this.c0+this.c1*e+this.c2*t+this.c3*i}}class ms extends sn{constructor(e=[],t=!1,i="centripetal",s=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new w,this._px=new As,this._py=new As,this._pz=new As,this._points=e.map(r=>new f(r)),this._closed=t,this._curveType=i,this._tension=s}get points(){return this._points}get closed(){return this._closed}get curveType(){return this._curveType}get tension(){return this._tension}get startPoint(){return this._points.length>0?this._points[0]:new f}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new f}get length(){if(this._points.length<2)return 0;let e=0;for(let t=1;t<this._points.length;t++)e+=this._points[t-1].distanceTo(this._points[t]);return this._closed&&this._points.length>2&&(e+=this._points[this._points.length-1].distanceTo(this._points[0])),e}getPoint(e,t=new f){const i=t,s=this._points,r=s.length;if(r===0)return i.set(0,0,0);if(r===1)return i.copy(s[0]);const a=(r-(this._closed?0:1))*e;let o=Math.floor(a),h=a-o;this._closed?o+=o>0?0:(Math.floor(Math.abs(o)/r)+1)*r:h===0&&o===r-1&&(o=r-2,h=1);let c,d;this._closed||o>0?c=s[(o-1)%r]:(this._tmp.subVectors(s[0],s[1]).add(s[0]),c=new f(this._tmp.x,this._tmp.y,this._tmp.z));const u=s[o%r],p=s[(o+1)%r];if(this._closed||o+2<r?d=s[(o+2)%r]:(this._tmp.subVectors(s[r-1],s[r-2]).add(s[r-1]),d=new f(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const g=this._curveType==="chordal"?.5:.25;let m=Math.pow(c.distanceToSquared(u),g),y=Math.pow(u.distanceToSquared(p),g),x=Math.pow(p.distanceToSquared(d),g);y<1e-4&&(y=1),m<1e-4&&(m=y),x<1e-4&&(x=y),this._px.initNonuniformCatmullRom(c.x,u.x,p.x,d.x,m,y,x),this._py.initNonuniformCatmullRom(c.y,u.y,p.y,d.y,m,y,x),this._pz.initNonuniformCatmullRom(c.z,u.z,p.z,d.z,m,y,x)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(c.x,u.x,p.x,d.x,this._tension),this._py.initCatmullRom(c.y,u.y,p.y,d.y,this._tension),this._pz.initCatmullRom(c.z,u.z,p.z,d.z,this._tension));return i.set(this._px.calc(h),this._py.calc(h),this._pz.calc(h)),i}getPoints(e){const t=[];for(let i=0;i<=e;i++)t.push(this.getPoint(i/e));return t}setPoints(e){this._points=e.map(t=>new f(t)),this._boundingBoxNeedsUpdate=!0}setClosed(e){this._closed!==e&&(this._closed=e,this._boundingBoxNeedsUpdate=!0)}setCurveType(e){this._curveType=e}setTension(e){this._tension=e}clone(){return new ms(this._points.map(e=>e.clone()),this._closed,this._curveType,this._tension)}transform(e){return this._points=this._points.map(t=>{const i=new f;return i.copy(t),i.applyMatrix4(e),i}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new N;const e=new N;return this._points.forEach(t=>{e.expandByPoint(t)}),e}}let Re=class Ci{constructor(e,t,i,s){this._degree=e,this._knots=[...t],this._controlPoints=i.map(r=>({x:r.x,y:r.y,z:r.z})),this._weights=s?[...s]:new Array(i.length).fill(1)}degree(){return this._degree}knots(){return[...this._knots]}controlPoints(){return this._controlPoints.map(e=>({x:e.x,y:e.y,z:e.z}))}weights(){return[...this._weights]}clone(){return new Ci(this._degree,this._knots,this._controlPoints,this._weights)}point(e){const t=this._controlPoints.map(i=>[i.x,i.y,i.z]);return Xi(e,this._degree,this._knots,t,this._weights)}length(){const e=this._controlPoints.map(t=>[t.x,t.y,t.z]);return Do(this._degree,this._knots,e,this._weights)}static byKnotsControlPointsWeights(e,t,i,s){return new Ci(e,t,i,s)}static byPoints(e,t,i="Uniform",s,r){const a=mr(e,t,i,s,r),o=a.controlPoints.map(h=>({x:h[0],y:h[1],z:h[2]}));return new Ci(t,a.knots,o,a.weights)}getParameterRange(){const e=this._knots[this._degree],t=this._knots[this._knots.length-this._degree-1];return{start:e,end:t}}getPoints(e){const t=[],{start:i,end:s}=this.getParameterRange();for(let r=0;r<=e;r++){const a=i+(s-i)*(r/e);t.push(this.point(a))}return t}isClosed(e=1e-6){const{start:t,end:i}=this.getParameterRange(),s=this.point(t),r=this.point(i),a=s[0]-r[0],o=s[1]-r[1],h=s[2]-r[2];return Math.sqrt(a*a+o*o+h*h)<e}static createFitPointsForClosedCurve(e){if(e.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");const t=new ms(e,!0,"centripetal"),i=Math.max(50,e.length*2);return t.getPoints(i)}static createClosedCurve(e,t,i="Chord"){const s=this.createFitPointsForClosedCurve(e).map(r=>[r.x,r.y,r.z]);return Ci.byPoints(s,t,i)}},We=class En extends sn{constructor(e,t,i,s,r,a){super();const o=arguments.length;if(this._degree=3,this._closed=!1,Array.isArray(t)){if(o<2||o>5)throw fe.ILLEGAL_PARAMETERS;this._controlPoints=e;let h,c=3,d=!1;if(o>=3&&(Array.isArray(i)?(h=i,o>=4&&(c=s||3),o>=5&&(d=r)):i!==void 0&&(c=i||3,o>=4&&(d=s))),i===void 0&&o>=4&&(c=s||3,o>=5&&(d=r)),this._degree=c,this._closed=d,this._controlPoints.length<this._degree+1)throw fe.ILLEGAL_PARAMETERS;this._nurbsCurve=Re.byKnotsControlPointsWeights(this._degree,t,this._controlPoints,h)}else{if(o<2||o>6)throw fe.ILLEGAL_PARAMETERS;this._fitPoints=e,this._knotParameterization=t,o>=3&&(this._degree=i||3);const h=typeof s=="boolean";o>=4&&h&&(this._closed=s),h?(o>=5&&(this._startTangent=r),o>=6&&(this._endTangent=a)):(o>=4&&(this._startTangent=s),o>=5&&(this._endTangent=r)),this._closed&&(this._startTangent=void 0,this._endTangent=void 0);const c=(this._startTangent?1:0)+(this._endTangent?1:0);if(this._fitPoints.length+c<this._degree+1)throw fe.ILLEGAL_PARAMETERS;if(this._closed)this._nurbsCurve=Re.createClosedCurve(this._fitPoints,this._degree,this._knotParameterization);else{const d=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Re.byPoints(d,this._degree,this._knotParameterization,this._startTangent?this.toNurbsPoint(this._startTangent):void 0,this._endTangent?this.toNurbsPoint(this._endTangent):void 0)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(d=>[d.x,d.y,d.z||0]))}}buildCurve(){if(this._fitPoints&&this._knotParameterization){if(this._closed){const e=Re.createFitPointsForClosedCurve(this._fitPoints),t=this.toNurbsPoints(e);this._nurbsCurve=Re.byPoints(t,this._degree,this._knotParameterization)}else{const e=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Re.byPoints(e,this._degree,this._knotParameterization,this._startTangent?this.toNurbsPoint(this._startTangent):void 0,this._endTangent?this.toNurbsPoint(this._endTangent):void 0)}this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(e=>[e.x,e.y,e.z||0]))}else if(this._controlPoints)if(this._closed){const e=Re.createFitPointsForClosedCurve(this._controlPoints),t=this.toNurbsPoints(e);this._nurbsCurve=Re.byPoints(t,this._degree,this._knotParameterization),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(i=>[i.x,i.y,i.z||0]))}else{const e=this._nurbsCurve.knots(),t=this._nurbsCurve.weights();this._nurbsCurve=Re.byKnotsControlPointsWeights(this._degree,e,this._controlPoints,t)}}setClosed(e){this._closed!==e&&(this._closed=e,this._boundingBoxNeedsUpdate=!0,this.buildCurve())}get degree(){return this._degree}get knotParameterization(){return this._knotParameterization}get controlPoints(){return this._controlPoints.map(e=>({x:e.x,y:e.y,z:e.z||0}))}get fitPoints(){var e;return(e=this._fitPoints)==null?void 0:e.map(t=>({x:t.x,y:t.y,z:t.z||0}))}get knots(){return[...this._nurbsCurve.knots()]}get weights(){return[...this._nurbsCurve.weights()]}get startPoint(){const e=this._nurbsCurve.knots(),t=this._nurbsCurve.degree(),i=e[t],s=this._nurbsCurve.point(i);return new f(s[0],s[1],s[2])}get endPoint(){const e=this._nurbsCurve.knots(),t=this._nurbsCurve.degree(),i=e[e.length-t-1],s=this._nurbsCurve.point(i);return new f(s[0],s[1],s[2])}get length(){return this._nurbsCurve.length()}getFitPointAt(e){if(!this._fitPoints)throw new Error("No fit points in this spline");const t=this._fitPoints.length,i=e<0||e>=t?t-1:e,s=this._fitPoints[i];return{x:s.x,y:s.y,z:s.z||0}}getControlPointAt(e){const t=this._controlPoints.length,i=e<0||e>=t?t-1:e;return this._controlPoints[i]}getPoints(e=100){const t=this._nurbsCurve,i=[],s=t.knots(),r=this._nurbsCurve.degree(),a=s[r],o=s[s.length-r-1],h=(o-a)/(e-1);for(let c=0;c<e;c++){const d=c===e-1?o:a+c*h,u=t.point(d);i.push(new f(u[0],u[1],u[2]))}return i}getCurvePoints(e,t){const i=[],s=e.knots(),r=e.degree(),a=s[r],o=(s[s.length-r-1]-a)/(t-1);for(let h=0;h<t;h++){const c=a+h*o;i.push(e.point(c))}return i}calculateBoundingBox(){const e=this.getPoints(100);return new N().setFromPoints(e)}get closed(){return this._closed}set closed(e){this.setClosed(e)}transform(e){if(this._fitPoints&&this._knotParameterization)this._fitPoints=this._fitPoints.map(t=>new f(t).applyMatrix4(e)),this._startTangent&&(this._startTangent=new f(this._startTangent).transformDirection(e)),this._endTangent&&(this._endTangent=new f(this._endTangent).transformDirection(e)),this.buildCurve();else{const t=this._nurbsCurve.knots(),i=this._nurbsCurve.weights();this._controlPoints=this._controlPoints.map(s=>new f(s).applyMatrix4(e)),this._nurbsCurve=Re.byKnotsControlPointsWeights(this._degree,t,this._controlPoints,i.length>0?i:void 0)}return this._boundingBoxNeedsUpdate=!0,this}clone(){return this._fitPoints&&this._knotParameterization?new En(this._fitPoints.map(e=>({x:e.x,y:e.y,z:e.z||0})),this._knotParameterization,this._degree,this._closed,this._startTangent?{x:this._startTangent.x,y:this._startTangent.y,z:this._startTangent.z||0}:void 0,this._endTangent?{x:this._endTangent.x,y:this._endTangent.y,z:this._endTangent.z||0}:void 0):new En(this._controlPoints.map(e=>({x:e.x,y:e.y,z:e.z||0})),this._nurbsCurve.knots(),this._nurbsCurve.weights(),this._degree,this._closed)}toNurbsPoints(e){const t=new Array(e.length);return e.forEach((i,s)=>{t[s]=[i.x,i.y,i.z||0]}),t}toGePoints(e){const t=new Array(e.length);return e.forEach((i,s)=>{t[s]={x:i[0],y:i[1],z:i[2]}}),t}toNurbsPoint(e){return[e.x,e.y,e.z||0]}static createClosedSpline(e,t="Uniform",i=3){if(e.length<i+1)throw new Error(`At least ${i+1} points are required for a degree ${i} closed spline`);return new En(e,t,i,!0)}};var xr=(n=>(n.ClosedFilled="",n.Dot="_DOT",n.DotSmall="_DOTSMALL",n.DotBlank="_DOTBLANK",n.Origin="_ORIGIN",n.Origin2="_ORIGIN2",n.Open="_OPEN",n.Open90="_OPEN90",n.Open30="_OPEN30",n.Closed="_CLOSED",n.Small="_SMALL",n.None="_NONE",n.Oblique="_OBLIQUE",n.BoxFilled="_BOXFILLED",n.Box="_BOXBLANK",n.ClosedBlank="_CLOSEDBLANK",n.DatumBlank="_DATUMBLANK",n.DatumFilled="_DATUMFILLED",n.Integral="_INTEGRAL",n.ArchTick="_ARCHTICK",n))(xr||{}),Qt=(n=>(n[n.ByBlock=-2]="ByBlock",n[n.ByDIPs=-4]="ByDIPs",n[n.ByLayer=-1]="ByLayer",n[n.ByLineWeightDefault=-3]="ByLineWeightDefault",n[n.LineWeight000=0]="LineWeight000",n[n.LineWeight005=5]="LineWeight005",n[n.LineWeight009=9]="LineWeight009",n[n.LineWeight013=13]="LineWeight013",n[n.LineWeight015=15]="LineWeight015",n[n.LineWeight018=18]="LineWeight018",n[n.LineWeight020=20]="LineWeight020",n[n.LineWeight025=25]="LineWeight025",n[n.LineWeight030=30]="LineWeight030",n[n.LineWeight035=35]="LineWeight035",n[n.LineWeight040=40]="LineWeight040",n[n.LineWeight050=50]="LineWeight050",n[n.LineWeight053=53]="LineWeight053",n[n.LineWeight060=60]="LineWeight060",n[n.LineWeight070=70]="LineWeight070",n[n.LineWeight080=80]="LineWeight080",n[n.LineWeight090=90]="LineWeight090",n[n.LineWeight100=100]="LineWeight100",n[n.LineWeight106=106]="LineWeight106",n[n.LineWeight120=120]="LineWeight120",n[n.LineWeight140=140]="LineWeight140",n[n.LineWeight158=158]="LineWeight158",n[n.LineWeight200=200]="LineWeight200",n[n.LineWeight211=211]="LineWeight211",n))(Qt||{}),ze=(n=>(n[n.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",n[n.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",n[n.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",n[n.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",n[n.BY_STYLE=5]="BY_STYLE",n))(ze||{}),ae=(n=>(n[n.TopLeft=1]="TopLeft",n[n.TopCenter=2]="TopCenter",n[n.TopRight=3]="TopRight",n[n.MiddleLeft=4]="MiddleLeft",n[n.MiddleCenter=5]="MiddleCenter",n[n.MiddleRight=6]="MiddleRight",n[n.BottomLeft=7]="BottomLeft",n[n.BottomCenter=8]="BottomCenter",n[n.BottomRight=9]="BottomRight",n))(ae||{}),wr=(n=>(n[n.OPTIMIZED_2D=0]="OPTIMIZED_2D",n[n.WIREFRAME=1]="WIREFRAME",n[n.HIDDEN_LINE=2]="HIDDEN_LINE",n[n.FLAT_SHADED=3]="FLAT_SHADED",n[n.GOURAUD_SHADED=4]="GOURAUD_SHADED",n[n.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",n[n.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",n))(wr||{}),fr=(n=>(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",n))(fr||{}),br=(n=>(n[n.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",n[n.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",n))(br||{});let Wo=class Go{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new f,this._height=0,this._width=0,this._viewCenter=new f,this._viewHeight=0}get number(){return this._number}set number(e){this._number=e}get id(){return this._id}set id(e){this._id=e}get groupId(){return this._groupId}set groupId(e){this._groupId=e}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint.copy(e)}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get box(){const e=new _e;return e.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),e}get viewCenter(){return this._viewCenter}set viewCenter(e){this._viewCenter.copy(e)}get viewHeight(){return this._viewHeight}set viewHeight(e){this._viewHeight=e}get viewWidth(){return this.viewHeight*(this.width/this.height)}get viewBox(){const e=new _e;return e.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),e}clone(){const e=new Go;return e.id=this.id,e.groupId=this.groupId,e.number=this.number,e.centerPoint.copy(this.centerPoint),e.height=this.height,e.width=this.width,e.viewCenter.copy(this.viewCenter),e.viewHeight=this.viewHeight,e}copy(e){return this.id=e.id,this.groupId=e.groupId,this.number=e.number,this.centerPoint.copy(e.centerPoint),this.height=e.height,this.width=e.width,this.viewCenter.copy(e.viewCenter),this.viewHeight=e.viewHeight,this}};const Yr=class Yr extends Be{constructor(){super(...arguments),this._visibility=!0,this._transparency=new ps}get type(){return this.constructor.typeName}get layer(){return this._layer==null&&(this._layer=this.database.clayer??"0"),this._layer}set layer(e){this._layer=e}get color(){return this._color==null&&(this._color=new z,this.database.cecolor&&this._color.copy(this.database.cecolor)),this._color}set color(e){this._color==null&&(this._color=new z),this._color.copy(e)}get resolvedColor(){var t;let e=this.color;if(e.isByLayer){const i=this.getLayerColor();i&&i.RGB!=null&&(e=i)}else if(e.isByBlock){const i=this.database.cecolor;if(i&&(e=i,e.isByLayer)){const s=this.database.clayer||this.layer,r=this.database.tables.layerTable.getAt(s);((t=r==null?void 0:r.color)==null?void 0:t.RGB)!=null&&(e=r.color)}}return e}get rgbColor(){const t=this.resolvedColor.RGB;return t??16777215}get lineType(){var e;return this._lineType==null&&(this._lineType=((e=this.database)==null?void 0:e.celtype)??de),this._lineType}set lineType(e){e?e.toUpperCase()==="BYLAYER"?this._lineType=de:e.toUpperCase()==="BYBLOCK"?this._lineType=Lt:this._lineType=e:this._lineType=de}get lineWeight(){return this._lineWeight==null&&(this._lineWeight=this.database.celweight??Qt.ByLayer),this._lineWeight}set lineWeight(e){this._lineWeight=e}get linetypeScale(){return this._linetypeScale==null&&(this._linetypeScale=this.database.celtscale??-1),this._linetypeScale}set linetypeScale(e){this._linetypeScale=e}get visibility(){return this._visibility}set visibility(e){this._visibility=e}get transparency(){return this._transparency}set transparency(e){this._transparency=e.clone()}dxfOutFields(e){e.writeSubclassMarker("AcDbEntity"),e.writeString(8,this.layer),e.writeString(6,this.lineType),e.writeDouble(48,this.linetypeScale),e.writeInt16(60,this.visibility?0:1),e.writeCmColor(this.color),e.writeInt16(370,this.lineWeight),e.writeTransparency(this.transparency);const t=this.database.tables.blockTable.getIdAt(this.ownerId);return t!=null&&t.isPaperSapce&&e.writeInt16(67,1),this}resolveEffectiveProperties(){this._layer==null&&(this._layer=this.database.clayer??"0"),this._color==null&&(this._color=new z,this.database.cecolor&&this._color.copy(this.database.cecolor)),this._lineType==null&&(this._lineType=this.database.celtype??de),this._linetypeScale==null&&(this._linetypeScale=this.database.celtscale??-1),this._lineWeight==null&&(this._lineWeight=this.database.celweight??Qt.ByLayer)}get properties(){return{type:this.type,groups:[this.getGeneralProperties()]}}subGetGripPoints(){return new Array}subGetOsnapPoints(e,t,i,s,r,a){}transformBy(e){return this}erase(){return this.database.tables.blockTable.removeEntity(this.objectId)}worldDraw(e,t){const i=e.subEntityTraits;i.color=this.resolvedColor,i.rgbColor=this.rgbColor,i.lineType=this.lineStyle,i.lineTypeScale=this.linetypeScale,i.lineWeight=this.lineWeight,i.transparency=this.transparency,i.layer=this.layer,i.drawOrder=0,"thickness"in this&&(i.thickness=this.thickness);const s=this.subWorldDraw(e,t);return this.attachEntityInfo(s),s}triggerModifiedEvent(){this.database.events.entityModified.dispatch({database:this.database,entity:this})}getGeneralProperties(){return{groupName:"general",properties:[{name:"handle",type:"int",editable:!1,accessor:{get:()=>this.objectId}},{name:"color",type:"color",editable:!0,accessor:{get:()=>this.color,set:e=>{this.color.copy(e)}}},{name:"layer",type:"string",editable:!0,accessor:{get:()=>this.layer,set:e=>{this.layer=e}}},{name:"linetype",type:"linetype",editable:!0,accessor:{get:()=>this.lineType,set:e=>{this.lineType=e}}},{name:"linetypeScale",type:"float",editable:!0,accessor:{get:()=>this.linetypeScale,set:e=>{this.linetypeScale=e}}},{name:"lineWeight",type:"lineweight",editable:!0,accessor:{get:()=>this.lineWeight,set:e=>{this.lineWeight=e}}},{name:"transparency",type:"transparency",editable:!0,accessor:{get:()=>this.transparency,set:e=>{this.transparency=e}}}]}}get lineStyle(){var s;const{type:e,name:t}=this.getLineType(),i=(s=this.database)==null?void 0:s.tables.linetypeTable.getAt(t);return i?{type:e,...i.linetype}:{type:e,name:t,standardFlag:0,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==de){const e=this.database.tables.layerTable.getAt(this.layer);if(e&&e.linetype)return{type:"ByLayer",name:e.linetype}}else return this.lineType==Lt?{type:"ByBlock",name:St}:{type:"UserSpecified",name:this.lineType};return{type:"UserSpecified",name:St}}getLayerColor(){const e=this.database.tables.layerTable.getAt(this.layer);return e!=null?e.color:null}attachEntityInfo(e){e&&(e.objectId=this.objectId,this.attrs.has("ownerId")&&(e.ownerId=this.ownerId),e.layerName=this.layer,e.visible=this.visibility)}};Yr.typeName="Entity";let le=Yr;const Xr=class Xr extends le{};Xr.typeName="Curve";let he=Xr;var ai=(n=>(n[n.SimplePoly=0]="SimplePoly",n[n.FitCurvePoly=1]="FitCurvePoly",n[n.QuadSplinePoly=2]="QuadSplinePoly",n[n.CubicSplinePoly=3]="CubicSplinePoly",n))(ai||{});const Rr=class Rr extends he{get dxfTypeName(){return"POLYLINE"}constructor(e,t,i=0,s=!1,r=0,a=0,o=null){super(),this._polyType=e,this._elevation=i;const h=o&&(o==null?void 0:o.length)===t.length,c=t.map((d,u)=>({x:d.x,y:d.y,bulge:h?o[u]:void 0}));this._geo=new oe(c,s)}get polyType(){return this._polyType}set polyType(e){this._polyType=e}get elevation(){return this._elevation}set elevation(e){this._elevation=e}get closed(){return this._geo.closed}set closed(e){this._geo.closed=e}get numberOfVertices(){return this._geo.numberOfVertices}getPointAt(e){return this._geo.getPointAt(e)}getBulgeAt(e){const t=this._geo.vertices[e];return(t==null?void 0:t.bulge)||0}get geometricExtents(){const e=this._geo.box;return new N({x:e.min.x,y:e.min.y,z:this._elevation},{x:e.max.x,y:e.max.y,z:this._elevation})}subGetGripPoints(){const e=new Array;for(let t=0;t<this._geo.numberOfVertices;++t){const i=this._geo.getPointAt(t);e.push(new f(i.x,i.y,0))}return e}subGetOsnapPoints(e,t,i,s){switch(e){case B.EndPoint:for(let r=0;r<this._geo.numberOfVertices;++r){const a=this._geo.getPointAt(r);s.push(new f(a.x,a.y,0))}break}}transformBy(e){const t=e.determinant()<0;let i=this._elevation;return this._geo.vertices.forEach(s=>{const r=new f(s.x,s.y,this._elevation).applyMatrix4(e);s.x=r.x,s.y=r.y,i=r.z,t&&s.bulge!=null&&(s.bulge=-s.bulge)}),this._elevation=i,this._geo._boundingBoxNeedsUpdate=!0,this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:e=>{this.elevation=e}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:e=>{this.closed=e}}}]}]}}subWorldDraw(e){const t=[];return this._geo.getPoints(100).forEach(s=>t.push(new f().set(s.x,s.y,this.elevation))),e.lines(t)}dxfOut(e,t=!1){super.dxfOut(e,t);for(let i=0;i<this.numberOfVertices;++i)e.writeStart("VERTEX"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity"),e.writeSubclassMarker("AcDbVertex"),e.writeSubclassMarker("AcDb2dVertex"),e.writePoint3d(10,{x:this.getPointAt(i).x,y:this.getPointAt(i).y,z:this.elevation}),e.writeDouble(42,this.getBulgeAt(i)),e.writeInt16(70,0);return e.writeStart("SEQEND"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity"),this}dxfOutFields(e){super.dxfOutFields(e),e.writeSubclassMarker("AcDb2dPolyline");let t=this.closed?1:0;return this.polyType===1&&(t|=2),this.polyType===2&&(t|=4),this.polyType===3&&(t|=8),e.writeInt16(66,this.numberOfVertices>0?1:0),e.writeInt16(70,t),e.writeDouble(10,0),e.writeDouble(20,0),e.writeDouble(30,this.elevation),this}};Rr.typeName="2dPolyline";let Xn=Rr;var Ho=(n=>(n[n.Vertex=0]="Vertex",n[n.CurveFitVertex=1]="CurveFitVertex",n[n.SplineFitVertex=8]="SplineFitVertex",n[n.SplineCtlVertex=9]="SplineCtlVertex",n))(Ho||{});const Br=class Br extends le{get dxfTypeName(){return"VERTEX"}constructor(){super(),this._position=new f,this._bulge=0,this._startWidth=0,this._endWidth=0,this._vertexType=0}get position(){return this._position}set position(e){this._position.copy(e)}get bulge(){return this._bulge}set bulge(e){this._bulge=e}get startWidth(){return this._startWidth}set startWidth(e){this._startWidth=e}get endWidth(){return this._endWidth}set endWidth(e){this._endWidth=e}get vertexType(){return this._vertexType}set vertexType(e){this._vertexType=e}get geometricExtents(){return new N().expandByPoint(this._position)}subGetGripPoints(){const e=new Array;return e.push(this._position),e}subGetOsnapPoints(e,t,i,s){s.push(this._position)}transformBy(e){return this._position.applyMatrix4(e),this}subWorldDraw(e){}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbVertex"),e.writeSubclassMarker("AcDb2dVertex"),e.writePoint2d(10,this.position),e.writeDouble(40,this.startWidth),e.writeDouble(41,this.endWidth),e.writeDouble(42,this.bulge),e.writeInt16(70,this.vertexType),this}};Br.typeName="2dVertex";let Us=Br;var Ri=(n=>(n[n.SimplePoly=0]="SimplePoly",n[n.QuadSplinePoly=1]="QuadSplinePoly",n[n.CubicSplinePoly=2]="CubicSplinePoly",n))(Ri||{});const Fr=class Fr extends he{get dxfTypeName(){return"POLYLINE"}constructor(e,t,i=!1){super(),this._polyType=e,this._geo=new oe(t,i)}get polyType(){return this._polyType}set polyType(e){this._polyType=e}get closed(){return this._geo.closed}set closed(e){this._geo.closed=e}get numberOfVertices(){return this._geo.numberOfVertices}getPointAt(e){const t=this._geo.vertices[e];return new f(t.x,t.y,t.z||0)}get geometricExtents(){const e=this._geo.vertices.map(t=>new f(t.x,t.y,t.z||0));return new N().setFromPoints(e)}subGetGripPoints(){const e=new Array;for(let t=0;t<this._geo.numberOfVertices;++t){const i=this._geo.getPointAt(t);e.push(new f(i.x,i.y,0))}return e}subGetOsnapPoints(e,t,i,s){switch(e){case B.EndPoint:for(let r=0;r<this._geo.numberOfVertices;++r)s.push(this.getPointAt(r));break}}transformBy(e){return this._geo.vertices.forEach(t=>{const i=new f(t.x,t.y,t.z||0).applyMatrix4(e);t.x=i.x,t.y=i.y,t.z=i.z}),this._geo._boundingBoxNeedsUpdate=!0,this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:e=>{this.closed=e}}}]}]}}subWorldDraw(e){const t=this._geo.vertices.map(i=>new f(i.x,i.y,i.z||0));return e.lines(t)}dxfOut(e,t=!1){super.dxfOut(e,t);for(let i=0;i<this.numberOfVertices;++i){const s=this.getPointAt(i);e.writeStart("VERTEX"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity"),e.writeSubclassMarker("AcDbVertex"),e.writeSubclassMarker("AcDb3dPolylineVertex"),e.writePoint3d(10,{x:s.x,y:s.y,z:s.z}),e.writeInt16(70,32)}return e.writeStart("SEQEND"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity"),this}dxfOutFields(e){super.dxfOutFields(e),e.writeSubclassMarker("AcDb3dPolyline");let t=this.closed?1:0;return t|=8,this.polyType===1&&(t|=16),this.polyType===2&&(t|=32),e.writeInt16(66,this.numberOfVertices>0?1:0),e.writeInt16(70,t),this}};Fr.typeName="3dPolyline";let Rn=Fr;var Uo=(n=>(n[n.SimpleVertex=0]="SimpleVertex",n[n.ControlVertex=1]="ControlVertex",n[n.FitVertex=2]="FitVertex",n))(Uo||{});const Dr=class Dr extends le{get dxfTypeName(){return"VERTEX"}constructor(){super(),this._position=new f,this._vertexType=0}get position(){return this._position}set position(e){this._position.copy(e)}get vertexType(){return this._vertexType}set vertexType(e){this._vertexType=e}get geometricExtents(){return new N().expandByPoint(this._position)}subGetGripPoints(){const e=new Array;return e.push(this._position),e}subGetOsnapPoints(e,t,i,s){s.push(this._position)}transformBy(e){return this._position.applyMatrix4(e),this}subWorldDraw(e){}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbVertex"),e.writeSubclassMarker("AcDb3dPolylineVertex"),e.writePoint3d(10,this.position),e.writeInt16(70,this.vertexType|32),this}};Dr.typeName="3dVertex";let $s=Dr;const zr=class zr extends he{get dxfTypeName(){return"ARC"}constructor(e,t,i,s,r=w.Z_AXIS){super();const a=yr(r);this._geo=new It(e,t,i,s,r,a)}get center(){return this._geo.center}set center(e){this._geo.center=e}get radius(){return this._geo.radius}set radius(e){this._geo.radius=e}get startAngle(){return this._geo.startAngle}set startAngle(e){this._geo.startAngle=e}get endAngle(){return this._geo.endAngle}set endAngle(e){this._geo.endAngle=e}get normal(){return this._geo.normal}set normal(e){this._geo.normal=e}get startPoint(){return this._geo.startPoint}get endPoint(){return this._geo.endPoint}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:e=>{this.center.x=e}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:e=>{this.center.y=e}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:e=>{this.center.z=e}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:e=>{this.radius=e}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:e=>{this.startAngle=e}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:e=>{this.endAngle=e}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:e=>{this.normal.x=e}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:e=>{this.normal.y=e}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:e=>{this.normal.z=e}}},{name:"arcLength",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"totalAngle",type:"float",editable:!1,accessor:{get:()=>k.radToDeg(Math.abs(this._geo.deltaAngle))}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subGetGripPoints(){const e=new Array;return e.push(this.center),e.push(this.startPoint),e.push(this.endPoint),e}subGetOsnapPoints(e,t,i,s){const r=this.startPoint,a=this.endPoint;switch(e){case B.EndPoint:s.push(r),s.push(a);break;case B.MidPoint:s.push(this.midPoint);break;case B.Nearest:{const o=this._geo.nearestPoint(t);s.push(o)}break;case B.Perpendicular:break;case B.Tangent:{const o=this._geo.tangentPoints(t);s.push(...o);break}}}transformBy(e){return this._geo.transform(e),this}subWorldDraw(e){return e.circularArc(this._geo)}dxfOutFields(e){super.dxfOutFields(e);const t=ji(this.center,this.normal);return e.writeSubclassMarker("AcDbArc"),e.writePoint3d(10,t),e.writeDouble(40,this.radius),e.writeAngle(50,Gs(this.center,this.startPoint,this.normal)),e.writeAngle(51,Gs(this.center,this.endPoint,this.normal)),e.writeVector3d(210,this.normal),this}};zr.typeName="Arc";let Bn=zr;var $o=(n=>(n[n.LEFT=0]="LEFT",n[n.CENTER=1]="CENTER",n[n.RIGHT=2]="RIGHT",n[n.ALIGNED=3]="ALIGNED",n[n.MIDDLE=4]="MIDDLE",n[n.FIT=5]="FIT",n))($o||{}),qo=(n=>(n[n.BASELINE=0]="BASELINE",n[n.BOTTOM=1]="BOTTOM",n[n.MIDDLE=2]="MIDDLE",n[n.TOP=3]="TOP",n))(qo||{});const Vr=class Vr extends le{get dxfTypeName(){return"TEXT"}constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new f,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=2,this._styleName="",this._widthFactor=1}get textString(){return this._textString}set textString(e){this._textString=e}get thickness(){return this._thickness}set thickness(e){this._thickness=e}get height(){return this._height}set height(e){this._height=e}get position(){return this._position}set position(e){this._position.copy(e)}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get oblique(){return this._oblique}set oblique(e){this._oblique=e}get horizontalMode(){return this._horizontalMode}set horizontalMode(e){this._horizontalMode=e}get verticalMode(){return this._verticalModel}set verticalMode(e){this._verticalModel=e}get styleName(){return this._styleName}set styleName(e){this._styleName=e}get widthFactor(){return this._widthFactor}set widthFactor(e){this._widthFactor=e}get geometricExtents(){return new N}subGetOsnapPoints(e,t,i,s){B.Insertion===e&&s.push(this._position)}transformBy(e){const t=this._position.clone(),i=this._position.clone().add(new w(Math.cos(this._rotation),Math.sin(this._rotation),0)),s=this._position.clone().add(new w(-Math.sin(this._rotation),Math.cos(this._rotation),0)),r=this._position.clone().add(new w(0,0,1));t.applyMatrix4(e),i.applyMatrix4(e),s.applyMatrix4(e),r.applyMatrix4(e);const a=new w(i).sub(t),o=new w(s).sub(t),h=new w(r).sub(t),c=o.length(),d=a.length(),u=h.length();return this._position.copy(t),d>0&&(this._rotation=Math.atan2(a.y,a.x)),c>0&&(this._height*=c,d>0&&(this._widthFactor*=d/c)),u>0&&(this._thickness*=u),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.textString,set:e=>{this.textString=e}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:e=>{this.styleName=e}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:e=>{this.height=e}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:e=>{this.rotation=e}}},{name:"widthFactor",type:"float",editable:!0,accessor:{get:()=>this.widthFactor,set:e=>{this.widthFactor=e}}},{name:"oblique",type:"float",editable:!0,accessor:{get:()=>this.oblique,set:e=>{this.oblique=e}}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:e=>{this.position.x=e}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:e=>{this.position.y=e}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:e=>{this.position.z=e}}}]}]}}getTextStyle(){const e=this.database.tables.textStyleTable,t=e.getAt(this.styleName)??e.getAt(this.database.textstyle)??e.getAt(Z);if(!t)throw new Error("No valid text style found in text style table.");return t.textStyle}subWorldDraw(e,t){const i={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:ze.BOTTOM_TO_TOP,attachmentPoint:ae.BottomLeft};return e.mtext(i,this.getTextStyle(),t)}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbText"),e.writePoint3d(10,this.position),e.writeDouble(39,this.thickness),e.writeDouble(40,this.height),e.writeString(1,this.textString),e.writeAngle(50,this.rotation),e.writeDouble(41,this.widthFactor),e.writeAngle(51,this.oblique),e.writeString(7,this.styleName),e.writeInt16(72,this.horizontalMode),e.writeInt16(73,this.verticalMode),e.writePoint3d(11,this.position),this}};Vr.typeName="Text";let di=Vr;var ee=(n=>(n[n.Invisible=1]="Invisible",n[n.Const=2]="Const",n[n.Verifiable=4]="Verifiable",n[n.Preset=8]="Preset",n))(ee||{}),Ve=(n=>(n[n.MultiLine=2]="MultiLine",n[n.ConstMultiLine=4]="ConstMultiLine",n))(Ve||{});const jr=class jr extends di{get dxfTypeName(){return"ATTDEF"}constructor(){super(),this._flags=0,this._prompt="",this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&1)!==0}set isInvisible(e){e?this._flags|=1:this._flags&=-2}get prompt(){return this._prompt}set prompt(e){this._prompt=e}get isConst(){return(this._flags&2)!==0}set isConst(e){e?this._flags|=2:this._flags&=-3}get isVerifiable(){return(this._flags&4)!==0}set isVerifiable(e){e?this._flags|=4:this._flags&=-5}get isPreset(){return(this._flags&8)!==0}set isPreset(e){e?this._flags|=8:this._flags&=-9}get isMTextAttribute(){return(this._mtextFlag&2)!==0}set isMTextAttribute(e){e?this._mtextFlag|=2:this._mtextFlag&=-3}get isConstMTextAttribute(){return(this._mtextFlag&4)!==0}set isConstMTextAttribute(e){e?this._mtextFlag|=4:this._mtextFlag&=-5}get tag(){return this._tag}set tag(e){this._tag=e}get fieldLength(){return this._fieldLength}set fieldLength(e){this._fieldLength=e}get lockPositionInBlock(){return this._lockPositionInBlock}set lockPositionInBlock(e){this._lockPositionInBlock=e}get isReallyLocked(){return this._isReallyLocked}set isReallyLocked(e){this._isReallyLocked=e}get mtext(){return this._mtext}set mtext(e){this._mtext=e,this.isMTextAttribute=e!=null}subWorldDraw(e){}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbAttributeDefinition"),e.writeString(3,this.prompt),e.writeString(2,this.tag),e.writeInt16(70,this.isInvisible?1:0),e.writeInt16(73,this.fieldLength),e.writeInt16(74,this.isReallyLocked?1:0),this}};jr.typeName="AttDef";let Fn=jr;const Wr=class Wr extends di{get dxfTypeName(){return"ATTRIB"}constructor(){super(),this._flags=0,this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&ee.Invisible)!==0}set isInvisible(e){e?this._flags|=ee.Invisible:this._flags&=~ee.Invisible}get isConst(){return(this._flags&ee.Const)!==0}set isConst(e){e?this._flags|=ee.Const:this._flags&=~ee.Const}get isVerifiable(){return(this._flags&ee.Verifiable)!==0}set isVerifiable(e){e?this._flags|=ee.Verifiable:this._flags&=~ee.Verifiable}get isPreset(){return(this._flags&ee.Preset)!==0}set isPreset(e){e?this._flags|=ee.Preset:this._flags&=~ee.Preset}get isMTextAttribute(){return(this._mtextFlag&Ve.MultiLine)!==0}set isMTextAttribute(e){e?this._mtextFlag|=Ve.MultiLine:this._mtextFlag&=~Ve.MultiLine}get isConstMTextAttribute(){return(this._mtextFlag&Ve.ConstMultiLine)!==0}set isConstMTextAttribute(e){e?this._mtextFlag|=Ve.ConstMultiLine:this._mtextFlag&=~Ve.ConstMultiLine}get tag(){return this._tag}set tag(e){this._tag=e}get fieldLength(){return this._fieldLength}set fieldLength(e){this._fieldLength=e}get lockPositionInBlock(){return this._lockPositionInBlock}set lockPositionInBlock(e){this._lockPositionInBlock=e}get isReallyLocked(){return this._isReallyLocked}set isReallyLocked(e){this._isReallyLocked=e}get mtext(){return this._mtext}set mtext(e){this._mtext=e,this.isMTextAttribute=e!=null}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbAttribute"),e.writeInt16(70,this.isInvisible?1:0),e.writeInt16(73,this.fieldLength),e.writeString(2,this.tag),e.writeInt16(74,this.isReallyLocked?1:0),this.mtext&&e.writeInt16(71,this.isMTextAttribute?1:0),this}};Wr.typeName="Attrib";let Dn=Wr;const zi=class zi extends le{get dxfTypeName(){return"INSERT"}constructor(e){super(),this._blockName=e,this._position=new f,this._rotation=0,this._normal=new w(0,0,1),this._scaleFactors=new f(1,1,1),this._attribs=new Map}get position(){return this._position}set position(e){this._position.copy(e)}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get scaleFactors(){return this._scaleFactors}set scaleFactors(e){this._scaleFactors.copy(e)}get normal(){return this._normal}set normal(e){this._normal.copy(e).normalize()}get blockName(){return this._blockName}get blockTableRecord(){return this.database.tables.blockTable.getAt(this._blockName)}appendAttributes(e){this._attribs.set(e.objectId,e),e.ownerId=this.objectId}attributeIterator(){return new an(this._attribs)}get blockTransform(){const e=this.blockTableRecord,t=(e==null?void 0:e.origin)??f.ORIGIN,i=new D().makeTranslation(-t.x,-t.y,-t.z),s=new D().makeScale(this._scaleFactors.x,this._scaleFactors.y,this._scaleFactors.z),r=new ni().setFromAxisAngle(w.Z_AXIS,this._rotation),a=new D().makeRotationFromQuaternion(r),o=new D().makeTranslation(this._position.x,this._position.y,this._position.z);return new D().multiplyMatrices(o,a).multiply(s).multiply(i)}subGetOsnapPoints(e,t,i,s,r,a){const o=a??new D;B.Insertion===e?s.push(this.getInsertionPoint(o)):r&&this.subEntityGetOsnapPoints(e,t,i,s,r,o)}transformBy(e){const t=new D().setFromExtrusionDirection(this._normal),i=new D().makeRotationZ(this._rotation),s=new D().multiplyMatrices(t,i),r=this._position.clone(),a=new f(this._scaleFactors.x,0,0).applyMatrix4(s).add(r),o=new f(0,this._scaleFactors.y,0).applyMatrix4(s).add(r),h=new f(0,0,this._scaleFactors.z).applyMatrix4(s).add(r);r.applyMatrix4(e),a.applyMatrix4(e),o.applyMatrix4(e),h.applyMatrix4(e);const c=new w(a).sub(r),d=new w(o).sub(r),u=new w(h).sub(r);let p=new w().crossVectors(c,d);p.lengthSq()===0?p=this._normal.clone().transformDirection(e):p.normalize();const m=new D().setFromExtrusionDirection(p).clone().invert(),y=c.clone().applyMatrix4(m);return this._position.copy(r),this._normal.copy(p),this._rotation=Math.atan2(y.y,y.x),this._scaleFactors.set(c.length(),d.length(),u.length()),this._attribs.forEach(x=>x.transformBy(e)),this}get properties(){const e={type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"blockName",type:"float",editable:!1,accessor:{get:()=>this._blockName}},{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"scaleFactorsX",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.x,set:t=>{this.scaleFactors.x=t}}},{name:"scaleFactorsY",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.y,set:t=>{this.scaleFactors.y=t}}},{name:"scaleFactorsZ",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.z,set:t=>{this.scaleFactors.z=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}}]}]};if(this._attribs.size>0){const t={groupName:"attribute",properties:[]};e.groups.push(t),this._attribs.forEach(i=>{t.properties.push({name:i.tag,type:"string",editable:!i.isConst,skipTranslation:!0,accessor:{get:()=>i.textString,set:s=>{i.textString=s}}})})}return e}get geometricExtents(){const e=new N,t=this.blockTableRecord;if(t!=null){const s=t.newIterator();for(const r of s)e.union(r.geometricExtents)}const i=this.blockTransform;return e.applyMatrix4(i),e}subWorldDraw(e){const t=this.blockTableRecord;if(t!=null){const i=this.blockTransform,s=[];return this._attribs.forEach(a=>{if(!a.isInvisible){const o=a.worldDraw(e);o&&s.push(o)}}),ii.instance.draw(e,t,this.rgbColor,s,!0,i,this._normal)}else return e.group([])}dxfOut(e,t=!1){super.dxfOut(e,t);let i=!1;for(const s of this.attributeIterator())i=!0,e.writeStart("ATTRIB"),s.dxfOut(e);return i&&(e.writeStart("SEQEND"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity")),this}subEntityGetOsnapPoints(e,t,i,s,r,a,o=new Set){if(r===this.objectId||o.has(this.objectId))return!1;o.add(this.objectId);try{const h=this.blockTableRecord;if(h==null)return!1;const c=new D().multiplyMatrices(a,this.getFullInsertionTransform());for(const d of h.newIterator()){if(d.objectId===r){const u=new f(t).applyMatrix4(c.clone().invert()),p=new f(i).applyMatrix4(c.clone().invert()),g=[];return d.subGetOsnapPoints(e,u,p,g,r,c),d instanceof zi?g.forEach(m=>{s.push(m.clone())}):g.forEach(m=>{s.push(new f(m).applyMatrix4(c))}),!0}if(d instanceof zi&&d.subEntityGetOsnapPoints(e,t,i,s,r,c,o))return!0}return!1}finally{o.delete(this.objectId)}}getInsertionPoint(e){var s;const t=((s=this.blockTableRecord)==null?void 0:s.origin)??f.ORIGIN,i=new D().multiplyMatrices(e,this.getFullInsertionTransform());return new f(t).applyMatrix4(i)}getFullInsertionTransform(){const e=new D().setFromExtrusionDirection(this._normal);return new D().multiplyMatrices(e,this.blockTransform)}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbBlockReference"),e.writePoint3d(10,this.position),e.writeString(2,this.blockName),e.writeDouble(41,this.scaleFactors.x),e.writeDouble(42,this.scaleFactors.y),e.writeDouble(43,this.scaleFactors.z),e.writeAngle(50,this.rotation),e.writeVector3d(210,this.normal),this}};zi.typeName="BlockReference";let ei=zi;const Gr=class Gr extends he{get dxfTypeName(){return"CIRCLE"}constructor(e,t,i=w.Z_AXIS){super();const s=yr(i);this._geo=new It(e,t,0,W,i,s)}get center(){return this._geo.center}set center(e){this._geo.center=e}get radius(){return this._geo.radius}set radius(e){this._geo.radius=e}get normal(){return this._geo.normal}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetOsnapPoints(e,t,i,s){switch(e){case B.Center:case B.Centroid:s.push(this._geo.center);break;case B.Quadrant:s.push(this._geo.getPointAtAngle(0)),s.push(this._geo.getPointAtAngle(Math.PI/2)),s.push(this._geo.getPointAtAngle(Math.PI)),s.push(this._geo.getPointAtAngle(Math.PI/2*3));break;case B.Nearest:{const r=this._geo.nearestPoint(t);s.push(r)}break;case B.Tangent:{const r=this._geo.tangentPoints(t);s.push(...r);break}}}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:e=>{this.center.x=e}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:e=>{this.center.y=e}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:e=>{this.center.z=e}}},{name:"radius",type:"float",editable:!0,accessor:{get:()=>this.radius,set:e=>{this.radius=e}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:e=>{this.normal.x=e}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:e=>{this.normal.y=e}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:e=>{this.normal.z=e}}},{name:"diameter",type:"float",editable:!1,accessor:{get:()=>this._geo.radius*2}},{name:"perimeter",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subGetGripPoints(){const e=new Array;return e.push(this.center),e}transformBy(e){return this._geo.transform(e),this}subWorldDraw(e){return e.circularArc(this._geo)}dxfOutFields(e){super.dxfOutFields(e);const t=ji(this.center,this.normal);return e.writeSubclassMarker("AcDbCircle"),e.writePoint3d(10,t),e.writeDouble(40,this.radius),e.writeVector3d(210,this.normal),this}};Gr.typeName="Circle";let zn=Gr;const Hr=class Hr extends he{get dxfTypeName(){return"ELLIPSE"}constructor(e,t,i,s,r,a,o){super(),this._geo=new hi(e,t,i,s,r,a,o)}get center(){return this._geo.center}set center(e){this._geo.center=e}get majorAxisRadius(){return this._geo.majorAxisRadius}set majorAxisRadius(e){this._geo.majorAxisRadius=e}get minorAxisRadius(){return this._geo.minorAxisRadius}set minorAxisRadius(e){this._geo.minorAxisRadius=e}get startAngle(){return this._geo.startAngle}set startAngle(e){this._geo.startAngle=e}get endAngle(){return this._geo.endAngle}set endAngle(e){this._geo.endAngle=e}get normal(){return this._geo.normal}set normal(e){this._geo.normal=e}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}subGetOsnapPoints(e,t,i,s){switch(e){case B.EndPoint:this.closed||(s.push(this._geo.startPoint),s.push(this._geo.endPoint));break;case B.MidPoint:this.closed||s.push(this._geo.midPoint);break;case B.Quadrant:this.closed&&(s.push(this._geo.getPointAtAngle(0)),s.push(this._geo.getPointAtAngle(Math.PI/2)),s.push(this._geo.getPointAtAngle(Math.PI)),s.push(this._geo.getPointAtAngle(Math.PI/2*3)));break}}transformBy(e){return this._geo.transform(e),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:e=>{this.center.x=e}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:e=>{this.center.y=e}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:e=>{this.center.z=e}}},{name:"majorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.majorAxisRadius,set:e=>{this.center.x=e}}},{name:"minorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.minorAxisRadius,set:e=>{this.minorAxisRadius=e}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:e=>{this.startAngle=e}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:e=>{this.endAngle=e}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:e=>{this.normal.x=e}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:e=>{this.normal.y=e}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:e=>{this.normal.z=e}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this._geo.area}}]}]}}subWorldDraw(e){return e.ellipticalArc(this._geo)}dxfOutFields(e){super.dxfOutFields(e),e.writeSubclassMarker("AcDbEllipse"),e.writePoint3d(10,this.center);const t=this._geo.majorAxis,i=this.majorAxisRadius;return e.writePoint3d(11,{x:t.x*i,y:t.y*i,z:t.z*i}),e.writeVector3d(210,this.normal),e.writeDouble(40,this.minorAxisRadius/this.majorAxisRadius),e.writeDouble(41,this.startAngle),e.writeDouble(42,this.endAngle),this}};Hr.typeName="Ellipse";let Vn=Hr;const Ur=class Ur extends le{get dxfTypeName(){return"3DFACE"}constructor(){super(),this._vertices=[new f,new f,new f],this._edgeInvisibilities=0}getVertexAt(e){return e<0?this._vertices[0]:e>this._vertices.length?this._vertices[this._vertices.length-1]:this._vertices[e]}setVertexAt(e,t){if(e<0&&this._vertices[0].copy(t),e>=3)return this._vertices.length===3&&this._vertices.push(new f),this._vertices[3].copy(t);this._vertices[e].copy(t)}setEdgeInvisibilities(e){this._edgeInvisibilities=e}isEdgeVisibleAt(e){if(e<0||e>3)throw new Error("Index out of range");return(this._edgeInvisibilities&1<<e)===0}makeEdgeInvisibleAt(e){if(e<0||e>3)throw new Error("Index out of range");this._edgeInvisibilities=this._edgeInvisibilities|1<<e}get geometricExtents(){return new N().setFromPoints(this._vertices)}subGetGripPoints(){const e=new Array;return e.push(...this._vertices),e}subGetOsnapPoints(e,t,i,s){switch(e){case B.EndPoint:s.push(...this._vertices);break}}transformBy(e){return this._vertices.forEach(t=>t.applyMatrix4(e)),this}subWorldDraw(e){const t=this._vertices.length,i=new Float32Array(t*3),s=new Uint16Array(t*2);for(let r=0;r<t;r++)i[r*3]=this._vertices[r].x,i[r*3+1]=this._vertices[r].y,i[r*3+2]=this._vertices[r].z,this.isEdgeVisibleAt(r)&&(s[r*2]=r,s[r*2+1]=(r+1)%4);return e.lineSegments(i,3,s)}dxfOutFields(e){super.dxfOutFields(e);const t=this.getVertexAt(0),i=this.getVertexAt(1),s=this.getVertexAt(2),r=this.getVertexAt(3);e.writeSubclassMarker("AcDbFace"),e.writePoint3d(10,t),e.writePoint3d(11,i),e.writePoint3d(12,s),e.writePoint3d(13,r);let a=0;for(let o=0;o<4;++o)this.isEdgeVisibleAt(o)||(a|=1<<o);return e.writeInt16(70,a),this}};Ur.typeName="Face";let jn=Ur;var Bi=(n=>(n[n.UserDefined=0]="UserDefined",n[n.Predefined=1]="Predefined",n[n.Custom=2]="Custom",n))(Bi||{}),Zo=(n=>(n[n.Normal=0]="Normal",n[n.Outer=1]="Outer",n[n.Ignore=2]="Ignore",n))(Zo||{}),Lr=(n=>(n[n.HatchObject=0]="HatchObject",n[n.GradientObject=1]="GradientObject",n))(Lr||{}),Ko=(n=>(n[n.PreDefinedGradient=0]="PreDefinedGradient",n[n.UserDefinedGradient=1]="UserDefinedGradient",n))(Ko||{});const $r=class $r extends le{constructor(){super(),this._gradientAngle=0,this._elevation=0,this._geo=new Pt,this._isSolidFill=!1,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=0,this._hatchObjectType=0,this._gradientAngle=0,this._gradientShift=0,this._shadeTintValue=0,this._gradientStartColor=void 0,this._gradientEndColor=void 0,this._gradientType=0,this._gradientName="",this._gradientOneColorMode=!1}get dxfTypeName(){return"HATCH"}get isGradient(){return this._hatchObjectType===1}get isHatch(){return this._hatchObjectType===0}get isSolidFill(){return this._isSolidFill||this._patternName.toUpperCase()==="SOLID"}set isSolidFill(e){this._isSolidFill=e}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(e){this._patternName=e}get patternType(){return this._patternType}set patternType(e){this._patternType=e}get patternAngle(){return this._patternAngle}set patternAngle(e){this._patternAngle=e}get patternScale(){return this._patternScale}set patternScale(e){this._patternScale=e}get hatchStyle(){return this._hatchStyle}set hatchStyle(e){this._hatchStyle=e}get elevation(){return this._elevation}set elevation(e){this._elevation=e}get hatchObjectType(){return this._hatchObjectType}set hatchObjectType(e){this._hatchObjectType=e}get gradientAngle(){return this._gradientAngle}set gradientAngle(e){this._gradientAngle=e}get gradientShift(){return this._gradientShift}set gradientShift(e){this._gradientShift=e}get gradientType(){return this._gradientType}set gradientType(e){this._gradientType=e}get gradientName(){return this._gradientName}set gradientName(e){this._gradientName=e}get gradientOneColorMode(){return this._gradientOneColorMode}set gradientOneColorMode(e){this._gradientOneColorMode=e}get shadeTintValue(){return this._shadeTintValue}set shadeTintValue(e){this._shadeTintValue=e}get gradientStartColor(){return this._gradientStartColor}set gradientStartColor(e){this._gradientStartColor=e==null||!Number.isFinite(e)?void 0:e&16777215}get gradientEndColor(){return this._gradientEndColor}set gradientEndColor(e){this._gradientEndColor=e==null||!Number.isFinite(e)?void 0:e&16777215}add(e){this._geo.add(e)}buildAreasFromLoops(){const e=this._geo.loops;if(e.length===0)return[];if(e.length===1)return[this._geo];const t=this._geo.buildHierarchy(),i=[],s=(r,a)=>{if(r.index>=0&&a%2===0){const o=new Pt;o.add(e[r.index]),r.children.forEach(h=>{h.index>=0&&o.add(e[h.index])}),i.push(o)}r.children.forEach(o=>s(o,a+1))};return t.children.forEach(r=>s(r,0)),i.length>0?i:[this._geo]}getCalculatedAreaValue(){const e=this.buildAreasFromLoops();return e.length===0?0:e.reduce((t,i)=>t+i.area,0)}get geometricExtents(){const e=this.buildAreasFromLoops();if(e.length===0)return new N;const t=new N;return e.forEach(i=>{const s=i.box;t.union(new N({x:s.min.x,y:s.min.y,z:this._elevation},{x:s.max.x,y:s.max.y,z:this._elevation}))}),t}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"pattern",properties:[{name:"patternType",type:"enum",editable:!0,options:[{label:Bi[0],value:0},{label:Bi[1],value:1},{label:Bi[2],value:2}],accessor:{get:()=>this.patternType,set:e=>{this.patternType=e}}},{name:"patternName",type:"string",editable:!0,accessor:{get:()=>this.patternName,set:e=>{this.patternName=e}}},{name:"patternAngle",type:"float",editable:!0,accessor:{get:()=>this.patternAngle,set:e=>{this.patternAngle=e}}},{name:"patternScale",type:"float",editable:!0,accessor:{get:()=>this.patternScale,set:e=>{this.patternScale=e}}}]},{groupName:"geometry",properties:[{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:e=>{this.elevation=e}}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this.getCalculatedAreaValue()}}]}]}}subWorldDraw(e){const t=e.subEntityTraits;t.fillType={solidFill:this.isSolidFill,patternAngle:this.patternAngle,definitionLines:this.definitionLines,gradient:this.isGradient?{name:this.gradientName,angle:this.gradientAngle,shift:this.gradientShift,oneColorMode:this.gradientOneColorMode,shadeTintValue:this.shadeTintValue,startColor:this.gradientStartColor,endColor:this.gradientEndColor}:void 0},t.drawOrder=-1;const i=this.buildAreasFromLoops();if(i.length===0)return e.area(this._geo);if(i.length===1)return e.area(i[0]);const s=i.map(r=>e.area(r));return e.group(s)}transformBy(e){const t=e.elements,i=new en(t[0],t[4],t[12],t[1],t[5],t[13],0,0,1);this._geo.transform(i),this._elevation=new f(0,0,this._elevation).applyMatrix4(e).z;const s=new f(1,0,0).applyMatrix4(e),r=new f().applyMatrix4(e),a=new f(s).sub(r);if(a.length()>0){const o=Math.atan2(a.y,a.x);this._patternAngle+=o,this._gradientAngle+=o,this._patternScale*=a.length()}return this}dxfOutFields(e){super.dxfOutFields(e);const t=this._geo.loops;return e.writeSubclassMarker("AcDbHatch"),e.writePoint3d(10,{x:0,y:0,z:this.elevation}),e.writeVector3d(210,{x:0,y:0,z:1}),e.writeString(2,this.patternName||(this.isSolidFill?"SOLID":"USER")),e.writeInt16(70,this.isSolidFill?1:0),e.writeInt16(71,0),e.writeInt16(91,t.length),t.forEach((i,s)=>{const r=s===0;if(i instanceof oe){const a=i.vertices,o=a.some(c=>(c.bulge??0)!==0);e.writeInt16(92,2),e.writeInt16(72,o?1:0),e.writeInt16(73,i.closed?1:0),e.writeInt16(93,a.length);for(const c of a)e.writePoint2d(10,c),o&&e.writeDouble(42,c.bulge??0);e.writeInt16(97,0);return}if(i instanceof Gi){const a=r?1:0;e.writeInt16(92,a),e.writeInt16(93,i.numberOfEdges);for(const o of i.curves){if(o instanceof je){e.writeInt16(72,1),e.writePoint2d(10,o.startPoint),e.writePoint2d(11,o.endPoint);continue}if(o instanceof Et){e.writeInt16(72,2),e.writePoint2d(10,o.center),e.writeDouble(40,o.radius),e.writeAngle(50,o.startAngle),e.writeAngle(51,o.endAngle),e.writeInt16(73,o.clockwise?0:1);continue}if(o instanceof Wi){e.writeInt16(72,3),e.writePoint2d(10,o.center);const h=new v(o.majorAxisRadius*Math.cos(o.rotation),o.majorAxisRadius*Math.sin(o.rotation));e.writePoint2d(11,h);const c=o.majorAxisRadius===0?0:o.minorAxisRadius/o.majorAxisRadius;e.writeDouble(40,c),e.writeAngle(50,o.startAngle),e.writeAngle(51,o.endAngle),e.writeInt16(73,o.clockwise?0:1);continue}if(o instanceof We){const h=o.knots,c=o.controlPoints,d=o.weights,u=o.fitPoints,p=d.some(g=>g!==1);e.writeInt16(72,4),e.writeInt16(94,o.degree),e.writeInt16(73,p?1:0),e.writeInt16(74,o.closed?1:0),e.writeInt16(95,h.length),e.writeInt16(96,c.length),h.forEach(g=>e.writeDouble(40,g)),c.forEach((g,m)=>{e.writePoint2d(10,g),p&&e.writeDouble(42,d[m]??1)}),e.writeInt16(97,(u==null?void 0:u.length)??0),u==null||u.forEach(g=>e.writePoint2d(11,g))}}e.writeInt16(97,0)}}),e.writeInt16(75,this.hatchStyle),e.writeInt16(76,this.patternType),e.writeAngle(52,this.patternAngle),e.writeDouble(41,this.patternScale),e.writeInt16(77,0),e.writeInt16(78,this.definitionLines.length),this.definitionLines.forEach(i=>{e.writeAngle(53,i.angle),e.writePoint2d(43,i.base),e.writePoint2d(45,i.offset),e.writeInt16(79,i.dashLengths.length),i.dashLengths.forEach(s=>e.writeDouble(49,s))}),this.isGradient&&(e.writeInt16(450,this._hatchObjectType),e.writeInt16(451,0),e.writeInt16(452,this._gradientOneColorMode?1:0),e.writeAngle(460,this._gradientAngle),e.writeDouble(461,this._gradientShift),e.writeString(470,this._gradientName)),e.writeInt16(98,0),this}};$r.typeName="Hatch";let Hi=$r;var Jo=(n=>(n[n.MText=0]="MText",n[n.Fcf=1]="Fcf",n[n.BlockReference=2]="BlockReference",n[n.NoAnnotation=3]="NoAnnotation",n))(Jo||{});const qr=class qr extends he{get dxfTypeName(){return"LEADER"}constructor(){super(),this._isSplined=!1,this._updated=!1,this._hasArrowHead=!1,this._vertices=[],this._dimensionStyle="",this._hasHookLine=!1,this._isHookLineSameDirection=!1,this._annoType=3,this._textHeight=0,this._textWidth=0,this._associatedAnnotation="",this._normal=new w(0,0,1),this._horizontalDirection=new w(1,0,0)}get isSplined(){return this._isSplined}set isSplined(e){this._isSplined=e}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(e){this._hasArrowHead=e}get hasHookLine(){return this._hasHookLine}set hasHookLine(e){this._hasHookLine=e}get isHookLineSameDirection(){return this._isHookLineSameDirection}set isHookLineSameDirection(e){this._isHookLineSameDirection=e}get numVertices(){return this._vertices.length}get vertices(){return this._vertices.map(e=>e.clone())}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(e){this._dimensionStyle=e}get annoType(){return this._annoType}set annoType(e){this._annoType=e}get textHeight(){return this._textHeight}set textHeight(e){this._textHeight=e}get textWidth(){return this._textWidth}set textWidth(e){this._textWidth=e}get byBlockColor(){return this._byBlockColor}set byBlockColor(e){this._byBlockColor=e}get associatedAnnotation(){return this._associatedAnnotation}set associatedAnnotation(e){this._associatedAnnotation=e}get normal(){return this._normal}set normal(e){this._normal.copy(e)}get horizontalDirection(){return this._horizontalDirection}set horizontalDirection(e){this._horizontalDirection.copy(e)}get offsetFromBlock(){var e;return(e=this._offsetFromBlock)==null?void 0:e.clone()}set offsetFromBlock(e){this._offsetFromBlock=e?new w(e):void 0}get offsetFromAnnotation(){var e;return(e=this._offsetFromAnnotation)==null?void 0:e.clone()}set offsetFromAnnotation(e){this._offsetFromAnnotation=e?new w(e):void 0}appendVertex(e){this._vertices.push(new f().copy(e)),this._updated=!0}setVertexAt(e,t){if(e<0||e>=this._vertices.length)throw new Error("The vertex index is out of range!");return this._vertices[e].copy(t),this._updated=!0,this}vertexAt(e){if(e<0||e>=this._vertices.length)throw new Error("The vertex index is out of range!");return this._vertices[e].clone()}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new N().setFromPoints(this._vertices)}get closed(){return!1}set closed(e){}transformBy(e){return this._vertices.forEach(t=>t.applyMatrix4(e)),this.transformVector(this._normal,e),this.transformVector(this._horizontalDirection,e),this._offsetFromBlock&&this.transformVector(this._offsetFromBlock,e),this._offsetFromAnnotation&&this.transformVector(this._offsetFromAnnotation,e),this._splineGeo?(this._splineGeo.transform(e),this._updated=!1):this._updated=!0,this}subWorldDraw(e){if(this.isSplined&&this.splineGeo){const t=this.splineGeo.getPoints(100);return e.lines(t)}else return e.lines(this._vertices)}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new We(this._vertices,"Uniform"),this._updated=!1)}dxfOutFields(e){super.dxfOutFields(e),e.writeSubclassMarker("AcDbLeader"),e.writeString(3,this.dimensionStyle),e.writeInt16(71,this.hasArrowHead?1:0),e.writeInt16(72,this.isSplined?1:0),e.writeInt16(73,this.annoType),e.writeInt16(74,this.isHookLineSameDirection?1:0),e.writeInt16(75,this.hasHookLine?1:0),e.writeInt16(76,this.numVertices),this.textHeight!==0&&e.writeDouble(40,this.textHeight),this.textWidth!==0&&e.writeDouble(41,this.textWidth),this.byBlockColor!=null&&e.writeInt16(77,this.byBlockColor),this.associatedAnnotation&&e.writeHandle(340,this.associatedAnnotation);for(const t of this.vertices)e.writePoint3d(10,t);return e.writeVector3d(210,this.normal),e.writeVector3d(211,this.horizontalDirection),this._offsetFromBlock&&e.writeVector3d(212,this._offsetFromBlock),this._offsetFromAnnotation&&e.writeVector3d(213,this._offsetFromAnnotation),this}transformVector(e,t){const i=new f,s=new f(e.x,e.y,e.z);i.applyMatrix4(t),s.applyMatrix4(t),e.set(s.x-i.x,s.y-i.y,s.z-i.z)}};qr.typeName="Leader";let Wn=qr;var B=(n=>(n[n.EndPoint=1]="EndPoint",n[n.MidPoint=2]="MidPoint",n[n.Center=3]="Center",n[n.Node=4]="Node",n[n.Quadrant=5]="Quadrant",n[n.Insertion=7]="Insertion",n[n.Perpendicular=8]="Perpendicular",n[n.Tangent=9]="Tangent",n[n.Nearest=10]="Nearest",n[n.Centroid=11]="Centroid",n))(B||{});function Ec(n){let e=0;for(const t of n)e|=1<<t-1;return e}function Tc(n){const e=[];for(const t of Object.values(B)){if(typeof t!="number")continue;const i=1<<t-1;n&i&&e.push(t)}return e}function Mc(n,e){return n^1<<e-1}function kc(n,e){return(n&1<<e-1)!==0}function vc(n,e){return n|1<<e-1}function Cc(n,e){return n&~(1<<e-1)}const Zr=class Zr extends he{get dxfTypeName(){return"LINE"}constructor(e,t){super(),this._geo=new Tt(e,t)}get startPoint(){return this._geo.startPoint}set startPoint(e){this._geo.startPoint=e}get endPoint(){return this._geo.endPoint}set endPoint(e){this._geo.endPoint=e}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"startX",type:"float",editable:!0,accessor:{get:()=>this.startPoint.x,set:e=>{this.startPoint.x=e}}},{name:"startY",type:"float",editable:!0,accessor:{get:()=>this.startPoint.y,set:e=>{this.startPoint.y=e}}},{name:"startZ",type:"float",editable:!0,accessor:{get:()=>this.startPoint.z,set:e=>{this.startPoint.z=e}}},{name:"endX",type:"float",editable:!0,accessor:{get:()=>this.endPoint.x,set:e=>{this.endPoint.x=e}}},{name:"endY",type:"float",editable:!0,accessor:{get:()=>this.endPoint.y,set:e=>{this.endPoint.y=e}}},{name:"endZ",type:"float",editable:!0,accessor:{get:()=>this.endPoint.z,set:e=>{this.endPoint.z=e}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]}]}}subGetGripPoints(){const e=new Array;return e.push(this.midPoint),e.push(this.startPoint),e.push(this.endPoint),e}subGetOsnapPoints(e,t,i,s){const r=this.startPoint,a=this.endPoint;switch(e){case B.EndPoint:s.push(r),s.push(a);break;case B.MidPoint:s.push(this.midPoint);break;case B.Nearest:{const o=this._geo.project(t);s.push(o)}break;case B.Perpendicular:{const o=this._geo.perpPoint(t);s.push(o)}break;case B.Tangent:break}}transformBy(e){return this._geo.transform(e),this}subWorldDraw(e){const t=this.startPoint,i=this.endPoint,s=[new f(t.x,t.y,0),new f(i.x,i.y,0)];return e.lines(s)}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbLine"),e.writePoint3d(10,this.startPoint),e.writePoint3d(11,this.endPoint),this}};Zr.typeName="Line";let Ui=Zr;var Qo=(n=>(n[n.Top=0]="Top",n[n.Zero=1]="Zero",n[n.Bottom=2]="Bottom",n))(Qo||{}),el=(n=>(n[n.HasVertex=1]="HasVertex",n[n.Closed=2]="Closed",n[n.SuppressStartCaps=4]="SuppressStartCaps",n[n.SuppressEndCaps=8]="SuppressEndCaps",n))(el||{});const Kr=class Kr extends le{get dxfTypeName(){return"MLINE"}constructor(){super(),this._styleName="",this._styleObjectHandle="",this._scale=1,this._justification=1,this._flags=0,this._styleCount=0,this._startPosition=new f,this._normal=new w(0,0,1),this._segments=[]}get styleName(){return this._styleName||this.getDefaultStyleName()}set styleName(e){this._styleName=e}get styleObjectHandle(){return this._styleObjectHandle}set styleObjectHandle(e){this._styleObjectHandle=e}get scale(){return this._scale}set scale(e){this._scale=e}get justification(){return this._justification}set justification(e){this._justification=e}get flags(){return this._flags}set flags(e){this._flags=e}get styleCount(){return this._styleCount}set styleCount(e){this._styleCount=Math.max(0,e)}get startPosition(){return this._startPosition}set startPosition(e){this._startPosition.copy(e)}get normal(){return this._normal}set normal(e){this._normal.copy(e)}get segments(){return this._segments.map(e=>this.cloneSegment(e))}set segments(e){this._segments=e.map(t=>this.createSegment(t)),this.updateHasVertexFlag()}get vertexCount(){return this._segments.length}get closed(){return(this._flags&2)!==0}set closed(e){this.setFlag(2,e)}get suppressStartCaps(){return(this._flags&4)!==0}set suppressStartCaps(e){this.setFlag(4,e)}get suppressEndCaps(){return(this._flags&8)!==0}set suppressEndCaps(e){this.setFlag(8,e)}appendSegment(e){this._segments.push(this.createSegment(e)),this.updateHasVertexFlag()}clearSegments(){this._segments=[],this.updateHasVertexFlag()}get geometricExtents(){const e=this.collectGeometryPoints();return new N().setFromPoints(e)}transformBy(e){return this._startPosition.applyMatrix4(e),this._segments.forEach(t=>{t.position.applyMatrix4(e),this.transformVector(t.direction,e),this.transformVector(t.miterDirection,e)}),this.transformVector(this._normal,e),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"mline",properties:[{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:e=>{this.styleName=e}}},{name:"scale",type:"float",editable:!0,accessor:{get:()=>this.scale,set:e=>{this.scale=e}}},{name:"justification",type:"int",editable:!0,accessor:{get:()=>this.justification,set:e=>{this.justification=e}}},{name:"closed",type:"boolean",editable:!0,accessor:{get:()=>this.closed,set:e=>{this.closed=e}}},{name:"vertexCount",type:"int",editable:!1,accessor:{get:()=>this.vertexCount}}]}]}}subWorldDraw(e){if(this._segments.length===0)return;const t=[],i=this.getMLineStyle(),s=this.getRenderableElementCount(i),r=e.subEntityTraits,a=r.color,o=r.rgbColor,h=r.lineType,c=r.fillType,d=r.drawOrder,u=this.createFillArea(i,s);if(u&&(r.color=a,r.rgbColor=o,this.applyFillTraits(i,r),r.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},r.drawOrder=-1,t.push(e.area(u)),r.fillType=c,r.drawOrder=d),s<=0){const p=this.getReferencePath();p.length>=2&&t.push(e.lines(p))}else{for(let p=0;p<s;p++){r.color=a,r.rgbColor=o,r.lineType=h,this.applyStyleElementTraits(i,p,r);const g=this.getElementPath(p,i);g.length>=2&&t.push(e.lines(g))}this.appendStyleDrivenJointAndCapEntities(e,t,i,s,a,o,h)}if(r.color=a,r.rgbColor=o,r.lineType=h,r.fillType=c,r.drawOrder=d,t.length!==0)return t.length===1?t[0]:e.group(t)}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbMline"),e.writeString(2,this.styleName),e.writeHandle(340,this._styleObjectHandle),e.writeDouble(40,this._scale),e.writeInt16(70,this._justification),e.writeInt16(71,this._flags),e.writeInt16(72,this.vertexCount),e.writeInt16(73,this._styleCount),e.writePoint3d(10,this._startPosition),e.writeVector3d(210,this._normal),this._segments.forEach(t=>{e.writePoint3d(11,t.position),e.writeVector3d(12,t.direction),e.writeVector3d(13,t.miterDirection),t.elements.forEach(i=>{e.writeInt16(74,i.parameterCount),i.parameters.forEach(s=>e.writeDouble(41,s)),e.writeInt16(75,i.fillCount),i.fillParameters.forEach(s=>e.writeDouble(42,s))})}),this}setFlag(e,t){t?this._flags|=e:this._flags&=~e}updateHasVertexFlag(){this.setFlag(1,this._segments.length>0)}createSegment(e){var t;return{position:new f().copy(e.position),direction:new w().copy(e.direction),miterDirection:new w().copy(e.miterDirection),elements:((t=e.elements)==null?void 0:t.map(i=>this.createElement(i)))??[]}}createElement(e){const t=e.parameters?[...e.parameters]:[],i=e.fillParameters?[...e.fillParameters]:[];return{parameterCount:e.parameterCount??t.length,parameters:t,fillCount:e.fillCount??i.length,fillParameters:i}}cloneSegment(e){return{position:e.position.clone(),direction:e.direction.clone(),miterDirection:e.miterDirection.clone(),elements:e.elements.map(t=>({parameterCount:t.parameterCount,parameters:[...t.parameters],fillCount:t.fillCount,fillParameters:[...t.fillParameters]}))}}collectGeometryPoints(){const e=[this._startPosition];if(this._segments.length===0)return e;const t=this.getMLineStyle(),i=this.getRenderableElementCount(t);if(i<=0)return this._segments.forEach(s=>e.push(s.position)),e;for(let s=0;s<i;s++)e.push(...this.getElementPath(s,t));return e}getRenderableElementCount(e){const t=(e==null?void 0:e.elementCount)??0;return Math.max(this._styleCount,t,...this._segments.map(i=>i.elements.length),0)}getReferencePath(){const e=[this._startPosition.clone(),...this._segments.map(t=>t.position.clone())];return this.closePathIfNeeded(e)}getElementPath(e,t){const i=[],s=this._segments[0];return i.push(this.getElementBoundaryPoint("start",s,e,t)),this._segments.forEach(r=>{i.push(this.offsetPoint(r.position,r.miterDirection,this.getElementMiterOffset(r,e,t)))}),i[i.length-1]=this.getElementBoundaryPoint("end",this._segments[this._segments.length-1],e,t),this.closePathIfNeeded(i)}getElementMiterOffset(e,t,i){var r;const s=e.elements[t];return(r=s==null?void 0:s.parameters)!=null&&r.length?s.parameters[0]:this.getStyleElementOffset(t,i)}getElementBoundaryPoint(e,t,i,s){const r=this.getElementMiterOffset(t,i,s),a=e==="start"?this._startPosition:t.position,o=this.offsetPoint(a,t.miterDirection,r);if(!this.shouldApplyCapCutAtSide(e,s))return o;const h=e==="start"?s==null?void 0:s.startAngle:s==null?void 0:s.endAngle,c=this.computeCapCutDistance(r,h,e);if(c===0)return o;const d=e==="start"?this.getStartSegmentDirection():this.getEndSegmentDirection();return d.lengthSq()===0?o:o.add(d.multiplyScalar(c))}shouldApplyCapCutAtSide(e,t){return!t||this.closed?!1:e==="start"?this.suppressStartCaps?!1:(t.flags&112)!==0:this.suppressEndCaps?!1:(t.flags&1792)!==0}computeCapCutDistance(e,t,i){const s=this.normalizeCapAngle(t),r=Math.tan(s);if(Math.abs(r)<1e-6)return 0;const a=e/r;return a}normalizeCapAngle(e){if(e==null||!Number.isFinite(e))return Math.PI/2;let t=e%180;return t<0&&(t+=180),(t<1||t>179)&&(t=90),t*Math.PI/180}getStartSegmentDirection(){const e=this._segments[0],t=new w;return e&&(t.subVectors(e.position,this._startPosition),t.lengthSq()===0&&t.copy(e.direction)),t.lengthSq()>0&&t.normalize(),t}getEndSegmentDirection(){const e=this._segments[this._segments.length-1];if(!e)return new w;const t=new w,i=this._segments.length>1?this._segments[this._segments.length-2].position:this._startPosition;return t.subVectors(e.position,i),t.lengthSq()===0&&t.copy(e.direction),t.lengthSq()>0&&t.normalize(),t}createFillArea(e,t){if(!e||!(e.flags&1)||t<2)return;const i=this.getFillBoundaryElementIndices(t,e);if(!i)return;const s=this.getElementPath(i.outerIndex,e),r=this.getElementPath(i.innerIndex,e),a=this.stripClosingPoint(s),o=this.stripClosingPoint(r);if(a.length<2||o.length<2)return;const h=new Pt;if(this.closed){if(a.length<3||o.length<3)return;h.add(new oe(a.map(c=>({x:c.x,y:c.y})),!0)),h.add(new oe(o.map(c=>({x:c.x,y:c.y})),!0))}else{const c=[...a,...o.slice().reverse()].map(d=>({x:d.x,y:d.y}));if(c.length<3)return;h.add(new oe(c,!0))}return h}getFillBoundaryElementIndices(e,t){let i=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,r=-1,a=-1;for(let o=0;o<e;o++){const h=this.getElementReferenceOffset(o,t);h<i&&(i=h,r=o),h>s&&(s=h,a=o)}if(!(r<0||a<0||r===a))return{outerIndex:a,innerIndex:r}}getElementReferenceOffset(e,t){var s;const i=this._segments[0];if(i){const r=i.elements[e];if((s=r==null?void 0:r.parameters)!=null&&s.length)return r.parameters[0]}return this.getStyleElementOffset(e,t)}getStyleElementOffset(e,t){const i=t==null?void 0:t.elements[e];if(!i)return 0;const s=this.getStyleJustificationShift(t);return(i.offset+s)*this._scale}getStyleJustificationShift(e){const t=(e==null?void 0:e.elements)??[];if(t.length<=0)return 0;let i=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(const r of t){const a=r.offset;a<i&&(i=a),a>s&&(s=a)}return this._justification===0?-s:this._justification===2?-i:0}stripClosingPoint(e){if(e.length<2)return e;const t=e[0],i=e[e.length-1],s=1e-9;return Math.abs(t.x-i.x)<=s&&Math.abs(t.y-i.y)<=s&&Math.abs(t.z-i.z)<=s?e.slice(0,-1):e}offsetPoint(e,t,i){if(i===0||t.lengthSq()===0)return e.clone();const s=t.clone().normalize().multiplyScalar(i);return e.clone().add(s)}closePathIfNeeded(e){if(!this.closed||e.length<2)return e;const t=e[0],i=e[e.length-1],s=1e-9;return Math.abs(t.x-i.x)<=s&&Math.abs(t.y-i.y)<=s&&Math.abs(t.z-i.z)<=s||e.push(t.clone()),e}appendStyleDrivenJointAndCapEntities(e,t,i,s,r,a,o){!i||s<2||(t.push(...this.drawMiterJointEntities(e,i,s,r,a,o)),t.push(...this.drawCapEntities(e,i,s,r,a,o)))}drawMiterJointEntities(e,t,i,s,r,a){if(this.closed||this._segments.length<2||!(t.flags&2))return[];const o=[],h=e.subEntityTraits;for(let c=0;c<this._segments.length-1;c++){const d=this._segments[c],u=Array.from({length:i},(p,g)=>{const m=this.getElementMiterOffset(d,g,t);return{elementIndex:g,offset:m,point:this.offsetPoint(d.position,d.miterDirection,m)}}).sort((p,g)=>g.offset-p.offset);for(let p=0;p<u.length-1;p++)this.applyElementDrawTraits(h,s,r,a,t,u[p].elementIndex),o.push(e.lines([u[p].point,u[p+1].point]))}return o}drawCapEntities(e,t,i,s,r,a){if(this.closed||this._segments.length<=0)return[];const o=[];return o.push(...this.drawCapEntitiesForSide(e,"start",t,i,s,r,a)),o.push(...this.drawCapEntitiesForSide(e,"end",t,i,s,r,a)),o}drawCapEntitiesForSide(e,t,i,s,r,a,o){if(t==="start"&&this.suppressStartCaps)return[];if(t==="end"&&this.suppressEndCaps)return[];const h=i.flags,c=t==="start",d=c?(h&16)!==0:(h&256)!==0,u=c?(h&64)!==0:(h&1024)!==0,p=c?(h&32)!==0:(h&512)!==0;if(!d&&!u&&!p)return[];const g=this.getCapElementPoints(t,s,i);if(g.length<2)return[];const m=[],y=e.subEntityTraits;if(d)for(let _=0;_<g.length-1;_++)this.applyElementDrawTraits(y,r,a,o,i,g[_].elementIndex),m.push(e.lines([g[_].point,g[_+1].point]));const x=c?this.getStartSegmentDirection().multiplyScalar(-1):this.getEndSegmentDirection().clone();if(u){const _=this.drawCapArcBetweenElements(e,t,g[0],g[g.length-1],x,y,r,a,o,i);_&&m.push(_)}if(p)for(let _=1;_<Math.floor(g.length/2);_++){const S=g[_],L=g[g.length-1-_];if(!S||!L||S===L)continue;const T=this.drawCapArcBetweenElements(e,t,S,L,x,y,r,a,o,i);T&&m.push(T)}return m}getCapElementPoints(e,t,i){const s=e==="start"?this._segments[0]:this._segments[this._segments.length-1];return s?Array.from({length:t},(r,a)=>({elementIndex:a,offset:this.getElementMiterOffset(s,a,i),point:this.getElementBoundaryPoint(e,s,a,i)})).sort((r,a)=>a.offset-r.offset):[]}drawCapArcBetweenElements(e,t,i,s,r,a,o,h,c,d){const u=t==="end"?s.point:i.point,p=t==="end"?i.point:s.point,g=u.distanceTo(p);if(g<=1e-9||r.lengthSq()===0)return;const y=u.clone().add(new w().subVectors(p,u).multiplyScalar(.5)).add(r.clone().normalize().multiplyScalar(g/2)),x=It.createByThreePoints(u,p,y);if(x)return this.applyElementDrawTraits(a,o,h,c,d,t==="end"?s.elementIndex:i.elementIndex),e.circularArc(x)}applyElementDrawTraits(e,t,i,s,r,a){e.color=t,e.rgbColor=i,e.lineType=s,this.applyStyleElementTraits(r,a,e)}transformVector(e,t){const i=new f,s=new f(e.x,e.y,e.z);i.applyMatrix4(t),s.applyMatrix4(t),e.set(s.x-i.x,s.y-i.y,s.z-i.z)}getMLineStyle(){var r;const e=this.database.objects.mlineStyle,t=this.styleObjectHandle?e.getIdAt(this.styleObjectHandle):void 0;if(t)return t;const i=this.styleName?e.getAt(this.styleName):void 0;if(i)return i;const s=(r=this.styleName)==null?void 0:r.toUpperCase();if(s)for(const[a,o]of e.entries()){const h=(o.styleName||a).toUpperCase();if(a.toUpperCase()===s||h===s)return o}}applyStyleElementTraits(e,t,i){const s=e==null?void 0:e.elements[t];if(!s)return;const r=this.resolveStyleElementLineType(s.lineType);r&&(i.lineType=r),!(s.color.isByBlock||s.color.isByLayer)&&(i.color=s.color.clone(),i.rgbColor=s.color.RGB??this.rgbColor)}applyFillTraits(e,t){const i=e==null?void 0:e.fillColor;!i||i.isByBlock||i.isByLayer||(t.color=i.clone(),t.rgbColor=i.RGB??this.rgbColor)}resolveStyleElementLineType(e){var c;const t=e==null?void 0:e.trim();if(!t)return;const i=t.toUpperCase(),s=de.toUpperCase(),r=Lt.toUpperCase();let a="UserSpecified",o=t;if(i===s){a="ByLayer";const d=(c=this.database.tables.layerTable.getAt(this.layer))==null?void 0:c.linetype;o=d&&d.toUpperCase()!==s&&d.toUpperCase()!==r?d:St}else i===r&&(a="ByBlock",o=St);const h=this.database.tables.linetypeTable.getAt(o);return h?{type:a,...h.linetype}:{type:a,name:o,standardFlag:0,description:"",totalPatternLength:0}}resolveEffectiveProperties(){super.resolveEffectiveProperties(),this._styleName||(this._styleName=this.getDefaultStyleName())}getDefaultStyleName(){try{return this.database.cmlstyle||dt}catch{return dt}}};Kr.typeName="MLine";let Gn=Kr;var ci=(n=>(n[n.InvisibleLeader=0]="InvisibleLeader",n[n.StraightLeader=1]="StraightLeader",n[n.SplineLeader=2]="SplineLeader",n))(ci||{}),gt=(n=>(n[n.NoneContent=0]="NoneContent",n[n.BlockContent=1]="BlockContent",n[n.MTextContent=2]="MTextContent",n[n.ToleranceContent=3]="ToleranceContent",n))(gt||{}),tl=(n=>(n[n.Horizontal=0]="Horizontal",n[n.Vertical=1]="Vertical",n))(tl||{}),il=(n=>(n[n.Unknown=0]="Unknown",n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.Top=3]="Top",n[n.Bottom=4]="Bottom",n))(il||{});const Oc=1,Nc=2,Yc=4,Xc=8,Rc=64,Bc=128,Fc=32768,Jr=class Jr extends le{get dxfTypeName(){return"MULTILEADER"}constructor(){super(),this._leaders=[],this._leaderLineType=1,this._contentType=0,this._doglegEnabled=!1,this._doglegLength=0,this._doglegVector=new w(1,0,0),this._normal=new w(0,0,1),this._mleaderStyleId="",this._textHeight=2.5,this._textWidth=0,this._textRotation=0,this._textDirection=new w(1,0,0),this._textStyleName="",this._textAttachmentPoint=ae.MiddleLeft,this._textDrawingDirection=ze.LEFT_TO_RIGHT,this._textLineSpacingFactor=1,this._textAttachmentDirection=0,this._arrowheadOverrides=[],this._blockAttributes=[]}get leaders(){return this._leaders.map(e=>this.cloneLeader(e))}get numberOfLeaders(){return this._leaders.length}get leaderLineType(){return this._leaderLineType}set leaderLineType(e){this._leaderLineType=e}get contentType(){return this._contentType}set contentType(e){this._contentType=e}get doglegEnabled(){return this._doglegEnabled}set doglegEnabled(e){this._doglegEnabled=e}get doglegLength(){return this._doglegLength}set doglegLength(e){this._doglegLength=e}get doglegVector(){return this._doglegVector}set doglegVector(e){this._doglegVector.copy(e)}get landingPoint(){return this._landingPoint}set landingPoint(e){this._landingPoint=e?this.createPoint(e):void 0}get normal(){return this._normal}set normal(e){this._normal.copy(e)}get mleaderStyleId(){return this._mleaderStyleId}set mleaderStyleId(e){this._mleaderStyleId=e}get version(){return this._version}set version(e){this._version=e}get leaderStyleId(){return this._leaderStyleId}set leaderStyleId(e){this._leaderStyleId=e}get propertyOverrideFlag(){return this._propertyOverrideFlag}set propertyOverrideFlag(e){this._propertyOverrideFlag=e}get leaderLineColor(){return this._leaderLineColor}set leaderLineColor(e){this._leaderLineColor=e}get leaderLineTypeId(){return this._leaderLineTypeId}set leaderLineTypeId(e){this._leaderLineTypeId=e}get leaderLineWeight(){return this._leaderLineWeight}set leaderLineWeight(e){this._leaderLineWeight=e}get landingEnabled(){return this._landingEnabled}set landingEnabled(e){this._landingEnabled=e}get arrowheadId(){return this._arrowheadId}set arrowheadId(e){this._arrowheadId=e}get arrowheadSize(){return this._arrowheadSize}set arrowheadSize(e){this._arrowheadSize=e}get textStyleId(){return this._textStyleId}set textStyleId(e){this._textStyleId=e}get textLeftAttachmentType(){return this._textLeftAttachmentType}set textLeftAttachmentType(e){this._textLeftAttachmentType=e}get textRightAttachmentType(){return this._textRightAttachmentType}set textRightAttachmentType(e){this._textRightAttachmentType=e}get textAngleType(){return this._textAngleType}set textAngleType(e){this._textAngleType=e}get textAlignmentType(){return this._textAlignmentType}set textAlignmentType(e){this._textAlignmentType=e}get textColor(){return this._textColor}set textColor(e){this._textColor=e}get textFrameEnabled(){return this._textFrameEnabled}set textFrameEnabled(e){this._textFrameEnabled=e}get landingGap(){return this._landingGap}set landingGap(e){this._landingGap=e}get textAttachment(){return this._textAttachment}set textAttachment(e){this._textAttachment=e}get textFlowDirection(){return this._textFlowDirection}set textFlowDirection(e){this._textFlowDirection=e}get blockContentId(){return this._blockContentId}set blockContentId(e){this._blockContentId=e}get blockContentColor(){return this._blockContentColor}set blockContentColor(e){this._blockContentColor=e}get blockContentScale(){return this._blockContentScale}set blockContentScale(e){this._blockContentScale=e}get blockContentRotation(){return this._blockContentRotation}set blockContentRotation(e){this._blockContentRotation=e}get blockContentConnectionType(){return this._blockContentConnectionType}set blockContentConnectionType(e){this._blockContentConnectionType=e}get annotativeScaleEnabled(){return this._annotativeScaleEnabled}set annotativeScaleEnabled(e){this._annotativeScaleEnabled=e}get arrowheadOverrides(){return this._arrowheadOverrides}set arrowheadOverrides(e){this._arrowheadOverrides=e}get blockAttributes(){return this._blockAttributes}set blockAttributes(e){this._blockAttributes=e}get textDirectionNegative(){return this._textDirectionNegative}set textDirectionNegative(e){this._textDirectionNegative=e}get textAlignInIPE(){return this._textAlignInIPE}set textAlignInIPE(e){this._textAlignInIPE=e}get bottomTextAttachmentDirection(){return this._bottomTextAttachmentDirection}set bottomTextAttachmentDirection(e){this._bottomTextAttachmentDirection=e}get topTextAttachmentDirection(){return this._topTextAttachmentDirection}set topTextAttachmentDirection(e){this._topTextAttachmentDirection=e}get contentScale(){return this._contentScale}set contentScale(e){this._contentScale=e}get contentBasePosition(){return this._contentBasePosition}set contentBasePosition(e){this._contentBasePosition=e}get textAnchor(){return this._textAnchor}set textAnchor(e){this._textAnchor=e}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(e){this._textLineSpacingStyle=e}get textBackgroundColor(){return this._textBackgroundColor}set textBackgroundColor(e){this._textBackgroundColor=e}get textBackgroundScaleFactor(){return this._textBackgroundScaleFactor}set textBackgroundScaleFactor(e){this._textBackgroundScaleFactor=e}get textBackgroundTransparency(){return this._textBackgroundTransparency}set textBackgroundTransparency(e){this._textBackgroundTransparency=e}get textBackgroundColorOn(){return this._textBackgroundColorOn}set textBackgroundColorOn(e){this._textBackgroundColorOn=e}get textFillOn(){return this._textFillOn}set textFillOn(e){this._textFillOn=e}get textColumnType(){return this._textColumnType}set textColumnType(e){this._textColumnType=e}get textUseAutoHeight(){return this._textUseAutoHeight}set textUseAutoHeight(e){this._textUseAutoHeight=e}get textColumnWidth(){return this._textColumnWidth}set textColumnWidth(e){this._textColumnWidth=e}get textColumnGutterWidth(){return this._textColumnGutterWidth}set textColumnGutterWidth(e){this._textColumnGutterWidth=e}get textColumnFlowReversed(){return this._textColumnFlowReversed}set textColumnFlowReversed(e){this._textColumnFlowReversed=e}get textColumnHeight(){return this._textColumnHeight}set textColumnHeight(e){this._textColumnHeight=e}get textUseWordBreak(){return this._textUseWordBreak}set textUseWordBreak(e){this._textUseWordBreak=e}get hasMText(){return this._hasMText}set hasMText(e){this._hasMText=e}get hasBlock(){return this._hasBlock}set hasBlock(e){this._hasBlock=e}get planeOrigin(){return this._planeOrigin}set planeOrigin(e){this._planeOrigin=e}get planeXAxisDirection(){return this._planeXAxisDirection}set planeXAxisDirection(e){this._planeXAxisDirection=e}get planeYAxisDirection(){return this._planeYAxisDirection}set planeYAxisDirection(e){this._planeYAxisDirection=e}get planeNormalReversed(){return this._planeNormalReversed}set planeNormalReversed(e){this._planeNormalReversed=e}get leaderSections(){return this.leaders}get blockContentData(){return this.blockContent}get mtextContent(){return this._mtextContent?{text:this._mtextContent.text,anchorPoint:this._mtextContent.anchorPoint.clone()}:void 0}set mtextContent(e){if(!e){this._mtextContent=void 0,this._contentType===2&&(this._contentType=0);return}this._mtextContent={text:e.text,anchorPoint:this.createPoint(e.anchorPoint)},this._contentType=2}get contents(){var e;return((e=this._mtextContent)==null?void 0:e.text)??""}set contents(e){this._mtextContent?this._mtextContent.text=e:this._mtextContent={text:e,anchorPoint:new f},this._contentType=2}get textLocation(){var e;return(e=this._mtextContent)==null?void 0:e.anchorPoint}set textLocation(e){if(!e){this._mtextContent=void 0;return}this._mtextContent?this._mtextContent.anchorPoint.copy(e):this._mtextContent={text:"",anchorPoint:this.createPoint(e)},this._contentType=2}get textHeight(){return this._textHeight}set textHeight(e){this._textHeight=e}get textWidth(){return this._textWidth}set textWidth(e){this._textWidth=e}get textRotation(){return this._textRotation}set textRotation(e){this._textRotation=e}get textDirection(){return this._textDirection}set textDirection(e){this._textDirection.copy(e)}get textStyleName(){return this._textStyleName}set textStyleName(e){this._textStyleName=e}get textAttachmentPoint(){return this._textAttachmentPoint}set textAttachmentPoint(e){this._textAttachmentPoint=e}get textDrawingDirection(){return this._textDrawingDirection}set textDrawingDirection(e){this._textDrawingDirection=e}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(e){this._textLineSpacingFactor=e}get textAttachmentDirection(){return this._textAttachmentDirection}set textAttachmentDirection(e){this._textAttachmentDirection=e}get blockContent(){var e,t;return this._blockContent?{blockContentId:this._blockContent.blockContentId,blockHandle:this._blockContent.blockHandle,normal:(e=this._blockContent.normal)==null?void 0:e.clone(),position:(t=this._blockContent.position)==null?void 0:t.clone(),scale:this._blockContent.scale.clone(),rotation:this._blockContent.rotation,color:this._blockContent.color,transformationMatrix:[...this._blockContent.transformationMatrix]}:void 0}set blockContent(e){if(!e){this._blockContent=void 0,this._contentType===1&&(this._contentType=0);return}this._blockContent={blockContentId:e.blockContentId??e.blockHandle,blockHandle:e.blockHandle,normal:e.normal?new w(e.normal):void 0,position:e.position?this.createPoint(e.position):void 0,scale:new w(e.scale??{x:1,y:1,z:1}),rotation:e.rotation??0,color:e.color,transformationMatrix:e.transformationMatrix?[...e.transformationMatrix]:[]},this.blockContentId=this._blockContent.blockContentId,this._contentType=1}addLeader(e={}){var i,s;const t={lastLeaderLinePoint:e.lastLeaderLinePoint?this.createPoint(e.lastLeaderLinePoint):void 0,lastLeaderLinePointSet:e.lastLeaderLinePointSet,landingPoint:e.landingPoint?this.createPoint(e.landingPoint):void 0,doglegVector:e.doglegVector?new w(e.doglegVector):void 0,doglegVectorSet:e.doglegVectorSet,doglegLength:e.doglegLength,breaks:((i=e.breaks)==null?void 0:i.map(r=>({index:r.index,start:this.createPoint(r.start),end:this.createPoint(r.end)})))??[],leaderBranchIndex:e.leaderBranchIndex,directionType:e.directionType,leaderLines:[]};return(s=e.leaderLines)==null||s.forEach(r=>{t.leaderLines.push(this.createLeaderLine(r))}),this._leaders.push(t),this._leaders.length-1}removeLeader(e){return this.checkLeaderIndex(e),this._leaders.splice(e,1),this}addLeaderLine(e,t=[]){return this.checkLeaderIndex(e),this._leaders[e].leaderLines.push(this.createLeaderLine({vertices:t})),this._leaders[e].leaderLines.length-1}appendVertex(e,t,i){return this.getMutableLeaderLine(e,t).vertices.push(this.createPoint(i)),this}setLeaderLineVertices(e,t,i){return this.getMutableLeaderLine(e,t).vertices=i.map(s=>this.createPoint(s)),this}getLeaderLineVertices(e,t){return this.getMutableLeaderLine(e,t).vertices.map(i=>i.clone())}addBreak(e,t,i,s){return this.getMutableLeaderLine(e,t).breaks.push({start:this.createPoint(i),end:this.createPoint(s)}),this}setLandingPoint(e,t){return this.checkLeaderIndex(e),this._leaders[e].landingPoint=t?this.createPoint(t):void 0,this}setDoglegDirection(e,t){return this.checkLeaderIndex(e),this._leaders[e].doglegVector=new w(t),this}setDoglegLength(e,t){return this.checkLeaderIndex(e),this._leaders[e].doglegLength=t,this}get geometricExtents(){const e=this.collectGeometryPoints();return e.length>0?new N().setFromPoints(e):new N}subGetGripPoints(){return this.collectGeometryPoints().map(e=>e.clone())}transformBy(e){var t,i,s,r,a,o,h,c;return this._leaders.forEach(d=>{var u,p;(u=d.lastLeaderLinePoint)==null||u.applyMatrix4(e),(p=d.landingPoint)==null||p.applyMatrix4(e),d.doglegVector&&this.transformVector(d.doglegVector,e),d.breaks.forEach(g=>{g.start.applyMatrix4(e),g.end.applyMatrix4(e)}),d.leaderLines.forEach(g=>{g.vertices.forEach(m=>m.applyMatrix4(e)),g.breaks.forEach(m=>{m.start.applyMatrix4(e),m.end.applyMatrix4(e)})})}),(t=this._landingPoint)==null||t.applyMatrix4(e),(i=this.contentBasePosition)==null||i.applyMatrix4(e),this.transformVector(this._doglegVector,e),this.transformVector(this._normal,e),(s=this.textAnchor)==null||s.applyMatrix4(e),(r=this._mtextContent)==null||r.anchorPoint.applyMatrix4(e),this.transformVector(this._textDirection,e),(o=(a=this._blockContent)==null?void 0:a.position)==null||o.applyMatrix4(e),(h=this._blockContent)!=null&&h.normal&&this.transformVector(this._blockContent.normal,e),this.blockContentScale&&this.transformVector(this.blockContentScale,e),(c=this.planeOrigin)==null||c.applyMatrix4(e),this.planeXAxisDirection&&this.transformVector(this.planeXAxisDirection,e),this.planeYAxisDirection&&this.transformVector(this.planeYAxisDirection,e),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"leader",properties:[{name:"contentType",type:"enum",editable:!0,options:[{label:gt[0],value:0},{label:gt[1],value:1},{label:gt[2],value:2},{label:gt[3],value:3}],accessor:{get:()=>this.contentType,set:e=>{this.contentType=e}}},{name:"leaderLineType",type:"enum",editable:!0,options:[{label:ci[0],value:0},{label:ci[1],value:1},{label:ci[2],value:2}],accessor:{get:()=>this.leaderLineType,set:e=>{this.leaderLineType=e}}},{name:"doglegEnabled",type:"boolean",editable:!0,accessor:{get:()=>this.doglegEnabled,set:e=>{this.doglegEnabled=e}}},{name:"doglegLength",type:"float",editable:!0,accessor:{get:()=>this.doglegLength,set:e=>{this.doglegLength=e}}},{name:"leaderCount",type:"int",editable:!1,accessor:{get:()=>this.numberOfLeaders}}]},{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:e=>{this.contents=e}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.textHeight,set:e=>{this.textHeight=e}}},{name:"textWidth",type:"float",editable:!0,accessor:{get:()=>this.textWidth,set:e=>{this.textWidth=e}}},{name:"textStyleName",type:"string",editable:!0,accessor:{get:()=>this.textStyleName,set:e=>{this.textStyleName=e}}}]}]}}resolveEffectiveProperties(){if(super.resolveEffectiveProperties(),this._mleaderStyleId)return;const e=this.getDefaultMLeaderStyle();e&&(this._mleaderStyleId=e.objectId)}subWorldDraw(e){const t=[],i=e.subEntityTraits,s=i.color,r=i.rgbColor,a=i.lineType,o=i.lineWeight,h=this.getResolvedLeaderLineColor(),c=this.getResolvedLeaderLineStyle(),d=this.getResolvedLeaderLineWeight(),u=this.getResolvedTextColor();this.getResolvedLeaderLineType()!==0&&(this.applyColorTraits(i,h,s,r),this.applyLineTraits(i,c,d),this._leaders.forEach(g=>{g.leaderLines.forEach(y=>{const x=this.getLeaderLineDrawPoints(g,y);if(x.length>0){const _=this.drawLeaderLine(e,x);_&&t.push(_)}});const m=this.getDoglegPoints(g);m&&t.push(e.lines(m))}));const p=this.getRenderableMTextContent();if(this.contentType===2&&p){this.applyColorTraits(i,u,s,r);const g=this.getResolvedTextHeight(),m={text:p.text,height:g,width:this.getMTextRenderWidth(p.text,g),position:p.anchorPoint,rotation:this.textRotation,directionVector:this.textDirection,attachmentPoint:this.textAttachmentPoint,drawingDirection:this.textDrawingDirection,lineSpaceFactor:this.textLineSpacingFactor};t.push(e.mtext(m,this.getTextStyle(),!1))}if(i.color=s,i.rgbColor=r,i.lineType=a,i.lineWeight=o,t.length!==0)return t.length===1?t[0]:e.group(t)}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbMLeader"),e.writeInt16(170,this.leaderLineType),e.writeBoolean(290,this.doglegEnabled),e.writeDouble(41,this.doglegLength),e.writeInt16(172,this.contentType),e.writeVector3d(210,this.normal),e.writeHandle(340,this.mleaderStyleId),this._landingPoint&&e.writePoint3d(10,this._landingPoint),e.writeVector3d(11,this.doglegVector),this._mtextContent&&(e.writeString(1,this._mtextContent.text),e.writePoint3d(12,this._mtextContent.anchorPoint),e.writeDouble(40,this.textHeight),e.writeDouble(42,this.textWidth),e.writeAngle(50,this.textRotation),e.writeString(7,this.textStyleName)),this._blockContent&&(e.writeHandle(341,this._blockContent.blockContentId??""),this._blockContent.position&&e.writePoint3d(15,this._blockContent.position),e.writeVector3d(16,this._blockContent.scale),e.writeAngle(52,this._blockContent.rotation)),this._leaders.forEach(t=>{t.landingPoint&&e.writePoint3d(110,t.landingPoint),t.doglegVector&&e.writeVector3d(111,t.doglegVector),e.writeDouble(140,t.doglegLength),e.writeInt16(171,t.leaderLines.length),t.leaderLines.forEach(i=>{e.writeInt16(90,i.vertices.length),i.vertices.forEach(s=>e.writePoint3d(10,s))})}),this}createPoint(e){return new f().copy(e)}createLeaderLine(e){var t,i;return{vertices:((t=e.vertices)==null?void 0:t.map(s=>this.createPoint(s)))??[],breakPointIndexes:e.breakPointIndexes?[...e.breakPointIndexes]:[],leaderLineIndex:e.leaderLineIndex,breaks:((i=e.breaks)==null?void 0:i.map(s=>({index:s.index,start:this.createPoint(s.start),end:this.createPoint(s.end)})))??[]}}cloneLeader(e){var t,i,s;return{lastLeaderLinePoint:(t=e.lastLeaderLinePoint)==null?void 0:t.clone(),lastLeaderLinePointSet:e.lastLeaderLinePointSet,landingPoint:(i=e.landingPoint)==null?void 0:i.clone(),doglegVector:(s=e.doglegVector)==null?void 0:s.clone(),doglegVectorSet:e.doglegVectorSet,doglegLength:e.doglegLength,breaks:e.breaks.map(r=>({index:r.index,start:r.start.clone(),end:r.end.clone()})),leaderBranchIndex:e.leaderBranchIndex,directionType:e.directionType,leaderLines:e.leaderLines.map(r=>({vertices:r.vertices.map(a=>a.clone()),breakPointIndexes:[...r.breakPointIndexes],leaderLineIndex:r.leaderLineIndex,breaks:r.breaks.map(a=>({index:a.index,start:a.start.clone(),end:a.end.clone()}))}))}}checkLeaderIndex(e){if(e<0||e>=this._leaders.length)throw new Error("The leader index is out of range!")}getMutableLeaderLine(e,t){this.checkLeaderIndex(e);const i=this._leaders[e].leaderLines[t];if(!i)throw new Error("The leader line index is out of range!");return i}collectGeometryPoints(){var t;const e=[];return this._leaders.forEach(i=>{i.lastLeaderLinePoint&&e.push(i.lastLeaderLinePoint),i.landingPoint&&e.push(i.landingPoint),i.breaks.forEach(r=>e.push(r.start,r.end)),i.leaderLines.forEach(r=>{e.push(...r.vertices),r.breaks.forEach(a=>e.push(a.start,a.end))});const s=this.getDoglegPoints(i);s&&e.push(...s),i.leaderLines.forEach(r=>{const a=this.getArrowheadPoints(this.getLeaderLineDrawPoints(i,r));a&&e.push(...a)})}),this._landingPoint&&e.push(this._landingPoint),this.contentBasePosition&&e.push(this.contentBasePosition),this.textAnchor&&e.push(this.textAnchor),this._mtextContent&&e.push(this._mtextContent.anchorPoint),(t=this._blockContent)!=null&&t.position&&e.push(this._blockContent.position),this.planeOrigin&&e.push(this.planeOrigin),e}getLeaderLineDrawPoints(e,t){if(t.vertices.length>=2)return t.vertices;if(t.vertices.length===0)return[];const i=e.lastLeaderLinePoint??e.landingPoint??this._landingPoint??this.contentBasePosition;return!i||t.vertices[0].equals(i)?t.vertices:[t.vertices[0],i]}getDoglegPoints(e){if(!this.getResolvedDoglegEnabled())return;const t=e.lastLeaderLinePoint??e.landingPoint??this._landingPoint,i=e.doglegVector??this._doglegVector,s=e.doglegLength??this.getResolvedDoglegLength();if(!t||s==null||s===0||i.lengthSq()===0)return;const r=t.clone().add(i.clone().normalize().multiplyScalar(s));return[t,r]}getArrowheadPoints(e){if(!this.isArrowheadVisible()||e.length<2)return;const t=this.getArrowheadFrame(e);if(!t)return;const i=this.getResolvedArrowheadSize(),{tip:s,unit:r}=t,a=s.clone().add(r.clone().multiplyScalar(i)),o=i/6,h=new w(-r.y,r.x,0),c=a.clone().add(h.clone().multiplyScalar(o)),d=a.clone().add(h.clone().multiplyScalar(-o));return[s,c,d,s]}isArrowheadVisible(){const e=this.getResolvedArrowheadId();return(e==null?void 0:e.toUpperCase())==="_NONE"?!1:this.getResolvedArrowheadSize()>0}drawLeaderLine(e,t){const i=[],s=this.getLeaderLinePointsForDraw(t);s.length>=2&&i.push(e.lines(s));const r=this.drawArrowhead(e,t);if(r&&i.push(r),i.length!==0)return i.length===1?i[0]:e.group(i)}getLeaderLinePointsForDraw(e){const t=this.getArrowheadLeaderLineTrimDistance();return t<=0?e:this.trimPolylineStart(e,t)}getArrowheadLeaderLineTrimDistance(){if(!this.isArrowheadVisible())return 0;const e=this.getResolvedArrowheadBlockTableRecord();if(!e)return 0;const t=this.getResolvedArrowheadSize();if(t<=0)return 0;const i=e.origin??f.ORIGIN;let s=i.x;for(const r of e.newIterator()){const a=r.geometricExtents;a.isEmpty()||a.max.x>s&&(s=a.max.x)}return Math.max(0,(s-i.x)*t)}trimPolylineStart(e,t){if(e.length<2||t<=0)return e;let i=t;for(let s=0;s<e.length-1;s++){const r=e[s],a=e[s+1],o=a.distanceTo(r);if(!(o<=0)){if(i<o){const h=new w().subVectors(a,r);return[r.clone().add(h.multiplyScalar(i/o)),...e.slice(s+1)]}i-=o}}return[e[e.length-1]]}drawArrowhead(e,t){if(!this.isArrowheadVisible())return;const i=this.drawArrowheadBlock(e,t);if(i)return i;const s=this.getArrowheadPoints(t);if(!s)return;const r=new Pt;r.add(new oe(s,!0));const a=e.subEntityTraits,o=a.fillType;a.fillType={solidFill:!0,patternAngle:0,definitionLines:[]};const h=e.area(r);return a.fillType=o,h}drawArrowheadBlock(e,t){const i=this.getResolvedArrowheadBlockTableRecord();if(!i)return;const s=this.getArrowheadFrame(t);if(!s)return;const{tip:r,unit:a}=s,o=this.getResolvedArrowheadSize(),h=Math.atan2(a.y,a.x),c=i.origin??f.ORIGIN,d=new D().makeTranslation(-c.x,-c.y,-c.z),u=new D().makeScale(o,o,o),p=new D().makeRotationZ(h),g=new D().makeTranslation(r.x,r.y,r.z),m=new D().multiplyMatrices(g,p).multiply(u).multiply(d);return ii.instance.draw(e,i,this.rgbColor,[],!0,m,new w(this.normal))}getArrowheadFrame(e){if(e.length<2)return;const t=e[0],i=e.find(r=>!r.equals(t));if(!i)return;const s=new w().subVectors(i,t);if(s.lengthSq()!==0)return{tip:t,unit:s.normalize()}}getResolvedArrowheadId(){var t;const e=(t=this.getMLeaderStyle())==null?void 0:t.arrowSymbolId;return this.arrowheadId??e}getResolvedArrowheadBlockTableRecord(){const e=this.getResolvedArrowheadId();if(e)return this.database.tables.blockTable.getIdAt(e)}getResolvedArrowheadSize(){const e=this.getMLeaderStyle(),t=(e==null?void 0:e.arrowSize)??(e==null?void 0:e.scale);return this.arrowheadSize??this.contentScale??t??this.getResolvedTextHeight()}getResolvedTextHeight(){var t;const e=(t=this.getMLeaderStyle())==null?void 0:t.textHeight;return this.textHeight>0?this.textHeight:e!=null&&e>0?e:2.5}getRenderableMTextContent(){var i;if(this._mtextContent)return{text:this._mtextContent.text,anchorPoint:this._mtextContent.anchorPoint};const e=(i=this.getMLeaderStyle())==null?void 0:i.defaultMTextContents,t=this.textAnchor??this.contentBasePosition??this._landingPoint;if(!(!e||!t))return{text:e,anchorPoint:t}}getMTextRenderWidth(e,t){if(this._textWidth>0)return this._textWidth;if(!e)return this._textWidth;const i=e.replace(/\\[PpNn]/g,`
4
+ `).replace(/\\[A-Za-z][^;]*;/g,"").replace(/[{}]/g,""),s=Math.max(...i.split(/\r\n|\r|\n/g).map(r=>r.length),1);return Math.max(t,s*t)}transformVector(e,t){const i=new f,s=new f(e.x,e.y,e.z);i.applyMatrix4(t),s.applyMatrix4(t),e.set(s.x-i.x,s.y-i.y,s.z-i.z)}getMLeaderStyle(){const e=this.database.objects.mleaderStyle,t=this.mleaderStyleId||this.leaderStyleId;if(t){const i=e.getIdAt(t);if(i)return i}return this.getDefaultMLeaderStyle()}getDefaultMLeaderStyle(){const e=this.resolveMLeaderStyleByName(this.getDefaultMLeaderStyleName());return e||this.database.objects.mleaderStyle.newIterator().toArray()[0]}resolveMLeaderStyleByName(e){const t=e==null?void 0:e.trim();if(!t)return;const i=this.database.objects.mleaderStyle,s=i.getAt(t);if(s)return s;const r=i.getIdAt(t);if(r)return r;const a=t.toUpperCase();for(const[o,h]of i.entries())if(o.toUpperCase()===a)return h}getDefaultMLeaderStyleName(){try{return this.database.cmleaderstyle||ut}catch{return ut}}getResolvedTextStyleName(){var r,a;const e=this.database.tables.textStyleTable,t=(r=this.getMLeaderStyle())==null?void 0:r.textStyleId,i=t?(a=e.getIdAt(t))==null?void 0:a.name:void 0;if(this.textStyleName)return this.textStyleName;const s=this.textStyleId?e.getIdAt(this.textStyleId):void 0;return s!=null&&s.name?s.name:i}getTextStyle(){const e=this.database.tables.textStyleTable,t=this.getResolvedTextStyleName(),i=(t?e.getAt(t):void 0)??e.getAt(this.database.textstyle)??e.getAt(Z);if(!i)throw new Error("No valid text style found in text style table.");return i.textStyle}getResolvedLeaderLineColor(){var e;return this.getResolvedComponentColor(this.leaderLineColor,(e=this.getMLeaderStyle())==null?void 0:e.leaderLineColor,Nc)}getResolvedLeaderLineType(){var t;const e=(t=this.getMLeaderStyle())==null?void 0:t.leaderLineType;return this.getResolvedStyleDrivenValue(this.leaderLineType,e,Oc)}getResolvedLeaderLineTypeId(){var e;return this.getResolvedStyleDrivenValue(this.leaderLineTypeId,(e=this.getMLeaderStyle())==null?void 0:e.leaderLineTypeId,Yc)}getResolvedLeaderLineStyle(){const e=this.getResolvedLeaderLineTypeId();if(!e)return;const t=this.database.tables.linetypeTable.getIdAt(e);if(t)return{type:"UserSpecified",...t.linetype}}getResolvedLeaderLineWeight(){var i;const e=(i=this.getMLeaderStyle())==null?void 0:i.leaderLineWeight,t=this.getResolvedStyleDrivenValue(this.leaderLineWeight,e,Xc);if(t!=null)return t}getResolvedDoglegEnabled(){var t;const e=(t=this.getMLeaderStyle())==null?void 0:t.doglegEnabled;return this.getResolvedStyleDrivenValue(this.doglegEnabled,e,Rc)}getResolvedDoglegLength(){var t;const e=(t=this.getMLeaderStyle())==null?void 0:t.doglegLength;return this.getResolvedStyleDrivenValue(this.doglegLength,e,Bc)}getResolvedTextColor(){var e;return this.getResolvedComponentColor(this.textColor,(e=this.getMLeaderStyle())==null?void 0:e.textColor,Fc)}getResolvedComponentColor(e,t,i){const s=e!=null?Fi(e):void 0;if(!s)return t;const r=this.isPropertyOverrideEnabled(i);return r===!0?s:r===!1?t??s:!s.isByBlock&&!s.isByLayer?s:t??s}getResolvedStyleDrivenValue(e,t,i){const s=this.isPropertyOverrideEnabled(i);return s===!0?e??t:t??e}isPropertyOverrideEnabled(e){if(this.propertyOverrideFlag!=null)return(this.propertyOverrideFlag&e)!==0}applyColorTraits(e,t,i,s){e.color=i,e.rgbColor=s,t&&(e.color=t,e.rgbColor=this.resolveColorToRgb(t))}applyLineTraits(e,t,i){t&&(e.lineType=t),i!=null&&(e.lineWeight=i)}resolveColorToRgb(e){if(e.isByLayer){const t=this.getLayerColor();return(t==null?void 0:t.RGB)!=null?t.RGB:this.rgbColor}return e.isByBlock?this.rgbColor:e.RGB??this.rgbColor}};Jr.typeName="MLeader";let Hn=Jr;const Qr=class Qr extends le{get dxfTypeName(){return"MTEXT"}constructor(){super(),this._contents="",this._height=0,this._width=0,this._lineSpacingFactor=.25,this._lineSpacingStyle=0,this._backgroundFill=!1,this._backgroundFillColor=13158600,this._backgroundFillTransparency=1,this._backgroundScaleFactor=1,this._rotation=0,this._styleName="",this._location=new f,this._attachmentPoint=ae.TopLeft,this._direction=new w(1,0,0),this._drawingDirection=ze.LEFT_TO_RIGHT}get contents(){return this._contents}set contents(e){this._contents=e}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get lineSpacingFactor(){return this._lineSpacingFactor}set lineSpacingFactor(e){this._lineSpacingFactor=e}get lineSpacingStyle(){return this._lineSpacingStyle}set lineSpacingStyle(e){this._lineSpacingStyle=e}get backgroundFill(){return this._backgroundFill}set backgroundFill(e){this._backgroundFill=e,this._backgroundFillColor=13158600}get backgroundFillColor(){return this._backgroundFillColor}set backgroundFillColor(e){this._backgroundFillColor=e}get backgroundFillTransparency(){return this._backgroundFillTransparency}set backgroundFillTransparency(e){this._backgroundFillTransparency=e}get backgroundScaleFactor(){return this._backgroundScaleFactor}set backgroundScaleFactor(e){this._backgroundScaleFactor=e}get styleName(){return this._styleName}set styleName(e){this._styleName=e}get location(){return this._location}set location(e){this._location.copy(e)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(e){this._attachmentPoint=e}get direction(){return this._direction}set direction(e){this._direction.copy(e)}get drawingDirection(){return this._drawingDirection}set drawingDirection(e){this._drawingDirection=e}get geometricExtents(){return new N}subGetOsnapPoints(e,t,i,s){B.Insertion===e&&s.push(this._location)}transformBy(e){const t=this._location.clone(),i=this._direction.lengthSq()>0?this._direction.clone().normalize():new w(Math.cos(this._rotation),Math.sin(this._rotation),0),s=new w(-i.y,i.x,i.z);s.lengthSq()===0&&s.set(0,1,0),s.normalize();const r=t.clone().add(i),a=t.clone().add(s);t.applyMatrix4(e),r.applyMatrix4(e),a.applyMatrix4(e);const o=new w(r).sub(t),h=new w(a).sub(t),c=o.length(),d=h.length();return this._location.copy(t),c>0&&(this._direction.copy(o).normalize(),this._rotation=Math.atan2(this._direction.y,this._direction.x),this._width*=c),d>0&&(this._height*=d),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:e=>{this.contents=e}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:e=>{this.styleName=e}}},{name:"attachmentPoint",type:"enum",editable:!0,options:[{label:ae[1],value:1},{label:ae[2],value:2},{label:ae[3],value:3},{label:ae[4],value:4},{label:ae[5],value:5},{label:ae[6],value:6},{label:ae[7],value:7},{label:ae[8],value:8},{label:ae[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:e=>{this.attachmentPoint=e}}},{name:"drawingDirection",type:"enum",editable:!0,options:[{label:ze[1],value:1},{label:ze[2],value:2},{label:ze[3],value:3},{label:ze[4],value:4},{label:ze[5],value:5}],accessor:{get:()=>this.drawingDirection,set:e=>{this.drawingDirection=e}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:e=>{this.height=e}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:e=>{this.rotation=e}}},{name:"lineSpacingFactor",type:"float",editable:!0,accessor:{get:()=>this.lineSpacingFactor,set:e=>{this.lineSpacingFactor=e}}},{name:"definedWidth",type:"float",editable:!0,accessor:{get:()=>this.width,set:e=>{this.width=e}}},{name:"directionX",type:"float",editable:!0,accessor:{get:()=>this.direction.x,set:e=>{this.direction.x=e}}},{name:"directionY",type:"float",editable:!0,accessor:{get:()=>this.direction.y,set:e=>{this.direction.y=e}}},{name:"directionZ",type:"float",editable:!0,accessor:{get:()=>this.direction.z,set:e=>{this.direction.z=e}}}]},{groupName:"geometry",properties:[{name:"locationX",type:"float",editable:!0,accessor:{get:()=>this.location.x,set:e=>{this.location.x=e}}},{name:"locationY",type:"float",editable:!0,accessor:{get:()=>this.location.y,set:e=>{this.location.y=e}}},{name:"locationZ",type:"float",editable:!0,accessor:{get:()=>this.location.z,set:e=>{this.location.z=e}}}]}]}}getTextStyle(){const e=this.database.tables.textStyleTable,t=e.getAt(this.styleName)??e.getAt(this.database.textstyle)??e.getAt(Z);if(!t)throw new Error("No valid text style found in text style table.");return t.textStyle}subWorldDraw(e,t){const i={text:this.contents,height:this.height,width:this.width,position:this.location,rotation:this.rotation,directionVector:this.direction,attachmentPoint:this.attachmentPoint,drawingDirection:this.drawingDirection,lineSpaceFactor:this.lineSpacingFactor};return e.mtext(i,this.getTextStyle(),t)}encodeMTextContentsForDxf(e){return e.replace(/\r\n|\r|\n/g,"\\P")}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbMText"),e.writePoint3d(10,this.location),e.writeDouble(40,this.height),e.writeDouble(41,this.width),e.writeString(1,this.encodeMTextContentsForDxf(this.contents)),e.writeString(7,this.styleName),e.writeAngle(50,this.rotation),e.writeVector3d(11,this.direction),e.writeInt16(71,this.attachmentPoint),e.writeInt16(72,this.drawingDirection),e.writeInt16(73,this.lineSpacingStyle),e.writeDouble(44,this.lineSpacingFactor),this.backgroundFill&&(e.writeInt16(90,1),e.writeInt32(63,this.backgroundFillColor),e.writeInt32(441,this.backgroundFillTransparency),e.writeDouble(45,this.backgroundScaleFactor)),this}};Qr.typeName="MText";let $i=Qr;const ea=class ea extends he{get dxfTypeName(){return"SPLINE"}constructor(e,t,i,s,r){super(),this.rebuild(e,t,i,s,r)}rebuild(e,t,i,s,r){const a=+(e!==void 0)+ +(t!==void 0)+ +(i!==void 0)+ +(s!==void 0)+ +(r!==void 0);if(a<2||a>5)throw fe.ILLEGAL_PARAMETERS;!Array.isArray(t)?this._geo=new We(e,t,i,s):this._geo=new We(e,t,i,s,r)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(e){this._geo.closed=e}subGetOsnapPoints(e,t,i,s){switch(e){case B.EndPoint:s.push(this._geo.startPoint),s.push(this._geo.endPoint);break}}transformBy(e){return this._geo.transform(e),this}subWorldDraw(e){const t=this._geo.getPoints(100);return e.lines(t)}dxfOutFields(e){var i;const t=this._geo;super.dxfOutFields(e),e.writeSubclassMarker("AcDbSpline"),e.writeInt16(70,this.closed?1:0),e.writeInt16(71,t.degree),e.writeInt16(72,t.knots.length),e.writeInt16(73,t.controlPoints.length),e.writeInt16(74,((i=t.fitPoints)==null?void 0:i.length)??0);for(const s of t.knots)e.writeDouble(40,s);for(const s of t.weights)e.writeDouble(41,s);for(const s of t.controlPoints)e.writePoint3d(10,s);for(const s of t.fitPoints??[])e.writePoint3d(11,s);return this}};ea.typeName="Spline";let qi=ea;const Dc=new w,ta=class ta extends ei{get dxfTypeName(){return"ACAD_TABLE"}constructor(e,t,i){super(e),this._attachmentPoint=ae.TopLeft,this._numColumns=i,this._numRows=t,this._columnWidth=new Array(i),this._rowHeight=new Array(t),this._cells=new Array(t*i)}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(e){this._attachmentPoint=e}get numRows(){return this._numRows}set numRows(e){this._numRows=e}get numColumns(){return this._numColumns}set numColumns(e){this._numColumns=e}numContents(e,t){return 1}rowHeight(e){return this._rowHeight[e]}setRowHeight(e,t){this._rowHeight[e]=t}setUniformRowHeight(e){this._rowHeight.fill(e)}columnWidth(e){return this._columnWidth[e]}setUniformColumnWidth(e){this._columnWidth.fill(e)}setColumnWidth(e,t){this._columnWidth[e]=t}cell(e){if(!(e<0||e>=this._cells.length))return this._cells[e]}setCell(e,t){this._cells[e]=t}textString(e,t,i){var r;const s=e*this._numColumns+t;return(r=this._cells[s])==null?void 0:r.text}setTextString(e,t,i){const s=e*this._numColumns+t;if(!this._cells[s]){this._cells[s]={text:i,attachmentPoint:this._attachmentPoint,cellType:1,textHeight:0};return}this._cells[s].text=i}isEmpty(e,t){var s;const i=e*this._numColumns+t;return!((s=this._cells[i])!=null&&s.text)}get geometricExtents(){return new N}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"table",properties:[{name:"numRows",type:"string",editable:!0,accessor:{get:()=>this.numRows,set:e=>{this.numRows=e}}},{name:"numColumns",type:"float",editable:!0,accessor:{get:()=>this.numColumns,set:e=>{this.numColumns=e}}},{name:"tableWidth",type:"float",editable:!1,accessor:{get:()=>this._columnWidth.reduce((e,t)=>e+t,0)}},{name:"tableHeight",type:"float",editable:!1,accessor:{get:()=>this._rowHeight.reduce((e,t)=>e+t,0)}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:e=>{this.position.x=e}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:e=>{this.position.y=e}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:e=>{this.position.z=e}}}]}]}}subWorldDraw(e){const t=this.blockTableRecord;if(!this.hasRenderableCellContent()&&t&&t.newIterator().count>0){const g=this.drawAnonymousTableBlock(e,t);if(g)return g}let i=0,s=0;const r=new Uint16Array(this.numColumns*this.numRows*8),a=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let o=0;for(let g=0;g<=this.numRows;g++){i-=g>0?this.rowHeight(g-1):0,s=0;for(let m=0;m<=this.numColumns;m++)s+=m>0?this.columnWidth(m-1):0,a[o++]=s,a[o++]=i,a[o++]=0}const h=[],c=new Array(this.numRows*this.numColumns).fill(!1);s=0,o=0;let d=0;for(let g=0;g<this.numColumns;g++){s+=g>0?this.columnWidth(g-1):0,i=0;for(let m=0;m<this.numRows;m++){i+=m>0?this.rowHeight(m-1):0;const y=this.cell(m*this.numColumns+g);if(d=m*this.numColumns+g,y&&!c[d]){const x=y.borderWidth??1,_=y.borderHeight??1;this.fillVisited(c,d,this.numColumns,x,_),r[o++]=g+m*(this.numColumns+1),r[o++]=g+m*(this.numColumns+1)+x;const S=a[r[o-1]*3]-s,L=g+(m+_)*(this.numColumns+1)+x;g+x==this.numColumns&&(r[o++]=g+m*(this.numColumns+1)+x,r[o++]=L);const T=-a[L*3+1]-i;if(m+_==this.numRows&&(r[o++]=g+(m+_)*(this.numColumns+1)+_,r[o++]=g+(m+_)*(this.numColumns+1)),r[o++]=g+(m+_)*(this.numColumns+1),r[o++]=g+m*(this.numColumns+1),y.text){const I=y.attachmentPoint||this.attachmentPoint||ae.MiddleCenter,j=this.getTableTextOffset(I,S,T),M={text:y.text,height:this.getCellTextHeight(y,T),width:S,position:Dc.set(s,-i,0).clone().add(j),rotation:this.rotation,attachmentPoint:I},U=this.getTextStyle(y);h.push(e.mtext(M,U))}}}}h.push(e.lineSegments(a,3,r));const u=e.group(h),p=new ni;return p.setFromAxisAngle(w.Z_AXIS,this.rotation),xn.compose(this.position,p,this.scaleFactors),u.applyMatrix(xn),u}hasRenderableCellContent(){return this._cells.some(e=>!!e&&(!!e.text||!!e.blockTableRecordId))}drawAnonymousTableBlock(e,t){const i=[],s=t.newIterator();for(const o of s){let h;o.color.isByBlock&&this.rgbColor?(Na.copy(o.color),o.color.setRGBValue(this.rgbColor),h=o.worldDraw(e),o.color.copy(Na)):h=o.worldDraw(e),h&&(h.objectId=this.objectId,h.ownerId=this.ownerId,h.layerName=this.layer,h.visible=this.visibility&&o.visibility,i.push(h))}const r=e.group(i);r.applyMatrix(this.blockTransform);const a=this.normal;return a&&(a.x!==0||a.y!==0||a.z!==1)&&(xn.setFromExtrusionDirection(a),r.applyMatrix(xn)),r}fillVisited(e,t,i,s,r){if(r==1&&s==1)e[t]=!0;else for(let a=0;a<s;++a)for(let o=0;o<r;++o)e[t+a+o*i]=!0}getTextStyle(e){const t=this.database.tables.textStyleTable,i=(e.textStyle?t.getAt(e.textStyle):void 0)??t.getAt(this.database.textstyle)??t.getAt(Z);if(!i)throw new Error("No valid text style found in text style table.");return i.textStyle}getTableTextOffset(e,t,i){const s=new w;switch(e){case 1:break;case 2:s.setX(t/2);break;case 3:s.setX(t);break;case 4:s.setY(-i/2);break;case 5:s.set(t/2,-i/2,0);break;case 6:s.set(t,-i/2,0);break;case 7:s.setY(-i);break;case 8:s.set(t/2,-i,0);break;case 9:s.set(t,-i,0);break}return s}getCellTextHeight(e,t){return e.textHeight&&e.textHeight>0?e.textHeight:Math.max(t/2,1)}dxfOutFields(e){var r,a,o,h,c,d,u;super.dxfOutFields(e),e.writeSubclassMarker("AcDbTable");const t=e.version??((r=e.database)==null?void 0:r.version)??((a=this.database)==null?void 0:a.version),i=(t==null?void 0:t.value)!=null?t.value>=27:!1;e.writeInt16(280,this.tableDataVersion),e.writeObjectId(342,this.tableStyleId),e.writeObjectId(343,this.owningBlockRecordId),e.writeVector3d(11,this.horizontalDirection),e.writeUInt32(90,this.tableValueFlag),e.writeUInt32(93,this.tableOverrideFlag),e.writeUInt32(94,this.borderColorOverrideFlag),e.writeUInt32(95,this.borderLineweightOverrideFlag),e.writeUInt32(96,this.borderVisibilityOverrideFlag),e.writeInt16(71,this.attachmentPoint),e.writeInt32(91,this.numRows),e.writeInt32(92,this.numColumns);for(let p=0;p<this.numRows;++p)e.writeDouble(141,this.rowHeight(p));for(let p=0;p<this.numColumns;++p)e.writeDouble(142,this.columnWidth(p));const s=this._cells.length>0?this._cells.length:this.numRows*this.numColumns;for(let p=0;p<s;p++){const g=this._cells[p],m=(g==null?void 0:g.cellType)??(g!=null&&g.blockTableRecordId?2:1);if(e.writeInt16(171,m),e.writeInt16(172,(g==null?void 0:g.flagValue)??0),e.writeInt16(173,(g==null?void 0:g.mergedValue)??0),e.writeBoolean(174,g==null?void 0:g.autoFit),e.writeInt16(175,g==null?void 0:g.borderWidth),e.writeInt16(176,g==null?void 0:g.borderHeight),(g==null?void 0:g.overrideFlag)!=null&&(i?e.writeInt32(91,g.overrideFlag):e.writeInt16(177,g.overrideFlag)),e.writeInt16(178,g==null?void 0:g.virtualEdgeFlag),e.writeAngle(145,g==null?void 0:g.rotation),i&&e.writeInt16(92,g==null?void 0:g.extendedCellFlags),m===1)g!=null&&g.fieldObjetId?e.writeObjectId(344,g.fieldObjetId):this.writeCellText(e,(g==null?void 0:g.text)??"",i,g==null?void 0:g.cellValueBlockBegin);else if(m===2){if(e.writeObjectId(340,g==null?void 0:g.blockTableRecordId),e.writeDouble(144,g==null?void 0:g.blockScale),e.writeInt16(179,g==null?void 0:g.blockAttrNum),(o=g==null?void 0:g.attrDefineId)!=null&&o.length)for(const y of g.attrDefineId)e.writeObjectId(331,y);if((g==null?void 0:g.attrText)!=null)if(Array.isArray(g.attrText))for(const y of g.attrText)e.writeString(300,y);else e.writeString(300,g.attrText)}g!=null&&g.textStyle&&e.writeString(7,g.textStyle),(g==null?void 0:g.textHeight)!=null&&e.writeDouble(140,g.textHeight),(g==null?void 0:g.attachmentPoint)!=null&&e.writeInt16(170,g.attachmentPoint),(g==null?void 0:g.topBorderVisibility)!=null&&e.writeInt16(289,g.topBorderVisibility?1:0),(g==null?void 0:g.rightBorderVisibility)!=null&&e.writeInt16(285,g.rightBorderVisibility?1:0),(g==null?void 0:g.bottomBorderVisibility)!=null&&e.writeInt16(286,g.bottomBorderVisibility?1:0),(g==null?void 0:g.leftBorderVisibility)!=null&&e.writeInt16(288,g.leftBorderVisibility?1:0)}if(e.writeInt16(70,this.flowDirection),e.writeDouble(40,this.horizontalCellMargin),e.writeDouble(41,this.verticalCellMargin),this.suppressTitle!=null&&e.writeInt16(280,this.suppressTitle?1:0),this.suppressHeader!=null&&e.writeInt16(281,this.suppressHeader?1:0),(h=this.cellTypeOverrides)!=null&&h.length)for(const p of this.cellTypeOverrides){e.writeString(7,p.textStyle),e.writeDouble(140,p.textHeight),e.writeInt16(170,p.alignment),e.writeInt16(63,p.backgroundColor),e.writeInt16(64,p.contentColor),p.backgroundColorEnabled!=null&&e.writeInt16(283,p.backgroundColorEnabled?1:0);const g=p.borderLineweights;g&&(e.writeInt16(274,g.top),e.writeInt16(275,g.right),e.writeInt16(276,g.bottom),e.writeInt16(277,g.left),e.writeInt16(278,g.insideHorizontal),e.writeInt16(279,g.insideVertical));const m=p.borderVisibility;m&&(e.writeInt16(284,m.top?1:0),e.writeInt16(285,m.right?1:0),e.writeInt16(286,m.bottom?1:0),e.writeInt16(287,m.left?1:0),e.writeInt16(288,m.insideHorizontal?1:0),e.writeInt16(289,m.insideVertical?1:0))}if(this.tableBorderColors&&(e.writeInt16(63,this.tableBorderColors.left),e.writeInt16(64,this.tableBorderColors.top),e.writeInt16(65,this.tableBorderColors.insideHorizontal),e.writeInt16(66,this.tableBorderColors.bottom),e.writeInt16(68,this.tableBorderColors.insideVertical),e.writeInt16(69,this.tableBorderColors.right)),(c=this.rowDataTypes)!=null&&c.length)for(const p of this.rowDataTypes)e.writeInt16(97,p);if((d=this.rowUnitTypes)!=null&&d.length)for(const p of this.rowUnitTypes)e.writeInt16(98,p);if((u=this.rowFormats)!=null&&u.length)for(const p of this.rowFormats)e.writeString(4,p);return this}writeCellText(e,t,i,s){if(!i){if(t.length<=250){e.writeString(1,t);return}const o=Math.ceil(t.length/250);for(let h=0;h<o;h++){const c=h*250,d=c+250,u=t.slice(c,d);h===o-1?e.writeString(1,u):e.writeString(2,u)}return}if(e.writeString(301,s??"CELL_VALUE"),t.length<=250){e.writeString(302,t),e.writeString(304,"ACVALUE_END");return}const a=Math.ceil(t.length/250);for(let o=0;o<a;o++){const h=o*250,c=h+250,d=t.slice(h,c);o===a-1?e.writeString(302,d):e.writeString(303,d)}e.writeString(304,"ACVALUE_END")}};ta.typeName="Table";let Un=ta;const xn=new D,Na=new z,ia=class ia extends he{get dxfTypeName(){return"TRACE"}constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new f,new f,new f,new f]}get elevation(){return this._elevation}set elevation(e){this._elevation=e}get closed(){return!0}get thickness(){return this._thickness}set thickness(e){this._thickness=e}getPointAt(e){return e<0?this._vertices[0]:e>3?this._vertices[3]:this._vertices[e]}setPointAt(e,t){if(e<0&&this._vertices[0].copy(t),e>3)return this._vertices[3].copy(t);this._vertices[e].copy(t)}get geometricExtents(){return new N().setFromPoints(this._vertices)}subGetGripPoints(){const e=new Array;return e.push(...this._vertices),e}subGetOsnapPoints(e,t,i,s){switch(e){case B.EndPoint:s.push(...this._vertices);break}}transformBy(e){return this._vertices.forEach(t=>t.applyMatrix4(e)),this._elevation=this._vertices[0].z,this}subWorldDraw(e){const t=new oe(this._vertices,!0),i=new Pt;i.add(t);const s=e.subEntityTraits;return s.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},e.area(i)}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbTrace"),e.writeDouble(38,this.elevation),e.writeDouble(39,this.thickness),e.writePoint3d(10,this.getPointAt(0)),e.writePoint3d(11,this.getPointAt(1)),e.writePoint3d(12,this.getPointAt(2)),e.writePoint3d(13,this.getPointAt(3)),this}};ia.typeName="Trace";let $n=ia;const na=class na extends he{get dxfTypeName(){return"LWPOLYLINE"}constructor(){super(),this._elevation=0,this._geo=new oe}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(e){this._elevation=e}get closed(){return this._geo.closed}set closed(e){this._geo.closed=e}addVertexAt(e,t,i=0,s=-1,r=-1){const a=s<0?void 0:s,o=r<0?void 0:r,h={x:t.x,y:t.y,bulge:i,startWidth:a,endWidth:o};this._geo.addVertexAt(e,h)}removeVertexAt(e){this._geo.removeVertexAt(e)}reset(e,t){this._geo.reset(e,t)}getPoint2dAt(e){return this._geo.getPointAt(e)}getPoint3dAt(e){const t=this.getPoint2dAt(e);return new f(t.x,t.y,this._elevation)}get geometricExtents(){const e=this._geo.box;return new N({x:e.min.x,y:e.min.y,z:this._elevation},{x:e.max.x,y:e.max.y,z:this._elevation})}subGetGripPoints(){const e=new Array;for(let t=0;t<this.numberOfVertices;++t)e.push(this.getPoint3dAt(t));return e}subGetOsnapPoints(e,t,i,s){const r=new Array;for(let a=0;a<this.numberOfVertices;++a)r.push(this.getPoint3dAt(a));switch(e){case B.EndPoint:s.push(...r);break}}transformBy(e){const t=e.determinant()<0;let i=this._elevation;return this._geo.vertices.forEach(s=>{const r=new f(s.x,s.y,this._elevation).applyMatrix4(e);s.x=r.x,s.y=r.y,i=r.z,t&&s.bulge!=null&&(s.bulge=-s.bulge)}),this._elevation=i,this._geo._boundingBoxNeedsUpdate=!0,this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:e=>{this.elevation=e}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:e=>{this.closed=e}}}]}]}}subWorldDraw(e){const t=this._geo.getPoints(100),i=this.createWidthProfile();if(i!=null){const r=zc(i,this.closed);if(r!=null){const a=e.subEntityTraits;return a.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},e.area(r)}}const s=[];return t.forEach(r=>s.push(new f().set(r.x,r.y,this.elevation))),e.lines(s)}dxfOutFields(e){super.dxfOutFields(e),e.writeSubclassMarker("AcDbPolyline"),e.writeInt32(90,this.numberOfVertices),e.writeInt16(70,this.closed?1:0),e.writeDouble(38,this.elevation);for(let t=0;t<this.numberOfVertices;++t)e.writePoint2d(10,this.getPoint2dAt(t));return this}createWidthProfile(){const e=this._geo.vertices,t=e.length;if(t<2)return null;const i=this.closed?t:t-1,s=[];let r=!1;for(let a=0;a<i;a++){const o=e[a],h=e[(a+1)%t],c=Math.max(0,o.startWidth??0),d=Math.max(0,o.endWidth??0);(c>ke||d>ke)&&(r=!0);const u=this.sampleSegment(o,h),p=u.length-1;for(let g=0;g<=p;g++){if(g===0&&s.length>0||this.closed&&a===i-1&&g===p)continue;const m=p>0?g/p:0;s.push({x:u[g].x,y:u[g].y,width:Gc(c,d,m)})}}return r&&s.length>=2?s:null}sampleSegment(e,t){if(e.bulge&&Math.abs(e.bulge)>ke){const s=new Et(e,t,e.bulge).getPoints(32);if(s.length>1)return s.map(r=>new v(r.x,r.y))}return[new v(e.x,e.y),new v(t.x,t.y)]}};na.typeName="Polyline";let qn=na;const ke=1e-6,Ya=4;function zc(n,e){if(n.length<2)return null;const t=jc(n,e);if(t.length<2)return null;const{left:i,right:s}=Vc(t,e);if(i.length<2||s.length<2)return null;const r=new Pt;if(e){if(!Ps(i)||!Ps(s))return null;const o=Math.abs(qs(i)),h=Math.abs(qs(s)),[c,d]=o>=h?[i,s]:[s,i];return r.add(new oe(c,!0)),r.add(new oe(d,!0)),r}const a=[...i,...s.reverse()];return Ps(a)?(r.add(new oe(a,!0)),r):null}function Vc(n,e){const t=[],i=[];for(let s=0;s<n.length;s++){const r=n[s],a=Math.max(0,r.width)/2;if(a<=ke)continue;const o=Wc(n,s,e);o!=null&&(t.push({x:r.x+o.x*a,y:r.y+o.y*a}),i.push({x:r.x-o.x*a,y:r.y-o.y*a}))}return{left:t,right:i}}function jc(n,e){const t=[];if(n.forEach(i=>{const s=t[t.length-1];(!s||Math.abs(s.x-i.x)>ke||Math.abs(s.y-i.y)>ke||Math.abs(s.width-i.width)>ke)&&t.push(i)}),e&&t.length>1){const i=t[0],s=t[t.length-1];Math.abs(i.x-s.x)<=ke&&Math.abs(i.y-s.y)<=ke&&t.pop()}return t}function Wc(n,e,t){const i=n.length,s=n[e],r=n[(e-1+i)%i],a=n[(e+1)%i];let o=Xa(s.x-r.x,s.y-r.y),h=Xa(a.x-s.x,a.y-s.y);if(t||(e===0&&(o=h),e===i-1&&(h=o)),o==null&&h==null)return null;if(o==null)return wn(h);if(h==null)return wn(o);const c=wn(o),d=wn(h),u=c.x+d.x,p=c.y+d.y,g=Math.hypot(u,p);if(g<=ke)return d;const m={x:u/g,y:p/g},y=Math.abs(m.x*d.x+m.y*d.y),x=y<=ke?Ya:Math.min(1/y,Ya);return{x:m.x*x,y:m.y*x}}function Xa(n,e){const t=Math.hypot(n,e);return t<=ke?null:{x:n/t,y:e/t}}function wn(n){return{x:-n.y,y:n.x}}function qs(n){let e=0;const t=n.length;for(let i=0;i<t;i++){const s=n[i],r=n[(i+1)%t];e+=s.x*r.y-r.x*s.y}return e/2}function Ps(n){return n.length>=3&&Math.abs(qs(n))>ke}function Gc(n,e,t){return n+(e-n)*t}const sa=class sa extends le{get dxfTypeName(){return"POINT"}constructor(){super(),this._geo=new f}get position(){return this._geo}set position(e){this._geo.set(e.x,e.y,e.z||0)}get geometricExtents(){return new N().expandByPoint(this._geo)}subGetOsnapPoints(e,t,i,s){B.Node===e&&s.push(this._geo)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:e=>{this.position.x=e}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:e=>{this.position.y=e}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:e=>{this.position.z=e}}}]}]}}transformBy(e){return this._geo.applyMatrix4(e),this}subWorldDraw(e){return e.point(this._geo,{displayMode:this.database.pdmode,displaySize:this.database.pdsize})}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbPoint"),e.writePoint3d(10,this.position),this}};sa.typeName="Point";let Zn=sa;var nl=(n=>(n[n.Invalid=0]="Invalid",n[n.Rect=1]="Rect",n[n.Poly=2]="Poly",n))(nl||{}),sl=(n=>(n[n.Show=1]="Show",n[n.ShowUnAligned=2]="ShowUnAligned",n[n.Clip=4]="Clip",n[n.Transparent=8]="Transparent",n))(sl||{});const ra=class ra extends le{get dxfTypeName(){return"IMAGE"}constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new f,this._scale=new $(1,1),this._rotation=0,this._imageSize=new v,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isShownClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get brightness(){return this._brightness}set brightness(e){this._brightness=e}get contrast(){return this._contrast}set contrast(e){this._contrast=e}get fade(){return this._fade}set fade(e){this._fade=e}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get position(){return this._position}set position(e){this._position=e}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get scale(){return this._scale}set scale(e){this._scale.copy(e)}get imageSize(){return this._imageSize}set imageSize(e){this._imageSize.copy(e)}get clipBoundaryType(){return this._clipBoundaryType}set clipBoundaryType(e){this._clipBoundaryType=e}get clipBoundary(){return this._clipBoundary}set clipBoundary(e){this._clipBoundary=[],this._clipBoundary.push(...e)}get isClipped(){return this._isClipped}set isClipped(e){this._isClipped=e}get isShownClipped(){return this._isShownClipped}set isShownClipped(e){this._isShownClipped=e}get isImageShown(){return this._isImageShown}set isImageShown(e){this._isImageShown=e}get isImageTransparent(){return this._isImageTransparent}set isImageTransparent(e){this._isImageTransparent=e}get image(){return this._image}set image(e){this._image=e}get imageDefId(){return this._imageDefId}set imageDefId(e){this._imageDefId=e}get imageFileName(){if(this._imageDefId){const e=this.database.objects.imageDefinition.getIdAt(this._imageDefId);if(e)return e.sourceFileName}return""}get geometricExtents(){const e=new N;return e.min.copy(this._position),e.max.set(this._position.x+this._width,this._position.y+this._height,0),e}subGetGripPoints(){return this.boundaryPath()}subWorldDraw(e){const t=this.boundaryPath();return this._image?e.image(this._image,{boundary:t,roation:this._rotation}):e.lines(t)}transformBy(e){const t=this._width*this._scale.x,i=this._height*this._scale.y,s=new w(t*Math.cos(this._rotation),t*Math.sin(this._rotation),0),r=new w(-i*Math.sin(this._rotation),i*Math.cos(this._rotation),0),a=this._position.clone(),o=this._position.clone().add(s),h=this._position.clone().add(r);a.applyMatrix4(e),o.applyMatrix4(e),h.applyMatrix4(e);const c=new w(o).sub(a),d=new w(h).sub(a);return this._position.copy(a),this._rotation=Math.atan2(c.y,c.x),this._width=c.length(),this._height=d.length(),this._scale.set(1,1),this}boundaryPath(){const e=[];if(this.isClipped&&this._clipBoundary.length>3){const t=this._width,i=this._height,s=new _e;s.setFromPoints(this._clipBoundary);const r=new v;r.setX(this._position.x-s.min.x*t),r.setY(this._position.y-s.min.y*i),this._clipBoundary.forEach(a=>{const o=a.x*t+r.x,h=a.y*i+r.y;e.push(new f(o,h,this._position.z))})}else{if(e.push(this._position),e.push(this._position.clone().setX(this._position.x+this._width)),e.push(this._position.clone().set(this._position.x+this._width,this._position.y+this._height,this._position.z)),e.push(this._position.clone().setY(this._position.y+this._height)),this._rotation>0){Ra.copy(e[1]);for(let t=1;t<4;t++)fn.copy(e[t]),fn.rotateAround(Ra,this._rotation),e[t].setX(fn.x),e[t].setY(fn.y)}e.push(e[0])}return e}dxfOutFields(e){super.dxfOutFields(e),e.writeSubclassMarker("AcDbRasterImage"),e.writePoint3d(10,this.position);const t=this.width*this.scale.x,i=this.height*this.scale.y,s=this._imageSize.x>0&&this._imageSize.y>0?this._imageSize:{x:t,y:i},r=s.x>0?t/s.x:t,a=s.y>0?i/s.y:i,o=Math.cos(this._rotation),h=Math.sin(this._rotation);e.writePoint3d(11,{x:r*o,y:r*h,z:0}),e.writePoint3d(12,{x:-a*h,y:a*o,z:0}),e.writePoint2d(13,s),e.writeObjectId(340,this.imageDefId);const c=(this.isImageShown?1:0)|(this.isShownClipped?4:0)|(this.isImageTransparent?8:0);if(e.writeInt16(70,c),e.writeInt16(280,this.isClipped?1:0),e.writeInt16(281,this.brightness),e.writeInt16(282,this.contrast),e.writeInt16(283,this.fade),e.writeInt16(71,this.clipBoundaryType),this.isClipped){e.writeInt16(91,this.clipBoundary.length);for(const d of this.clipBoundary)e.writePoint2d(14,d)}return this}};ra.typeName="RasterImage";let Zi=ra;const Ra=new v,fn=new v,aa=class aa extends he{get dxfTypeName(){return"RAY"}constructor(){super(),this._basePoint=new f,this._unitDir=new w}get basePoint(){return this._basePoint}set basePoint(e){this._basePoint.copy(e)}get unitDir(){return this._unitDir}set unitDir(e){this._unitDir.copy(e)}get closed(){return!1}get geometricExtents(){const e=new N;return e.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),e.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),e}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:e=>{this.basePoint.x=e}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:e=>{this.basePoint.y=e}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:e=>{this.basePoint.z=e}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:e=>{this.unitDir.x=e}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:e=>{this.unitDir.y=e}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:e=>{this.unitDir.z=e}}}]}]}}subGetGripPoints(){const e=new Array;return e.push(this.basePoint),e}subGetOsnapPoints(e,t,i,s){switch(e){case B.EndPoint:s.push(this.basePoint);break}}transformBy(e){return this._basePoint.applyMatrix4(e),this._unitDir.transformDirection(e),this}subWorldDraw(e){const t=[];return t.push(this.basePoint),t.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),e.lines(t)}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbRay"),e.writePoint3d(10,this.basePoint),e.writeVector3d(11,this.unitDir),this}};aa.typeName="Ray";let Kn=aa;const oa=class oa extends le{get dxfTypeName(){return"VIEWPORT"}constructor(){super(),this._centerPoint=new f,this._height=0,this._width=0,this._viewCenter=new f,this._viewHeight=0,this._number=-1}get number(){return this._number}set number(e){this._number=e}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint=e}get height(){return this._height}set height(e){this._height=e}get width(){return this._width}set width(e){this._width=e}get viewCenter(){return this._viewCenter}set viewCenter(e){this._viewCenter=e}get viewHeight(){return this._viewHeight}set viewHeight(e){this._viewHeight=e}get geometricExtents(){return new N}transformBy(e){const t=this._centerPoint.clone(),i=this._centerPoint.clone().add(new w(this._width,0,0)),s=this._centerPoint.clone().add(new w(0,this._height,0));t.applyMatrix4(e),i.applyMatrix4(e),s.applyMatrix4(e);const r=new w(i).sub(t),a=new w(s).sub(t),o=this._height!==0?a.length()/this._height:1;return this._centerPoint.copy(t),this._width=r.length(),this._height=a.length(),this._viewHeight*=o,this}subWorldDraw(e){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const t=this.toGiViewport();return e.group(this.createViewportRect(t,e))}}toGiViewport(){const e=new Wo;return e.id=this.objectId,e.groupId=this.ownerId,e.number=this.number,e.centerPoint=this.centerPoint,e.width=this.width,e.height=this.height,e.viewHeight=this.viewHeight,e.viewCenter=this.viewCenter,e}createViewportRect(e,t){const i=[];return i.push(t.lines([new f(e.centerPoint.x-e.width/2,e.centerPoint.y-e.height/2,0),new f(e.centerPoint.x+e.width/2,e.centerPoint.y-e.height/2,0)])),i.push(t.lines([new f(e.centerPoint.x+e.width/2,e.centerPoint.y-e.height/2,0),new f(e.centerPoint.x+e.width/2,e.centerPoint.y+e.height/2,0)])),i.push(t.lines([new f(e.centerPoint.x+e.width/2,e.centerPoint.y+e.height/2,0),new f(e.centerPoint.x-e.width/2,e.centerPoint.y+e.height/2,0)])),i.push(t.lines([new f(e.centerPoint.x-e.width/2,e.centerPoint.y+e.height/2,0),new f(e.centerPoint.x-e.width/2,e.centerPoint.y-e.height/2,0)])),i}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbViewport"),e.writePoint3d(10,this.centerPoint),e.writeDouble(40,this.height),e.writeDouble(41,this.width),e.writePoint3d(12,this.viewCenter),e.writeDouble(45,this.viewHeight),e.writeInt32(69,this.number),this}};oa.typeName="Viewport";let Jn=oa;const la=class la extends Zi{get dxfTypeName(){return"WIPEOUT"}subWorldDraw(e){const t=this.boundaryPath(),i=new Pt;return i.add(new oe(t)),e.area(i)}dxfOutFields(e){return super.dxfOutFields(e),this}};la.typeName="Wipeout";let Qn=la;const ha=class ha extends he{get dxfTypeName(){return"XLINE"}constructor(){super(),this._basePoint=new f,this._unitDir=new w}get basePoint(){return this._basePoint}set basePoint(e){this._basePoint.copy(e)}get unitDir(){return this._unitDir}set unitDir(e){this._unitDir.copy(e)}get closed(){return!1}get geometricExtents(){const e=new N;return e.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),e.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),e}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"basePointX",type:"float",editable:!0,accessor:{get:()=>this.basePoint.x,set:e=>{this.basePoint.x=e}}},{name:"basePointY",type:"float",editable:!0,accessor:{get:()=>this.basePoint.y,set:e=>{this.basePoint.y=e}}},{name:"basePointZ",type:"float",editable:!0,accessor:{get:()=>this.basePoint.z,set:e=>{this.basePoint.z=e}}},{name:"unitDirX",type:"float",editable:!0,accessor:{get:()=>this.unitDir.x,set:e=>{this.unitDir.x=e}}},{name:"unitDirY",type:"float",editable:!0,accessor:{get:()=>this.unitDir.y,set:e=>{this.unitDir.y=e}}},{name:"unitDirZ",type:"float",editable:!0,accessor:{get:()=>this.unitDir.z,set:e=>{this.unitDir.z=e}}}]}]}}subGetGripPoints(){const e=new Array;return e.push(this.basePoint),e}transformBy(e){return this._basePoint.applyMatrix4(e),this._unitDir.transformDirection(e),this}subWorldDraw(e){const t=[];return t.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),t.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),e.lines(t)}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbXline"),e.writePoint3d(10,this.basePoint),e.writeVector3d(11,this.unitDir),this}};ha.typeName="Xline";let es=ha;class rl{constructor(e){this.position=new f(e.x,e.y,e.z||0)}}const ca=class ca extends he{get dxfTypeName(){return"POLYLINE"}constructor(e,t,i,s=!1,r=!1){super(),this._mCount=e,this._nCount=t,this._closedM=s,this._closedN=r,this._vertices=i.map(a=>new rl(a))}get mCount(){return this._mCount}get nCount(){return this._nCount}get closedM(){return this._closedM}get closedN(){return this._closedN}get closed(){return this._closedM}set closed(e){this._closedM=e}get numberOfVertices(){return this._vertices.length}getVertexAt(e){if(e<0||e>=this._vertices.length)throw new Error("Vertex index out of bounds");return this._vertices[e]}getVertexAtMN(e,t){const i=e*this._nCount+t;return this.getVertexAt(i)}get geometricExtents(){if(this._vertices.length===0)return new N(new f(0,0,0),new f(0,0,0));let e=Number.MAX_VALUE,t=Number.MAX_VALUE,i=Number.MAX_VALUE,s=-Number.MAX_VALUE,r=-Number.MAX_VALUE,a=-Number.MAX_VALUE;return this._vertices.forEach(o=>{e=Math.min(e,o.position.x),t=Math.min(t,o.position.y),i=Math.min(i,o.position.z),s=Math.max(s,o.position.x),r=Math.max(r,o.position.y),a=Math.max(a,o.position.z)}),new N(new f(e,t,i),new f(s,r,a))}subGetGripPoints(){const e=new Array;return this._vertices.forEach(t=>{e.push(t.position)}),e}subGetOsnapPoints(e,t,i,s){switch(e){case B.EndPoint:this._vertices.forEach(r=>{s.push(r.position)});break}}transformBy(e){return this._vertices.forEach(t=>{t.position.applyMatrix4(e)}),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"mCount",type:"float",editable:!1,accessor:{get:()=>this._mCount}},{name:"nCount",type:"float",editable:!1,accessor:{get:()=>this._nCount}},{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._vertices.map(e=>({x:e.position.x,y:e.position.y,z:e.position.z}))}}]},{groupName:"others",properties:[{name:"closedM",type:"boolean",editable:!0,accessor:{get:()=>this._closedM,set:e=>{this._closedM=e}}},{name:"closedN",type:"boolean",editable:!0,accessor:{get:()=>this._closedN,set:e=>{this._closedN=e}}}]}]}}subWorldDraw(e){const t=[];for(let i=0;i<this._mCount;i++)for(let s=0;s<this._nCount;s++){const r=this.getVertexAtMN(i,s);let a=s+1;if(a>=this._nCount)if(this._closedN)a=0;else continue;const o=this.getVertexAtMN(i,a);t.push(r.position),t.push(o.position)}for(let i=0;i<this._nCount;i++)for(let s=0;s<this._mCount;s++){const r=this.getVertexAtMN(s,i);let a=s+1;if(a>=this._mCount)if(this._closedM)a=0;else continue;const o=this.getVertexAtMN(a,i);t.push(r.position),t.push(o.position)}return e.lines(t)}dxfOutFields(e){super.dxfOutFields(e),e.writeSubclassMarker("AcDbPolygonMesh");let t=16;return this._closedM&&(t|=1),this._closedN&&(t|=32),e.writeInt16(66,1),e.writeInt16(70,t),e.writeInt32(71,this._mCount),e.writeInt32(72,this._nCount),this}dxfOut(e,t=!1){super.dxfOut(e,t);for(let i=0;i<this.numberOfVertices;i++){const s=this.getVertexAt(i);e.writeStart("VERTEX"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity"),e.writeSubclassMarker("AcDbVertex"),e.writeSubclassMarker("AcDbPolygonMeshVertex"),e.writePoint3d(10,s.position),e.writeInt16(70,16)}return e.writeStart("SEQEND"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity"),this}};ca.typeName="PolygonMesh";let ts=ca;class al{constructor(e){this.position=new f(e.x,e.y,e.z||0)}}class ol{constructor(e){this.vertexIndices=e}}const da=class da extends he{get dxfTypeName(){return"POLYLINE"}constructor(e,t){super(),this._vertices=e.map(i=>new al(i)),this._faces=t.map(i=>new ol(i))}get numberOfVertices(){return this._vertices.length}get numberOfFaces(){return this._faces.length}get closed(){return!1}set closed(e){}getVertexAt(e){if(e<0||e>=this._vertices.length)throw new Error("Vertex index out of bounds");return this._vertices[e]}getFaceAt(e){if(e<0||e>=this._faces.length)throw new Error("Face index out of bounds");return this._faces[e]}get geometricExtents(){if(this._vertices.length===0)return new N(new f(0,0,0),new f(0,0,0));let e=Number.MAX_VALUE,t=Number.MAX_VALUE,i=Number.MAX_VALUE,s=-Number.MAX_VALUE,r=-Number.MAX_VALUE,a=-Number.MAX_VALUE;return this._vertices.forEach(o=>{e=Math.min(e,o.position.x),t=Math.min(t,o.position.y),i=Math.min(i,o.position.z),s=Math.max(s,o.position.x),r=Math.max(r,o.position.y),a=Math.max(a,o.position.z)}),new N(new f(e,t,i),new f(s,r,a))}subGetGripPoints(){const e=new Array;return this._vertices.forEach(t=>{e.push(t.position)}),e}subGetOsnapPoints(e,t,i,s){switch(e){case B.EndPoint:this._vertices.forEach(r=>{s.push(r.position)});break}}transformBy(e){return this._vertices.forEach(t=>{t.position.applyMatrix4(e)}),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._vertices.map(e=>({x:e.position.x,y:e.position.y,z:e.position.z}))}},{name:"faces",type:"array",editable:!1,itemSchema:{properties:[{name:"vertexIndices",type:"array",editable:!1,itemSchema:{properties:[{name:"index",type:"int",editable:!1}]}}]},accessor:{get:()=>this._faces.map(e=>({vertexIndices:e.vertexIndices}))}}]}]}}subWorldDraw(e){const t=[];return this._faces.forEach(i=>{const s=[];if(i.vertexIndices.forEach(r=>{const a=Math.abs(r)-1;a>=0&&a<this._vertices.length&&s.push(this._vertices[a].position)}),s.length>=3)for(let r=0;r<s.length;r++){const a=s[r],o=s[(r+1)%s.length];t.push(a),t.push(o)}}),e.lines(t)}dxfOutFields(e){super.dxfOutFields(e),e.writeSubclassMarker("AcDbPolyFaceMesh");const t=64;return e.writeInt16(66,1),e.writeInt16(70,t),this}dxfOut(e,t=!1){super.dxfOut(e,t);for(let i=0;i<this.numberOfVertices;i++){const s=this.getVertexAt(i);e.writeStart("VERTEX"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity"),e.writeSubclassMarker("AcDbVertex"),e.writeSubclassMarker("AcDbPolyFaceMeshVertex"),e.writePoint3d(10,s.position),e.writeInt16(70,64)}for(let i=0;i<this.numberOfFaces;i++){const s=this.getFaceAt(i);e.writeStart("VERTEX"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity"),e.writeSubclassMarker("AcDbVertex"),e.writeSubclassMarker("AcDbPolyFaceMeshVertex"),e.writeInt16(70,128),s.vertexIndices.forEach((r,a)=>{e.writeInt32(10+a,r)})}return e.writeStart("SEQEND"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity"),this}};da.typeName="PolyFaceMesh";let is=da;var ns=(n=>(n[n.AtLeast=1]="AtLeast",n[n.Exactly=2]="Exactly",n))(ns||{});const ua=class ua extends le{get dxfTypeName(){return"DIMENSION"}constructor(){super(),this._dimBlockId=null,this._dimBlockPosition=new f,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new f,this._textRotation=0,this._normal=new w(0,0,1)}get dimBlockId(){return this._dimBlockId}set dimBlockId(e){this._dimBlockId=e}get dimBlockPosition(){return this._dimBlockPosition}set dimBlockPosition(e){this._dimBlockPosition.copy(e)}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(e){this._dimensionStyleName=e,this._dimStyle=void 0}get dimensionStyle(){if(this._dimStyle==null){let e;this.dimensionStyleName&&(e=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),e==null&&(e=new ti),this._dimStyle=e}return this._dimStyle}get dimensionText(){return this._dimensionText}set dimensionText(e){this._dimensionText=e}get measurement(){return this._measurement}set measurement(e){this._measurement=e}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(e){this._textLineSpacingFactor=e}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(e){this._textLineSpacingStyle=e}get textPosition(){return this._textPosition}set textPosition(e){this._textPosition.copy(e)}get textRotation(){return this._textRotation}set textRotation(e){this._textRotation=e}get normal(){return this._normal}set normal(e){this._normal.copy(e).normalize()}get properties(){return this.getBaseProperties()}getBaseProperties(){return{type:this.type,groups:[this.getGeneralProperties(),this.getDimensionProperties()]}}transformBy(e){const t=this._textPosition.clone(),i=this._textPosition.clone().add(new w(Math.cos(this._textRotation),Math.sin(this._textRotation),0));this._dimBlockPosition.applyMatrix4(e),this._textPosition.applyMatrix4(e),this._normal.transformDirection(e),t.applyMatrix4(e),i.applyMatrix4(e);const s=new w(i).sub(t);return s.lengthSq()>0&&(this._textRotation=Math.atan2(s.y,s.x)),this.subTransformBy(e),this}subGetOsnapPoints(e,t,i,s,r){const a=this.getDimBlockTableRecord();if(!a)return;const o=this.getFullDimBlockTransform(),h=new f(t).applyMatrix4(o.clone().invert()),c=new f(i).applyMatrix4(o.clone().invert()),d=(u,p)=>{const g=[];u.subGetOsnapPoints(e,h,c,g,p,o),u instanceof ei?g.forEach(m=>s.push(m.clone())):g.forEach(m=>s.push(new f(m).applyMatrix4(o)))};if(r){const u=a.getIdAt(r);if(u&&(d(u,r),s.length>0))return}for(const u of a.newIterator())d(u)}subWorldDraw(e){const t=this.getDimBlockTableRecord();if(t){const s=this.computeDimBlockTransform();return ii.instance.draw(e,t,this.rgbColor,[],!1,s,this._normal)}return e.group([])}getDimBlockGeometricExtents(){const e=new N,t=this.getDimBlockTableRecord();if(!t)return e;for(const i of t.newIterator())e.union(i.geometricExtents);return e.applyMatrix4(this.getFullDimBlockTransform()),e}getDimBlockTableRecord(){return this.dimBlockId?this.database.tables.blockTable.getAt(this.dimBlockId):void 0}getDimensionProperties(){return{groupName:"dimension",properties:[this.createProperty("dimensionStyleName","string",()=>this.dimensionStyleName??"",e=>{this.dimensionStyleName=e.trim()===""?null:e}),this.createProperty("dimensionText","string",()=>this.dimensionText??"",e=>{this.dimensionText=e}),this.createProperty("measurement","float",()=>this.getMeasurementPropertyValue()),this.createProperty("dimBlockId","string",()=>this.dimBlockId??""),...this.createPoint3dProperties("dimBlockPosition",()=>this.dimBlockPosition),...this.createPoint3dProperties("textPosition",()=>this.textPosition),this.createProperty("textRotation","float",()=>this.textRotation,e=>{this.textRotation=e}),this.createProperty("textLineSpacingFactor","float",()=>this.textLineSpacingFactor,e=>{this.textLineSpacingFactor=e}),this.createProperty("textLineSpacingStyle","enum",()=>this.textLineSpacingStyle,e=>{this.textLineSpacingStyle=e},[{label:ns[1],value:1},{label:ns[2],value:2}]),...this.createPoint3dProperties("normal",()=>this.normal)]}}createProperty(e,t,i,s,r){return{name:e,type:t,editable:s!=null,options:r,accessor:s?{get:i,set:s}:{get:i}}}createPoint3dProperties(e,t){return[this.createProperty(`${e}X`,"float",()=>t().x,i=>{t().x=i}),this.createProperty(`${e}Y`,"float",()=>t().y,i=>{t().y=i}),this.createProperty(`${e}Z`,"float",()=>t().z,i=>{t().z=i})]}getMeasurementPropertyValue(){return this.measurement}getFullDimBlockTransform(){const e=this.computeDimBlockTransform();if(this._normal.x===0&&this._normal.y===0&&this._normal.z===1)return e;const t=new D().setFromExtrusionDirection(this._normal);return new D().multiplyMatrices(t,e)}get arrowScaleFactor(){return this.dimensionStyle.dimasz}get firstArrowStyle(){return{type:this.firstArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse1==0}}get secondArrowStyle(){return{type:this.secondArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse2==0}}get isAppendArrow(){return!0}get firstArrowTypeBtrId(){const e=this.dimensionStyle;return e.dimsah==0?e.dimblk:e.dimblk1}get firstArrowType(){const e=this.firstArrowTypeBtrId;return this.getArrowName(e)}get secondArrowTypeBtrId(){const e=this.dimensionStyle;return e.dimsah==0?e.dimblk:e.dimblk2}get secondArrowType(){const e=this.secondArrowTypeBtrId;return this.getArrowName(e)}get arrowLineCount(){return 1}findPointOnLine1(e,t,i){const s=new f().subVectors(t,e).normalize();return new f(t).addScaledVector(s,i)}findPointOnLine2(e,t,i){const s=e.x+i*Math.cos(t),r=e.y+i*Math.sin(t);return{x:s,y:r}}adjustExtensionLine(e){const t=this.dimensionStyle;e.extend(t.dimexe),e.extend(-t.dimexo,!0)}getArrowName(e){const t=this.database.tables.blockTable.getIdAt(e);return t?t.name.toUpperCase():xr.Closed}computeDimBlockTransform(){const e=this.dimBlockId?this.database.tables.blockTable.getAt(this.dimBlockId):void 0,t=(e==null?void 0:e.origin)??f.ORIGIN,i=new D().makeTranslation(-t.x,-t.y,-t.z),s=new D().makeTranslation(this._dimBlockPosition.x,this._dimBlockPosition.y,this._dimBlockPosition.z);return new D().multiplyMatrices(s,i)}subTransformBy(e){}dxfOutFields(e){super.dxfOutFields(e);const t=this.dimensionStyleName!=null?this.database.tables.dimStyleTable.getAt(this.dimensionStyleName):void 0;return e.writeSubclassMarker("AcDbDimension"),e.writeInt16(280,0),e.writeString(2,this.dimBlockId??void 0),e.writeString(3,this.dimensionStyleName??this.dimensionStyle.name),e.writePoint3d(10,this.dimBlockPosition),e.writeString(1,this.dimensionText??""),e.writeAngle(53,this.textRotation),e.writePoint3d(11,this.textPosition),e.writeInt16(70,0),e.writeInt16(72,this.textLineSpacingStyle),e.writeDouble(41,this.textLineSpacingFactor),e.writeDouble(42,this.measurement),e.writeVector3d(210,this.normal),e.writeObjectId(340,t==null?void 0:t.objectId),this}};ua.typeName="Dimension";let pt=ua;const ga=class ga extends pt{constructor(e,t,i,s,r=null,a=null){super(),this._centerPoint=new f().copy(e),this._xLine1Point=new f().copy(t),this._xLine2Point=new f().copy(i),this._arcPoint=new f().copy(s),this.dimensionText=r,this.dimensionStyleName=a}get arcPoint(){return this._arcPoint}set arcPoint(e){this._arcPoint.copy(e)}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint.copy(e)}get xLine1Point(){return this._xLine1Point}set xLine1Point(e){this._xLine1Point.copy(e)}get xLine2Point(){return this._xLine2Point}set xLine2Point(e){this._xLine2Point.copy(e)}get properties(){const e=this.getBaseProperties();return{type:this.type,groups:[...e.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("centerPoint",()=>this.centerPoint),...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("arcPoint",()=>this.arcPoint)]}]}}subTransformBy(e){this._arcPoint.applyMatrix4(e),this._centerPoint.applyMatrix4(e),this._xLine1Point.applyMatrix4(e),this._xLine2Point.applyMatrix4(e)}get geometricExtents(){return new N}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDb3PointAngularDimension"),e.writePoint3d(13,this.xLine1Point),e.writePoint3d(14,this.xLine2Point),e.writePoint3d(15,this.centerPoint),e.writePoint3d(16,this.arcPoint),this}};ga.typeName="3PointAngularDimension";let ss=ga;const pa=class pa extends pt{constructor(e,t,i,s=null,r=null){super(),this._dimLinePoint=new f().copy(i),this._xLine1Point=new f().copy(e),this._xLine2Point=new f().copy(t),this._oblique=0,this._rotation=0,this.calculateRotation(),s?this.dimensionText=s:this.dimensionText=this._xLine1Point.distanceTo(this._xLine2Point).toFixed(3),this.dimensionStyleName=r}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(e){this._dimLinePoint.copy(e)}get xLine1Point(){return this._xLine1Point}set xLine1Point(e){this._xLine1Point.copy(e)}get xLine2Point(){return this._xLine2Point}set xLine2Point(e){this._xLine2Point.copy(e)}get rotation(){return this._rotation}set rotation(e){this._rotation=e}get oblique(){return this._oblique}set oblique(e){this._oblique=e}get properties(){const e=this.getBaseProperties();return{type:this.type,groups:[...e.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("dimLinePoint",()=>this.dimLinePoint),this.createProperty("rotation","float",()=>this.rotation,t=>{this.rotation=t}),this.createProperty("oblique","float",()=>this.oblique,t=>{this.oblique=t})]}]}}subTransformBy(e){this._dimLinePoint.applyMatrix4(e),this._xLine1Point.applyMatrix4(e),this._xLine2Point.applyMatrix4(e),this.calculateRotation()}get geometricExtents(){return this.getDimBlockGeometricExtents()}get isAppendArrow(){return!1}createDimBlock(e){const t=new Q;t.name=e;const i=this.createLines();i.forEach(o=>t.appendEntity(new Ui(o.startPoint,o.endPoint))),this.createArrows(i[0]).forEach(o=>t.appendEntity(o));const r=i[0].midPoint,a=this.createMText(r,this._rotation);return a&&t.appendEntity(a),t}createMText(e,t){const i=s=>({x:Math.cos(s),y:Math.sin(s),z:0});if(this.dimensionText){const s=new $i;return s.attachmentPoint=ae.MiddleLeft,s.layer="0",s.color=new z(A.ByBlock),s.location=e,s.contents=this.dimensionText??"",s.height=10,s.direction=i(t),s.styleName=this.dimensionStyle.dimtxsty,s}}createArrows(e){const t=[];return t.push(this.createArrow(e.startPoint,this.rotation+Math.PI,10)),t.push(this.createArrow(e.endPoint,this.rotation,10)),t}createArrow(e,t,i){const s="_CAXARROW",r=new ei(s);return r.position=e,r.rotation=t,r.scaleFactors={x:i,y:i,z:i},r}createLines(){const e=[],t=this.createExtensionLine(this._xLine1Point),i=this.createExtensionLine(this._xLine2Point),s=this.findIntersectionPoint(t,this._dimLinePoint),r=this.findIntersectionPoint(i,this._dimLinePoint),a=new Tt(s,r);return e.push(a),t.endPoint=s,this.adjustExtensionLine(t),e.push(t),i.endPoint=r,this.adjustExtensionLine(i),e.push(i),e}createExtensionLine(e){const t=this.rotation+Math.PI/2,i=this.findPointOnLine2(e,t,100);return new Tt(e,{...i,z:e.z})}findIntersectionPoint(e,t){const i=e.startPoint,s=e.endPoint,r=new w().subVectors(s,i).normalize(),o=new w().subVectors(t,i).dot(r),h=new w().copy(r).multiplyScalar(o);return new w().addVectors(i,h)}calculateRotation(){const e=this._xLine1Point,t=this._xLine2Point,i=t.x-e.x,s=t.y-e.y;this._rotation=Math.atan2(s,i)}get dxfSubclassMarker(){return"AcDbAlignedDimension"}getMeasurementPropertyValue(){return this.measurement??this.xLine1Point.distanceTo(this.xLine2Point)}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker(this.dxfSubclassMarker),e.writePoint3d(13,this.xLine1Point),e.writePoint3d(14,this.xLine2Point),e.writePoint3d(15,this.dimLinePoint),e.writeAngle(50,this.rotation),e.writeAngle(52,this.oblique),this}};pa.typeName="AlignedDimension";let Ki=pa;const ma=class ma extends pt{constructor(e,t,i,s,r=null,a=null){super(),this._arcPoint=new f().copy(s),this._xLine1Point=new f().copy(t),this._xLine2Point=new f().copy(i),this._centerPoint=new f().copy(e),this.dimensionText=r,this.dimensionStyleName=a}get arcPoint(){return this._arcPoint}set arcPoint(e){this._arcPoint.copy(e)}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint.copy(e)}get xLine1Point(){return this._xLine1Point}set xLine1Point(e){this._xLine1Point.copy(e)}get xLine2Point(){return this._xLine2Point}set xLine2Point(e){this._xLine2Point.copy(e)}get properties(){const e=this.getBaseProperties();return{type:this.type,groups:[...e.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("centerPoint",()=>this.centerPoint),...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("arcPoint",()=>this.arcPoint)]}]}}subTransformBy(e){this._arcPoint.applyMatrix4(e),this._centerPoint.applyMatrix4(e),this._xLine1Point.applyMatrix4(e),this._xLine2Point.applyMatrix4(e)}get geometricExtents(){return new N}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbArcDimension"),e.writePoint3d(13,this.xLine1Point),e.writePoint3d(14,this.xLine2Point),e.writePoint3d(15,this.centerPoint),e.writePoint3d(16,this.arcPoint),this}};ma.typeName="ArcDimension";let Zs=ma;const ya=class ya extends pt{constructor(e,t,i=0,s=null,r=null){super(),this._chordPoint=new f().copy(e),this._farChordPoint=new f().copy(t),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=i,this.dimensionText=s,this.dimensionStyleName=r}get chordPoint(){return this._chordPoint}set chordPoint(e){this._chordPoint.copy(e)}get farChordPoint(){return this._farChordPoint}set farChordPoint(e){this._farChordPoint.copy(e)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(e){this._extArcStartAngle=e}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(e){this._extArcEndAngle=e}get leaderLength(){return this._leaderLength}set leaderLength(e){this._leaderLength=e}get properties(){const e=this.getBaseProperties();return{type:this.type,groups:[...e.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("chordPoint",()=>this.chordPoint),...this.createPoint3dProperties("farChordPoint",()=>this.farChordPoint),this.createProperty("leaderLength","float",()=>this.leaderLength,t=>{this.leaderLength=t}),this.createProperty("extArcStartAngle","float",()=>this.extArcStartAngle,t=>{this.extArcStartAngle=t}),this.createProperty("extArcEndAngle","float",()=>this.extArcEndAngle,t=>{this.extArcEndAngle=t})]}]}}subTransformBy(e){this._chordPoint.applyMatrix4(e),this._farChordPoint.applyMatrix4(e)}getMeasurementPropertyValue(){return this.measurement??this.chordPoint.distanceTo(this.farChordPoint)}get geometricExtents(){return new N}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbDiametricDimension"),e.writePoint3d(15,this.chordPoint),e.writePoint3d(16,this.farChordPoint),e.writeDouble(40,this.leaderLength),e.writeAngle(52,this.extArcStartAngle),e.writeAngle(53,this.extArcEndAngle),this}};ya.typeName="DiametricDimension";let rs=ya;const _a=class _a extends pt{constructor(e,t,i=null,s=null){super(),this._definingPoint=new f().copy(e),this._leaderEndPoint=new f().copy(t),this.dimensionText=i,this.dimensionStyleName=s}get definingPoint(){return this._definingPoint}set definingPoint(e){this._definingPoint.copy(e)}get leaderEndPoint(){return this._leaderEndPoint}set leaderEndPoint(e){this._leaderEndPoint.copy(e)}get properties(){const e=this.getBaseProperties();return{type:this.type,groups:[...e.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("definingPoint",()=>this.definingPoint),...this.createPoint3dProperties("leaderEndPoint",()=>this.leaderEndPoint)]}]}}subTransformBy(e){this._definingPoint.applyMatrix4(e),this._leaderEndPoint.applyMatrix4(e)}get geometricExtents(){return new N}get arrowLineCount(){return 0}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbOrdinateDimension"),e.writePoint3d(13,this.definingPoint),e.writePoint3d(14,this.leaderEndPoint),this}};_a.typeName="OrdinateDimension";let as=_a;const xa=class xa extends pt{constructor(e,t,i,s=null,r=null){super(),this._center=new f().copy(e),this._chordPoint=new f().copy(t),this._leaderLength=i,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=s,this.dimensionStyleName=r}get center(){return this._center}set center(e){this._center.copy(e)}get chordPoint(){return this._chordPoint}set chordPoint(e){this._chordPoint.copy(e)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(e){this._extArcStartAngle=e}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(e){this._extArcEndAngle=e}get leaderLength(){return this._leaderLength}set leaderLength(e){this._leaderLength=e}set leaderLenght(e){this._leaderLength=e}get properties(){const e=this.getBaseProperties();return{type:this.type,groups:[...e.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("center",()=>this.center),...this.createPoint3dProperties("chordPoint",()=>this.chordPoint),this.createProperty("leaderLength","float",()=>this.leaderLength,t=>{this.leaderLength=t}),this.createProperty("extArcStartAngle","float",()=>this.extArcStartAngle,t=>{this.extArcStartAngle=t}),this.createProperty("extArcEndAngle","float",()=>this.extArcEndAngle,t=>{this.extArcEndAngle=t})]}]}}subTransformBy(e){this._center.applyMatrix4(e),this._chordPoint.applyMatrix4(e)}getMeasurementPropertyValue(){return this.measurement??this.center.distanceTo(this.chordPoint)}get geometricExtents(){return new N}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbRadialDimension"),e.writePoint3d(15,this.center),e.writePoint3d(13,this.chordPoint),e.writeDouble(40,this.leaderLength),e.writeAngle(52,this.extArcStartAngle),e.writeAngle(53,this.extArcEndAngle),this}};xa.typeName="RadialDimension";let os=xa;const wa=class wa extends Ki{get dxfSubclassMarker(){return"AcDbRotatedDimension"}};wa.typeName="RotatedDimension";let ls=wa;var ll=(n=>(n[n.kInches=0]="kInches",n[n.kMillimeters=1]="kMillimeters",n[n.kPixels=2]="kPixels",n))(ll||{}),hl=(n=>(n[n.k0degrees=0]="k0degrees",n[n.k90degrees=1]="k90degrees",n[n.k180degrees=2]="k180degrees",n[n.k270degrees=3]="k270degrees",n))(hl||{}),cl=(n=>(n[n.kDisplay=0]="kDisplay",n[n.kExtents=1]="kExtents",n[n.kLimits=2]="kLimits",n[n.kView=3]="kView",n[n.kWindow=4]="kWindow",n[n.kLayout=5]="kLayout",n))(cl||{}),ft=(n=>(n[n.kDraft=0]="kDraft",n[n.kPreview=1]="kPreview",n[n.kNormal=2]="kNormal",n[n.kPresentation=3]="kPresentation",n[n.kMaximum=4]="kMaximum",n[n.kCustom=5]="kCustom",n))(ft||{}),oi=(n=>(n[n.kAsDisplayed=0]="kAsDisplayed",n[n.kWireframe=1]="kWireframe",n[n.kHidden=2]="kHidden",n[n.kRendered=3]="kRendered",n[n.kVisualStyle=4]="kVisualStyle",n[n.kRenderPreset=5]="kRenderPreset",n))(oi||{}),dl=(n=>(n[n.kScaleToFit=0]="kScaleToFit",n[n.k1_128in_1ft=1]="k1_128in_1ft",n[n.k1_64in_1ft=2]="k1_64in_1ft",n[n.k1_32in_1ft=3]="k1_32in_1ft",n[n.k1_16in_1ft=4]="k1_16in_1ft",n[n.k3_32in_1ft=5]="k3_32in_1ft",n[n.k1_8in_1ft=6]="k1_8in_1ft",n[n.k3_16in_1ft=7]="k3_16in_1ft",n[n.k1_4in_1ft=8]="k1_4in_1ft",n[n.k3_8in_1ft=9]="k3_8in_1ft",n[n.k1_2in_1ft=10]="k1_2in_1ft",n[n.k3_4in_1ft=11]="k3_4in_1ft",n[n.k1in_1ft=12]="k1in_1ft",n[n.k3in_1ft=13]="k3in_1ft",n[n.k6in_1ft=14]="k6in_1ft",n[n.k1ft_1ft=15]="k1ft_1ft",n[n.k1_1=16]="k1_1",n[n.k1_2=17]="k1_2",n[n.k1_4=18]="k1_4",n[n.k1_5=19]="k1_5",n[n.k1_8=20]="k1_8",n[n.k1_10=21]="k1_10",n[n.k1_16=22]="k1_16",n[n.k1_20=23]="k1_20",n[n.k1_30=24]="k1_30",n[n.k1_40=25]="k1_40",n[n.k1_50=26]="k1_50",n[n.k1_100=27]="k1_100",n[n.k2_1=28]="k2_1",n[n.k4_1=29]="k4_1",n[n.k8_1=30]="k8_1",n[n.k10_1=31]="k10_1",n[n.k100_1=32]="k100_1",n[n.k1000_1=33]="k1000_1",n[n.k1and1_2in_1ft=34]="k1and1_2in_1ft",n))(dl||{});const Hc={0:0,1:1/1536,2:1/768,3:1/384,4:1/192,5:1/128,6:1/96,7:1/64,8:1/48,9:1/32,10:1/24,11:1/16,12:1/12,13:1/4,14:1/2,15:1,16:1,17:1/2,18:1/4,19:1/5,20:1/8,21:1/10,22:1/16,23:1/20,24:1/30,25:1/40,26:1/50,27:1/100,28:2,29:4,30:8,31:10,32:100,33:1e3,34:1/8};class ul extends Be{constructor(e=!1){super(),this._plotSettingsName="",this._plotCfgName="",this._canonicalMediaName="",this._currentStyleSheet="",this._plotOrigin=new v,this._customPrintScale={numerator:1,denominator:1},this._plotPaperSize=new v,this._plotPaperMargins={left:0,right:0,top:0,bottom:0},this._plotViewName="",this._plotWindowArea=new _e,this._modelType=e,this._plotCentered=!1,this._plotHidden=!1,this._plotPaperUnits=1,this._plotPlotStyles=!0,this._plotRotation=0,this._plotType=5,this._plotViewportBorders=!1,this._printLineweights=!0,this._scaleLineweights=!1,this._drawViewportsFirst=!1,this._showPlotStyles=!0,this._shadePlotType=0,this._shadePlotResLevel=2,this._shadePlotCustomDpi=300,this._shadePlotId=void 0,this._stdScaleType=0,this._useStandardScale=!0}get plotSettingsName(){return this._plotSettingsName}set plotSettingsName(e){this._plotSettingsName=e}getPlotSettingsName(){return this._plotSettingsName}setPlotSettingsName(e){this._plotSettingsName=e}get plotCfgName(){return this._plotCfgName}set plotCfgName(e){this._plotCfgName=e}getPlotCfgName(){return this._plotCfgName}get canonicalMediaName(){return this._canonicalMediaName}set canonicalMediaName(e){this._canonicalMediaName=e}getCanonicalMediaName(){return this._canonicalMediaName}get currentStyleSheet(){return this._currentStyleSheet}set currentStyleSheet(e){this._currentStyleSheet=e}getCurrentStyleSheet(){return this._currentStyleSheet}get plotOrigin(){return this._plotOrigin}set plotOrigin(e){this._plotOrigin=e}getPlotOrigin(){return this._plotOrigin}get customPrintScale(){return this._customPrintScale}set customPrintScale(e){this._customPrintScale=e}getCustomPrintScale(){return this._customPrintScale}get plotPaperSize(){return this._plotPaperSize}set plotPaperSize(e){this._plotPaperSize=e}getPlotPaperSize(){return this._plotPaperSize}get plotPaperMargins(){return this._plotPaperMargins}set plotPaperMargins(e){this._plotPaperMargins=e}getPlotPaperMargins(){return this._plotPaperMargins}get plotViewName(){return this._plotViewName}set plotViewName(e){this._plotViewName=e}getPlotViewName(){return this._plotViewName}get plotWindowArea(){return this._plotWindowArea}set plotWindowArea(e){this._plotWindowArea=e}getPlotWindowArea(){return this._plotWindowArea}get modelType(){return this._modelType}set modelType(e){this._modelType=e}getModelType(){return this._modelType}setModelType(e){this._modelType=e}get drawViewportsFirst(){return this._drawViewportsFirst}set drawViewportsFirst(e){this._drawViewportsFirst=e}setDrawViewportsFirst(e){this._drawViewportsFirst=e}get plotCentered(){return this._plotCentered}set plotCentered(e){this._plotCentered=e}setPlotCentered(e){this._plotCentered=e}get plotHidden(){return this._plotHidden}set plotHidden(e){this._plotHidden=e}setPlotHidden(e){this._plotHidden=e}get plotPaperUnits(){return this._plotPaperUnits}set plotPaperUnits(e){this._plotPaperUnits=e}get plotPlotStyles(){return this._plotPlotStyles}set plotPlotStyles(e){this._plotPlotStyles=e}setPlotPlotStyles(e){this._plotPlotStyles=e}get plotRotation(){return this._plotRotation}set plotRotation(e){this._plotRotation=e}get plotType(){return this._plotType}set plotType(e){this._plotType=e}get plotViewportBorders(){return this._plotViewportBorders}set plotViewportBorders(e){this._plotViewportBorders=e}setPlotViewportBorders(e){this._plotViewportBorders=e}get printLineweights(){return this._printLineweights}set printLineweights(e){this._printLineweights=e}setPrintLineweights(e){this._printLineweights=e}get scaleLineweights(){return this._scaleLineweights}set scaleLineweights(e){this._scaleLineweights=e}setScaleLineweights(e){this._scaleLineweights=e}get showPlotStyles(){return this._showPlotStyles}set showPlotStyles(e){this._showPlotStyles=e}setShowPlotStyles(e){this._showPlotStyles=e}get shadePlot(){return this._shadePlotType}set shadePlot(e){this._shadePlotType=e}setShadePlot(e){this._shadePlotType=e}get shadePlotResLevel(){return this._shadePlotResLevel}set shadePlotResLevel(e){this._shadePlotResLevel=e}setShadePlotResLevel(e){this._shadePlotResLevel=e}get shadePlotCustomDPI(){return this._shadePlotCustomDpi}set shadePlotCustomDPI(e){this._shadePlotCustomDpi=e}setShadePlotCustomDPI(e){this._shadePlotCustomDpi=e}get shadePlotId(){return this._shadePlotId}set shadePlotId(e){this._shadePlotId=e}get plotWireframe(){return this._shadePlotType===1}get plotAsRaster(){return this._shadePlotType===3||this._shadePlotType===4||this._shadePlotType===5}get stdScaleType(){return this._stdScaleType}set stdScaleType(e){this._stdScaleType=e}get stdScale(){return Hc[this._stdScaleType]??1}get useStandardScale(){return this._useStandardScale}set useStandardScale(e){this._useStandardScale=e}dxfOutFields(e){super.dxfOutFields(e),e.writeSubclassMarker("AcDbPlotSettings"),e.writeString(1,this.plotSettingsName),e.writeString(2,this.plotCfgName),e.writeString(4,this.canonicalMediaName),e.writeString(6,this.plotViewName),e.writeDouble(40,this.plotPaperMargins.left),e.writeDouble(41,this.plotPaperMargins.bottom),e.writeDouble(42,this.plotPaperMargins.right),e.writeDouble(43,this.plotPaperMargins.top),e.writeDouble(44,this.plotPaperSize.x),e.writeDouble(45,this.plotPaperSize.y),e.writeDouble(46,this.plotOrigin.x),e.writeDouble(47,this.plotOrigin.y),e.writeDouble(48,this.plotWindowArea.min.x),e.writeDouble(49,this.plotWindowArea.min.y),e.writeDouble(140,this.plotWindowArea.max.x),e.writeDouble(141,this.plotWindowArea.max.y),e.writeDouble(142,this.customPrintScale.numerator),e.writeDouble(143,this.customPrintScale.denominator);let t=0;return this.plotViewportBorders&&(t|=1),this.showPlotStyles&&(t|=2),this.plotCentered&&(t|=4),this.plotHidden&&(t|=8),this.useStandardScale&&(t|=16),this.plotPlotStyles&&(t|=32),this.scaleLineweights&&(t|=64),this.printLineweights&&(t|=128),this.drawViewportsFirst&&(t|=512),this.modelType&&(t|=1024),e.writeInt16(70,t),e.writeInt16(72,this.plotPaperUnits),e.writeInt16(73,this.plotRotation),e.writeInt16(74,this.plotType),e.writeString(7,this.currentStyleSheet),e.writeInt16(75,this.stdScaleType),e.writeInt16(76,this.shadePlot),e.writeInt16(77,this.shadePlotResLevel),e.writeInt16(78,this.shadePlotCustomDPI),e.writeDouble(147,this.stdScale),e.writeObjectId(333,this.shadePlotId),this}}class rn extends ul{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new _e,this._extents=new N,this._viewportArray=[]}get layoutName(){return this._layoutName}set layoutName(e){this._layoutName=e.length>256?e.slice(0,256):e}get tabOrder(){return this._tabOrder}set tabOrder(e){this._tabOrder=e}get tabSelected(){return this._tabSelected}set tabSelected(e){this._tabSelected=e}get blockTableRecordId(){return this._blockTableRecordId}set blockTableRecordId(e){this._blockTableRecordId=e}get limits(){return this._limits}set limits(e){this._limits.copy(e)}get extents(){return this._extents}set extents(e){this._extents.copy(e)}get viewportArray(){return this._viewportArray}set viewportArray(e){this._viewportArray=e.slice()}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbLayout"),e.writeString(1,this.layoutName),e.writeInt16(70,this.tabSelected?1:0),e.writeInt16(71,this.tabOrder),e.writeObjectId(330,this.blockTableRecordId),e.writeObjectId(331,this._viewportArray.length>0?this._viewportArray[0]:"0"),e.writePoint2d(10,this.limits.min),e.writePoint2d(11,this.limits.max),e.writePoint3d(14,this.extents.min),e.writePoint3d(15,this.extents.max),this}}class an{constructor(e){this.i=0,this._records=e,this._keys=Array.from(e.keys())}get count(){return this._records.size}toArray(){return Array.from(this._records.values())}[Symbol.iterator](){return this}next(){for(;this.i<this._keys.length;){const e=this._records.get(this._keys[this.i]);return this.i+=1,{value:e,done:!1}}return{value:null,done:!0}}}class Kt extends Be{constructor(e){super(),this.database=e,this.objectId=e.generateHandle(),this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}setAt(e,t){t.database=this.database,t.ownerId=this.objectId,this.database.commitObjectHandle(t,i=>this.hasId(i)),this._recordsByName.set(e,t),this._recordsById.set(t.objectId,t),this.database.events.dictObjetSet.dispatch({database:this.database,object:t,key:e})}remove(e){const t=this.getAt(e);return t?(this._recordsByName.delete(e.toUpperCase()),this._recordsById.delete(this.objectId),this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:e}),!0):!1}removeId(e){const t=this.getIdAt(e);return t?(this._recordsById.delete(this.objectId),this._recordsByName.forEach((i,s)=>{i===t&&(this._recordsByName.delete(s),this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:s}))}),!0):!1}removeAll(){this._recordsByName.forEach((e,t)=>{this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:t})}),this._recordsByName.clear(),this._recordsById.clear()}has(e){return this._recordsByName.has(e.toUpperCase())}hasId(e){return this._recordsById.has(e)}getAt(e){return this._recordsByName.get(e)}getIdAt(e){return this._recordsById.get(e)}newIterator(){return new an(this._recordsByName)}entries(){return this._recordsByName.entries()}dxfOutFields(e){super.dxfOutFields(e),e.writeSubclassMarker("AcDbDictionary"),e.writeInt16(280,1),e.writeInt16(281,1);for(const[t,i]of this._recordsByName)e.writeString(3,t),e.writeObjectId(350,i.objectId);return this}}class gl extends Kt{getBtrIdAt(e){for(const[t,i]of this._recordsByName)if(i.blockTableRecordId==e)return i}get maxTabOrder(){let e=-1;return this._recordsByName.forEach(t=>{t.tabOrder>e&&(e=t.tabOrder)}),e}}class kt extends Be{constructor(e,t){e=e||{},Qi(e,{name:""}),super(e,t)}get name(){return this.getAttr("name")}set name(e){this.setAttr("name",e)}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbSymbolTableRecord"),this}}var pl=(n=>(n[n.Any=0]="Any",n[n.Uniform=1]="Uniform",n))(pl||{});const bt=class bt extends kt{static isModelSapceName(e){return e.toLowerCase()==bt.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(e){return e.toLowerCase().startsWith(bt.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new f,this._layoutId="",this._entities=new Map,this._blockInsertUnits=0,this._explodability=1,this._blockScaling=1,this._bmpPreview=void 0}get isModelSapce(){return bt.isModelSapceName(this.name)}get isPaperSapce(){return bt.isPaperSapceName(this.name)}get origin(){return this._origin}set origin(e){this._origin.copy(e)}get layoutId(){return this._layoutId}set layoutId(e){this._layoutId=e}get blockInsertUnits(){return this._blockInsertUnits}set blockInsertUnits(e){this._blockInsertUnits=e}get explodability(){return this._explodability}set explodability(e){this._explodability=e}get blockScaling(){return this._blockScaling}set blockScaling(e){this._blockScaling=e}get bmpPreview(){return this._bmpPreview}set bmpPreview(e){this._bmpPreview=e}appendEntity(e){const t=i=>{i.database=this.database,i.ownerId=this.objectId,this.database.ensureEntityStyleDefaults(i),this.database.commitObjectHandle(i,s=>this._entities.has(s)),i.resolveEffectiveProperties(),this._entities.set(i.objectId,i)};if(Array.isArray(e))for(let i=0;i<e.length;++i)t(e[i]);else t(e);(this.isModelSapce||this.isPaperSapce)&&this.database.events.entityAppended.dispatch({database:this.database,entity:e})}removeEntity(e){const t=Array.isArray(e)?e:[e],i=[];return t.forEach(s=>{const r=this._entities.get(s);r&&i.push(r),this._entities.delete(s)}),i.length>0&&this.database.events.entityErased.dispatch({database:this.database,entity:i}),i.length>0}newIterator(){return new an(this._entities)}getIdAt(e){return this._entities.get(e)}dxfOutBlockRecord(e){return e.writeStart("BLOCK_RECORD"),this.dxfOut(e),this}dxfOutBlockBegin(e){return e.writeStart("BLOCK"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity"),e.writeString(8,"0"),e.writeSubclassMarker("AcDbBlockBegin"),e.writeString(2,this.name),e.writeInt16(70,0),e.writePoint3d(10,this.origin),e.writeString(3,this.name),this}dxfOutBlockEnd(e){return e.writeStart("ENDBLK"),e.writeHandle(5,this.database.generateHandle()),e.writeObjectId(330,this.objectId),e.writeSubclassMarker("AcDbEntity"),e.writeSubclassMarker("AcDbBlockEnd"),this}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbBlockTableRecord"),e.writeString(2,this.name),e.writeInt16(70,this.blockInsertUnits),e.writeInt16(280,this.explodability),e.writeInt16(281,this.blockScaling),(this.isModelSapce||this.isPaperSapce)&&e.writeObjectId(340,this.layoutId),this}};bt.MODEL_SPACE_NAME="*Model_Space",bt.PAPER_SPACE_NAME_PREFIX="*Paper_Space";let Q=bt;class ml{constructor(){this.events={layoutCreated:new J,layoutRemoved:new J,layoutRenamed:new J,layoutSwitched:new J}}countLayouts(e){return this.getWorkingDatabase(e).objects.layout.numEntries}findLayoutNamed(e,t){return this.getWorkingDatabase(t).objects.layout.getAt(e)}findActiveLayout(){const e=this.getActiveLayout();return e?e.layoutName:"Model"}setCurrentLayoutId(e,t){const i=this.getWorkingDatabase(t),s=i.objects.layout.getIdAt(e);return this.setCurrentLayoutInternal(s,i)}setCurrentLayoutBtrId(e,t){const i=this.getWorkingDatabase(t),s=i.objects.layout.getBtrIdAt(e);return this.setCurrentLayoutInternal(s,i)}setCurrentLayout(e,t){const i=this.getWorkingDatabase(t),s=i.objects.layout.getAt(e);return this.setCurrentLayoutInternal(s,i)}renameLayout(e,t,i){const r=this.getWorkingDatabase(i).objects.layout.getAt(e);return r?(r.layoutName=t,this.events.layoutRenamed.dispatch({layout:r,oldName:e,newName:t}),!0):!1}layoutExists(e,t){return this.getWorkingDatabase(t).objects.layout.has(e)}deleteLayout(e,t){const i=this.getWorkingDatabase(t).objects.layout,s=i.getAt(e);let r=!1;return s&&(r=i.remove(e),r&&this.events.layoutRemoved.dispatch({layout:s})),r}createLayout(e,t){const i=this.getWorkingDatabase(t),s=new rn;s.layoutName=e,s.tabOrder=i.objects.layout.maxTabOrder;const r=new Q;return r.name=`*Paper_Space${s.tabOrder}`,i.tables.blockTable.add(r),i.objects.layout.setAt(e,s),this.events.layoutCreated.dispatch({layout:s}),{layout:s,btr:r}}getActiveLayout(e){const t=this.getWorkingDatabase(e);return t.objects.layout.getBtrIdAt(t.currentSpaceId)}getWorkingDatabase(e){return e||ir().workingDatabase}setCurrentLayoutInternal(e,t){return e?(this.events.layoutSwitched.dispatch({layout:e}),t.currentSpaceId=e.blockTableRecordId,!0):!1}}so(()=>new ml);class Sr extends Be{constructor(){super(),this._contentType=2,this._drawMLeaderOrderType=1,this._drawLeaderOrderType=0,this._bitFlags=0,this._maxLeaderSegmentsPoints=-1,this._firstSegmentAngleConstraint=0,this._secondSegmentAngleConstraint=0,this._leaderLineType=1,this._leaderLineColor=new z(A.ByLayer),this._leaderLineWeight=-2,this._enableLanding=!0,this._landingGap=2,this._enableDogleg=!0,this._doglegLength=8,this._description="",this._arrowSize=4,this._defaultMTextContents="",this._textLeftAttachmentType=1,this._textAngleType=1,this._textAlignmentType=0,this._textRightAttachmentType=1,this._textColor=new z(A.ByLayer),this._textHeight=4,this._enableFrameText=!1,this._textAlignAlwaysLeft=!1,this._alignSpace=0,this._blockColor=new z(A.ByBlock),this._blockScale=new w(1,1,1),this._enableBlockScale=!0,this._blockRotation=0,this._enableBlockRotation=!1,this._blockConnectionType=0,this._scale=1,this._overwritePropChanged=!1,this._annotative=!1,this._breakSize=0,this._textAttachmentDirection=0,this._bottomTextAttachmentType=9,this._topTextAttachmentType=9,this._extendLeaderToText=!1}get unknown1(){return this._unknown1}set unknown1(e){this._unknown1=e}get contentType(){return this._contentType}set contentType(e){this._contentType=e}get drawMLeaderOrderType(){return this._drawMLeaderOrderType}set drawMLeaderOrderType(e){this._drawMLeaderOrderType=e}get drawLeaderOrderType(){return this._drawLeaderOrderType}set drawLeaderOrderType(e){this._drawLeaderOrderType=e}get bitFlags(){return this._bitFlags}set bitFlags(e){this._bitFlags=e}get maxLeaderSegmentsPoints(){return this._maxLeaderSegmentsPoints}set maxLeaderSegmentsPoints(e){this._maxLeaderSegmentsPoints=e}get maxLeaderSegmentPoints(){return this.maxLeaderSegmentsPoints}set maxLeaderSegmentPoints(e){this.maxLeaderSegmentsPoints=e}get firstSegmentAngleConstraint(){return this._firstSegmentAngleConstraint}set firstSegmentAngleConstraint(e){this._firstSegmentAngleConstraint=e}get secondSegmentAngleConstraint(){return this._secondSegmentAngleConstraint}set secondSegmentAngleConstraint(e){this._secondSegmentAngleConstraint=e}get leaderLineType(){return this._leaderLineType}set leaderLineType(e){this._leaderLineType=e}get leaderLineColor(){return this._leaderLineColor}set leaderLineColor(e){this._leaderLineColor.copy(e)}get leaderLineTypeId(){return this._leaderLineTypeId}set leaderLineTypeId(e){this._leaderLineTypeId=e}get leaderLineWeight(){return this._leaderLineWeight}set leaderLineWeight(e){this._leaderLineWeight=e}get enableLanding(){return this._enableLanding}set enableLanding(e){this._enableLanding=e}get landingEnabled(){return this.enableLanding}set landingEnabled(e){this.enableLanding=e}get landingGap(){return this._landingGap}set landingGap(e){this._landingGap=e}get enableDogleg(){return this._enableDogleg}set enableDogleg(e){this._enableDogleg=e}get doglegEnabled(){return this.enableDogleg}set doglegEnabled(e){this.enableDogleg=e}get doglegLength(){return this._doglegLength}set doglegLength(e){this._doglegLength=e}get description(){return this._description}set description(e){this._description=e}get arrowSymbolId(){return this._arrowSymbolId}set arrowSymbolId(e){this._arrowSymbolId=e}get arrowheadId(){return this.arrowSymbolId}set arrowheadId(e){this.arrowSymbolId=e}get arrowSize(){return this._arrowSize}set arrowSize(e){this._arrowSize=e}get arrowheadSize(){return this.arrowSize}set arrowheadSize(e){this.arrowSize=e}get defaultMTextContents(){return this._defaultMTextContents}set defaultMTextContents(e){this._defaultMTextContents=e}get defaultMText(){return this.defaultMTextContents}set defaultMText(e){this.defaultMTextContents=e}get textString(){return this.defaultMTextContents}set textString(e){this.defaultMTextContents=e}get textStyleId(){return this._textStyleId}set textStyleId(e){this._textStyleId=e}get textStyle(){return this.textStyleId}set textStyle(e){this.textStyleId=e}get textLeftAttachmentType(){return this._textLeftAttachmentType}set textLeftAttachmentType(e){this._textLeftAttachmentType=e}get textAngleType(){return this._textAngleType}set textAngleType(e){this._textAngleType=e}get textAlignmentType(){return this._textAlignmentType}set textAlignmentType(e){this._textAlignmentType=e}get textRightAttachmentType(){return this._textRightAttachmentType}set textRightAttachmentType(e){this._textRightAttachmentType=e}get textColor(){return this._textColor}set textColor(e){this._textColor.copy(e)}get textHeight(){return this._textHeight}set textHeight(e){this._textHeight=e}get enableFrameText(){return this._enableFrameText}set enableFrameText(e){this._enableFrameText=e}get textFrameEnabled(){return this.enableFrameText}set textFrameEnabled(e){this.enableFrameText=e}get textAlignAlwaysLeft(){return this._textAlignAlwaysLeft}set textAlignAlwaysLeft(e){this._textAlignAlwaysLeft=e}get alignSpace(){return this._alignSpace}set alignSpace(e){this._alignSpace=e}get blockId(){return this._blockId}set blockId(e){this._blockId=e}get blockContentId(){return this.blockId}set blockContentId(e){this.blockId=e}get blockColor(){return this._blockColor}set blockColor(e){this._blockColor.copy(e)}get blockContentColor(){return this.blockColor}set blockContentColor(e){this.blockColor=e}get blockScale(){return this._blockScale.clone()}set blockScale(e){this._blockScale.copy(e)}get blockContentScale(){return this.blockScale}set blockContentScale(e){this.blockScale=e}get enableBlockScale(){return this._enableBlockScale}set enableBlockScale(e){this._enableBlockScale=e}get blockContentScaleEnabled(){return this.enableBlockScale}set blockContentScaleEnabled(e){this.enableBlockScale=e}get blockRotation(){return this._blockRotation}set blockRotation(e){this._blockRotation=e}get blockContentRotation(){return this.blockRotation}set blockContentRotation(e){this.blockRotation=e}get enableBlockRotation(){return this._enableBlockRotation}set enableBlockRotation(e){this._enableBlockRotation=e}get blockContentRotationEnabled(){return this.enableBlockRotation}set blockContentRotationEnabled(e){this.enableBlockRotation=e}get blockConnectionType(){return this._blockConnectionType}set blockConnectionType(e){this._blockConnectionType=e}get blockContentConnectionType(){return this.blockConnectionType}set blockContentConnectionType(e){this.blockConnectionType=e}get scale(){return this._scale}set scale(e){this._scale=e}get scaleFactor(){return this.scale}set scaleFactor(e){this.scale=e}get overwritePropChanged(){return this._overwritePropChanged}set overwritePropChanged(e){this._overwritePropChanged=e}get overwritePropertyValue(){return this.overwritePropChanged}set overwritePropertyValue(e){this.overwritePropChanged=e}get annotative(){return this._annotative}set annotative(e){this._annotative=e}get breakSize(){return this._breakSize}set breakSize(e){this._breakSize=e}get breakGapSize(){return this.breakSize}set breakGapSize(e){this.breakSize=e}get textAttachmentDirection(){return this._textAttachmentDirection}set textAttachmentDirection(e){this._textAttachmentDirection=e}get bottomTextAttachmentType(){return this._bottomTextAttachmentType}set bottomTextAttachmentType(e){this._bottomTextAttachmentType=e}get bottomTextAttachmentDirection(){return this.bottomTextAttachmentType}set bottomTextAttachmentDirection(e){this.bottomTextAttachmentType=e}get topTextAttachmentType(){return this._topTextAttachmentType}set topTextAttachmentType(e){this._topTextAttachmentType=e}get topTextAttachmentDirection(){return this.topTextAttachmentType}set topTextAttachmentDirection(e){this.topTextAttachmentType=e}get extendLeaderToText(){return this._extendLeaderToText}set extendLeaderToText(e){this._extendLeaderToText=e}get unknown2(){return this._unknown2}set unknown2(e){this._unknown2=e}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbMLeaderStyle"),e.writeInt16(179,this.unknown1),e.writeInt16(170,this.contentType),e.writeInt16(171,this.drawMLeaderOrderType),e.writeInt16(172,this.drawLeaderOrderType),e.writeInt32(90,this.maxLeaderSegmentsPoints),e.writeDouble(40,this.firstSegmentAngleConstraint),e.writeDouble(41,this.secondSegmentAngleConstraint),e.writeInt16(173,this.leaderLineType),e.writeInt32(91,Tn(this.leaderLineColor)),e.writeHandle(340,this.leaderLineTypeId),e.writeInt32(92,this.leaderLineWeight),e.writeBoolean(290,this.enableLanding),e.writeDouble(42,this.landingGap),e.writeBoolean(291,this.enableDogleg),e.writeDouble(43,this.doglegLength),e.writeString(3,this.description),e.writeHandle(341,this.arrowSymbolId),e.writeDouble(44,this.arrowSize),e.writeString(300,this.defaultMTextContents),e.writeHandle(342,this.textStyleId),e.writeInt16(174,this.textLeftAttachmentType),e.writeInt16(175,this.textAngleType),e.writeInt16(176,this.textAlignmentType),e.writeInt16(178,this.textRightAttachmentType),e.writeInt32(93,Tn(this.textColor)),e.writeDouble(45,this.textHeight),e.writeBoolean(292,this.enableFrameText),e.writeBoolean(297,this.textAlignAlwaysLeft),e.writeDouble(46,this.alignSpace),e.writeHandle(343,this.blockId),e.writeInt32(94,Tn(this.blockColor)),e.writeDouble(47,this._blockScale.x),e.writeDouble(49,this._blockScale.y),e.writeDouble(140,this._blockScale.z),e.writeBoolean(293,this.enableBlockScale),e.writeDouble(141,this.blockRotation),e.writeBoolean(294,this.enableBlockRotation),e.writeInt16(177,this.blockConnectionType),e.writeDouble(142,this.scale),e.writeBoolean(295,this.overwritePropChanged),e.writeBoolean(296,this.annotative),e.writeDouble(143,this.breakSize),e.writeInt16(271,this.textAttachmentDirection),e.writeInt16(272,this.bottomTextAttachmentType),e.writeInt16(273,this.topTextAttachmentType),e.writeBoolean(298,this.unknown2),this}}class Ir extends Be{constructor(){super(),this._styleName="STANDARD",this._flags=0,this._description="",this._fillColor=new z,this._startAngle=90,this._endAngle=90,this._elements=[]}get styleName(){return this._styleName}set styleName(e){this._styleName=e}get flags(){return this._flags}set flags(e){this._flags=e}get description(){return this._description}set description(e){this._description=e}get fillColor(){return this._fillColor}set fillColor(e){this._fillColor.copy(e)}get startAngle(){return this._startAngle}set startAngle(e){this._startAngle=e}get endAngle(){return this._endAngle}set endAngle(e){this._endAngle=e}get elementCount(){return this._elements.length}get elements(){return this._elements.map(e=>({offset:e.offset,color:e.color.clone(),lineType:e.lineType}))}set elements(e){this._elements=e.map(t=>({offset:t.offset,color:t.color.clone(),lineType:t.lineType}))}addElement(e){this._elements.push({offset:e.offset,color:e.color.clone(),lineType:e.lineType})}removeElementAt(e){if(e<0||e>=this._elements.length)throw new Error("The element index is out of range!");this._elements.splice(e,1)}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbMlineStyle"),e.writeString(2,this.styleName),e.writeInt16(70,this.flags),e.writeString(3,this.description),e.writeCmColor(this.fillColor),e.writeDouble(51,this.startAngle),e.writeDouble(52,this.endAngle),e.writeInt16(71,this.elementCount),this._elements.forEach(t=>{e.writeDouble(49,t.offset),e.writeCmColor(t.color),e.writeString(6,t.lineType)}),this}}class yl extends Be{constructor(){super(),this._sourceFileName=""}get sourceFileName(){return this._sourceFileName}set sourceFileName(e){this._sourceFileName=e}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbRasterImageDef"),e.writeString(1,this.sourceFileName),e.writeInt16(280,1),e.writeInt16(281,0),this}}var _l=(n=>(n[n.NotApplicable=0]="NotApplicable",n[n.Ignore=1]="Ignore",n[n.Replace=2]="Replace",n[n.XrefMangleName=3]="XrefMangleName",n[n.MangleName=4]="MangleName",n))(_l||{});class Uc extends Be{constructor(){super(...arguments),this._data=null}get data(){return this._data}set data(e){this._data=e}clear(){var e;(e=this._data)==null||e.clear()}clone(){return super.clone()}getDuplicateRecordCloning(){return 0}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbXrecord"),e.writeInt16(280,1),e.writeResultBuffer(this.data),this}}class xl{constructor(e){this.db=e}createDefaultLayer(){const e=new z;return e.colorIndex=7,this.db.tables.layerTable.add(new ys({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:e,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new At({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new At({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new At({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new _s({name:Z,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new ti({name:Z,dimtxsty:Z}))}createDefaultLayout(){const e=new rn;e.layoutName="Model",e.tabOrder=0,e.blockTableRecordId=this.db.tables.blockTable.modelSpace.objectId,e.limits.min.copy({x:0,y:0}),e.limits.max.copy({x:1e6,y:1e6}),e.extents.min.copy({x:0,y:0,z:0}),e.extents.max.copy({x:1e6,y:1e6,z:0}),this.db.objects.layout.setAt(e.layoutName,e),this.db.tables.blockTable.modelSpace.layoutId=e.objectId}createArrowBlock(){if(!this.db.tables.blockTable.getAt("_CAXARROW")){const t=new Hi;t.patternName="SOLID";const i=new Gi;i.add(new je({x:0,y:0},{x:-1,y:.125})),i.add(new je({x:-1,y:.125},{x:-1,y:-.125})),i.add(new je({x:-1,y:-.125},{x:0,y:0})),t.add(i);const s=new Q;s.name="_CAXARROW",s.appendEntity(t),this.db.tables.blockTable.add(s)}}}var wl=(n=>(n.ClosedFilled="",n.Dot="_DOT",n.DotSmall="_DOTSMALL",n.DotBlank="_DOTBLANK",n.Origin="_ORIGIN",n.Origin2="_ORIGIN2",n.Open="_OPEN",n.Open90="_OPEN90",n.Open30="_OPEN30",n.Closed="_CLOSED",n.Small="_SMALL",n.None="_NONE",n.Oblique="_OBLIQUE",n.BoxFilled="_BOXFILLED",n.Box="_BOXBLANK",n.ClosedBlank="_CLOSEDBLANK",n.DatumBlank="_DATUMBLANK",n.DatumFilled="_DATUMFILLED",n.Integral="_INTEGRAL",n.ArchTick="_ARCHTICK",n))(wl||{});const Ar=192,hs=193,Pr=194,Er=195,fl=200;function Tn(n){if(n.isByBlock)return hs<<24>>0;if(n.isByLayer)return Ar<<24>>0;const e=n.colorIndex;if(e!=null&&e>0&&e<256)return(Er<<24|e&255)>>0;const t=n.RGB;return t!=null?(Pr<<24|t&16777215)>>0:hs<<24>>0}function Fi(n){const e=new z(A.ByBlock);switch(n>>>24&255){case Ar:e.setByLayer();break;case hs:case fl:e.setByBlock();break;case Er:e.colorIndex=n&255;break;case Pr:e.setRGBValue(n&16777215);break;default:n>=0&&n<=256&&(e.colorIndex=n);break}return e}var Tr=(n=>(n[n.Undefined=0]="Undefined",n[n.Inches=1]="Inches",n[n.Feet=2]="Feet",n[n.Miles=3]="Miles",n[n.Millimeters=4]="Millimeters",n[n.Centimeters=5]="Centimeters",n[n.Meters=6]="Meters",n[n.Kilometers=7]="Kilometers",n[n.Microinches=8]="Microinches",n[n.Mils=9]="Mils",n[n.Yards=10]="Yards",n[n.Angstroms=11]="Angstroms",n[n.Nanometers=12]="Nanometers",n[n.Microns=13]="Microns",n[n.Decimeters=14]="Decimeters",n[n.Dekameters=15]="Dekameters",n[n.Hectometers=16]="Hectometers",n[n.Gigameters=17]="Gigameters",n[n.Astronomical=18]="Astronomical",n[n.LightYears=19]="LightYears",n[n.Parsecs=20]="Parsecs",n[n.USSurveyFeet=21]="USSurveyFeet",n[n.USSurveyInch=22]="USSurveyInch",n[n.USSurveyYard=23]="USSurveyYard",n[n.USSurveyMile=24]="USSurveyMile",n[n.Max=24]="Max",n))(Tr||{});function $c(n){return n==4||n==5||n==6||n==7||n==12||n==13||n==14||n==15||n==16||n==17}function qc(n){return n==1||n==2||n==3||n==8||n==9||n==10||n==21}class Mr{parse(e){const i=this.normalizeLineEndings(e).split(`
5
+ `),s=[],r=[];let a=null;return i.forEach((o,h)=>{const c=h+1,d=this.stripInlineComment(o).trim();if(!d)return;if(d.startsWith("*")){this.flushCurrentPattern(a,s,r);const p=this.parseHeader(d.slice(1));if(!p){r.push({line:c,message:"Invalid pattern header.",source:o}),a=null;return}a={pattern:{name:p.name,description:p.description,lines:[]},headerLine:c};return}if(!a){r.push({line:c,message:"Line descriptor appears before any pattern header.",source:o});return}const u=this.parseLineDescriptor(d,c);if(!u){r.push({line:c,message:"Invalid line descriptor. Expect: angle,x-origin,y-origin,delta-x,delta-y[,dash-1,...].",source:o});return}a.pattern.lines.push(u)}),this.flushCurrentPattern(a,s,r),{patterns:s,issues:r}}static parse(e){return new Mr().parse(e)}normalizeLineEndings(e){return e.replace(/\r\n/g,`
6
+ `).replace(/\r/g,`
7
+ `)}stripInlineComment(e){const t=e.indexOf(";");return t<0?e:e.slice(0,t)}parseHeader(e){const t=e.indexOf(",");if(t<0){const r=e.trim();return r?{name:r,description:""}:null}const i=e.slice(0,t).trim(),s=e.slice(t+1).trim();return i?{name:i,description:s}:null}parseNumber(e){const t=Number(e.trim());return Number.isFinite(t)?t:null}parseLineDescriptor(e,t){const i=e.split(",").map(u=>u.trim()).filter(u=>u.length>0);if(i.length<5)return null;const s=this.parseNumber(i[0]),r=this.parseNumber(i[1]),a=this.parseNumber(i[2]),o=this.parseNumber(i[3]),h=this.parseNumber(i[4]);if(s==null||r==null||a==null||o==null||h==null)return null;const c=i.slice(5),d=[];for(const u of c){const p=this.parseNumber(u);if(p==null)return null;d.push(p)}return{angle:s,originX:r,originY:a,deltaX:o,deltaY:h,dashes:d,sourceLine:t}}flushCurrentPattern(e,t,i){e&&(e.pattern.lines.length===0&&i.push({line:e.headerLine,message:`Pattern "${e.pattern.name}" has no line descriptor.`,source:""}),t.push(e.pattern))}}const Zc={patterns:[{name:"SOLID",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:21}]},{name:"ANGLE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.275,dashes:[.2,-.075],sourceLine:23},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.275,dashes:[.2,-.075],sourceLine:24}]},{name:"ANSI31",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:26}]},{name:"ANSI32",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.375,dashes:[],sourceLine:28},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.375,dashes:[],sourceLine:29}]},{name:"ANSI33",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:31},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.25,dashes:[.125,-.0625],sourceLine:32}]},{name:"ANSI34",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:34},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:35},{angle:45,originX:.353553391,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:36},{angle:45,originX:.530330086,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:37}]},{name:"ANSI35",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:39},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.25,dashes:[.3125,-.0625,0,-.0625],sourceLine:40}]},{name:"ANSI36",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:.21875,deltaY:.125,dashes:[.3125,-.0625,0,-.0625],sourceLine:42}]},{name:"ANSI37",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:44},{angle:135,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:45}]},{name:"ANSI38",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:47},{angle:135,originX:0,originY:0,deltaX:.25,deltaY:.125,dashes:[.3125,-.1875],sourceLine:48}]},{name:"AR-B816",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:8,dashes:[],sourceLine:54},{angle:90,originX:0,originY:0,deltaX:8,deltaY:8,dashes:[8,-8],sourceLine:55}]},{name:"AR-B816C",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:8,deltaY:8,dashes:[15.625,-.375],sourceLine:57},{angle:0,originX:-8,originY:.375,deltaX:8,deltaY:8,dashes:[15.625,-.375],sourceLine:58},{angle:90,originX:0,originY:0,deltaX:8,deltaY:8,dashes:[-8.375,7.625],sourceLine:59},{angle:90,originX:-.375,originY:0,deltaX:8,deltaY:8,dashes:[-8.375,7.625],sourceLine:60}]},{name:"AR-B88",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:8,dashes:[],sourceLine:62},{angle:90,originX:0,originY:0,deltaX:8,deltaY:4,dashes:[8,-8],sourceLine:63}]},{name:"AR-BRELM",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5.334,dashes:[7.625,-.375],sourceLine:65},{angle:0,originX:0,originY:2.25,deltaX:0,deltaY:5.334,dashes:[7.625,-.375],sourceLine:66},{angle:0,originX:2,originY:2.667,deltaX:0,deltaY:5.334,dashes:[3.625,-.375],sourceLine:67},{angle:0,originX:2,originY:4.917,deltaX:0,deltaY:5.334,dashes:[3.625,-.375],sourceLine:68},{angle:90,originX:0,originY:0,deltaX:0,deltaY:8,dashes:[2.25,-3.084],sourceLine:69},{angle:90,originX:-.375,originY:0,deltaX:0,deltaY:8,dashes:[2.25,-3.084],sourceLine:70},{angle:90,originX:2,originY:2.667,deltaX:0,deltaY:4,dashes:[2.25,-3.084],sourceLine:71},{angle:90,originX:1.625,originY:2.667,deltaX:0,deltaY:4,dashes:[2.25,-3.084],sourceLine:72}]},{name:"AR-BRSTD",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:2.667,dashes:[],sourceLine:74},{angle:90,originX:0,originY:0,deltaX:2.667,deltaY:4,dashes:[2.667,-2.667],sourceLine:75}]},{name:"AR-CONC",description:"",lines:[{angle:50,originX:0,originY:0,deltaX:4.12975034,deltaY:-5.89789472,dashes:[.75,-8.25],sourceLine:77},{angle:355,originX:0,originY:0,deltaX:-2.03781207,deltaY:7.3723684,dashes:[.6,-6.6],sourceLine:78},{angle:100.45144446,originX:.59771681,originY:-.05229344,deltaX:5.7305871,deltaY:-6.9397673,dashes:[.63740192,-7.01142112],sourceLine:79},{angle:46.1842,originX:0,originY:2,deltaX:6.19462554,deltaY:-8.84684596,dashes:[1.125,-12.375],sourceLine:80},{angle:96.63563549,originX:.88936745,originY:1.86206693,deltaX:8.59588239,deltaY:-10.40964966,dashes:[.95610342,-10.5171376],sourceLine:81},{angle:351.18416399,originX:0,originY:2,deltaX:7.74327494,deltaY:11.05855746,dashes:[.9,-9.90000001],sourceLine:82},{angle:21,originX:1,originY:1.5,deltaX:4.12975034,deltaY:-5.89789472,dashes:[.75,-8.25],sourceLine:83},{angle:326,originX:1,originY:1.5,deltaX:-2.03781207,deltaY:7.3723684,dashes:[.6,-6.6],sourceLine:84},{angle:71.45144474,originX:1.49742254,originY:1.16448426,deltaX:5.7305871,deltaY:-6.9397673,dashes:[.6374019,-7.01142112],sourceLine:85},{angle:37.5,originX:0,originY:0,deltaX:2.123,deltaY:2.567,dashes:[0,-6.52,0,-6.7,0,-6.625],sourceLine:86},{angle:7.5,originX:0,originY:0,deltaX:3.123,deltaY:3.567,dashes:[0,-3.82,0,-6.37,0,-2.525],sourceLine:87},{angle:-32.5,originX:-2.23,originY:0,deltaX:4.6234,deltaY:2.678,dashes:[0,-2.5,0,-7.8,0,-10.35],sourceLine:88},{angle:-42.5,originX:-3.23,originY:0,deltaX:3.6234,deltaY:4.678,dashes:[0,-3.25,0,-5.18,0,-7.35],sourceLine:89}]},{name:"AR-HBONE",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:4,deltaY:4,dashes:[12,-4],sourceLine:91},{angle:135,originX:2.828427125,originY:2.828427125,deltaX:4,deltaY:-4,dashes:[12,-4],sourceLine:92}]},{name:"AR-PARQ1",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:94},{angle:90,originX:2,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:95},{angle:90,originX:4,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:96},{angle:90,originX:6,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:97},{angle:90,originX:8,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:98},{angle:90,originX:10,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:99},{angle:90,originX:12,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:100},{angle:0,originX:0,originY:12,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:101},{angle:0,originX:0,originY:14,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:102},{angle:0,originX:0,originY:16,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:103},{angle:0,originX:0,originY:18,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:104},{angle:0,originX:0,originY:20,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:105},{angle:0,originX:0,originY:22,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:106},{angle:0,originX:0,originY:24,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:107}]},{name:"AR-RROOF",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:2.2,deltaY:1,dashes:[15,-2,5,-1],sourceLine:109},{angle:0,originX:1.33,originY:.5,deltaX:-1,deltaY:1.33,dashes:[3,-.33,6,-.75],sourceLine:110},{angle:0,originX:.5,originY:.85,deltaX:5.2,deltaY:.67,dashes:[8,-1.4,4,-1],sourceLine:111}]},{name:"AR-RSHKE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:25.5,deltaY:12,dashes:[6,-5,7,-3,9,-4],sourceLine:113},{angle:0,originX:6,originY:.5,deltaX:25.5,deltaY:12,dashes:[5,-19,4,-6],sourceLine:114},{angle:0,originX:18,originY:-.75,deltaX:25.5,deltaY:12,dashes:[3,-31],sourceLine:115},{angle:90,originX:0,originY:0,deltaX:12,deltaY:8.5,dashes:[11.5,-36.5],sourceLine:116},{angle:90,originX:6,originY:0,deltaX:12,deltaY:8.5,dashes:[11.25,-36.75],sourceLine:117},{angle:90,originX:11,originY:0,deltaX:12,deltaY:8.5,dashes:[10.5,-37.5],sourceLine:118},{angle:90,originX:18,originY:-.75,deltaX:12,deltaY:8.5,dashes:[11.5,-36.5],sourceLine:119},{angle:90,originX:21,originY:-.75,deltaX:12,deltaY:8.5,dashes:[11.5,-36.5],sourceLine:120},{angle:90,originX:30,originY:0,deltaX:12,deltaY:8.5,dashes:[11,-37],sourceLine:121}]},{name:"AR-SAND",description:"",lines:[{angle:37.5,originX:0,originY:0,deltaX:1.123,deltaY:1.567,dashes:[0,-1.52,0,-1.7,0,-1.625],sourceLine:123},{angle:7.5,originX:0,originY:0,deltaX:2.123,deltaY:2.567,dashes:[0,-.82,0,-1.37,0,-.525],sourceLine:124},{angle:-32.5,originX:-1.23,originY:0,deltaX:2.6234,deltaY:1.678,dashes:[0,-.5,0,-1.8,0,-2.35],sourceLine:125},{angle:-42.5,originX:-1.23,originY:0,deltaX:1.6234,deltaY:2.678,dashes:[0,-.25,0,-1.18,0,-1.35],sourceLine:126}]},{name:"BOX",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[],sourceLine:128},{angle:90,originX:.25,originY:0,deltaX:0,deltaY:1,dashes:[],sourceLine:129},{angle:0,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[-.25,.25],sourceLine:130},{angle:0,originX:0,originY:.25,deltaX:0,deltaY:1,dashes:[-.25,.25],sourceLine:131},{angle:0,originX:0,originY:.5,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:132},{angle:0,originX:0,originY:.75,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:133},{angle:90,originX:.5,originY:0,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:134},{angle:90,originX:.75,originY:0,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:135}]},{name:"BRASS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:137},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.25,dashes:[.125,-.0625],sourceLine:138}]},{name:"BRICK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:140},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.5,dashes:[.25,-.25],sourceLine:141},{angle:90,originX:.25,originY:0,deltaX:0,deltaY:.5,dashes:[-.25,.25],sourceLine:142}]},{name:"BRSTONE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.33,dashes:[],sourceLine:144},{angle:90,originX:.9,originY:0,deltaX:.33,deltaY:.5,dashes:[.33,-.33],sourceLine:145},{angle:90,originX:.8,originY:0,deltaX:.33,deltaY:.5,dashes:[.33,-.33],sourceLine:146},{angle:0,originX:.9,originY:.055,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:147},{angle:0,originX:.9,originY:.11,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:148},{angle:0,originX:.9,originY:.165,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:149},{angle:0,originX:.9,originY:.22,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:150},{angle:0,originX:.9,originY:.275,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:151}]},{name:"CLAY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.1875,dashes:[],sourceLine:153},{angle:0,originX:0,originY:.03125,deltaX:0,deltaY:.1875,dashes:[],sourceLine:154},{angle:0,originX:0,originY:.0625,deltaX:0,deltaY:.1875,dashes:[],sourceLine:155},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.1875,dashes:[.1875,-.125],sourceLine:156}]},{name:"CORK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:158},{angle:135,originX:.0625,originY:-.0625,deltaX:0,deltaY:.35355339,dashes:[.176776696,-.176776696],sourceLine:159},{angle:135,originX:.09375,originY:-.0625,deltaX:0,deltaY:.35355339,dashes:[.176776696,-.176776696],sourceLine:160},{angle:135,originX:.125,originY:-.0625,deltaX:0,deltaY:.35355339,dashes:[.176776696,-.176776696],sourceLine:161}]},{name:"CROSS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.25,deltaY:.25,dashes:[.125,-.375],sourceLine:163},{angle:90,originX:.0625,originY:-.0625,deltaX:.25,deltaY:.25,dashes:[.125,-.375],sourceLine:164}]},{name:"DASH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.125,deltaY:.125,dashes:[.125,-.125],sourceLine:166}]},{name:"DOLMIT",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:168},{angle:45,originX:0,originY:0,deltaX:0,deltaY:.70710678,dashes:[.3535533905932738,-.7071067811865476],sourceLine:169}]},{name:"DOTS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.03125,deltaY:.0625,dashes:[0,-.0625],sourceLine:171}]},{name:"EARTH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:173},{angle:0,originX:0,originY:.09375,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:174},{angle:0,originX:0,originY:.1875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:175},{angle:90,originX:.03125,originY:.21875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:176},{angle:90,originX:.125,originY:.21875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:177},{angle:90,originX:.21875,originY:.21875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:178}]},{name:"ESCHER",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[1.1,-.1],sourceLine:180},{angle:180,originX:0,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[1.1,-.1],sourceLine:181},{angle:300,originX:0,originY:0,deltaX:.6,deltaY:1.039230484,dashes:[1.1,-.1],sourceLine:182},{angle:60,originX:.1,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:183},{angle:300,originX:.1,originY:0,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:184},{angle:60,originX:-.05,originY:.08660254,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:185},{angle:180,originX:-.05,originY:.08660254,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:186},{angle:300,originX:-.05,originY:-.08660254,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:187},{angle:180,originX:-.05,originY:-.08660254,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:188},{angle:60,originX:-.4,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:189},{angle:300,originX:-.4,originY:0,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:190},{angle:60,originX:.2,originY:-.346410161,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:191},{angle:180,originX:.2,originY:-.346410161,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:192},{angle:300,originX:.2,originY:.346410161,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:193},{angle:180,originX:.2,originY:.346410161,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:194},{angle:0,originX:.2,originY:.173205081,deltaX:-.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:195},{angle:0,originX:.2,originY:-.173205081,deltaX:-.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:196},{angle:120,originX:.05,originY:.259807621,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:197},{angle:120,originX:-.25,originY:.08660254,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:198},{angle:240,originX:-.25,originY:-.08660254,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:199},{angle:240,originX:.05,originY:-.259807621,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:200}]},{name:"FLEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[.25,-.25],sourceLine:202},{angle:45,originX:.25,originY:0,deltaX:.176776695296,deltaY:.176776695296,dashes:[.0625,-.2285533906,.0625,-.353553390593],sourceLine:203}]},{name:"GOST_GLASS",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:6,deltaY:-6,dashes:[5,-7],sourceLine:205},{angle:45,originX:2.12132,originY:0,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:206},{angle:45,originX:0,originY:2.12132,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:207}]},{name:"GOST_WOOD",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:209},{angle:90,originX:2,originY:-2,deltaX:0,deltaY:-6,dashes:[6,-1.5,3,-1.5],sourceLine:210},{angle:90,originX:4,originY:-5,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:211}]},{name:"GOST_GROUND",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:213},{angle:45,originX:3,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:214},{angle:45,originX:6,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:215}]},{name:"GRASS",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:.707106781,deltaY:.707106781,dashes:[.1875,-1.226713563],sourceLine:217},{angle:45,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[.1875,-.8125],sourceLine:218},{angle:135,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[.1875,-.8125],sourceLine:219}]},{name:"GRATE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.03125,dashes:[],sourceLine:221},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:222}]},{name:"GRAVEL",description:"",lines:[{angle:228.012787504,originX:.72,originY:1,deltaX:12.0413651692039,deltaY:.0743294146632,dashes:[.134536,-13.3190880470737],sourceLine:224},{angle:184.969740728,originX:.63,originY:.9,deltaX:-12.0415166747131,deltaY:.0433148081592,dashes:[.230868,-22.85592476123],sourceLine:225},{angle:132.510447078,originX:.4,originY:.88,deltaX:-14.8659418273816,deltaY:.061429511683,dashes:[.162788,-16.1160325960997],sourceLine:226},{angle:267.273689006,originX:.01,originY:.63,deltaX:-20.0249279039043,deltaY:.0475651493827,dashes:[.210238,-20.813558041629],sourceLine:227},{angle:292.833654178,originX:0,originY:.42,deltaX:-12.9999095019474,deltaY:.048507125026,dashes:[.206155,-20.4093731280883],sourceLine:228},{angle:357.273689006,originX:.08,originY:.23,deltaX:-20.0249279039043,deltaY:.0475651493827,dashes:[.210238,-20.813558041629],sourceLine:229},{angle:37.6942404667,originX:.29,originY:.22,deltaX:-16.4011800288558,deltaY:.0359675000664,dashes:[.278029,-27.524848548916],sourceLine:230},{angle:72.2553283749,originX:.51,originY:.39,deltaX:23.0867613281116,deltaY:.0380969659053,dashes:[.262488,-25.9863214968134],sourceLine:231},{angle:121.429565615,originX:.59,originY:.64,deltaX:15.2642639131074,deltaY:.047404546271,dashes:[.21095,-20.884073109729],sourceLine:232},{angle:175.236358309,originX:.48,originY:.82,deltaX:-11.0450488205478,deltaY:.083045479801,dashes:[.240832,-11.8007625787923],sourceLine:233},{angle:222.397437798,originX:.24,originY:.84,deltaX:16.2787889313724,deltaY:.0321080648114,dashes:[.311448,-30.8333750047949],sourceLine:234},{angle:138.814074834,originX:1,originY:.62,deltaX:9.2190645101588,deltaY:.0940720868851,dashes:[.106301,-10.5238448127347],sourceLine:235},{angle:171.46923439,originX:.92,originY:.69,deltaX:-13.1528534931484,deltaY:.0494468176315,dashes:[.202237,-20.021511416157],sourceLine:236},{angle:225,originX:.72,originY:.72,deltaX:.7071067811865,deltaY:.7071067811865,dashes:[.141421,-1.2727925623731],sourceLine:237},{angle:203.198590514,originX:.65,originY:.84,deltaX:-5.3835637472478,deltaY:.1313064328928,dashes:[.076158,-7.5396151058639],sourceLine:238},{angle:291.801409486,originX:.58,originY:.81,deltaX:-3.156820749011,deltaY:.185695338158,dashes:[.107703,-5.2774618071345],sourceLine:239},{angle:30.9637565321,originX:.62,originY:.71,deltaX:3.6014702879928,deltaY:.1714985851408,dashes:[.174929,-5.6560228948453],sourceLine:240},{angle:161.565051177,originX:.77,originY:.8,deltaX:-2.2135943621183,deltaY:.3162277660138,dashes:[.126491,-3.0357866601684],sourceLine:241},{angle:16.389540334,originX:0,originY:.81,deltaX:10.4401539876873,deltaY:.0564332648047,dashes:[.1772,-17.5428451466694],sourceLine:242},{angle:70.3461759419,originX:.17,originY:.86,deltaX:-11.7045066155395,deltaY:.0672672793901,dashes:[.148661,-14.717407747319],sourceLine:243},{angle:293.198590514,originX:.77,originY:1,deltaX:-5.3835637472478,deltaY:.1313064328928,dashes:[.152315,-7.4634581058639],sourceLine:244},{angle:343.610459666,originX:.83,originY:.86,deltaX:-10.4401539876873,deltaY:.0564332648047,dashes:[.1772,-17.542845146669],sourceLine:245},{angle:339.44395478,originX:0,originY:.19,deltaX:-5.3838927710229,deltaY:.117041147157,dashes:[.17088,-8.3731237453175],sourceLine:246},{angle:294.775140569,originX:.16,originY:.13,deltaX:-12.0828441168135,deltaY:.0698430296124,dashes:[.143178,-14.174643063276],sourceLine:247},{angle:66.8014094864,originX:.78,originY:0,deltaX:5.3835637472487,deltaY:.1313064328552,dashes:[.152315,-7.4634581058639],sourceLine:248},{angle:17.3540246363,originX:.84,originY:.14,deltaX:-13.6013396869991,deltaY:.0596549986364,dashes:[.167631,-16.59542361424],sourceLine:249},{angle:69.4439547804,originX:.29,originY:0,deltaX:-5.383892771022,deltaY:.1170411471946,dashes:[.08544,-8.4585637453175],sourceLine:250},{angle:101.309932474,originX:.72,originY:0,deltaX:4.1184388379018,deltaY:.1961161351396,dashes:[.05099,-5.0480295135928],sourceLine:251},{angle:165.963756532,originX:.71,originY:.05,deltaX:-3.1529631254726,deltaY:.2425356250323,dashes:[.206155,-3.9169506256177],sourceLine:252},{angle:186.009005957,originX:.51,originY:.1,deltaX:-10.0497393137326,deltaY:.0523423921723,dashes:[.19105,-18.9139231745428],sourceLine:253},{angle:303.690067526,originX:.62,originY:.62,deltaX:-2.2188007849008,deltaY:.2773500981134,dashes:[.144222,-3.461329275464],sourceLine:254},{angle:353.157226587,originX:.7,originY:.5,deltaX:17.1171966955143,deltaY:.0397150736497,dashes:[.251794,-24.9275626240283],sourceLine:255},{angle:60.9453959009,originX:.95,originY:.47,deltaX:-8.0616726575653,deltaY:.0971285862325,dashes:[.102956,-10.192674140987],sourceLine:256},{angle:90,originX:1,originY:.56,deltaX:1,deltaY:1,dashes:[.06,-.94],sourceLine:257},{angle:120.256437164,originX:.49,originY:.13,deltaX:-8.0619364083848,deltaY:.0719815751411,dashes:[.138924,-13.7535199894498],sourceLine:258},{angle:48.0127875042,originX:.42,originY:.25,deltaX:12.0413651692041,deltaY:.0743294146212,dashes:[.269072,-13.1845520470737],sourceLine:259},{angle:0,originX:.6,originY:.45,deltaX:1,deltaY:1,dashes:[.26,-.74],sourceLine:260},{angle:325.304846469,originX:.86,originY:.45,deltaX:12.2063917682497,deltaY:-.063245553253,dashes:[.158114,-15.653274300842],sourceLine:261},{angle:254.054604099,originX:.99,originY:.36,deltaX:4.1208169184605,deltaY:.1373605639542,dashes:[.145602,-7.1345078892805],sourceLine:262},{angle:207.645975364,originX:.95,originY:.22,deltaX:21.4708691170287,deltaY:.0421824539631,dashes:[.237065,-23.4694741822594],sourceLine:263},{angle:175.42607874,originX:.74,originY:.11,deltaX:13.0383438432524,deltaY:.039872611164,dashes:[.250799,-24.8290734079689],sourceLine:264}]},{name:"HEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.21650635094610965,dashes:[.125,-.25],sourceLine:266},{angle:120,originX:0,originY:0,deltaX:0,deltaY:.21650635094610965,dashes:[.125,-.25],sourceLine:267},{angle:60,originX:.125,originY:0,deltaX:0,deltaY:.21650635094610965,dashes:[.125,-.25],sourceLine:268}]},{name:"HONEY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.1875,deltaY:.10825317547305482,dashes:[.125,-.25],sourceLine:270},{angle:120,originX:0,originY:0,deltaX:.1875,deltaY:.10825317547305482,dashes:[.125,-.25],sourceLine:271},{angle:60,originX:0,originY:0,deltaX:.1875,deltaY:.10825317547305482,dashes:[-.25,.125],sourceLine:272}]},{name:"HOUND",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.25,deltaY:.0625,dashes:[1,-.5],sourceLine:274},{angle:90,originX:0,originY:0,deltaX:-.25,deltaY:.0625,dashes:[1,-.5],sourceLine:275}]},{name:"INSUL",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.375,dashes:[],sourceLine:277},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.375,dashes:[.125,-.125],sourceLine:278},{angle:0,originX:0,originY:.25,deltaX:0,deltaY:.375,dashes:[.125,-.125],sourceLine:279}]},{name:"ACAD_ISO02W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3],sourceLine:292}]},{name:"ACAD_ISO03W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-18],sourceLine:294}]},{name:"ACAD_ISO04W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3],sourceLine:296}]},{name:"ACAD_ISO05W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-3],sourceLine:298}]},{name:"ACAD_ISO06W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-6.5],sourceLine:300},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-34,.5,-3],sourceLine:301}]},{name:"ACAD_ISO07W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[.5,-3],sourceLine:303}]},{name:"ACAD_ISO08W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3],sourceLine:305}]},{name:"ACAD_ISO09W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3,6,-3],sourceLine:307}]},{name:"ACAD_ISO10W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3],sourceLine:309}]},{name:"ACAD_ISO11W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-3],sourceLine:311}]},{name:"ACAD_ISO12W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-3],sourceLine:313}]},{name:"ACAD_ISO13W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-6.5],sourceLine:315},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3],sourceLine:316}]},{name:"ACAD_ISO14W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-6.5],sourceLine:318},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-22,.5,-3],sourceLine:319}]},{name:"ACAD_ISO15W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-10],sourceLine:321},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3,.5,-3],sourceLine:322}]},{name:"LINE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:327}]},{name:"MUDST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.5,deltaY:.25,dashes:[.25,-.25,0,-.25,0,-.25],sourceLine:329}]},{name:"NET",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:331},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:332}]},{name:"NET3",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:334},{angle:60,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:335},{angle:120,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:336}]},{name:"PLAST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:338},{angle:0,originX:0,originY:.03125,deltaX:0,deltaY:.25,dashes:[],sourceLine:339},{angle:0,originX:0,originY:.0625,deltaX:0,deltaY:.25,dashes:[],sourceLine:340}]},{name:"PLASTI",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:342},{angle:0,originX:0,originY:.03125,deltaX:0,deltaY:.25,dashes:[],sourceLine:343},{angle:0,originX:0,originY:.0625,deltaX:0,deltaY:.25,dashes:[],sourceLine:344},{angle:0,originX:0,originY:.15625,deltaX:0,deltaY:.25,dashes:[],sourceLine:345}]},{name:"SACNCR",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.09375,dashes:[],sourceLine:347},{angle:45,originX:.066291261,originY:0,deltaX:0,deltaY:.09375,dashes:[0,-.09375],sourceLine:348}]},{name:"SQUARE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[.125,-.125],sourceLine:350},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[.125,-.125],sourceLine:351}]},{name:"STARS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.216506351,dashes:[.125,-.125],sourceLine:353},{angle:60,originX:0,originY:0,deltaX:0,deltaY:.216506351,dashes:[.125,-.125],sourceLine:354},{angle:120,originX:.0625,originY:.108253176,deltaX:0,deltaY:.216506351,dashes:[.125,-.125],sourceLine:355}]},{name:"STEEL",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:357},{angle:45,originX:0,originY:.0625,deltaX:0,deltaY:.125,dashes:[],sourceLine:358}]},{name:"SWAMP",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.5,deltaY:.866025403,dashes:[.125,-.875],sourceLine:360},{angle:90,originX:.0625,originY:0,deltaX:.866025403,deltaY:.5,dashes:[.0625,-1.669550806],sourceLine:361},{angle:90,originX:.078125,originY:0,deltaX:.866025403,deltaY:.5,dashes:[.05,-1.682050806],sourceLine:362},{angle:90,originX:.046875,originY:0,deltaX:.866025403,deltaY:.5,dashes:[.05,-1.682050806],sourceLine:363},{angle:60,originX:.09375,originY:0,deltaX:.5,deltaY:.866025403,dashes:[.04,-.96],sourceLine:364},{angle:120,originX:.03125,originY:0,deltaX:.5,deltaY:.866025403,dashes:[.04,-.96],sourceLine:365}]},{name:"TRANS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:367},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.25,dashes:[.125,-.125],sourceLine:368}]},{name:"TRIANG",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:.1875,deltaY:.324759526,dashes:[.1875,-.1875],sourceLine:370},{angle:120,originX:0,originY:0,deltaX:.1875,deltaY:.324759526,dashes:[.1875,-.1875],sourceLine:371},{angle:0,originX:-.09375,originY:.162379763,deltaX:.1875,deltaY:.324759526,dashes:[.1875,-.1875],sourceLine:372}]},{name:"ZIGZAG",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.125,deltaY:.125,dashes:[.125,-.125],sourceLine:374},{angle:90,originX:.125,originY:0,deltaX:.125,deltaY:.125,dashes:[.125,-.125],sourceLine:375}]}],issues:[]},Kc={patterns:[{name:"SOLID",description:"ʵ�����",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:18}]},{name:"ANGLE",description:"�Ǹ�",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.985,dashes:[5.08,-1.905],sourceLine:20},{angle:90,originX:0,originY:0,deltaX:0,deltaY:6.985,dashes:[5.08,-1.905],sourceLine:21}]},{name:"ANSI31",description:"ANSI ����ש��ʯ",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:23}]},{name:"ANSI32",description:"ANSI ��",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:9.525,dashes:[],sourceLine:25},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:9.525,dashes:[],sourceLine:26}]},{name:"ANSI33",description:"ANSI ��ͭ����ͭ����ͭ",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:28},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:6.35,dashes:[3.175,-1.5875],sourceLine:29}]},{name:"ANSI34",description:"ANSI ���Ϻ���",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:31},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:32},{angle:45,originX:8.98026,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:33},{angle:45,originX:13.4704,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:34}]},{name:"ANSI35",description:"ANSI �ͻ�ש���ͻ����",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:36},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:6.35,dashes:[7.9375,-1.5875,0,-1.5875],sourceLine:37}]},{name:"ANSI36",description:"ANSI ����ʯ�����ҺͲ���",lines:[{angle:45,originX:0,originY:0,deltaX:5.55625,deltaY:3.175,dashes:[7.9375,-1.5875,0,-1.5875],sourceLine:39}]},{name:"ANSI37",description:"ANSI Ǧ��п��þ����/��/���Ե��",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:41},{angle:135,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:42}]},{name:"ANSI38",description:"ANSI ��",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:44},{angle:135,originX:0,originY:0,deltaX:6.35,deltaY:3.175,dashes:[7.9375,-4.7625],sourceLine:45}]},{name:"AR-B816",description:"8x16 ��ש˳��",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:203.2,dashes:[],sourceLine:47},{angle:90,originX:0,originY:0,deltaX:203.2,deltaY:203.2,dashes:[203.2,-203.2],sourceLine:48}]},{name:"AR-B816C",description:"8x16 ��ש˳�����û���ӷ�",lines:[{angle:0,originX:0,originY:0,deltaX:203.2,deltaY:203.2,dashes:[396.875,-9.525],sourceLine:50},{angle:0,originX:-203.2,originY:9.525,deltaX:203.2,deltaY:203.2,dashes:[396.875,-9.525],sourceLine:51},{angle:90,originX:0,originY:0,deltaX:203.2,deltaY:203.2,dashes:[-212.725,193.675],sourceLine:52},{angle:90,originX:-9.525,originY:0,deltaX:203.2,deltaY:203.2,dashes:[-212.725,193.675],sourceLine:53}]},{name:"AR-B88",description:"8x8 ��ש˳��",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:203.2,dashes:[],sourceLine:55},{angle:90,originX:0,originY:0,deltaX:203.2,deltaY:101.6,dashes:[203.2,-203.2],sourceLine:56}]},{name:"AR-BRELM",description:"��׼ש��Ӣʽ�������û���ӷ�",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:135.484,dashes:[193.675,-9.525],sourceLine:58},{angle:0,originX:0,originY:57.15,deltaX:0,deltaY:135.484,dashes:[193.675,-9.525],sourceLine:59},{angle:0,originX:50.8,originY:67.7418,deltaX:0,deltaY:135.484,dashes:[92.075,-9.525],sourceLine:60},{angle:0,originX:50.8,originY:124.892,deltaX:0,deltaY:135.484,dashes:[92.075,-9.525],sourceLine:61},{angle:90,originX:0,originY:0,deltaX:0,deltaY:203.2,dashes:[57.15,-78.334],sourceLine:62},{angle:90,originX:-9.525,originY:0,deltaX:0,deltaY:203.2,dashes:[57.15,-78.334],sourceLine:63},{angle:90,originX:50.8,originY:67.7418,deltaX:0,deltaY:101.6,dashes:[57.15,-78.334],sourceLine:64},{angle:90,originX:41.275,originY:67.7418,deltaX:0,deltaY:101.6,dashes:[57.15,-78.334],sourceLine:65}]},{name:"AR-BRSTD",description:"��׼ש��˳��",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:67.7418,dashes:[],sourceLine:67},{angle:90,originX:0,originY:0,deltaX:67.7418,deltaY:101.6,dashes:[67.7418,-67.7418],sourceLine:68}]},{name:"AR-CONC",description:"����ĵ��ʯͷͼ��",lines:[{angle:50,originX:0,originY:0,deltaX:104.896,deltaY:-149.807,dashes:[19.05,-209.55],sourceLine:70},{angle:355,originX:0,originY:0,deltaX:-51.76101082,deltaY:187.25814969,dashes:[15.24,-167.64058417],sourceLine:71},{angle:100.4514447,originX:15.182007,originY:-1.3282535,deltaX:145.5569059,deltaY:-176.270089,dashes:[16.1900088,-178.0902446],sourceLine:72},{angle:46.1842,originX:0,originY:50.8,deltaX:157.343,deltaY:-224.71,dashes:[28.575,-314.325],sourceLine:73},{angle:96.63555761,originX:22.5899,originY:47.2965,deltaX:218.33577212,deltaY:-264.40480444,dashes:[24.28502314,-267.13560816],sourceLine:74},{angle:351.18415117,originX:0,originY:50.8,deltaX:196.67912063,deltaY:280.88740361,dashes:[22.85996707,-251.45973192],sourceLine:75},{angle:21,originX:25.4,originY:38.1,deltaX:104.89565868,deltaY:-149.80652586,dashes:[19.05,-209.55],sourceLine:76},{angle:326,originX:25.4,originY:38.1,deltaX:-51.7604,deltaY:187.258,dashes:[15.24,-167.64],sourceLine:77},{angle:71.451445,originX:38.0345326,originY:29.5779001,deltaX:145.5567546,deltaY:-176.2700748,dashes:[16.1900088,-178.0899376],sourceLine:78},{angle:37.5,originX:0,originY:0,deltaX:53.9242,deltaY:65.2018,dashes:[0,-165.608,0,-170.18,0,-168.275],sourceLine:79},{angle:7.5,originX:0,originY:0,deltaX:79.3242,deltaY:90.6018,dashes:[0,-97.028,0,-161.798,0,-64.135],sourceLine:80},{angle:-32.5,originX:-56.642,originY:0,deltaX:117.434,deltaY:68.0212,dashes:[0,-63.5,0,-198.12,0,-262.89],sourceLine:81},{angle:-42.5,originX:-82.042,originY:0,deltaX:92.0344,deltaY:118.821,dashes:[0,-82.55,0,-131.572,0,-186.69],sourceLine:82}]},{name:"AR-HBONE",description:"��׼��ש���������ͼ�� @ 45 �Ƚ�",lines:[{angle:45,originX:0,originY:0,deltaX:101.6,deltaY:101.6,dashes:[304.8,-101.6],sourceLine:84},{angle:135,originX:71.842,originY:71.842,deltaX:101.6,deltaY:-101.6,dashes:[304.8,-101.6],sourceLine:85}]},{name:"AR-PARQ1",description:"2x12 ��ľ�ذ�: 12x12 ��ͼ��",lines:[{angle:90,originX:0,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:87},{angle:90,originX:50.8,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:88},{angle:90,originX:101.6,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:89},{angle:90,originX:152.4,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:90},{angle:90,originX:203.2,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:91},{angle:90,originX:254,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:92},{angle:90,originX:304.8,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:93},{angle:0,originX:0,originY:304.8,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:94},{angle:0,originX:0,originY:355.6,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:95},{angle:0,originX:0,originY:406.4,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:96},{angle:0,originX:0,originY:457.2,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:97},{angle:0,originX:0,originY:508,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:98},{angle:0,originX:0,originY:558.8,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:99},{angle:0,originX:0,originY:609.6,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:100}]},{name:"AR-RROOF",description:"�ݶ�ľ��ͼ��",lines:[{angle:0,originX:0,originY:0,deltaX:55.88,deltaY:25.4,dashes:[381,-50.8,127,-25.4],sourceLine:102},{angle:0,originX:33.782,originY:12.7,deltaX:-25.4,deltaY:33.782,dashes:[76.2,-8.382,152.4,-19.05],sourceLine:103},{angle:0,originX:12.7,originY:21.59,deltaX:132.08,deltaY:17.018,dashes:[203.2,-35.56,101.6,-25.4],sourceLine:104}]},{name:"AR-RSHKE",description:"�ݶ�ʵľ��ͼ��",lines:[{angle:0,originX:0,originY:0,deltaX:647.7,deltaY:304.8,dashes:[152.4,-127,177.8,-76.2,228.6,-101.6],sourceLine:106},{angle:0,originX:152.4,originY:12.7,deltaX:647.7,deltaY:304.8,dashes:[127,-482.6,101.6,-152.4],sourceLine:107},{angle:0,originX:457.2,originY:-19.05,deltaX:647.7,deltaY:304.8,dashes:[76.2,-787.4],sourceLine:108},{angle:90,originX:0,originY:0,deltaX:304.8,deltaY:215.9,dashes:[292.1,-927.1],sourceLine:109},{angle:90,originX:152.4,originY:0,deltaX:304.8,deltaY:215.9,dashes:[285.75,-933.45],sourceLine:110},{angle:90,originX:279.4,originY:0,deltaX:304.8,deltaY:215.9,dashes:[266.7,-952.5],sourceLine:111},{angle:90,originX:457.2,originY:-19.05,deltaX:304.8,deltaY:215.9,dashes:[292.1,-927.1],sourceLine:112},{angle:90,originX:533.4,originY:-19.05,deltaX:304.8,deltaY:215.9,dashes:[292.1,-927.1],sourceLine:113},{angle:90,originX:762,originY:0,deltaX:304.8,deltaY:215.9,dashes:[279.4,-939.8],sourceLine:114}]},{name:"AR-SAND",description:"����ĵ�ͼ��",lines:[{angle:37.5,originX:0,originY:0,deltaX:28.5242,deltaY:39.8018,dashes:[0,-38.608,0,-43.18,0,-41.275],sourceLine:116},{angle:7.5,originX:0,originY:0,deltaX:53.9242,deltaY:65.2018,dashes:[0,-20.828,0,-34.798,0,-13.335],sourceLine:117},{angle:-32.5,originX:-31.242,originY:0,deltaX:66.6344,deltaY:42.6212,dashes:[0,-12.7,0,-45.72,0,-59.69],sourceLine:118},{angle:-42.5,originX:-31.242,originY:0,deltaX:41.2344,deltaY:68.0212,dashes:[0,-6.35,0,-29.972,0,-34.29],sourceLine:119}]},{name:"BOX",description:"����",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[],sourceLine:121},{angle:90,originX:6.35,originY:0,deltaX:0,deltaY:25.4,dashes:[],sourceLine:122},{angle:0,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[-6.35,6.35],sourceLine:123},{angle:0,originX:0,originY:6.35,deltaX:0,deltaY:25.4,dashes:[-6.35,6.35],sourceLine:124},{angle:0,originX:0,originY:12.7,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:125},{angle:0,originX:0,originY:19.05,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:126},{angle:90,originX:12.7,originY:0,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:127},{angle:90,originX:19.05,originY:0,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:128}]},{name:"BRASS",description:"��ͭ����",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:130},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:6.35,dashes:[3.175,-1.5875],sourceLine:131}]},{name:"BRICK",description:"שʯ���͵ı���",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:133},{angle:90,originX:0,originY:0,deltaX:0,deltaY:12.7,dashes:[6.35,-6.35],sourceLine:134},{angle:90,originX:6.35,originY:0,deltaX:0,deltaY:12.7,dashes:[-6.35,6.35],sourceLine:135}]},{name:"BRSTONE",description:"ש��ʯ",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:8.382,dashes:[],sourceLine:137},{angle:90,originX:22.86,originY:0,deltaX:8.382,deltaY:12.7,dashes:[8.382,-8.382],sourceLine:138},{angle:90,originX:20.32,originY:0,deltaX:8.382,deltaY:12.7,dashes:[8.382,-8.382],sourceLine:139},{angle:0,originX:22.86,originY:1.397,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:140},{angle:0,originX:22.86,originY:2.794,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:141},{angle:0,originX:22.86,originY:4.191,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:142},{angle:0,originX:22.86,originY:5.588,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:143},{angle:0,originX:22.86,originY:6.985,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:144}]},{name:"CLAY",description:"ճ������",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:4.7625,dashes:[],sourceLine:146},{angle:0,originX:0,originY:.79375,deltaX:0,deltaY:4.7625,dashes:[],sourceLine:147},{angle:0,originX:0,originY:1.5875,deltaX:0,deltaY:4.7625,dashes:[],sourceLine:148},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:4.7625,dashes:[4.7625,-3.175],sourceLine:149}]},{name:"CORK",description:"��ľ����",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:151},{angle:135,originX:1.5875,originY:-1.5875,deltaX:0,deltaY:8.98026,dashes:[4.49013,-4.49013],sourceLine:152},{angle:135,originX:2.38125,originY:-1.5875,deltaX:0,deltaY:8.98026,dashes:[4.49013,-4.49013],sourceLine:153},{angle:135,originX:3.175,originY:-1.5875,deltaX:0,deltaY:8.98026,dashes:[4.49013,-4.49013],sourceLine:154}]},{name:"CROSS",description:"һϵ��ʮ����",lines:[{angle:0,originX:0,originY:0,deltaX:6.35,deltaY:6.35,dashes:[3.175,-9.525],sourceLine:156},{angle:90,originX:1.5875,originY:-1.5875,deltaX:6.35,deltaY:6.35,dashes:[3.175,-9.525],sourceLine:157}]},{name:"DASH",description:"����",lines:[{angle:0,originX:0,originY:0,deltaX:3.175,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:159}]},{name:"DOLMIT",description:"�ؿ��Ҳ�",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:161},{angle:45,originX:0,originY:0,deltaX:0,deltaY:17.9605,dashes:[8.980256121069154,-17.960512242138307],sourceLine:162}]},{name:"DOTS",description:"һϵ�е�",lines:[{angle:0,originX:0,originY:0,deltaX:.79375,deltaY:1.5875,dashes:[0,-1.5875],sourceLine:164}]},{name:"EARTH",description:"����",lines:[{angle:0,originX:0,originY:0,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:166},{angle:0,originX:0,originY:2.38125,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:167},{angle:0,originX:0,originY:4.7625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:168},{angle:90,originX:.79375,originY:5.55625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:169},{angle:90,originX:3.175,originY:5.55625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:170},{angle:90,originX:5.55625,originY:5.55625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:171}]},{name:"ESCHER",description:"Escher ͼ��",lines:[{angle:60,originX:0,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[27.94,-2.54],sourceLine:173},{angle:180,originX:0,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[27.94,-2.54],sourceLine:174},{angle:300,originX:0,originY:0,deltaX:15.24,deltaY:26.3964542936,dashes:[27.94,-2.54],sourceLine:175},{angle:60,originX:2.54,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:176},{angle:300,originX:2.54,originY:0,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:177},{angle:60,originX:-1.27,originY:2.199704516,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:178},{angle:180,originX:-1.27,originY:2.199704516,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:179},{angle:300,originX:-1.27,originY:-2.199704516,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:180},{angle:180,originX:-1.27,originY:-2.199704516,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:181},{angle:60,originX:-10.16,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:182},{angle:300,originX:-10.16,originY:0,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:183},{angle:60,originX:5.08,originY:-8.7988180894,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:184},{angle:180,originX:5.08,originY:-8.7988180894,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:185},{angle:300,originX:5.08,originY:8.7988180894,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:186},{angle:180,originX:5.08,originY:8.7988180894,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:187},{angle:0,originX:5.08,originY:4.3994090574,deltaX:-15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:188},{angle:0,originX:5.08,originY:-4.3994090574,deltaX:-15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:189},{angle:120,originX:1.27,originY:6.5991135734,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:190},{angle:120,originX:-6.35,originY:2.199704516,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:191},{angle:240,originX:-6.35,originY:-2.199704516,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:192},{angle:240,originX:1.27,originY:-6.5991135734,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:193}]},{name:"FLEX",description:"���Բ���",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:195},{angle:45,originX:6.35,originY:0,deltaX:4.490128053,deltaY:4.490128053,dashes:[1.5875,-5.8052561314,1.5875,-8.9802561314],sourceLine:196}]},{name:"GOST_GLASS",description:"��������",lines:[{angle:45,originX:0,originY:0,deltaX:6,deltaY:-6,dashes:[5,-7],sourceLine:198},{angle:45,originX:2.12132,originY:0,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:199},{angle:45,originX:0,originY:2.12132,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:200}]},{name:"GOST_WOOD",description:"ľ�IJ���",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:202},{angle:90,originX:2,originY:-2,deltaX:0,deltaY:-6,dashes:[6,-1.5,3,-1.5],sourceLine:203},{angle:90,originX:4,originY:-5,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:204}]},{name:"GOST_GROUND",description:"����",lines:[{angle:45,originX:0,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:206},{angle:45,originX:3,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:207},{angle:45,originX:6,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:208}]},{name:"GRASS",description:"�ݵ�",lines:[{angle:90,originX:0,originY:0,deltaX:17.96051224,deltaY:17.96051224,dashes:[4.7625,-31.15852448],sourceLine:210},{angle:45,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[4.7625,-20.6375],sourceLine:211},{angle:135,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[4.7625,-20.6375],sourceLine:212}]},{name:"GRATE",description:"��դ����",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.79375,dashes:[],sourceLine:214},{angle:90,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:215}]},{name:"GRAVEL",description:"ɳ��ͼ��",lines:[{angle:228.0127875,originX:18.288,originY:25.4,deltaX:305.85067529778,deltaY:1.88796713245,dashes:[3.4172144,-338.30483639565],sourceLine:217},{angle:184.969741,originX:16.002,originY:22.86,deltaX:-305.8545235377,deltaY:1.10019612724,dashes:[5.8640472,-580.54048893524],sourceLine:218},{angle:132.5104471,originX:10.16,originY:22.352,deltaX:-377.59492241548,deltaY:1.56030959675,dashes:[4.1348152,-409.347227941],sourceLine:219},{angle:267.273689,originX:.254,originY:16.002,deltaX:-508.63316875916,deltaY:1.20815479432,dashes:[5.3400452,-528.66437425738],sourceLine:220},{angle:292.83365418,originX:0,originY:10.668,deltaX:-330.19770134945,deltaY:1.23208097566,dashes:[5.236337,-518.39807745344],sourceLine:221},{angle:357.273689,originX:2.032,originY:5.842,deltaX:-508.63316875916,deltaY:1.20815479432,dashes:[5.3400452,-528.66437425738],sourceLine:222},{angle:37.69424047,originX:7.366,originY:5.588,deltaX:-416.58997273292,deltaY:.91357450169,dashes:[7.0619366,-699.13115314247],sourceLine:223},{angle:72.25532837,originX:12.954,originY:9.906,deltaX:586.40373773403,deltaY:.96766293399,dashes:[6.6671952,-660.05256601905],sourceLine:224},{angle:121.42956562,originX:14.986,originY:16.256,deltaX:387.71230339293,deltaY:1.2040754753,dashes:[5.35813,-530.45545698712],sourceLine:225},{angle:175.2363583,originX:12.192,originY:20.828,deltaX:-280.5442400419,deltaY:2.10935518695,dashes:[6.1171328,-299.7393695],sourceLine:226},{angle:222.3974378,originX:6.096,originY:21.336,deltaX:413.48123885686,deltaY:.81554484621,dashes:[7.9107792,-783.16772512177],sourceLine:227},{angle:138.81407483,originX:25.4,originY:15.748,deltaX:234.164238558,deltaY:2.38943100688,dashes:[2.7000454,-267.30565824344],sourceLine:228},{angle:171.4692344,originX:23.368,originY:17.526,deltaX:-334.082478726,deltaY:1.25594916784,dashes:[5.1368198,-508.5463899704],sourceLine:229},{angle:225,originX:18.288,originY:18.288,deltaX:17.96051224214,deltaY:17.96051224214,dashes:[3.5920934,-32.32893108428],sourceLine:230},{angle:203.19859051,originX:16.51,originY:21.336,deltaX:-136.74251918,deltaY:3.33518339548,dashes:[1.9344132,-191.50622368894],sourceLine:231},{angle:291.80140949,originX:14.732,originY:20.574,deltaX:-80.18324702488,deltaY:4.71666158921,dashes:[2.7356562,-134.0475299],sourceLine:232},{angle:30.96375653,originX:15.748,originY:18.034,deltaX:91.47734531502,deltaY:4.35606406258,dashes:[4.4431966,-143.6629815291],sourceLine:233},{angle:161.56505118,originX:19.558,originY:20.32,deltaX:-56.2252967978,deltaY:8.03218525675,dashes:[3.2128714,-77.10898116828],sourceLine:234},{angle:16.389540334,originX:0,originY:20.574,deltaX:265.17991128726,deltaY:1.43340492604,dashes:[4.50088,-445.58826672539],sourceLine:235},{angle:70.34617594,originX:4.318,originY:21.844,deltaX:-297.29446803469,deltaY:1.70858889651,dashes:[3.7759894,-373.822156782],sourceLine:236},{angle:293.19859051,originX:19.558,originY:25.4,deltaX:-136.7425191801,deltaY:3.33518339548,dashes:[3.868801,-189.57183588894],sourceLine:237},{angle:343.61045967,originX:21.082,originY:21.844,deltaX:-265.17991128725,deltaY:1.433404926,dashes:[4.50088,-445.5882667254],sourceLine:238},{angle:339.44395478,originX:0,originY:4.826,deltaX:-136.75087638398,deltaY:2.97284513779,dashes:[4.340352,-212.67734313106],sourceLine:239},{angle:294.7751406,originX:4.064,originY:3.302,deltaX:-306.90424056705,deltaY:1.77401295215,dashes:[3.6367212,-360.0359338072],sourceLine:240},{angle:66.80140949,originX:19.812,originY:0,deltaX:136.74251918012,deltaY:3.33518339452,dashes:[3.868801,-189.57183588894],sourceLine:241},{angle:17.35402464,originX:21.336,originY:3.556,deltaX:-345.47402804977,deltaY:1.51523696536,dashes:[4.2578274,-421.523759802],sourceLine:242},{angle:69.44395478,originX:7.366,originY:0,deltaX:-136.75087638396,deltaY:2.97284513874,dashes:[2.170176,-214.84751913106],sourceLine:243},{angle:101.309932474,originX:18.288,originY:0,deltaX:104.60834648271,deltaY:4.98134983255,dashes:[1.295146,-128.21994964526],sourceLine:244},{angle:165.963756532,originX:18.034,originY:1.27,deltaX:-80.085263387,deltaY:6.16040487582,dashes:[5.236337,-99.49054589069],sourceLine:245},{angle:186.00900596,originX:12.954,originY:2.54,deltaX:-255.26337856879,deltaY:1.32949676118,dashes:[4.85267,-480.41364863337],sourceLine:246},{angle:303.69006753,originX:15.748,originY:15.748,deltaX:-56.35753993648,deltaY:7.0446924921,dashes:[3.6632388,-87.9177635968],sourceLine:247},{angle:353.15722659,originX:17.78,originY:12.7,deltaX:434.77679606606,deltaY:1.0087628707,dashes:[6.3955676,-633.16009065031],sourceLine:248},{angle:60.9453959,originX:24.13,originY:11.938,deltaX:-204.76648550216,deltaY:2.46706609031,dashes:[2.6150824,-258.8939231811],sourceLine:249},{angle:90,originX:25.4,originY:14.224,deltaX:25.4,deltaY:25.4,dashes:[1.524,-23.876],sourceLine:250},{angle:120.25643716,originX:12.446,originY:3.302,deltaX:-204.77318477297,deltaY:1.8283320086,dashes:[3.5286696,-349.339407732],sourceLine:251},{angle:48.0127875,originX:10.668,originY:6.35,deltaX:305.85067529778,deltaY:1.88796713138,dashes:[6.8344288,-334.88762199565],sourceLine:252},{angle:0,originX:15.24,originY:11.43,deltaX:25.4,deltaY:25.4,dashes:[6.604,-18.796],sourceLine:253},{angle:325.3048465,originX:21.844,originY:11.43,deltaX:310.04235091354,deltaY:-1.6064370526,dashes:[4.0160956,-397.5931672414],sourceLine:254},{angle:254.0546041,originX:25.146,originY:9.144,deltaX:104.6687497289,deltaY:3.48895832444,dashes:[3.6982908,-181.21650038772],sourceLine:255},{angle:207.64597536,originX:24.13,originY:5.588,deltaX:545.36007557253,deltaY:1.07143433066,dashes:[6.021451,-596.12464422938],sourceLine:256},{angle:175.42607874,originX:18.796,originY:2.794,deltaX:331.1739336186,deltaY:1.01276432357,dashes:[6.3702946,-630.6584645624],sourceLine:257}]},{name:"HEX",description:"������",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-6.35],sourceLine:259},{angle:120,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-6.35],sourceLine:260},{angle:60,originX:3.175,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-6.35],sourceLine:261}]},{name:"HONEY",description:"�䳲ͼ��",lines:[{angle:0,originX:0,originY:0,deltaX:4.7625,deltaY:2.749630645,dashes:[3.175,-6.35],sourceLine:263},{angle:120,originX:0,originY:0,deltaX:4.7625,deltaY:2.749630645,dashes:[3.175,-6.35],sourceLine:264},{angle:60,originX:0,originY:0,deltaX:4.7625,deltaY:2.749630645,dashes:[-6.35,3.175],sourceLine:265}]},{name:"HOUND",description:"Ȯ������ͼ��",lines:[{angle:0,originX:0,originY:0,deltaX:6.35,deltaY:1.5875,dashes:[25.4,-12.7],sourceLine:267},{angle:90,originX:0,originY:0,deltaX:-6.35,deltaY:1.5875,dashes:[25.4,-12.7],sourceLine:268}]},{name:"INSUL",description:"��Ե����",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:9.525,dashes:[],sourceLine:270},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:9.525,dashes:[3.175,-3.175],sourceLine:271},{angle:0,originX:0,originY:6.35,deltaX:0,deltaY:9.525,dashes:[3.175,-3.175],sourceLine:272}]},{name:"ACAD_ISO02W100",description:"����",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3],sourceLine:285}]},{name:"ACAD_ISO03W100",description:"�����ո���",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-18],sourceLine:287}]},{name:"ACAD_ISO04W100",description:"����������",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3],sourceLine:289}]},{name:"ACAD_ISO05W100",description:"������˫����",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-3],sourceLine:291}]},{name:"ACAD_ISO06W100",description:"������������",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-6.5],sourceLine:293},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-34,.5,-3],sourceLine:294}]},{name:"ACAD_ISO07W100",description:"����",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[.5,-3],sourceLine:296}]},{name:"ACAD_ISO08W100",description:"�������̻���",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3],sourceLine:298}]},{name:"ACAD_ISO09W100",description:"������˫�̻���",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3,6,-3],sourceLine:300}]},{name:"ACAD_ISO10W100",description:"��������",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3],sourceLine:302}]},{name:"ACAD_ISO11W100",description:"˫��������",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-3],sourceLine:304}]},{name:"ACAD_ISO12W100",description:"����˫����",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-3],sourceLine:306}]},{name:"ACAD_ISO13W100",description:"˫����˫����",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-6.5],sourceLine:308},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3],sourceLine:309}]},{name:"ACAD_ISO14W100",description:"����������",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-6.5],sourceLine:311},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-22,.5,-3],sourceLine:312}]},{name:"ACAD_ISO15W100",description:"˫����������",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-10],sourceLine:314},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3,.5,-3],sourceLine:315}]},{name:"JIS_LC_20",description:"LC JIS A 0150(@20)",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:322},{angle:45,originX:.4,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:323}]},{name:"JIS_LC_20A",description:"LC JIS A 0150(@20��?)",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:325},{angle:45,originX:1,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:326}]},{name:"JIS_LC_8",description:"LC JIS A 0150(@8)",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:328},{angle:45,originX:.4,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:329}]},{name:"JIS_LC_8A",description:"LC JIS A 0150(@8��?)",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:331},{angle:45,originX:1,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:332}]},{name:"JIS_RC_10",description:"RC JIS A 0150(@10)",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:10,dashes:[],sourceLine:334},{angle:45,originX:.725,originY:0,deltaX:0,deltaY:10,dashes:[],sourceLine:335},{angle:45,originX:1.45,originY:0,deltaX:0,deltaY:10,dashes:[],sourceLine:336}]},{name:"JIS_RC_15",description:"RC JIS A 0150(@15)",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:15,dashes:[],sourceLine:338},{angle:45,originX:.725,originY:0,deltaX:0,deltaY:15,dashes:[],sourceLine:339},{angle:45,originX:1.45,originY:0,deltaX:0,deltaY:15,dashes:[],sourceLine:340}]},{name:"JIS_RC_18",description:"RC JIS A 0150(@18)",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:18,dashes:[],sourceLine:342},{angle:45,originX:1,originY:0,deltaX:0,deltaY:18,dashes:[],sourceLine:343},{angle:45,originX:2,originY:0,deltaX:0,deltaY:18,dashes:[],sourceLine:344}]},{name:"JIS_RC_30",description:"RC JIS A 0150(@30)",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:30,dashes:[],sourceLine:346},{angle:45,originX:1,originY:0,deltaX:0,deltaY:30,dashes:[],sourceLine:347},{angle:45,originX:2,originY:0,deltaX:0,deltaY:30,dashes:[],sourceLine:348}]},{name:"JIS_STN_1E",description:"STONE JIS A 0150(@1)",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[],sourceLine:350},{angle:45,originX:.705,originY:0,deltaX:0,deltaY:1,dashes:[1,-.5],sourceLine:351}]},{name:"JIS_STN_2.5",description:"STONE JIS A 0150(@2.5)",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:2.5,dashes:[],sourceLine:353},{angle:45,originX:1.765,originY:0,deltaX:0,deltaY:2.5,dashes:[1.2,-.5],sourceLine:354}]},{name:"JIS_WOOD",description:"WOOD JIS A 0150",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.70710678,dashes:[],sourceLine:356}]},{name:"LINE",description:"ƽ��ˮƽ��",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:359}]},{name:"MUDST",description:"��ɳ",lines:[{angle:0,originX:0,originY:0,deltaX:12.7,deltaY:6.35,dashes:[6.35,-6.35,0,-6.35,0,-6.35],sourceLine:361}]},{name:"NET",description:"ˮƽ/��ֱդ��",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:363},{angle:90,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:364}]},{name:"NET3",description:"��״ͼ�� 0-60-120",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:366},{angle:60,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:367},{angle:120,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:368}]},{name:"PLAST",description:"���ϲ���",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:370},{angle:0,originX:0,originY:.79375,deltaX:0,deltaY:6.35,dashes:[],sourceLine:371},{angle:0,originX:0,originY:1.5875,deltaX:0,deltaY:6.35,dashes:[],sourceLine:372}]},{name:"PLASTI",description:"���ϲ���",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:374},{angle:0,originX:0,originY:.79375,deltaX:0,deltaY:6.35,dashes:[],sourceLine:375},{angle:0,originX:0,originY:1.5875,deltaX:0,deltaY:6.35,dashes:[],sourceLine:376},{angle:0,originX:0,originY:3.96875,deltaX:0,deltaY:6.35,dashes:[],sourceLine:377}]},{name:"SACNCR",description:"������",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:2.38125,dashes:[],sourceLine:379},{angle:45,originX:1.6838,originY:0,deltaX:0,deltaY:2.38125,dashes:[0,-2.38125],sourceLine:380}]},{name:"SQUARE",description:"�����С����",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:382},{angle:90,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:383}]},{name:"STARS",description:"��â��",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-3.175],sourceLine:385},{angle:60,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-3.175],sourceLine:386},{angle:120,originX:1.5875,originY:2.7496306704,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-3.175],sourceLine:387}]},{name:"STEEL",description:"�ֲ���",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:389},{angle:45,originX:0,originY:1.5875,deltaX:0,deltaY:3.175,dashes:[],sourceLine:390}]},{name:"SWAMP",description:"����ش�",lines:[{angle:0,originX:0,originY:0,deltaX:12.7,deltaY:21.9970452362,dashes:[3.175,-22.225],sourceLine:392},{angle:90,originX:1.5875,originY:0,deltaX:21.9970452362,deltaY:12.7,dashes:[1.5875,-42.4065904724],sourceLine:393},{angle:90,originX:1.984375,originY:0,deltaX:21.9970452362,deltaY:12.7,dashes:[1.27,-42.7240904724],sourceLine:394},{angle:90,originX:1.190625,originY:0,deltaX:21.9970452362,deltaY:12.7,dashes:[1.27,-42.7240904724],sourceLine:395},{angle:60,originX:2.38125,originY:0,deltaX:12.7,deltaY:21.9970452362,dashes:[1.016,-24.384],sourceLine:396},{angle:120,originX:.79375,originY:0,deltaX:12.7,deltaY:21.9970452362,dashes:[1.016,-24.384],sourceLine:397}]},{name:"TRANS",description:"�ȴ��ݲ���",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:399},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:6.35,dashes:[3.175,-3.175],sourceLine:400}]},{name:"TRIANG",description:"�ȱ�������",lines:[{angle:60,originX:0,originY:0,deltaX:4.7625,deltaY:8.2488919604,dashes:[4.7625,-4.7625],sourceLine:402},{angle:120,originX:0,originY:0,deltaX:4.7625,deltaY:8.2488919604,dashes:[4.7625,-4.7625],sourceLine:403},{angle:0,originX:-2.38125,originY:4.1244459802,deltaX:4.7625,deltaY:8.2488919604,dashes:[4.7625,-4.7625],sourceLine:404}]},{name:"ZIGZAG",description:"¥��Ч��",lines:[{angle:0,originX:0,originY:0,deltaX:3.175,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:406},{angle:90,originX:3.175,originY:0,deltaX:3.175,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:407}]}],issues:[]},we=class we{static toRadians(e){return e*Math.PI/180}static clamp(e,t,i){return Math.min(i,Math.max(t,e))}static estimateUnitScale(e){const t=[];for(const r of e.lines){t.push(Math.abs(r.deltaX),Math.abs(r.deltaY));for(const a of r.dashes)t.push(Math.abs(a))}const i=t.filter(r=>r>we.EPSILON);if(i.length===0)return 1;const s=i.sort((r,a)=>r-a);return s[Math.floor(s.length/2)]||1}static segmentToSvgPath(e){return`M ${e.x1.toFixed(2)} ${(-e.y1).toFixed(2)} L ${e.x2.toFixed(2)} ${(-e.y2).toFixed(2)}`}static buildDashSegments(e,t,i,s,r,a,o){const h=e.dashes;if(h.length===0)return[{x1:s+a*t,y1:r+o*t,x2:s+a*i,y2:r+o*i}];const c=h.reduce((g,m)=>g+Math.abs(m),0);if(c<=we.EPSILON)return[{x1:s+a*t,y1:r+o*t,x2:s+a*i,y2:r+o*i}];const d=[],u=Math.ceil((i-t)/c)+2;let p=t-c;for(let g=0;g<u;g++){let m=p;for(const y of h){const x=Math.abs(y),_=m+x;if(y>0||y===0){const S=we.clamp(m,t,i),L=we.clamp(_,t,i);L>S?d.push({x1:s+a*S,y1:r+o*S,x2:s+a*L,y2:r+o*L}):y===0&&S>=t&&S<=i&&d.push({x1:s+a*(S-.35),y1:r+o*(S-.35),x2:s+a*(S+.35),y2:r+o*(S+.35)})}m=_}p+=c}return d}static renderFamily(e,t){const i=we.toRadians(e.angle),s=Math.cos(i),r=Math.sin(i),a=-r,o=s,h=s*e.deltaX+a*e.deltaY,c=r*e.deltaX+o*e.deltaY,d=Math.hypot(h,c),u=d<=we.EPSILON?1:Math.max(1,Math.ceil(t*2/d)+1),p=Math.floor(u/2),g=-t*1.5,m=t*1.5,y=[];for(let x=-p;x<=p;x++){const _=e.originX+h*x,S=e.originY+c*x,L=we.buildDashSegments(e,g,m,_,S,s,r);for(const T of L)y.push(we.segmentToSvgPath(T))}return`<path d="${y.join(" ")}" fill="none" />`}renderPattern(e,t={}){const i=t.width??260,s=t.height??160,r=t.stroke??"#1f2937",a=t.strokeWidth??1.3,o=t.background??"#ffffff",h=we.estimateUnitScale(e),d=Math.min(i,s)*.18/Math.max(h,we.EPSILON),u={...e,lines:e.lines.map(y=>({...y,originX:y.originX*d,originY:y.originY*d,deltaX:y.deltaX*d,deltaY:y.deltaY*d,dashes:y.dashes.map(x=>x*d)}))},p=Math.hypot(i,s)*.75,g=u.lines.map(y=>we.renderFamily(y,p)).join("");return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${`${-i/2} ${-s/2} ${i} ${s}`}" width="${i}" height="${s}">`,`<rect x="${-i/2}" y="${-s/2}" width="${i}" height="${s}" fill="${o}" />`,`<g stroke="${r}" stroke-width="${a.toFixed(2)}" stroke-linecap="round">`,g,"</g>","</svg>"].join("")}};we.EPSILON=1e-9;let Ks=we;class mt extends Be{constructor(e){super(),this.database=e,this.objectId=e.generateHandle(),this.ownerId=e.objectId,this._recordsByName=new Map,this._recordsById=new Map}get numEntries(){return this._recordsByName.size}add(e){e.database=this.database,e.ownerId=this.objectId,this.database.commitObjectHandle(e,i=>this.hasId(i));const t=this.normalizeName(e.name);this._recordsByName.set(t,e),this._recordsById.set(e.objectId,e)}remove(e){const t=this.normalizeName(e),i=this._recordsByName.get(t);return i?(this._recordsById.delete(i.objectId),this._recordsByName.delete(t),!0):!1}removeId(e){const t=this._recordsById.get(e);return t?(this._recordsByName.delete(this.normalizeName(t.name)),this._recordsById.delete(e),!0):!1}removeAll(){this._recordsByName.clear(),this._recordsById.clear()}has(e){const t=this.normalizeName(e);return this._recordsByName.has(t)}hasId(e){return this._recordsById.has(e)}getAt(e){const t=this.normalizeName(e);return this._recordsByName.get(t)}getIdAt(e){return this._recordsById.get(e)}getOwnerIdAt(e){return this._recordsById.get(e)}newIterator(){return new an(this._recordsByName)}normalizeName(e){return e}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbSymbolTable"),e.writeInt16(70,this.numEntries),this}}class bl extends mt{constructor(e){super(e)}get modelSpace(){let e=this.getAt(Q.MODEL_SPACE_NAME);return e||(e=new Q,e.name=Q.MODEL_SPACE_NAME,this.add(e)),e}getEntityById(e){for(const t of this.database.tables.blockTable.newIterator()){const i=t.getIdAt(e);if(i)return i}}removeEntity(e){let t=!1;for(const i of this.database.tables.blockTable.newIterator())if(i.removeEntity(e)){t=!0;break}return t}normalizeName(e){let t=e;if(Q.isModelSapceName(e))t=Q.MODEL_SPACE_NAME;else if(Q.isPaperSapceName(e)){const i=Q.PAPER_SPACE_NAME_PREFIX,s=e.substring(i.length);t=i+s}return t}}class Ll extends mt{constructor(e){super(e)}}var Sl=(n=>(n[n.Center=0]="Center",n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.OverFirst=3]="OverFirst",n[n.OverSecond=4]="OverSecond",n))(Sl||{}),Il=(n=>(n[n.Center=0]="Center",n[n.Above=1]="Above",n[n.Outside=2]="Outside",n[n.JIS=3]="JIS",n[n.Below=4]="Below",n))(Il||{}),Al=(n=>(n[n.Feet=0]="Feet",n[n.None=1]="None",n[n.Inch=2]="Inch",n[n.FeetAndInch=3]="FeetAndInch",n[n.Leading=4]="Leading",n[n.Trailing=8]="Trailing",n[n.LeadingAndTrailing=12]="LeadingAndTrailing",n))(Al||{}),Pl=(n=>(n[n.None=0]="None",n[n.Leading=1]="Leading",n[n.Trailing=2]="Trailing",n[n.LeadingAndTrailing=3]="LeadingAndTrailing",n))(Pl||{}),El=(n=>(n[n.Bottom=0]="Bottom",n[n.Middle=1]="Middle",n[n.Top=2]="Top",n))(El||{});const us=class us extends kt{constructor(e,t){e=e||{},Qi(e,us.DEFAULT_DIM_VALUES),super(e,t)}get dimpost(){return this.getAttr("dimpost")}set dimpost(e){this.setAttr("dimpost",e)}get dimapost(){return this.getAttr("dimapost")}set dimapost(e){this.setAttr("dimapost",e)}get dimscale(){return this.getAttr("dimscale")}set dimscale(e){this.setAttr("dimscale",e)}get dimasz(){return this.getAttr("dimasz")}set dimasz(e){this.setAttr("dimasz",e)}get dimexo(){return this.getAttr("dimexo")}set dimexo(e){this.setAttr("dimexo",e)}get dimdli(){return this.getAttr("dimdli")}set dimdli(e){this.setAttr("dimdli",e)}get dimexe(){return this.getAttr("dimexe")}set dimexe(e){this.setAttr("dimexe",e)}get dimrnd(){return this.getAttr("dimrnd")}set dimrnd(e){this.setAttr("dimrnd",e)}get dimdle(){return this.getAttr("dimdle")}set dimdle(e){this.setAttr("dimdle",e)}get dimtp(){return this.getAttr("dimtp")}set dimtp(e){this.setAttr("dimtp",e)}get dimtm(){return this.getAttr("dimtm")}set dimtm(e){this.setAttr("dimtm",e)}get dimtxt(){return this.getAttr("dimtxt")}set dimtxt(e){this.setAttr("dimtxt",e)}get dimcen(){return this.getAttr("dimcen")}set dimcen(e){this.setAttr("dimcen",e)}get dimtsz(){return this.getAttr("dimtsz")}set dimtsz(e){this.setAttr("dimtsz",e)}get dimaltf(){return this.getAttr("dimaltf")}set dimaltf(e){this.setAttr("dimaltf",e)}get dimlfac(){return this.getAttr("dimlfac")}set dimlfac(e){this.setAttr("dimlfac",e)}get dimtvp(){return this.getAttr("dimtvp")}set dimtvp(e){this.setAttr("dimtvp",e)}get dimtfac(){return this.getAttr("dimtfac")}set dimtfac(e){this.setAttr("dimtfac",e)}get dimgap(){return this.getAttr("dimgap")}set dimgap(e){this.setAttr("dimgap",e)}get dimaltrnd(){return this.getAttr("dimaltrnd")}set dimaltrnd(e){this.setAttr("dimaltrnd",e)}get dimtol(){return this.getAttr("dimtol")}set dimtol(e){this.setAttr("dimtol",e)}get dimlim(){return this.getAttr("dimlim")}set dimlim(e){this.setAttr("dimlim",e)}get dimtih(){return this.getAttr("dimtih")}set dimtih(e){this.setAttr("dimtih",e)}get dimtoh(){return this.getAttr("dimtoh")}set dimtoh(e){this.setAttr("dimtoh",e)}get dimse1(){return this.getAttr("dimse1")}set dimse1(e){this.setAttr("dimse1",e)}get dimse2(){return this.getAttr("dimse2")}set dimse2(e){this.setAttr("dimse2",e)}get dimtad(){return this.getAttr("dimtad")}set dimtad(e){this.setAttr("dimtad",e)}get dimzin(){return this.getAttr("dimzin")}set dimzin(e){this.setAttr("dimzin",e)}get dimazin(){return this.getAttr("dimazin")}set dimazin(e){this.setAttr("dimazin",e)}get dimalt(){return this.getAttr("dimalt")}set dimalt(e){this.setAttr("dimalt",e)}get dimaltd(){return this.getAttr("dimaltd")}set dimaltd(e){this.setAttr("dimaltd",e)}get dimtofl(){return this.getAttr("dimtofl")}set dimtofl(e){this.setAttr("dimtofl",e)}get dimsah(){return this.getAttr("dimsah")}set dimsah(e){this.setAttr("dimsah",e)}get dimtix(){return this.getAttr("dimtix")}set dimtix(e){this.setAttr("dimtix",e)}get dimsoxd(){return this.getAttr("dimsoxd")}set dimsoxd(e){this.setAttr("dimsoxd",e)}get dimclrd(){return this.getAttr("dimclrd")}set dimclrd(e){this.setAttr("dimclrd",e)}get dimclre(){return this.getAttr("dimclre")}set dimclre(e){this.setAttr("dimclre",e)}get dimclrt(){return this.getAttr("dimclrt")}set dimclrt(e){this.setAttr("dimclrt",e)}get dimadec(){return this.getAttr("dimadec")}set dimadec(e){this.setAttr("dimadec",e)}get dimunit(){return this.getAttr("dimunit")}set dimunit(e){this.setAttr("dimunit",e)}get dimdec(){return this.getAttr("dimdec")}set dimdec(e){this.setAttr("dimdec",e)}get dimtdec(){return this.getAttr("dimtdec")}set dimtdec(e){this.setAttr("dimtdec",e)}get dimaltu(){return this.getAttr("dimaltu")}set dimaltu(e){this.setAttr("dimaltu",e)}get dimalttd(){return this.getAttr("dimalttd")}set dimalttd(e){this.setAttr("dimalttd",e)}get dimaunit(){return this.getAttr("dimaunit")}set dimaunit(e){this.setAttr("dimaunit",e)}get dimfrac(){return this.getAttr("dimfrac")}set dimfrac(e){this.setAttr("dimfrac",e)}get dimlunit(){return this.getAttr("dimlunit")}set dimlunit(e){this.setAttr("dimlunit",e)}get dimdsep(){return this.getAttr("dimdsep")}set dimdsep(e){this.setAttr("dimdsep",e)}get dimtmove(){return this.getAttr("dimtmove")}set dimtmove(e){this.setAttr("dimtmove",e)}get dimjust(){return this.getAttr("dimjust")}set dimjust(e){this.setAttr("dimjust",e)}get dimsd1(){return this.getAttr("dimsd1")}set dimsd1(e){this.setAttr("dimsd1",e)}get dimsd2(){return this.getAttr("dimsd2")}set dimsd2(e){this.setAttr("dimsd2",e)}get dimtolj(){return this.getAttr("dimtolj")}set dimtolj(e){this.setAttr("dimtolj",e)}get dimtzin(){return this.getAttr("dimtzin")}set dimtzin(e){this.setAttr("dimtzin",e)}get dimaltz(){return this.getAttr("dimaltz")}set dimaltz(e){this.setAttr("dimaltz",e)}get dimalttz(){return this.getAttr("dimalttz")}set dimalttz(e){this.setAttr("dimalttz",e)}get dimfit(){return this.getAttr("dimfit")}set dimfit(e){this.setAttr("dimfit",e)}get dimupt(){return this.getAttr("dimupt")}set dimupt(e){this.setAttr("dimupt",e)}get dimatfit(){return this.getAttr("dimatfit")}set dimatfit(e){this.setAttr("dimatfit",e)}get dimtxsty(){return this.getAttr("dimtxsty")}set dimtxsty(e){this.setAttr("dimtxsty",e)}get dimldrblk(){return this.getAttr("dimldrblk")}set dimldrblk(e){this.setAttr("dimldrblk",e)}get dimblk(){return this.getAttr("dimblk")}set dimblk(e){this.setAttr("dimblk",e)}get dimblk1(){return this.getAttr("dimblk1")}set dimblk1(e){this.setAttr("dimblk1",e)}get dimblk2(){return this.getAttr("dimblk2")}set dimblk2(e){this.setAttr("dimblk2",e)}get dimlwd(){return this.getAttr("dimlwd")}set dimlwd(e){this.setAttr("dimlwd",e)}get dimlwe(){return this.getAttr("dimlwe")}set dimlwe(e){this.setAttr("dimlwe",e)}dxfOutFields(e){super.dxfOutFields(e);const t=this.database.tables.textStyleTable.getAt(this.dimtxsty),i=this.database.tables.blockTable.getAt(this.dimldrblk),s=this.database.tables.blockTable.getAt(this.dimblk),r=this.database.tables.blockTable.getAt(this.dimblk1),a=this.database.tables.blockTable.getAt(this.dimblk2);return e.writeSubclassMarker("AcDbDimStyleTableRecord"),e.writeString(2,this.name),e.writeInt16(70,0),e.writeString(3,this.dimpost),e.writeString(4,this.dimapost),e.writeDouble(40,this.dimscale),e.writeDouble(41,this.dimasz),e.writeDouble(42,this.dimexo),e.writeDouble(43,this.dimdli),e.writeDouble(44,this.dimexe),e.writeDouble(140,this.dimtxt),e.writeDouble(147,this.dimgap),e.writeInt16(170,this.dimalt),e.writeInt16(171,this.dimtol),e.writeInt16(172,this.dimlim),e.writeInt16(173,this.dimtih),e.writeInt16(174,this.dimtoh),e.writeObjectId(340,t==null?void 0:t.objectId),e.writeObjectId(341,i==null?void 0:i.objectId),e.writeObjectId(342,s==null?void 0:s.objectId),e.writeObjectId(343,r==null?void 0:r.objectId),e.writeObjectId(344,a==null?void 0:a.objectId),e.writeInt16(371,this.dimlwd),e.writeInt16(372,this.dimlwe),this}};us.DEFAULT_DIM_VALUES={name:"",dimpost:"",dimapost:"",dimscale:1,dimasz:2.5,dimexo:.625,dimdli:.38,dimexe:.18,dimrnd:0,dimdle:0,dimtp:0,dimtm:0,dimtxt:2.5,dimcen:2.5,dimtsz:0,dimaltf:0,dimlfac:1,dimtvp:0,dimtfac:1,dimgap:1,dimaltrnd:0,dimtol:0,dimlim:0,dimtih:0,dimtoh:0,dimse1:0,dimse2:0,dimtad:0,dimzin:0,dimazin:0,dimalt:0,dimaltd:2,dimtofl:0,dimsah:0,dimtix:0,dimsoxd:0,dimclrd:0,dimclre:0,dimclrt:0,dimadec:0,dimunit:2,dimdec:4,dimtdec:4,dimaltu:2,dimalttd:2,dimaunit:0,dimfrac:0,dimlunit:2,dimdsep:".",dimtmove:0,dimjust:0,dimsd1:0,dimsd2:0,dimtolj:0,dimtzin:0,dimaltz:0,dimalttz:0,dimfit:0,dimupt:0,dimatfit:3,dimtxsty:Z,dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let ti=us;class Tl extends mt{constructor(e){super(e)}add(e){super.add(e),this.database.events.layerAppended.dispatch({database:this.database,layer:e})}}class ys extends kt{constructor(e,t){e=e||{},Qi(e,{color:new z,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:new ps,linetype:"",lineWeight:1,materialId:-1}),super(e,t),this.attrs.events.attrChanged.addEventListener(i=>{this.database.events.layerModified.dispatch({database:this.database,layer:this,changes:i.object.changedAttributes()})})}get color(){return this.getAttr("color")}set color(e){this.setAttr("color",e.clone())}get description(){return this.getAttr("description")}set description(e){this.setAttr("description",e)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(e){this.setAttr("standardFlags",e)}get isFrozen(){return(this.standardFlags&1)==1}set isFrozen(e){const t=e?1:0;this.standardFlags=this.standardFlags|t}get isHidden(){return this.getAttr("isHidden")}set isHidden(e){this.setAttr("isHidden",e)}get isInUse(){return this.getAttr("isInUse")}set isInUse(e){this.setAttr("isInUse",e)}get isLocked(){return(this.standardFlags&4)==4}set isLocked(e){const t=e?4:0;this.standardFlags=this.standardFlags|t}get isOff(){return this.getAttr("isOff")}set isOff(e){this.setAttr("isOff",e)}get isPlottable(){return this.getAttr("isPlottable")}set isPlottable(e){this.setAttr("isPlottable",e)}get transparency(){return this.getAttr("transparency")}set transparency(e){this.setAttr("transparency",e.clone())}get linetype(){return this.getAttr("linetype")}set linetype(e){this.setAttr("linetype",e)}get lineStyle(){var t;const e=(t=this.database)==null?void 0:t.tables.linetypeTable.getAt(this.linetype);if(e)return{type:"UserSpecified",...e.linetype}}get lineWeight(){return this.getAttr("lineWeight")}set lineWeight(e){this.setAttr("lineWeight",e)}get materialId(){return this.getAttr("materialId")}set materialId(e){this.setAttr("materialId",e)}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbLayerTableRecord"),e.writeString(2,this.name),e.writeInt16(70,this.standardFlags),e.writeCmColor(this.color),e.writeString(6,this.linetype),e.writeInt16(290,this.isPlottable?1:0),e.writeInt16(370,this.lineWeight),e.writeTransparency(this.transparency),this.description&&e.writeString(4,this.description),this}}class Ml extends mt{constructor(e){super(e)}}class At extends kt{constructor(e){super(),this.name=e.name,this._linetype=e}get numDashes(){return this._linetype.pattern?this._linetype.pattern.length:0}get patternLength(){return this._linetype.totalPatternLength}get comments(){return this._linetype.description}get linetype(){return this._linetype}dashLengthAt(e){if(e<0||e>=this.numDashes)throw new Error('Index must be greater than or equal to zero, but less than the value of property "numDashes".');return this._linetype.pattern[e].elementLength}toPreviewSvgString(e){const t=Math.max((e==null?void 0:e.width)??220,1),i=Math.max((e==null?void 0:e.height)??36,1),s=Math.min(Math.max((e==null?void 0:e.padding)??8,0),Math.floor(t/2)),r=Math.max((e==null?void 0:e.strokeWidth)??2,.5),a=this.escapeSvgAttribute((e==null?void 0:e.stroke)??"currentColor"),o=Math.max((e==null?void 0:e.repeats)??4,1),h=i/2,c=s,d=Math.max(t-s,c+1),u=d-c,p=this._linetype.pattern??[];if(p.length===0||this.patternLength<=0||!p.some(L=>L.elementLength!==0))return this.buildSvgString({width:t,height:i,stroke:a,strokeWidth:r,lineSegments:[[c,d]],dots:[],y:h});const g=[],m=[],y=u/(this.patternLength*o),x=.5,_=Math.max(r*2,2);let S=c;for(;S<d;)for(const L of p){if(S>=d)break;const T=L.elementLength;if(T===0){m.push(S),S=Math.min(S+_,d);continue}const I=Math.max(Math.abs(T)*y,x),j=Math.min(S+I,d);T>0&&j>S&&g.push([S,j]),S=j}return this.buildSvgString({width:t,height:i,stroke:a,strokeWidth:r,lineSegments:g,dots:m,y:h})}buildSvgString(e){const{width:t,height:i,stroke:s,strokeWidth:r,lineSegments:a,dots:o,y:h}=e,c=a.map(([u,p])=>`<line x1="${u.toFixed(2)}" y1="${h.toFixed(2)}" x2="${p.toFixed(2)}" y2="${h.toFixed(2)}" stroke="${s}" stroke-width="${r.toFixed(2)}" stroke-linecap="round" />`).join(""),d=o.map(u=>`<circle cx="${u.toFixed(2)}" cy="${h.toFixed(2)}" r="${(r/2).toFixed(2)}" fill="${s}" />`).join("");return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${i}" viewBox="0 0 ${t} ${i}" role="img" aria-label="${this.escapeSvgAttribute(this.name)} linetype preview">${c}${d}</svg>`}escapeSvgAttribute(e){return e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;")}dxfOutFields(e){super.dxfOutFields(e),e.writeSubclassMarker("AcDbLinetypeTableRecord"),e.writeString(2,this.name),e.writeInt16(70,this.linetype.standardFlag),e.writeString(3,this.comments),e.writeInt16(72,65),e.writeInt16(73,this.numDashes),e.writeDouble(40,this.patternLength);for(const t of this.linetype.pattern??[])e.writeDouble(49,t.elementLength),e.writeInt16(74,t.elementTypeFlag);return this}}class kl extends mt{constructor(e){super(e)}get fonts(){const e=new Set,t=s=>{if(s){const r=s.lastIndexOf(".");if(r>=0){const a=s.substring(0,r).toLowerCase();e.add(a)}else e.add(s.toLowerCase())}},i=this.newIterator();for(const s of i)t(s.fileName),t(s.bigFontFileName);return Array.from(e)}}class _s extends kt{constructor(e){super(),this.name=e.name,this._textStyle=e,this._textStyle.font=this.getFileNameWithoutExtension(this._textStyle.font||this._textStyle.extendedFont||this.name),this._isVertical=!1}get obliquingAngle(){return this._textStyle.obliqueAngle}set obliquingAngle(e){this._textStyle.obliqueAngle=e}get priorSize(){return this._textStyle.lastHeight}set priorSize(e){this._textStyle.lastHeight=e}get textSize(){return this._textStyle.fixedTextHeight}set textSize(e){this._textStyle.fixedTextHeight=e}get xScale(){return this._textStyle.widthFactor}set xScale(e){this._textStyle.widthFactor=e}get isVertical(){return this._isVertical}set isVertical(e){this._isVertical=e}get fileName(){return this._textStyle.font}set fileName(e){this._textStyle.font=e}get bigFontFileName(){return this._textStyle.bigFont}set bigFontFileName(e){this._textStyle.bigFont=e}get textStyle(){return this._textStyle}getFileNameWithoutExtension(e){const t=e.split("/").pop();if(t){const i=t.lastIndexOf(".");return i===-1?t:t.substring(0,i)}return e}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbTextStyleTableRecord"),e.writeString(2,this.name),e.writeInt16(70,this.textStyle.standardFlag),e.writeDouble(40,this.textSize),e.writeDouble(41,this.xScale),e.writeAngle(50,this.obliquingAngle),e.writeInt16(71,this.isVertical?4:this.textStyle.textGenerationFlag),e.writeDouble(42,this.priorSize),e.writeString(3,this.fileName),e.writeString(4,this.bigFontFileName),this}}class vl extends mt{constructor(e){super(e)}}class Cl extends mt{constructor(e){super(e)}}const Jc=()=>({center:new v,viewDirectionFromTarget:new f(0,0,1),viewTarget:new f(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:wr.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new f(0,0,0),ucsXAxis:new f(1,0,0),ucsYAxis:new f(0,1,0),orthographicType:fr.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:br.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0});class kr extends kt{constructor(){super(),this._gsView=Jc(),this._centerPoint=this._gsView.center}get gsView(){return this._gsView}get centerPoint(){return this._centerPoint}set centerPoint(e){this._centerPoint.copy(e)}get viewDirectionFromTarget(){return this._gsView.viewDirectionFromTarget}set viewDirectionFromTarget(e){this._gsView.viewDirectionFromTarget.copy(e)}get viewTarget(){return this._gsView.viewTarget}set viewTarget(e){this._gsView.viewTarget.copy(e)}get viewHeight(){return this._gsView.viewHeight}set viewHeight(e){this._gsView.viewHeight=e}get viewTwistAngle(){return this._gsView.viewTwistAngle}set viewTwistAngle(e){this._gsView.viewTwistAngle=e}get lensLength(){return this._gsView.lensLength}set lensLength(e){this._gsView.lensLength=e}get frontClippingPlane(){return this._gsView.frontClippingPlane}set frontClippingPlane(e){this._gsView.frontClippingPlane=e}get backClippingPlane(){return this._gsView.backClippingPlane}set backClippingPlane(e){this._gsView.backClippingPlane=e}get renderMode(){return this._gsView.renderMode}set renderMode(e){this._gsView.renderMode=e}get viewMode(){return this._gsView.viewMode}set viewMode(e){this._gsView.viewMode=e}get ucsIconSetting(){return this._gsView.ucsIconSetting}set ucsIconSetting(e){this._gsView.ucsIconSetting=e}get ucsOrigin(){return this._gsView.ucsOrigin}set ucsOrigin(e){this._gsView.ucsOrigin.copy(e)}get ucsXAxis(){return this._gsView.ucsXAxis}set ucsXAxis(e){this._gsView.ucsXAxis.copy(e)}get ucsYAxis(){return this._gsView.ucsYAxis}set ucsYAxis(e){this._gsView.ucsYAxis.copy(e)}get orthographicType(){return this._gsView.orthographicType}set orthographicType(e){this._gsView.orthographicType=e}get shadePlotSetting(){return this._gsView.shadePlotSetting}set shadePlotSetting(e){this._gsView.shadePlotSetting=e}get shadePlotObjectId(){return this._gsView.shadePlotObjectId}set shadePlotObjectId(e){this._gsView.shadePlotObjectId=e}get visualStyleObjectId(){return this._gsView.visualStyleObjectId}set visualStyleObjectId(e){this._gsView.visualStyleObjectId=e}get isDefaultLightingOn(){return this._gsView.isDefaultLightingOn}set isDefaultLightingOn(e){this._gsView.isDefaultLightingOn=e}get defaultLightingType(){return this._gsView.defaultLightingType}set defaultLightingType(e){this._gsView.defaultLightingType=e}get brightness(){return this._gsView.brightness}set brightness(e){this._gsView.brightness=e}get contrast(){return this._gsView.contrast}set contrast(e){this._gsView.contrast=e}get ambientColor(){return this._gsView.ambientColor}set ambientColor(e){this._gsView.ambientColor=e}}class vr extends kr{constructor(){super(),this._circleSides=100,this._lowerLeftCorner=new v(0,0),this._upperRightCorner=new v(1,1),this._snapBase=new v(0,0),this._snapAngle=0,this._snapSpacing=new v(0,0),this._standardFlag=0,this._gridSpacing=new v,this._gridMajor=10}get circleSides(){return this._circleSides}set circleSides(e){this._circleSides=e}get center(){return this.centerPoint}set center(e){this.centerPoint=e}get lowerLeftCorner(){return this._lowerLeftCorner}set lowerLeftCorner(e){this._lowerLeftCorner.copy(e)}get upperRightCorner(){return this._upperRightCorner}set upperRightCorner(e){this._upperRightCorner.copy(e)}get snapBase(){return this._snapBase}set snapBase(e){this._snapBase.copy(e)}get snapAngle(){return this._snapAngle}set snapAngle(e){this._snapAngle=e}get snapIncrements(){return this._snapSpacing}set snapIncrements(e){this._snapSpacing.copy(e)}get gridMajor(){return this._gridMajor}set gridMajor(e){this._gridMajor=e}get gridIncrements(){return this._gridSpacing}set gridIncrements(e){this._gridSpacing.copy(e)}get standardFlag(){return this._standardFlag}set standardFlag(e){this._standardFlag=e}get snapEnabled(){return!!(this._standardFlag&256)}get backgroundObjectId(){return this._backgroundObjectId}set backgroundObjectId(e){this._backgroundObjectId=e}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbViewportTableRecord"),e.writeString(2,this.name),e.writeDouble(45,this.gsView.viewHeight),e.writePoint2d(10,this.lowerLeftCorner),e.writePoint2d(11,this.upperRightCorner),e.writePoint2d(12,this.center),e.writePoint2d(13,this.snapBase),e.writePoint2d(14,this.snapIncrements),e.writePoint2d(15,this.gridIncrements),e.writeInt16(70,this.standardFlag),e.writeInt16(71,this.circleSides),e.writeDouble(42,this.gsView.lensLength),e.writePoint3d(16,this.gsView.viewDirectionFromTarget),e.writePoint3d(17,this.gsView.viewTarget),e.writeAngle(50,this.snapAngle),e.writeAngle(51,this.gsView.viewTwistAngle),e.writeInt16(61,this.gridMajor),e.writeInt16(281,this.backgroundObjectId?1:0),e.writeObjectId(332,this.backgroundObjectId),this}}class Ol extends mt{constructor(e){super(e)}}class Js extends kt{constructor(e){super(),this.name=e}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbRegAppTableRecord"),e.writeString(2,this.name),e.writeInt16(70,0),this}}const Y={ACADVER:"ACADVER",ANGBASE:"ANGBASE",ANGDIR:"ANGDIR",AUNITS:"AUNITS",CECOLOR:"CECOLOR",CELTYPE:"CELTYPE",CELTSCALE:"CELTSCALE",CELWEIGHT:"CELWEIGHT",CLAYER:"CLAYER",CMLSTYLE:"CMLSTYLE",CMLSCALE:"CMLSCALE",CMLEADERSTYLE:"CMLEADERSTYLE",COLORTHEME:"COLORTHEME",DYNMODE:"DYNMODE",DYNPROMPT:"DYNPROMPT",EXTMAX:"EXTMAX",EXTMIN:"EXTMIN",INSUNITS:"INSUNITS",LTSCALE:"LTSCALE",LWDISPLAY:"LWDISPLAY",MEASUREMENTCOLOR:"MEASUREMENTCOLOR",OSMODE:"OSMODE",PDMODE:"PDMODE",PDSIZE:"PDSIZE",PICKBOX:"PICKBOX",SHORTCUTMENU:"SHORTCUTMENU",TEXTSTYLE:"TEXTSTYLE",WHITEBKCOLOR:"WHITEBKCOLOR"},Qc=Object.freeze(Object.values(Y)),gs=class gs{constructor(){this.registry=new Map,this.cache=new Map,this.events={sysVarChanged:new J},this.registerVar({name:Y.CECOLOR,type:"color",isDbVar:!0,defaultValue:new z(A.ByLayer)}),this.registerVar({name:Y.CELTSCALE,type:"number",isDbVar:!0,defaultValue:-1}),this.registerVar({name:Y.CELTYPE,type:"string",isDbVar:!0,defaultValue:de}),this.registerVar({name:Y.CELWEIGHT,type:"number",isDbVar:!0,defaultValue:Qt.ByLayer}),this.registerVar({name:Y.CLAYER,type:"string",isDbVar:!0,defaultValue:"0"}),this.registerVar({name:Y.CMLSTYLE,type:"string",isDbVar:!0,defaultValue:dt}),this.registerVar({name:Y.CMLSCALE,type:"number",isDbVar:!0,defaultValue:1}),this.registerVar({name:Y.CMLEADERSTYLE,type:"string",isDbVar:!0,defaultValue:ut}),this.registerVar({name:Y.COLORTHEME,type:"number",isDbVar:!1,defaultValue:"0"}),this.registerVar({name:Y.DYNMODE,type:"number",isDbVar:!1,defaultValue:3}),this.registerVar({name:Y.DYNPROMPT,type:"boolean",isDbVar:!1,defaultValue:!0}),this.registerVar({name:Y.LWDISPLAY,type:"boolean",isDbVar:!0,defaultValue:!1}),this.registerVar({name:Y.MEASUREMENTCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const e=new z(A.ByColor);return e.setRGB(96,165,250),e})()}),this.registerVar({name:Y.OSMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:Y.PICKBOX,type:"number",isDbVar:!1,defaultValue:10}),this.registerVar({name:Y.SHORTCUTMENU,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:Y.TEXTSTYLE,type:"string",isDbVar:!0,defaultValue:Z}),this.registerVar({name:Y.WHITEBKCOLOR,type:"boolean",isDbVar:!1,defaultValue:!1})}static instance(){return this._instance||(this._instance=new gs),this._instance}registerVar(e){const t=this.normalizeName(e.name);this.registry.set(t,{...e,name:t}),e.isDbVar||this.cache.set(t,e.defaultValue)}registerMany(e){e.forEach(t=>this.registerVar(t))}getVar(e,t){e=this.normalizeName(e);const i=this.getDescriptor(e);if(!i)throw new Error(`System variable ${e} not found!`);if(i.isDbVar)return t[e.toLowerCase()];if(this.cache.has(e))return this.cache.get(e)}getDefaultValue(e){e=this.normalizeName(e);const t=this.getDescriptor(e);if(!t)throw new Error(`System variable ${e} not found!`);return t.defaultValue}setVar(e,t,i){e=this.normalizeName(e);const s=this.getDescriptor(e);if(s){const r=this.getVar(e,i);if(s.type!=="string"&&(typeof t=="string"||t instanceof String)){if(s.type==="number"){const a=Number(t);if(Number.isNaN(a))throw new Error("Invalid number input!");t=a}else if(s.type==="boolean")t=this.parseBoolean(t);else if(s.type==="color"){const a=z.fromString(t);if(a==null)throw new Error("Invalid color value!");t=a}}s.isDbVar?i[e.toLowerCase()]=t:(this.cache.set(e,t),this.hasValueChanged(r,t)&&this.events.sysVarChanged.dispatch({database:i,name:e,newVal:t,oldVal:r}))}else throw new Error(`System variable ${e} not found!`)}getDescriptor(e){return this.registry.get(this.normalizeName(e))}getAllDescriptors(){return[...this.registry.values()]}parseBoolean(e){if(e==null)return!1;const t=String(e).trim().toLowerCase(),i=new Set(["true","t","1","yes","y"]),s=new Set(["false","f","0","no","n"]);return i.has(t)?!0:(s.has(t),!1)}hasValueChanged(e,t){return e instanceof z&&t instanceof z?!e.equals(t):!Object.is(e,t)}normalizeName(e){return e.toLowerCase()}};gs._instance=null;let Ji=gs;class ed extends Be{constructor(){super({objectId:"0"}),this.events={dictObjetSet:new J,dictObjectErased:new J,entityAppended:new J,entityModified:new J,entityErased:new J,layerAppended:new J,layerModified:new J,layerErased:new J,openProgress:new J},this._version=new ve("AC1014"),this._angBase=0,this._angDir=0,this._aunits=rr.DecimalDegrees,this._celtscale=1,this._cecolor=new z,this._celtype=de,this._celweight=Qt.ByLayer,this._clayer="0",this._cmlstyle=dt,this._cmlscale=1,this._cmleaderstyle=ut,this._textstyle=Z,this._extents=new N,this._insunits=Tr.Millimeters,this._ltscale=1,this._lwdisplay=!1,this._pdmode=0,this._pdsize=0,this._osmode=0,this._maxHandle=0,this._tables={appIdTable:new Ol(this),blockTable:new bl(this),dimStyleTable:new Ll(this),linetypeTable:new Ml(this),textStyleTable:new kl(this),viewTable:new vl(this),layerTable:new Tl(this),viewportTable:new Cl(this)},this._objects={dictionary:new Kt(this),imageDefinition:new Kt(this),layout:new gl(this),mleaderStyle:new Kt(this),mlineStyle:new Kt(this),xrecord:new Kt(this)}}get tables(){return this._tables}get objects(){return this._objects}generateHandle(){return this._maxHandle++,this._maxHandle.toString(16).toUpperCase()}updateMaxHandle(e){const t=parseInt(e,16);!isNaN(t)&&t>this._maxHandle&&(this._maxHandle=t)}commitObjectHandle(e,t){const i=e.getAttrWithoutException("objectId");!i||e.isTemp||t&&t(i)?e.objectId=this.generateHandle():this.updateMaxHandle(i)}get currentSpaceId(){return this._currentSpace||(this._currentSpace=this._tables.blockTable.modelSpace),this._currentSpace.objectId}set currentSpaceId(e){const t=this.tables.blockTable.getIdAt(e);if(t==null)throw new Error(`[AcDbDatabase] The specified block table record id '${e}' doesn't exist in the drawing database!`);this._currentSpace=t}get aunits(){return this._aunits}set aunits(e){this.updateSysVar(Y.AUNITS,this._aunits,e??0,t=>{this._aunits=t})}get version(){return this._version}set version(e){this.updateSysVar(Y.ACADVER,this._version,new ve(e),t=>{this._version=t})}get insunits(){return this._insunits}set insunits(e){this.updateSysVar(Y.INSUNITS,this._insunits,e??4,t=>{this._insunits=t})}get ltscale(){return this._ltscale}set ltscale(e){this.updateSysVar(Y.LTSCALE,this._ltscale,e??1,t=>{this._ltscale=t})}get lwdisplay(){return this._lwdisplay}set lwdisplay(e){this.updateSysVar(Y.LWDISPLAY,this._lwdisplay,e??!1,t=>{this._lwdisplay=t})}get cecolor(){return this._cecolor}set cecolor(e){this.updateSysVar(Y.CECOLOR,this._cecolor,e||0,t=>{this._cecolor=t.clone()})}get celtscale(){return this._celtscale}set celtscale(e){this.updateSysVar(Y.CELTSCALE,this._celtscale,e??1,t=>{this._celtscale=t})}get celtype(){return this._celtype}set celtype(e){const t=this.normalizeLinetypeName(e??de);this.updateSysVar(Y.CELTYPE,this._celtype,t,i=>{this._celtype=i})}get celweight(){return this._celweight}set celweight(e){this.updateSysVar(Y.CELWEIGHT,this._celweight,e??Qt.ByLayer,t=>{this._celweight=t})}get clayer(){return this._clayer}set clayer(e){this.updateSysVar(Y.CLAYER,this._clayer,e??"0",t=>{this._clayer=t})}get cmlstyle(){return this._cmlstyle}set cmlstyle(e){this.updateSysVar(Y.CMLSTYLE,this._cmlstyle,e??dt,t=>{this._cmlstyle=t})}get cmlscale(){return this._cmlscale}set cmlscale(e){this.updateSysVar(Y.CMLSCALE,this._cmlscale,e??1,t=>{this._cmlscale=t})}get cmleaderstyle(){return this._cmleaderstyle}set cmleaderstyle(e){this.updateSysVar(Y.CMLEADERSTYLE,this._cmleaderstyle,e??ut,t=>{this._cmleaderstyle=t})}get textstyle(){return this._textstyle}set textstyle(e){this.updateSysVar(Y.TEXTSTYLE,this._textstyle,e??Z,t=>{this._textstyle=t})}get angBase(){return this._angBase}set angBase(e){this.updateSysVar(Y.ANGBASE,this._angBase,e??0,t=>{this._angBase=t})}get angDir(){return this._angDir}set angDir(e){this.updateSysVar(Y.ANGDIR,this._angDir,e??0,t=>{this._angDir=t})}get extmax(){return this._extents.max}set extmax(e){if(e){const t=this._extents.max.clone();this._extents.expandByPoint(e),this._extents.max.equals(t)||this.triggerSysVarChangedEvent(Y.EXTMAX,t,this._extents.max)}}get extmin(){return this._extents.min}set extmin(e){if(e){const t=this._extents.min.clone();this._extents.expandByPoint(e),this._extents.min.equals(t)||this.triggerSysVarChangedEvent(Y.EXTMIN,t,this._extents.min)}}get extents(){return this._extents}get pdmode(){return this._pdmode}set pdmode(e){this.updateSysVar(Y.PDMODE,this._pdmode,e??0,t=>{this._pdmode=t})}get pdsize(){return this._pdsize}set pdsize(e){this.updateSysVar(Y.PDSIZE,this._pdsize,e??0,t=>{this._pdsize=t})}get osmode(){return this._osmode}set osmode(e){this.updateSysVar(Y.OSMODE,this._osmode,e??0,t=>{this._osmode=t})}async read(e,t,i=Ni.DXF){const s=De.instance.get(i);if(s==null)throw new Error(`Database converter for file type '${i}' isn't registered and can can't read this file!`);this.clear(),await s.read(e,this,t&&t.minimumChunkSize||10,async(r,a,o,h)=>{if(this.events.openProgress.dispatch({database:this,percentage:r,stage:"CONVERSION",subStage:a,subStageStatus:o,data:h}),t&&t.fontLoader&&a=="FONT"&&o=="END"){const c=h||this.tables.textStyleTable.fonts;await t.fontLoader.load(c)}},t==null?void 0:t.timeout,t==null?void 0:t.sysVars),this.ensureDatabaseDefaults()}async openUri(e,t){var g;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",subStageStatus:"START"});const i=await fetch(e);if(!i.ok)throw this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"ERROR"}),new Error(`Failed to fetch file '${e}' with HTTP status code '${i.status}'!`);const s=i.headers.get("content-length"),r=s?parseInt(s,10):null;let a=0;const o=(g=i.body)==null?void 0:g.getReader();if(!o)throw new Error("Failed to get response reader");const h=[];for(;;){const{done:m,value:y}=await o.read();if(m)break;if(h.push(y),a+=y.length,r!==null){const x=Math.round(a/r*100);this.events.openProgress.dispatch({database:this,percentage:x,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const c=new Uint8Array(a);let d=0;for(const m of h)c.set(m,d),d+=m.length;const p=this.getFileNameFromUri(e).toLowerCase().split(".").pop();p==="dwg"?await this.read(c.buffer,t,Ni.DWG):p==="dxf"?await this.read(c.buffer,t,Ni.DXF):await this.read(c.buffer,t,p),this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}dxfOut(e,t=16,i=this.version.name,s=!1){this.ensureDatabaseDefaults();const r=i instanceof ve?i:new ve(i),a=new Ga({database:this,precision:t,version:r});return this.writeDxfHeaderSection(a),this.writeDxfTablesSection(a,r),this.writeDxfBlocksSection(a),this.writeDxfEntitiesSection(a),this.writeDxfObjectsSection(a),a.writeStart("EOF"),a.toString()}async regen(){await new ec(this).read(null,this,500,async(t,i,s,r)=>{this.events.openProgress.dispatch({database:this,percentage:t,stage:"CONVERSION",subStage:i,subStageStatus:s,data:r})})}createDefaultData(e={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){const t=new xl(this);e.layer&&t.createDefaultLayer(),e.lineType&&t.createDefaultLineType(),e.textStyle&&t.createDefaultTextStyle(),e.dimStyle&&t.createDefaultDimStyle(),e.layout&&t.createDefaultLayout()}ensureEntityStyleDefaults(e){if(e.dxfTypeName==="MLINE"){this.ensureMLineStyle(this._cmlstyle||dt);return}e.dxfTypeName==="MULTILEADER"&&this.ensureMLeaderStyle(this._cmleaderstyle||ut)}ensureDatabaseDefaults(){if(!this.tables.layerTable.has("0")){const t=new z;t.colorIndex=7,this.tables.layerTable.add(new ys({name:"0",standardFlags:0,linetype:St,lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}if(this.tables.linetypeTable.has(Lt)||this.tables.linetypeTable.add(new At({name:Lt,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(de)||this.tables.linetypeTable.add(new At({name:de,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(St)||this.tables.linetypeTable.add(new At({name:St,standardFlag:0,description:"Solid line",totalPatternLength:0})),this.tables.textStyleTable.has(Z)||this.tables.textStyleTable.add(new _s({name:Z,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"})),this.tables.dimStyleTable.has(Z)||this.tables.dimStyleTable.add(new ti({name:Z,dimtxsty:Z})),!this.tables.viewportTable.has("*Active")){const t=new vr;t.name="*Active",this.tables.viewportTable.add(t)}this.ensureMLineStyle(this._cmlstyle||dt),this.ensureMLeaderStyle(this._cmleaderstyle||ut);const e=this.tables.blockTable.modelSpace;if(!this.objects.layout.getAt("Model")){const t=new rn;t.layoutName="Model",t.tabOrder=0,t.blockTableRecordId=e.objectId,t.limits.min.copy({x:0,y:0}),t.limits.max.copy({x:1e6,y:1e6}),t.extents.min.copy({x:0,y:0,z:0}),t.extents.max.copy({x:1e6,y:1e6,z:0}),this.objects.layout.setAt(t.layoutName,t),e.layoutId=t.objectId}this.tables.appIdTable.has(Fs)||this.tables.appIdTable.add(new Js(Fs)),this.tables.appIdTable.has(Bs)||this.tables.appIdTable.add(new Js(Bs))}ensureMLineStyle(e){const t=this.objects.mlineStyle,i=e.trim();if(!i||t.getAt(i))return;for(const[r,a]of t.entries())if(r.toUpperCase()===i.toUpperCase()||a.styleName.toUpperCase()===i.toUpperCase())return;const s=new Ir;s.styleName=i,s.elements=[{offset:.5,color:new z().setByLayer(),lineType:de},{offset:-.5,color:new z().setByLayer(),lineType:de}],t.setAt(i,s)}ensureMLeaderStyle(e){const t=this.objects.mleaderStyle,i=e.trim();if(!i||t.getAt(i))return;for(const[o]of t.entries())if(o.toUpperCase()===i.toUpperCase())return;const s=new Sr;s.unknown1=2,s.maxLeaderSegmentsPoints=2,s.leaderLineColor=new z().setByBlock(),s.textColor=new z().setByBlock(),s.blockColor=new z().setByBlock(),s.alignSpace=4,s.breakSize=3.75,s.enableBlockRotation=!0,s.unknown2=!1;const r=this.tables.linetypeTable.getAt(Lt);s.leaderLineTypeId=r==null?void 0:r.objectId;const a=this.tables.textStyleTable.getAt(Z);s.textStyleId=a==null?void 0:a.objectId,t.setAt(i,s)}writeDxfHeaderSection(e){var t;e.startSection("HEADER"),e.writeString(9,"$ACADVER"),e.writeString(1,((t=e.version)==null?void 0:t.name)??this.version.name),e.writeString(9,"$HANDSEED"),e.writeString(5,e.nextHandle.toString(16).toUpperCase()),e.version!=null&&e.version.value>=27&&(e.writeString(9,"$DWGCODEPAGE"),e.writeString(3,"UTF-8")),e.writeString(9,"$INSUNITS"),e.writeInt16(70,this.insunits),e.writeString(9,"$LTSCALE"),e.writeDouble(40,this.ltscale),e.writeString(9,"$LWDISPLAY"),e.writeInt16(70,this.lwdisplay?1:0),e.writeString(9,"$CLAYER"),e.writeString(8,this.clayer),e.writeString(9,"$CELTYPE"),e.writeString(6,this.celtype),e.writeString(9,"$CMLSTYLE"),e.writeString(2,this.cmlstyle),e.writeString(9,"$CMLSCALE"),e.writeDouble(40,this.cmlscale),e.writeString(9,"$CMLEADERSTYLE"),e.writeString(2,this.cmleaderstyle),e.writeString(9,"$TEXTSTYLE"),e.writeString(7,this.textstyle),e.writeString(9,"$ANGBASE"),e.writeAngle(50,this.angBase),e.writeString(9,"$ANGDIR"),e.writeInt16(70,this.angDir),e.writeString(9,"$EXTMIN"),e.writePoint3d(10,this.extmin),e.writeString(9,"$EXTMAX"),e.writePoint3d(10,this.extmax),e.writeString(9,"$PDMODE"),e.writeInt32(70,this.pdmode),e.writeString(9,"$PDSIZE"),e.writeDouble(40,this.pdsize),e.writeString(9,"$OSMODE"),e.writeInt32(70,this.osmode),e.endSection()}writeDxfTablesSection(e,t){e.startSection("TABLES"),this.writeDxfTable(e,"VPORT",this.tables.viewportTable,this.tables.viewportTable.newIterator(),"VPORT"),this.writeDxfTable(e,"VIEW",this.tables.viewTable,this.tables.viewTable.newIterator(),"VIEW"),this.writeDxfTable(e,"LTYPE",this.tables.linetypeTable,this.tables.linetypeTable.newIterator(),"LTYPE"),this.writeDxfTable(e,"LAYER",this.tables.layerTable,this.tables.layerTable.newIterator(),"LAYER"),this.writeDxfTable(e,"STYLE",this.tables.textStyleTable,this.tables.textStyleTable.newIterator(),"STYLE"),this.writeDxfTable(e,"APPID",this.tables.appIdTable,this.tables.appIdTable.newIterator(),"APPID"),this.writeDxfTable(e,"DIMSTYLE",this.tables.dimStyleTable,this.tables.dimStyleTable.newIterator(),"DIMSTYLE"),t.value>=19&&this.writeDxfTable(e,"BLOCK_RECORD",this.tables.blockTable,this.tables.blockTable.newIterator(),"BLOCK_RECORD"),e.endSection()}writeDxfBlocksSection(e){e.startSection("BLOCKS");for(const t of this.tables.blockTable.newIterator()){if(t.dxfOutBlockBegin(e),!t.isModelSapce&&!t.isPaperSapce)for(const i of t.newIterator())this.writeDxfEntity(e,i);t.dxfOutBlockEnd(e)}e.endSection()}writeDxfEntitiesSection(e){e.startSection("ENTITIES");for(const t of this.tables.blockTable.newIterator())if(!(!t.isModelSapce&&!t.isPaperSapce))for(const i of t.newIterator())this.writeDxfEntity(e,i);e.endSection()}writeDxfObjectsSection(e){e.startSection("OBJECTS");const t=this.objects.dictionary;t.ownerId="0";const i=a=>{e.writeStart("DICTIONARY"),a.dxfOut(e)},s=(a,o)=>{t.getAt(a)!==o&&t.setAt(a,o)},r=a=>{t.getAt(a)&&t.remove(a)};s("ACAD_LAYOUT",this.objects.layout),this.objects.mleaderStyle.numEntries>0?s("ACAD_MLEADERSTYLE",this.objects.mleaderStyle):r("ACAD_MLEADERSTYLE"),this.objects.mlineStyle.numEntries>0?s("ACAD_MLINESTYLE",this.objects.mlineStyle):r("ACAD_MLINESTYLE"),this.objects.imageDefinition.numEntries>0?s("ISM_RASTER_IMAGE_DICT",this.objects.imageDefinition):r("ISM_RASTER_IMAGE_DICT"),this.objects.xrecord.numEntries>0?s("MLIGHT_XRECORD",this.objects.xrecord):r("MLIGHT_XRECORD"),i(t),i(this.objects.layout),this.objects.mleaderStyle.numEntries>0&&i(this.objects.mleaderStyle),this.objects.mlineStyle.numEntries>0&&i(this.objects.mlineStyle),this.objects.imageDefinition.numEntries>0&&i(this.objects.imageDefinition),this.objects.xrecord.numEntries>0&&i(this.objects.xrecord);for(const[a,o]of this.objects.layout.entries())e.writeStart("LAYOUT"),o.dxfOut(e);for(const[a,o]of this.objects.imageDefinition.entries())e.writeStart("IMAGEDEF"),o.dxfOut(e);for(const[a,o]of this.objects.mleaderStyle.entries())e.writeStart("MLEADERSTYLE"),o.dxfOut(e);for(const[a,o]of this.objects.mlineStyle.entries())e.writeStart("MLINESTYLE"),o.dxfOut(e);for(const[a,o]of this.objects.xrecord.entries())e.writeStart("XRECORD"),o.dxfOut(e);e.endSection()}writeDxfTable(e,t,i,s,r){const a=[...s];e.startTable(t),i.dxfOut(e);for(const o of a){if(r==="BLOCK_RECORD"&&o instanceof Q){o.dxfOutBlockRecord(e);continue}e.writeStart(r),o.dxfOut(e)}e.endTable()}writeDxfEntity(e,t){e.writeStart(t.dxfTypeName),t.dxfOut(e)}clear(){this._tables.blockTable.removeAll(),this._tables.dimStyleTable.removeAll(),this._tables.linetypeTable.removeAll(),this._tables.textStyleTable.removeAll(),this._tables.viewTable.removeAll(),this._tables.layerTable.removeAll(),this._tables.viewportTable.removeAll(),this._objects.layout.removeAll(),this._objects.imageDefinition.removeAll(),this._objects.mleaderStyle.removeAll(),this._objects.mlineStyle.removeAll(),this._objects.xrecord.removeAll(),this._currentSpace=void 0,this._extents.makeEmpty()}updateSysVar(e,t,i,s){this.hasSysVarValueChanged(t,i)&&(s(i),this.triggerSysVarChangedEvent(e,t,i))}hasSysVarValueChanged(e,t){return e instanceof z&&t instanceof z?!e.equals(t):e instanceof ve&&t instanceof ve?e.value!==t.value:!Object.is(e,t)}normalizeLinetypeName(e){const t=e.trim();return t.toUpperCase()==="BYLAYER"?de:t.toUpperCase()==="BYBLOCK"?Lt:t}triggerSysVarChangedEvent(e,t,i){const s=Ji.instance(),r=e.toLowerCase();s.getDescriptor(r)!=null&&s.events.sysVarChanged.dispatch({database:this,name:r,oldVal:t,newVal:i})}getFileNameFromUri(e){try{const i=new URL(e).pathname.split("/");return i[i.length-1]||""}catch{return""}}}const Nl="Load Database",Ba=3e4,td=12e4,id=1024*1024;class xe extends Ja{constructor(e,t){super(e.stage),this.data=e,this.progress=t}async run(e){const t=tr.getInstance().getEntry(Nl),i=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const s=await this.data.task(e);return this.progress&&(await this.progress(this.data.progress.value,this.data.stage,"END",s?s.data:null),this.data.progress.value+=this.data.step,this.data.progress.value>100&&(this.data.progress.value=100)),t&&(t.data[this.name]=Date.now()-i),s}}class Cr{constructor(e={}){this.config=e}async read(e,t,i,s,r,a){const o={name:Nl,data:{total:0},format(){let u="";return Object.keys(this.data).forEach(p=>{p!=="total"&&(u+=`- ${p}: ${this.data[p]} ms
8
+ `)}),u+=`- total: ${this.data.total} ms`,u}};tr.getInstance().collect(o),this.progress=s;const h={value:0},c=new Qa;c.setCompleteCallback(()=>this.onFinished()),c.setErrorCallback(u=>this.onError(u)),c.addTask(new xe({stage:"START",step:1,progress:h,task:async u=>u},s)),c.addTask(new xe({stage:"PARSE",step:5,progress:h,task:async u=>await this.parse(u,r)},s)),c.addTask(new xe({stage:"FONT",step:5,progress:h,task:async u=>{const p=this.getFonts(u.model);return{model:u.model,data:p}}},s)),c.addTask(new xe({stage:"LTYPE",step:1,progress:h,task:async u=>(this.processLineTypes(u.model,t),u)},s)),c.addTask(new xe({stage:"STYLE",step:1,progress:h,task:async u=>(this.processTextStyles(u.model,t),u)},s)),c.addTask(new xe({stage:"DIMSTYLE",step:1,progress:h,task:async u=>(this.processDimStyles(u.model,t),u)},s)),c.addTask(new xe({stage:"LAYER",step:1,progress:h,task:async u=>(this.processLayers(u.model,t),t.tables.layerTable.numEntries===0&&t.createDefaultData({layer:!0}),u)},s)),c.addTask(new xe({stage:"VPORT",step:1,progress:h,task:async u=>(this.processViewports(u.model,t),u)},s)),c.addTask(new xe({stage:"HEADER",step:1,progress:h,task:async u=>{if(this.processHeader(u.model,t),a){const p=Ji.instance();for(const[g,m]of Object.entries(a))p.setVar(g,m,t)}return u}},s)),c.addTask(new xe({stage:"BLOCK_RECORD",step:5,progress:h,task:async u=>(this.processBlockTables(u.model,t),u)},s)),c.addTask(new xe({stage:"OBJECT",step:5,progress:h,task:async u=>(this.processObjects(u.model,t),t.objects.layout.numEntries===0&&t.createDefaultData({layout:!0}),u)},s)),c.addTask(new xe({stage:"BLOCK",step:5,progress:h,task:async u=>(await this.processBlocks(u.model,t),u)},s)),c.addTask(new xe({stage:"ENTITY",step:100,progress:h,task:async u=>(await this.processEntities(u.model,t,i,h,s),u)},s)),c.addTask(new xe({stage:"END",step:0,progress:h,task:async u=>u},s));const d=Date.now();await c.run(e),o.data.total=Date.now()-d}onError(e){if(this.progress){const t=e.task;this.progress(t.data.progress.value,t.data.stage,"ERROR",void 0,e)}return e.task.name==="ENTITY"?!1:(this.onFinished(),!0)}onFinished(){this.progress&&(this.progress(100,"END","END"),ii.instance.clear())}getParserWorkerTimeout(e,t){const i=t??this.config.timeout;if(i!=null)return i;const s=Math.ceil(e.byteLength/id),r=Ba+s*1e3;return Math.min(td,Math.max(Ba,r))}async parse(e,t){throw new Error("Not impelemented yet!")}getFonts(e){throw new Error("Not impelemented yet!")}processLineTypes(e,t){throw new Error("Not impelemented yet!")}processTextStyles(e,t){throw new Error("Not impelemented yet!")}processDimStyles(e,t){throw new Error("Not impelemented yet!")}processLayers(e,t){throw new Error("Not impelemented yet!")}processViewports(e,t){throw new Error("Not impelemented yet!")}processHeader(e,t){throw new Error("Not impelemented yet!")}processBlockTables(e,t){throw new Error("Not impelemented yet!")}processObjects(e,t){throw new Error("Not impelemented yet!")}processBlocks(e,t){throw new Error("Not impelemented yet!")}processEntities(e,t,i,s,r){throw new Error("Not impelemented yet!")}}class nd extends kr{constructor(){super(),this._standardFlags=0,this._viewWidth=this.viewHeight,this._ucsAssociated=!1,this._cameraPlottable=!1,this._ucsElevation=0}get standardFlags(){return this._standardFlags}set standardFlags(e){this._standardFlags=e}get viewWidth(){return this._viewWidth}set viewWidth(e){this._viewWidth=e}get ucsAssociated(){return this._ucsAssociated}set ucsAssociated(e){this._ucsAssociated=e}get cameraPlottable(){return this._cameraPlottable}set cameraPlottable(e){this._cameraPlottable=e}get ucsElevation(){return this._ucsElevation}set ucsElevation(e){this._ucsElevation=e}get ucsObjectId(){return this._ucsObjectId}set ucsObjectId(e){this._ucsObjectId=e}get ucsBaseObjectId(){return this._ucsBaseObjectId}set ucsBaseObjectId(e){this._ucsBaseObjectId=e}get backgroundObjectId(){return this._backgroundObjectId}set backgroundObjectId(e){this._backgroundObjectId=e}get liveSectionObjectId(){return this._liveSectionObjectId}set liveSectionObjectId(e){this._liveSectionObjectId=e}dxfOutFields(e){return super.dxfOutFields(e),e.writeSubclassMarker("AcDbViewTableRecord"),e.writeString(2,this.name),e.writeInt16(70,this.standardFlags),e.writeDouble(40,this.gsView.viewHeight),e.writePoint2d(10,this.centerPoint),e.writeDouble(41,this.viewWidth),e.writePoint3d(11,this.gsView.viewDirectionFromTarget),e.writePoint3d(12,this.gsView.viewTarget),e.writeDouble(42,this.gsView.lensLength),e.writeDouble(43,this.gsView.frontClippingPlane),e.writeDouble(44,this.gsView.backClippingPlane),e.writeAngle(50,this.gsView.viewTwistAngle),e.writeInt16(71,this.gsView.viewMode),e.writeInt16(281,this.gsView.renderMode),e.writeInt16(72,this.ucsAssociated?1:0),e.writeInt16(73,this.cameraPlottable?1:0),e.writeObjectId(332,this.backgroundObjectId),e.writeObjectId(334,this.liveSectionObjectId),e.writeObjectId(348,this.gsView.visualStyleObjectId),this.ucsAssociated&&(e.writePoint3d(110,this.gsView.ucsOrigin),e.writePoint3d(111,this.gsView.ucsXAxis),e.writePoint3d(112,this.gsView.ucsYAxis),e.writeInt16(79,this.gsView.orthographicType),e.writeDouble(146,this.ucsElevation),e.writeObjectId(345,this.ucsObjectId),e.writeObjectId(346,this.ucsBaseObjectId)),this}}var ie,gi,q,K,pi,Oe,Nt,Ue,ue,$e,Ne,Yt,Xt,Rt,Le,qe,mi,yi,Bt,Ft,_i,xi,wi,Se,Ze,G,Dt,fi,C,ge,bi,pe,Li,Ke,V,Si,Je,zt,Es,Ts,Ye,Ii,Vt,Ie,Qe,et,tt,Ai,Pi,it,jt,Wt,Ms,Ei,Gt,nt,Ht,ne,st,Ae,ks,se,vs,rt,Pe,Ut,Ti,$t,Ee,at,Te,ot,Cs,qt,Me;(ie={})[ie.None=0]="None",ie[ie.Anonymous=1]="Anonymous",ie[ie.NonConstant=2]="NonConstant",ie[ie.Xref=4]="Xref",ie[ie.XrefOverlay=8]="XrefOverlay",ie[ie.ExternallyDependent=16]="ExternallyDependent",ie[ie.ResolvedOrDependent=32]="ResolvedOrDependent",ie[ie.ReferencedXref=64]="ReferencedXref";(gi={})[gi.BYBLOCK=0]="BYBLOCK",gi[gi.BYLAYER=256]="BYLAYER";(q={})[q.Rotated=0]="Rotated",q[q.Aligned=1]="Aligned",q[q.Angular=2]="Angular",q[q.Diameter=3]="Diameter",q[q.Radius=4]="Radius",q[q.Angular3Point=5]="Angular3Point",q[q.Ordinate=6]="Ordinate",q[q.ReferenceIsExclusive=32]="ReferenceIsExclusive",q[q.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",q[q.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(K={})[K.TopLeft=1]="TopLeft",K[K.TopCenter=2]="TopCenter",K[K.TopRight=3]="TopRight",K[K.MiddleLeft=4]="MiddleLeft",K[K.MiddleCenter=5]="MiddleCenter",K[K.MiddleRight=6]="MiddleRight",K[K.BottomLeft=7]="BottomLeft",K[K.BottomCenter=8]="BottomCenter",K[K.BottomRight=9]="BottomRight";(pi={})[pi.AtLeast=1]="AtLeast",pi[pi.Exact=2]="Exact";var Fa=((Oe={})[Oe.Center=0]="Center",Oe[Oe.Above=1]="Above",Oe[Oe.Outside=2]="Outside",Oe[Oe.JIS=3]="JIS",Oe[Oe.Below=4]="Below",Oe);(Nt={})[Nt.WithDimension=0]="WithDimension",Nt[Nt.AddLeader=1]="AddLeader",Nt[Nt.Independent=2]="Independent";(Ue={})[Ue.BothOutside=0]="BothOutside",Ue[Ue.ArrowFirst=1]="ArrowFirst",Ue[Ue.TextFirst=2]="TextFirst",Ue[Ue.Auto=3]="Auto";var ri=((ue={})[ue.Feet=0]="Feet",ue[ue.None=1]="None",ue[ue.Inch=2]="Inch",ue[ue.FeetAndInch=3]="FeetAndInch",ue[ue.Leading=4]="Leading",ue[ue.Trailing=8]="Trailing",ue[ue.LeadingAndTrailing=12]="LeadingAndTrailing",ue),sd=(($e={})[$e.None=0]="None",$e[$e.Leading=1]="Leading",$e[$e.Trailing=2]="Trailing",$e[$e.LeadingAndTrailing=3]="LeadingAndTrailing",$e),rd=((Ne={})[Ne.Center=0]="Center",Ne[Ne.First=1]="First",Ne[Ne.Second=2]="Second",Ne[Ne.OverFirst=3]="OverFirst",Ne[Ne.OverSecond=4]="OverSecond",Ne),ad=((Yt={})[Yt.Bottom=0]="Bottom",Yt[Yt.Center=1]="Center",Yt[Yt.Top=2]="Top",Yt);(Xt={})[Xt.None=0]="None",Xt[Xt.UseDrawingBackground=1]="UseDrawingBackground",Xt[Xt.Custom=2]="Custom";(Rt={})[Rt.Horizontal=0]="Horizontal",Rt[Rt.Diagonal=1]="Diagonal",Rt[Rt.NotStacked=2]="NotStacked";(Le={})[Le.Scientific=1]="Scientific",Le[Le.Decimal=2]="Decimal",Le[Le.Engineering=3]="Engineering",Le[Le.Architectural=4]="Architectural",Le[Le.Fractional=5]="Fractional",Le[Le.WindowDesktop=6]="WindowDesktop";(qe={})[qe.Decimal=0]="Decimal",qe[qe.DegreesMinutesSecond=1]="DegreesMinutesSecond",qe[qe.Gradian=2]="Gradian",qe[qe.Radian=3]="Radian";var od=((mi={})[mi.PatternFill=0]="PatternFill",mi[mi.SolidFill=1]="SolidFill",mi);(yi={})[yi.NonAssociative=0]="NonAssociative",yi[yi.Associative=1]="Associative";(Bt={})[Bt.Normal=0]="Normal",Bt[Bt.Outer=1]="Outer",Bt[Bt.Ignore=2]="Ignore";(Ft={})[Ft.UserDefined=0]="UserDefined",Ft[Ft.Predefined=1]="Predefined",Ft[Ft.Custom=2]="Custom";(_i={})[_i.NotAnnotated=0]="NotAnnotated",_i[_i.Annotated=1]="Annotated";(xi={})[xi.Solid=0]="Solid",xi[xi.Gradient=1]="Gradient";(wi={})[wi.TwoColor=0]="TwoColor",wi[wi.OneColor=1]="OneColor";var ld=((Se={})[Se.Default=0]="Default",Se[Se.External=1]="External",Se[Se.Polyline=2]="Polyline",Se[Se.Derived=4]="Derived",Se[Se.Textbox=8]="Textbox",Se[Se.Outermost=16]="Outermost",Se),bn=((Ze={})[Ze.Line=1]="Line",Ze[Ze.Circular=2]="Circular",Ze[Ze.Elliptic=3]="Elliptic",Ze[Ze.Spline=4]="Spline",Ze),hd=((G={})[G.Off=0]="Off",G[G.Solid=1]="Solid",G[G.Dashed=2]="Dashed",G[G.Dotted=3]="Dotted",G[G.ShotDash=4]="ShotDash",G[G.MediumDash=5]="MediumDash",G[G.LongDash=6]="LongDash",G[G.DoubleShortDash=7]="DoubleShortDash",G[G.DoubleMediumDash=8]="DoubleMediumDash",G[G.DoubleLongDash=9]="DoubleLongDash",G[G.DoubleMediumLongDash=10]="DoubleMediumLongDash",G[G.SparseDot=11]="SparseDot",G);hd.Off;(Dt={})[Dt.Standard=-3]="Standard",Dt[Dt.ByLayer=-2]="ByLayer",Dt[Dt.ByBlock=-1]="ByBlock";(fi={})[fi.English=0]="English",fi[fi.Metric=1]="Metric";(C={})[C.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",C[C.FRONT_CLIPPING=2]="FRONT_CLIPPING",C[C.BACK_CLIPPING=4]="BACK_CLIPPING",C[C.UCS_FOLLOW=8]="UCS_FOLLOW",C[C.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",C[C.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",C[C.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",C[C.FAST_ZOOM=128]="FAST_ZOOM",C[C.SNAP_MODE=256]="SNAP_MODE",C[C.GRID_MODE=512]="GRID_MODE",C[C.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",C[C.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",C[C.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",C[C.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",C[C.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",C[C.UNUSED=32768]="UNUSED",C[C.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",C[C.VIEWPORT_OFF=131072]="VIEWPORT_OFF",C[C.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",C[C.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",C[C.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",C[C.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE";(ge={})[ge.OPTIMIZED_2D=0]="OPTIMIZED_2D",ge[ge.WIREFRAME=1]="WIREFRAME",ge[ge.HIDDEN_LINE=2]="HIDDEN_LINE",ge[ge.FLAT_SHADED=3]="FLAT_SHADED",ge[ge.GOURAUD_SHADED=4]="GOURAUD_SHADED",ge[ge.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",ge[ge.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME";(bi={})[bi.UCS_UNCHANGED=0]="UCS_UNCHANGED",bi[bi.HAS_OWN_UCS=1]="HAS_OWN_UCS";(pe={})[pe.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",pe[pe.TOP=1]="TOP",pe[pe.BOTTOM=2]="BOTTOM",pe[pe.FRONT=3]="FRONT",pe[pe.BACK=4]="BACK",pe[pe.LEFT=5]="LEFT",pe[pe.RIGHT=6]="RIGHT";(Li={})[Li.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",Li[Li.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(Ke={})[Ke.ByLayer=0]="ByLayer",Ke[Ke.ByBlock=1]="ByBlock",Ke[Ke.ByDictionaryDefault=2]="ByDictionaryDefault",Ke[Ke.ByObject=3]="ByObject";(V={})[V.NotAllowed=0]="NotAllowed",V[V.AllowErase=1]="AllowErase",V[V.AllowTransform=2]="AllowTransform",V[V.AllowChangeColor=4]="AllowChangeColor",V[V.AllowChangeLayer=8]="AllowChangeLayer",V[V.AllowChangeLinetype=16]="AllowChangeLinetype",V[V.AllowChangeLinetypeScale=32]="AllowChangeLinetypeScale",V[V.AllowChangeVisibility=64]="AllowChangeVisibility",V[V.AllowClone=128]="AllowClone",V[V.AllowChangeLineweight=256]="AllowChangeLineweight",V[V.AllowChangePlotStyleName=512]="AllowChangePlotStyleName",V[V.AllowAllExceptClone=895]="AllowAllExceptClone",V[V.AllowAll=1023]="AllowAll",V[V.DisableProxyWarning=1024]="DisableProxyWarning",V[V.R13FormatProxy=32768]="R13FormatProxy";function O(n,e,t){return n.code===e&&(t==null||n.value===t)}function Mt(n){let e={};n.rewind();let t=n.next(),i=t.code;if(e.x=t.value,(t=n.next()).code!==i+10)throw Error("Expected code for point value to be 20 but got "+t.code+".");return e.y=t.value,(t=n.next()).code!==i+20?n.rewind():e.z=t.value,e}let on=Symbol();function E(n,e){return(t,i,s)=>{let r=function(h,c=!1){return h.reduce((d,u)=>{u.pushContext&&d.push({});let p=d[d.length-1];for(let g of typeof u.code=="number"?[u.code]:u.code){let m=p[g]??(p[g]=[]);u.isMultiple&&m.length,m.push(u)}return d},[{}])}(n,i.debug),a=!1,o=r.length-1;for(;!O(t,0,"EOF");){let h=function(x,_,S){return x.find((L,T)=>{var I;return T>=S&&((I=L[_])==null?void 0:I.length)})}(r,t.code,o),c=h==null?void 0:h[t.code],d=c==null?void 0:c[c.length-1];if(!h||!d){i.rewind();break}d.isMultiple||h[t.code].pop();let{name:u,parser:p,isMultiple:g,isReducible:m}=d,y=p==null?void 0:p(t,i,s);if(y===on){i.rewind();break}if(u){let[x,_]=cd(s,u);g&&!m?(Object.prototype.hasOwnProperty.call(x,_)||(x[_]=[]),x[_].push(y)):x[_]=y}d.pushContext&&(o-=1),a=!0,t=i.next()}return e&&Object.setPrototypeOf(s,e),a}}function cd(n,e){let t=e.split(".");if(!t.length)throw Error("[parserGenerator::getObjectByPath] Invalid empty path");let i=n;for(let s=0;s<t.length-1;++s){let r=Os(t[s]),a=Os(t[s+1]);Object.prototype.hasOwnProperty.call(i,r)||(typeof a=="number"?i[r]=[]:i[r]={}),i=i[r]}return[i,Os(t[t.length-1])]}function Os(n){let e=Number.parseInt(n);return Number.isNaN(e)?n:e}function l({value:n}){return n}function b(n,e){return Mt(e)}function P({value:n}){return!!n}function dd({value:n}){return n.trim()}let ud=[{code:281,name:"isEntity",parser:P},{code:280,name:"wasProxy",parser:P},{code:91,name:"instanceCount",parser:l},{code:90,name:"proxyFlag",parser:l},{code:3,name:"appName",parser:l},{code:2,name:"cppClassName",parser:l},{code:1,name:"name",parser:l}],gd=E(ud),pd=[{code:0,name:"classes",isMultiple:!0,parser(n,e){if(n.value!=="CLASS")return on;n=e.next();let t={};return gd(n,e,t),t}}],md=E(pd);(Si={})[Si.RayTrace=0]="RayTrace",Si[Si.ShadowMap=1]="ShadowMap";function Ge(n,e,t){for(;O(n,102);){var i;let s=n.value;if(n=e.next(),!s.startsWith("{")){e.debug,function(a,o){for(;!O(a,102)&&!O(a,0,"EOF");)a=o.next()}(n,e),n=e.next();continue}let r=s.slice(1).trim();t.extensions??(t.extensions={}),(i=t.extensions)[r]??(i[r]=[]),function(a,o,h){for(;!O(a,102,"}")&&!O(a,0,"EOF");)h.push(a),a=o.next()}(n,e,t.extensions[r]),n=e.next()}e.rewind()}let yd=[{code:1001,name:"xdata",isMultiple:!0,parser:Yl}],_d=new Set([1010,1011,1012,1013]);function Yl(n,e){var s;if(!O(n,1001))throw Error("XData must starts with code 1001");let t={appName:n.value,value:[]};n=e.next();let i=[t.value];for(;!O(n,0,"EOF")&&!O(n,1001)&&n.code>=1e3;){let r=i[i.length-1];if(n.code===1002){n.value==="{"?i.push([]):(i.pop(),(s=i[i.length-1])==null||s.push(r)),n=e.next();continue}_d.has(n.code)?r.push(Mt(e)):r.push(n.value),n=e.next()}return e.rewind(),t}(Je={})[Je.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",Je[Je.CAST=1]="CAST",Je[Je.RECEIVE=2]="RECEIVE",Je[Je.IGNORE=3]="IGNORE";let F=[...yd,{code:284,name:"shadowMode",parser:l},{code:390,name:"plotStyleHardId",parser:l},{code:380,name:"plotStyleType",parser:l},{code:440,name:"transparency",parser:l},{code:430,name:"colorName",parser:l},{code:420,name:"color",parser:l},{code:310,name:"proxyEntity",isMultiple:!0,isReducible:!0,parser:(n,e,t)=>(t.proxyEntity??"")+n.value},{code:[92,160],name:"proxyByte",parser:l},{code:60,name:"isVisible",parser:P},{code:48,name:"lineTypeScale",parser:l},{code:370,name:"lineweight",parser:l},{code:62,name:"colorIndex",parser:l},{code:347,name:"materialObjectHardId",parser:l},{code:6,name:"lineType",parser:l},{code:8,name:"layer",parser:l},{code:410,name:"layoutTabName",parser:l},{code:67,name:"isInPaperSpace",parser:P},{code:100},{code:330,name:"ownerBlockRecordSoftId",parser:l},{code:102,parser:Ge},{code:102,parser:Ge},{code:102,parser:Ge},{code:5,name:"handle",parser:l}];function xs(n){return[{code:3,name:n,parser:(e,t,i)=>(i._code3text=(i._code3text??"")+e.value,i._code3text+(i._code1text??"")),isMultiple:!0,isReducible:!0},{code:1,name:n,parser:(e,t,i)=>(i._code1text=e.value,(i._code3text??"")+i._code1text)}]}function Xl(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}let xd={extrusionDirection:{x:0,y:0,z:1}},wd=[{code:210,name:"extrusionDirection",parser:b},{code:51,name:"endAngle",parser:l},{code:50,name:"startAngle",parser:l},{code:100,name:"subclassMarker",parser:l},{code:40,name:"radius",parser:l},{code:10,name:"center",parser:b},{code:39,name:"thickness",parser:l},{code:100},...F];class Rl{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){Xl(this,"parser",E(wd,xd))}}Xl(Rl,"ForEntityName","ARC");(zt={})[zt.BeforeText=0]="BeforeText",zt[zt.AboveText=1]="AboveText",zt[zt.None=2]="None";let Or=[{name:"DIMPOST",code:3},{name:"DIMAPOST",code:4,defaultValue:""},{name:"DIMBLK_OBSOLETE",code:5},{name:"DIMBLK1_OBSOLETE",code:6},{name:"DIMBLK2_OBSOLETE",code:7},{name:"DIMSCALE",code:40,defaultValue:1},{name:"DIMASZ",code:41,defaultValue:.25},{name:"DIMEXO",code:42,defaultValue:.625,defaultValueImperial:.0625},{name:"DIMDLI",code:43,defaultValue:3.75,defaultValueImperial:.38},{name:"DIMEXE",code:44,defaultValue:2.25,defaultValueImperial:.28},{name:"DIMRND",code:45,defaultValue:0},{name:"DIMDLE",code:46,defaultValue:0},{name:"DIMTP",code:47,defaultValue:0},{name:"DIMTM",code:48,defaultValue:0},{name:"DIMFXL",code:49,defaultValue:1},{name:"DIMJOGANG",code:50,defaultValue:45},{name:"DIMTFILL",code:69,defaultValue:0},{name:"DIMTFILLCLR",code:70,defaultValue:0},{name:"DIMTOL",code:71,defaultValue:0,defaultValueImperial:1},{name:"DIMLIM",code:72,defaultValue:0},{name:"DIMTIH",code:73,defaultValue:0,defaultValueImperial:1},{name:"DIMTOH",code:74,defaultValue:0,defaultValueImperial:1},{name:"DIMSE1",code:75,defaultValue:0},{name:"DIMSE2",code:76,defaultValue:0},{name:"DIMTAD",code:77,defaultValue:Fa.Above,defaultValueImperial:Fa.Center},{name:"DIMZIN",code:78,defaultValue:ri.Trailing,defaultValueImperial:ri.Feet},{name:"DIMAZIN",code:79,defaultValue:sd.None},{name:"DIMARCSYM",code:90,defaultValue:0},{name:"DIMTXT",code:140,defaultValue:2.5,defaultValueImperial:.28},{name:"DIMCEN",code:141,defaultValue:2.5,defaultValueImperial:.09},{name:"DIMTSZ",code:142,defaultValue:0},{name:"DIMALTF",code:143,defaultValue:25.4},{name:"DIMLFAC",code:144,defaultValue:1},{name:"DIMTVP",code:145,defaultValue:0},{name:"DIMTFAC",code:146,defaultValue:1},{name:"DIMGAP",code:147,defaultValue:.625,defaultValueImperial:.09},{name:"DIMALTRND",code:148,defaultValue:0},{name:"DIMALT",code:170,defaultValue:0},{name:"DIMALTD",code:171,defaultValue:3,defaultValueImperial:2},{name:"DIMTOFL",code:172,defaultValue:1,defaultValueImperial:0},{name:"DIMSAH",code:173,defaultValue:0},{name:"DIMTIX",code:174,defaultValue:0},{name:"DIMSOXD",code:175,defaultValue:0},{name:"DIMCLRD",code:176,defaultValue:0},{name:"DIMCLRE",code:177,defaultValue:0},{name:"DIMCLRT",code:178,defaultValue:0},{name:"DIMADEC",code:179,defaultValue:0},{name:"DIMUNIT",code:270},{name:"DIMDEC",code:271,defaultValue:2,defaultValueImperial:4},{name:"DIMTDEC",code:272,defaultValue:2,defaultValueImperial:4},{name:"DIMALTU",code:273,defaultValue:2},{name:"DIMALTTD",code:274,defaultValue:3,defaultValueImperial:2},{name:"DIMAUNIT",code:275,defaultValue:0},{name:"DIMFRAC",code:276,defaultValue:0},{name:"DIMLUNIT",code:277,defaultValue:2},{name:"DIMDSEP",code:278,defaultValue:44,defaultValueImperial:46},{name:"DIMTMOVE",code:279,defaultValue:0},{name:"DIMJUST",code:280,defaultValue:rd.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:ad.Center},{name:"DIMTZIN",code:284,defaultValue:ri.Trailing,defaultValueImperial:ri.Feet},{name:"DIMALTZ",code:285,defaultValue:ri.Trailing},{name:"DIMALTTZ",code:286,defaultValue:ri.Trailing},{name:"DIMFIT",code:287},{name:"DIMUPT",code:288,defaultValue:0},{name:"DIMATFIT",code:289,defaultValue:3},{name:"DIMFXLON",code:290,defaultValue:0},{name:"DIMTXTDIRECTION",code:294,defaultValue:0},{name:"DIMTXSTY",code:340,defaultValue:"Standard"},{name:"DIMLDRBLK",code:341,defaultValue:""},{name:"DIMBLK",code:342,defaultValue:""},{name:"DIMBLK1",code:343,defaultValue:""},{name:"DIMBLK2",code:344,defaultValue:""},{name:"DIMLTYPE",code:345,defaultValue:""},{name:"DIMLTEX1",code:346,defaultValue:""},{name:"DIMLTEX2",code:347,defaultValue:""},{name:"DIMLWD",code:371,defaultValue:-2},{name:"DIMLWE",code:372,defaultValue:-2}],Bl=[{code:3,name:"styleName",parser:l},{code:210,name:"extrusionDirection",parser:b},{code:51,name:"ocsRotation",parser:l},{code:53,name:"textRotation",parser:l},{code:1,name:"text",parser:l},{code:42,name:"measurement",parser:l},{code:72,name:"textLineSpacingStyle",parser:l},{code:71,name:"attachmentPoint",parser:l},{code:70,name:"dimensionType",parser:l},{code:11,name:"textPoint",parser:b},{code:10,name:"definitionPoint",parser:b},{code:2,name:"name",parser:l},{code:280,name:"version",parser:l},{code:100}],fd=[{code:100},{code:52,name:"obliqueAngle",parser:l},{code:50,name:"rotationAngle",parser:l},{code:14,name:"subDefinitionPoint2",parser:b},{code:13,name:"subDefinitionPoint1",parser:b},{code:12,name:"insertionPoint",parser:b},{code:100,name:"subclassMarker",parser:l}],bd=[{code:16,name:"arcPoint",parser:b},{code:15,name:"centerPoint",parser:b},{code:14,name:"subDefinitionPoint2",parser:b},{code:13,name:"subDefinitionPoint1",parser:b},{code:100,name:"subclassMarker",parser:l}],Ld=[{code:14,name:"subDefinitionPoint2",parser:b},{code:13,name:"subDefinitionPoint1",parser:b},{code:100,name:"subclassMarker",parser:l}],Sd=[{code:40,name:"leaderLength",parser:l},{code:15,name:"subDefinitionPoint",parser:b},{code:100,name:"subclassMarker",parser:l}],Id=[{code:100,parser(n,e,t){let i=function(s){switch(s){case"AcDbAlignedDimension":return E(fd);case"AcDb3PointAngularDimension":case"AcDb2LineAngularDimension":return E(bd);case"AcDbOrdinateDimension":return E(Ld);case"AcDbRadialDimension":case"AcDbDiametricDimension":return E(Sd)}return null}(n.value);if(!i)return on;i(n,e,t)},pushContext:!0},...Or.map(n=>({...n,parser:l})),...Bl,...F];class Mn{parseEntity(e,t){let i={};return E(Id)(t,e,i),i}}(Es="ForEntityName")in Mn?Object.defineProperty(Mn,Es,{value:"DIMENSION",enumerable:!0,configurable:!0,writable:!0}):Mn[Es]="DIMENSION";let Ad=[{code:73},{code:17,name:"leaderEnd",parser:b},{code:16,name:"leaderStart",parser:b},{code:71,name:"hasLeader",parser:P},{code:41,name:"endAngle",parser:l},{code:40,name:"startAngle",parser:l},{code:70,name:"isPartial",parser:P},{code:15,name:"centerPoint",parser:b},{code:14,name:"xline2Point",parser:b},{code:13,name:"xline1Point",parser:b},{code:100,name:"subclassMarker",parser:l,pushContext:!0},...Or.map(n=>({...n,parser:l})),...Bl,...F];class kn{parseEntity(e,t){let i={};return E(Ad)(t,e,i),i}}(Ts="ForEntityName")in kn?Object.defineProperty(kn,Ts,{value:"ARC_DIMENSION",enumerable:!0,configurable:!0,writable:!0}):kn[Ts]="ARC_DIMENSION";(Ye={})[Ye.NONE=0]="NONE",Ye[Ye.INVISIBLE=1]="INVISIBLE",Ye[Ye.CONSTANT=2]="CONSTANT",Ye[Ye.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",Ye[Ye.PRESET=8]="PRESET";(Ii={})[Ii.MULTILINE=2]="MULTILINE",Ii[Ii.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(Vt={})[Vt.NONE=0]="NONE",Vt[Vt.MIRRORED_X=2]="MIRRORED_X",Vt[Vt.MIRRORED_Y=4]="MIRRORED_Y";var Pd=((Ie={})[Ie.LEFT=0]="LEFT",Ie[Ie.CENTER=1]="CENTER",Ie[Ie.RIGHT=2]="RIGHT",Ie[Ie.ALIGNED=3]="ALIGNED",Ie[Ie.MIDDLE=4]="MIDDLE",Ie[Ie.FIT=5]="FIT",Ie),Ed=((Qe={})[Qe.BASELINE=0]="BASELINE",Qe[Qe.BOTTOM=1]="BOTTOM",Qe[Qe.MIDDLE=2]="MIDDLE",Qe[Qe.TOP=3]="TOP",Qe);function Fl(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}let Dl={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:Pd.LEFT,valign:Ed.BASELINE,extrusionDirection:{x:0,y:0,z:1}},zl=[{code:73,name:"valign",parser:l},{code:100},{code:210,name:"extrusionDirection",parser:b},{code:11,name:"endPoint",parser:b},{code:72,name:"valign",parser:l},{code:72,name:"halign",parser:l},{code:71,name:"generationFlag",parser:l},{code:7,name:"styleName",parser:l},{code:51,name:"obliqueAngle",parser:l},{code:41,name:"xScale",parser:l},{code:50,name:"rotation",parser:l},{code:1,name:"text",parser:l},{code:40,name:"textHeight",parser:l},{code:10,name:"startPoint",parser:b},{code:39,name:"thickness",parser:l},{code:100,name:"subclassMarker",parser:l},...F];class Vl{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){Fl(this,"parser",E(zl,Dl))}}function jl(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}Fl(Vl,"ForEntityName","TEXT");let Td={...Dl},Md=[{code:2},{code:40,name:"annotationScale",parser:l},{code:10,name:"alignmentPoint",parser:b},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:l},{code:70,name:"numberOfSecondaryAttributes",parser:l},{code:70,name:"isReallyLocked",parser:P},{code:70,name:"mtextFlag",parser:l},{code:280,name:"isDuplicatedRecord",parser:P},{code:100},{code:280,name:"isLocked",parser:P},{code:74,name:"valign",parser:l},{code:73},{code:70,name:"attributeFlag",parser:l},{code:2,name:"tag",parser:l},{code:3,name:"prompt",parser:l},{code:280},{code:100,name:"subclassMarker",parser:l},...zl.slice(2)];class Wl{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){jl(this,"parser",E(Md,Td))}}function kd(n,e){let t={};for(let i of n){let s=e(i);s!=null&&(t[s]??(t[s]=[]),t[s].push(i))}return t}function*cs(n,e=1/0,t=1){for(let i=n;i!==e;i+=t)yield i}function Qs(n){return{x:n.x??0,y:n.y??0,z:n.z??0}}jl(Wl,"ForEntityName","ATTDEF");var vd=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function Cd(n){return vd[n]}function Od(n){n.rewind();let e=n.next();if(e.code!==101)throw Error("Bad call for skipEmbeddedObject()");do e=n.next();while(e.code!==0);n.rewind()}function Nd(n,e,t){if(O(e,102))return Ge(e,t,n),!0;switch(e.code){case 0:n.type=e.value;break;case 5:n.handle=e.value;break;case 330:n.ownerBlockRecordSoftId=e.value;break;case 67:n.isInPaperSpace=!!e.value;break;case 8:n.layer=e.value;break;case 6:n.lineType=e.value;break;case 347:n.materialObjectHardId=e.value;break;case 62:n.colorIndex=e.value,n.color=Cd(Math.abs(e.value));break;case 370:n.lineweight=e.value;break;case 48:n.lineTypeScale=e.value;break;case 60:n.isVisible=!!e.value;break;case 92:n.proxyByte=e.value;break;case 310:n.proxyEntity=e.value;break;case 100:break;case 420:n.color=e.value;break;case 430:n.transparency=e.value;break;case 390:n.plotStyleHardId=e.value;break;case 284:n.shadowMode=e.value;break;case 1001:(n.xdata??(n.xdata=[])).push(Yl(e,t));break;default:return!1}return!0}function Gl(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}let Yd={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},vn=[{code:46,name:"annotationHeight",parser:l},{code:101,parser(n,e){Od(e)}},{code:50,name:"columnHeight",parser:l},{code:49,name:"columnGutter",parser:l},{code:48,name:"columnWidth",parser:l},{code:79,name:"columnAutoHeight",parser:l},{code:78,name:"columnFlowReversed",parser:l},{code:76,name:"columnCount",parser:l},{code:75,name:"columnType",parser:l},{code:441,name:"backgroundFillTransparency",parser:l},{code:63,name:"backgroundFillColor",parser:l},{code:45,name:"fillBoxScale",parser:l},{code:[...cs(430,440)],name:"backgroundColor",parser:l},{code:[...cs(420,430)],name:"backgroundColor",parser:l},{code:90,name:"backgroundFill",parser:l},{code:44,name:"lineSpacing",parser:l},{code:73,name:"lineSpacingStyle",parser:l},{code:50,name:"rotation",parser:l},{code:43},{code:42},{code:11,name:"direction",parser:b},{code:210,name:"extrusionDirection",parser:b},{code:7,name:"styleName",parser:l},...xs("text"),{code:72,name:"drawingDirection",parser:l},{code:71,name:"attachmentPoint",parser:l},{code:41,name:"width",parser:l},{code:40,name:"height",parser:l},{code:10,name:"insertionPoint",parser:b},{code:100,name:"subclassMarker",parser:l},...F];class Hl{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){Gl(this,"parser",E(vn,Yd))}}function Ul(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}Gl(Hl,"ForEntityName","MTEXT");let Xd={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},Rd=[...vn.slice(vn.findIndex(({name:n})=>n==="columnType"),vn.findIndex(({name:n})=>n==="subclassMarker")+1),{code:100},{code:0,parser(n){if(!O(n,0,"MTEXT"))return on}},{code:2,name:"definitionTag",parser:l},{code:40,name:"annotationScale",parser:l},{code:10,name:"alignmentPoint",parser:b},{code:340,name:"secondaryAttributesHardId",parser:l},{code:70,name:"numberOfSecondaryAttributes",parser:l},{code:70,name:"isReallyLocked",parser:P},{code:70,name:"mtextFlag",parser:l},{code:280,name:"isDuplicatedEntriesKeep",parser:P},{code:100},{code:280,name:"lockPositionFlag",parser:P},{code:210,name:"extrusionDirection",parser:b},{code:11,name:"alignmentPoint",parser:b},{code:74,name:"verticalJustification",parser:l},{code:72,name:"horizontalJustification",parser:l},{code:71,name:"textGenerationFlag",parser:l},{code:7,name:"textStyle",parser:l},{code:51,name:"obliqueAngle",parser:l},{code:41,name:"scale",parser:l},{code:50,name:"rotation",parser:l},{code:73},{code:70,name:"attributeFlag",parser:l},{code:2,name:"tag",parser:l},{code:280},{code:100,name:"subclassMarker",parser:l},{code:1,name:"text",parser:l},{code:40,name:"textHeight",parser:l},{code:10,name:"startPoint",parser:b},{code:39,name:"thickness",parser:l},{code:100},...F];class $l{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){Ul(this,"parser",E(Rd,Xd))}}function ql(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}Ul($l,"ForEntityName","ATTRIB");let Bd=[...xs("data"),{code:70,name:"version",parser:l},{code:100,name:"subclassMarker",parser:l},...F];class Zl{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){ql(this,"parser",E(Bd))}}function Kl(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}ql(Zl,"ForEntityName","BODY");let Fd={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Dd=[{code:210,name:"extrusionDirection",parser:b},{code:40,name:"radius",parser:l},{code:10,name:"center",parser:b},{code:39,name:"thickness",parser:l},{code:100,name:"subclassMarker",parser:l},...F];class Jl{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){Kl(this,"parser",E(Dd,Fd))}}function Ql(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}Kl(Jl,"ForEntityName","CIRCLE");let zd={extrusionDirection:{x:0,y:0,z:1}},Vd=[{code:42,name:"endAngle",parser:l},{code:41,name:"startAngle",parser:l},{code:40,name:"axisRatio",parser:l},{code:210,name:"extrusionDirection",parser:b},{code:11,name:"majorAxisEndPoint",parser:b},{code:10,name:"center",parser:b},{code:100,name:"subclassMarker",parser:l},...F];class eh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){Ql(this,"parser",E(Vd,zd))}}function th(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}Ql(eh,"ForEntityName","ELLIPSE");let jd=[{code:13,name:"vertices.3",parser:b},{code:12,name:"vertices.2",parser:b},{code:11,name:"vertices.1",parser:b},{code:10,name:"vertices.0",parser:b},{code:100,name:"subclassMarker",parser:l},...F];class ih{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){th(this,"parser",E(jd))}}th(ih,"ForEntityName","3DFACE");(et={})[et.First=1]="First",et[et.Second=2]="Second",et[et.Third=4]="Third",et[et.Fourth=8]="Fourth";let nh=[{code:330,name:"sourceBoundaryObjects",parser:l,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:l}],Wd=[{code:11,name:"end",parser:b},{code:10,name:"start",parser:b}],Gd=[{code:73,name:"isCCW",parser:P},{code:51,name:"endAngle",parser:l},{code:50,name:"startAngle",parser:l},{code:40,name:"radius",parser:l},{code:10,name:"center",parser:b}],Hd=[{code:73,name:"isCCW",parser:P},{code:51,name:"endAngle",parser:l},{code:50,name:"startAngle",parser:l},{code:40,name:"lengthOfMinorAxis",parser:l},{code:11,name:"end",parser:b},{code:10,name:"center",parser:b}],Ud=[{code:13,name:"endTangent",parser:b},{code:12,name:"startTangent",parser:b},{code:11,name:"fitDatum",isMultiple:!0,parser:b},{code:97,name:"numberOfFitData",parser:l},{code:10,name:"controlPoints",isMultiple:!0,parser(n,e){let t={...Mt(e),weight:1};return(n=e.next()).code===42?t.weight=n.value:e.rewind(),t}},{code:40,name:"knots",isMultiple:!0,parser:l},{code:96,name:"numberOfControlPoints",parser:l},{code:95,name:"numberOfKnots",parser:l},{code:74,name:"isPeriodic",parser:P},{code:73,name:"splineFlag",parser:l},{code:94,name:"degree",parser:l}],$d={[bn.Line]:Wd,[bn.Circular]:Gd,[bn.Elliptic]:Hd,[bn.Spline]:Ud},qd=[...nh,{code:72,name:"edges",parser(n,e){let t={type:n.value},i=E($d[t.type]);if(!i)throw Error(`Invalid edge type ${t.type}`);return i(n=e.next(),e,t),t},isMultiple:!0},{code:93,name:"numberOfEdges",parser:l}],Zd=[...nh,{code:10,name:"vertices",parser(n,e){let t={...Mt(e),bulge:0};return(n=e.next()).code===42?t.bulge=n.value:e.rewind(),t},isMultiple:!0},{code:93,name:"numberOfVertices",parser:l},{code:73,name:"isClosed",parser:P},{code:72,name:"hasBulge",parser:P}];function Kd(n,e){let t={boundaryPathTypeFlag:n.value},i=t.boundaryPathTypeFlag&ld.Polyline;return n=e.next(),i?E(Zd)(n,e,t):E(qd)(n,e,t),t}let Jd=[{code:49,name:"dashLengths",parser:l,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:l},{code:45,name:"offset",parser:Da},{code:43,name:"base",parser:Da},{code:53,name:"angle",parser:l}];function Da(n,e){let t=n.code+1,i={x:n.value,y:1};return(n=e.next()).code===t?i.y=n.value:e.rewind(),i}function Qd(n,e){let t={};return E(Jd)(n,e,t),t}function eu(n,e){let t=[];for(;n.code===463;){let i={reservedField:n.value};if((n=e.next()).code===63&&(i.colorIndex=n.value,n=e.next()),n.code===421)i.rgb=n.value,t.push(i),n=e.next();else{e.rewind();break}}return n.code!==463&&t.length>0&&e.rewind(),t}function sh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}let tu={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},iu=[{code:470,name:"gradientName",parser:l},{code:463,name:"gradientColors",parser:eu},{code:462,name:"colorTint",parser:l},{code:461,name:"gradientDefinition",parser:l},{code:460,name:"gradientRotation",parser:l},{code:453,name:"numberOfColors",parser:l},{code:452,name:"gradientColorFlag",parser:l},{code:451},{code:450,name:"gradientFlag",parser:l},{code:10,name:"seedPoints",parser:b,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:b},{code:98,name:"numberOfSeedPoints",parser:l},{code:47,name:"pixelSize",parser:l},{code:53,name:"definitionLines",parser:Qd,isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:l},{code:77,name:"isDouble",parser:P},{code:73,name:"isAnnotated",parser:P},{code:41,name:"patternScale",parser:l},{code:52,name:"patternAngle",parser:l},{code:76,name:"patternType",parser:l},{code:75,name:"hatchStyle",parser:l},{code:92,name:"boundaryPaths",parser:Kd,isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:l},{code:71,name:"associativity",parser:l},{code:63,name:"patternFillColor",parser:l},{code:70,name:"solidFill",parser:l},{code:2,name:"patternName",parser:l},{code:210,name:"extrusionDirection",parser:b},{code:10,name:"elevationPoint",parser:b},{code:100,name:"subclassMarker",parser:l,pushContext:!0},...F];class rh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){sh(this,"parser",E(iu,tu))}}function ah(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}sh(rh,"ForEntityName","HATCH");let nu={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},su=[{code:290,name:"clipMode",parser:l},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:b},{code:91,name:"countBoundaryPoints",parser:l},{code:71,name:"clippingBoundaryType",parser:l},{code:360,name:"imageDefReactorHandle",parser:l},{code:283,name:"fade",parser:l},{code:282,name:"contrast",parser:l},{code:281,name:"brightness",parser:l},{code:280,name:"isClipped",parser:P},{code:70,name:"flags",parser:l},{code:340,name:"imageDefHandle",parser:l},{code:13,name:"imageSize",parser:b},{code:12,name:"vPixel",parser:b},{code:11,name:"uPixel",parser:b},{code:10,name:"position",parser:b},{code:90,name:"version",parser:l},{code:100,name:"subclassMarker",parser:l},...F];class oh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){ah(this,"parser",E(su,nu))}}ah(oh,"ForEntityName","IMAGE");(tt={})[tt.ShowImage=1]="ShowImage",tt[tt.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",tt[tt.UseClippingBoundary=4]="UseClippingBoundary",tt[tt.TransparencyIsOn=8]="TransparencyIsOn";(Ai={})[Ai.Rectangular=1]="Rectangular",Ai[Ai.Polygonal=2]="Polygonal";(Pi={})[Pi.Outside=0]="Outside",Pi[Pi.Inside=1]="Inside";function lh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}let ru={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},au=[{code:210,name:"extrusionDirection",parser:b},{code:45,name:"rowSpacing",parser:l},{code:44,name:"columnSpacing",parser:l},{code:71,name:"rowCount",parser:l},{code:70,name:"columnCount",parser:l},{code:50,name:"rotation",parser:l},{code:43,name:"zScale",parser:l},{code:42,name:"yScale",parser:l},{code:41,name:"xScale",parser:l},{code:10,name:"insertionPoint",parser:b},{code:2,name:"name",parser:l},{code:66,name:"isVariableAttributes",parser:P},{code:100,name:"subclassMarker",parser:l},...F];class hh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){lh(this,"parser",E(au,ru))}}function ch(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}lh(hh,"ForEntityName","INSERT");let ou={isArrowheadEnabled:!0},lu=[{code:213,name:"offsetFromAnnotation",parser:b},{code:212,name:"offsetFromBlock",parser:b},{code:211,name:"horizontalDirection",parser:b},{code:210,name:"normal",parser:b},{code:340,name:"associatedAnnotation",parser:l},{code:77,name:"byBlockColor",parser:l},{code:10,name:"vertices",parser:b,isMultiple:!0},{code:76,name:"numberOfVertices",parser:l},{code:41,name:"textWidth",parser:l},{code:40,name:"textHeight",parser:l},{code:75,name:"isHooklineExists",parser:P},{code:74,name:"isHooklineSameDirection",parser:P},{code:73,name:"leaderCreationFlag",parser:l},{code:72,name:"isSpline",parser:P},{code:71,name:"isArrowheadEnabled",parser:P},{code:3,name:"styleName",parser:l},{code:100,name:"subclassMarker",parser:l},...F];class dh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){ch(this,"parser",E(lu,ou))}}ch(dh,"ForEntityName","LEADER");(it={})[it.TextAnnotation=0]="TextAnnotation",it[it.ToleranceAnnotation=1]="ToleranceAnnotation",it[it.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",it[it.NoAnnotation=3]="NoAnnotation";function uh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}let hu={thickness:0,extrusionDirection:{x:0,y:0,z:1}},cu=[{code:210,name:"extrusionDirection",parser:b},{code:11,name:"endPoint",parser:b},{code:10,name:"startPoint",parser:b},{code:39,name:"thickness",parser:l},{code:100,name:"subclassMarker",parser:l},...F];class gh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){uh(this,"parser",E(cu,hu))}}function ph(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}uh(gh,"ForEntityName","LINE");let du=[{code:280,name:"shadowMapSoftness",parser:l},{code:91,name:"shadowMapSize",parser:l},{code:73,name:"shadowType",parser:l},{code:293,name:"isShadowCast",parser:P},{code:51,name:"falloffAngle",parser:l},{code:50,name:"hotspotAngle",parser:l},{code:42,name:"limitEnd",parser:l},{code:41,name:"limitStart",parser:l},{code:292,name:"isAttenuationLimited",parser:P},{code:72,name:"attenuationType",parser:l},{code:11,name:"target",parser:b},{code:10,name:"position",parser:b},{code:40,name:"intensity",parser:l},{code:291,name:"isPlotGlyph",parser:P},{code:290,name:"isOn",parser:P},{code:421,name:"lightColorInstance",parser:l},{code:63,name:"lightColorIndex",parser:l},{code:70,name:"lightType",parser:l},{code:1,name:"name",parser:l},{code:90,name:"version",parser:l},{code:100,name:"subclassMarker",parser:l},...F];class mh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){ph(this,"parser",E(du))}}ph(mh,"ForEntityName","LIGHT");(jt={})[jt.Distant=1]="Distant",jt[jt.Point=2]="Point",jt[jt.Spot=3]="Spot";(Wt={})[Wt.None=0]="None",Wt[Wt.InverseLinear=1]="InverseLinear",Wt[Wt.InverseSquare=2]="InverseSquare";let uu={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},gu={bulge:0},pu=[{code:42,name:"bulge",parser:l},{code:41,name:"endWidth",parser:l},{code:40,name:"startWidth",parser:l},{code:91,name:"id",parser:l},{code:20,name:"y",parser:l},{code:10,name:"x",parser:l}],mu=[{code:210,name:"extrusionDirection",parser:b},{code:10,name:"vertices",isMultiple:!0,parser(n,e){let t={};return E(pu,gu)(n,e,t),t}},{code:39,name:"thickness",parser:l},{code:38,name:"elevation",parser:l},{code:43,name:"constantWidth",parser:l},{code:70,name:"flag",parser:l},{code:90,name:"numberOfVertices",parser:l},{code:100,name:"subclassMarker",parser:l},...F];class Cn{parseEntity(e,t){let i={};return E(mu,uu)(t,e,i),i}}(Ms="ForEntityName")in Cn?Object.defineProperty(Cn,Ms,{value:"LWPOLYLINE",enumerable:!0,configurable:!0,writable:!0}):Cn[Ms]="LWPOLYLINE";(Ei={})[Ei.IS_CLOSED=1]="IS_CLOSED",Ei[Ei.PLINE_GEN=128]="PLINE_GEN";function yh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}let yu=[{code:90,name:"overridenSubEntityCount",parser:l},{code:140,name:"edgeCreaseWeights",parser:l,isMultiple:!0},{code:95,name:"edgeCreaseCount",parser:l},{code:94,parser(n,e,t){t.edgeCount=n.value,t.edgeIndices=[];for(let i=0;i<t.edgeCount;++i){let s=[];n=e.next(),s[0]=n.value,n=e.next(),s[1]=n.value,t.edgeIndices.push(s)}}},{code:93,parser(n,e,t){t.totalFaceIndices=n.value,t.faceIndices=[];let i=[];for(let r=0;r<t.totalFaceIndices&&!O(n,0);++r)n=e.next(),i.push(n.value);let s=0;for(;s<i.length;){let r=i[s++],a=[];for(let o=0;o<r;++o)a.push(i[s++]);t.faceIndices.push(a)}}},{code:10,name:"vertices",parser:b,isMultiple:!0},{code:92,name:"verticesCount",parser:l},{code:91,name:"subdivisionLevel",parser:l},{code:40,name:"blendCrease",parser:l},{code:72,name:"isBlendCreased",parser:P},{code:71,name:"version",parser:l},{code:100,name:"subclassMarker",parser:dd,pushContext:!0},...F];class _h{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){yh(this,"parser",E(yu))}}function xh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}yh(_h,"ForEntityName","MESH");let _u=[{code:42,name:"fillParameters",parser:l,isMultiple:!0},{code:75,name:"fillCount",parser:l},{code:41,name:"parameters",parser:l,isMultiple:!0},{code:74,name:"parameterCount",parser:l}],xu=[{code:[74,41,75,42],name:"elements",parser(n,e){let t=E(_u),i={};return t(n,e,i),i},isMultiple:!0},{code:13,name:"miterDirection",parser:b},{code:12,name:"direction",parser:b},{code:11,name:"position",parser:b}],wu=[{code:[11,12,13],name:"segments",parser(n,e){let t=E(xu),i={};return t(n,e,i),i},isMultiple:!0},{code:210,name:"extrusionDirection",parser:b},{code:10,name:"startPosition",parser:b},{code:73,name:"styleCount",parser:l},{code:72,name:"vertexCount",parser:l},{code:71,name:"flags",parser:l},{code:70,name:"justification",parser:l},{code:40,name:"scale",parser:l},{code:340,name:"styleObjectHandle",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l,pushContext:!0},...F];class wh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){xh(this,"parser",E(wu))}}xh(wh,"ForEntityName","MLINE");(Gt={})[Gt.Top=0]="Top",Gt[Gt.Zero=1]="Zero",Gt[Gt.Bottom=2]="Bottom";(nt={})[nt.HasVertex=1]="HasVertex",nt[nt.Closed=2]="Closed",nt[nt.SuppressStartCaps=4]="SuppressStartCaps",nt[nt.SuppressEndCaps=8]="SuppressEndCaps";(Ht={})[Ht.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",Ht[Ht.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",Ht[Ht.BY_STYLE=5]="BY_STYLE";function fh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}let fu={},bu=[{code:300,parser:function(n,e,t){var r;let i;if(n.value==="CONTEXT_DATA{")for(;e.hasNext();){var s;if((i=e.next()).code===301)break;switch(i.code){case 10:t.contentBasePosition=re(i,e);break;case 11:t.normal=re(i,e);break;case 12:t.textAnchor=re(i,e);break;case 13:t.textDirection=re(i,e);break;case 14:lt(t).normal=re(i,e);break;case 15:lt(t).position=re(i,e);break;case 16:lt(t).scale=re(i,e);break;case 40:t.contentScale=i.value;break;case 41:case 44:t.textHeight=i.value;break;case 42:t.textRotation=i.value;break;case 43:t.textWidth=i.value;break;case 45:t.textLineSpacingFactor=i.value;break;case 46:lt(t).rotation=i.value;break;case 47:(s=lt(t)).transformationMatrix??(s.transformationMatrix=[]),(r=lt(t).transformationMatrix)==null||r.push(i.value);break;case 90:t.textColor=i.value;break;case 91:t.textBackgroundColor=i.value;break;case 92:t.textBackgroundTransparency=i.value;break;case 93:lt(t).color=i.value;break;case 110:t.planeOrigin=re(i,e);break;case 111:t.planeXAxisDirection=re(i,e);break;case 112:t.planeYAxisDirection=re(i,e);break;case 140:t.arrowheadSize=i.value;break;case 141:t.textBackgroundScaleFactor=i.value;break;case 142:t.textColumnWidth=i.value;break;case 143:t.textColumnGutterWidth=i.value;break;case 144:t.textColumnHeight=i.value;break;case 145:t.landingGap=i.value;break;case 170:t.textLineSpacingStyle=i.value;break;case 171:t.textAttachment=i.value;break;case 172:t.textFlowDirection=i.value;break;case 173:t.textColumnType=i.value;break;case 290:t.hasMText=i.value;break;case 291:t.textBackgroundColorOn=i.value;break;case 292:t.textFillOn=i.value;break;case 293:t.textUseAutoHeight=i.value;break;case 294:t.textColumnFlowReversed=i.value;break;case 295:t.textUseWordBreak=i.value;break;case 296:t.hasBlock=i.value;break;case 297:t.planeNormalReversed=i.value;break;case 302:i.value==="LEADER{"&&(t.leaderSections??(t.leaderSections=[]),t.leaderSections.push(function(a,o){let h,c;if(a.value!=="LEADER{")return{leaderLines:[]};let d={leaderLines:[]};for(;o.hasNext();){if((c=o.next()).code===303){Ln(d,h);break}switch(c.code){case 290:d.lastLeaderLinePointSet=c.value;break;case 291:d.doglegVectorSet=c.value;break;case 10:d.lastLeaderLinePoint=re(c,o);break;case 11:d.doglegVector=re(c,o);break;case 12:h??(h={}),h.start=re(c,o);break;case 13:h??(h={}),h.end=re(c,o),Ln(d,h),h=void 0;break;case 90:d.leaderBranchIndex=c.value;break;case 40:d.doglegLength=c.value;break;case 304:c.value==="LEADER_LINE{"&&d.leaderLines.push(function(u,p){let g,m;if(u.value!=="LEADER_LINE{")return{vertices:[]};let y={vertices:[]};for(;p.hasNext();){if((m=p.next()).code===305){Ln(y,g);break}switch(m.code){case 10:y.vertices.push(re(m,p));break;case 11:g??(g={}),g.start=re(m,p);break;case 12:g??(g={}),g.end=re(m,p),Ln(y,g),g=void 0;break;case 90:y.breakPointIndexes??(y.breakPointIndexes=[]),y.breakPointIndexes.push(m.value),g??(g={}),g.index=m.value;break;case 91:y.leaderLineIndex=m.value}}return y}(c,o))}}return d}(i,e)));break;case 304:i.value!=="LEADER_LINE{"&&(t.textContent=i.value,t.contentType??(t.contentType=2));break;case 340:t.textStyleId=i.value;break;case 341:t.blockContentId=i.value,lt(t).blockContentId=i.value}}}},{code:270,name:"version",parser:l},{code:340,name:"leaderStyleId",parser:l},{code:90,name:"propertyOverrideFlag",parser:l},{code:170,name:"leaderLineType",parser:l},{code:91,name:"leaderLineColor",parser:l},{code:341,name:"leaderLineTypeId",parser:l},{code:171,name:"leaderLineWeight",parser:l},{code:290,name:"landingEnabled",parser:P},{code:291,name:"doglegEnabled",parser:P},{code:[40,41],name:"doglegLength",parser:l},{code:342,name:"arrowheadId",parser:l},{code:42,name:"arrowheadSize",parser:l},{code:172,name:"contentType",parser:l},{code:343,name:"textStyleId",parser:l},{code:173,name:"textLeftAttachmentType",parser:l},{code:95,name:"textRightAttachmentType",parser:l},{code:174,name:"textAngleType",parser:l},{code:175,name:"textAlignmentType",parser:l},{code:92,name:"textColor",parser:l},{code:292,name:"textFrameEnabled",parser:P},{code:344,parser:function(n,e,t){t.blockContentId=n.value,lt(t).blockContentId=n.value}},{code:93,name:"blockContentColor",parser:l},{code:10,name:"blockContentScale",parser:b},{code:43,name:"blockContentRotation",parser:l},{code:176,name:"blockContentConnectionType",parser:l},{code:293,name:"annotativeScaleEnabled",parser:P},{code:94,parser:function(n,e,t){t.arrowheadOverrides??(t.arrowheadOverrides=[]),t.arrowheadOverrides.push({index:n.value})},isMultiple:!0},{code:345,parser:function(n,e,t){var i;((i=t).arrowheadOverrides??(i.arrowheadOverrides=[]),i.arrowheadOverrides.length||i.arrowheadOverrides.push({}),i.arrowheadOverrides[i.arrowheadOverrides.length-1]).handle=n.value},isMultiple:!0},{code:330,parser:function(n,e,t){t.blockAttributes??(t.blockAttributes=[]),t.blockAttributes.push({id:n.value})},isMultiple:!0},{code:177,parser:function(n,e,t){Ns(t).index=n.value},isMultiple:!0},{code:44,parser:function(n,e,t){Ns(t).width=n.value},isMultiple:!0},{code:302,parser:function(n,e,t){Ns(t).text=n.value},isMultiple:!0},{code:294,name:"textDirectionNegative",parser:P},{code:178,name:"textAlignInIPE",parser:l},{code:179,name:"textAttachmentPoint",parser:l},{code:271,name:"textAttachmentDirection",parser:l},{code:272,name:"bottomTextAttachmentDirection",parser:l},{code:273,name:"topTextAttachmentDirection",parser:l},{code:100,name:"subclassMarker",parser:l},...F];function re(n,e){return Qs(b(n,e))}function Ln(n,e){(e!=null&&e.start||e!=null&&e.end)&&(n.breaks??(n.breaks=[]),n.breaks.push(e))}function lt(n){return n.blockContent??(n.blockContent={})}function Ns(n){return n.blockAttributes??(n.blockAttributes=[]),n.blockAttributes.length||n.blockAttributes.push({}),n.blockAttributes[n.blockAttributes.length-1]}class bh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){fh(this,"parser",E(bu,fu))}}function Lh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}fh(bh,"ForEntityName","MULTILEADER");let Lu={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},Su=[{code:50,name:"angle",parser:l},{code:210,name:"extrusionDirection",parser:b},{code:39,name:"thickness",parser:l},{code:10,name:"position",parser:b},{code:100,name:"subclassMarker",parser:l},...F];class Sh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){Lh(this,"parser",E(Su,Lu))}}function Ih(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}Lh(Sh,"ForEntityName","POINT");let Iu={startWidth:0,endWidth:0,bulge:0},Au=[{code:91,name:"id",parser:l},{code:[...cs(71,75)],name:"faces",isMultiple:!0,parser:l},{code:50,name:"tangentDirection",parser:l},{code:70,name:"flag",parser:l},{code:42,name:"bulge",parser:l},{code:41,name:"endWidth",parser:l},{code:40,name:"startWidth",parser:l},{code:30,name:"z",parser:l},{code:20,name:"y",parser:l},{code:10,name:"x",parser:l},{code:100,name:"subclassMarker",parser:l},{code:100},...F];class Nr{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){Ih(this,"parser",E(Au,Iu))}}function Ah(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}Ih(Nr,"ForEntityName","VERTEX");let Pu={thickness:0,flag:0,startWidth:0,endWidth:0,meshMVertexCount:0,meshNVertexCount:0,surfaceMDensity:0,surfaceNDensity:0,smoothType:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},Eu=[{code:0,name:"vertices",isMultiple:!0,parser:(n,e)=>O(n,0,"VERTEX")?(n=e.next(),new Nr().parseEntity(e,n)):on},{code:210,name:"extrusionDirection",parser:b},{code:75,name:"smoothType",parser:l},{code:74,name:"surfaceNDensity",parser:l},{code:73,name:"surfaceMDensity",parser:l},{code:72,name:"meshNVertexCount",parser:l},{code:71,name:"meshMVertexCount",parser:l},{code:41,name:"endWidth",parser:l},{code:40,name:"startWidth",parser:l},{code:70,name:"flag",parser:l},{code:39,name:"thickness",parser:l},{code:30,name:"elevation",parser:l},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:l},...F];class Ph{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){Ah(this,"parser",E(Eu,Pu))}}Ah(Ph,"ForEntityName","POLYLINE");(ne={})[ne.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",ne[ne.CURVE_FIT=2]="CURVE_FIT",ne[ne.SPLINE_FIT=4]="SPLINE_FIT",ne[ne.POLYLINE_3D=8]="POLYLINE_3D",ne[ne.POLYGON_3D=16]="POLYGON_3D",ne[ne.CLOSED_POLYGON=32]="CLOSED_POLYGON",ne[ne.POLYFACE=64]="POLYFACE",ne[ne.CONTINUOUS=128]="CONTINUOUS";var Sn=((st={})[st.NONE=0]="NONE",st[st.QUADRATIC=5]="QUADRATIC",st[st.CUBIC=6]="CUBIC",st[st.BEZIER=8]="BEZIER",st);function Eh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}let Tu=[{code:11,name:"direction",parser:b},{code:10,name:"position",parser:b},{code:100,name:"subclassMarker",parser:l},...F];class Th{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){Eh(this,"parser",E(Tu))}}function Mh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}Eh(Th,"ForEntityName","RAY");let Mu=[...xs("data"),{code:70,name:"version",parser:l},{code:100,name:"subclassMarker",parser:l},...F];class kh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){Mh(this,"parser",E(Mu))}}function vh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}Mh(kh,"ForEntityName","REGION");let ku={vertices:[],backLineVertices:[]},vu=[{code:360,name:"geometrySettingHardId",parser:l},{code:12,name:"backLineVertices",isMultiple:!0,parser:b},{code:93,name:"numberOfBackLineVertices",parser:l},{code:11,name:"vertices",isMultiple:!0,parser:b},{code:92,name:"verticesCount",parser:l},{code:[63,411],name:"indicatorColor",parser:l},{code:70,name:"indicatorTransparency",parser:l},{code:41,name:"bottomHeight",parser:l},{code:40,name:"topHeight",parser:l},{code:10,name:"verticalDirection",parser:b},{code:1,name:"name",parser:l},{code:91,name:"flag",parser:l},{code:90,name:"state",parser:l},{code:100,name:"subclassMarker",parser:l},...F];class Ch{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){vh(this,"parser",E(vu,ku))}}function Oh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}vh(Ch,"ForEntityName","SECTION");let Cu={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},Ou=[{code:210,name:"extrusionDirection",parser:b},{code:39,name:"thickness",parser:l},{code:[...cs(10,14)],name:"points",isMultiple:!0,parser:b},{code:100,name:"subclassMarker",parser:l},...F];class Nh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){Oh(this,"parser",E(Ou,Cu))}}function Yh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}Oh(Nh,"ForEntityName","SOLID");let Nu=[{code:350,name:"historyObjectSoftId",parser:l},{code:100,name:"subclassMarker",parser:l},...xs("data"),{code:70,name:"version",parser:l},{code:100},...F];class Xh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){Yh(this,"parser",E(Nu))}}function Rh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}Yh(Xh,"ForEntityName","3DSOLID");let Yu={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},Xu=[{code:11,name:"fitPoints",isMultiple:!0,parser:b},{code:10,name:"controlPoints",isMultiple:!0,parser:b},{code:41,name:"weights",isMultiple:!0,parser:l},{code:40,name:"knots",isMultiple:!0,parser:l},{code:13,name:"endTangent",parser:b},{code:12,name:"startTangent",parser:b},{code:44,name:"fitTolerance",parser:l},{code:43,name:"controlTolerance",parser:l},{code:42,name:"knotTolerance",parser:l},{code:74,name:"numberOfFitPoints",parser:l},{code:73,name:"numberOfControlPoints",parser:l},{code:72,name:"numberOfKnots",parser:l},{code:71,name:"degree",parser:l},{code:70,name:"flag",parser:l},{code:210,name:"normal",parser:b},{code:100,name:"subclassMarker",parser:l},...F];class Bh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){Rh(this,"parser",E(Xu,Yu))}}Rh(Bh,"ForEntityName","SPLINE");(Ae={})[Ae.NONE=0]="NONE",Ae[Ae.CLOSED=1]="CLOSED",Ae[Ae.PERIODIC=2]="PERIODIC",Ae[Ae.RATIONAL=4]="RATIONAL",Ae[Ae.PLANAR=8]="PLANAR",Ae[Ae.LINEAR=16]="LINEAR";function Fh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}let Ru=[{code:280,name:"shadowMapSoftness",parser:l},{code:71,name:"shadowMapSize",parser:l},{code:70,name:"shadowType",parser:l},{code:292,name:"isSummerTime",parser:P},{code:92,name:"time",parser:l},{code:91,name:"julianDay",parser:l},{code:291,name:"hasShadow",parser:P},{code:40,name:"intensity",parser:l},{code:421,name:"lightColorInstance",parser:l},{code:63,name:"lightColorIndex",parser:l},{code:290,name:"isOn",parser:P},{code:90,name:"version",parser:l},{code:100,name:"subclassMarker",parser:l,pushContext:!0},...F.filter(n=>n.code!==100)];class Dh{parseEntity(e,t){let i={layer:""};return this.parser(t,e,i),i}constructor(){Fh(this,"parser",E(Ru))}}Fh(Dh,"ForEntityName","SUN");class On{parseEntity(e,t){let i={};for(;!e.isEOF();){if(t.code===0){e.rewind();break}switch(t.code){case 100:i.subclassMarker=t.value,t=e.next();break;case 2:i.name=t.value,t=e.next();break;case 5:i.handle=t.value,t=e.next();break;case 10:i.startPoint=Qs(Mt(e)),t=e.lastReadGroup;break;case 11:i.directionVector=Qs(Mt(e)),t=e.lastReadGroup;break;case 90:i.tableValue=t.value,t=e.next();break;case 91:i.rowCount=t.value,t=e.next();break;case 92:i.columnCount=t.value,t=e.next();break;case 93:i.overrideFlag=t.value,t=e.next();break;case 94:i.borderColorOverrideFlag=t.value,t=e.next();break;case 95:i.borderLineWeightOverrideFlag=t.value,t=e.next();break;case 96:i.borderVisibilityOverrideFlag=t.value,t=e.next();break;case 141:i.rowHeightArr??(i.rowHeightArr=[]),i.rowHeightArr.push(t.value),t=e.next();break;case 142:i.columnWidthArr??(i.columnWidthArr=[]),i.columnWidthArr.push(t.value),t=e.next();break;case 280:i.version=t.value,t=e.next();break;case 310:i.bmpPreview??(i.bmpPreview=""),i.bmpPreview+=t.value,t=e.next();break;case 330:i.ownerBlockRecordSoftId=t.value,t=e.next();break;case 342:i.tableStyleId=t.value,t=e.next();break;case 343:i.blockRecordHandle=t.value,t=e.next();break;case 170:i.attachmentPoint=t.value,t=e.next();break;case 171:i.cells??(i.cells=[]),i.cells.push(function(s,r){let a=!1,o=!1,h={};for(;!s.isEOF()&&r.code!==0&&!o;)switch(r.code){case 171:if(a){o=!0;continue}h.cellType=r.value,a=!0,r=s.next();break;case 172:h.flagValue=r.value,r=s.next();break;case 173:h.mergedValue=r.value,r=s.next();break;case 174:h.autoFit=r.value,r=s.next();break;case 175:h.borderWidth=r.value,r=s.next();break;case 176:h.borderHeight=r.value,r=s.next();break;case 91:h.overrideFlag=r.value,r=s.next();break;case 178:h.virtualEdgeFlag=r.value,r=s.next();break;case 145:h.rotation=r.value,r=s.next();break;case 345:h.fieldObjetId=r.value,r=s.next();break;case 340:h.blockTableRecordId=r.value,r=s.next();break;case 146:h.blockScale=r.value,r=s.next();break;case 177:h.blockAttrNum=r.value,r=s.next();break;case 7:h.textStyle=r.value,r=s.next();break;case 140:h.textHeight=r.value,r=s.next();break;case 170:h.attachmentPoint=r.value,r=s.next();break;case 92:h.extendedCellFlags=r.value,r=s.next();break;case 285:h.rightBorderVisibility=!!(r.value??!0),r=s.next();break;case 286:h.bottomBorderVisibility=!!(r.value??!0),r=s.next();break;case 288:h.leftBorderVisibility=!!(r.value??!0),r=s.next();break;case 289:h.topBorderVisibility=!!(r.value??!0),r=s.next();break;case 301:(function(c,d,u){for(;u.code!==304;)switch(u.code){case 301:case 93:case 90:case 94:u=d.next();break;case 1:c.text=u.value,u=d.next();break;case 300:c.attrText=u.value,u=d.next();break;case 302:c.text=u.value?u.value:c.text,u=d.next();break;default:u=d.next()}})(h,s,r),r=s.next();break;default:return h}return a=!1,o=!1,h}(e,t)),t=e.lastReadGroup;break;default:Nd(i,t,e),t=e.next()}}return i}}function zh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}(ks="ForEntityName")in On?Object.defineProperty(On,ks,{value:"ACAD_TABLE",enumerable:!0,configurable:!0,writable:!0}):On[ks]="ACAD_TABLE";let Bu=[{code:11,name:"xAxisDirection",parser:b},{code:210,name:"extrusionDirection",parser:b},{code:1,name:"text",parser:l},{code:10,name:"position",parser:b},{code:3,name:"styleName",parser:l},{code:100,name:"subclassMarker",parser:l},...F];class Vh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){zh(this,"parser",E(Bu))}}zh(Vh,"ForEntityName","TOLERANCE");var Fu=((se={})[se.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",se[se.TANGENT_DEFINED=2]="TANGENT_DEFINED",se[se.NOT_USED=4]="NOT_USED",se[se.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",se[se.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",se[se.FOR_POLYLINE=32]="FOR_POLYLINE",se[se.FOR_POLYGON=64]="FOR_POLYGON",se[se.POLYFACE=128]="POLYFACE",se);let Du=[{code:[335,343,344,91],name:"softPointers",isMultiple:!0,parser:l},{code:361,name:"sunId",parser:l},{code:431,name:"ambientLightColorName",parser:l},{code:421,name:"ambientLightColorInstance",parser:l},{code:63,name:"ambientLightColorIndex",parser:l},{code:142,name:"contrast",parser:l},{code:141,name:"brightness",parser:l},{code:282,name:"defaultLightingType",parser:l},{code:292,name:"isDefaultLighting",parser:P},{code:348,name:"visualStyleId",parser:l},{code:333,name:"shadePlotId",parser:l},{code:332,name:"backgroundId",parser:l},{code:61,name:"majorGridFrequency",parser:l},{code:170,name:"shadePlotMode",parser:l},{code:146,name:"elevation",parser:l},{code:79,name:"orthographicType",parser:l},{code:346,name:"ucsBaseId",parser:l},{code:345,name:"ucsId",parser:l},{code:112,name:"ucsYAxis",parser:b},{code:111,name:"ucsXAxis",parser:b},{code:110,name:"ucsOrigin",parser:b},{code:74,name:"iconFlag",parser:l},{code:71,name:"ucsPerViewport",parser:l},{code:281,name:"renderMode",parser:l},{code:1,name:"sheetName",parser:l},{code:340,name:"clippingBoundaryId",parser:l},{code:90,name:"statusBitFlags",parser:l},{code:331,name:"frozenLayerIds",isMultiple:!0,parser:l},{code:72,name:"circleZoomPercent",parser:l},{code:51,name:"viewTwistAngle",parser:l},{code:50,name:"snapAngle",parser:l},{code:45,name:"viewHeight",parser:l},{code:44,name:"backClipZ",parser:l},{code:43,name:"frontClipZ",parser:l},{code:42,name:"perspectiveLensLength",parser:l},{code:17,name:"targetPoint",parser:b},{code:16,name:"viewDirection",parser:b},{code:15,name:"gridSpacing",parser:b},{code:14,name:"snapSpacing",parser:b},{code:13,name:"snapBase",parser:b},{code:12,name:"displayCenter",parser:b},{code:69,name:"viewportId",parser:l},{code:68,name:"status",parser:l},{code:41,name:"height",parser:l},{code:40,name:"width",parser:l},{code:10,name:"viewportCenter",parser:b},{code:100,name:"subclassMarker",parser:l,pushContext:!0},...F];class Nn{parseEntity(e,t){let i={};return E(Du)(t,e,i),i}}function jh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}(vs="ForEntityName")in Nn?Object.defineProperty(Nn,vs,{value:"VIEWPORT",enumerable:!0,configurable:!0,writable:!0}):Nn[vs]="VIEWPORT";let zu={brightness:50,constrast:50,fade:0},Vu=[{code:14,name:"boundary",isMultiple:!0,parser:b},{code:91,name:"numberOfVertices",parser:l},{code:71,name:"boundaryType",parser:l},{code:360,name:"imageDefReactorHardId",parser:l},{code:283,name:"fade",parser:l},{code:282,name:"contrast",parser:l},{code:281,name:"brightness",parser:l},{code:280,name:"isClipping",parser:P},{code:70,name:"displayFlag",parser:l},{code:340,name:"imageDefHardId",parser:l},{code:13,name:"imageSize",parser:b},{code:12,name:"vDirection",parser:b},{code:11,name:"uDirection",parser:b},{code:10,name:"position",parser:b},{code:90,name:"classVersion",parser:l},{code:100,name:"subclassMarker",parser:l},...F];class Wh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){jh(this,"parser",E(Vu,zu))}}jh(Wh,"ForEntityName","WIPEOUT");(rt={})[rt.ShowImage=1]="ShowImage",rt[rt.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",rt[rt.UseClippingBoundary=4]="UseClippingBoundary",rt[rt.Transparency=8]="Transparency";function Gh(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}let ju=[{code:11,name:"direction",parser:b},{code:10,name:"position",parser:b},{code:100,name:"subclassMarker",parser:l},...F];class Hh{parseEntity(e,t){let i={};return this.parser(t,e,i),i}constructor(){Gh(this,"parser",E(ju))}}Gh(Hh,"ForEntityName","XLINE");let Wu=0;function Uh(n){if(!n)throw TypeError("entity cannot be undefined or null");n.handle||(n.handle=Wu++)}let Gu=Object.fromEntries([Rl,kn,Wl,$l,Zl,Jl,Mn,eh,ih,oh,hh,dh,gh,mh,Cn,_h,wh,Hl,bh,Sh,Ph,Th,kh,Ch,Nh,Xh,Bh,Dh,On,Vl,Vh,rh,Nr,Nn,Wh,Hh].map(n=>[n.ForEntityName,new n]));function $h(n,e){let t=[];for(;!O(n,0,"EOF");){if(n.code===0){if(n.value==="ENDBLK"||n.value==="ENDSEC"){e.rewind();break}let i=Gu[n.value];if(i){let s=n.value;n=e.next();let r=i.parseEntity(e,n);r.type=s,Uh(r),t.push(r)}else e.debug}n=e.next()}return t}function Mi(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}class za{next(){if(!this.hasNext())return this._eof?this.debug:this.debug,{code:0,value:"EOF"};let e=parseInt(this._data[this._pointer++],10),t=Va(e,this._data[this._pointer++],this.debug),i={code:e,value:t};return O(i,0,"EOF")&&(this._eof=!0),this.lastReadGroup=i,i}peek(){if(!this.hasNext())throw this._eof?Error("Cannot call 'next' after EOF group has been read"):Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);let e={code:parseInt(this._data[this._pointer]),value:0};return e.value=Va(e.code,this._data[this._pointer+1],this.debug),e}rewind(e){e=e||1,this._pointer=this._pointer-2*e}hasNext(){return!this._eof&&!(this._pointer>this._data.length-2)}isEOF(){return this._eof}constructor(e,t=!1){Mi(this,"_data",void 0),Mi(this,"debug",void 0),Mi(this,"_pointer",void 0),Mi(this,"_eof",void 0),Mi(this,"lastReadGroup",void 0),this._data=e,this.debug=t,this.lastReadGroup={code:0,value:0},this._pointer=0,this._eof=!1}}function Va(n,e,t=!1){var i;let s=(i=e).endsWith("\r")?i.slice(0,-1):i;return n<=9?s:n>=10&&n<=59?parseFloat(e.trim()):n>=60&&n<=99?parseInt(e.trim()):n>=100&&n<=109?s:n>=110&&n<=149?parseFloat(e.trim()):n>=160&&n<=179?parseInt(e.trim()):n>=210&&n<=239?parseFloat(e.trim()):n>=270&&n<=289?parseInt(e.trim()):n>=290&&n<=299?function(r){if(r==="0")return!1;if(r==="1")return!0;throw TypeError("String '"+r+"' cannot be cast to Boolean type")}(e.trim()):n>=300&&n<=369?s:n>=370&&n<=389?parseInt(e.trim()):n>=390&&n<=399?s:n>=400&&n<=409?parseInt(e.trim()):n>=410&&n<=419?s:n>=420&&n<=429?parseInt(e.trim()):n>=430&&n<=439?s:n>=440&&n<=459?parseInt(e.trim()):n>=460&&n<=469?parseFloat(e.trim()):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?s:n>=1010&&n<=1059?parseFloat(e.trim()):n>=1060&&n<=1071?parseInt(e.trim()):s}function Hu(n,e){let t=null,i={};for(;!O(n,0,"EOF")&&!O(n,0,"ENDSEC");)n.code===9?t=typeof n.value=="string"?n.value:null:t!=null&&(n.code===10?i[t]=Mt(e):i[t]=n.value),n=e.next();return i}let yt=[{code:100,name:"subclassMarker",parser:l},{code:330,name:"ownerObjectId",parser:l},{code:102,isMultiple:!0,parser(n,e){for(;!O(n,0,"EOF")&&!O(n,102,"}");)n=e.next()}},{code:5,name:"handle",parser:l}],Uu=[{code:70,name:"flag",parser:l},{code:2,name:"appName",parser:l},{code:100,name:"subclassMarker",parser:l},...yt],$u=E(Uu),qu=E([{code:310,name:"bmpPreview",parser:l},{code:281,name:"scalability",parser:l},{code:280,name:"explodability",parser:l},{code:70,name:"insertionUnits",parser:l},{code:340,name:"layoutObjects",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...yt]),Zu=E([...Or.map(n=>({...n,parser:l})),{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},{code:105,name:"handle",parser:l},...yt.filter(n=>n.code!==5)]),Ku=E([{code:347,name:"materialObjectId",parser:l},{code:390,name:"plotStyleNameObjectId",parser:l},{code:370,name:"lineweight",parser:l},{code:290,name:"isPlotting",parser:P},{code:6,name:"lineType",parser:l},{code:62,name:"colorIndex",parser:l},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...yt]),Ju=E([{code:9,name:"text",parser:l},{code:45,name:"offsetY",parser:l},{code:44,name:"offsetX",parser:l},{code:50,name:"rotation",parser:l},{code:46,name:"scale",parser:l},{code:340,name:"styleObjectId",parser:l},{code:75,name:"shapeNumber",parser:l},{code:74,name:"elementTypeFlag",parser:l},{code:49,name:"elementLength",parser:l}],{elementTypeFlag:0,elementLength:0}),Qu=E([{code:49,name:"pattern",parser(n,e){let t={};return Ju(n,e,t),t},isMultiple:!0},{code:40,name:"totalPatternLength",parser:l},{code:73,name:"numberOfLineTypes",parser:l},{code:72,parser:l},{code:3,name:"description",parser:l},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...yt]),eg=E([{code:1e3,name:"extendedFont",parser:l},{code:1001},{code:4,name:"bigFont",parser:l},{code:3,name:"font",parser:l},{code:42,name:"lastHeight",parser:l},{code:71,name:"textGenerationFlag",parser:l},{code:50,name:"obliqueAngle",parser:l},{code:41,name:"widthFactor",parser:l},{code:40,name:"fixedTextHeight",parser:l},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...yt]),tg=[{code:13,name:"orthographicOrigin",parser:b},{code:71,name:"orthographicType",parser:l},{code:346,name:"baseUcsHandle",parser:l},{code:146,name:"elevation",parser:l},{code:79,name:"isOrthographic",parser:P},{code:12,name:"yAxis",parser:b},{code:11,name:"xAxis",parser:b},{code:10,name:"origin",parser:b},{code:70,name:"flag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...yt],ig=E(tg),ng=[{code:346,name:"baseUcsId",parser:l},{code:345,name:"ucsId",parser:l},{code:146,name:"elevation",parser:l},{code:79,name:"orthographicType",parser:l},{code:112,name:"ucsYAxis",parser:b},{code:111,name:"ucsXAxis",parser:b},{code:110,name:"ucsOrigin",parser:b},{code:361,name:"sunHardId",parser:l},{code:348,name:"styleHardId",parser:l},{code:334,name:"liveSectionSoftId",parser:l},{code:332,name:"backgroundSoftId",parser:l},{code:73,name:"isPlottable",parser:P},{code:72,name:"isUcsAssociated",parser:P},{code:281,name:"renderMode",parser:l},{code:71,name:"viewMode",parser:l},{code:50,name:"twistAngle",parser:l},{code:44,name:"backClippingPlane",parser:l},{code:43,name:"frontClippingPlane",parser:l},{code:42,name:"lensLength",parser:l},{code:12,name:"target",parser:b},{code:11,name:"direction",parser:b},{code:10,name:"center",parser:b},{code:41,name:"width",parser:l},{code:40,name:"height",parser:l},{code:70,name:"flag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...yt],sg=E(ng),rg=E([{code:[63,421,431],name:"ambientColor",parser:l},{code:142,name:"contrast",parser:l},{code:141,name:"brightness",parser:l},{code:282,name:"defaultLightingType",parser:l},{code:292,name:"isDefaultLightingOn",parser:P},{code:348,name:"visualStyleObjectId",parser:l},{code:333,name:"shadePlotObjectId",parser:l},{code:332,name:"backgroundObjectId",parser:l},{code:61,name:"majorGridLines",parser:l},{code:170,name:"shadePlotSetting",parser:l},{code:146,name:"elevation",parser:l},{code:79,name:"orthographicType",parser:l},{code:112,name:"ucsYAxis",parser:b},{code:111,name:"ucsXAxis",parser:b},{code:110,name:"ucsOrigin",parser:b},{code:74,name:"ucsIconSetting",parser:l},{code:71,name:"viewMode",parser:l},{code:281,name:"renderMode",parser:l},{code:1,name:"styleSheet",parser:l},{code:[331,441],name:"frozenLayers",parser:l,isMultiple:!0},{code:72,name:"circleSides",parser:l},{code:51,name:"viewTwistAngle",parser:l},{code:50,name:"snapRotationAngle",parser:l},{code:45,name:"viewHeight",parser:l},{code:44,name:"backClippingPlane",parser:l},{code:43,name:"frontClippingPlane",parser:l},{code:42,name:"lensLength",parser:l},{code:17,name:"viewTarget",parser:b},{code:16,name:"viewDirectionFromTarget",parser:b},{code:15,name:"gridSpacing",parser:b},{code:14,name:"snapSpacing",parser:b},{code:13,name:"snapBasePoint",parser:b},{code:12,name:"center",parser:b},{code:11,name:"upperRightCorner",parser:b},{code:10,name:"lowerLeftCorner",parser:b},{code:70,name:"standardFlag",parser:l},{code:2,name:"name",parser:l},{code:100,name:"subclassMarker",parser:l},...yt]),ag={APPID:$u,BLOCK_RECORD:qu,DIMSTYLE:Zu,LAYER:Ku,LTYPE:Qu,STYLE:eg,UCS:ig,VIEW:sg,VPORT:rg},og=E([{code:70,name:"maxNumberOfEntries",parser:l},{code:100,name:"subclassMarker",parser:l},{code:330,name:"ownerObjectId",parser:l},{code:102,parser:Ge},{code:102,parser:Ge},{code:102,parser:Ge},{code:360,isMultiple:!0},{code:5,name:"handle",parser:l},{code:2,name:"name",parser:l}]);function lg(n,e){var i;let t={};for(;!O(n,0,"EOF")&&!O(n,0,"ENDSEC");){if(O(n,0,"TABLE")){n=e.next();let s={entries:[]};og(n,e,s),t[s.name]=s}if(O(n,0)&&!O(n,0,"ENDTAB")){let s=n.value;n=e.next();let r=ag[s];if(!r){e.debug,n=e.next();continue}let a={};r(n,e,a),(i=t[s])==null||i.entries.push(a)}n=e.next()}return t}function hg(n,e){let t={};for(;!O(n,0,"EOF")&&!O(n,0,"ENDSEC");){if(O(n,0,"BLOCK")){let i=cg(n=e.next(),e);Uh(i),i.name&&(t[i.name]=i)}n=e.next()}return t}function cg(n,e){let t={};for(;!O(n,0,"EOF");){if(O(n,0,"ENDBLK")){for(n=e.next();!O(n,0,"EOF");){if(O(n,100,"AcDbBlockEnd"))return t;n=e.next()}break}switch(n.code){case 1:t.xrefPath=n.value;break;case 2:t.name=n.value;break;case 3:t.name2=n.value;break;case 5:t.handle=n.value;break;case 8:t.layer=n.value;break;case 10:t.position=Mt(e);break;case 67:t.paperSpace=!!n.value&&n.value==1;break;case 70:n.value!==0&&(t.type=n.value);break;case 100:break;case 330:t.ownerHandle=n.value;break;case 0:t.entities=$h(n,e)}n=e.next()}return t}let _t=[{code:330,name:"ownerObjectId",parser:l},{code:102,parser:Ge},{code:102,parser:Ge},{code:102,parser:Ge},{code:5,name:"handle",parser:l}],qh=[{code:333,name:"shadePlotId",parser:l},{code:149,name:"imageOriginY",parser:l},{code:148,name:"imageOriginX",parser:l},{code:147,name:"scaleFactor",parser:l},{code:78,name:"shadePlotCustomDPI",parser:l},{code:77,name:"shadePlotResolution",parser:l},{code:76,name:"shadePlotMode",parser:l},{code:75,name:"standardScaleType",parser:l},{code:7,name:"currentStyleSheet",parser:l},{code:74,name:"plotType",parser:l},{code:73,name:"plotRotation",parser:l},{code:72,name:"plotPaperUnit",parser:l},{code:70,name:"layoutFlag",parser:l},{code:143,name:"printScaleDenominator",parser:l},{code:142,name:"printScaleNumerator",parser:l},{code:141,name:"windowAreaYMax",parser:l},{code:140,name:"windowAreaXMax",parser:l},{code:49,name:"windowAreaYMin",parser:l},{code:48,name:"windowAreaXMin",parser:l},{code:47,name:"plotOriginY",parser:l},{code:46,name:"plotOriginX",parser:l},{code:45,name:"paperHeight",parser:l},{code:44,name:"paperWidth",parser:l},{code:43,name:"marginTop",parser:l},{code:42,name:"marginRight",parser:l},{code:41,name:"marginBottom",parser:l},{code:40,name:"marginLeft",parser:l},{code:6,name:"plotViewName",parser:l},{code:4,name:"paperSize",parser:l},{code:2,name:"configName",parser:l},{code:1,name:"pageSetupName",parser:l},{code:100,name:"subclassMarker",parser:l},..._t],dg=[{code:346,name:"orthographicUcsId",parser:l},{code:345,name:"namedUcsId",parser:l},{code:331,name:"viewportId",parser:l},{code:330,name:"paperSpaceTableId",parser:l},{code:76,name:"orthographicType",parser:l},{code:17,name:"ucsYAxis",parser:b},{code:16,name:"ucsXAxis",parser:b},{code:13,name:"ucsOrigin",parser:b},{code:146,name:"elevation",parser:l},{code:15,name:"maxExtent",parser:b},{code:14,name:"minExtent",parser:b},{code:12,name:"insertionPoint",parser:b},{code:11,name:"maxLimit",parser:b},{code:10,name:"minLimit",parser:b},{code:71,name:"tabOrder",parser:l},{code:70,name:"controlFlag",parser:l},{code:1,name:"layoutName",parser:l},{code:100,name:"subclassMarker",parser:l},...qh],ug=[{code:3,name:"entries",parser:(n,e)=>{let t={name:n.value};return(n=e.next()).code===350?t.objectSoftId=n.value:n.code===360?t.objectHardId=n.value:e.rewind(),t},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:l},{code:280,name:"isHardOwned",parser:P},{code:100,name:"subclassMarker",parser:l},..._t],gg=[{code:40,name:"wcsToOCSTransform",parser:ja},{code:40,name:"ocsToWCSTransform",parser:ja},{code:41,name:"backClippingDistance",parser:l},{code:73,name:"isBackClipping",parser:P,pushContext:!0},{code:40,name:"frontClippingDistance",parser:l},{code:72,name:"isFrontClipping",parser:P,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:P},{code:11,name:"position",parser:b},{code:210,name:"normal",parser:b},{code:10,name:"boundaryVertices",parser:b,isMultiple:!0},{code:70,name:"boundaryCount",parser:l},{code:100,name:"subclassMarker",parser:l},{code:100},..._t];function ja(n,e){let t=[];for(let i=0;i<3&&O(n,40);++i){let s=[];for(let r=0;r<4&&O(n,40);++r)s.push(n.value),n=e.next();t.push(s)}return e.rewind(),t}let pg=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:l},{code:90,name:"version",parser:l},{code:1,name:"fileName",parser:l},{code:10,name:"size",parser:b},{code:11,name:"sizeOfOnePixel",parser:b},{code:280,name:"isLoaded",parser:l},{code:281,name:"resolutionUnits",parser:l},{code:100,name:"subclassMarker",parser:l}],mg=[{code:179,name:"unknown1",parser:l},{code:170,name:"contentType",parser:l},{code:171,name:"drawMLeaderOrderType",parser:l},{code:172,name:"drawLeaderOrderType",parser:l},{code:90,name:"maxLeaderSegmentPoints",parser:l},{code:40,name:"firstSegmentAngleConstraint",parser:l},{code:41,name:"secondSegmentAngleConstraint",parser:l},{code:173,name:"leaderLineType",parser:l},{code:91,name:"leaderLineColor",parser:l},{code:340,name:"leaderLineTypeId",parser:l},{code:92,name:"leaderLineWeight",parser:l},{code:290,name:"landingEnabled",parser:P},{code:42,name:"landingGap",parser:l},{code:291,name:"doglegEnabled",parser:P},{code:43,name:"doglegLength",parser:l},{code:3,name:"description",parser:l},{code:341,name:"arrowheadId",parser:l},{code:44,name:"arrowheadSize",parser:l},{code:300,name:"defaultMTextContents",parser:l},{code:342,name:"textStyleId",parser:l},{code:174,name:"textLeftAttachmentType",parser:l},{code:175,name:"textAngleType",parser:l},{code:176,name:"textAlignmentType",parser:l},{code:178,name:"textRightAttachmentType",parser:l},{code:93,name:"textColor",parser:l},{code:45,name:"textHeight",parser:l},{code:292,name:"textFrameEnabled",parser:P},{code:297,name:"textAlignAlwaysLeft",parser:P},{code:46,name:"alignSpace",parser:l},{code:343,name:"blockContentId",parser:l},{code:94,name:"blockContentColor",parser:l},{code:47,name:"blockContentScale.x",parser:l},{code:49,name:"blockContentScale.y",parser:l},{code:140,name:"blockContentScale.z",parser:l},{code:293,name:"blockContentScaleEnabled",parser:P},{code:141,name:"blockContentRotation",parser:l},{code:294,name:"blockContentRotationEnabled",parser:P},{code:177,name:"blockContentConnectionType",parser:l},{code:142,name:"scale",parser:l},{code:295,name:"overwritePropertyValue",parser:P},{code:296,name:"annotative",parser:P},{code:143,name:"breakGapSize",parser:l},{code:271,name:"textAttachmentDirection",parser:l},{code:272,name:"bottomTextAttachmentDirection",parser:l},{code:273,name:"topTextAttachmentDirection",parser:l},{code:298,name:"unknown2",parser:l},{code:100,name:"subclassMarker",parser:l},..._t];function In(n,e,t){n.elements||(n.elements=[]);let i=n.elements.find(s=>s[e]===void 0);if(i){i[e]=t;return}n.elements.push({[e]:t})}let yg=[{code:6,parser:function({value:n},e,t){In(t,"lineType",n)},isMultiple:!0},{code:62,parser:function({value:n},e,t){var i;if(t.fillColorIndex===void 0&&!((i=t.elements)!=null&&i.length)){t.fillColorIndex=n;return}In(t,"colorIndex",n)},isMultiple:!0},{code:420,parser:function({value:n},e,t){var i;if(t.fillColor===void 0&&!((i=t.elements)!=null&&i.length)){t.fillColor=n;return}In(t,"color",n)},isMultiple:!0},{code:49,parser:function({value:n},e,t){In(t,"offset",n)},isMultiple:!0},{code:71,name:"elementCount",parser:l},{code:52,name:"endAngle",parser:l},{code:51,name:"startAngle",parser:l},{code:3,name:"description",parser:l},{code:70,name:"flags",parser:l},{code:2,name:"styleName",parser:l},{code:100,name:"subclassMarker",parser:l},..._t],_g=[{code:340,name:"entityIds",parser:l,isMultiple:!0},{code:71,name:"isSelectable",parser:P},{code:70,name:"isUnnamed",parser:P},{code:300,name:"description",parser:l},{code:100,name:"subclassMarker",parser:l},..._t],xg=[{code:8,name:"layerNames",parser:l,isMultiple:!0},{code:100,name:"subclassMarker",parser:l},{code:100,name:"filterSubclassMarker",parser:l},..._t],wg=[{code:90,name:"idBufferEntryCounts",parser:l,isMultiple:!0},{code:360,name:"idBufferIds",parser:l,isMultiple:!0},{code:8,name:"layerNames",parser:l,isMultiple:!0},{code:100,name:"subclassMarker",parser:l},{code:40,name:"timeStamp",parser:l},{code:100,name:"indexSubclassMarker",parser:l},..._t],fg=[{code:75,name:"hasLastPointRef",parser:P},{code:1,name:"pointRefs",parser:function(n,e){let t={className:n.value};for(;;)switch((n=e.next()).code){case 72:t.objectOsnapType=n.value;continue;case 331:t.mainObjectId=n.value;continue;case 73:t.mainObjectSubentityType=n.value;continue;case 91:t.mainObjectGsMarker=n.value;continue;case 301:t.mainObjectXrefHandle=n.value;continue;case 40:t.nearOsnapGeometryParameter=n.value;continue;case 10:{let i=b(n,e);t.osnapPoint="z"in i?i:{...i,z:0}}continue;case 332:t.intersectionObjectId=n.value;continue;case 74:t.intersectionObjectSubentityType=n.value;continue;case 92:t.intersectionObjectGsMarker=n.value;continue;case 302:t.intersectionObjectXrefHandle=n.value;continue;default:return e.rewind(),t}},isMultiple:!0},{code:71,name:"rotatedDimensionType",parser:l},{code:70,name:"transSpaceFlag",parser:P},{code:90,name:"associativityFlag",parser:l},{code:330,name:"dimensionObjectId",parser:l},{code:100,name:"subclassMarker",parser:l},..._t],bg={LAYOUT:dg,PLOTSETTINGS:qh,DICTIONARY:ug,SPATIAL_FILTER:gg,IMAGEDEF:pg,MLEADERSTYLE:mg,MLINESTYLE:yg,GROUP:_g,LAYER_FILTER:xg,LAYER_INDEX:wg,DIMASSOC:fg};function Lg(n,e){let t=[];for(;n.code!==0||!["EOF","ENDSEC"].includes(n.value);){let i=n.value,s=bg[i];if(n.code===0&&(s!=null&&s.length)){let r=E(s),a={name:i};r(n=e.next(),e,a)?(t.push(a),n=e.peek()):n=e.next()}else n=e.next()}return{byName:kd(t,({name:i})=>i)}}function Di(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}class Sg{constructor(){Di(this,"encoding","utf-8"),Di(this,"encodingFailureFatal",!1),Di(this,"thumbnailImageFormat","base64")}}class Ig extends EventTarget{parseSync(e,t=!1){let i=new za(e.split(/\r\n|\r|\n/g),t);if(!i.hasNext())throw Error("Empty file");return this.parseAll(i)}parseStream(e){let t="",i=this;return new Promise((s,r)=>{e.on("data",a=>{t+=a}),e.on("end",()=>{try{let a=t.split(/\r\n|\r|\n/g),o=new za(a);if(!o.hasNext())throw Error("Empty file");s(i.parseAll(o))}catch(a){r(a)}}),e.on("error",a=>{r(a)})})}async parseFromUrl(e,t){let i=await fetch(e,t);if(!i.body)return null;let s=i.body.getReader(),r="";for(;;){let{done:a,value:o}=await s.read();if(a){r+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}r+=this._decoder.decode(o,{stream:!0})}return this.parseSync(r)}parseAll(e){let t={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},i=e.next();for(;!O(i,0,"EOF");)O(i,0,"SECTION")&&(O(i=e.next(),2,"HEADER")?t.header=Hu(i=e.next(),e):O(i,2,"CLASSES")?md(i=e.next(),e,t):O(i,2,"BLOCKS")?t.blocks=hg(i=e.next(),e):O(i,2,"ENTITIES")?t.entities=$h(i=e.next(),e):O(i,2,"TABLES")?t.tables=lg(i=e.next(),e):O(i,2,"OBJECTS")?t.objects=Lg(i=e.next(),e):O(i,2,"THUMBNAILIMAGE")&&(t.thumbnailImage=function(s,r,a="base64"){let o,h="",c=0;for(;!O(s,0,"EOF")&&!O(s,0,"ENDSEC");)s.code===90?c=s.value:s.code===310&&(h+=s.value),s=r.next();if(a==="hex")o=h;else{let d=function(u){let p=u.length/2,g=new Uint8Array(p);for(let m=0;m<p;m++)g[m]=parseInt(u.substr(2*m,2),16);return g}(h);o=a==="buffer"?d:function(u){let p="";for(let g=0;g<u.length;g++)p+=String.fromCharCode(u[g]);return btoa(p)}(d)}return{size:c,data:o}}(i=e.next(),e,this._options.thumbnailImageFormat))),i=e.next();return t}constructor(e={}){super(),Di(this,"_decoder",void 0),Di(this,"_options",void 0);let t=new Sg;this._options=Object.assign(t,e),this._decoder=new TextDecoder(this._options.encoding,{fatal:this._options.encodingFailureFatal})}}(Pe={})[Pe.NOT_APPLICABLE=0]="NOT_APPLICABLE",Pe[Pe.KEEP_EXISTING=1]="KEEP_EXISTING",Pe[Pe.USE_CLONE=2]="USE_CLONE",Pe[Pe.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",Pe[Pe.VALUE_NAME=4]="VALUE_NAME",Pe[Pe.UNMANGLE_NAME=5]="UNMANGLE_NAME";(Ut={})[Ut.NOUNIT=0]="NOUNIT",Ut[Ut.CENTIMETERS=2]="CENTIMETERS",Ut[Ut.INCH=5]="INCH";(Ti={})[Ti.PSLTSCALE=1]="PSLTSCALE",Ti[Ti.LIMCHECK=2]="LIMCHECK";($t={})[$t.INCHES=0]="INCHES",$t[$t.MILLIMETERS=1]="MILLIMETERS",$t[$t.PIXELS=2]="PIXELS";(Ee={})[Ee.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",Ee[Ee.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",Ee[Ee.DRAWING_LIMITS=2]="DRAWING_LIMITS",Ee[Ee.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",Ee[Ee.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",Ee[Ee.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(at={})[at.AS_DISPLAYED=0]="AS_DISPLAYED",at[at.WIREFRAME=1]="WIREFRAME",at[at.HIDDEN=2]="HIDDEN",at[at.RENDERED=3]="RENDERED";(Te={})[Te.DRAFT=0]="DRAFT",Te[Te.PREVIEW=1]="PREVIEW",Te[Te.NORMAL=2]="NORMAL",Te[Te.PRESENTATION=3]="PRESENTATION",Te[Te.MAXIMUM=4]="MAXIMUM",Te[Te.CUSTOM=5]="CUSTOM";(ot={})[ot.NONE=0]="NONE",ot[ot.AbsoluteRotation=1]="AbsoluteRotation",ot[ot.TextEmbedded=2]="TextEmbedded",ot[ot.ShapeEmbedded=4]="ShapeEmbedded";(Cs={})[Cs.PaperSpace=1]="PaperSpace";(qt={})[qt.XrefDependent=16]="XrefDependent",qt[qt.XrefResolved=32]="XrefResolved",qt[qt.Referenced=64]="Referenced";(Me={})[Me.Off=0]="Off",Me[Me.Perspective=1]="Perspective",Me[Me.ClipFront=2]="ClipFront",Me[Me.ClipBack=4]="ClipBack",Me[Me.UcsFollow=8]="UcsFollow",Me[Me.ClipFrontByFrontZ=16]="ClipFrontByFrontZ";class Ag{parse(e){const t=new Ig,i=this.getDxfInfoFromBuffer(e);let s="";return i.version&&i.version.value<=23&&i.encoding?s=new TextDecoder(i.encoding).decode(e):s=new TextDecoder().decode(e),t.parseSync(s)}getDxfInfoFromBuffer(e){var c,d,u;const i=new TextDecoder("utf-8");let s=0,r="",a=null,o=null,h=!1;for(;s<e.byteLength;){const p=Math.min(s+65536,e.byteLength),g=e.slice(s,p);s=p;const y=(r+i.decode(g,{stream:!0})).split(/\r?\n/);r=y.pop()??"";for(let x=0;x<y.length;x++){const _=y[x].trim();if(_==="SECTION"&&((c=y[x+2])==null?void 0:c.trim())==="HEADER")h=!0;else if(_==="ENDSEC"&&h)return{version:a,encoding:o};if(h&&_==="$ACADVER"){const S=(d=y[x+2])==null?void 0:d.trim();S&&(a=new ve(S))}else if(h&&_==="$DWGCODEPAGE"){const S=(u=y[x+2])==null?void 0:u.trim();if(S){const L=ar[S];o=ao(L)}}if(a&&o)return{version:a,encoding:o}}}return{version:a,encoding:o}}}class Wa{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=="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):null}convertFace(e){const t=new jn;return e.vertices.forEach((i,s)=>t.setVertexAt(s,i)),t}convertArc(e){const t=e.extrusionDirection??w.Z_AXIS;return new Bn(Ws(e.center,t),e.radius,k.degToRad(e.startAngle),k.degToRad(e.endAngle),t)}convertAttributeCommon(e,t){t.textString=e.text,t.height=e.textHeight,t.position.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&ee.Invisible)!==0,t.isConst=(e.attributeFlag&ee.Const)!==0,t.isVerifiable=(e.attributeFlag&ee.Verifiable)!==0,t.isPreset=(e.attributeFlag&ee.Preset)!==0,t.isReallyLocked=!!e.isReallyLocked,t.isMTextAttribute=(e.mtextFlag&Ve.MultiLine)!==0,t.isConstMTextAttribute=(e.mtextFlag&Ve.ConstMultiLine)!==0}convertAttribute(e){const t=new Dn;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 Fn;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??w.Z_AXIS;return new zn(Ws(e.center,t),e.radius,t)}convertEllipse(e){const t=new w(e.majorAxisEndPoint),i=t.length();return new Vn(e.center,e.extrusionDirection??w.Z_AXIS,t,i,i*e.axisRatio,e.startAngle,e.endAngle)}convertLine(e){const t=e.startPoint,i=e.endPoint;return new Ui(new f(t.x,t.y,t.z||0),new f(i.x,i.y,i.z||0))}convertSpline(e){try{if(e.numberOfControlPoints>0&&e.numberOfKnots>0)return new qi(e.controlPoints,e.knots,e.weights,e.degree,!!(e.flag&1));if(e.numberOfFitPoints>0)return new qi(e.fitPoints,"Uniform",e.degree,!!(e.flag&1))}catch{}return null}convertPoint(e){const t=new Zn;return t.position=e.position,t}convertSolid(e){const t=new $n;return e.points.forEach((i,s)=>t.setPointAt(s,i)),t.thickness=e.thickness,t}convertPolyline(e){var d;const t=!!(e.flag&1),i=!!(e.flag&8),s=!!(e.flag&16),r=!!(e.flag&64),a=!!(e.flag&32),o=[],h=[],c=[];if((d=e.vertices)==null||d.map(u=>{u.flag&Fu.SPLINE_CONTROL_POINT||(r&&u.flag&128?u.flag&64?(o.push({x:u.x,y:u.y,z:u.z}),h.push(u.bulge??0)):u.faces&&u.faces.length>=3&&c.push([...u.faces]):(o.push({x:u.x,y:u.y,z:u.z}),h.push(u.bulge??0)))}),s){const u=e.meshMVertexCount,p=e.meshNVertexCount;return new ts(u,p,o,t,a)}else{if(r)return new is(o,c);if(i){let u=Ri.SimplePoly;return e.flag&4&&(e.smoothType==Sn.CUBIC?u=Ri.CubicSplinePoly:e.smoothType==Sn.QUADRATIC&&(u=Ri.QuadSplinePoly)),new Rn(u,o,t)}else{let u=ai.SimplePoly;return e.flag&2?u=ai.FitCurvePoly:e.flag&4&&(e.smoothType==Sn.CUBIC?u=ai.CubicSplinePoly:e.smoothType==Sn.QUADRATIC&&(u=ai.QuadSplinePoly)),new Xn(u,o,0,t,e.startWidth,e.endWidth,h)}}}convertLWPolyline(e){var s;const t=new qn;t.closed=!!(e.flag&1);const i=e.constantWidth??-1;return(s=e.vertices)==null||s.forEach((r,a)=>{t.addVertexAt(a,new v(r.x,r.y),r.bulge,r.startWidth??i,r.endWidth??i)}),t}convertHatch(e){var s;const t=new Hi;if((s=e.definitionLines)==null||s.forEach(r=>{t.definitionLines.push({angle:k.degToRad(r.angle||0),base:r.base,offset:r.offset,dashLengths:r.numberOfDashLengths>0?r.dashLengths:[]})}),t.isSolidFill=e.solidFill==od.SolidFill,t.hatchStyle=e.hatchStyle,t.patternName=e.patternName,t.patternType=e.patternType,t.patternAngle=e.patternAngle==null?0:k.degToRad(e.patternAngle),t.patternScale=e.patternScale==null?0:e.patternScale,e.boundaryPaths.forEach(r=>{if(r.boundaryPathTypeFlag&2){const o=r,h=new oe;h.closed=o.isClosed,o.vertices.forEach((c,d)=>{h.addVertexAt(d,{x:c.x,y:c.y,bulge:c.bulge})}),t.add(h)}else{const o=r,h=[];o.edges.forEach(d=>{if(d.type==1){const u=d;h.push(new je(u.start,u.end))}else if(d.type==2){const u=d;h.push(new Et(u.center,u.radius,k.degToRad(u.startAngle||0),k.degToRad(u.endAngle||0),!u.isCCW))}else if(d.type==3){const u=d;new $().subVectors(u.end,u.center);const g=Math.sqrt(Math.pow(u.end.x,2)+Math.pow(u.end.y,2)),m=g*u.lengthOfMinorAxis;let y=k.degToRad(u.startAngle||0),x=k.degToRad(u.endAngle||0);const _=Math.atan2(u.end.y,u.end.x);u.isCCW||(y=Math.PI*2-y,x=Math.PI*2-x),h.push(new Wi({...u.center,z:0},g,m,y,x,!u.isCCW,_))}else if(d.type==4){const u=d;if(u.numberOfControlPoints>0&&u.numberOfKnots>0){const p=u.controlPoints.map(y=>({x:y.x,y:y.y,z:0}));let g=!0;const m=u.controlPoints.map(y=>(y.weight==null&&(g=!1),y.weight||1));h.push(new We(p,u.knots,g?m:void 0))}else if(u.numberOfFitData>0){const p=u.fitDatum.map(g=>({x:g.x,y:g.y,z:0}));h.push(new We(p,"Uniform"))}}});const c=Gi.buildFromEdges(h);c.length==0&&h.length>0?t.add(new Gi(h)):c.forEach(d=>t.add(d))}}),e.gradientFlag){const r=e;if(t.hatchObjectType=Lr.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 a=r.gradientColors.length;a>1?(t.gradientStartColor=r.gradientColors[0].rgb,t.gradientEndColor=r.gradientColors[1].rgb):a>0&&(t.gradientStartColor=r.gradientColors[0].rgb)}}return t}convertTable(e){const t=new Un(e.name,e.rowCount,e.columnCount);return t.tableDataVersion=e.version,t.tableStyleId=e.tableStyleId,t.owningBlockRecordId=e.blockRecordHandle,e.directionVector&&(t.horizontalDirection=new w(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((i,s)=>t.setColumnWidth(s,i)),e.rowHeightArr.forEach((i,s)=>t.setRowHeight(s,i)),e.cells.forEach((i,s)=>{t.setCell(s,i)}),t}convertText(e){const t=new di;return t.textString=e.text,t.styleName=e.styleName,t.height=e.textHeight,t.position.copy(e.startPoint),t.rotation=k.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;return t.contents=e.text,e.styleName!=null&&(t.styleName=e.styleName),t.height=e.height,t.width=e.width,t.rotation=k.degToRad(e.rotation||0),t.location=e.insertionPoint,t.attachmentPoint=e.attachmentPoint,e.direction&&(t.direction=new w(e.direction)),t.drawingDirection=e.drawingDirection,t}convertLeader(e){var i;const t=new Wn;return(i=e.vertices)==null||i.forEach(s=>{t.appendVertex(s)}),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 Gn;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??w.Z_AXIS,t.segments=(e.segments??[]).map(i=>{var s;return{position:i.position,direction:i.direction,miterDirection:i.miterDirection,elements:((s=i.elements)==null?void 0:s.map(r=>({parameterCount:r.parameterCount,parameters:r.parameters??[],fillCount:r.fillCount,fillParameters:r.fillParameters??[]})))??[]}}),t}convertMLeader(e){var L,T;const t=new Hn,i=e;t.version=e.version,t.leaderStyleId=e.leaderStyleId,e.leaderStyleId&&(t.mleaderStyleId=e.leaderStyleId),t.propertyOverrideFlag=e.propertyOverrideFlag,t.leaderLineType=e.leaderLineType??ci.StraightLeader,t.leaderLineColor=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,t.textColor=e.textColor,t.textFrameEnabled=e.textFrameEnabled,t.landingGap=e.landingGap,t.textAttachment=e.textAttachment,t.textFlowDirection=e.textFlowDirection,t.blockContentId=e.blockContentId,t.blockContentColor=e.blockContentColor,t.blockContentRotation=e.blockContentRotation,t.blockContentConnectionType=e.blockContentConnectionType,t.annotativeScaleEnabled=e.annotativeScaleEnabled,t.arrowheadOverrides=e.arrowheadOverrides?e.arrowheadOverrides.map(I=>({...I})):[],t.blockAttributes=e.blockAttributes?e.blockAttributes.map(I=>({...I})):[],t.textDirectionNegative=e.textDirectionNegative,t.textAlignInIPE=e.textAlignInIPE,t.bottomTextAttachmentDirection=e.bottomTextAttachmentDirection,t.topTextAttachmentDirection=e.topTextAttachmentDirection,t.contentScale=e.contentScale,t.textLineSpacingStyle=e.textLineSpacingStyle,t.textBackgroundColor=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 w(e.blockContentScale)),e.contentBasePosition&&(t.contentBasePosition=new f().copy(e.contentBasePosition)),e.textAnchor&&(t.textAnchor=new f().copy(e.textAnchor)),e.planeOrigin&&(t.planeOrigin=new f().copy(e.planeOrigin)),e.planeXAxisDirection&&(t.planeXAxisDirection=new w(e.planeXAxisDirection)),e.planeYAxisDirection&&(t.planeYAxisDirection=new w(e.planeYAxisDirection));const s=i.textContent,r=s&&typeof s=="object"?s:void 0,a=typeof s=="string"&&s.length>0||this.readString(r??{},["text","contents"])!=null||this.readString(i,["text","contents","mtext"])!=null,o=e.contentType??(a?gt.MTextContent:e.blockContent?gt.BlockContent:gt.NoneContent);t.contentType=o;const h=this.readPoint(i,["normal","extrusionDirection"]);h&&(t.normal=h);const c=this.readString(r??{},["styleName","textStyleName","textStyle"])??this.readString(i,["textStyleName","textStyle","styleName","textStyleId"]);c&&(t.textStyleName=c);const d=this.readPositiveNumber(r??{},["textHeight","height"])??this.readPositiveNumber(i,["textHeight","mtextHeight","textContentHeight"])??this.readPositiveNumber(i,["arrowheadSize","contentScale"]);d!=null&&(t.textHeight=d);const u=this.readPositiveNumber(r??{},["textWidth","width"])??this.readPositiveNumber(i,["textWidth","mtextWidth","textContentWidth"]);u!=null&&(t.textWidth=u),t.textLineSpacingFactor=this.readNumber(r??{},["lineSpacingFactor","textLineSpacingFactor"])??this.readNumber(i,["textLineSpacingFactor"])??t.textLineSpacingFactor;const p=this.readNumber(r??{},["textRotation","rotation"])??this.readNumber(i,["textRotation","mtextRotation","textContentRotation"]);p!=null&&(t.textRotation=k.degToRad(p));const g=this.readPoint(i,["textDirection","mtextDirection","textDirectionVector"]);g&&(t.textDirection=g);const m=this.readNumber(i,["textAttachmentPoint","attachmentPoint"]);m!=null&&(t.textAttachmentPoint=m);const y=e.textAttachmentDirection;y!=null&&(t.textAttachmentDirection=y);const x=this.readNumber(i,["textDrawingDirection","drawingDirection"]);x!=null&&(t.textDrawingDirection=x);const _=typeof s=="string"?s:this.readString(r??{},["text","contents"])??this.readString(i,["text","contents","mtext"]),S=this.readPoint(r??{},["anchorPoint","textAnchor","textLocation","textPosition","textAnchorPoint"])??this.readPoint(i,["textAnchor","textLocation","textPosition","textAnchorPoint","contentBasePosition"]);if(_!=null&&S&&(t.mtextContent={text:_,anchorPoint:S}),e.blockContent){const I=e.blockContent;t.blockContent={blockContentId:e.blockContent.blockContentId,normal:this.readPoint(I,["normal"]),position:e.blockContent.position,scale:this.readPoint(I,["scale"]),rotation:this.readNumber(I,["rotation"]),color:this.readNumber(I,["color"]),transformationMatrix:Array.isArray(e.blockContent.transformationMatrix)?e.blockContent.transformationMatrix:[]}}else e.blockContentId&&(t.blockContent={blockContentId:e.blockContentId,scale:e.blockContentScale,rotation:e.blockContentRotation,color:e.blockContentColor,transformationMatrix:[]});return(L=this.readMLeaderLeaders(i))==null||L.forEach(I=>{t.addLeader({lastLeaderLinePoint:I.lastLeaderLinePoint,lastLeaderLinePointSet:I.lastLeaderLinePointSet,doglegVector:I.doglegVector,doglegVectorSet:I.doglegVectorSet,doglegLength:I.doglegLength??e.doglegLength,breaks:I.breaks,leaderBranchIndex:I.leaderBranchIndex,leaderLines:I.leaderLines})}),t.numberOfLeaders===0&&((T=this.readLeaderLineArray(i))==null||T.forEach(I=>{t.addLeader({doglegLength:e.doglegLength}),t.addLeaderLine(t.numberOfLeaders-1,I)})),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,i=new Ki(t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return t.insertionPoint&&(i.dimBlockPosition={...t.insertionPoint,z:0}),i.rotation=k.degToRad(t.rotationAngle||0),this.processDimensionCommonAttrs(e,i),i}else if(e.subclassMarker=="AcDbRotatedDimension"){const t=e,i=new ls(t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return t.insertionPoint&&(i.dimBlockPosition={...t.insertionPoint,z:0}),i.rotation=k.degToRad(t.rotationAngle||0),this.processDimensionCommonAttrs(e,i),i}else if(e.subclassMarker=="AcDb3PointAngularDimension"){const t=e,i=new ss(t.centerPoint,t.subDefinitionPoint1,t.subDefinitionPoint2,t.definitionPoint);return this.processDimensionCommonAttrs(e,i),i}else if(e.subclassMarker=="AcDbOrdinateDimension"){const t=e,i=new as(t.subDefinitionPoint1,t.subDefinitionPoint2);return this.processDimensionCommonAttrs(e,i),i}else if(e.subclassMarker=="AcDbRadialDimension"){const t=e,i=new os(t.definitionPoint,t.subDefinitionPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,i),i}else if(e.subclassMarker=="AcDbDiametricDimension"){const t=e,i=new rs(t.definitionPoint,t.subDefinitionPoint,t.leaderLength);return this.processDimensionCommonAttrs(e,i),i}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(i=>{t.clipBoundary.push(new v(i))}),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 Zi;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(i=>{t.clipBoundary.push(new v(i))}),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 Qn;return this.processWipeout(e,t),t}convertViewport(e){const t=new Jn;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 Kn;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertXline(e){const t=new es;return t.basePoint.copy(e.position),t.unitDir.copy(e.direction),t}convertBlockReference(e){const t=new ei(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?k.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){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&&t.color.setRGBValue(e.color),e.colorIndex!=null&&(t.color.colorIndex=e.colorIndex),e.colorName&&(t.color.colorName=e.colorName),e.isVisible!=null&&(t.visibility=!e.isVisible),e.transparency!=null&&(t.transparency=ps.deserialize(e.transparency))}readNumber(e,t){for(const i of t){const s=e[i];if(typeof s=="number"&&Number.isFinite(s))return s}}readPositiveNumber(e,t){const i=this.readNumber(e,t);return i!=null&&i>0?i:void 0}readString(e,t){for(const i of t){const s=e[i];if(typeof s=="string")return s}}readBoolean(e,t){for(const i of t){const s=e[i];if(typeof s=="boolean")return s;if(typeof s=="number")return s!==0}}readPoint(e,t){for(const i of t){const s=e[i];if(this.isPointLike(s))return s;if(Array.isArray(s)&&typeof s[0]=="number"&&typeof s[1]=="number")return{x:s[0],y:s[1],z:s[2]??0}}}readLeaderLineArray(e){const t=e.leaderLines;if(Array.isArray(t))return t.map(s=>{if(!s||typeof s!="object")return;const r=s.vertices;return Array.isArray(r)?r.filter(a=>this.isPointLike(a)):void 0}).filter(s=>!!s&&s.length>0);const i=e.vertices;if(Array.isArray(i)){const s=i.filter(r=>this.isPointLike(r));return s.length>0?[s]:void 0}}readMLeaderLeaders(e){const t=e.leaderSections;if(!Array.isArray(t))return;const i=[];return t.forEach(s=>{if(!s||typeof s!="object")return;const r=s,a=r.leaderLines,o=Array.isArray(a)?a.reduce((m,y)=>{const x=this.readMLeaderLine(y);return x&&m.push(x),m},[]):void 0,h={},c=this.readPoint(r,["lastLeaderLinePoint"]),d=this.readPoint(r,["doglegVector"]),u=this.readNumber(r,["doglegLength"]),p=this.readMLeaderBreaks(r.breaks),g=this.readNumber(r,["leaderBranchIndex"]);c&&(h.lastLeaderLinePoint=c),r.lastLeaderLinePointSet!=null&&(h.lastLeaderLinePointSet=this.readBoolean(r,["lastLeaderLinePointSet"])),d&&(h.doglegVector=d),r.doglegVectorSet!=null&&(h.doglegVectorSet=this.readBoolean(r,["doglegVectorSet"])),u!=null&&(h.doglegLength=u),p&&(h.breaks=p),g!=null&&(h.leaderBranchIndex=g),o&&(h.leaderLines=o),i.push(h)}),i}readMLeaderLine(e){if(!e||typeof e!="object")return;const t=e,i=t.vertices,s=Array.isArray(i)?i.filter(h=>this.isPointLike(h)):[],r=this.readMLeaderBreaks(t.breaks),a=Array.isArray(t.breakPointIndexes)?t.breakPointIndexes.filter(h=>typeof h=="number"):void 0,o=this.readNumber(t,["leaderLineIndex"]);return s.length>0||r&&r.length>0?{vertices:s,breakPointIndexes:a,leaderLineIndex:o,breaks:r}:void 0}readMLeaderBreaks(e){if(!Array.isArray(e))return;const t=e.map(i=>{if(!i||typeof i!="object")return;const s=i,r=this.readPoint(s,["start"]),a=this.readPoint(s,["end"]),o=this.readNumber(s,["index"]);if(!r||!a)return;const h={start:r,end:a};return o!=null&&(h.index=o),h}).filter(i=>!!i);return t.length>0?t:void 0}isPointLike(e){return!!e&&typeof e=="object"&&typeof e.x=="number"&&typeof e.y=="number"}}class Pg{convertLayout(e,t){var r,a;const i=new rn;i.layoutName=e.layoutName,i.tabOrder=e.tabOrder,i.plotSettingsName=e.pageSetupName,i.plotCfgName=e.configName,i.canonicalMediaName=e.paperSize,i.plotViewName=e.plotViewName,i.currentStyleSheet=e.currentStyleSheet,i.plotPaperMargins={left:e.marginLeft,right:e.marginRight,top:e.marginTop,bottom:e.marginBottom},i.plotPaperSize.copy({x:e.paperWidth,y:e.paperHeight}),i.plotOrigin.copy({x:e.plotOriginX,y:e.plotOriginY}),i.plotWindowArea.min.copy({x:e.windowAreaXMin,y:e.windowAreaYMin}),i.plotWindowArea.max.copy({x:e.windowAreaXMax,y:e.windowAreaYMax}),i.customPrintScale={numerator:e.printScaleNumerator,denominator:e.printScaleDenominator},i.plotPaperUnits=e.plotPaperUnit,i.plotRotation=e.plotRotation,i.plotType=e.plotType,i.stdScaleType=e.standardScaleType,i.shadePlot=(()=>{switch(e.shadePlotMode){case 1:return oi.kWireframe;case 2:return oi.kHidden;case 3:return oi.kRendered;default:return oi.kAsDisplayed}})(),i.shadePlotResLevel=(()=>{switch(e.shadePlotResolution){case 1:return ft.kPreview;case 2:return ft.kNormal;case 3:return ft.kPresentation;case 4:return ft.kMaximum;case 5:return ft.kCustom;default:return ft.kDraft}})(),e.shadePlotCustomDPI!=null&&(i.shadePlotCustomDPI=e.shadePlotCustomDPI),e.shadePlotId&&(i.shadePlotId=e.shadePlotId);const s=e.layoutFlag??0;if(i.plotViewportBorders=(s&1)!==0,i.showPlotStyles=(s&2)!==0,i.plotCentered=(s&4)!==0,i.plotHidden=(s&8)!==0,i.useStandardScale=(s&16)!==0,i.plotPlotStyles=(s&32)!==0,i.scaleLineweights=(s&64)!==0,i.printLineweights=(s&128)!==0,i.drawViewportsFirst=(s&512)!==0,i.modelType=(s&1024)!==0,e.viewportId&&i.viewportArray.push(e.viewportId),e.layoutName==="Model"){const o=Q.MODEL_SPACE_NAME.toUpperCase();(r=t.tables.BLOCK_RECORD)==null||r.entries.some(h=>h.name.toUpperCase()===o?(i.blockTableRecordId=h.handle,!0):!1)}else(a=t.tables.BLOCK_RECORD)==null||a.entries.some(o=>o.layoutObjects===e.handle?(i.blockTableRecordId=o.handle,!0):!1),i.blockTableRecordId||(i.blockTableRecordId=e.paperSpaceTableId);return e.minLimit&&i.limits.min.copy(e.minLimit),e.maxLimit&&i.limits.max.copy(e.maxLimit),e.minExtent&&i.extents.min.copy(e.minExtent),e.maxExtent&&i.extents.max.copy(e.maxExtent),this.processCommonAttrs(e,i),i}convertImageDef(e){const t=new yl;return t.sourceFileName=e.fileName,this.processCommonAttrs(e,t),t}convertMLeaderStyle(e){const t=new Sr;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=Fi(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=Fi(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=Fi(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 s;const t=new Ir;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 z().setRGBValue(e.fillColor);else if(e.fillColorIndex!=null){const r=new z;r.colorIndex=e.fillColorIndex,t.fillColor=r}e.startAngle!=null&&(t.startAngle=e.startAngle),e.endAngle!=null&&(t.endAngle=e.endAngle);const i=Math.max(e.elementCount??0,((s=e.elements)==null?void 0:s.length)??0);return i>0&&(t.elements=Array.from({length:i},(r,a)=>{var o,h,c,d;return{offset:((h=(o=e.elements)==null?void 0:o[a])==null?void 0:h.offset)??0,color:(()=>{var p,g,m,y;const u=new z;return((g=(p=e.elements)==null?void 0:p[a])==null?void 0:g.color)!=null?u.setRGBValue(e.elements[a].color):u.colorIndex=((y=(m=e.elements)==null?void 0:m[a])==null?void 0:y.colorIndex)??256,u})(),lineType:((d=(c=e.elements)==null?void 0:c[a])==null?void 0:d.lineType)??"BYLAYER"}})),this.processCommonAttrs(e,t),t}processCommonAttrs(e,t){t.objectId=e.handle,e.ownerObjectId!=null&&(t.ownerId=e.ownerObjectId)}}class Zh{constructor(e){this.taskId=0,this.workers=new Map,this.pendingTasks=new Map,this.config={workerUrl:e.workerUrl,timeout:e.timeout??3e4,maxConcurrentWorkers:e.maxConcurrentWorkers??4}}async execute(e,t){const i=Date.now(),s=this.generateTaskId();try{return await this.executeInWorker(s,e,t||this.config.workerUrl)}catch(r){const a=Date.now()-i;return{success:!1,error:r instanceof Error?r.message:String(r),duration:a}}}async executeInWorker(e,t,i){const s=Date.now();return new Promise((r,a)=>{const o=this.getAvailableWorker(i),h=setTimeout(()=>{this.cleanupTask(e),this.releaseWorker(o),a(new Error(`Worker operation timed out after ${this.config.timeout}ms`))},this.config.timeout);this.pendingTasks.set(e,{resolve:u=>{clearTimeout(h),this.releaseWorker(o),r(u)},reject:u=>{clearTimeout(h),this.releaseWorker(o),a(u)},timeout:h});const c=u=>{const{id:p,success:g,data:m,error:y}=u.data;if(p!==e)return;this.cleanupTask(e);const x=Date.now()-s;r(g?{success:!0,data:m,duration:x}:{success:!1,error:y,duration:x})},d=u=>{this.cleanupTask(e),a(new Error(`Worker error: ${u.message}`))};o.addEventListener("message",c),o.addEventListener("error",d),o.postMessage({id:e,input:t})})}cleanupTask(e){const t=this.pendingTasks.get(e);t&&(clearTimeout(t.timeout),this.pendingTasks.delete(e))}generateTaskId(){return`task_${++this.taskId}_${Date.now()}`}detectWorkerSupport(){return typeof Worker<"u"}getAvailableWorker(e){for(const[i,s]of this.workers)if(!s.isBusy)return s.isBusy=!0,s.worker;if(this.workers.size<this.config.maxConcurrentWorkers){const i=new Worker(e,{type:"module"}),s=this.generateWorkerId(),r={worker:i,isBusy:!0,id:s,createdAt:new Date};return this.workers.set(s,r),i}const t=Array.from(this.workers.values()).sort((i,s)=>i.createdAt.getTime()-s.createdAt.getTime())[0];return t.isBusy=!0,t.worker}releaseWorker(e){for(const[t,i]of this.workers)if(i.worker===e){i.isBusy=!1;break}}generateWorkerId(){return`worker_${Date.now()}_${Math.random().toString(36).substr(2,9)}`}getStats(){return{totalWorkers:this.workers.size,busyWorkers:Array.from(this.workers.values()).filter(e=>e.isBusy).length,pendingTasks:this.pendingTasks.size,config:this.config}}destroy(){for(const[e,t]of this.pendingTasks)clearTimeout(t.timeout),t.reject(new Error("Framework destroyed"));this.pendingTasks.clear();for(const[e,t]of this.workers)t.worker.terminate();this.workers.clear()}}class Kh{constructor(e){this.framework=new Zh(e)}async execute(e,t){return this.framework.execute(e,t)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function Jh(n){return new Kh(n)}class Eg{constructor(){this.setupMessageHandler()}setupMessageHandler(){self.onmessage=async e=>{const{id:t,input:i}=e.data;try{const s=await this.executeTask(i);this.sendResponse(t,!0,s)}catch(s){this.sendResponse(t,!1,void 0,s instanceof Error?s.message:String(s))}}}sendResponse(e,t,i,s){const r={id:e,success:t,data:i,error:s};self.postMessage(r)}}class Qh extends Cr{constructor(e={}){super(e),e.parserWorkerUrl||(e.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(e,t){const i=this.config,s=this.getParserWorkerTimeout(e,t);if(i.useWorker&&i.parserWorkerUrl){const r=Jh({workerUrl:i.parserWorkerUrl,timeout:s,maxConcurrentWorkers:1}),a=await r.execute(e);if(r.destroy(),a.success)return{model:a.data,data:{unknownEntityCount:0}};throw new Error(`Failed to parse drawing due to error: '${a.error}'`)}else return{model:new Ag().parse(e),data:{unknownEntityCount:0}}}getFonts(e){var r;const t=new Map,i=a=>{if(a){const o=a.lastIndexOf(".");return o>=0?a.substring(0,o).toLowerCase():a.toLowerCase()}};(r=e.tables.STYLE)==null||r.entries.forEach(a=>{const o=[];if(a.font){const h=i(a.font);h&&o.push(h)}if(a.bigFont){const h=i(a.bigFont);h&&o.push(h)}if(a.extendedFont){const h=i(a.extendedFont);h&&o.push(h)}t.set(a.name,o)});const s=new Set;return this.getFontsInBlock(e.entities,e.blocks,t,s),Array.from(s)}getFontsInBlock(e,t,i,s){const r=/\\f(.*?)\|/g;e.forEach(a=>{if(a.type=="MTEXT"){const o=a;[...o.text.matchAll(r)].forEach(d=>{s.add(d[1].toLowerCase())});const c=i.get(o.styleName);c==null||c.forEach(d=>s.add(d))}else if(a.type=="TEXT"){const o=a,h=i.get(o.styleName);h==null||h.forEach(c=>s.add(c))}else if(a.type=="MULTILEADER"||a.type=="MLEADER"){const o=a;[...(typeof o.textContent=="string"?o.textContent:"").matchAll(r)].forEach(u=>{s.add(u[1].toLowerCase())});const c=typeof o.textStyleName=="string"?o.textStyleName:typeof o.styleName=="string"?o.styleName:void 0,d=c?i.get(c):void 0;d==null||d.forEach(u=>s.add(u))}else if(a.type=="INSERT"){const h=t[a.name];h&&h.entities&&this.getFontsInBlock(h.entities,t,i,s)}})}async processEntities(e,t,i,s,r){const a=new Wa;let o=e.entities;const h=o.length,c=new sr(h,100-s.value,i);this.config.convertByEntityType&&(o=this.groupAndFlattenByType(o));const d=new Map;for(let p=0;p<h;p++){const g=o[p];if(g.type==="ATTRIB"){const m=a.convert(g);if(m&&m.ownerId&&m.ownerId!=="0"){let y=d.get(m==null?void 0:m.ownerId);y==null&&(y=[],d.set(m.ownerId,y)),y.push(m)}}}const u=t.tables.blockTable.modelSpace;await c.processChunk(async(p,g)=>{let m=[],y=p<g?o[p].type:"";for(let _=p;_<g;_++){const S=o[_];if(!(S.ownerBlockRecordSoftId&&S.ownerBlockRecordSoftId!==u.objectId)&&S.type!=="ATTRIB"){const L=a.convert(S);if(L){if(this.config.convertByEntityType&&S.type!==y&&(u.appendEntity(m),m=[],y=S.type),S.type==="INSERT"){const T=d.get(L.objectId);T&&T.length>0&&T.forEach(I=>{L.appendAttributes(I)})}m.push(L)}}}u.appendEntity(m);let x=s.value+g/h*(100-s.value);x>100&&(x=100),r&&await r(x,"ENTITY","IN-PROGRESS")})}async processEntitiesInBlock(e,t,i=!1){const s=new Wa,r=e.length,a=[],o=t.objectId,h=[];for(let c=0;c<r;c++){const d=e[c],u=s.convert(d);u&&(d.type==="ATTRIB"?h.push(u):(!i||d.ownerBlockRecordSoftId===o)&&a.push(u))}t.appendEntity(a),h.forEach(c=>{const d=t.getIdAt(c.ownerId);d&&d.appendAttributes(c)})}processBlocks(e,t){const i=e.blocks;for(const[s,r]of Object.entries(i)){let a=t.tables.blockTable.getAt(r.name);a||(a=new Q,a.objectId=r.handle,a.name=s,a.origin.copy(r.position),t.tables.blockTable.add(a)),r.entities?this.processEntitiesInBlock(r.entities,a):a.isPaperSapce&&this.processEntitiesInBlock(e.entities,a,!0)}}processHeader(e,t){const i=e.header;i.$ACADVER&&(t.version=i.$ACADVER),t.cecolor.colorIndex=i.$CECOLOR||256,t.angBase=i.$ANGBASE||0,t.angDir=i.$ANGDIR||0,i.$AUNITS!=null&&(t.aunits=i.$AUNITS),t.celtype=i.$CELTYPE||de,t.celtscale=i.$CELTSCALE||1;const s=this.normalizeHeaderStringValue(i.$CMLSTYLE)||this.normalizeHeaderStringValue(i.CMLSTYLE)||dt;t.cmlstyle=s;const r=i.$CMLSCALE??i.CMLSCALE;typeof r=="number"&&Number.isFinite(r)&&(t.cmlscale=r);const a=this.normalizeHeaderStringValue(i.$CMLEADERSTYLE)||this.normalizeHeaderStringValue(i.CMLEADERSTYLE)||ut;t.cmleaderstyle=a,t.ltscale=i.$LTSCALE||1,i.$EXTMAX&&(t.extmax=i.$EXTMAX),i.$EXTMIN&&(t.extmin=i.$EXTMIN),i.$INSUNITS!=null&&(t.insunits=i.$INSUNITS),t.osmode=i.$OSMODE||0,t.pdmode=i.$PDMODE||0,t.pdsize=i.$PDSIZE||0,t.textstyle=i.$TEXTSTYLE||Z}processBlockTables(e,t){var s;const i=(s=e.tables.BLOCK_RECORD)==null?void 0:s.entries;i&&i.length>0&&(t.tables.blockTable.removeAll(),i.forEach(r=>{const a=new Q;a.objectId=r.handle,a.name=r.name,a.layoutId=r.layoutObjects,a.blockInsertUnits=r.insertionUnits,a.explodability=r.explodability,a.blockScaling=r.scalability,r.bmpPreview&&(a.bmpPreview=r.bmpPreview),t.tables.blockTable.add(a)}))}processObjects(e,t){const i=e.objects.byName,s=new Pg;if("LAYOUT"in i){const r=t.objects.layout;i.LAYOUT.forEach(a=>{const o=s.convertLayout(a,e);r.setAt(o.layoutName,o)})}if("IMAGEDEF"in i){const r=t.objects.imageDefinition;i.IMAGEDEF.forEach(a=>{const o=s.convertImageDef(a);r.setAt(o.objectId,o)})}if("MLEADERSTYLE"in i){const r=t.objects.mleaderStyle;i.MLEADERSTYLE.forEach(a=>{const o=s.convertMLeaderStyle(a);r.setAt(o.objectId,o)})}if("MLINESTYLE"in i){const r=t.objects.mlineStyle;i.MLINESTYLE.forEach(a=>{const o=s.convertMLineStyle(a);r.setAt(o.styleName||o.objectId,o)})}}processViewports(e,t){var s;const i=(s=e.tables)==null?void 0:s.VPORT;if(i){this.processCommonTableAttrs(i,t.tables.viewportTable);const r=i.entries;r&&r.length>0&&r.forEach(a=>{const o=new vr;this.processCommonTableEntryAttrs(a,o),a.circleSides&&(o.circleSides=a.circleSides),o.standardFlag=a.standardFlag,o.center.copy(a.center),o.lowerLeftCorner.copy(a.lowerLeftCorner),o.upperRightCorner.copy(a.upperRightCorner),a.snapBasePoint&&o.snapBase.copy(a.snapBasePoint),a.snapRotationAngle&&(o.snapAngle=a.snapRotationAngle),a.snapSpacing&&o.snapIncrements.copy(a.snapSpacing),a.majorGridLines&&(o.gridMajor=a.majorGridLines),a.gridSpacing&&o.gridIncrements.copy(a.gridSpacing),a.backgroundObjectId&&(o.backgroundObjectId=a.backgroundObjectId),o.gsView.center.copy(a.center),o.gsView.viewDirectionFromTarget.copy(a.viewDirectionFromTarget),o.gsView.viewTarget.copy(a.viewTarget),a.lensLength&&(o.gsView.lensLength=a.lensLength),a.frontClippingPlane&&(o.gsView.frontClippingPlane=a.frontClippingPlane),a.backClippingPlane&&(o.gsView.backClippingPlane=a.backClippingPlane),a.viewHeight&&(o.gsView.viewHeight=a.viewHeight),a.viewTwistAngle&&(o.gsView.viewTwistAngle=a.viewTwistAngle),a.frozenLayers&&(o.gsView.frozenLayers=a.frozenLayers),a.styleSheet&&(o.gsView.styleSheet=a.styleSheet),a.renderMode&&(o.gsView.renderMode=a.renderMode),a.viewMode&&(o.gsView.viewMode=a.viewMode),a.ucsIconSetting&&(o.gsView.ucsIconSetting=a.ucsIconSetting),a.ucsOrigin&&o.gsView.ucsOrigin.copy(a.ucsOrigin),a.ucsXAxis&&o.gsView.ucsXAxis.copy(a.ucsXAxis),a.ucsYAxis&&o.gsView.ucsYAxis.copy(a.ucsYAxis),a.orthographicType&&(o.gsView.orthographicType=a.orthographicType),a.shadePlotSetting&&(o.gsView.shadePlotSetting=a.shadePlotSetting),a.shadePlotObjectId&&(o.gsView.shadePlotObjectId=a.shadePlotObjectId),a.visualStyleObjectId&&(o.gsView.visualStyleObjectId=a.visualStyleObjectId),a.isDefaultLightingOn&&(o.gsView.isDefaultLightingOn=a.isDefaultLightingOn),a.defaultLightingType&&(o.gsView.defaultLightingType=a.defaultLightingType),a.brightness&&(o.gsView.brightness=a.brightness),a.contrast&&(o.gsView.contrast=a.contrast),a.ambientColor&&(o.gsView.ambientColor=a.ambientColor),t.tables.viewportTable.add(o)})}}processLayers(e,t){var s;const i=(s=e.tables)==null?void 0:s.LAYER;if(i){this.processCommonTableAttrs(i,t.tables.layerTable);const r=i.entries;r&&r.length>0&&r.forEach(a=>{const o=new z;o.colorIndex=a.colorIndex;const h=new ys({name:a.name,standardFlags:a.standardFlag,linetype:a.lineType,lineWeight:a.lineweight,isOff:a.colorIndex<0,color:o,isPlottable:a.isPlotting});this.processCommonTableEntryAttrs(a,h),t.tables.layerTable.add(h)})}}processLineTypes(e,t){var s;const i=(s=e.tables)==null?void 0:s.LTYPE;if(i){this.processCommonTableAttrs(i,t.tables.linetypeTable);const r=i.entries;r&&r.length>0&&r.forEach(a=>{const o=new At(a);this.processCommonTableEntryAttrs(a,o),o.name=a.name,t.tables.linetypeTable.add(o)})}}processTextStyles(e,t){var s;const i=(s=e.tables)==null?void 0:s.STYLE;if(i){this.processCommonTableAttrs(i,t.tables.textStyleTable);const r=i.entries;r&&r.length>0&&r.forEach(a=>{const o=new _s(a);this.processCommonTableEntryAttrs(a,o),t.tables.textStyleTable.add(o)})}}processDimStyles(e,t){var s;const i=(s=e.tables)==null?void 0:s.DIMSTYLE;if(i){this.processCommonTableAttrs(i,t.tables.dimStyleTable);const r=i.entries;r&&r.length>0&&r.forEach(a=>{const o={name:a.name,ownerId:a.ownerObjectId,dimpost:a.DIMPOST||"",dimapost:a.DIMAPOST||"",dimscale:a.DIMSCALE,dimasz:a.DIMASZ,dimexo:a.DIMEXO,dimdli:a.DIMDLI,dimexe:a.DIMEXE,dimrnd:a.DIMRND,dimdle:a.DIMDLE,dimtp:a.DIMTP,dimtm:a.DIMTM,dimtxt:a.DIMTXT,dimcen:a.DIMCEN,dimtsz:a.DIMTSZ,dimaltf:a.DIMALTF,dimlfac:a.DIMLFAC,dimtvp:a.DIMTVP,dimtfac:a.DIMTFAC,dimgap:a.DIMGAP,dimaltrnd:a.DIMALTRND,dimtol:a.DIMTOL==null||a.DIMTOL==0?0:1,dimlim:a.DIMLIM==null||a.DIMLIM==0?0:1,dimtih:a.DIMTIH==null||a.DIMTIH==0?0:1,dimtoh:a.DIMTOH==null||a.DIMTOH==0?0:1,dimse1:a.DIMSE1==null||a.DIMSE1==0?0:1,dimse2:a.DIMSE2==null||a.DIMSE2==0?0:1,dimtad:a.DIMTAD,dimzin:a.DIMZIN,dimazin:a.DIMAZIN,dimalt:a.DIMALT,dimaltd:a.DIMALTD,dimtofl:a.DIMTOFL,dimsah:a.DIMSAH,dimtix:a.DIMTIX,dimsoxd:a.DIMSOXD,dimclrd:a.DIMCLRD,dimclre:a.DIMCLRE,dimclrt:a.DIMCLRT,dimadec:a.DIMADEC||0,dimunit:a.DIMUNIT||2,dimdec:a.DIMDEC,dimtdec:a.DIMTDEC,dimaltu:a.DIMALTU,dimalttd:a.DIMALTTD,dimaunit:a.DIMAUNIT,dimfrac:a.DIMFRAC,dimlunit:a.DIMLUNIT,dimdsep:a.DIMDSEP?a.DIMDSEP.toString():".",dimtmove:a.DIMTMOVE||0,dimjust:a.DIMJUST,dimsd1:a.DIMSD1,dimsd2:a.DIMSD2,dimtolj:a.DIMTOLJ,dimtzin:a.DIMTZIN,dimaltz:a.DIMALTZ,dimalttz:a.DIMALTTZ,dimfit:a.DIMFIT||0,dimupt:a.DIMUPT,dimatfit:a.DIMATFIT,dimtxsty:a.DIMTXSTY||Z,dimldrblk:a.DIMLDRBLK||"",dimblk:a.DIMBLK||"",dimblk1:a.DIMBLK1||"",dimblk2:a.DIMBLK2||"",dimlwd:a.DIMLWD,dimlwe:a.DIMLWE},h=new ti(o);this.processCommonTableEntryAttrs(a,h),t.tables.dimStyleTable.add(h)})}}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={},i=[];for(const s of e)t[s.type]||(t[s.type]=[],i.push(s.type)),t[s.type].push(s);return i.flatMap(s=>t[s])}normalizeHeaderStringValue(e){if(typeof e!="string")return;const t=e.trim();return t.length>0?t:void 0}}class ec extends Cr{constructor(e){super({}),this._database=e}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}getFonts(){return[]}async processEntities(e,t,i,s,r){let a=e.tables.blockTable.modelSpace.newIterator().toArray();const o=a.length,h=new sr(o,100-s.value,i);this.config.convertByEntityType&&(a=this.groupAndFlattenByType(a));const c=t.tables.blockTable.modelSpace;await h.processChunk(async(d,u)=>{let p=[],g=d<u?a[d].type:"";for(let m=d;m<u;m++){const y=a[m];this.config.convertByEntityType&&y.type!==g&&(this.triggerEvents(c,p),p=[],g=y.type),p.push(y)}if(this.triggerEvents(c,p),r){let m=s.value+u/o*(100-s.value);m>100&&(m=100),await r(m,"ENTITY","IN-PROGRESS")}})}processBlocks(){const e=this._database.tables.blockTable.newIterator();for(const t of e){const i=t.newIterator().toArray();this.triggerEvents(t,i)}}processHeader(){}processBlockTables(){}processObjects(){const e=this._database.objects.layout.newIterator();for(const s of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:s,key:s.layoutName});const t=this._database.objects.imageDefinition.newIterator();for(const s of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:s,key:s.objectId});const i=this._database.objects.mleaderStyle.newIterator();for(const s of i)this._database.events.dictObjetSet.dispatch({database:this._database,object:s,key:s.objectId})}processViewports(){}processLayers(){this._database.tables.layerTable.newIterator().toArray().forEach(t=>{this._database.events.layerAppended.dispatch({database:this._database,layer:t})})}processLineTypes(){}processTextStyles(){}processDimStyles(){}groupAndFlattenByType(e){const t={},i=[];for(const s of e)t[s.type]||(t[s.type]=[],i.push(s.type)),t[s.type].push(s);return i.flatMap(s=>t[s])}triggerEvents(e,t){(e.isModelSapce||e.isPaperSapce)&&e.database.events.entityAppended.dispatch({database:e.database,entity:t})}}exports.ACAD_APPID=Fs;exports.AC_DB_SYSTEM_VARIABLE_NAMES=Qc;exports.AcCmColor=z;exports.AcCmColorMethod=A;exports.AcCmColorUtil=wt;exports.AcCmEntityColor=ic;exports.AcCmErrors=fe;exports.AcCmEventDispatcher=nc;exports.AcCmEventManager=J;exports.AcCmLoader=dc;exports.AcCmLoadingManager=eo;exports.AcCmObject=Za;exports.AcCmPerformanceCollector=tr;exports.AcCmTask=Ja;exports.AcCmTaskScheduler=Qa;exports.AcCmTransparency=ps;exports.AcCmTransparencyMethod=ye;exports.AcDb2dPolyline=Xn;exports.AcDb2dVertex=Us;exports.AcDb2dVertexType=Ho;exports.AcDb3PointAngularDimension=ss;exports.AcDb3dPolyline=Rn;exports.AcDb3dVertex=$s;exports.AcDb3dVertexType=Uo;exports.AcDbAbstractViewTableRecord=kr;exports.AcDbAlignedDimension=Ki;exports.AcDbAngleUnits=rr;exports.AcDbArc=Bn;exports.AcDbArcDimension=Zs;exports.AcDbAttribute=Dn;exports.AcDbAttributeDefinition=Fn;exports.AcDbAttributeFlags=ee;exports.AcDbAttributeMTextFlag=Ve;exports.AcDbBaseWorker=Eg;exports.AcDbBatchProcessing=sr;exports.AcDbBlockReference=ei;exports.AcDbBlockScaling=pl;exports.AcDbBlockTable=bl;exports.AcDbBlockTableRecord=Q;exports.AcDbCircle=zn;exports.AcDbCodePage=ar;exports.AcDbCurve=he;exports.AcDbDataGenerator=xl;exports.AcDbDatabase=ed;exports.AcDbDatabaseConverter=Cr;exports.AcDbDatabaseConverterManager=De;exports.AcDbDiametricDimension=rs;exports.AcDbDictionary=Kt;exports.AcDbDimArrowType=wl;exports.AcDbDimStyleTable=Ll;exports.AcDbDimStyleTableRecord=ti;exports.AcDbDimTextHorizontal=Sl;exports.AcDbDimTextVertical=Il;exports.AcDbDimVerticalJustification=El;exports.AcDbDimZeroSuppression=Al;exports.AcDbDimZeroSuppressionAngular=Pl;exports.AcDbDimension=pt;exports.AcDbDuplicateRecordCloning=_l;exports.AcDbDwgVersion=ve;exports.AcDbDxfCode=er;exports.AcDbDxfConverter=Qh;exports.AcDbDxfFiler=Ga;exports.AcDbEllipse=Vn;exports.AcDbEntity=le;exports.AcDbFace=jn;exports.AcDbFileType=Ni;exports.AcDbGradientPatternType=Ko;exports.AcDbHatch=Hi;exports.AcDbHatchObjectType=Lr;exports.AcDbHatchPatternType=Bi;exports.AcDbHatchStyle=Zo;exports.AcDbHostApplicationServices=Yn;exports.AcDbLayerTable=Tl;exports.AcDbLayerTableRecord=ys;exports.AcDbLayout=rn;exports.AcDbLayoutDictionary=gl;exports.AcDbLayoutManager=ml;exports.AcDbLeader=Wn;exports.AcDbLeaderAnnotationType=Jo;exports.AcDbLine=Ui;exports.AcDbLineSpacingStyle=ns;exports.AcDbLinetypeTable=Ml;exports.AcDbLinetypeTableRecord=At;exports.AcDbMLeader=Hn;exports.AcDbMLeaderContentType=gt;exports.AcDbMLeaderDirectionType=il;exports.AcDbMLeaderLineType=ci;exports.AcDbMLeaderStyle=Sr;exports.AcDbMLeaderTextAttachmentDirection=tl;exports.AcDbMLine=Gn;exports.AcDbMLineFlags=el;exports.AcDbMLineJustification=Qo;exports.AcDbMText=$i;exports.AcDbMlineStyle=Ir;exports.AcDbObject=Be;exports.AcDbObjectIterator=an;exports.AcDbOpenMode=ro;exports.AcDbOrdinateDimension=as;exports.AcDbOsnapMode=B;exports.AcDbPatParser=Mr;exports.AcDbPatSvgRenderer=Ks;exports.AcDbPlotPaperUnits=ll;exports.AcDbPlotRotation=hl;exports.AcDbPlotSettings=ul;exports.AcDbPlotShadePlotResLevel=ft;exports.AcDbPlotShadePlotType=oi;exports.AcDbPlotStdScaleType=dl;exports.AcDbPlotType=cl;exports.AcDbPoint=Zn;exports.AcDbPoly2dType=ai;exports.AcDbPoly3dType=Ri;exports.AcDbPolyFaceMesh=is;exports.AcDbPolyFaceMeshFace=ol;exports.AcDbPolyFaceMeshVertex=al;exports.AcDbPolygonMesh=ts;exports.AcDbPolygonMeshVertex=rl;exports.AcDbPolyline=qn;exports.AcDbPredefinedAcadIsoPat=Kc;exports.AcDbPredefinedAcadPat=Zc;exports.AcDbRadialDimension=os;exports.AcDbRasterImage=Zi;exports.AcDbRasterImageClipBoundaryType=nl;exports.AcDbRasterImageDef=yl;exports.AcDbRasterImageImageDisplayOpt=sl;exports.AcDbRay=Kn;exports.AcDbRegAppTable=Ol;exports.AcDbRegAppTableRecord=Js;exports.AcDbRegenerator=ec;exports.AcDbRenderingCache=ii;exports.AcDbResultBuffer=nr;exports.AcDbRotatedDimension=ls;exports.AcDbSpline=qi;exports.AcDbSymbolTable=mt;exports.AcDbSymbolTableRecord=kt;exports.AcDbSysVarManager=Ji;exports.AcDbSystemVariables=Y;exports.AcDbTable=Un;exports.AcDbText=di;exports.AcDbTextHorizontalMode=$o;exports.AcDbTextStyleTable=kl;exports.AcDbTextStyleTableRecord=_s;exports.AcDbTextVerticalMode=qo;exports.AcDbTrace=$n;exports.AcDbUnitsValue=Tr;exports.AcDbViewTable=vl;exports.AcDbViewTableRecord=nd;exports.AcDbViewport=Jn;exports.AcDbViewportTable=Cl;exports.AcDbViewportTableRecord=vr;exports.AcDbWipeout=Qn;exports.AcDbWorkerApi=Kh;exports.AcDbWorkerManager=Zh;exports.AcDbXline=es;exports.AcDbXrecord=Uc;exports.AcGeArea2d=Pt;exports.AcGeBox2d=_e;exports.AcGeBox3d=N;exports.AcGeCatmullRomCurve3d=ms;exports.AcGeCircArc2d=Et;exports.AcGeCircArc3d=It;exports.AcGeCurve2d=ui;exports.AcGeEllipseArc2d=Wi;exports.AcGeEllipseArc3d=hi;exports.AcGeEuler=wc;exports.AcGeGeometryUtil=Ro;exports.AcGeLine2d=je;exports.AcGeLine3d=Tt;exports.AcGeLoop2d=Gi;exports.AcGeMathUtil=k;exports.AcGeMatrix2d=en;exports.AcGeMatrix3d=D;exports.AcGeNurbsCurve=Re;exports.AcGePlane=nn;exports.AcGePoint2d=v;exports.AcGePoint3d=f;exports.AcGePolyline2d=oe;exports.AcGeQuaternion=ni;exports.AcGeShape2d=_r;exports.AcGeSpline3d=We;exports.AcGeTol=tn;exports.AcGeVector2d=$;exports.AcGeVector3d=w;exports.AcGiArrowType=xr;exports.AcGiDefaultLightingType=br;exports.AcGiLineWeight=Qt;exports.AcGiMTextAttachmentPoint=ae;exports.AcGiMTextFlowDirection=ze;exports.AcGiOrthographicType=fr;exports.AcGiRenderMode=wr;exports.AcGiViewport=Wo;exports.AcTrStringUtil=cc;exports.ByBlock=Lt;exports.ByLayer=de;exports.DEBUG_MODE=lc;exports.DEFAULT_LINE_TYPE=St;exports.DEFAULT_MLEADER_STYLE=ut;exports.DEFAULT_MLINE_STYLE=dt;exports.DEFAULT_TEXT_STYLE=Z;exports.DEFAULT_TOL=gr;exports.DEG2RAD=or;exports.DefaultLoadingManager=to;exports.FLOAT_TOL=Zt;exports.MLIGHTCAD_APPID=Bs;exports.ORIGIN_POINT_2D=pc;exports.ORIGIN_POINT_3D=ur;exports.RAD2DEG=lr;exports.RAW_COLOR_TYPE_ACI=Er;exports.RAW_COLOR_TYPE_BY_BLOCK=hs;exports.RAW_COLOR_TYPE_BY_LAYER=Ar;exports.RAW_COLOR_TYPE_RGB=Pr;exports.RAW_COLOR_TYPE_WINDOW_BG=fl;exports.TAU=W;exports.TEMP_OBJECT_ID_PREFIX=An;exports.acdbDisableOsnapMode=Cc;exports.acdbEnableOsnapMode=vc;exports.acdbHasOsnapMode=kc;exports.acdbHostApplicationServices=ir;exports.acdbMaskToOsnapModes=Tc;exports.acdbOsnapModesToMask=Ec;exports.acdbToggleOsnapMode=Mc;exports.basisFunction=Vi;exports.calculateCurveLength=Do;exports.ceilPowerOfTwo=Lo;exports.clamp=ct;exports.clone=ki;exports.computeParameterValues=Bo;exports.createWorkerApi=Jh;exports.damp=co;exports.decodeMLeaderStyleRawColor=Fi;exports.deepClone=Ys;exports.defaults=Qi;exports.degToRad=wo;exports.dwgCodePageToEncoding=ao;exports.encodeMLeaderStyleRawColor=Tn;exports.euclideanModulo=hr;exports.evaluateNurbsPoint=Xi;exports.floorPowerOfTwo=So;exports.generateAveragedKnots=Fo;exports.generateChordKnots=bc;exports.generateSqrtChordKnots=Lc;exports.generateUUID=oo;exports.generateUniformKnots=fc;exports.getOcsAngle=Gs;exports.getOcsReferenceVector=yr;exports.has=Ha;exports.intPartLength=dr;exports.interpolateControlPoints=Sc;exports.interpolateNurbsCurve=mr;exports.inverseLerp=ho;exports.isBetween=Io;exports.isBetweenAngle=Ao;exports.isEmpty=Ua;exports.isEqual=li;exports.isImperialUnits=qc;exports.isMetricUnits=$c;exports.isPointInPolygon=pr;exports.isPolygonIntersect=Xo;exports.isPowerOfTwo=bo;exports.lerp=cr;exports.log=Oi;exports.mapLinear=lo;exports.normalizeAngle=Yi;exports.pingpong=uo;exports.radToDeg=fo;exports.randFloat=yo;exports.randFloatSpread=_o;exports.randInt=mo;exports.relativeEps=Po;exports.seededRandom=xo;exports.setAcDbHostApplicationServicesProvider=no;exports.setAcDbLayoutManagerFactory=so;exports.setLogLevel=hc;exports.smootherstep=po;exports.smoothstep=go;exports.transformOcsPointToWcs=Ws;exports.transformWcsPointToOcs=ji;