@mlightcad/data-model 1.7.15 → 1.7.16

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,4 +1,4 @@
1
1
  "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var xr=(s=>(s[s.Invalid=-9999]="Invalid",s[s.Start=0]="Start",s[s.Text=1]="Text",s[s.AttributeTag=2]="AttributeTag",s[s.BlockName=2]="BlockName",s[s.ShapeName=2]="ShapeName",s[s.SymbolTableName=2]="SymbolTableName",s[s.SymbolTableRecordName=2]="SymbolTableRecordName",s[s.MlineStyleName=2]="MlineStyleName",s[s.AttributePrompt=3]="AttributePrompt",s[s.Description=3]="Description",s[s.DimPostString=3]="DimPostString",s[s.DimStyleName=3]="DimStyleName",s[s.LinetypeProse=3]="LinetypeProse",s[s.TextFontFile=3]="TextFontFile",s[s.CLShapeName=4]="CLShapeName",s[s.DimensionAlternativePrefixSuffix=4]="DimensionAlternativePrefixSuffix",s[s.SymbolTableRecordComments=4]="SymbolTableRecordComments",s[s.TextBigFontFile=4]="TextBigFontFile",s[s.Handle=5]="Handle",s[s.DimensionBlock=5]="DimensionBlock",s[s.LinetypeName=6]="LinetypeName",s[s.DimBlk1=6]="DimBlk1",s[s.TextStyleName=7]="TextStyleName",s[s.DimBlk2=7]="DimBlk2",s[s.LayerName=8]="LayerName",s[s.CLShapeText=9]="CLShapeText",s[s.XCoordinate=10]="XCoordinate",s[s.YCoordinate=20]="YCoordinate",s[s.ZCoordinate=30]="ZCoordinate",s[s.Real=40]="Real",s[s.TxtSize=40]="TxtSize",s[s.ViewportHeight=40]="ViewportHeight",s[s.Angle=50]="Angle",s[s.ViewportSnapAngle=50]="ViewportSnapAngle",s[s.Visibility=60]="Visibility",s[s.Int16=70]="Int16",s[s.Int32=90]="Int32",s[s.Int64=160]="Int64",s[s.Int8=280]="Int8",s[s.Thickness=39]="Thickness",s[s.Elevation=38]="Elevation",s[s.LinetypeScale=48]="LinetypeScale",s[s.DashLength=49]="DashLength",s[s.MlineOffset=49]="MlineOffset",s[s.LinetypeElement=49]="LinetypeElement",s[s.NormalX=210]="NormalX",s[s.NormalY=220]="NormalY",s[s.NormalZ=230]="NormalZ",s[s.UcsOrg=110]="UcsOrg",s[s.UcsOrientationX=111]="UcsOrientationX",s[s.UcsOrientationY=112]="UcsOrientationY",s[s.ViewHeight=45]="ViewHeight",s[s.ViewWidth=41]="ViewWidth",s[s.ViewLensLength=42]="ViewLensLength",s[s.ViewFrontClip=43]="ViewFrontClip",s[s.ViewBackClip=44]="ViewBackClip",s[s.ViewBrightness=141]="ViewBrightness",s[s.ViewContrast=142]="ViewContrast",s[s.ViewMode=71]="ViewMode",s[s.ViewportActive=68]="ViewportActive",s[s.ViewportAspect=41]="ViewportAspect",s[s.ViewportGrid=76]="ViewportGrid",s[s.ViewportIcon=74]="ViewportIcon",s[s.ViewportNumber=69]="ViewportNumber",s[s.ViewportSnap=75]="ViewportSnap",s[s.ViewportSnapPair=78]="ViewportSnapPair",s[s.ViewportSnapStyle=77]="ViewportSnapStyle",s[s.ViewportTwist=51]="ViewportTwist",s[s.ViewportVisibility=67]="ViewportVisibility",s[s.ViewportZoom=73]="ViewportZoom",s[s.Color=62]="Color",s[s.ColorRgb=420]="ColorRgb",s[s.ColorName=430]="ColorName",s[s.LineWeight=370]="LineWeight",s[s.PlotStyleNameType=380]="PlotStyleNameType",s[s.PlotStyleNameId=390]="PlotStyleNameId",s[s.GradientObjType=450]="GradientObjType",s[s.GradientAngle=460]="GradientAngle",s[s.GradientName=470]="GradientName",s[s.GradientColCount=453]="GradientColCount",s[s.GradientPatType=451]="GradientPatType",s[s.GradientTintType=452]="GradientTintType",s[s.GradientShift=461]="GradientShift",s[s.GradientColVal=463]="GradientColVal",s[s.GradientTintVal=462]="GradientTintVal",s[s.SoftPointerId=330]="SoftPointerId",s[s.HardPointerId=340]="HardPointerId",s[s.SoftOwnershipId=350]="SoftOwnershipId",s[s.HardOwnershipId=360]="HardOwnershipId",s[s.ArbitraryHandle=320]="ArbitraryHandle",s[s.ExtendedDataAsciiString=1e3]="ExtendedDataAsciiString",s[s.ExtendedDataRegAppName=1001]="ExtendedDataRegAppName",s[s.ExtendedDataControlString=1002]="ExtendedDataControlString",s[s.ExtendedDataLayerName=1003]="ExtendedDataLayerName",s[s.ExtendedDataBinaryChunk=1004]="ExtendedDataBinaryChunk",s[s.ExtendedDataHandle=1005]="ExtendedDataHandle",s[s.ExtendedDataXCoordinate=1010]="ExtendedDataXCoordinate",s[s.ExtendedDataWorldXCoordinate=1011]="ExtendedDataWorldXCoordinate",s[s.ExtendedDataWorldXDisp=1012]="ExtendedDataWorldXDisp",s[s.ExtendedDataWorldXDir=1013]="ExtendedDataWorldXDir",s[s.ExtendedDataYCoordinate=1020]="ExtendedDataYCoordinate",s[s.ExtendedDataWorldYCoordinate=1021]="ExtendedDataWorldYCoordinate",s[s.ExtendedDataWorldYDisp=1022]="ExtendedDataWorldYDisp",s[s.ExtendedDataWorldYDir=1023]="ExtendedDataWorldYDir",s[s.ExtendedDataZCoordinate=1030]="ExtendedDataZCoordinate",s[s.ExtendedDataWorldZCoordinate=1031]="ExtendedDataWorldZCoordinate",s[s.ExtendedDataWorldZDisp=1032]="ExtendedDataWorldZDisp",s[s.ExtendedDataWorldZDir=1033]="ExtendedDataWorldZDir",s[s.ExtendedDataReal=1040]="ExtendedDataReal",s[s.ExtendedDataDist=1041]="ExtendedDataDist",s[s.ExtendedDataScale=1042]="ExtendedDataScale",s[s.ExtendedDataInteger16=1070]="ExtendedDataInteger16",s[s.ExtendedDataInteger32=1071]="ExtendedDataInteger32",s[s.XTextString=300]="XTextString",s[s.XReal=140]="XReal",s[s.XInt16=170]="XInt16",s[s.XXInt16=270]="XXInt16",s[s.Subclass=100]="Subclass",s[s.ControlString=102]="ControlString",s[s.EmbeddedObjectStart=101]="EmbeddedObjectStart",s[s.End=-1]="End",s[s.FirstEntityId=-2]="FirstEntityId",s[s.HeaderId=-2]="HeaderId",s[s.XDataStart=-3]="XDataStart",s[s.Operator=-4]="Operator",s[s.PReactors=-5]="PReactors",s[s.XDictionary=-6]="XDictionary",s))(xr||{});const On=[{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 At{constructor(t){if(typeof t=="string"){const e=On.find(i=>i.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=On.find(i=>i.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 ta{constructor(t={}){this._database=t.database,this._precision=Math.max(0,Math.min(16,t.precision??16)),this._version=t.version instanceof At?t.version:t.version!=null?new At(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 At?t:new At(t),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 i=this.formatValue(e);return this._lines.push(i===""?"0":i),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 i=this.resolveHandle(e);return i?this.writeString(t,i):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,i=420){if(!t)return this;const r=t.colorIndex;r!=null&&this.writeInt16(e,r);const n=t.RGB;return n!=null&&t.colorIndex==null&&this.writeInt32(i,n),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 i=t.toFixed(this._precision).replace(/\.?0+$/,"");return i===""||i==="-"?"0":i}return String(t)}sanitizeStringForDxfLine(t){return t.replace(/\r\n|\r|\n/g," ").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,"")}}function il(s,t){for(var e=0;e<t.length;e++){const i=t[e];if(typeof i!="string"&&!Array.isArray(i)){for(const r in i)if(r!=="default"&&!(r in s)){const n=Object.getOwnPropertyDescriptor(i,r);n&&Object.defineProperty(s,r,n.get?n:{enumerable:!0,get:()=>i[r]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}var E=(s=>(s[s.ByColor=1]="ByColor",s[s.ByACI=2]="ByACI",s[s.ByLayer=3]="ByLayer",s[s.ByBlock=4]="ByBlock",s[s.None=0]="None",s))(E||{});const Cn={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},Xi=[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 le=class{static getColorByIndex(t){return Xi[t]}static getIndexByColor(t){const e=Xi.length-1;for(let i=1;i<e;++i)if(Xi[i]===t)return i}static getColorByName(t){return Cn[t.toLowerCase()]}static getNameByColor(t){for(const[e,i]of Object.entries(Cn))if(i===t)return e}static getNameByIndex(t){const e=this.getColorByIndex(t);return this.getNameByColor(e)}},J=class ee{constructor(t=E.ByLayer,e){this._colorMethod=t,this._colorMethod==E.ByColor&&e==null?this._value=16777215:this._colorMethod==E.ByACI?e==null?this._value=8:e===0?this._colorMethod=E.ByBlock:e===256?this._colorMethod=E.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 E.ByColor:case E.ByBlock:case E.ByLayer:return this._value;case E.ByACI:return this._value?le.getColorByIndex(this._value):this._value;default:return}}setRGB(t,e,i){const r=Math.max(0,Math.min(255,Math.round(t))),n=Math.max(0,Math.min(255,Math.round(e))),a=Math.max(0,Math.min(255,Math.round(i)));return this._value=r<<16|n<<8|a,this._colorMethod=E.ByColor,this}setRGBValue(t){return t==null||!Number.isFinite(t)?this:(this._value=t&16777215,this._colorMethod=E.ByColor,this)}setRGBFromCss(t){if(!t)return this;const e=t.trim().toLowerCase();if(e.startsWith("#")){let n=0,a=0,o=0;if(e.length===7)n=parseInt(e.substr(1,2),16),a=parseInt(e.substr(3,2),16),o=parseInt(e.substr(5,2),16);else if(e.length===4)n=parseInt(e[1]+e[1],16),a=parseInt(e[2]+e[2],16),o=parseInt(e[3]+e[3],16);else return this;return this.setRGB(n,a,o)}const i=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(i){const n=parseInt(i[1],10),a=parseInt(i[2],10),o=parseInt(i[3],10);return this.setRGB(n,a,o)}const r=le.getColorByName(t);return r!==void 0?this.setRGBValue(r):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===E.ByACI?this._value:this._colorMethod===E.ByLayer?256:this._colorMethod===E.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=E.ByBlock,this._value=void 0):e===256?(this._colorMethod=E.ByLayer,this._value=void 0):(this._colorMethod=E.ByACI,this._value=e)}get isByColor(){return this._colorMethod===E.ByColor}get isByACI(){return this._colorMethod===E.ByACI}get isForeground(){return this._colorMethod===E.ByACI&&this._value===7}setForeground(){return this._colorMethod=E.ByACI,this._value=7,this}get isByLayer(){return this._colorMethod===E.ByLayer}setByLayer(t){return this._colorMethod=E.ByLayer,t==null?this._value=256:this._value=t,this}get isByBlock(){return this._colorMethod===E.ByBlock}setByBlock(t){return this._colorMethod=E.ByBlock,t==null?this._value=0:this._value=t,this}get colorName(){switch(this._colorMethod){case E.ByLayer:return"ByLayer";case E.ByBlock:return"ByBlock";case E.ByColor:return this._value?le.getNameByColor(this._value):"";case E.ByACI:return this._value?le.getNameByIndex(this._value):"";default:return}}set colorName(t){if(!t)return;const e=le.getColorByName(t);e!==void 0&&(this._value=e,this._colorMethod=E.ByColor)}clone(){const t=new ee;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 E.ByLayer:return"ByLayer";case E.ByBlock:return"ByBlock";case E.ByACI:return this._value!==void 0?String(this._value):"";case E.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 ee(E.ByLayer);if(/^byblock$/i.test(e))return new ee(E.ByBlock);const i=e.match(/^rgb\s*:\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})$/i);if(i){const n=Number(i[1]),a=Number(i[2]),o=Number(i[3]),l=new ee(E.ByColor);return l.setRGB(n,a,o),l}if(/^\d{1,3},\d{1,3},\d{1,3}$/.test(e)){const[n,a,o]=e.split(",").map(Number),l=new ee(E.ByColor);return l.setRGB(n,a,o),l}if(/^\d+$/.test(e)){const n=parseInt(e,10);return new ee(E.ByACI,n)}if(/^book\$/i.test(e)){const n=e.substring(e.indexOf("$")+1),a=le.getColorByName(n);return a!=null?new ee(E.ByColor,a):void 0}const r=le.getColorByName(e);if(r!=null)return new ee(E.ByColor,r)}};class rl{constructor(t=E.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=E.ByColor,this._value=this._value&65535|(t&255)<<16}get green(){return this._value>>8&255}set green(t){this._colorMethod=E.ByColor,this._value=this._value&16711935|(t&255)<<8}get blue(){return this._value&255}set blue(t){this._colorMethod=E.ByColor,this._value=this._value&16776960|t&255}setRGB(t,e,i){this._colorMethod=E.ByColor,this._value=(t&255)<<16|(e&255)<<8|i&255}get colorIndex(){return this._value}set colorIndex(t){this._colorMethod=E.ByACI,this._value=t}get layerIndex(){return this._value}set layerIndex(t){this._colorMethod=E.ByLayer,this._value=t}isByColor(){return this._colorMethod===E.ByColor}isByLayer(){return this._colorMethod===E.ByLayer}isByBlock(){return this._colorMethod===E.ByBlock}isByACI(){return this._colorMethod===E.ByACI}isNone(){return this._colorMethod===E.None}get rawValue(){return this._value}set rawValue(t){this._value=t}}const gt={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 nl=class{constructor(){this._listeners={}}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const i=this._listeners;return i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const i=this._listeners[t];if(i!==void 0){const r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const e=this._listeners[t.type];if(e!==void 0){t.target=this;const i=e.slice(0);for(let r=0,n=i.length;r<n;r++)i[r].call(this,t)}}},Z=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 i of this.listeners)i.call(null,t,...e)}};function ws(s){return s===null||typeof s!="object"?s:Array.isArray(s)?[...s]:{...s}}function ar(s){if(s===null||typeof s!="object")return s;if(s instanceof Date)return new Date(s.getTime());if(s instanceof RegExp)return new RegExp(s.source,s.flags);if(Array.isArray(s))return s.map(ar);const t={};for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(t[e]=ar(s[e]));return t}function Rs(s,...t){for(const e of t)if(e)for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&s[i]===void 0&&(s[i]=e[i]);return s}function ea(s,t){return s!=null&&Object.prototype.hasOwnProperty.call(s,t)}function sa(s){return s==null?!0:Array.isArray(s)||typeof s=="string"?s.length===0:s instanceof Map||s instanceof Set?s.size===0:typeof s=="object"?Object.keys(s).length===0:!1}function $e(s,t){if(s===t)return!0;if(s==null||t==null)return s===t;if(typeof s!=typeof t)return!1;if(typeof s!="object")return s===t;if(Array.isArray(s)!==Array.isArray(t))return!1;if(Array.isArray(s)){if(s.length!==t.length)return!1;for(let r=0;r<s.length;r++)if(!$e(s[r],t[r]))return!1;return!0}const e=Object.keys(s),i=Object.keys(t);if(e.length!==i.length)return!1;for(const r of e)if(!Object.prototype.hasOwnProperty.call(t,r)||!$e(s[r],t[r]))return!1;return!0}var al=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ol(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var ia={exports:{}};(function(s){(function(t,e){s.exports?s.exports=e():t.log=e()})(al,function(){var t=function(){},e="undefined",i=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"],n={},a=null;function o(y,x){var w=y[x];if(typeof w.bind=="function")return w.bind(y);try{return Function.prototype.bind.call(w,y)}catch{return function(){return Function.prototype.apply.apply(w,[y,arguments])}}}function l(){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"&&i?l:console[y]!==void 0?o(console,y):console.log!==void 0?o(console,"log"):t}function d(){for(var y=this.getLevel(),x=0;x<r.length;x++){var w=r[x];this[w]=x<y?t:this.methodFactory(w,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 m(y,x,w){return c(y)||u.apply(this,arguments)}function p(y,x){var w=this,P,I,k,A="loglevel";typeof y=="string"?A+=":"+y:typeof y=="symbol"&&(A=void 0);function j(B){var H=(r[B]||"silent").toUpperCase();if(!(typeof window===e||!A)){try{window.localStorage[A]=H;return}catch{}try{window.document.cookie=encodeURIComponent(A)+"="+H+";"}catch{}}}function T(){var B;if(!(typeof window===e||!A)){try{B=window.localStorage[A]}catch{}if(typeof B===e)try{var H=window.document.cookie,_e=encodeURIComponent(A),we=H.indexOf(_e+"=");we!==-1&&(B=/^([^;]+)/.exec(H.slice(we+_e.length+1))[1])}catch{}return w.levels[B]===void 0&&(B=void 0),B}}function $(){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 F(B){var H=B;if(typeof H=="string"&&w.levels[H.toUpperCase()]!==void 0&&(H=w.levels[H.toUpperCase()]),typeof H=="number"&&H>=0&&H<=w.levels.SILENT)return H;throw new TypeError("log.setLevel() called with invalid level: "+B)}w.name=y,w.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},w.methodFactory=x||m,w.getLevel=function(){return k??I??P},w.setLevel=function(B,H){return k=F(B),H!==!1&&j(k),d.call(w)},w.setDefaultLevel=function(B){I=F(B),T()||w.setLevel(B,!1)},w.resetLevel=function(){k=null,$(),d.call(w)},w.enableAll=function(B){w.setLevel(w.levels.TRACE,B)},w.disableAll=function(B){w.setLevel(w.levels.SILENT,B)},w.rebuild=function(){if(a!==w&&(P=F(a.getLevel())),d.call(w),a===w)for(var B in n)n[B].rebuild()},P=F(a?a.getLevel():"WARN");var tt=T();tt!=null&&(k=F(tt)),d.call(w)}a=new p,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=n[y];return x||(x=n[y]=new p(y,a.methodFactory)),x};var g=typeof window!==e?window.log:void 0;return a.noConflict=function(){return typeof window!==e&&window.log===a&&(window.log=g),a},a.getLoggers=function(){return n},a.default=a,a})})(ia);var ra=ia.exports;const hl=ol(ra),ll=il({__proto__:null,default:hl},[ra]),cl=!0,bs=ll;bs.setLevel("debug");const dl=s=>{try{bs.setLevel(s)}catch(t){bs.setLevel("error"),bs.error(t)}};let na=class aa{constructor(t,e){this.events={attrChanged:new Z,modelChanged:new Z},this._changing=!1,this._previousAttributes={},this._pending=!1;const i=t||{};e&&Rs(i,e),this.attributes=i,this.changed={}}get(t){return this.attributes[t]}set(t,e,i){if(t==null)return this;let r;typeof t=="object"?(r=t,i=e):(r={},r[t]=e),i||(i={});const n=i.unset,a=i.silent,o=[],l=this._changing;this._changing=!0,l||(this._previousAttributes=ws(this.attributes),this.changed={});const c=this.attributes,d=this.changed,u=this._previousAttributes;for(const m in r)e=r[m],$e(c[m],e)||o.push(m),$e(u[m],e)?delete d[m]:d[m]=e,n?delete c[m]:c[m]=e;if(!a){o.length&&(this._pending=i);for(let m=0;m<o.length;m++)this.events.attrChanged.dispatch({object:this,attrName:o[m],attrValue:c[o[m]],options:i})}if(l)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(t){return this.get(t)!=null}hasChanged(t){return t==null?!sa(this.changed):ea(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?ws(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,i={};for(const r in t){const n=t[r];$e(e[r],n)||(i[r]=n)}return i}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return ws(this._previousAttributes)}clone(){const t=ws(this.attributes);return new aa(t)}},br=class xs{constructor(){this.entries=new Map}static getInstance(){return xs.instance||(xs.instance=new xs),xs.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 ul{static formatBytes(t,e=2){if(t===0)return"0 B";const i=1024,r=Math.max(0,e),n=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(t)/Math.log(i)),o=t/Math.pow(i,a);return`${parseFloat(o.toFixed(r))} ${n[a]}`}}var dt=(s=>(s[s.ByLayer=0]="ByLayer",s[s.ByBlock=1]="ByBlock",s[s.ByAlpha=2]="ByAlpha",s[s.ErrorValue=3]="ErrorValue",s))(dt||{});let Di=class Nt{constructor(t){t!==void 0?(this._method=dt.ByAlpha,this._alpha=Nt.clampAlpha(t)):(this._method=dt.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=Nt.clampAlpha(t),this._method=dt.ByAlpha}get percentage(){if(this._method===dt.ByAlpha)return Math.round((1-this._alpha/255)*100)}set percentage(t){const e=Math.max(0,Math.min(100,t)),i=Math.round(255*(1-e/100));this.alpha=i}static clampAlpha(t){return Math.max(0,Math.min(255,Math.floor(t)))}get isByAlpha(){return this._method===dt.ByAlpha}get isByBlock(){return this._method===dt.ByBlock}get isByLayer(){return this._method===dt.ByLayer}get isClear(){return this.isByAlpha&&this._alpha===0}get isSolid(){return this.isByAlpha&&this._alpha===255}get isInvalid(){return this._method===dt.ErrorValue}serialize(){return this._method<<24|this._alpha}clone(){const t=new Nt;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 n=new Nt;return n._method=dt.ByLayer,n}if(/^byblock$/i.test(e)){const n=new Nt;return n._method=dt.ByBlock,n}const i=Number(e);if(Number.isInteger(i)&&i>=0&&i<=255)return new Nt(i);const r=new Nt;return r._method=dt.ErrorValue,r}static deserialize(t){const e=t>>>24&255,i=t&255,r=Object.values(dt)[e]??dt.ErrorValue,n=new Nt;return n._method=r,n._alpha=Nt.clampAlpha(i),n}};class oa{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}class ha{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>!1}scheduleTask(t){return new Promise((e,i)=>{const r=()=>{Promise.resolve(t()).then(e).catch(i)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(r):setTimeout(r,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 i=t;for(let r=0;r<e;r++){const n=this.tasks[r];try{i=await this.scheduleTask(async()=>{const a=await n.run(i);return this.onProgress((r+1)/e,n),a})}catch(a){if(this.onError({error:a,taskIndex:r,task:n}))return Promise.reject(a)}}this.onComplete(i)}}let la=class{constructor(t,e,i){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=i}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,i=this.handlers.length;e<i;e+=2){const r=this.handlers[e],n=this.handlers[e+1];if(r.global&&(r.lastIndex=0),r.test(t))return n}return null}};const ca=new la;class pl{constructor(t){this.manager=t!==void 0?t:ca,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((i,r)=>{this.load(t,i,e,r)})}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 Re=256,da=[],Fn=256,Zs;for(;Re--;)da[Re]=(Re+256).toString(16).substring(1);function ml(s){var t=0,e=11;if(!Zs||Re+e>Fn*2)for(Zs="",Re=0;t<Fn;t++)Zs+=da[Math.random()*256|0];return Zs.substring(Re,Re+++e)}const si="TEMP_";let or;function ua(s){or=s}class ne{constructor(t,e){if(t=t||{},this._attrs=new na(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 si+ml()}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(si)&&this.database.updateMaxHandle(t)}get isTemp(){const t=this.getAttrWithoutException("objectId");return!!t&&t.startsWith(si)}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(or)return or().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===xr.ExtendedDataRegAppName&&this._xDataMap.set(e.value,t)}removeXData(t){this._xDataMap.delete(t)}createExtensionDictionary(){}close(){}dxfOut(...t){const[e,i=!1]=t;if(e.writeHandle(5,this.objectId),e.writeObjectId(330,this.ownerId),e.writeObjectId(360,this.extensionDictionary),this.dxfOutFields(e),i)for(const r of this._xDataMap.values())e.writeResultBuffer(r);return this}dxfOutFields(t){return this}}let hr;function pa(s){hr=s}function fr(){return ci.instance}const Ri=class Ri{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(!hr)throw new Error("The layout manager factory must be registered before using it!");this._layoutManager=hr()}return this._layoutManager}};Ri.instance=new Ri;let ci=Ri;ua(fr);var ma=(s=>(s.kForRead="kForRead",s.kForWrite="kForWrite",s))(ma||{});class Ir{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 Ir(this._values)}[Symbol.iterator](){return this._values[Symbol.iterator]()}}class Sr{constructor(t,e,i){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=i,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,i)=>{const r=()=>{Promise.resolve(t()).then(e).catch(i)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(r):setTimeout(r,0)})}async processChunk(t,e){if(this._count<=0){await(e==null?void 0:e());return}let i=0;const r=async()=>{const n=i,a=Math.min(i+this._chunkSize,this._count);await t(n,a),i=a,i<this._count&&await this.scheduleTask(r)};await r(),await(e==null?void 0:e())}}var fs=(s=>(s.DXF="dxf",s.DWG="dwg",s))(fs||{});class Ft{constructor(){this.events={registered:new Z,unregistered:new Z},this._converters=new Map,this.register("dxf",new el)}static createInstance(){return Ft._instance==null&&(Ft._instance=new Ft),this._instance}static get instance(){return Ft._instance||(Ft._instance=new Ft),Ft._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 Er=(s=>(s[s.DecimalDegrees=0]="DecimalDegrees",s[s.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",s[s.Gradians=2]="Gradians",s[s.Radians=3]="Radians",s[s.SurveyorsUnits=4]="SurveyorsUnits",s))(Er||{});class Je{static get instance(){return this._instance||(this._instance=new Je),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,i,r=[],n=!0,a,o){const l=[];if(e!=null){const c=this.createKey(e.name,i);let d;if(this.has(c))d=this.get(c);else{const u=e.newIterator();for(const m of u)m.color.isByBlock&&i?(Bn.copy(m.color),m.color.setRGBValue(i),this.addEntity(m,l,t),m.color.copy(Bn)):this.addEntity(m,l,t);d=t.group(l),d&&n&&K.name&&!K.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&&r&&r.length>0&&(d.bakeTransformToChildren(),r.forEach(u=>d.addChild(u))),d}else return t.group(l)}addEntity(t,e,i){const r=t.worldDraw(i);r&&(this.attachEntityInfo(r,t),e.push(r))}attachEntityInfo(t,e){t.objectId=e.objectId,t.ownerId=e.ownerId,t.layerName=e.layer,t.visible=e.visibility}}const Bn=new J;var Pr=(s=>(s[s.UTF8=0]="UTF8",s[s.US_ASCII=1]="US_ASCII",s[s.ISO_8859_1=2]="ISO_8859_1",s[s.ISO_8859_2=3]="ISO_8859_2",s[s.ISO_8859_3=4]="ISO_8859_3",s[s.ISO_8859_4=5]="ISO_8859_4",s[s.ISO_8859_5=6]="ISO_8859_5",s[s.ISO_8859_6=7]="ISO_8859_6",s[s.ISO_8859_7=8]="ISO_8859_7",s[s.ISO_8859_8=9]="ISO_8859_8",s[s.ISO_8859_9=10]="ISO_8859_9",s[s.CP437=11]="CP437",s[s.CP850=12]="CP850",s[s.CP852=13]="CP852",s[s.CP855=14]="CP855",s[s.CP857=15]="CP857",s[s.CP860=16]="CP860",s[s.CP861=17]="CP861",s[s.CP863=18]="CP863",s[s.CP864=19]="CP864",s[s.CP865=20]="CP865",s[s.CP869=21]="CP869",s[s.CP932=22]="CP932",s[s.MACINTOSH=23]="MACINTOSH",s[s.BIG5=24]="BIG5",s[s.CP949=25]="CP949",s[s.JOHAB=26]="JOHAB",s[s.CP866=27]="CP866",s[s.ANSI_1250=28]="ANSI_1250",s[s.ANSI_1251=29]="ANSI_1251",s[s.ANSI_1252=30]="ANSI_1252",s[s.GB2312=31]="GB2312",s[s.ANSI_1253=32]="ANSI_1253",s[s.ANSI_1254=33]="ANSI_1254",s[s.ANSI_1255=34]="ANSI_1255",s[s.ANSI_1256=35]="ANSI_1256",s[s.ANSI_1257=36]="ANSI_1257",s[s.ANSI_874=37]="ANSI_874",s[s.ANSI_932=38]="ANSI_932",s[s.ANSI_936=39]="ANSI_936",s[s.ANSI_949=40]="ANSI_949",s[s.ANSI_950=41]="ANSI_950",s[s.ANSI_1361=42]="ANSI_1361",s[s.UTF16=43]="UTF16",s[s.ANSI_1258=44]="ANSI_1258",s[s.UNDEFINED=255]="UNDEFINED",s))(Pr||{});const gl=["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"],ga=s=>gl[s],qe="Continuous",Y="Standard",Ze="ByLayer",di="ByBlock",lr="mlightcad",cr="ACAD",nt=["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 Rn=1234567;const Ar=Math.PI/180,Tr=180/Math.PI;function ya(){const s=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(nt[s&255]+nt[s>>8&255]+nt[s>>16&255]+nt[s>>24&255]+"-"+nt[t&255]+nt[t>>8&255]+"-"+nt[t>>16&15|64]+nt[t>>24&255]+"-"+nt[e&63|128]+nt[e>>8&255]+"-"+nt[e>>16&255]+nt[e>>24&255]+nt[i&255]+nt[i>>8&255]+nt[i>>16&255]+nt[i>>24&255]).toLowerCase()}function se(s,t,e){return Math.max(t,Math.min(e,s))}function Mr(s,t){return(s%t+t)%t}function _a(s,t,e,i,r){return i+(s-t)*(r-i)/(e-t)}function wa(s,t,e){return s!==t?(e-s)/(t-s):0}function vr(s,t,e){return(1-e)*s+e*t}function xa(s,t,e,i){return vr(s,t,1-Math.exp(-e*i))}function ba(s,t=1){return t-Math.abs(Mr(s,t*2)-t)}function fa(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*(3-2*s))}function Ia(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*s*(s*(s*6-15)+10))}function Sa(s,t){return s+Math.floor(Math.random()*(t-s+1))}function Ea(s,t){return s+Math.random()*(t-s)}function Pa(s){return s*(.5-Math.random())}function Aa(s){s!==void 0&&(Rn=s);let t=Rn+=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 Ta(s){return s*Ar}function Ma(s){return s*Tr}function va(s){return(s&s-1)===0&&s!==0}function ka(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function La(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function Is(s){const t=Math.PI*2;return(s%t+t)%t}function Na(s,t,e){return s>t&&s<e||s>e&&s<t}function Oa(s,t,e,i=!1){return s=Is(s),t=Is(t),e=Is(e),i?t>e?s<=t&&s>=e:s<=t||s>=e:t<e?s>=t&&s<=e:s>=t||s<=e}function kr(s){return s=Math.abs(s),s<1?0:Math.ceil(Math.log10(Math.abs(s)+1))}function Ca(s,t=1e-7){const e=kr(s);return Math.max(Math.pow(10,e)*t,t)}const N={DEG2RAD:Ar,RAD2DEG:Tr,generateUUID:ya,clamp:se,euclideanModulo:Mr,mapLinear:_a,inverseLerp:wa,lerp:vr,damp:xa,pingpong:ba,smoothstep:fa,smootherstep:Ia,randInt:Sa,randFloat:Ea,randFloatSpread:Pa,seededRandom:Aa,degToRad:Ta,radToDeg:Ma,isPowerOfTwo:va,ceilPowerOfTwo:ka,floorPowerOfTwo:La,normalizeAngle:Is,isBetween:Na,isBetweenAngle:Oa,intPartLength:kr,relativeEps:Ca},dr=class Fa{constructor(t,e){this.x=0,this.y=0;const i=+(t!==void 0)+ +(e!==void 0);if(i!==0){if(i===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(i===1){const{x:r,y:n}=t;this.x=r,this.y=n;return}if(i===2){this.x=t,this.y=e;return}throw gt.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 Fa(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,i=this.y,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6],this.y=r[1]*e+r[4]*i+r[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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,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(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 i=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,i)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,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 i=Math.cos(e),r=Math.sin(e),n=this.x-t.x,a=this.y-t.y;return this.x=n*i-a*r+t.x,this.y=n*r+a*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(N.relativeEps(this.x,t),N.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};dr.EMPTY=Object.freeze(new dr(0,0));let U=dr;const ur=class Ba{constructor(t,e,i,r,n,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&i!=null&&r!=null&&n!=null&&a!=null&&o!=null&&l!=null&&c!=null&&this.set(t,e,i,r,n,a,o,l,c)}set(t,e,i,r,n,a,o,l,c){const d=this.elements;return d[0]=t,d[1]=r,d[2]=o,d[3]=e,d[4]=n,d[5]=l,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(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.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 i=t.elements,r=e.elements,n=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],d=i[4],u=i[7],m=i[2],p=i[5],g=i[8],y=r[0],x=r[3],w=r[6],P=r[1],I=r[4],k=r[7],A=r[2],j=r[5],T=r[8];return n[0]=a*y+o*P+l*A,n[3]=a*x+o*I+l*j,n[6]=a*w+o*k+l*T,n[1]=c*y+d*P+u*A,n[4]=c*x+d*I+u*j,n[7]=c*w+d*k+u*T,n[2]=m*y+p*P+g*A,n[5]=m*x+p*I+g*j,n[8]=m*w+p*k+g*T,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],i=t[1],r=t[2],n=t[3],a=t[4],o=t[5],l=t[6],c=t[7],d=t[8];return e*a*d-e*o*c-i*n*d+i*o*l+r*n*c-r*a*l}invert(){const t=this.elements,e=t[0],i=t[1],r=t[2],n=t[3],a=t[4],o=t[5],l=t[6],c=t[7],d=t[8],u=d*a-o*c,m=o*l-d*n,p=c*n-a*l,g=e*u+i*m+r*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/g;return t[0]=u*y,t[1]=(r*c-d*i)*y,t[2]=(o*i-r*a)*y,t[3]=m*y,t[4]=(d*e-r*l)*y,t[5]=(r*n-o*e)*y,t[6]=p*y,t[7]=(i*l-c*e)*y,t[8]=(a*e-i*n)*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,i,r,n,a,o){const l=Math.cos(n),c=Math.sin(n);return this.set(i*l,i*c,-i*(l*a+c*o)+a+t,-r*c,r*l,-r*(-c*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Yi.makeScale(t,e)),this}rotate(t){return this.premultiply(Yi.makeRotation(-t)),this}translate(t,e){return this.premultiply(Yi.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof U?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),i=Math.sin(t);return this.set(e,-i,0,i,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,i=t.elements;for(let r=0;r<9;r++)if(e[r]!==i[r])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new Ba().fromArray(this.elements)}};ur.IDENTITY=Object.freeze(new ur);let ji=ur;const Yi=new ji,Be=1e-6,G=2*Math.PI,yl={x:0,y:0},Lr={x:0,y:0,z:0};class Nr{constructor(){this.equalPointTol=Be,this.equalVectorTol=Be}equalPoint2d(t,e){return new U(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new f(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=Be){return t<e&&t>-e}static equal(t,e,i=Be){return Math.abs(t-e)<i}static great(t,e,i=Be){return t-e>i}static less(t,e,i=Be){return t-e<i}}const Or=new Nr;function Cr(s,t,e=!1){const i=s.x,r=s.y;let n=!1;const a=t.length;for(let o=0,l=a-1;o<a;l=o++){const c=t[o].x,d=t[o].y,u=t[l].x,m=t[l].y;let p=d>r!=m>r;e&&(p=d>=r!=m>=r),p&&i<(u-c)*(r-d)/(m-d)+c&&(n=!n)}return n}function Ra(s,t){if(s.length===0||t.length===0)return!1;const e=new ut().setFromPoints(s),i=new ut().setFromPoints(t);if(!e.intersectsBox(i))return!1;for(let r=0;r<s.length;){if(Cr(s[r],t,!0))return!0;r<s.length-1&&Or.equalPoint2d(s[r+1],s[r])&&++r,++r}return!1}const za={isPointInPolygon:Cr,isPolygonIntersect:Ra};function _l(s,t){const e=[],i=t-1,r=s;for(let n=0;n<=r;n++)e.push(0);for(let n=1;n<=i-r;n++)e.push(n);for(let n=0;n<=r;n++)e.push(i-r+1);return e}function wl(s,t){const e=t.length-1,i=s,r=[0];let n=0;for(let o=1;o<=e;o++){const l=t[o][0]-t[o-1][0],c=t[o][1]-t[o-1][1],d=t[o][2]-t[o-1][2],u=Math.sqrt(l*l+c*c+d*d);n+=u,r.push(n)}const a=[];for(let o=0;o<=i;o++)a.push(0);for(let o=1;o<=e-i;o++){const l=r[o]/n;a.push(l*(e-i+1))}for(let o=0;o<=i;o++)a.push(e-i+1);return a}function Va(s,t="Uniform"){const e=s.length;if(e===0)return[];if(e===1)return[0];const i=e-1;if(t==="Uniform")return new Array(e).fill(0).map((a,o)=>o/i);const r=[0];let n=0;for(let a=1;a<=i;a++){const o=s[a][0]-s[a-1][0],l=s[a][1]-s[a-1][1],c=s[a][2]-s[a-1][2],d=Math.sqrt(o*o+l*l+c*c),u=t==="SqrtChord"?Math.sqrt(d):d;n+=u,r.push(n)}return n<1e-12?new Array(e).fill(0).map((a,o)=>o/i):r.map(a=>a/n)}function Da(s,t){const e=t.length-1,i=s,r=e+i+1,n=new Array(r+1).fill(0),a=t[t.length-1];for(let o=r-i;o<=r;o++)n[o]=a;for(let o=1;o<=e-i;o++){let l=0;for(let c=o;c<o+i;c++)l+=t[c];n[o+i]=l/i}return n}function xl(s,t){const e=t.length-1,i=s,r=[0];let n=0;for(let o=1;o<=e;o++){const l=t[o][0]-t[o-1][0],c=t[o][1]-t[o-1][1],d=t[o][2]-t[o-1][2],u=Math.sqrt(l*l+c*c+d*d),m=Math.sqrt(u);n+=m,r.push(n)}const a=[];for(let o=0;o<=i;o++)a.push(0);for(let o=1;o<=e-i;o++){const l=r[o]/n;a.push(l*(e-i+1))}for(let o=0;o<=i;o++)a.push(e-i+1);return a}function $i(s,t){const e=s.length,i=s.map(a=>a.slice()),r=t.slice();for(let a=0;a<e;a++){let o=a,l=Math.abs(i[a][a]);for(let c=a+1;c<e;c++){const d=Math.abs(i[c][a]);d>l&&(l=d,o=c)}if(l<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=r[a];r[a]=r[o],r[o]=d}for(let c=a+1;c<e;c++){const d=i[c][a]/i[a][a];if(!(Math.abs(d)<1e-14)){for(let u=a;u<e;u++)i[c][u]-=d*i[a][u];r[c]-=d*r[a]}}}const n=new Array(e).fill(0);for(let a=e-1;a>=0;a--){let o=r[a];for(let l=a+1;l<e;l++)o-=i[a][l]*n[l];n[a]=o/i[a][a]}return n}function Fr(s,t,e="Uniform",i,r){if(s.length===0)return{controlPoints:[],knots:[],weights:[]};const n=s.map(F=>[F[0],F[1],F[2]??0]),a=!!i,o=!!r,l=(a?1:0)+(o?1:0),c=n.length-1,d=c+l;if(d<t)throw new Error("Not enough points to interpolate a curve of this degree.");const u=Va(n,e),m=u.slice();a&&m.unshift(u[0]),o&&m.push(u[u.length-1]);const p=Da(t,m),g=d+1,y=new Array(g),x=new Array(g),w=new Array(g),P=new Array(g);let I=0;y[I]=new Array(g).fill(0),y[I][0]=1,x[I]=n[0][0],w[I]=n[0][1],P[I]=n[0][2],I++;for(let F=1;F<=c-1;F++){const tt=u[F];y[I]=new Array(g).fill(0);for(let B=0;B<=d;B++)y[I][B]=Ms(B,t,tt,p);x[I]=n[F][0],w[I]=n[F][1],P[I]=n[F][2],I++}if(y[I]=new Array(g).fill(0),y[I][d]=1,x[I]=n[c][0],w[I]=n[c][1],P[I]=n[c][2],I++,a){const F=p[t+1]-p[0],tt=F!==0?t/F:0;y[I]=new Array(g).fill(0),y[I][0]=-tt,y[I][1]=tt,x[I]=(i==null?void 0:i[0])??0,w[I]=(i==null?void 0:i[1])??0,P[I]=(i==null?void 0:i[2])??0,I++}if(o){const F=p[d+t+1]-p[d],tt=F!==0?t/F:0;y[I]=new Array(g).fill(0),y[I][d-1]=-tt,y[I][d]=tt,x[I]=(r==null?void 0:r[0])??0,w[I]=(r==null?void 0:r[1])??0,P[I]=(r==null?void 0:r[2])??0,I++}const k=$i(y,x),A=$i(y,w),j=$i(y,P),T=new Array(g);for(let F=0;F<g;F++)T[F]=[k[F],A[F],j[F]];const $=new Array(g).fill(1);return{controlPoints:T,knots:p,weights:$}}function Ms(s,t,e,i){if(t===0)return e>=i[s]&&e<i[s+1]?1:0;const r=i[s+t]-i[s],n=i[s+t+1]-i[s+1],a=r>1e-10?(e-i[s])/r:0,o=n>1e-10?(i[s+t+1]-e)/n:0;return a*Ms(s,t-1,e,i)+o*Ms(s+1,t-1,e,i)}function Ss(s,t,e,i,r){const n=i.length-1,a=t;if(s=Math.max(e[a],Math.min(e[n+1],s)),Math.abs(s-e[n+1])<1e-8)return[...i[n]];if(Math.abs(s-e[a])<1e-8)return[...i[0]];const o=[0,0,0];let l=0;for(let c=0;c<=n;c++){const d=Ms(c,a,s,e),u=r[c]*d;o[0]+=i[c][0]*u,o[1]+=i[c][1]*u,o[2]+=i[c][2]*u,l+=u}if(Math.abs(l)<1e-10){const c=e[e.length-a-1];if(Math.abs(s-c)<1e-8)return[...i[n]];if(Math.abs(s-e[a])<1e-8)return[...i[0]]}return Math.abs(l)>=1e-10&&(o[0]/=l,o[1]/=l,o[2]/=l),o}function ja(s,t,e,i){const r=s,n=t[r],a=t[t.length-r-1];let o=0;const l=1e3,c=(a-n)/l;let d=Ss(n,s,t,e,i);for(let y=1;y<=l;y++){const x=n+y*c,w=Ss(x,s,t,e,i),P=w[0]-d[0],I=w[1]-d[1],k=w[2]-d[2];o+=Math.sqrt(P*P+I*I+k*k),d=w}const u=Ss(a,s,t,e,i),m=u[0]-d[0],p=u[1]-d[1],g=u[2]-d[2];return o+=Math.sqrt(m*m+p*p+g*g),o}function bl(s,t=3,e="Uniform",i,r){return s.length===0?[]:Fr(s,t,e,i,r).controlPoints}class Ge{constructor(t=0,e=0,i=0,r=1){this._x=t,this._y=e,this._z=i,this._w=r}static slerpFlat(t,e,i,r,n,a,o){let l=i[r+0],c=i[r+1],d=i[r+2],u=i[r+3];const m=n[a+0],p=n[a+1],g=n[a+2],y=n[a+3];if(o===0){t[e+0]=l,t[e+1]=c,t[e+2]=d,t[e+3]=u;return}if(o===1){t[e+0]=m,t[e+1]=p,t[e+2]=g,t[e+3]=y;return}if(u!==y||l!==m||c!==p||d!==g){let x=1-o;const w=l*m+c*p+d*g+u*y,P=w>=0?1:-1,I=1-w*w;if(I>Number.EPSILON){const A=Math.sqrt(I),j=Math.atan2(A,w*P);x=Math.sin(x*j)/A,o=Math.sin(o*j)/A}const k=o*P;if(l=l*x+m*k,c=c*x+p*k,d=d*x+g*k,u=u*x+y*k,x===1-o){const A=1/Math.sqrt(l*l+c*c+d*d+u*u);l*=A,c*=A,d*=A,u*=A}}t[e]=l,t[e+1]=c,t[e+2]=d,t[e+3]=u}static multiplyQuaternionsFlat(t,e,i,r,n,a){const o=i[r],l=i[r+1],c=i[r+2],d=i[r+3],u=n[a],m=n[a+1],p=n[a+2],g=n[a+3];return t[e]=o*g+d*u+l*p-c*m,t[e+1]=l*g+d*m+c*u-o*p,t[e+2]=c*g+d*p+o*m-l*u,t[e+3]=d*g-o*u-l*m-c*p,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,i,r){return this._x=t,this._y=e,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new Ge(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 i=t.x,r=t.y,n=t.z,a=t.order,o=Math.cos,l=Math.sin,c=o(i/2),d=o(r/2),u=o(n/2),m=l(i/2),p=l(r/2),g=l(n/2);switch(a){case"XYZ":this._x=m*d*u+c*p*g,this._y=c*p*u-m*d*g,this._z=c*d*g+m*p*u,this._w=c*d*u-m*p*g;break;case"YXZ":this._x=m*d*u+c*p*g,this._y=c*p*u-m*d*g,this._z=c*d*g-m*p*u,this._w=c*d*u+m*p*g;break;case"ZXY":this._x=m*d*u-c*p*g,this._y=c*p*u+m*d*g,this._z=c*d*g+m*p*u,this._w=c*d*u-m*p*g;break;case"ZYX":this._x=m*d*u-c*p*g,this._y=c*p*u+m*d*g,this._z=c*d*g-m*p*u,this._w=c*d*u+m*p*g;break;case"YZX":this._x=m*d*u+c*p*g,this._y=c*p*u+m*d*g,this._z=c*d*g-m*p*u,this._w=c*d*u-m*p*g;break;case"XZY":this._x=m*d*u-c*p*g,this._y=c*p*u-m*d*g,this._z=c*d*g+m*p*u,this._w=c*d*u+m*p*g;break}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,r=Math.sin(i);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],r=e[4],n=e[8],a=e[1],o=e[5],l=e[9],c=e[2],d=e[6],u=e[10],m=i+o+u;if(m>0){const p=.5/Math.sqrt(m+1);this._w=.25/p,this._x=(d-l)*p,this._y=(n-c)*p,this._z=(a-r)*p}else if(i>o&&i>u){const p=2*Math.sqrt(1+i-o-u);this._w=(d-l)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(n+c)/p}else if(o>u){const p=2*Math.sqrt(1+o-i-u);this._w=(n-c)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(l+d)/p}else{const p=2*Math.sqrt(1+u-i-o);this._w=(a-r)/p,this._x=(n+c)/p,this._y=(l+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(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=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(se(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const r=Math.min(1,e/i);return this.slerp(t,r),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 i=t._x,r=t._y,n=t._z,a=t._w,o=e._x,l=e._y,c=e._z,d=e._w;return this._x=i*d+a*o+r*c-n*l,this._y=r*d+a*l+n*o-i*c,this._z=n*d+a*c+i*l-r*o,this._w=a*d-i*o-r*l-n*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,r=this._y,n=this._z,a=this._w;let o=a*t._w+i*t._x+r*t._y+n*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=i,this._y=r,this._z=n,this;const l=1-o*o;if(l<=Number.EPSILON){const p=1-e;return this._w=p*a+e*this._w,this._x=p*i+e*this._x,this._y=p*r+e*this._y,this._z=p*n+e*this._z,this.normalize(),this}const c=Math.sqrt(l),d=Math.atan2(c,o),u=Math.sin((1-e)*d)/c,m=Math.sin(e*d)/c;return this._w=a*u+this._w*m,this._x=i*u+this._x*m,this._y=r*u+this._y*m,this._z=n*u+this._z*m,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(r*Math.sin(t),r*Math.cos(t),n*Math.sin(e),n*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 ct=class Wa{constructor(t,e,i){this.x=0,this.y=0,this.z=0;const r=+(t!==void 0)+ +(e!==void 0)+ +(i!==void 0);if(r!==0){if(r===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(r===1){const{x:n,y:a,z:o}=t;this.x=n,this.y=a,this.z=o||0;return}if(r===3){this.x=t,this.y=e,this.z=i;return}throw gt.ILLEGAL_PARAMETERS}}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,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 Wa(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(zn.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(zn.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,r=this.z,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6]*r,this.y=n[1]*e+n[4]*i+n[7]*r,this.z=n[2]*e+n[5]*i+n[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,r=this.z,n=t.elements,a=1/(n[3]*e+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*e+n[4]*i+n[8]*r+n[12])*a,this.y=(n[1]*e+n[5]*i+n[9]*r+n[13])*a,this.z=(n[2]*e+n[6]*i+n[10]*r+n[14])*a,this}applyQuaternion(t){const e=this.x,i=this.y,r=this.z,n=t.x,a=t.y,o=t.z,l=t.w,c=2*(a*r-o*i),d=2*(o*e-n*r),u=2*(n*i-a*e);return this.x=e+l*c+a*u-o*d,this.y=i+l*d+o*c-n*u,this.z=r+l*u+n*d-a*c,this}transformDirection(t){const e=this.x,i=this.y,r=this.z,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*r,this.y=n[1]*e+n[5]*i+n[9]*r,this.z=n[2]*e+n[6]*i+n[10]*r,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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,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(t){return this.x*t.x+this.y*t.y+this.z*t.z}isParallelTo(t){const e=this.dot(t),i=this.length(),r=t.length();return Math.abs(e)===i*r}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,r=t.y,n=t.z,a=e.x,o=e.y,l=e.z;return this.x=r*l-n*o,this.y=n*a-i*l,this.z=i*o-r*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return qi.copy(this).projectOnVector(t),this.sub(qi)}reflect(t){return this.sub(qi.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 i=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,i)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r}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(),i=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=r,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,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};ct.ORIGIN=Object.freeze(new ct(0,0,0)),ct.X_AXIS=Object.freeze(new ct(1,0,0)),ct.NEGATIVE_X_AXIS=Object.freeze(new ct(-1,0,0)),ct.Y_AXIS=Object.freeze(new ct(0,1,0)),ct.NEGATIVE_Y_AXIS=Object.freeze(new ct(0,-1,0)),ct.Z_AXIS=Object.freeze(new ct(0,0,1)),ct.NEGATIVE_Z_AXIS=Object.freeze(new ct(0,0,-1));let f=ct;const qi=new f,zn=new Ge,pr=class Ga{constructor(t,e,i,r,n,a,o,l,c,d,u,m,p,g,y,x){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&i!=null&&r!=null&&n!=null&&a!=null&&o!=null&&l!=null&&c!=null&&d!=null&&u!=null&&m!=null&&p!=null&&g!=null&&y!=null&&x!=null&&this.set(t,e,i,r,n,a,o,l,c,d,u,m,p,g,y,x)}set(t,e,i,r,n,a,o,l,c,d,u,m,p,g,y,x){const w=this.elements;return w[0]=t,w[4]=e,w[8]=i,w[12]=r,w[1]=n,w[5]=a,w[9]=o,w[13]=l,w[2]=c,w[6]=d,w[10]=u,w[14]=m,w[3]=p,w[7]=g,w[11]=y,w[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 Ga().fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[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(Or.equalPoint3d(t,f.Z_AXIS))this.identity();else{const e=new f(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?e.crossVectors(f.Y_AXIS,t).normalize():e.crossVectors(f.Z_AXIS,t).normalize();const i=t.clone().cross(e).normalize();this.set(e.x,e.y,e.z,0,i.x,i.y,i.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,r=1/He.setFromMatrixColumn(t,0).length(),n=1/He.setFromMatrixColumn(t,1).length(),a=1/He.setFromMatrixColumn(t,2).length();return e[0]=i[0]*r,e[1]=i[1]*r,e[2]=i[2]*r,e[3]=0,e[4]=i[4]*n,e[5]=i[5]*n,e[6]=i[6]*n,e[7]=0,e[8]=i[8]*a,e[9]=i[9]*a,e[10]=i[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(fl,t,Il)}lookAt(t,e,i){const r=this.elements;return yt.subVectors(t,e),yt.lengthSq()===0&&(yt.z=1),yt.normalize(),he.crossVectors(i,yt),he.lengthSq()===0&&(Math.abs(i.z)===1?yt.x+=1e-4:yt.z+=1e-4,yt.normalize(),he.crossVectors(i,yt)),he.normalize(),Ks.crossVectors(yt,he),r[0]=he.x,r[4]=Ks.x,r[8]=yt.x,r[1]=he.y,r[5]=Ks.y,r[9]=yt.y,r[2]=he.z,r[6]=Ks.z,r[10]=yt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,r=e.elements,n=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],d=i[1],u=i[5],m=i[9],p=i[13],g=i[2],y=i[6],x=i[10],w=i[14],P=i[3],I=i[7],k=i[11],A=i[15],j=r[0],T=r[4],$=r[8],F=r[12],tt=r[1],B=r[5],H=r[9],_e=r[13],we=r[2],Gs=r[6],Hs=r[10],Us=r[14],Xs=r[3],Ys=r[7],$s=r[11],qs=r[15];return n[0]=a*j+o*tt+l*we+c*Xs,n[4]=a*T+o*B+l*Gs+c*Ys,n[8]=a*$+o*H+l*Hs+c*$s,n[12]=a*F+o*_e+l*Us+c*qs,n[1]=d*j+u*tt+m*we+p*Xs,n[5]=d*T+u*B+m*Gs+p*Ys,n[9]=d*$+u*H+m*Hs+p*$s,n[13]=d*F+u*_e+m*Us+p*qs,n[2]=g*j+y*tt+x*we+w*Xs,n[6]=g*T+y*B+x*Gs+w*Ys,n[10]=g*$+y*H+x*Hs+w*$s,n[14]=g*F+y*_e+x*Us+w*qs,n[3]=P*j+I*tt+k*we+A*Xs,n[7]=P*T+I*B+k*Gs+A*Ys,n[11]=P*$+I*H+k*Hs+A*$s,n[15]=P*F+I*_e+k*Us+A*qs,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],i=t[4],r=t[8],n=t[12],a=t[1],o=t[5],l=t[9],c=t[13],d=t[2],u=t[6],m=t[10],p=t[14],g=t[3],y=t[7],x=t[11],w=t[15];return g*(+n*l*u-r*c*u-n*o*m+i*c*m+r*o*p-i*l*p)+y*(+e*l*p-e*c*m+n*a*m-r*a*p+r*c*d-n*l*d)+x*(+e*c*u-e*o*p-n*a*u+i*a*p+n*o*d-i*c*d)+w*(-r*o*d-e*l*u+e*o*m+r*a*u-i*a*m+i*l*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,i){const r=this.elements;return t instanceof f?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],r=t[2],n=t[3],a=t[4],o=t[5],l=t[6],c=t[7],d=t[8],u=t[9],m=t[10],p=t[11],g=t[12],y=t[13],x=t[14],w=t[15],P=u*x*c-y*m*c+y*l*p-o*x*p-u*l*w+o*m*w,I=g*m*c-d*x*c-g*l*p+a*x*p+d*l*w-a*m*w,k=d*y*c-g*u*c+g*o*p-a*y*p-d*o*w+a*u*w,A=g*u*l-d*y*l-g*o*m+a*y*m+d*o*x-a*u*x,j=e*P+i*I+r*k+n*A;if(j===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/j;return t[0]=P*T,t[1]=(y*m*n-u*x*n-y*r*p+i*x*p+u*r*w-i*m*w)*T,t[2]=(o*x*n-y*l*n+y*r*c-i*x*c-o*r*w+i*l*w)*T,t[3]=(u*l*n-o*m*n-u*r*c+i*m*c+o*r*p-i*l*p)*T,t[4]=I*T,t[5]=(d*x*n-g*m*n+g*r*p-e*x*p-d*r*w+e*m*w)*T,t[6]=(g*l*n-a*x*n-g*r*c+e*x*c+a*r*w-e*l*w)*T,t[7]=(a*m*n-d*l*n+d*r*c-e*m*c-a*r*p+e*l*p)*T,t[8]=k*T,t[9]=(g*u*n-d*y*n-g*i*p+e*y*p+d*i*w-e*u*w)*T,t[10]=(a*y*n-g*o*n+g*i*c-e*y*c-a*i*w+e*o*w)*T,t[11]=(d*o*n-a*u*n-d*i*c+e*u*c+a*i*p-e*o*p)*T,t[12]=A*T,t[13]=(d*y*r-g*u*r+g*i*m-e*y*m-d*i*x+e*u*x)*T,t[14]=(g*o*r-a*y*r-g*i*l+e*y*l+a*i*x-e*o*x)*T,t[15]=(a*u*r-d*o*r+d*i*l-e*u*l-a*i*m+e*o*m)*T,this}scale(t){const e=this.elements,i=t.x,r=t.y,n=t.z;return e[0]*=i,e[4]*=r,e[8]*=n,e[1]*=i,e[5]*=r,e[9]*=n,e[2]*=i,e[6]*=r,e[10]*=n,e[3]*=i,e[7]*=r,e[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,r))}makeTranslation(t,e,i){return t instanceof f?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,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),r=Math.sin(e),n=1-i,a=t.x,o=t.y,l=t.z,c=n*a,d=n*o;return this.set(c*a+i,c*o-r*l,c*l+r*o,0,c*o+r*l,d*o+i,d*l-r*a,0,c*l-r*o,d*l+r*a,n*l*l+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,r,n,a){return this.set(1,i,n,0,t,1,a,0,e,r,1,0,0,0,0,1),this}compose(t,e,i){const r=this.elements,n=e.x,a=e.y,o=e.z,l=e.w,c=n+n,d=a+a,u=o+o,m=n*c,p=n*d,g=n*u,y=a*d,x=a*u,w=o*u,P=l*c,I=l*d,k=l*u,A=i.x,j=i.y,T=i.z;return r[0]=(1-(y+w))*A,r[1]=(p+k)*A,r[2]=(g-I)*A,r[3]=0,r[4]=(p-k)*j,r[5]=(1-(m+w))*j,r[6]=(x+P)*j,r[7]=0,r[8]=(g+I)*T,r[9]=(x-P)*T,r[10]=(1-(m+y))*T,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,i){const r=this.elements;let n=He.set(r[0],r[1],r[2]).length();const a=He.set(r[4],r[5],r[6]).length(),o=He.set(r[8],r[9],r[10]).length();this.determinant()<0&&(n=-n),t.x=r[12],t.y=r[13],t.z=r[14],Tt.copy(this);const l=1/n,c=1/a,d=1/o;return Tt.elements[0]*=l,Tt.elements[1]*=l,Tt.elements[2]*=l,Tt.elements[4]*=c,Tt.elements[5]*=c,Tt.elements[6]*=c,Tt.elements[8]*=d,Tt.elements[9]*=d,Tt.elements[10]*=d,e.setFromRotationMatrix(Tt),i.x=n,i.y=a,i.z=o,this}equals(t){const e=this.elements,i=t.elements;for(let r=0;r<16;r++)if(e[r]!==i[r])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}};pr.IDENTITY=Object.freeze(new pr);let Pt=pr;const He=new f,Tt=new Pt,fl=new f(0,0,0),Il=new f(1,1,1),he=new f,Ks=new f,yt=new f;let C=class Ha{constructor(t=void 0,e=void 0){this.min=t==null?new f(1/0,1/0,1/0):new f(t.x,t.y,t.z),this.max=e==null?new f(-1/0,-1/0,-1/0):new f(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,i=t.length;e<i;e+=3)this.expandByPoint(Zi.fromArray(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=Zi.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return new Ha().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 f(0,0,0):new f(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new f(0,0,0):new f(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,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Zi).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:(Vt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Vt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Vt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Vt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Vt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Vt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Vt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Vt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Vt),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 Vt=[new f,new f,new f,new f,new f,new f,new f,new f],Zi=new f,Vn=new U;let ut=class Ua{constructor(t=void 0,e=void 0){this.min=t==null?new U(1/0,1/0):new U(t.x,t.y),this.max=e==null?new U(-1/0,-1/0):new U(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,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=Vn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return new Ua().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 U(0,0):new U(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new U(0,0):new U(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,Vn).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 Dn=new f,Sl=new f,El=new ji;class zs{constructor(t=new f(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,i,r){return this.normal.set(t,e,i),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const r=Dn.subVectors(i,e).cross(Sl.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,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 i=e||El.getNormalMatrix(t),r=this.coplanarPoint(Dn).applyMatrix4(t),n=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(n),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 zs().copy(this)}}let O=class extends U{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((i,r)=>{i.toArray(e,r*2)}),e}},b=class extends f{static pointArrayToNumberArray(t,e=!0){const i=e?3:2,r=new Array(t.length*i);return t.forEach((n,a)=>{n.toArray(r,a*i)}),r}};const jn=new Pt,Wn=new Ge,Xa=class mr{constructor(t=0,e=0,i=0,r=mr.DEFAULT_ORDER){this._x=t,this._y=e,this._z=i,this._order=r}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,i,r=this._order){return this._x=t,this._y=e,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new mr(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,i=!0){const r=t.elements,n=r[0],a=r[4],o=r[8],l=r[1],c=r[5],d=r[9],u=r[2],m=r[6],p=r[10];switch(e){case"XYZ":this._y=Math.asin(se(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-a,n)):(this._x=Math.atan2(m,c),this._z=0);break;case"YXZ":this._x=Math.asin(-se(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,n),this._z=0);break;case"ZXY":this._x=Math.asin(se(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,n));break;case"ZYX":this._y=Math.asin(-se(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(m,p),this._z=Math.atan2(l,n)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(se(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-u,n)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-se(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(m,c),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-d,p),this._y=0);break}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i=!0){return jn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(jn,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Wn.setFromEuler(this),this.setFromQuaternion(Wn,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}};Xa.DEFAULT_ORDER="XYZ";let Pl=Xa;class Ya{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class Br extends Ya{translate(t){return this.transform(new ji().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class vs extends Br{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 ut}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let i=0;i<this.loops.length;++i){const r=this.loops[i].getPoints(t);e.push(r)}return e}buildHierarchy(){var t;const e=this.getPoints(100),i=this.calculateBoundaryBoxes(e),r=this.sortBoundaryBoxesByAreas(i),n=new Map,a=r.length;for(let l=0;l<a;l++)n.set(r[l],{index:r[l],children:[]});const o={index:-1,children:[]};for(let l=0;l<a;l++){const c=r[l],d=e[c],u=i[c];let m=l+1;for(;m<a;m++){const p=r[m],g=e[p];if(i[p].containsBox(u)&&za.isPointInPolygon(d[N.randInt(0,d.length-1)],g)){(t=n.get(p))==null||t.children.push(n.get(c));break}}m===a&&o.children.push(n.get(c))}return o}get area(){if(this._loops.length===0)return 0;let t=0;for(let e=0;e<this._loops.length;e++){const i=this._loops[e].getPoints(128),r=this.polygonArea(i);e===0?t+=Math.abs(r):t-=Math.abs(r)}return t}polygonArea(t){const e=t.length;if(e<3)return 0;let i=0;for(let r=0,n=e-1;r<e;n=r++){const a=t[n],o=t[r];i+=a.x*o.y-o.x*a.y}return i*.5}calculateBoundaryBoxes(t){const e=[];return t.forEach(i=>{e.push(new ut().setFromPoints(i))}),e}sortBoundaryBoxesByAreas(t){const e=[];t.forEach((r,n)=>{const a=r.size,o=a.width*a.height;e.push({area:o,index:n})}),e.sort((r,n)=>r.area-n.area);const i=[];return e.forEach(r=>{i.push(r.index)}),i}}class ts extends Br{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 i=0;i<=t;i++)e.push(this.getPoint(i/t));return e}getSpacedPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPointAt(i/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const e=[];let i,r=this.getPoint(0),n=0;e.push(0);for(let a=1;a<=t;a++)i=this.getPoint(a/t),n+=i.distanceTo(r),e.push(n),r=i;return e}getUtoTmapping(t,e){const i=this.getLengths();let r=0;const n=i.length;let a;e?a=e:a=t*i[n-1];let o=0,l=n-1,c;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),c=i[r]-a,c<0)o=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,i[r]===a)return r/(n-1);const d=i[r],u=i[r+1]-d,m=(a-d)/u;return(r+m)/(n-1)}getTangent(t){let e=t-1e-4,i=t+1e-4;e<0&&(e=0),i>1&&(i=1);const r=this.getPoint(e),n=this.getPoint(i),a=new O;return a.copy(n).sub(r).normalize(),a}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}}let Ve=class $a extends ts{constructor(t,e,i,r,n){super();const a=+(t!==void 0)+ +(e!==void 0)+ +(i!==void 0)+ +(r!==void 0)+ +(n!==void 0);if(a==3)typeof t=="object"&&typeof e=="object"&&typeof i=="object"?this.createByThreePoints(t,e,i):this.createByStartEndPointsAndBulge(t,e,i);else if(a==5){const o=t;this.center=new O(o.x,o.y),this.radius=e,this._clockwise=n,this._startAngle=this._clockwise?this._mirrorAngle(N.normalizeAngle(i)):N.normalizeAngle(i),this._endAngle=this._clockwise?this._mirrorAngle(N.normalizeAngle(r)):N.normalizeAngle(r)}else throw gt.ILLEGAL_PARAMETERS}createByThreePoints(t,e,i){const r=(T,$)=>({x:(T.x+$.x)/2,y:(T.y+$.y)/2}),n=(T,$)=>($.y-T.y)/($.x-T.x),a=T=>-1/T,o=r(t,e),l=r(e,i),c=n(t,e),d=n(e,i),u=a(c),m=a(d),p=(T,$,F,tt)=>{const B=(tt-$)/(T-F),H=T*B+$;return{x:B,y:H}},g=o.y-u*o.x,y=l.y-m*l.x,x=p(u,g,m,y),w=Math.sqrt(Math.pow(t.x-x.x,2)+Math.pow(t.y-x.y,2)),P=(T,$)=>Math.atan2(T.y-$.y,T.x-$.x),I=P(t,x),k=P(e,x),A=P(i,x),j=A>I&&A<k||I>A&&I<k||k>A&&k<I;this.center=x,this.radius=w,this._clockwise=!j,this._startAngle=I,this._endAngle=A}createByStartEndPointsAndBulge(t,e,i){let r,n,a;i<0?(r=Math.atan(-i)*4,n=new U(t),a=new U(e)):(r=Math.atan(i)*4,n=new U(e),a=new U(t));const o=new U().subVectors(a,n),l=o.length(),c=new U().addVectors(n,o.multiplyScalar(.5)),d=Math.abs(l/2/Math.tan(r/2)),u=o.normalize(),m=i<0?-Math.PI/2:Math.PI/2,p=new U(u.x*Math.cos(m)-u.y*Math.sin(m),u.y*Math.cos(m)+u.x*Math.sin(m));let g;r<Math.PI?i<0?g=c.add(p.multiplyScalar(d)):g=c.add(p.multiplyScalar(-d)):i<0?g=c.add(p.multiplyScalar(-d)):g=c.add(p.multiplyScalar(d)),i<0?(this._startAngle=Math.atan2(n.y-g.y,n.x-g.x),this._endAngle=Math.atan2(a.y-g.y,a.x-g.x)):(this._startAngle=Math.atan2(a.y-g.y,a.x-g.x),this._endAngle=Math.atan2(n.y-g.y,n.x-g.x)),this._clockwise=i<0,this.center=g,this.radius=a.sub(g).length()}get center(){return this._center}set center(t){this._center=new O(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(N.normalizeAngle(t)):N.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:N.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?N.normalizeAngle(t-e):N.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?N.normalizeAngle(t-this.deltaAngle/2):N.normalizeAngle(t+this.deltaAngle/2),i=this._clockwise?this._mirrorAngle(e):e;return this.getPointAtAngle(i)}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 n of e){const a=this._getInternalAngle(n);N.isBetweenAngle(a,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(n))}const i=t.map(n=>n.x),r=t.map(n=>n.y);return new ut(new O(Math.min(...i),Math.min(...r)),new O(Math.max(...i),Math.max(...r)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new $a(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const e=this._getInternalAngle(t),i=this.center.x+this.radius*Math.cos(e),r=this.center.y+this.radius*Math.sin(e);return new O(i,r)}getPoints(t=100){const e=[];let i=this.deltaAngle,r=this._getInternalAngle(this.startAngle);if(this.closed&&(i=G,r=0),this.clockwise)for(let n=0;n<=t;n++){const a=r-i*(n/t),o=this._clockwise?this._mirrorAngle(a):a,l=this.getPointAtAngle(o);e.push(new O(l.x,l.y))}else for(let n=0;n<=t;n++){const a=r+i*(n/t),o=this._clockwise?this._mirrorAngle(a):a,l=this.getPointAtAngle(o);e.push(new O(l.x,l.y))}return e}};class Al extends Ya{translate(t){return this.transform(new Pt().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 Vs extends Al{}class pe extends Vs{constructor(t,e){super(),this._start=new b(t),this._end=new b(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 f().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new b((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 i=this.delta(xe).normalize();return new b(this._start).addScaledVector(i,t)}else{const i=this.delta(xe).normalize();return new b(this._end).addScaledVector(i,t)}}extend(t,e=!1){if(e){const i=xe.subVectors(this._start,this._end).normalize();this._start=new b(this._start).addScaledVector(i,t)}else{const i=this.delta(xe).normalize();this._end=new b(this._end).addScaledVector(i,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,e){Gn.subVectors(t,this._start),Qs.subVectors(this.endPoint,this.startPoint);const i=Qs.dot(Qs);let r=Qs.dot(Gn)/i;return e&&(r=N.clamp(r,0,1)),r}closestPointToPoint(t,e,i){const r=this.closestPointToPointParameter(t,e);return this.delta(i).multiplyScalar(r).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,i=xe.subVectors(t,this.startPoint).dot(e);return new b().copy(e).multiplyScalar(i).add(this.startPoint)}perpPoint(t){const e=this.direction,i=this.startPoint,r=xe.subVectors(t,i).dot(e),n=xe.copy(e).multiplyScalar(r);return new b().addVectors(i,n)}calculateBoundingBox(){const t=new b(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 b(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 C(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 pe(this._start.clone(),this._end.clone())}}const xe=new f,Gn=new f,Qs=new f;class ze extends Vs{static computeCenterPoint(t,e,i){const r=new f().addVectors(t,e).multiplyScalar(.5),n=new f().addVectors(t,i).multiplyScalar(.5),a=new f().subVectors(e,t),o=new f().subVectors(i,t),l=new f().crossVectors(a,o).normalize();if(l.lengthSq()===0)return null;const c=new f().crossVectors(a,l).normalize(),d=new f().crossVectors(o,l).normalize(),u=c.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),m=d.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),p=new pe(r,r.clone().add(u)),g=new pe(n,n.clone().add(m)),y=new f;return p.closestPointToPoint(g.startPoint,!0,y)?y:null}static createByThreePoints(t,e,i){const r=ze.computeCenterPoint(t,e,i);if(r){const n=r.distanceTo(t),a=new f().subVectors(t,r),o=new f().subVectors(e,r),l=Math.atan2(a.y,a.x),c=Math.atan2(o.y,o.x);return new ze(r,n,l,c,f.Z_AXIS)}}constructor(t,e,i,r,n,a=f.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=i,this.endAngle=r,this.normal=n,this.refVec=a,(r-i)%G==0?(this.startAngle=0,this.endAngle=G):(this.startAngle=i,this.endAngle=r)}get center(){return this._center}set center(t){this._center=new b(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw gt.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=N.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==G?t:N.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return N.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 f(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new f(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 i=t+e*.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(t){const e=new f(t.x,t.y,t.z||0),i=this.center,r=this.normal,n=e.clone().sub(i).dot(r),a=e.clone().sub(r.clone().multiplyScalar(n)).clone().sub(i);if(a.lengthSq()===0)return this.startPoint.clone();a.normalize().multiplyScalar(this.radius);const o=i.clone().add(a),l=this.getAngle(o.clone()),c=this.startAngle,d=this.deltaAngle;let u=N.normalizeAngle(l-c);u<0&&(u=0),u>d&&(u=d);const m=this.getPointAtAngle(c+u),p=m.distanceTo(e),g=this.startPoint.distanceTo(e),y=this.endPoint.distanceTo(e);return g<p&&g<=y?this.startPoint.clone():y<p&&y<g?this.endPoint.clone():m}tangentPoints(t){const e=[],i=new f(t.x,t.y,t.z||0),r=this.center,n=this.normal,a=this.radius,o=i.clone().sub(r).dot(n),l=i.clone().sub(n.clone().multiplyScalar(o)),c=r.clone(),d=l.clone().sub(c).length();if(d<a)return e;const u=Math.acos(a/d),m=this.getAngle(l.clone()),p=[m+u,m-u];for(const g of p){const y=N.normalizeAngle(g-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 i=new b(t.x,t.y,t.z||0);return e.length===1||e[0].distanceTo(i)<e[1].distanceTo(i)?e[0]:e[1]}calculateBoundingBox(){const t=[this.startAngle,this.endAngle];for(let l=0;l<2*Math.PI;l+=Math.PI/2)N.isBetweenAngle(l,this.startAngle,this.endAngle)&&t.push(l);let e=1/0,i=1/0,r=1/0,n=-1/0,a=-1/0,o=-1/0;for(const l of t){const c=this.getPointAtAngle(l);c.x<e&&(e=c.x),c.y<i&&(i=c.y),c.z<r&&(r=c.z),c.x>n&&(n=c.x),c.y>a&&(a=c.y),c.z>o&&(o=c.z)}return new C({x:e,y:i,z:r},{x:n,y:a,z:o})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const e=[];let i=this.deltaAngle,r=this.startAngle;this.closed&&(i=G,r=0);for(let n=0;n<=t;n++){const a=r+i*(n/t),o=this.getPointAtAngle(a);e.push(o)}return e}transform(t){const e=Ki.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),i=Ki.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix4(t),e.applyMatrix4(t),i.applyMatrix4(t),this.normal.applyMatrix4(t).normalize(),this.refVec.applyMatrix4(t).normalize(),this.startAngle=this.getAngle(e),this.endAngle=this.getAngle(i),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 ze(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(Ki.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,i=this.refVec,r={x:e.y*i.z-e.z*i.y,y:e.z*i.x-e.x*i.z,z:e.x*i.y-e.y*i.x},n=this.center,a=this.radius;return new b(n.x+a*(i.x*Math.cos(t)+r.x*Math.sin(t)),n.y+a*(i.y*Math.cos(t)+r.y*Math.sin(t)),n.z+a*(i.z*Math.cos(t)+r.z*Math.sin(t)))}get plane(){const t=new f(this.center).distanceTo(Lr);return new zs(this.normal,t)}}const Ki=new f;class De extends ts{constructor(t,e,i,r=0,n=G,a=!1,o=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=i,(n-r)%G==0?(this.startAngle=0,this.endAngle=G):(this.startAngle=r,this.endAngle=n),this.clockwise=a,this.rotation=o}get center(){return this._center}set center(t){this._center=new b(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw gt.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw gt.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=N.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==G?t:N.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 N.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let t=1/0,e=1/0,i=-1/0,r=-1/0;for(let n=0;n<=100;n++){const a=this.getPoint(n/100);t=Math.min(t,a.x),e=Math.min(e,a.y),i=Math.max(i,a.x),r=Math.max(r,a.y)}return new ut({x:t,y:e},{x:i,y:r})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let i=this.endAngle-this.startAngle;const r=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=e;for(;i>e;)i-=e;i<Number.EPSILON&&(r?i=0:i=e),this.clockwise===!0&&!r&&(i===e?i=-e:i=i-e);const n=this.startAngle+t*i;let a=this.center.x+this.majorAxisRadius*Math.cos(n),o=this.center.y+this.minorAxisRadius*Math.sin(n);if(this.rotation!==0){const l=Math.cos(this.rotation),c=Math.sin(this.rotation),d=a-this.center.x,u=o-this.center.y;a=d*l-u*c+this.center.x,o=d*c+u*l+this.center.y}return new O(a,o)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}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 De(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class Wi extends Vs{constructor(t,e,i,r,n,a=0,o=G){super(),this.center=t,this.normal=e,this.majorAxis=i,this.majorAxisRadius=r,this.minorAxisRadius=n;const l=Math.abs(o-a);Math.abs(l-G)<1e-10||Math.abs(l-2*G)<1e-10?(this.startAngle=0,this.endAngle=G):(this.startAngle=a,this.endAngle=o)}get center(){return this._center}set center(t){this._center=new b(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw gt.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw gt.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=N.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==G?t:N.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-G)<1e-10?G:N.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 f(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new f(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new f().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 i=t+e/2;return this.getPointAtAngle(i)}get isCircular(){return Nr.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 i=0,r=this.getPointAtAngle(this.startAngle);for(let n=1;n<=t;n++){const a=this.startAngle+n*e,o=this.getPointAtAngle(a),l=o.x-r.x,c=o.y-r.y,d=o.z-r.z;i+=Math.sqrt(l*l+c*c+d*d),r=o}return i}get area(){const t=this.majorAxisRadius,e=this.minorAxisRadius,i=this.startAngle,r=i+this.deltaAngle;if(Math.abs(this.deltaAngle-G)<1e-10)return Math.PI*t*e;const n=t*e/2*(r-i-(Math.sin(r)*Math.cos(r)-Math.sin(i)*Math.cos(i)));return Math.abs(n)}calculateBoundingBox(){if(this.majorAxis.equals(f.X_AXIS)||this.majorAxis.equals(f.Y_AXIS)||this.majorAxis.isParallelTo(f.X_AXIS)||this.majorAxis.isParallelTo(f.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let l=0;l<2*Math.PI;l+=Math.PI/2)N.isBetweenAngle(l,this.startAngle,this.endAngle)&&t.push(l);let e=1/0,i=1/0,r=1/0,n=-1/0,a=-1/0,o=-1/0;for(const l of t){const c=this.getPointAtAngle(l);c.x<e&&(e=c.x),c.y<i&&(i=c.y),c.z<r&&(r=c.z),c.x>n&&(n=c.x),c.y>a&&(a=c.y),c.z>o&&(o=c.z)}return new C({x:e,y:i,z:r},{x:n,y:a,z:o})}else{let t=1/0,e=1/0,i=1/0,r=-1/0,n=-1/0,a=-1/0;for(let o=0;o<=100;o++){const l=this.startAngle+this.deltaAngle*(o/100),c=this.getPointAtAngle(l);t=Math.min(t,c.x),e=Math.min(e,c.y),i=Math.min(i,c.z),r=Math.max(r,c.x),n=Math.max(n,c.y),a=Math.max(a,c.z)}return new C({x:t,y:e,z:i},{x:r,y:n,z:a})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let i=this.deltaAngle,r=this.startAngle;this.closed&&(i=G,r=0);for(let n=0;n<=t;n++){const a=r+i*(n/t),o=this.getPointAtAngle(a);e.push(o)}return e}getPointAtAngle(t){const e=Math.cos(t),i=Math.sin(t),r=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(i),n=this.majorAxis.clone().multiplyScalar(e*this.majorAxisRadius).add(r);return new b(this.center.x+n.x,this.center.y+n.y,this.center.z+n.z)}contains(t){const e=new f(t).sub(this.center),i=e.dot(this.majorAxis),r=e.dot(this.minorAxis),n=i/this.majorAxisRadius,a=r/this.minorAxisRadius;return n*n+a*a<=1}transform(t){return 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 Wi(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new f(this.center).distanceTo(Lr);return new zs(this.normal,t)}}class ge extends ts{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 O(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 O(e.x,e.y)}else{const e=this._vertices[t-1];return new O(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 i=0;i<e;++i){const r=this._vertices[i];let n=null;if(i<e-1?n=this._vertices[i+1]:i==e-1&&this.closed&&(n=this._vertices[0]),n)if(r.bulge){const a=new Ve(r,n,r.bulge);t+=a.length}else t+=new O(r.x,r.y).distanceTo(n)}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 O(e.x,e.y)}calculateBoundingBox(){const t=this.getPoints(100);return new ut().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const i=[];return this.getPoints(t).forEach(r=>i.push(new b().set(r.x,r.y,e))),i}getPoints(t){const e=[],i=this._vertices.length;for(let r=0;r<i;++r){const n=this._vertices[r];if(n.bulge){let a=null;if(r<i-1?a=this._vertices[r+1]:r==i-1&&this.closed&&(a=this._vertices[0]),a){const o=new Ve(n,a,n.bulge).getPoints(t),l=o.length;for(let c=0;c<l;++c){const d=o[c];e.push(new O(d.x,d.y))}}}else e.push(new O(n.x,n.y)),r==i-1&&this.closed&&e.push(e[0])}return e}}class Rt extends ts{constructor(t,e){super(),this._start=new O(t),this._end=new O(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 O(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),e=new O(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new ut(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 Rt(this._start.clone(),this._end.clone())}}let ks=class Ot extends ts{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}static buildFromEdges(t,e=.001){if(t.length===0)return[];const i=[...t],r=[],n=e*e,a=(o,l)=>{const c=o.x-l.x,d=o.y-l.y;return c*c+d*d<=n};for(;i.length>0;){const o=[],l=i.shift();o.push(l);const c=Ot.getEdgeStartPoint(l);let d=Ot.getEdgeEndPoint(l);if(!a(c,d))for(;i.length>0;){const u=Ot.findConnectingEdge(i,d,n);if(u.index<0)break;let m=i.splice(u.index,1)[0];if(u.reverse&&(m=Ot.reverseEdge(m)),o.push(m),d=Ot.getEdgeEndPoint(m),a(d,c))break}r.push(new Ot(o))}return r}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 O(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 ut;return e.setFromPoints(t),e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(i=>{i.getPoints(t).forEach(r=>{e.push(new O(r.x,r.y))})}),e}static findConnectingEdge(t,e,i){let r=-1,n=!1,a=Number.POSITIVE_INFINITY;for(let o=0;o<t.length;o++){const l=t[o],c=Ot.getEdgeStartPoint(l),d=Ot.getEdgeEndPoint(l),u=e.x-c.x,m=e.y-c.y,p=u*u+m*m;p<a&&(a=p,r=o,n=!1);const g=e.x-d.x,y=e.y-d.y,x=g*g+y*y;x<a&&(a=x,r=o,n=!0)}return a>i?{index:-1,reverse:!1}:{index:r,reverse:n}}static getEdgeStartPoint(t){const e=t.startPoint;return new O(e.x,e.y)}static getEdgeEndPoint(t){const e=t.endPoint;return new O(e.x,e.y)}static reverseEdge(t){return t instanceof Rt?new Rt(t.endPoint,t.startPoint):t instanceof Ve?new Ve(t.center,t.radius,t.endAngle,t.startAngle,!t.clockwise):t instanceof De?new De(t.center,t.majorAxisRadius,t.minorAxisRadius,t.endAngle,t.startAngle,!t.clockwise,t.rotation):t instanceof Lt?Ot.reverseSplineEdge(t):t}static reverseSplineEdge(t){const e=[...t.controlPoints].reverse(),i=t.knots,r=i[0],n=i[i.length-1],a=i.map(c=>r+n-c).reverse(),o=t.weights,l=o.length>0?[...o].reverse():void 0;return new Lt(e,a,l,t.degree,t.closed)}};class Qi{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,i,r){this.c0=t,this.c1=i,this.c2=-3*t+3*e-2*i-r,this.c3=2*t-2*e+i+r}initCatmullRom(t,e,i,r,n){this.init(e,i,n*(i-t),n*(r-e))}initNonuniformCatmullRom(t,e,i,r,n,a,o){let l=(e-t)/n-(i-t)/(n+a)+(i-e)/a,c=(i-e)/a-(r-e)/(a+o)+(r-i)/o;l*=a,c*=a,this.init(e,i,l,c)}calc(t){const e=t*t,i=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*i}}class qa extends Vs{constructor(t=[],e=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new f,this._px=new Qi,this._py=new Qi,this._pz=new Qi,this._points=t.map(n=>new b(n)),this._closed=e,this._curveType=i,this._tension=r}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 b}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new b}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 b){const i=e,r=this._points,n=r.length;if(n===0)return i.set(0,0,0);if(n===1)return i.copy(r[0]);const a=(n-(this._closed?0:1))*t;let o=Math.floor(a),l=a-o;this._closed?o+=o>0?0:(Math.floor(Math.abs(o)/n)+1)*n:l===0&&o===n-1&&(o=n-2,l=1);let c,d;this._closed||o>0?c=r[(o-1)%n]:(this._tmp.subVectors(r[0],r[1]).add(r[0]),c=new b(this._tmp.x,this._tmp.y,this._tmp.z));const u=r[o%n],m=r[(o+1)%n];if(this._closed||o+2<n?d=r[(o+2)%n]:(this._tmp.subVectors(r[n-1],r[n-2]).add(r[n-1]),d=new b(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const p=this._curveType==="chordal"?.5:.25;let g=Math.pow(c.distanceToSquared(u),p),y=Math.pow(u.distanceToSquared(m),p),x=Math.pow(m.distanceToSquared(d),p);y<1e-4&&(y=1),g<1e-4&&(g=y),x<1e-4&&(x=y),this._px.initNonuniformCatmullRom(c.x,u.x,m.x,d.x,g,y,x),this._py.initNonuniformCatmullRom(c.y,u.y,m.y,d.y,g,y,x),this._pz.initNonuniformCatmullRom(c.z,u.z,m.z,d.z,g,y,x)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(c.x,u.x,m.x,d.x,this._tension),this._py.initCatmullRom(c.y,u.y,m.y,d.y,this._tension),this._pz.initCatmullRom(c.z,u.z,m.z,d.z,this._tension));return i.set(this._px.calc(l),this._py.calc(l),this._pz.calc(l)),i}getPoints(t){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return e}setPoints(t){this._points=t.map(e=>new b(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}transform(t){return this._points=this._points.map(e=>{const i=new b;return i.copy(e),i.applyMatrix4(t),i}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new C;const t=new C;return this._points.forEach(e=>{t.expandByPoint(e)}),t}}let Ct=class ii{constructor(t,e,i,r){this._degree=t,this._knots=[...e],this._controlPoints=i.map(n=>({x:n.x,y:n.y,z:n.z})),this._weights=r?[...r]:new Array(i.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]}point(t){const e=this._controlPoints.map(i=>[i.x,i.y,i.z]);return Ss(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return ja(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,i,r){return new ii(t,e,i,r)}static byPoints(t,e,i="Uniform",r,n){const a=Fr(t,e,i,r,n),o=a.controlPoints.map(l=>({x:l[0],y:l[1],z:l[2]}));return new ii(e,a.knots,o,a.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:i,end:r}=this.getParameterRange();for(let n=0;n<=t;n++){const a=i+(r-i)*(n/t);e.push(this.point(a))}return e}isClosed(t=1e-6){const{start:e,end:i}=this.getParameterRange(),r=this.point(e),n=this.point(i),a=r[0]-n[0],o=r[1]-n[1],l=r[2]-n[2];return Math.sqrt(a*a+o*o+l*l)<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 qa(t,!0,"centripetal"),i=Math.max(50,t.length*2);return e.getPoints(i)}static createClosedCurve(t,e,i="Chord"){const r=this.createFitPointsForClosedCurve(t).map(n=>[n.x,n.y,n.z]);return ii.byPoints(r,e,i)}};class Lt extends Vs{constructor(t,e,i,r,n,a){super();const o=arguments.length;if(this._degree=3,this._closed=!1,Array.isArray(e)){if(o<2||o>5)throw gt.ILLEGAL_PARAMETERS;this._controlPoints=t;let l,c=3,d=!1;if(o>=3&&(Array.isArray(i)?(l=i,o>=4&&(c=r||3),o>=5&&(d=n)):i!==void 0&&(c=i||3,o>=4&&(d=r))),i===void 0&&o>=4&&(c=r||3,o>=5&&(d=n)),this._degree=c,this._closed=d,this._controlPoints.length<this._degree+1)throw gt.ILLEGAL_PARAMETERS;this._nurbsCurve=Ct.byKnotsControlPointsWeights(this._degree,e,this._controlPoints,l)}else{if(o<2||o>6)throw gt.ILLEGAL_PARAMETERS;this._fitPoints=t,this._knotParameterization=e,o>=3&&(this._degree=i||3);const l=typeof r=="boolean";o>=4&&l&&(this._closed=r),l?(o>=5&&(this._startTangent=n),o>=6&&(this._endTangent=a)):(o>=4&&(this._startTangent=r),o>=5&&(this._endTangent=n)),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 gt.ILLEGAL_PARAMETERS;if(this._closed)this._nurbsCurve=Ct.createClosedCurve(this._fitPoints,this._degree,this._knotParameterization);else{const d=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Ct.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=Ct.createFitPointsForClosedCurve(this._fitPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Ct.byPoints(e,this._degree,this._knotParameterization)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Ct.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=Ct.createFitPointsForClosedCurve(this._controlPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Ct.byPoints(e,this._degree,this._knotParameterization),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(i=>[i.x,i.y,i.z||0]))}else{const t=this._nurbsCurve.knots(),e=this._nurbsCurve.weights();this._nurbsCurve=Ct.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(),i=t[e],r=this._nurbsCurve.point(i);return new b(r[0],r[1],r[2])}get endPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),i=t[t.length-e-1],r=this._nurbsCurve.point(i);return new b(r[0],r[1],r[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,i=t<0||t>=e?e-1:t,r=this._fitPoints[i];return{x:r.x,y:r.y,z:r.z||0}}getControlPointAt(t){const e=this._controlPoints.length,i=t<0||t>=e?e-1:t;return this._controlPoints[i]}getPoints(t=100){const e=this._nurbsCurve,i=[],r=e.knots(),n=this._nurbsCurve.degree(),a=r[n],o=r[r.length-n-1],l=(o-a)/(t-1);for(let c=0;c<t;c++){const d=c===t-1?o:a+c*l,u=e.point(d);i.push(new b(u[0],u[1],u[2]))}return i}getCurvePoints(t,e){const i=[],r=t.knots(),n=t.degree(),a=r[n],o=(r[r.length-n-1]-a)/(e-1);for(let l=0;l<e;l++){const c=a+l*o;i.push(t.point(c))}return i}calculateBoundingBox(){const t=this.getPoints(100);return new C().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(t){const e=new Array(t.length);return t.forEach((i,r)=>{e[r]=[i.x,i.y,i.z||0]}),e}toGePoints(t){const e=new Array(t.length);return t.forEach((i,r)=>{e[r]={x:i[0],y:i[1],z:i[2]}}),e}toNurbsPoint(t){return[t.x,t.y,t.z||0]}static createClosedSpline(t,e="Uniform",i=3){if(t.length<i+1)throw new Error(`At least ${i+1} points are required for a degree ${i} closed spline`);return new Lt(t,e,i,!0)}}var Rr=(s=>(s.ClosedFilled="",s.Dot="_DOT",s.DotSmall="_DOTSMALL",s.DotBlank="_DOTBLANK",s.Origin="_ORIGIN",s.Origin2="_ORIGIN2",s.Open="_OPEN",s.Open90="_OPEN90",s.Open30="_OPEN30",s.Closed="_CLOSED",s.Small="_SMALL",s.None="_NONE",s.Oblique="_OBLIQUE",s.BoxFilled="_BOXFILLED",s.Box="_BOXBLANK",s.ClosedBlank="_CLOSEDBLANK",s.DatumBlank="_DATUMBLANK",s.DatumFilled="_DATUMFILLED",s.Integral="_INTEGRAL",s.ArchTick="_ARCHTICK",s))(Rr||{}),je=(s=>(s[s.ByBlock=-2]="ByBlock",s[s.ByDIPs=-4]="ByDIPs",s[s.ByLayer=-1]="ByLayer",s[s.ByLineWeightDefault=-3]="ByLineWeightDefault",s[s.LineWeight000=0]="LineWeight000",s[s.LineWeight005=5]="LineWeight005",s[s.LineWeight009=9]="LineWeight009",s[s.LineWeight013=13]="LineWeight013",s[s.LineWeight015=15]="LineWeight015",s[s.LineWeight018=18]="LineWeight018",s[s.LineWeight020=20]="LineWeight020",s[s.LineWeight025=25]="LineWeight025",s[s.LineWeight030=30]="LineWeight030",s[s.LineWeight035=35]="LineWeight035",s[s.LineWeight040=40]="LineWeight040",s[s.LineWeight050=50]="LineWeight050",s[s.LineWeight053=53]="LineWeight053",s[s.LineWeight060=60]="LineWeight060",s[s.LineWeight070=70]="LineWeight070",s[s.LineWeight080=80]="LineWeight080",s[s.LineWeight090=90]="LineWeight090",s[s.LineWeight100=100]="LineWeight100",s[s.LineWeight106=106]="LineWeight106",s[s.LineWeight120=120]="LineWeight120",s[s.LineWeight140=140]="LineWeight140",s[s.LineWeight158=158]="LineWeight158",s[s.LineWeight200=200]="LineWeight200",s[s.LineWeight211=211]="LineWeight211",s))(je||{}),ie=(s=>(s[s.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",s[s.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",s[s.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",s[s.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",s[s.BY_STYLE=5]="BY_STYLE",s))(ie||{}),at=(s=>(s[s.TopLeft=1]="TopLeft",s[s.TopCenter=2]="TopCenter",s[s.TopRight=3]="TopRight",s[s.MiddleLeft=4]="MiddleLeft",s[s.MiddleCenter=5]="MiddleCenter",s[s.MiddleRight=6]="MiddleRight",s[s.BottomLeft=7]="BottomLeft",s[s.BottomCenter=8]="BottomCenter",s[s.BottomRight=9]="BottomRight",s))(at||{}),zr=(s=>(s[s.OPTIMIZED_2D=0]="OPTIMIZED_2D",s[s.WIREFRAME=1]="WIREFRAME",s[s.HIDDEN_LINE=2]="HIDDEN_LINE",s[s.FLAT_SHADED=3]="FLAT_SHADED",s[s.GOURAUD_SHADED=4]="GOURAUD_SHADED",s[s.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",s[s.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",s))(zr||{}),Vr=(s=>(s[s.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",s[s.TOP=1]="TOP",s[s.BOTTOM=2]="BOTTOM",s[s.FRONT=3]="FRONT",s[s.BACK=4]="BACK",s[s.LEFT=5]="LEFT",s[s.RIGHT=6]="RIGHT",s))(Vr||{}),Dr=(s=>(s[s.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",s[s.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",s))(Dr||{});let Za=class Ka{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new b,this._height=0,this._width=0,this._viewCenter=new b,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 ut;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 ut;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new Ka;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 qr=class qr extends ne{constructor(){super(...arguments),this._lineType=Ze,this._visibility=!0,this._transparency=new Di}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(){let t=this.color;if(t.isByLayer){const e=this.getLayerColor();e&&e.RGB!=null&&(t=e)}else t.isByBlock;return t}get rgbColor(){const e=this.resolvedColor.RGB;return e??16777215}get lineType(){return this._lineType}set lineType(t){this._lineType=t||Ze}get lineWeight(){return this._lineWeight==null&&(this._lineWeight=this.database.celweight??je.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._linetypeScale==null&&(this._linetypeScale=this.database.celtscale??-1),this._lineWeight==null&&(this._lineWeight=this.database.celweight??je.ByLayer)}get properties(){return{type:this.type,groups:[this.getGeneralProperties()]}}subGetGripPoints(){return new Array}subGetOsnapPoints(t,e,i,r,n){}transformBy(t){return this}erase(){return this.database.tables.blockTable.removeEntity(this.objectId)}worldDraw(t,e){const i=t.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,"thickness"in this&&(i.thickness=this.thickness);const r=this.subWorldDraw(t,e);return this.attachEntityInfo(r),r}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 r;const{type:t,name:e}=this.getLineType(),i=(r=this.database)==null?void 0:r.tables.linetypeTable.getAt(e);return i?{type:t,...i.linetype}:{type:t,name:e,standardFlag:0,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==Ze){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return{type:"ByLayer",name:t.linetype}}else return this.lineType==di?{type:"ByBlock",name:qe}:{type:"UserSpecified",name:this.lineType};return{type:"UserSpecified",name:qe}}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)}};qr.typeName="Entity";let pt=qr;const Zr=class Zr extends pt{};Zr.typeName="Curve";let rt=Zr;var Xe=(s=>(s[s.SimplePoly=0]="SimplePoly",s[s.FitCurvePoly=1]="FitCurvePoly",s[s.QuadSplinePoly=2]="QuadSplinePoly",s[s.CubicSplinePoly=3]="CubicSplinePoly",s))(Xe||{});const Kr=class Kr extends rt{get dxfTypeName(){return"POLYLINE"}constructor(t,e,i=0,r=!1,n=0,a=0,o=null){super(),this._polyType=t,this._elevation=i;const l=o&&(o==null?void 0:o.length)===e.length,c=e.map((d,u)=>({x:d.x,y:d.y,bulge:l?o[u]:void 0}));this._geo=new ge(c,r)}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 C({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 i=this._geo.getPointAt(e);t.push(new b(i.x,i.y,0))}return t}subGetOsnapPoints(t,e,i,r){switch(t){case R.EndPoint:for(let n=0;n<this._geo.numberOfVertices;++n){const a=this._geo.getPointAt(n);r.push(new b(a.x,a.y,0))}break}}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(r=>e.push(new b().set(r.x,r.y,this.elevation))),t.lines(e)}dxfOut(t,e=!1){super.dxfOut(t,e);for(let i=0;i<this.numberOfVertices;++i)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(i).x,y:this.getPointAt(i).y,z:this.elevation}),t.writeDouble(42,this.getBulgeAt(i)),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}};Kr.typeName="2dPolyline";let ui=Kr;var Qa=(s=>(s[s.Vertex=0]="Vertex",s[s.CurveFitVertex=1]="CurveFitVertex",s[s.SplineFitVertex=8]="SplineFitVertex",s[s.SplineCtlVertex=9]="SplineCtlVertex",s))(Qa||{});const Qr=class Qr extends pt{get dxfTypeName(){return"VERTEX"}constructor(){super(),this._position=new b,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 C().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subGetOsnapPoints(t,e,i,r){r.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}};Qr.typeName="2dVertex";let gr=Qr;var Es=(s=>(s[s.SimplePoly=0]="SimplePoly",s[s.QuadSplinePoly=1]="QuadSplinePoly",s[s.CubicSplinePoly=2]="CubicSplinePoly",s))(Es||{});const Jr=class Jr extends rt{get dxfTypeName(){return"POLYLINE"}constructor(t,e,i=!1){super(),this._polyType=t,this._geo=new ge(e,i)}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){return this._geo.getPointAt(t)}get geometricExtents(){const t=this._geo.box;return new C({x:t.min.x,y:t.min.y,z:0},{x:t.max.x,y:t.max.y,z:0})}subGetGripPoints(){const t=new Array;for(let e=0;e<this._geo.numberOfVertices;++e){const i=this._geo.getPointAt(e);t.push(new b(i.x,i.y,0))}return t}subGetOsnapPoints(t,e,i,r){switch(t){case R.EndPoint:for(let n=0;n<this._geo.numberOfVertices;++n){const a=this._geo.getPointAt(n);r.push(new b(a.x,a.y,0))}break}}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=[];return this._geo.getPoints(100).forEach(r=>e.push(new b().set(r.x,r.y,0))),t.lines(e)}dxfOut(t,e=!1){super.dxfOut(t,e);for(let i=0;i<this.numberOfVertices;++i){const r=this.getPointAt(i);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:r.x,y:r.y,z:0}),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}};Jr.typeName="3dPolyline";let pi=Jr;var Ja=(s=>(s[s.SimpleVertex=0]="SimpleVertex",s[s.ControlVertex=1]="ControlVertex",s[s.FitVertex=2]="FitVertex",s))(Ja||{});const tn=class tn extends pt{get dxfTypeName(){return"VERTEX"}constructor(){super(),this._position=new b,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 C().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subGetOsnapPoints(t,e,i,r){r.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}};tn.typeName="3dVertex";let yr=tn;const en=class en extends rt{get dxfTypeName(){return"ARC"}constructor(t,e,i,r,n=f.Z_AXIS){super(),this._geo=new ze(t,e,i,r,n,f.X_AXIS)}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:()=>N.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,i,r){const n=this.startPoint,a=this.endPoint;switch(t){case R.EndPoint:r.push(n),r.push(a);break;case R.MidPoint:r.push(this.midPoint);break;case R.Nearest:{const o=this._geo.nearestPoint(e);r.push(o)}break;case R.Perpendicular:break;case R.Tangent:{const o=this._geo.tangentPoints(e);r.push(...o);break}}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){return t.circularArc(this._geo)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbArc"),t.writePoint3d(10,this.center),t.writeDouble(40,this.radius),t.writeAngle(50,this.startAngle),t.writeAngle(51,this.endAngle),t.writeVector3d(210,this.normal),this}};en.typeName="Arc";let mi=en;var to=(s=>(s[s.LEFT=0]="LEFT",s[s.CENTER=1]="CENTER",s[s.RIGHT=2]="RIGHT",s[s.ALIGNED=3]="ALIGNED",s[s.MIDDLE=4]="MIDDLE",s[s.FIT=5]="FIT",s))(to||{}),eo=(s=>(s[s.BASELINE=0]="BASELINE",s[s.BOTTOM=1]="BOTTOM",s[s.MIDDLE=2]="MIDDLE",s[s.TOP=3]="TOP",s))(eo||{});const sn=class sn extends pt{get dxfTypeName(){return"TEXT"}constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new b,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 C}subGetOsnapPoints(t,e,i,r){R.Insertion===t&&r.push(this._position)}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;let e=t.getAt(this.styleName);return e||(e=t.getAt(Y)||t.getAt(Y)),e.textStyle}subWorldDraw(t,e){const i={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:ie.BOTTOM_TO_TOP,attachmentPoint:at.BottomLeft};return t.mtext(i,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}};sn.typeName="Text";let Ke=sn;var Q=(s=>(s[s.Invisible=1]="Invisible",s[s.Const=2]="Const",s[s.Verifiable=4]="Verifiable",s[s.Preset=8]="Preset",s))(Q||{}),Bt=(s=>(s[s.MultiLine=2]="MultiLine",s[s.ConstMultiLine=4]="ConstMultiLine",s))(Bt||{});const rn=class rn extends Ke{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}};rn.typeName="AttDef";let gi=rn;const nn=class nn extends Ke{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&Q.Invisible)!==0}set isInvisible(t){t?this._flags|=Q.Invisible:this._flags&=~Q.Invisible}get isConst(){return(this._flags&Q.Const)!==0}set isConst(t){t?this._flags|=Q.Const:this._flags&=~Q.Const}get isVerifiable(){return(this._flags&Q.Verifiable)!==0}set isVerifiable(t){t?this._flags|=Q.Verifiable:this._flags&=~Q.Verifiable}get isPreset(){return(this._flags&Q.Preset)!==0}set isPreset(t){t?this._flags|=Q.Preset:this._flags&=~Q.Preset}get isMTextAttribute(){return(this._mtextFlag&Bt.MultiLine)!==0}set isMTextAttribute(t){t?this._mtextFlag|=Bt.MultiLine:this._mtextFlag&=~Bt.MultiLine}get isConstMTextAttribute(){return(this._mtextFlag&Bt.ConstMultiLine)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=Bt.ConstMultiLine:this._mtextFlag&=~Bt.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}};nn.typeName="Attrib";let yi=nn;const an=class an extends pt{get dxfTypeName(){return"INSERT"}constructor(t){super(),this._blockName=t,this._position=new b,this._rotation=0,this._normal=new f(0,0,1),this._scaleFactors=new b(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 js(this._attribs)}get blockTransform(){const t=this.blockTableRecord,e=(t==null?void 0:t.origin)??b.ORIGIN,i=new Pt().makeTranslation(-e.x,-e.y,-e.z),r=new Pt().makeScale(this._scaleFactors.x,this._scaleFactors.y,this._scaleFactors.z),n=new Ge().setFromAxisAngle(f.Z_AXIS,this._rotation),a=new Pt().makeRotationFromQuaternion(n),o=new Pt().makeTranslation(this._position.x,this._position.y,this._position.z);return new Pt().multiplyMatrices(o,a).multiply(r).multiply(i)}subGetOsnapPoints(t,e,i,r,n){R.Insertion===t?r.push(this._position):n&&this.subEntityGetOsnapPoints(t,e,i,r,n)}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(i=>{e.properties.push({name:i.tag,type:"string",editable:!i.isConst,skipTranslation:!0,accessor:{get:()=>i.textString,set:r=>{i.textString=r}}})})}return t}get geometricExtents(){const t=new C,e=this.blockTableRecord;if(e!=null){const r=e.newIterator();for(const n of r)t.union(n.geometricExtents)}const i=this.blockTransform;return t.applyMatrix4(i),t}subWorldDraw(t){const e=this.blockTableRecord;if(e!=null){const i=this.blockTransform,r=[];return this._attribs.forEach(a=>{if(!a.isInvisible){const o=a.worldDraw(t);o&&r.push(o)}}),Je.instance.draw(t,e,this.rgbColor,r,!0,i,this._normal)}else return t.group([])}dxfOut(t,e=!1){super.dxfOut(t,e);let i=!1;for(const r of this.attributeIterator())i=!0,t.writeStart("ATTRIB"),r.dxfOut(t);return i&&(t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity")),this}subEntityGetOsnapPoints(t,e,i,r,n){var o;if(n===this.objectId)return;const a=(o=this.database)==null?void 0:o.tables.blockTable;if(a!=null){const l=a.getEntityById(n);if(l){const c=[];l.subGetOsnapPoints(t,e,i,c,n);const d=this.blockTransform;c.forEach(u=>{const m=u.clone().applyMatrix4(d);r.push(m)})}}}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}};an.typeName="BlockReference";let Qe=an;const on=class on extends rt{get dxfTypeName(){return"CIRCLE"}constructor(t,e,i=f.Z_AXIS){super(),this._geo=new ze(t,e,0,G,i,f.X_AXIS)}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,i,r){switch(t){case R.Center:case R.Centroid:r.push(this._geo.center);break;case R.Quadrant:r.push(this._geo.getPointAtAngle(0)),r.push(this._geo.getPointAtAngle(Math.PI/2)),r.push(this._geo.getPointAtAngle(Math.PI)),r.push(this._geo.getPointAtAngle(Math.PI/2*3));break;case R.Nearest:{const n=this._geo.nearestPoint(e);r.push(n)}break;case R.Tangent:{const n=this._geo.tangentPoints(e);r.push(...n);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){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbCircle"),t.writePoint3d(10,this.center),t.writeDouble(40,this.radius),t.writeVector3d(210,this.normal),this}};on.typeName="Circle";let _i=on;const hn=class hn extends rt{get dxfTypeName(){return"ELLIPSE"}constructor(t,e,i,r,n,a,o){super(),this._geo=new Wi(t,e,i,r,n,a,o)}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,i,r){switch(t){case R.EndPoint:this.closed||(r.push(this._geo.startPoint),r.push(this._geo.endPoint));break;case R.MidPoint:this.closed||r.push(this._geo.midPoint);break;case R.Quadrant:this.closed&&(r.push(this._geo.getPointAtAngle(0)),r.push(this._geo.getPointAtAngle(Math.PI/2)),r.push(this._geo.getPointAtAngle(Math.PI)),r.push(this._geo.getPointAtAngle(Math.PI/2*3)));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:"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,i=this.majorAxisRadius;return t.writePoint3d(11,{x:e.x*i,y:e.y*i,z:e.z*i}),t.writeVector3d(210,this.normal),t.writeDouble(40,this.minorAxisRadius/this.majorAxisRadius),t.writeDouble(41,this.startAngle),t.writeDouble(42,this.endAngle),this}};hn.typeName="Ellipse";let wi=hn;const ln=class ln extends pt{get dxfTypeName(){return"3DFACE"}constructor(){super(),this._vertices=[new b,new b,new b],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 b),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 C().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subGetOsnapPoints(t,e,i,r){switch(t){case R.EndPoint:r.push(...this._vertices);break}}subWorldDraw(t){const e=this._vertices.length,i=new Float32Array(e*3),r=new Uint16Array(e*2);for(let n=0;n<e;n++)i[n*3]=this._vertices[n].x,i[n*3+1]=this._vertices[n].y,i[n*3+2]=this._vertices[n].z,this.isEdgeVisibleAt(n)&&(r[n*2]=n,r[n*2+1]=(n+1)%4);return t.lineSegments(i,3,r)}dxfOutFields(t){super.dxfOutFields(t);const e=this.getVertexAt(0),i=this.getVertexAt(1),r=this.getVertexAt(2),n=this.getVertexAt(3);t.writeSubclassMarker("AcDbFace"),t.writePoint3d(10,e),t.writePoint3d(11,i),t.writePoint3d(12,r),t.writePoint3d(13,n);let a=0;for(let o=0;o<4;++o)this.isEdgeVisibleAt(o)||(a|=1<<o);return t.writeInt16(70,a),this}};ln.typeName="Face";let xi=ln;var Ps=(s=>(s[s.UserDefined=0]="UserDefined",s[s.Predefined=1]="Predefined",s[s.Custom=2]="Custom",s))(Ps||{}),so=(s=>(s[s.Normal=0]="Normal",s[s.Outer=1]="Outer",s[s.Ignore=2]="Ignore",s))(so||{});const cn=class cn extends pt{get dxfTypeName(){return"HATCH"}constructor(){super(),this._elevation=0,this._geo=new vs,this._isSolidFill=!1,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=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}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(),i=[],r=(n,a)=>{if(n.index>=0&&a%2===0){const o=new vs;o.add(t[n.index]),n.children.forEach(l=>{l.index>=0&&o.add(t[l.index])}),i.push(o)}n.children.forEach(o=>r(o,a+1))};return e.children.forEach(n=>r(n,0)),i.length>0?i:[this._geo]}getCalculatedAreaValue(){const t=this.buildAreasFromLoops();return t.length===0?0:t.reduce((e,i)=>e+i.area,0)}get geometricExtents(){const t=this.buildAreasFromLoops();if(t.length===0)return new C;const e=new C;return t.forEach(i=>{const r=i.box;e.union(new C({x:r.min.x,y:r.min.y,z:this._elevation},{x:r.max.x,y:r.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:Ps[0],value:0},{label:Ps[1],value:1},{label:Ps[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};const i=this.buildAreasFromLoops();if(i.length===0)return t.area(this._geo);if(i.length===1)return t.area(i[0]);const r=i.map(n=>t.area(n));return t.group(r)}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((i,r)=>{const n=r===0;if(i instanceof ge){const a=i.vertices,o=a.some(c=>(c.bulge??0)!==0);t.writeInt16(92,2),t.writeInt16(72,o?1:0),t.writeInt16(73,i.closed?1:0),t.writeInt16(93,a.length);for(const c of a)t.writePoint2d(10,c),o&&t.writeDouble(42,c.bulge??0);t.writeInt16(97,0);return}if(i instanceof ks){const a=n?1:0;t.writeInt16(92,a),t.writeInt16(93,i.numberOfEdges);for(const o of i.curves){if(o instanceof Rt){t.writeInt16(72,1),t.writePoint2d(10,o.startPoint),t.writePoint2d(11,o.endPoint);continue}if(o instanceof Ve){t.writeInt16(72,2),t.writePoint2d(10,o.center),t.writeDouble(40,o.radius),t.writeAngle(50,o.startAngle),t.writeAngle(51,o.endAngle),t.writeInt16(73,o.clockwise?0:1);continue}if(o instanceof De){t.writeInt16(72,3),t.writePoint2d(10,o.center);const l=new O(o.majorAxisRadius*Math.cos(o.rotation),o.majorAxisRadius*Math.sin(o.rotation));t.writePoint2d(11,l);const c=o.majorAxisRadius===0?0:o.minorAxisRadius/o.majorAxisRadius;t.writeDouble(40,c),t.writeAngle(50,o.startAngle),t.writeAngle(51,o.endAngle),t.writeInt16(73,o.clockwise?0:1);continue}if(o instanceof Lt){const l=o.knots,c=o.controlPoints,d=o.weights,u=o.fitPoints,m=d.some(p=>p!==1);t.writeInt16(72,4),t.writeInt16(94,o.degree),t.writeInt16(73,m?1:0),t.writeInt16(74,o.closed?1:0),t.writeInt16(95,l.length),t.writeInt16(96,c.length),l.forEach(p=>t.writeDouble(40,p)),c.forEach((p,g)=>{t.writePoint2d(10,p),m&&t.writeDouble(42,d[g]??1)}),t.writeInt16(97,(u==null?void 0:u.length)??0),u==null||u.forEach(p=>t.writePoint2d(11,p))}}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(i=>{t.writeAngle(53,i.angle),t.writePoint2d(43,i.base),t.writePoint2d(45,i.offset),t.writeInt16(79,i.dashLengths.length),i.dashLengths.forEach(r=>t.writeDouble(49,r))}),t.writeInt16(98,0),this}};cn.typeName="Hatch";let Ls=cn;var io=(s=>(s[s.MText=0]="MText",s[s.Fcf=1]="Fcf",s[s.BlockReference=2]="BlockReference",s[s.NoAnnotation=3]="NoAnnotation",s))(io||{});const dn=class dn extends rt{get dxfTypeName(){return"LEADER"}constructor(){super(),this._isSplined=!1,this._updated=!1,this._hasArrowHead=!1,this._vertices=[],this._dimensionStyle="",this._hasHookLine=!1,this._annoType=3}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 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}appendVertex(t){this._vertices.push(new b().copy(t)),this._updated=!0}setVertexAt(t,e){throw(t<0||t>=this._vertices.length)&&(this._vertices[t].copy(e),this._updated=!0),new Error("The vertex index is out of range!")}vertexAt(t){throw(t<0||t>=this._vertices.length)&&this._vertices[t],new Error("The vertex index is out of range!")}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new C().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}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 Lt(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.annoType),t.writeInt16(73,this.hasHookLine?1:0),t.writeInt16(74,this.isSplined?1:0),t.writeInt16(76,this.numVertices);for(const e of this.vertices)t.writePoint3d(10,e);return this}};dn.typeName="Leader";let bi=dn;var R=(s=>(s[s.EndPoint=1]="EndPoint",s[s.MidPoint=2]="MidPoint",s[s.Center=3]="Center",s[s.Node=4]="Node",s[s.Quadrant=5]="Quadrant",s[s.Insertion=7]="Insertion",s[s.Perpendicular=8]="Perpendicular",s[s.Tangent=9]="Tangent",s[s.Nearest=10]="Nearest",s[s.Centroid=11]="Centroid",s))(R||{});function Tl(s){let t=0;for(const e of s)t|=1<<e-1;return t}function Ml(s){const t=[];for(const e of Object.values(R)){if(typeof e!="number")continue;const i=1<<e-1;s&i&&t.push(e)}return t}function vl(s,t){return s^1<<t-1}function kl(s,t){return(s&1<<t-1)!==0}function Ll(s,t){return s|1<<t-1}function Nl(s,t){return s&~(1<<t-1)}const un=class un extends rt{get dxfTypeName(){return"LINE"}constructor(t,e){super(),this._geo=new pe(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,i,r){const n=this.startPoint,a=this.endPoint;switch(t){case R.EndPoint:r.push(n),r.push(a);break;case R.MidPoint:r.push(this.midPoint);break;case R.Nearest:{const o=this._geo.project(e);r.push(o)}break;case R.Perpendicular:{const o=this._geo.perpPoint(e);r.push(o)}break;case R.Tangent:break}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){const e=this.startPoint,i=this.endPoint,r=[new b(e.x,e.y,0),new b(i.x,i.y,0)];return t.lines(r)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbLine"),t.writePoint3d(10,this.startPoint),t.writePoint3d(11,this.endPoint),this}};un.typeName="Line";let Ns=un;const pn=class pn extends pt{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 b,this._attachmentPoint=at.TopLeft,this._direction=new f(1,0,0),this._drawingDirection=ie.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 C}subGetOsnapPoints(t,e,i,r){R.Insertion===t&&r.push(this._location)}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:at[1],value:1},{label:at[2],value:2},{label:at[3],value:3},{label:at[4],value:4},{label:at[5],value:5},{label:at[6],value:6},{label:at[7],value:7},{label:at[8],value:8},{label:at[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:t=>{this.attachmentPoint=t}}},{name:"drawingDirection",type:"enum",editable:!0,options:[{label:ie[1],value:1},{label:ie[2],value:2},{label:ie[3],value:3},{label:ie[4],value:4},{label:ie[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;let e=t.getAt(this.styleName);return e||(e=t.getAt(Y)||t.getAt(Y)),e.textStyle}subWorldDraw(t,e){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 t.mtext(i,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}};pn.typeName="MText";let Os=pn;const mn=class mn extends rt{get dxfTypeName(){return"SPLINE"}constructor(t,e,i,r,n){super(),this.rebuild(t,e,i,r,n)}rebuild(t,e,i,r,n){const a=+(t!==void 0)+ +(e!==void 0)+ +(i!==void 0)+ +(r!==void 0)+ +(n!==void 0);if(a<2||a>5)throw gt.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new Lt(t,e,i,r):this._geo=new Lt(t,e,i,r,n)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}subGetOsnapPoints(t,e,i,r){switch(t){case R.EndPoint:r.push(this._geo.startPoint),r.push(this._geo.endPoint);break}}subWorldDraw(t){const e=this._geo.getPoints(100);return t.lines(e)}dxfOutFields(t){var i;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,((i=e.fitPoints)==null?void 0:i.length)??0);for(const r of e.knots)t.writeDouble(40,r);for(const r of e.weights)t.writeDouble(41,r);for(const r of e.controlPoints)t.writePoint3d(10,r);for(const r of e.fitPoints??[])t.writePoint3d(11,r);return this}};mn.typeName="Spline";let Cs=mn;const Ol=new f,gn=class gn extends Qe{get dxfTypeName(){return"ACAD_TABLE"}constructor(t,e,i){super(t),this._attachmentPoint=at.TopLeft,this._numColumns=i,this._numRows=e,this._columnWidth=new Array(i),this._rowHeight=new Array(e),this._cells=new Array(e*i)}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,i){var n;const r=t*this._numColumns+e;return(n=this._cells[r])==null?void 0:n.text}setTextString(t,e,i){const r=t*this._numColumns+e;if(!this._cells[r]){this._cells[r]={text:i,attachmentPoint:this._attachmentPoint,cellType:1,textHeight:0};return}this._cells[r].text=i}isEmpty(t,e){var r;const i=t*this._numColumns+e;return!((r=this._cells[i])!=null&&r.text)}get geometricExtents(){return new C}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){let e=0,i=0;const r=new Uint16Array(this.numColumns*this.numRows*8),n=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let a=0;for(let m=0;m<=this.numRows;m++){e-=m>0?this.rowHeight(m-1):0,i=0;for(let p=0;p<=this.numColumns;p++)i+=p>0?this.columnWidth(p-1):0,n[a++]=i,n[a++]=e,n[a++]=0}const o=[],l=new Array(this.numRows*this.numColumns).fill(!1);i=0,a=0;let c=0;for(let m=0;m<this.numColumns;m++){i+=m>0?this.columnWidth(m-1):0,e=0;for(let p=0;p<this.numRows;p++){e+=p>0?this.rowHeight(p-1):0;const g=this.cell(p*this.numColumns+m);if(c=p*this.numColumns+m,g&&!l[c]){const y=g.borderWidth??1,x=g.borderHeight??1;this.fillVisited(l,c,this.numColumns,y,x),r[a++]=m+p*(this.numColumns+1),r[a++]=m+p*(this.numColumns+1)+y;const w=n[r[a-1]*3]-i,P=m+(p+x)*(this.numColumns+1)+y;m+y==this.numColumns&&(r[a++]=m+p*(this.numColumns+1)+y,r[a++]=P);const I=-n[P*3+1]-e;if(p+x==this.numRows&&(r[a++]=m+(p+x)*(this.numColumns+1)+x,r[a++]=m+(p+x)*(this.numColumns+1)),r[a++]=m+(p+x)*(this.numColumns+1),r[a++]=m+p*(this.numColumns+1),g.text){const k=g.attachmentPoint||this.attachmentPoint||at.MiddleCenter,A=this.getTableTextOffset(k,w,I),j={text:g.text,height:g.textHeight,width:w,position:Ol.set(i,-e,0).clone().add(A),rotation:this.rotation,attachmentPoint:k},T=this.getTextStyle(g);o.push(t.mtext(j,T))}}}}o.push(t.lineSegments(n,3,r));const d=t.group(o),u=new Ge;return u.setFromAxisAngle(f.Z_AXIS,this.rotation),Hn.compose(this.position,u,this.scaleFactors),d.applyMatrix(Hn),d}fillVisited(t,e,i,r,n){if(n==1&&r==1)t[e]=!0;else for(let a=0;a<r;++a)for(let o=0;o<n;++o)t[e+a+o*i]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable;let i;return t.textStyle&&(i=e.getAt(t.textStyle)),i||(i=e.getAt(Y)||e.getAt(Y)),i.textStyle}getTableTextOffset(t,e,i){const r=new f;switch(t){case 1:break;case 2:r.setX(e/2);break;case 3:r.setX(e);break;case 4:r.setY(-i/2);break;case 5:r.set(e/2,-i/2,0);break;case 6:r.set(e,-i/2,0);break;case 7:r.setY(-i);break;case 8:r.set(e/2,-i,0);break;case 9:r.set(e,-i,0);break}return r}dxfOutFields(t){var n,a,o,l,c,d,u;super.dxfOutFields(t),t.writeSubclassMarker("AcDbTable");const e=t.version??((n=t.database)==null?void 0:n.version)??((a=this.database)==null?void 0:a.version),i=(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 m=0;m<this.numRows;++m)t.writeDouble(141,this.rowHeight(m));for(let m=0;m<this.numColumns;++m)t.writeDouble(142,this.columnWidth(m));const r=this._cells.length>0?this._cells.length:this.numRows*this.numColumns;for(let m=0;m<r;m++){const p=this._cells[m],g=(p==null?void 0:p.cellType)??(p!=null&&p.blockTableRecordId?2:1);if(t.writeInt16(171,g),t.writeInt16(172,(p==null?void 0:p.flagValue)??0),t.writeInt16(173,(p==null?void 0:p.mergedValue)??0),t.writeBoolean(174,p==null?void 0:p.autoFit),t.writeInt16(175,p==null?void 0:p.borderWidth),t.writeInt16(176,p==null?void 0:p.borderHeight),(p==null?void 0:p.overrideFlag)!=null&&(i?t.writeInt32(91,p.overrideFlag):t.writeInt16(177,p.overrideFlag)),t.writeInt16(178,p==null?void 0:p.virtualEdgeFlag),t.writeAngle(145,p==null?void 0:p.rotation),i&&t.writeInt16(92,p==null?void 0:p.extendedCellFlags),g===1)p!=null&&p.fieldObjetId?t.writeObjectId(344,p.fieldObjetId):this.writeCellText(t,(p==null?void 0:p.text)??"",i,p==null?void 0:p.cellValueBlockBegin);else if(g===2){if(t.writeObjectId(340,p==null?void 0:p.blockTableRecordId),t.writeDouble(144,p==null?void 0:p.blockScale),t.writeInt16(179,p==null?void 0:p.blockAttrNum),(o=p==null?void 0:p.attrDefineId)!=null&&o.length)for(const y of p.attrDefineId)t.writeObjectId(331,y);if((p==null?void 0:p.attrText)!=null)if(Array.isArray(p.attrText))for(const y of p.attrText)t.writeString(300,y);else t.writeString(300,p.attrText)}p!=null&&p.textStyle&&t.writeString(7,p.textStyle),(p==null?void 0:p.textHeight)!=null&&t.writeDouble(140,p.textHeight),(p==null?void 0:p.attachmentPoint)!=null&&t.writeInt16(170,p.attachmentPoint),(p==null?void 0:p.topBorderVisibility)!=null&&t.writeInt16(289,p.topBorderVisibility?1:0),(p==null?void 0:p.rightBorderVisibility)!=null&&t.writeInt16(285,p.rightBorderVisibility?1:0),(p==null?void 0:p.bottomBorderVisibility)!=null&&t.writeInt16(286,p.bottomBorderVisibility?1:0),(p==null?void 0:p.leftBorderVisibility)!=null&&t.writeInt16(288,p.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),(l=this.cellTypeOverrides)!=null&&l.length)for(const m of this.cellTypeOverrides){t.writeString(7,m.textStyle),t.writeDouble(140,m.textHeight),t.writeInt16(170,m.alignment),t.writeInt16(63,m.backgroundColor),t.writeInt16(64,m.contentColor),m.backgroundColorEnabled!=null&&t.writeInt16(283,m.backgroundColorEnabled?1:0);const p=m.borderLineweights;p&&(t.writeInt16(274,p.top),t.writeInt16(275,p.right),t.writeInt16(276,p.bottom),t.writeInt16(277,p.left),t.writeInt16(278,p.insideHorizontal),t.writeInt16(279,p.insideVertical));const g=m.borderVisibility;g&&(t.writeInt16(284,g.top?1:0),t.writeInt16(285,g.right?1:0),t.writeInt16(286,g.bottom?1:0),t.writeInt16(287,g.left?1:0),t.writeInt16(288,g.insideHorizontal?1:0),t.writeInt16(289,g.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 m of this.rowDataTypes)t.writeInt16(97,m);if((d=this.rowUnitTypes)!=null&&d.length)for(const m of this.rowUnitTypes)t.writeInt16(98,m);if((u=this.rowFormats)!=null&&u.length)for(const m of this.rowFormats)t.writeString(4,m);return this}writeCellText(t,e,i,r){if(!i){if(e.length<=250){t.writeString(1,e);return}const o=Math.ceil(e.length/250);for(let l=0;l<o;l++){const c=l*250,d=c+250,u=e.slice(c,d);l===o-1?t.writeString(1,u):t.writeString(2,u)}return}if(t.writeString(301,r??"CELL_VALUE"),e.length<=250){t.writeString(302,e),t.writeString(304,"ACVALUE_END");return}const a=Math.ceil(e.length/250);for(let o=0;o<a;o++){const l=o*250,c=l+250,d=e.slice(l,c);o===a-1?t.writeString(302,d):t.writeString(303,d)}t.writeString(304,"ACVALUE_END")}};gn.typeName="Table";let fi=gn;const Hn=new Pt,yn=class yn extends rt{get dxfTypeName(){return"TRACE"}constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new b,new b,new b,new b]}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 C().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subGetOsnapPoints(t,e,i,r){switch(t){case R.EndPoint:r.push(...this._vertices);break}}subWorldDraw(t){const e=new ge(this._vertices,!0),i=new vs;i.add(e);const r=t.subEntityTraits;return r.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},t.area(i)}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}};yn.typeName="Trace";let Ii=yn;const _n=class _n extends rt{get dxfTypeName(){return"LWPOLYLINE"}constructor(){super(),this._elevation=0,this._geo=new ge}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,i=0,r=-1,n=-1){const a=r<0?void 0:r,o=n<0?void 0:n,l={x:e.x,y:e.y,bulge:i,startWidth:a,endWidth:o};this._geo.addVertexAt(t,l)}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 b(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new C({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,i,r){const n=new Array;for(let a=0;a<this.numberOfVertices;++a)n.push(this.getPoint3dAt(a));switch(t){case R.EndPoint:r.push(...n);break}}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(r=>e.push(new b().set(r.x,r.y,this.elevation))),t.lines(e)}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}};_n.typeName="Polyline";let Si=_n;const wn=class wn extends pt{get dxfTypeName(){return"POINT"}constructor(){super(),this._geo=new b}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new C().expandByPoint(this._geo)}subGetOsnapPoints(t,e,i,r){R.Node===t&&r.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}};wn.typeName="Point";let Ei=wn;var ro=(s=>(s[s.Invalid=0]="Invalid",s[s.Rect=1]="Rect",s[s.Poly=2]="Poly",s))(ro||{}),no=(s=>(s[s.Show=1]="Show",s[s.ShowUnAligned=2]="ShowUnAligned",s[s.Clip=4]="Clip",s[s.Transparent=8]="Transparent",s))(no||{});const xn=class xn extends pt{get dxfTypeName(){return"IMAGE"}constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new b,this._scale=new U(1,1),this._rotation=0,this._imageSize=new O,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 C;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)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,i=this._height,r=new ut;r.setFromPoints(this._clipBoundary);const n=new O;n.setX(this._position.x-r.min.x*e),n.setY(this._position.y-r.min.y*i),this._clipBoundary.forEach(a=>{const o=a.x*e+n.x,l=a.y*i+n.y;t.push(new b(o,l,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){Un.copy(t[1]);for(let e=1;e<4;e++)Js.copy(t[e]),Js.rotateAround(Un,this._rotation),t[e].setX(Js.x),t[e].setY(Js.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,i=this.height*this.scale.y,r=this._imageSize.x>0&&this._imageSize.y>0?this._imageSize:{x:e,y:i},n=r.x>0?e/r.x:e,a=r.y>0?i/r.y:i,o=Math.cos(this._rotation),l=Math.sin(this._rotation);t.writePoint3d(11,{x:n*o,y:n*l,z:0}),t.writePoint3d(12,{x:-a*l,y:a*o,z:0}),t.writePoint2d(13,r),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}};xn.typeName="RasterImage";let Fs=xn;const Un=new O,Js=new O,bn=class bn extends rt{get dxfTypeName(){return"RAY"}constructor(){super(),this._basePoint=new b,this._unitDir=new f}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 C;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,i,r){switch(t){case R.EndPoint:r.push(this.basePoint);break}}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}};bn.typeName="Ray";let Pi=bn;const fn=class fn extends pt{get dxfTypeName(){return"VIEWPORT"}constructor(){super(),this._centerPoint=new b,this._height=0,this._width=0,this._viewCenter=new b,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 C}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 Za;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 i=[];return i.push(e.lines([new b(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new b(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)])),i.push(e.lines([new b(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new b(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)])),i.push(e.lines([new b(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new b(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)])),i.push(e.lines([new b(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new b(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)])),i}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}};fn.typeName="Viewport";let Ai=fn;const In=class In extends Fs{get dxfTypeName(){return"WIPEOUT"}subWorldDraw(t){const e=this.boundaryPath(),i=new vs;return i.add(new ge(e)),t.area(i)}dxfOutFields(t){return super.dxfOutFields(t),this}};In.typeName="Wipeout";let Ti=In;const Sn=class Sn extends rt{get dxfTypeName(){return"XLINE"}constructor(){super(),this._basePoint=new b,this._unitDir=new f}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 C;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}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}};Sn.typeName="Xline";let Mi=Sn;class ao{constructor(t){this.position=new b(t.x,t.y,t.z||0)}}const En=class En extends rt{get dxfTypeName(){return"POLYLINE"}constructor(t,e,i,r=!1,n=!1){super(),this._mCount=t,this._nCount=e,this._closedM=r,this._closedN=n,this._vertices=i.map(a=>new ao(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(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 i=t*this._nCount+e;return this.getVertexAt(i)}get geometricExtents(){if(this._vertices.length===0)return new C(new b(0,0,0),new b(0,0,0));let t=Number.MAX_VALUE,e=Number.MAX_VALUE,i=Number.MAX_VALUE,r=-Number.MAX_VALUE,n=-Number.MAX_VALUE,a=-Number.MAX_VALUE;return this._vertices.forEach(o=>{t=Math.min(t,o.position.x),e=Math.min(e,o.position.y),i=Math.min(i,o.position.z),r=Math.max(r,o.position.x),n=Math.max(n,o.position.y),a=Math.max(a,o.position.z)}),new C(new b(t,e,i),new b(r,n,a))}subGetGripPoints(){const t=new Array;return this._vertices.forEach(e=>{t.push(e.position)}),t}subGetOsnapPoints(t,e,i,r){switch(t){case R.EndPoint:this._vertices.forEach(n=>{r.push(n.position)});break}}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 i=0;i<this._mCount;i++)for(let r=0;r<this._nCount;r++){const n=this.getVertexAtMN(i,r);let a=r+1;if(a>=this._nCount)if(this._closedN)a=0;else continue;const o=this.getVertexAtMN(i,a);e.push(n.position),e.push(o.position)}for(let i=0;i<this._nCount;i++)for(let r=0;r<this._mCount;r++){const n=this.getVertexAtMN(r,i);let a=r+1;if(a>=this._mCount)if(this._closedM)a=0;else continue;const o=this.getVertexAtMN(a,i);e.push(n.position),e.push(o.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 i=0;i<this.numberOfVertices;i++){const r=this.getVertexAt(i);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,r.position),t.writeInt16(70,16)}return t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}};En.typeName="PolygonMesh";let vi=En;class oo{constructor(t){this.position=new b(t.x,t.y,t.z||0)}}class ho{constructor(t){this.vertexIndices=t}}const Pn=class Pn extends rt{get dxfTypeName(){return"POLYLINE"}constructor(t,e){super(),this._vertices=t.map(i=>new oo(i)),this._faces=e.map(i=>new ho(i))}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 C(new b(0,0,0),new b(0,0,0));let t=Number.MAX_VALUE,e=Number.MAX_VALUE,i=Number.MAX_VALUE,r=-Number.MAX_VALUE,n=-Number.MAX_VALUE,a=-Number.MAX_VALUE;return this._vertices.forEach(o=>{t=Math.min(t,o.position.x),e=Math.min(e,o.position.y),i=Math.min(i,o.position.z),r=Math.max(r,o.position.x),n=Math.max(n,o.position.y),a=Math.max(a,o.position.z)}),new C(new b(t,e,i),new b(r,n,a))}subGetGripPoints(){const t=new Array;return this._vertices.forEach(e=>{t.push(e.position)}),t}subGetOsnapPoints(t,e,i,r){switch(t){case R.EndPoint:this._vertices.forEach(n=>{r.push(n.position)});break}}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(i=>{const r=[];if(i.vertexIndices.forEach(n=>{const a=Math.abs(n)-1;a>=0&&a<this._vertices.length&&r.push(this._vertices[a].position)}),r.length>=3)for(let n=0;n<r.length;n++){const a=r[n],o=r[(n+1)%r.length];e.push(a),e.push(o)}}),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 i=0;i<this.numberOfVertices;i++){const r=this.getVertexAt(i);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,r.position),t.writeInt16(70,64)}for(let i=0;i<this.numberOfFaces;i++){const r=this.getFaceAt(i);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),r.vertexIndices.forEach((n,a)=>{t.writeInt32(10+a,n)})}return t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}};Pn.typeName="PolyFaceMesh";let ki=Pn;var lo=(s=>(s[s.AtLeast=1]="AtLeast",s[s.Exactly=2]="Exactly",s))(lo||{});const An=class An extends pt{get dxfTypeName(){return"DIMENSION"}constructor(){super(),this._dimBlockId=null,this._dimBlockPosition=new b,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new b,this._textRotation=0,this._normal=new f(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}get dimensionStyle(){if(this._dimStyle==null){let t;this.dimensionStyleName&&(t=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),t==null&&(t=new We),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()}subWorldDraw(t){if(this.dimBlockId){const i=this.database.tables.blockTable.getAt(this.dimBlockId);if(i){const r=this.computeDimBlockTransform();return Je.instance.draw(t,i,this.rgbColor,[],!1,r,this._normal)}}return t.group([])}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}getLineArrowStyle(t){}findPointOnLine1(t,e,i){const r=new b().subVectors(e,t).normalize();return new b(e).addScaledVector(r,i)}findPointOnLine2(t,e,i){const r=t.x+i*Math.cos(e),n=t.y+i*Math.sin(e);return{x:r,y:n}}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():Rr.Closed}computeDimBlockTransform(){const t=this.dimBlockId?this.database.tables.blockTable.getAt(this.dimBlockId):void 0,e=(t==null?void 0:t.origin)??b.ORIGIN,i=new Pt().makeTranslation(-e.x,-e.y,-e.z),r=new Pt().makeTranslation(this._dimBlockPosition.x,this._dimBlockPosition.y,this._dimBlockPosition.z);return new Pt().multiplyMatrices(r,i)}dxfOutFields(t){super.dxfOutFields(t);const e=this.dimensionStyleName!=null?this.database.tables.dimStyleTable.getAt(this.dimensionStyleName):void 0;return t.writeSubclassMarker("AcDbDimension"),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.writeVector3d(210,this.normal),t.writeObjectId(340,e==null?void 0:e.objectId),this}};An.typeName="Dimension";let re=An;const Tn=class Tn extends re{constructor(t,e,i,r,n=null,a=null){super(),this._centerPoint=new b().copy(t),this._xLine1Point=new b().copy(e),this._xLine2Point=new b().copy(i),this._arcPoint=new b().copy(r),this.dimensionText=n,this.dimensionStyleName=a}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 geometricExtents(){return new C}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}};Tn.typeName="3PointAngularDimension";let Li=Tn;const Mn=class Mn extends re{constructor(t,e,i,r=null,n=null){super(),this._dimLinePoint=new b().copy(i),this._xLine1Point=new b().copy(t),this._xLine2Point=new b().copy(e),this._oblique=0,this._rotation=0,this.calculateRotation(),r?this.dimensionText=r:this.dimensionText=this._xLine1Point.distanceTo(this._xLine2Point).toFixed(3),this.dimensionStyleName=n}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 geometricExtents(){return new C}get isAppendArrow(){return!1}createDimBlock(t){const e=new K;e.name=t;const i=this.createLines();i.forEach(o=>e.appendEntity(new Ns(o.startPoint,o.endPoint))),this.createArrows(i[0]).forEach(o=>e.appendEntity(o));const n=i[0].midPoint,a=this.createMText(n,this._rotation);return a&&e.appendEntity(a),e}createMText(t,e){const i=r=>({x:Math.cos(r),y:Math.sin(r),z:0});if(this.dimensionText){const r=new Os;return r.attachmentPoint=at.MiddleLeft,r.layer="0",r.color=new J(E.ByBlock),r.location=t,r.contents=this.dimensionText??"",r.height=10,r.direction=i(e),r.styleName=this.dimensionStyle.dimtxsty,r}}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,i){const r="_CAXARROW",n=new Qe(r);return n.position=t,n.rotation=e,n.scaleFactors={x:i,y:i,z:i},n}createLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),i=this.createExtensionLine(this._xLine2Point),r=this.findIntersectionPoint(e,this._dimLinePoint),n=this.findIntersectionPoint(i,this._dimLinePoint),a=new pe(r,n);return t.push(a),e.endPoint=r,this.adjustExtensionLine(e),t.push(e),i.endPoint=n,this.adjustExtensionLine(i),t.push(i),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,i=this.findPointOnLine2(t,e,100);return new pe(t,{...i,z:t.z})}findIntersectionPoint(t,e){const i=t.startPoint,r=t.endPoint,n=new f().subVectors(r,i).normalize(),o=new f().subVectors(e,i).dot(n),l=new f().copy(n).multiplyScalar(o);return new f().addVectors(i,l)}calculateRotation(){const t=this._xLine1Point,e=this._xLine2Point,i=e.x-t.x,r=e.y-t.y;this._rotation=Math.atan2(r,i)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbAlignedDimension"),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}};Mn.typeName="AlignedDimension";let Ni=Mn;const vn=class vn extends re{constructor(t,e,i,r,n=null,a=null){super(),this._arcPoint=new b().copy(r),this._xLine1Point=new b().copy(e),this._xLine2Point=new b().copy(i),this._centerPoint=new b().copy(t),this.dimensionText=n,this.dimensionStyleName=a}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 geometricExtents(){return new C}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}};vn.typeName="ArcDimension";let _r=vn;const kn=class kn extends re{constructor(t,e,i=0,r=null,n=null){super(),this._chordPoint=new b().copy(t),this._farChordPoint=new b().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=i,this.dimensionText=r,this.dimensionStyleName=n}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}get geometricExtents(){return new C}drawLines(t,e){const i=[],r=e.length;return r==1?i.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):r==3?(this.sortLines(e),i.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),i.push(this.drawLine(t,e[1])),i.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(n=>{i.push(this.drawLine(t,n))}),i}drawLine(t,e,i){if(i){const r=[e.startPoint,e.endPoint];return t.lines(r)}else return e.worldDraw(t)}sortLines(t){const e=(i,r)=>i.x!==r.x?i.x-r.x:i.y!==r.y?i.y-r.y:i.z-r.z;t.sort((i,r)=>{const n=e(i.startPoint,r.startPoint);return n!==0?n:e(i.endPoint,r.endPoint)})}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}};kn.typeName="DiametricDimension";let Oi=kn;const Ln=class Ln extends re{constructor(t,e,i=null,r=null){super(),this._definingPoint=new b().copy(t),this._leaderEndPoint=new b().copy(e),this.dimensionText=i,this.dimensionStyleName=r}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 geometricExtents(){return new C}get arrowLineCount(){return 0}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbOrdinateDimension"),t.writePoint3d(13,this.definingPoint),t.writePoint3d(14,this.leaderEndPoint),this}};Ln.typeName="OrdinateDimension";let Ci=Ln;const Nn=class Nn extends re{constructor(t,e,i,r=null,n=null){super(),this._center=new b().copy(t),this._chordPoint=new b().copy(e),this._leaderLength=i,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=r,this.dimensionStyleName=n}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 leaderLenght(t){this._leaderLength=t}get geometricExtents(){return new C}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}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}};Nn.typeName="RadialDimension";let Fi=Nn;var co=(s=>(s[s.kInches=0]="kInches",s[s.kMillimeters=1]="kMillimeters",s[s.kPixels=2]="kPixels",s))(co||{}),uo=(s=>(s[s.k0degrees=0]="k0degrees",s[s.k90degrees=1]="k90degrees",s[s.k180degrees=2]="k180degrees",s[s.k270degrees=3]="k270degrees",s))(uo||{}),po=(s=>(s[s.kDisplay=0]="kDisplay",s[s.kExtents=1]="kExtents",s[s.kLimits=2]="kLimits",s[s.kView=3]="kView",s[s.kWindow=4]="kWindow",s[s.kLayout=5]="kLayout",s))(po||{}),ce=(s=>(s[s.kDraft=0]="kDraft",s[s.kPreview=1]="kPreview",s[s.kNormal=2]="kNormal",s[s.kPresentation=3]="kPresentation",s[s.kMaximum=4]="kMaximum",s[s.kCustom=5]="kCustom",s))(ce||{}),Ye=(s=>(s[s.kAsDisplayed=0]="kAsDisplayed",s[s.kWireframe=1]="kWireframe",s[s.kHidden=2]="kHidden",s[s.kRendered=3]="kRendered",s[s.kVisualStyle=4]="kVisualStyle",s[s.kRenderPreset=5]="kRenderPreset",s))(Ye||{}),mo=(s=>(s[s.kScaleToFit=0]="kScaleToFit",s[s.k1_128in_1ft=1]="k1_128in_1ft",s[s.k1_64in_1ft=2]="k1_64in_1ft",s[s.k1_32in_1ft=3]="k1_32in_1ft",s[s.k1_16in_1ft=4]="k1_16in_1ft",s[s.k3_32in_1ft=5]="k3_32in_1ft",s[s.k1_8in_1ft=6]="k1_8in_1ft",s[s.k3_16in_1ft=7]="k3_16in_1ft",s[s.k1_4in_1ft=8]="k1_4in_1ft",s[s.k3_8in_1ft=9]="k3_8in_1ft",s[s.k1_2in_1ft=10]="k1_2in_1ft",s[s.k3_4in_1ft=11]="k3_4in_1ft",s[s.k1in_1ft=12]="k1in_1ft",s[s.k3in_1ft=13]="k3in_1ft",s[s.k6in_1ft=14]="k6in_1ft",s[s.k1ft_1ft=15]="k1ft_1ft",s[s.k1_1=16]="k1_1",s[s.k1_2=17]="k1_2",s[s.k1_4=18]="k1_4",s[s.k1_5=19]="k1_5",s[s.k1_8=20]="k1_8",s[s.k1_10=21]="k1_10",s[s.k1_16=22]="k1_16",s[s.k1_20=23]="k1_20",s[s.k1_30=24]="k1_30",s[s.k1_40=25]="k1_40",s[s.k1_50=26]="k1_50",s[s.k1_100=27]="k1_100",s[s.k2_1=28]="k2_1",s[s.k4_1=29]="k4_1",s[s.k8_1=30]="k8_1",s[s.k10_1=31]="k10_1",s[s.k100_1=32]="k100_1",s[s.k1000_1=33]="k1000_1",s[s.k1and1_2in_1ft=34]="k1and1_2in_1ft",s))(mo||{});const Cl={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 go extends ne{constructor(t=!1){super(),this._plotSettingsName="",this._plotCfgName="",this._canonicalMediaName="",this._currentStyleSheet="",this._plotOrigin=new O,this._customPrintScale={numerator:1,denominator:1},this._plotPaperSize=new O,this._plotPaperMargins={left:0,right:0,top:0,bottom:0},this._plotViewName="",this._plotWindowArea=new ut,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 Cl[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 Ds extends go{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new ut,this._extents=new C,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 js{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 As extends ne{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,i=>this.hasId(i)),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((i,r)=>{i===e&&(this._recordsByName.delete(r),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:r}))}),!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 js(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,i]of this._recordsByName)t.writeString(3,e),t.writeObjectId(350,i.objectId);return this}}class yo extends As{getBtrIdAt(t){for(const[e,i]of this._recordsByName)if(i.blockTableRecordId==t)return i}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class ye extends ne{constructor(t,e){t=t||{},Rs(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 _o=(s=>(s[s.Any=0]="Any",s[s.Uniform=1]="Uniform",s))(_o||{});const de=class de extends ye{static isModelSapceName(t){return t.toLowerCase()==de.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(de.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new b,this._layoutId="",this._entities=new Map,this._blockInsertUnits=0,this._explodability=1,this._blockScaling=1,this._bmpPreview=void 0}get isModelSapce(){return de.isModelSapceName(this.name)}get isPaperSapce(){return de.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=i=>{i.database=this.database,i.ownerId=this.objectId,this.database.commitObjectHandle(i,r=>this._entities.has(r)),i.resolveEffectiveProperties(),this._entities.set(i.objectId,i)};if(Array.isArray(t))for(let i=0;i<t.length;++i)e(t[i]);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],i=[];return e.forEach(r=>{const n=this._entities.get(r);n&&i.push(n),this._entities.delete(r)}),i.length>0&&this.database.events.entityErased.dispatch({database:this.database,entity:i}),i.length>0}newIterator(){return new js(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}};de.MODEL_SPACE_NAME="*Model_Space",de.PAPER_SPACE_NAME_PREFIX="*Paper_Space";let K=de;class wo{constructor(){this.events={layoutCreated:new Z,layoutRemoved:new Z,layoutRenamed:new Z,layoutSwitched:new Z}}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 i=this.getWorkingDatabase(e),r=i.objects.layout.getIdAt(t);return this.setCurrentLayoutInternal(r,i)}setCurrentLayoutBtrId(t,e){const i=this.getWorkingDatabase(e),r=i.objects.layout.getBtrIdAt(t);return this.setCurrentLayoutInternal(r,i)}setCurrentLayout(t,e){const i=this.getWorkingDatabase(e),r=i.objects.layout.getAt(t);return this.setCurrentLayoutInternal(r,i)}renameLayout(t,e,i){const n=this.getWorkingDatabase(i).objects.layout.getAt(t);return n?(n.layoutName=e,this.events.layoutRenamed.dispatch({layout:n,oldName:t,newName:e}),!0):!1}layoutExists(t,e){return this.getWorkingDatabase(e).objects.layout.has(t)}deleteLayout(t,e){const i=this.getWorkingDatabase(e).objects.layout,r=i.getAt(t);let n=!1;return r&&(n=i.remove(t),n&&this.events.layoutRemoved.dispatch({layout:r})),n}createLayout(t,e){const i=this.getWorkingDatabase(e),r=new Ds;r.layoutName=t,r.tabOrder=i.objects.layout.maxTabOrder;const n=new K;return n.name=`*Paper_Space${r.tabOrder}`,i.tables.blockTable.add(n),i.objects.layout.setAt(t,r),this.events.layoutCreated.dispatch({layout:r}),{layout:r,btr:n}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.objects.layout.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||fr().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}pa(()=>new wo);class xo extends ne{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 bo=(s=>(s[s.NotApplicable=0]="NotApplicable",s[s.Ignore=1]="Ignore",s[s.Replace=2]="Replace",s[s.XrefMangleName=3]="XrefMangleName",s[s.MangleName=4]="MangleName",s))(bo||{});class jr extends ne{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(){var e;const t=new jr;return t._data=((e=this._data)==null?void 0:e.clone())??null,t}getDuplicateRecordCloning(){return 0}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbXrecord"),t.writeInt16(280,1),t.writeResultBuffer(this.data),this}}class fo{constructor(t){this.db=t}createDefaultLayer(){const t=new J;return t.colorIndex=7,this.db.tables.layerTable.add(new Gi({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new ue({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new ue({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new ue({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new Hi({name:Y,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new We({name:Y,dimtxsty:Y}))}createDefaultLayout(){const t=new Ds;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 Ls;e.patternName="SOLID";const i=new ks;i.add(new Rt({x:0,y:0},{x:-1,y:.125})),i.add(new Rt({x:-1,y:.125},{x:-1,y:-.125})),i.add(new Rt({x:-1,y:-.125},{x:0,y:0})),e.add(i);const r=new K;r.name="_CAXARROW",r.appendEntity(e),this.db.tables.blockTable.add(r)}}}var Io=(s=>(s.ClosedFilled="",s.Dot="_DOT",s.DotSmall="_DOTSMALL",s.DotBlank="_DOTBLANK",s.Origin="_ORIGIN",s.Origin2="_ORIGIN2",s.Open="_OPEN",s.Open90="_OPEN90",s.Open30="_OPEN30",s.Closed="_CLOSED",s.Small="_SMALL",s.None="_NONE",s.Oblique="_OBLIQUE",s.BoxFilled="_BOXFILLED",s.Box="_BOXBLANK",s.ClosedBlank="_CLOSEDBLANK",s.DatumBlank="_DATUMBLANK",s.DatumFilled="_DATUMFILLED",s.Integral="_INTEGRAL",s.ArchTick="_ARCHTICK",s))(Io||{}),Wr=(s=>(s[s.Undefined=0]="Undefined",s[s.Inches=1]="Inches",s[s.Feet=2]="Feet",s[s.Miles=3]="Miles",s[s.Millimeters=4]="Millimeters",s[s.Centimeters=5]="Centimeters",s[s.Meters=6]="Meters",s[s.Kilometers=7]="Kilometers",s[s.Microinches=8]="Microinches",s[s.Mils=9]="Mils",s[s.Yards=10]="Yards",s[s.Angstroms=11]="Angstroms",s[s.Nanometers=12]="Nanometers",s[s.Microns=13]="Microns",s[s.Decimeters=14]="Decimeters",s[s.Dekameters=15]="Dekameters",s[s.Hectometers=16]="Hectometers",s[s.Gigameters=17]="Gigameters",s[s.Astronomical=18]="Astronomical",s[s.LightYears=19]="LightYears",s[s.Parsecs=20]="Parsecs",s[s.USSurveyFeet=21]="USSurveyFeet",s[s.USSurveyInch=22]="USSurveyInch",s[s.USSurveyYard=23]="USSurveyYard",s[s.USSurveyMile=24]="USSurveyMile",s[s.Max=24]="Max",s))(Wr||{});function Fl(s){return s==4||s==5||s==6||s==7||s==12||s==13||s==14||s==15||s==16||s==17}function Bl(s){return s==1||s==2||s==3||s==8||s==9||s==10||s==21}class ae extends ne{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,i=>this.hasId(i));const e=this.normalizeName(t.name);this._recordsByName.set(e,t),this._recordsById.set(t.objectId,t)}remove(t){const e=this.normalizeName(t),i=this._recordsByName.get(e);return i?(this._recordsById.delete(i.objectId),this._recordsByName.delete(t),!0):!1}removeId(t){const e=this._recordsById.get(t);return e?(this._recordsByName.delete(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 js(this._recordsByName)}normalizeName(t){return t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbSymbolTable"),t.writeInt16(70,this.numEntries),this}}class So extends ae{constructor(t){super(t)}get modelSpace(){let t=this.getAt(K.MODEL_SPACE_NAME);return t||(t=new K,t.name=K.MODEL_SPACE_NAME,this.add(t)),t}getEntityById(t){for(const e of this.database.tables.blockTable.newIterator()){const i=e.getIdAt(t);if(i)return i}}removeEntity(t){let e=!1;for(const i of this.database.tables.blockTable.newIterator())if(i.removeEntity(t)){e=!0;break}return e}normalizeName(t){let e=t;if(K.isModelSapceName(t))e=K.MODEL_SPACE_NAME;else if(K.isPaperSapceName(t)){const i=K.PAPER_SPACE_NAME_PREFIX,r=t.substring(i.length);e=i+r}return e}}class Eo extends ae{constructor(t){super(t)}}var Po=(s=>(s[s.Center=0]="Center",s[s.Left=1]="Left",s[s.Right=2]="Right",s[s.OverFirst=3]="OverFirst",s[s.OverSecond=4]="OverSecond",s))(Po||{}),Ao=(s=>(s[s.Center=0]="Center",s[s.Above=1]="Above",s[s.Outside=2]="Outside",s[s.JIS=3]="JIS",s[s.Below=4]="Below",s))(Ao||{}),To=(s=>(s[s.Feet=0]="Feet",s[s.None=1]="None",s[s.Inch=2]="Inch",s[s.FeetAndInch=3]="FeetAndInch",s[s.Leading=4]="Leading",s[s.Trailing=8]="Trailing",s[s.LeadingAndTrailing=12]="LeadingAndTrailing",s))(To||{}),Mo=(s=>(s[s.None=0]="None",s[s.Leading=1]="Leading",s[s.Trailing=2]="Trailing",s[s.LeadingAndTrailing=3]="LeadingAndTrailing",s))(Mo||{}),vo=(s=>(s[s.Bottom=0]="Bottom",s[s.Middle=1]="Middle",s[s.Top=2]="Top",s))(vo||{});const zi=class zi extends ye{constructor(t,e){t=t||{},Rs(t,zi.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),i=this.database.tables.blockTable.getAt(this.dimldrblk),r=this.database.tables.blockTable.getAt(this.dimblk),n=this.database.tables.blockTable.getAt(this.dimblk1),a=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,i==null?void 0:i.objectId),t.writeObjectId(342,r==null?void 0:r.objectId),t.writeObjectId(343,n==null?void 0:n.objectId),t.writeObjectId(344,a==null?void 0:a.objectId),t.writeInt16(371,this.dimlwd),t.writeInt16(372,this.dimlwe),this}};zi.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:Y,dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let We=zi;class ko extends ae{constructor(t){super(t)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class Gi extends ye{constructor(t,e){t=t||{},Rs(t,{color:new J,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:new Di,linetype:"",lineWeight:1,materialId:-1}),super(t,e),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(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 Lo extends ae{constructor(t){super(t)}}class ue extends ye{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}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 No extends ae{constructor(t){super(t)}get fonts(){const t=new Set,e=r=>{if(r){const n=r.lastIndexOf(".");if(n>=0){const a=r.substring(0,n).toLowerCase();t.add(a)}else t.add(r.toLowerCase())}},i=this.newIterator();for(const r of i)e(r.fileName),e(r.bigFontFileName);return Array.from(t)}}class Hi extends ye{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 i=e.lastIndexOf(".");return i===-1?e:e.substring(0,i)}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 Oo extends ae{constructor(t){super(t)}}class Co extends ae{constructor(t){super(t)}}const Rl=()=>({center:new O,viewDirectionFromTarget:new b(0,0,1),viewTarget:new b(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:zr.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new b(0,0,0),ucsXAxis:new b(1,0,0),ucsYAxis:new b(0,1,0),orthographicType:Vr.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:Dr.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0});class Gr extends ye{constructor(){super(),this._gsView=Rl(),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 Hr extends Gr{constructor(){super(),this._circleSides=100,this._lowerLeftCorner=new O(0,0),this._upperRightCorner=new O(1,1),this._snapBase=new O(0,0),this._snapAngle=0,this._snapSpacing=new O(0,0),this._standardFlag=0,this._gridSpacing=new O,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 Fo extends ae{constructor(t){super(t)}}class wr extends ye{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 D={ACADVER:"ACADVER",ANGBASE:"ANGBASE",ANGDIR:"ANGDIR",AUNITS:"AUNITS",CECOLOR:"CECOLOR",CELTSCALE:"CELTSCALE",CELWEIGHT:"CELWEIGHT",CLAYER:"CLAYER",COLORTHEME:"COLORTHEME",EXTMAX:"EXTMAX",EXTMIN:"EXTMIN",INSUNITS:"INSUNITS",LTSCALE:"LTSCALE",LWDISPLAY:"LWDISPLAY",MEASUREMENTCOLOR:"MEASUREMENTCOLOR",OSMODE:"OSMODE",PDMODE:"PDMODE",PDSIZE:"PDSIZE",PICKBOX:"PICKBOX",TEXTSTYLE:"TEXTSTYLE",WHITEBKCOLOR:"WHITEBKCOLOR"},zl=Object.freeze(Object.values(D)),Vi=class Vi{constructor(){this.registry=new Map,this.cache=new Map,this.events={sysVarChanged:new Z},this.registerVar({name:D.CECOLOR,type:"color",isDbVar:!0,defaultValue:new J(E.ByLayer)}),this.registerVar({name:D.CELTSCALE,type:"number",isDbVar:!0,defaultValue:-1}),this.registerVar({name:D.CELWEIGHT,type:"number",isDbVar:!0,defaultValue:je.ByLayer}),this.registerVar({name:D.CLAYER,type:"string",isDbVar:!0,defaultValue:"0"}),this.registerVar({name:D.COLORTHEME,type:"number",isDbVar:!1,defaultValue:"0"}),this.registerVar({name:D.LWDISPLAY,type:"boolean",isDbVar:!0,defaultValue:!1}),this.registerVar({name:D.MEASUREMENTCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new J(E.ByColor);return t.setRGB(96,165,250),t})()}),this.registerVar({name:D.OSMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:D.PICKBOX,type:"number",isDbVar:!1,defaultValue:10}),this.registerVar({name:D.TEXTSTYLE,type:"string",isDbVar:!0,defaultValue:Y}),this.registerVar({name:D.WHITEBKCOLOR,type:"boolean",isDbVar:!1,defaultValue:!1})}static instance(){return this._instance||(this._instance=new Vi),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 i=this.getDescriptor(t);if(i){if(i.isDbVar)return e[t.toLowerCase()];if(this.cache.has(t))return this.cache.get(t)}}setVar(t,e,i){t=this.normalizeName(t);const r=this.getDescriptor(t);if(r){const n=this.getVar(t,i);if(r.type!=="string"&&(typeof e=="string"||e instanceof String)){if(r.type==="number"){const a=Number(e);if(Number.isNaN(a))throw new Error("Invalid number input!");e=a}else if(r.type==="boolean")e=this.parseBoolean(e);else if(r.type==="color"){const a=J.fromString(e);if(a==null)throw new Error("Invalid color value!");e=a}}r.isDbVar?i[t.toLowerCase()]=e:(this.cache.set(t,e),this.hasValueChanged(n,e)&&this.events.sysVarChanged.dispatch({database:i,name:t,newVal:e,oldVal:n}))}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(),i=new Set(["true","t","1","yes","y"]),r=new Set(["false","f","0","no","n"]);return i.has(e)?!0:(r.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()}};Vi._instance=null;let Bs=Vi;class Vl extends ne{constructor(){super({objectId:"0"}),this.events={dictObjetSet:new Z,dictObjectErased:new Z,entityAppended:new Z,entityModified:new Z,entityErased:new Z,layerAppended:new Z,layerModified:new Z,layerErased:new Z,openProgress:new Z},this._version=new At("AC1014"),this._angBase=0,this._angDir=0,this._aunits=Er.DecimalDegrees,this._celtscale=1,this._cecolor=new J,this._celweight=je.ByLayer,this._clayer="0",this._textstyle=Y,this._extents=new C,this._insunits=Wr.Millimeters,this._ltscale=1,this._lwdisplay=!1,this._pdmode=0,this._pdsize=0,this._osmode=0,this._maxHandle=0,this._tables={appIdTable:new Fo(this),blockTable:new So(this),dimStyleTable:new Eo(this),linetypeTable:new Lo(this),textStyleTable:new No(this),viewTable:new Oo(this),layerTable:new ko(this),viewportTable:new Co(this)},this._objects={dictionary:new As(this),imageDefinition:new As(this),layout:new yo(this),xrecord:new As(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 i=t.getAttrWithoutException("objectId");!i||t.isTemp||e&&e(i)?t.objectId=this.generateHandle():this.updateMaxHandle(i)}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(D.AUNITS,this._aunits,t??0,e=>{this._aunits=e})}get version(){return this._version}set version(t){this.updateSysVar(D.ACADVER,this._version,new At(t),e=>{this._version=e})}get insunits(){return this._insunits}set insunits(t){this.updateSysVar(D.INSUNITS,this._insunits,t??4,e=>{this._insunits=e})}get ltscale(){return this._ltscale}set ltscale(t){this.updateSysVar(D.LTSCALE,this._ltscale,t??1,e=>{this._ltscale=e})}get lwdisplay(){return this._lwdisplay}set lwdisplay(t){this.updateSysVar(D.LWDISPLAY,this._lwdisplay,t??!1,e=>{this._lwdisplay=e})}get cecolor(){return this._cecolor}set cecolor(t){this.updateSysVar(D.CECOLOR,this._cecolor,t||0,e=>{this._cecolor=e.clone()})}get celtscale(){return this._celtscale}set celtscale(t){this.updateSysVar(D.CELTSCALE,this._celtscale,t??1,e=>{this._celtscale=e})}get celweight(){return this._celweight}set celweight(t){this.updateSysVar(D.CELWEIGHT,this._celweight,t??je.ByLayer,e=>{this._celweight=e})}get clayer(){return this._clayer}set clayer(t){this.updateSysVar(D.CLAYER,this._clayer,t??"0",e=>{this._clayer=e})}get textstyle(){return this._textstyle}set textstyle(t){this.updateSysVar(D.TEXTSTYLE,this._textstyle,t??Y,e=>{this._textstyle=e})}get angBase(){return this._angBase}set angBase(t){this.updateSysVar(D.ANGBASE,this._angBase,t??0,e=>{this._angBase=e})}get angDir(){return this._angDir}set angDir(t){this.updateSysVar(D.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(D.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(D.EXTMIN,e,this._extents.min)}}get extents(){return this._extents}get pdmode(){return this._pdmode}set pdmode(t){this.updateSysVar(D.PDMODE,this._pdmode,t??0,e=>{this._pdmode=e})}get pdsize(){return this._pdsize}set pdsize(t){this.updateSysVar(D.PDSIZE,this._pdsize,t??0,e=>{this._pdsize=e})}get osmode(){return this._osmode}set osmode(t){this.updateSysVar(D.OSMODE,this._osmode,t??0,e=>{this._osmode=e})}async read(t,e,i=fs.DXF){const r=Ft.instance.get(i);if(r==null)throw new Error(`Database converter for file type '${i}' isn't registered and can can't read this file!`);this.clear(),await r.read(t,this,e&&e.minimumChunkSize||10,async(n,a,o,l)=>{if(this.events.openProgress.dispatch({database:this,percentage:n,stage:"CONVERSION",subStage:a,subStageStatus:o,data:l}),e&&e.fontLoader&&a=="FONT"&&o=="END"){const c=l||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 p;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",subStageStatus:"START"});const i=await fetch(t);if(!i.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 '${i.status}'!`);const r=i.headers.get("content-length"),n=r?parseInt(r,10):null;let a=0;const o=(p=i.body)==null?void 0:p.getReader();if(!o)throw new Error("Failed to get response reader");const l=[];for(;;){const{done:g,value:y}=await o.read();if(g)break;if(l.push(y),a+=y.length,n!==null){const x=Math.round(a/n*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 g of l)c.set(g,d),d+=g.length;const m=this.getFileNameFromUri(t).toLowerCase().split(".").pop();m==="dwg"?await this.read(c.buffer,e,fs.DWG):m==="dxf"?await this.read(c.buffer,e,fs.DXF):await this.read(c.buffer,e,m),this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}dxfOut(t,e=16,i=this.version.name,r=!1){this.ensureDatabaseDefaults();const n=i instanceof At?i:new At(i),a=new ta({database:this,precision:e,version:n});return this.writeDxfHeaderSection(a),this.writeDxfTablesSection(a,n),this.writeDxfBlocksSection(a),this.writeDxfEntitiesSection(a),this.writeDxfObjectsSection(a),a.writeStart("EOF"),a.toString()}async regen(){await new sl(this).read(null,this,500,async(e,i,r,n)=>{this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:i,subStageStatus:r,data:n})})}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){const e=new fo(this);t.layer&&e.createDefaultLayer(),t.lineType&&e.createDefaultLineType(),t.textStyle&&e.createDefaultTextStyle(),t.dimStyle&&e.createDefaultDimStyle(),t.layout&&e.createDefaultLayout()}ensureDatabaseDefaults(){if(!this.tables.layerTable.has("0")){const e=new J;e.colorIndex=7,this.tables.layerTable.add(new Gi({name:"0",standardFlags:0,linetype:qe,lineWeight:0,isOff:!1,color:e,isPlottable:!0}))}if(this.tables.linetypeTable.has(di)||this.tables.linetypeTable.add(new ue({name:di,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(Ze)||this.tables.linetypeTable.add(new ue({name:Ze,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(qe)||this.tables.linetypeTable.add(new ue({name:qe,standardFlag:0,description:"Solid line",totalPatternLength:0})),this.tables.textStyleTable.has(Y)||this.tables.textStyleTable.add(new Hi({name:Y,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"})),this.tables.dimStyleTable.has(Y)||this.tables.dimStyleTable.add(new We({name:Y,dimtxsty:Y})),!this.tables.viewportTable.has("*Active")){const e=new Hr;e.name="*Active",this.tables.viewportTable.add(e)}const t=this.tables.blockTable.modelSpace;if(!this.objects.layout.getAt("Model")){const e=new Ds;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(cr)||this.tables.appIdTable.add(new wr(cr)),this.tables.appIdTable.has(lr)||this.tables.appIdTable.add(new wr(lr))}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,"$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 i of e.newIterator())this.writeDxfEntity(t,i);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 i of e.newIterator())this.writeDxfEntity(t,i);t.endSection()}writeDxfObjectsSection(t){t.startSection("OBJECTS");const e=this.objects.dictionary;e.ownerId="0";const i=a=>{t.writeStart("DICTIONARY"),a.dxfOut(t)},r=(a,o)=>{e.getAt(a)!==o&&e.setAt(a,o)},n=a=>{e.getAt(a)&&e.remove(a)};r("ACAD_LAYOUT",this.objects.layout),this.objects.imageDefinition.numEntries>0?r("ISM_RASTER_IMAGE_DICT",this.objects.imageDefinition):n("ISM_RASTER_IMAGE_DICT"),this.objects.xrecord.numEntries>0?r("MLIGHT_XRECORD",this.objects.xrecord):n("MLIGHT_XRECORD"),i(e),i(this.objects.layout),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())t.writeStart("LAYOUT"),o.dxfOut(t);for(const[a,o]of this.objects.imageDefinition.entries())t.writeStart("IMAGEDEF"),o.dxfOut(t);for(const[a,o]of this.objects.xrecord.entries())t.writeStart("XRECORD"),o.dxfOut(t);t.endSection()}writeDxfTable(t,e,i,r,n){const a=[...r];t.startTable(e),i.dxfOut(t);for(const o of a){if(n==="BLOCK_RECORD"&&o instanceof K){o.dxfOutBlockRecord(t);continue}t.writeStart(n),o.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._currentSpace=void 0,this._extents.makeEmpty()}updateSysVar(t,e,i,r){this.hasSysVarValueChanged(e,i)&&(r(i),this.triggerSysVarChangedEvent(t,e,i))}hasSysVarValueChanged(t,e){return t instanceof J&&e instanceof J?!t.equals(e):t instanceof At&&e instanceof At?t.value!==e.value:!Object.is(t,e)}triggerSysVarChangedEvent(t,e,i){const r=Bs.instance(),n=t.toLowerCase();r.getDescriptor(n)!=null&&r.events.sysVarChanged.dispatch({database:this,name:n,oldVal:e,newVal:i})}getFileNameFromUri(t){try{const i=new URL(t).pathname.split("/");return i[i.length-1]||""}catch{return""}}}const Bo="Load Database",Xn=3e4,Dl=12e4,jl=1024*1024;class mt extends oa{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=br.getInstance().getEntry(Bo),i=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const r=await this.data.task(t);return this.progress&&(await this.progress(this.data.progress.value,this.data.stage,"END",r?r.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()-i),r}}class Ur{constructor(t={}){this.config=t}async read(t,e,i,r,n,a){const o={name:Bo,data:{total:0},format(){let u="";return Object.keys(this.data).forEach(m=>{m!=="total"&&(u+=`- ${m}: ${this.data[m]} ms
4
- `)}),u+=`- total: ${this.data.total} ms`,u}};br.getInstance().collect(o),this.progress=r;const l={value:0},c=new ha;c.setCompleteCallback(()=>this.onFinished()),c.setErrorCallback(u=>this.onError(u)),c.addTask(new mt({stage:"START",step:1,progress:l,task:async u=>u},r)),c.addTask(new mt({stage:"PARSE",step:5,progress:l,task:async u=>await this.parse(u,n)},r)),c.addTask(new mt({stage:"FONT",step:5,progress:l,task:async u=>{const m=this.getFonts(u.model);return{model:u.model,data:m}}},r)),c.addTask(new mt({stage:"LTYPE",step:1,progress:l,task:async u=>(this.processLineTypes(u.model,e),u)},r)),c.addTask(new mt({stage:"STYLE",step:1,progress:l,task:async u=>(this.processTextStyles(u.model,e),u)},r)),c.addTask(new mt({stage:"DIMSTYLE",step:1,progress:l,task:async u=>(this.processDimStyles(u.model,e),u)},r)),c.addTask(new mt({stage:"LAYER",step:1,progress:l,task:async u=>(this.processLayers(u.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),u)},r)),c.addTask(new mt({stage:"VPORT",step:1,progress:l,task:async u=>(this.processViewports(u.model,e),u)},r)),c.addTask(new mt({stage:"HEADER",step:1,progress:l,task:async u=>{if(this.processHeader(u.model,e),a){const m=Bs.instance();for(const[p,g]of Object.entries(a))m.setVar(p,g,e)}return u}},r)),c.addTask(new mt({stage:"BLOCK_RECORD",step:5,progress:l,task:async u=>(this.processBlockTables(u.model,e),u)},r)),c.addTask(new mt({stage:"OBJECT",step:5,progress:l,task:async u=>(this.processObjects(u.model,e),e.objects.layout.numEntries===0&&e.createDefaultData({layout:!0}),u)},r)),c.addTask(new mt({stage:"BLOCK",step:5,progress:l,task:async u=>(await this.processBlocks(u.model,e),u)},r)),c.addTask(new mt({stage:"ENTITY",step:100,progress:l,task:async u=>(await this.processEntities(u.model,e,i,l,r),u)},r)),c.addTask(new mt({stage:"END",step:0,progress:l,task:async u=>u},r));const d=Date.now();await c.run(t),o.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"),Je.instance.clear())}getParserWorkerTimeout(t,e){const i=e??this.config.timeout;if(i!=null)return i;const r=Math.ceil(t.byteLength/jl),n=Xn+r*1e3;return Math.min(Dl,Math.max(Xn,n))}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,i,r,n){throw new Error("Not impelemented yet!")}}class Wl extends Gr{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 et,es,X,q,ss,Mt,be,Dt,ot,jt,vt,fe,Ie,Se,_t,Wt,is,rs,Ee,Pe,ns,as,os,wt,Gt,W,Ae,hs,M,ht,ls,lt,cs,Ht,V,ds,Ut,Te,Ji,tr,kt,us,Me,xt,Xt,Yt,$t,ps,ms,qt,ve,ke,er,gs,Le,Zt,Ne,st,Kt,bt,sr,it,ir,Qt,ft,Oe,ys,Ce,It,Jt,St,te,rr,Fe,Et;(et={})[et.None=0]="None",et[et.Anonymous=1]="Anonymous",et[et.NonConstant=2]="NonConstant",et[et.Xref=4]="Xref",et[et.XrefOverlay=8]="XrefOverlay",et[et.ExternallyDependent=16]="ExternallyDependent",et[et.ResolvedOrDependent=32]="ResolvedOrDependent",et[et.ReferencedXref=64]="ReferencedXref";(es={})[es.BYBLOCK=0]="BYBLOCK",es[es.BYLAYER=256]="BYLAYER";(X={})[X.Rotated=0]="Rotated",X[X.Aligned=1]="Aligned",X[X.Angular=2]="Angular",X[X.Diameter=3]="Diameter",X[X.Radius=4]="Radius",X[X.Angular3Point=5]="Angular3Point",X[X.Ordinate=6]="Ordinate",X[X.ReferenceIsExclusive=32]="ReferenceIsExclusive",X[X.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",X[X.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(q={})[q.TopLeft=1]="TopLeft",q[q.TopCenter=2]="TopCenter",q[q.TopRight=3]="TopRight",q[q.MiddleLeft=4]="MiddleLeft",q[q.MiddleCenter=5]="MiddleCenter",q[q.MiddleRight=6]="MiddleRight",q[q.BottomLeft=7]="BottomLeft",q[q.BottomCenter=8]="BottomCenter",q[q.BottomRight=9]="BottomRight";(ss={})[ss.AtLeast=1]="AtLeast",ss[ss.Exact=2]="Exact";var Yn=((Mt={})[Mt.Center=0]="Center",Mt[Mt.Above=1]="Above",Mt[Mt.Outside=2]="Outside",Mt[Mt.JIS=3]="JIS",Mt[Mt.Below=4]="Below",Mt);(be={})[be.WithDimension=0]="WithDimension",be[be.AddLeader=1]="AddLeader",be[be.Independent=2]="Independent";(Dt={})[Dt.BothOutside=0]="BothOutside",Dt[Dt.ArrowFirst=1]="ArrowFirst",Dt[Dt.TextFirst=2]="TextFirst",Dt[Dt.Auto=3]="Auto";var Ue=((ot={})[ot.Feet=0]="Feet",ot[ot.None=1]="None",ot[ot.Inch=2]="Inch",ot[ot.FeetAndInch=3]="FeetAndInch",ot[ot.Leading=4]="Leading",ot[ot.Trailing=8]="Trailing",ot[ot.LeadingAndTrailing=12]="LeadingAndTrailing",ot),Gl=((jt={})[jt.None=0]="None",jt[jt.Leading=1]="Leading",jt[jt.Trailing=2]="Trailing",jt[jt.LeadingAndTrailing=3]="LeadingAndTrailing",jt),Hl=((vt={})[vt.Center=0]="Center",vt[vt.First=1]="First",vt[vt.Second=2]="Second",vt[vt.OverFirst=3]="OverFirst",vt[vt.OverSecond=4]="OverSecond",vt),Ul=((fe={})[fe.Bottom=0]="Bottom",fe[fe.Center=1]="Center",fe[fe.Top=2]="Top",fe);(Ie={})[Ie.None=0]="None",Ie[Ie.UseDrawingBackground=1]="UseDrawingBackground",Ie[Ie.Custom=2]="Custom";(Se={})[Se.Horizontal=0]="Horizontal",Se[Se.Diagonal=1]="Diagonal",Se[Se.NotStacked=2]="NotStacked";(_t={})[_t.Scientific=1]="Scientific",_t[_t.Decimal=2]="Decimal",_t[_t.Engineering=3]="Engineering",_t[_t.Architectural=4]="Architectural",_t[_t.Fractional=5]="Fractional",_t[_t.WindowDesktop=6]="WindowDesktop";(Wt={})[Wt.Decimal=0]="Decimal",Wt[Wt.DegreesMinutesSecond=1]="DegreesMinutesSecond",Wt[Wt.Gradian=2]="Gradian",Wt[Wt.Radian=3]="Radian";var Xl=((is={})[is.PatternFill=0]="PatternFill",is[is.SolidFill=1]="SolidFill",is);(rs={})[rs.NonAssociative=0]="NonAssociative",rs[rs.Associative=1]="Associative";(Ee={})[Ee.Normal=0]="Normal",Ee[Ee.Outer=1]="Outer",Ee[Ee.Ignore=2]="Ignore";(Pe={})[Pe.UserDefined=0]="UserDefined",Pe[Pe.Predefined=1]="Predefined",Pe[Pe.Custom=2]="Custom";(ns={})[ns.NotAnnotated=0]="NotAnnotated",ns[ns.Annotated=1]="Annotated";(as={})[as.Solid=0]="Solid",as[as.Gradient=1]="Gradient";(os={})[os.TwoColor=0]="TwoColor",os[os.OneColor=1]="OneColor";var Yl=((wt={})[wt.Default=0]="Default",wt[wt.External=1]="External",wt[wt.Polyline=2]="Polyline",wt[wt.Derived=4]="Derived",wt[wt.Textbox=8]="Textbox",wt[wt.Outermost=16]="Outermost",wt),ti=((Gt={})[Gt.Line=1]="Line",Gt[Gt.Circular=2]="Circular",Gt[Gt.Elliptic=3]="Elliptic",Gt[Gt.Spline=4]="Spline",Gt),$l=((W={})[W.Off=0]="Off",W[W.Solid=1]="Solid",W[W.Dashed=2]="Dashed",W[W.Dotted=3]="Dotted",W[W.ShotDash=4]="ShotDash",W[W.MediumDash=5]="MediumDash",W[W.LongDash=6]="LongDash",W[W.DoubleShortDash=7]="DoubleShortDash",W[W.DoubleMediumDash=8]="DoubleMediumDash",W[W.DoubleLongDash=9]="DoubleLongDash",W[W.DoubleMediumLongDash=10]="DoubleMediumLongDash",W[W.SparseDot=11]="SparseDot",W);$l.Off;(Ae={})[Ae.Standard=-3]="Standard",Ae[Ae.ByLayer=-2]="ByLayer",Ae[Ae.ByBlock=-1]="ByBlock";(hs={})[hs.English=0]="English",hs[hs.Metric=1]="Metric";(M={})[M.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",M[M.FRONT_CLIPPING=2]="FRONT_CLIPPING",M[M.BACK_CLIPPING=4]="BACK_CLIPPING",M[M.UCS_FOLLOW=8]="UCS_FOLLOW",M[M.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",M[M.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",M[M.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",M[M.FAST_ZOOM=128]="FAST_ZOOM",M[M.SNAP_MODE=256]="SNAP_MODE",M[M.GRID_MODE=512]="GRID_MODE",M[M.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",M[M.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",M[M.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",M[M.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",M[M.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",M[M.UNUSED=32768]="UNUSED",M[M.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",M[M.VIEWPORT_OFF=131072]="VIEWPORT_OFF",M[M.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",M[M.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",M[M.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",M[M.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE";(ht={})[ht.OPTIMIZED_2D=0]="OPTIMIZED_2D",ht[ht.WIREFRAME=1]="WIREFRAME",ht[ht.HIDDEN_LINE=2]="HIDDEN_LINE",ht[ht.FLAT_SHADED=3]="FLAT_SHADED",ht[ht.GOURAUD_SHADED=4]="GOURAUD_SHADED",ht[ht.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",ht[ht.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME";(ls={})[ls.UCS_UNCHANGED=0]="UCS_UNCHANGED",ls[ls.HAS_OWN_UCS=1]="HAS_OWN_UCS";(lt={})[lt.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",lt[lt.TOP=1]="TOP",lt[lt.BOTTOM=2]="BOTTOM",lt[lt.FRONT=3]="FRONT",lt[lt.BACK=4]="BACK",lt[lt.LEFT=5]="LEFT",lt[lt.RIGHT=6]="RIGHT";(cs={})[cs.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",cs[cs.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(Ht={})[Ht.ByLayer=0]="ByLayer",Ht[Ht.ByBlock=1]="ByBlock",Ht[Ht.ByDictionaryDefault=2]="ByDictionaryDefault",Ht[Ht.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 L(s,t,e){return s.code===t&&(e==null||s.value===e)}function me(s){let t={};s.rewind();let e=s.next(),i=e.code;if(t.x=e.value,(e=s.next()).code!==i+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=s.next()).code!==i+20?s.rewind():t.z=e.value,t}let Ws=Symbol();function S(s,t){return(e,i,r)=>{let n=function(l,c=!1){return l.reduce((d,u)=>{u.pushContext&&d.push({});let m=d[d.length-1];for(let p of typeof u.code=="number"?[u.code]:u.code){let g=m[p]??(m[p]=[]);u.isMultiple&&g.length,g.push(u)}return d},[{}])}(s,i.debug),a=!1,o=n.length-1;for(;!L(e,0,"EOF");){let l=function(x,w,P){return x.find((I,k)=>{var A;return k>=P&&((A=I[w])==null?void 0:A.length)})}(n,e.code,o),c=l==null?void 0:l[e.code],d=c==null?void 0:c[c.length-1];if(!l||!d){i.rewind();break}d.isMultiple||l[e.code].pop();let{name:u,parser:m,isMultiple:p,isReducible:g}=d,y=m==null?void 0:m(e,i,r);if(y===Ws){i.rewind();break}if(u){let[x,w]=ql(r,u);p&&!g?(Object.prototype.hasOwnProperty.call(x,w)||(x[w]=[]),x[w].push(y)):x[w]=y}d.pushContext&&(o-=1),a=!0,e=i.next()}return t&&Object.setPrototypeOf(r,t),a}}function ql(s,t){let e=t.split(".");if(!e.length)throw Error("[parserGenerator::getObjectByPath] Invalid empty path");let i=s;for(let r=0;r<e.length-1;++r){let n=nr(e[r]),a=nr(e[r+1]);Object.prototype.hasOwnProperty.call(i,n)||(typeof a=="number"?i[n]=[]:i[n]={}),i=i[n]}return[i,nr(e[e.length-1])]}function nr(s){let t=Number.parseInt(s);return Number.isNaN(t)?s:t}function h({value:s}){return s}function _(s,t){return me(t)}function v({value:s}){return!!s}function Zl({value:s}){return s.trim()}let Kl=[{code:281,name:"isEntity",parser:v},{code:280,name:"wasProxy",parser:v},{code:91,name:"instanceCount",parser:h},{code:90,name:"proxyFlag",parser:h},{code:3,name:"appName",parser:h},{code:2,name:"cppClassName",parser:h},{code:1,name:"name",parser:h}],Ql=S(Kl),Jl=[{code:0,name:"classes",isMultiple:!0,parser(s,t){if(s.value!=="CLASS")return Ws;s=t.next();let e={};return Ql(s,t,e),e}}],tc=S(Jl);(ds={})[ds.RayTrace=0]="RayTrace",ds[ds.ShadowMap=1]="ShadowMap";function zt(s,t,e){for(;L(s,102);){var i;let r=s.value;if(s=t.next(),!r.startsWith("{")){t.debug,function(a,o){for(;!L(a,102)&&!L(a,0,"EOF");)a=o.next()}(s,t),s=t.next();continue}let n=r.slice(1).trim();e.extensions??(e.extensions={}),(i=e.extensions)[n]??(i[n]=[]),function(a,o,l){for(;!L(a,102,"}")&&!L(a,0,"EOF");)l.push(a),a=o.next()}(s,t,e.extensions[n]),s=t.next()}t.rewind()}let ec=[{code:1001,name:"xdata",isMultiple:!0,parser:Ro}],sc=new Set([1010,1011,1012,1013]);function Ro(s,t){var r;if(!L(s,1001))throw Error("XData must starts with code 1001");let e={appName:s.value,value:[]};s=t.next();let i=[e.value];for(;!L(s,0,"EOF")&&!L(s,1001)&&s.code>=1e3;){let n=i[i.length-1];if(s.code===1002){s.value==="{"?i.push([]):(i.pop(),(r=i[i.length-1])==null||r.push(n)),s=t.next();continue}sc.has(s.code)?n.push(me(t)):n.push(s.value),s=t.next()}return t.rewind(),e}(Ut={})[Ut.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",Ut[Ut.CAST=1]="CAST",Ut[Ut.RECEIVE=2]="RECEIVE",Ut[Ut.IGNORE=3]="IGNORE";let z=[...ec,{code:284,name:"shadowMode",parser:h},{code:390,name:"plotStyleHardId",parser:h},{code:380,name:"plotStyleType",parser:h},{code:440,name:"transparency",parser:h},{code:430,name:"colorName",parser:h},{code:420,name:"color",parser:h},{code:310,name:"proxyEntity",isMultiple:!0,isReducible:!0,parser:(s,t,e)=>(e.proxyEntity??"")+s.value},{code:[92,160],name:"proxyByte",parser:h},{code:60,name:"isVisible",parser:v},{code:48,name:"lineTypeScale",parser:h},{code:370,name:"lineweight",parser:h},{code:62,name:"colorIndex",parser:h},{code:347,name:"materialObjectHardId",parser:h},{code:6,name:"lineType",parser:h},{code:8,name:"layer",parser:h},{code:410,name:"layoutTabName",parser:h},{code:67,name:"isInPaperSpace",parser:v},{code:100},{code:330,name:"ownerBlockRecordSoftId",parser:h},{code:102,parser:zt},{code:102,parser:zt},{code:102,parser:zt},{code:5,name:"handle",parser:h}];function Ui(s){return[{code:3,name:s,parser:(t,e,i)=>(i._code3text=(i._code3text??"")+t.value,i._code3text+(i._code1text??"")),isMultiple:!0,isReducible:!0},{code:1,name:s,parser:(t,e,i)=>(i._code1text=t.value,(i._code3text??"")+i._code1text)}]}function zo(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let ic={extrusionDirection:{x:0,y:0,z:1}},rc=[{code:210,name:"extrusionDirection",parser:_},{code:51,name:"endAngle",parser:h},{code:50,name:"startAngle",parser:h},{code:100,name:"subclassMarker",parser:h},{code:40,name:"radius",parser:h},{code:10,name:"center",parser:_},{code:39,name:"thickness",parser:h},{code:100},...z];class Vo{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){zo(this,"parser",S(rc,ic))}}zo(Vo,"ForEntityName","ARC");(Te={})[Te.BeforeText=0]="BeforeText",Te[Te.AboveText=1]="AboveText",Te[Te.None=2]="None";let Xr=[{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:Yn.Above,defaultValueImperial:Yn.Center},{name:"DIMZIN",code:78,defaultValue:Ue.Trailing,defaultValueImperial:Ue.Feet},{name:"DIMAZIN",code:79,defaultValue:Gl.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:Hl.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:Ul.Center},{name:"DIMTZIN",code:284,defaultValue:Ue.Trailing,defaultValueImperial:Ue.Feet},{name:"DIMALTZ",code:285,defaultValue:Ue.Trailing},{name:"DIMALTTZ",code:286,defaultValue:Ue.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}],Do=[{code:3,name:"styleName",parser:h},{code:210,name:"extrusionDirection",parser:_},{code:51,name:"ocsRotation",parser:h},{code:53,name:"textRotation",parser:h},{code:1,name:"text",parser:h},{code:42,name:"measurement",parser:h},{code:72,name:"textLineSpacingStyle",parser:h},{code:71,name:"attachmentPoint",parser:h},{code:70,name:"dimensionType",parser:h},{code:11,name:"textPoint",parser:_},{code:10,name:"definitionPoint",parser:_},{code:2,name:"name",parser:h},{code:280,name:"version",parser:h},{code:100}],nc=[{code:100},{code:52,name:"obliqueAngle",parser:h},{code:50,name:"rotationAngle",parser:h},{code:14,name:"subDefinitionPoint2",parser:_},{code:13,name:"subDefinitionPoint1",parser:_},{code:12,name:"insertionPoint",parser:_},{code:100,name:"subclassMarker",parser:h}],ac=[{code:16,name:"arcPoint",parser:_},{code:15,name:"centerPoint",parser:_},{code:14,name:"subDefinitionPoint2",parser:_},{code:13,name:"subDefinitionPoint1",parser:_},{code:100,name:"subclassMarker",parser:h}],oc=[{code:14,name:"subDefinitionPoint2",parser:_},{code:13,name:"subDefinitionPoint1",parser:_},{code:100,name:"subclassMarker",parser:h}],hc=[{code:40,name:"leaderLength",parser:h},{code:15,name:"subDefinitionPoint",parser:_},{code:100,name:"subclassMarker",parser:h}],lc=[{code:100,parser(s,t,e){let i=function(r){switch(r){case"AcDbAlignedDimension":return S(nc);case"AcDb3PointAngularDimension":case"AcDb2LineAngularDimension":return S(ac);case"AcDbOrdinateDimension":return S(oc);case"AcDbRadialDimension":case"AcDbDiametricDimension":return S(hc)}return null}(s.value);if(!i)return Ws;i(s,t,e)},pushContext:!0},...Xr.map(s=>({...s,parser:h})),...Do,...z];class ri{parseEntity(t,e){let i={};return S(lc)(e,t,i),i}}(Ji="ForEntityName")in ri?Object.defineProperty(ri,Ji,{value:"DIMENSION",enumerable:!0,configurable:!0,writable:!0}):ri[Ji]="DIMENSION";let cc=[{code:73},{code:17,name:"leaderEnd",parser:_},{code:16,name:"leaderStart",parser:_},{code:71,name:"hasLeader",parser:v},{code:41,name:"endAngle",parser:h},{code:40,name:"startAngle",parser:h},{code:70,name:"isPartial",parser:v},{code:15,name:"centerPoint",parser:_},{code:14,name:"xline2Point",parser:_},{code:13,name:"xline1Point",parser:_},{code:100,name:"subclassMarker",parser:h,pushContext:!0},...Xr.map(s=>({...s,parser:h})),...Do,...z];class ni{parseEntity(t,e){let i={};return S(cc)(e,t,i),i}}(tr="ForEntityName")in ni?Object.defineProperty(ni,tr,{value:"ARC_DIMENSION",enumerable:!0,configurable:!0,writable:!0}):ni[tr]="ARC_DIMENSION";(kt={})[kt.NONE=0]="NONE",kt[kt.INVISIBLE=1]="INVISIBLE",kt[kt.CONSTANT=2]="CONSTANT",kt[kt.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",kt[kt.PRESET=8]="PRESET";(us={})[us.MULTILINE=2]="MULTILINE",us[us.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(Me={})[Me.NONE=0]="NONE",Me[Me.MIRRORED_X=2]="MIRRORED_X",Me[Me.MIRRORED_Y=4]="MIRRORED_Y";var dc=((xt={})[xt.LEFT=0]="LEFT",xt[xt.CENTER=1]="CENTER",xt[xt.RIGHT=2]="RIGHT",xt[xt.ALIGNED=3]="ALIGNED",xt[xt.MIDDLE=4]="MIDDLE",xt[xt.FIT=5]="FIT",xt),uc=((Xt={})[Xt.BASELINE=0]="BASELINE",Xt[Xt.BOTTOM=1]="BOTTOM",Xt[Xt.MIDDLE=2]="MIDDLE",Xt[Xt.TOP=3]="TOP",Xt);function jo(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let Wo={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:dc.LEFT,valign:uc.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Go=[{code:73,name:"valign",parser:h},{code:100},{code:210,name:"extrusionDirection",parser:_},{code:11,name:"endPoint",parser:_},{code:72,name:"valign",parser:h},{code:72,name:"halign",parser:h},{code:71,name:"generationFlag",parser:h},{code:7,name:"styleName",parser:h},{code:51,name:"obliqueAngle",parser:h},{code:41,name:"xScale",parser:h},{code:50,name:"rotation",parser:h},{code:1,name:"text",parser:h},{code:40,name:"textHeight",parser:h},{code:10,name:"startPoint",parser:_},{code:39,name:"thickness",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class Ho{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){jo(this,"parser",S(Go,Wo))}}function Uo(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}jo(Ho,"ForEntityName","TEXT");let pc={...Wo},mc=[{code:2},{code:40,name:"annotationScale",parser:h},{code:10,name:"alignmentPoint",parser:_},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:h},{code:70,name:"numberOfSecondaryAttributes",parser:h},{code:70,name:"isReallyLocked",parser:v},{code:70,name:"mtextFlag",parser:h},{code:280,name:"isDuplicatedRecord",parser:v},{code:100},{code:280,name:"isLocked",parser:v},{code:74,name:"valign",parser:h},{code:73},{code:70,name:"attributeFlag",parser:h},{code:2,name:"tag",parser:h},{code:3,name:"prompt",parser:h},{code:280},{code:100,name:"subclassMarker",parser:h},...Go.slice(2)];class Xo{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Uo(this,"parser",S(mc,pc))}}function gc(s,t){let e={};for(let i of s){let r=t(i);r!=null&&(e[r]??(e[r]=[]),e[r].push(i))}return e}function*Bi(s,t=1/0,e=1){for(let i=s;i!==t;i+=e)yield i}function $n(s){return{x:s.x??0,y:s.y??0,z:s.z??0}}Uo(Xo,"ForEntityName","ATTDEF");var yc=[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 _c(s){return yc[s]}function wc(s){s.rewind();let t=s.next();if(t.code!==101)throw Error("Bad call for skipEmbeddedObject()");do t=s.next();while(t.code!==0);s.rewind()}function xc(s,t,e){if(L(t,102))return zt(t,e,s),!0;switch(t.code){case 0:s.type=t.value;break;case 5:s.handle=t.value;break;case 330:s.ownerBlockRecordSoftId=t.value;break;case 67:s.isInPaperSpace=!!t.value;break;case 8:s.layer=t.value;break;case 6:s.lineType=t.value;break;case 347:s.materialObjectHardId=t.value;break;case 62:s.colorIndex=t.value,s.color=_c(Math.abs(t.value));break;case 370:s.lineweight=t.value;break;case 48:s.lineTypeScale=t.value;break;case 60:s.isVisible=!!t.value;break;case 92:s.proxyByte=t.value;break;case 310:s.proxyEntity=t.value;break;case 100:break;case 420:s.color=t.value;break;case 430:s.transparency=t.value;break;case 390:s.plotStyleHardId=t.value;break;case 284:s.shadowMode=t.value;break;case 1001:(s.xdata??(s.xdata=[])).push(Ro(t,e));break;default:return!1}return!0}function Yo(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let bc={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},ai=[{code:46,name:"annotationHeight",parser:h},{code:101,parser(s,t){wc(t)}},{code:50,name:"columnHeight",parser:h},{code:49,name:"columnGutter",parser:h},{code:48,name:"columnWidth",parser:h},{code:79,name:"columnAutoHeight",parser:h},{code:78,name:"columnFlowReversed",parser:h},{code:76,name:"columnCount",parser:h},{code:75,name:"columnType",parser:h},{code:441,name:"backgroundFillTransparency",parser:h},{code:63,name:"backgroundFillColor",parser:h},{code:45,name:"fillBoxScale",parser:h},{code:[...Bi(430,440)],name:"backgroundColor",parser:h},{code:[...Bi(420,430)],name:"backgroundColor",parser:h},{code:90,name:"backgroundFill",parser:h},{code:44,name:"lineSpacing",parser:h},{code:73,name:"lineSpacingStyle",parser:h},{code:50,name:"rotation",parser:h},{code:43},{code:42},{code:11,name:"direction",parser:_},{code:210,name:"extrusionDirection",parser:_},{code:7,name:"styleName",parser:h},...Ui("text"),{code:72,name:"drawingDirection",parser:h},{code:71,name:"attachmentPoint",parser:h},{code:41,name:"width",parser:h},{code:40,name:"height",parser:h},{code:10,name:"insertionPoint",parser:_},{code:100,name:"subclassMarker",parser:h},...z];class $o{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Yo(this,"parser",S(ai,bc))}}function qo(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Yo($o,"ForEntityName","MTEXT");let fc={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},Ic=[...ai.slice(ai.findIndex(({name:s})=>s==="columnType"),ai.findIndex(({name:s})=>s==="subclassMarker")+1),{code:100},{code:0,parser(s){if(!L(s,0,"MTEXT"))return Ws}},{code:2,name:"definitionTag",parser:h},{code:40,name:"annotationScale",parser:h},{code:10,name:"alignmentPoint",parser:_},{code:340,name:"secondaryAttributesHardId",parser:h},{code:70,name:"numberOfSecondaryAttributes",parser:h},{code:70,name:"isReallyLocked",parser:v},{code:70,name:"mtextFlag",parser:h},{code:280,name:"isDuplicatedEntriesKeep",parser:v},{code:100},{code:280,name:"lockPositionFlag",parser:v},{code:210,name:"extrusionDirection",parser:_},{code:11,name:"alignmentPoint",parser:_},{code:74,name:"verticalJustification",parser:h},{code:72,name:"horizontalJustification",parser:h},{code:71,name:"textGenerationFlag",parser:h},{code:7,name:"textStyle",parser:h},{code:51,name:"obliqueAngle",parser:h},{code:41,name:"scale",parser:h},{code:50,name:"rotation",parser:h},{code:73},{code:70,name:"attributeFlag",parser:h},{code:2,name:"tag",parser:h},{code:280},{code:100,name:"subclassMarker",parser:h},{code:1,name:"text",parser:h},{code:40,name:"textHeight",parser:h},{code:10,name:"startPoint",parser:_},{code:39,name:"thickness",parser:h},{code:100},...z];class Zo{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){qo(this,"parser",S(Ic,fc))}}function Ko(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}qo(Zo,"ForEntityName","ATTRIB");let Sc=[...Ui("data"),{code:70,name:"version",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class Qo{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Ko(this,"parser",S(Sc))}}function Jo(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Ko(Qo,"ForEntityName","BODY");let Ec={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Pc=[{code:210,name:"extrusionDirection",parser:_},{code:40,name:"radius",parser:h},{code:10,name:"center",parser:_},{code:39,name:"thickness",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class th{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Jo(this,"parser",S(Pc,Ec))}}function eh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Jo(th,"ForEntityName","CIRCLE");let Ac={extrusionDirection:{x:0,y:0,z:1}},Tc=[{code:42,name:"endAngle",parser:h},{code:41,name:"startAngle",parser:h},{code:40,name:"axisRatio",parser:h},{code:210,name:"extrusionDirection",parser:_},{code:11,name:"majorAxisEndPoint",parser:_},{code:10,name:"center",parser:_},{code:100,name:"subclassMarker",parser:h},...z];class sh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){eh(this,"parser",S(Tc,Ac))}}function ih(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}eh(sh,"ForEntityName","ELLIPSE");let Mc=[{code:13,name:"vertices.3",parser:_},{code:12,name:"vertices.2",parser:_},{code:11,name:"vertices.1",parser:_},{code:10,name:"vertices.0",parser:_},{code:100,name:"subclassMarker",parser:h},...z];class rh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){ih(this,"parser",S(Mc))}}ih(rh,"ForEntityName","3DFACE");(Yt={})[Yt.First=1]="First",Yt[Yt.Second=2]="Second",Yt[Yt.Third=4]="Third",Yt[Yt.Fourth=8]="Fourth";let nh=[{code:330,name:"sourceBoundaryObjects",parser:h,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:h}],vc=[{code:11,name:"end",parser:_},{code:10,name:"start",parser:_}],kc=[{code:73,name:"isCCW",parser:v},{code:51,name:"endAngle",parser:h},{code:50,name:"startAngle",parser:h},{code:40,name:"radius",parser:h},{code:10,name:"center",parser:_}],Lc=[{code:73,name:"isCCW",parser:v},{code:51,name:"endAngle",parser:h},{code:50,name:"startAngle",parser:h},{code:40,name:"lengthOfMinorAxis",parser:h},{code:11,name:"end",parser:_},{code:10,name:"center",parser:_}],Nc=[{code:13,name:"endTangent",parser:_},{code:12,name:"startTangent",parser:_},{code:11,name:"fitDatum",isMultiple:!0,parser:_},{code:97,name:"numberOfFitData",parser:h},{code:10,name:"controlPoints",isMultiple:!0,parser(s,t){let e={...me(t),weight:1};return(s=t.next()).code===42?e.weight=s.value:t.rewind(),e}},{code:40,name:"knots",isMultiple:!0,parser:h},{code:96,name:"numberOfControlPoints",parser:h},{code:95,name:"numberOfKnots",parser:h},{code:74,name:"isPeriodic",parser:v},{code:73,name:"splineFlag",parser:h},{code:94,name:"degree",parser:h}],Oc={[ti.Line]:vc,[ti.Circular]:kc,[ti.Elliptic]:Lc,[ti.Spline]:Nc},Cc=[...nh,{code:72,name:"edges",parser(s,t){let e={type:s.value},i=S(Oc[e.type]);if(!i)throw Error(`Invalid edge type ${e.type}`);return i(s=t.next(),t,e),e},isMultiple:!0},{code:93,name:"numberOfEdges",parser:h}],Fc=[...nh,{code:10,name:"vertices",parser(s,t){let e={...me(t),bulge:0};return(s=t.next()).code===42?e.bulge=s.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:h},{code:73,name:"isClosed",parser:v},{code:72,name:"hasBulge",parser:v}];function Bc(s,t){let e={boundaryPathTypeFlag:s.value},i=e.boundaryPathTypeFlag&Yl.Polyline;return s=t.next(),i?S(Fc)(s,t,e):S(Cc)(s,t,e),e}let Rc=[{code:49,name:"dashLengths",parser:h,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:h},{code:45,name:"offset",parser:qn},{code:43,name:"base",parser:qn},{code:53,name:"angle",parser:h}];function qn(s,t){let e=s.code+1,i={x:s.value,y:1};return(s=t.next()).code===e?i.y=s.value:t.rewind(),i}function zc(s,t){let e={};return S(Rc)(s,t,e),e}function ah(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let Vc={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},Dc=[{code:470},{code:463},{code:462,name:"colorTint",parser:h},{code:461,name:"gradientDefinition",parser:h},{code:460,name:"gradientRotation",parser:h},{code:453,name:"numberOfColors",parser:h},{code:452,name:"gradientColorFlag",parser:h},{code:451},{code:450,name:"gradientFlag",parser:h},{code:10,name:"seedPoints",parser:_,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:_},{code:98,name:"numberOfSeedPoints",parser:h},{code:47,name:"pixelSize",parser:h},{code:53,name:"definitionLines",parser:zc,isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:h},{code:77,name:"isDouble",parser:v},{code:73,name:"isAnnotated",parser:v},{code:41,name:"patternScale",parser:h},{code:52,name:"patternAngle",parser:h},{code:76,name:"patternType",parser:h},{code:75,name:"hatchStyle",parser:h},{code:92,name:"boundaryPaths",parser:Bc,isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:h},{code:71,name:"associativity",parser:h},{code:63,name:"patternFillColor",parser:h},{code:70,name:"solidFill",parser:h},{code:2,name:"patternName",parser:h},{code:210,name:"extrusionDirection",parser:_},{code:10,name:"elevationPoint",parser:_},{code:100,name:"subclassMarker",parser:h,pushContext:!0},...z];class oh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){ah(this,"parser",S(Dc,Vc))}}function hh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}ah(oh,"ForEntityName","HATCH");let jc={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},Wc=[{code:290,name:"clipMode",parser:h},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:_},{code:91,name:"countBoundaryPoints",parser:h},{code:71,name:"clippingBoundaryType",parser:h},{code:360,name:"imageDefReactorHandle",parser:h},{code:283,name:"fade",parser:h},{code:282,name:"contrast",parser:h},{code:281,name:"brightness",parser:h},{code:280,name:"isClipped",parser:v},{code:70,name:"flags",parser:h},{code:340,name:"imageDefHandle",parser:h},{code:13,name:"imageSize",parser:_},{code:12,name:"vPixel",parser:_},{code:11,name:"uPixel",parser:_},{code:10,name:"position",parser:_},{code:90,name:"version",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class lh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){hh(this,"parser",S(Wc,jc))}}hh(lh,"ForEntityName","IMAGE");($t={})[$t.ShowImage=1]="ShowImage",$t[$t.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",$t[$t.UseClippingBoundary=4]="UseClippingBoundary",$t[$t.TransparencyIsOn=8]="TransparencyIsOn";(ps={})[ps.Rectangular=1]="Rectangular",ps[ps.Polygonal=2]="Polygonal";(ms={})[ms.Outside=0]="Outside",ms[ms.Inside=1]="Inside";function ch(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let Gc={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},Hc=[{code:210,name:"extrusionDirection",parser:_},{code:45,name:"rowSpacing",parser:h},{code:44,name:"columnSpacing",parser:h},{code:71,name:"rowCount",parser:h},{code:70,name:"columnCount",parser:h},{code:50,name:"rotation",parser:h},{code:43,name:"zScale",parser:h},{code:42,name:"yScale",parser:h},{code:41,name:"xScale",parser:h},{code:10,name:"insertionPoint",parser:_},{code:2,name:"name",parser:h},{code:66,name:"isVariableAttributes",parser:v},{code:100,name:"subclassMarker",parser:h},...z];class dh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){ch(this,"parser",S(Hc,Gc))}}function uh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}ch(dh,"ForEntityName","INSERT");let Uc={isArrowheadEnabled:!0},Xc=[{code:213,name:"offsetFromAnnotation",parser:_},{code:212,name:"offsetFromBlock",parser:_},{code:211,name:"horizontalDirection",parser:_},{code:210,name:"normal",parser:_},{code:340,name:"associatedAnnotation",parser:h},{code:77,name:"byBlockColor",parser:h},{code:10,name:"vertices",parser:_,isMultiple:!0},{code:76,name:"numberOfVertices",parser:h},{code:41,name:"textWidth",parser:h},{code:40,name:"textHeight",parser:h},{code:75,name:"isHooklineExists",parser:v},{code:74,name:"isHooklineSameDirection",parser:v},{code:73,name:"leaderCreationFlag",parser:h},{code:72,name:"isSpline",parser:v},{code:71,name:"isArrowheadEnabled",parser:v},{code:3,name:"styleName",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class ph{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){uh(this,"parser",S(Xc,Uc))}}uh(ph,"ForEntityName","LEADER");(qt={})[qt.TextAnnotation=0]="TextAnnotation",qt[qt.ToleranceAnnotation=1]="ToleranceAnnotation",qt[qt.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",qt[qt.NoAnnotation=3]="NoAnnotation";function mh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let Yc={thickness:0,extrusionDirection:{x:0,y:0,z:1}},$c=[{code:210,name:"extrusionDirection",parser:_},{code:11,name:"endPoint",parser:_},{code:10,name:"startPoint",parser:_},{code:39,name:"thickness",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class gh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){mh(this,"parser",S($c,Yc))}}function yh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}mh(gh,"ForEntityName","LINE");let qc=[{code:280,name:"shadowMapSoftness",parser:h},{code:91,name:"shadowMapSize",parser:h},{code:73,name:"shadowType",parser:h},{code:293,name:"isShadowCast",parser:v},{code:51,name:"falloffAngle",parser:h},{code:50,name:"hotspotAngle",parser:h},{code:42,name:"limitEnd",parser:h},{code:41,name:"limitStart",parser:h},{code:292,name:"isAttenuationLimited",parser:v},{code:72,name:"attenuationType",parser:h},{code:11,name:"target",parser:_},{code:10,name:"position",parser:_},{code:40,name:"intensity",parser:h},{code:291,name:"isPlotGlyph",parser:v},{code:290,name:"isOn",parser:v},{code:421,name:"lightColorInstance",parser:h},{code:63,name:"lightColorIndex",parser:h},{code:70,name:"lightType",parser:h},{code:1,name:"name",parser:h},{code:90,name:"version",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class _h{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){yh(this,"parser",S(qc))}}yh(_h,"ForEntityName","LIGHT");(ve={})[ve.Distant=1]="Distant",ve[ve.Point=2]="Point",ve[ve.Spot=3]="Spot";(ke={})[ke.None=0]="None",ke[ke.InverseLinear=1]="InverseLinear",ke[ke.InverseSquare=2]="InverseSquare";let Zc={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},Kc={bulge:0},Qc=[{code:42,name:"bulge",parser:h},{code:41,name:"endWidth",parser:h},{code:40,name:"startWidth",parser:h},{code:91,name:"id",parser:h},{code:20,name:"y",parser:h},{code:10,name:"x",parser:h}],Jc=[{code:210,name:"extrusionDirection",parser:_},{code:10,name:"vertices",isMultiple:!0,parser(s,t){let e={};return S(Qc,Kc)(s,t,e),e}},{code:39,name:"thickness",parser:h},{code:38,name:"elevation",parser:h},{code:43,name:"constantWidth",parser:h},{code:70,name:"flag",parser:h},{code:90,name:"numberOfVertices",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class oi{parseEntity(t,e){let i={};return S(Jc,Zc)(e,t,i),i}}(er="ForEntityName")in oi?Object.defineProperty(oi,er,{value:"LWPOLYLINE",enumerable:!0,configurable:!0,writable:!0}):oi[er]="LWPOLYLINE";(gs={})[gs.IS_CLOSED=1]="IS_CLOSED",gs[gs.PLINE_GEN=128]="PLINE_GEN";function wh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let td=[{code:90,name:"overridenSubEntityCount",parser:h},{code:140,name:"edgeCreaseWeights",parser:h,isMultiple:!0},{code:95,name:"edgeCreaseCount",parser:h},{code:94,parser(s,t,e){e.edgeCount=s.value,e.edgeIndices=[];for(let i=0;i<e.edgeCount;++i){let r=[];s=t.next(),r[0]=s.value,s=t.next(),r[1]=s.value,e.edgeIndices.push(r)}}},{code:93,parser(s,t,e){e.totalFaceIndices=s.value,e.faceIndices=[];let i=[];for(let n=0;n<e.totalFaceIndices&&!L(s,0);++n)s=t.next(),i.push(s.value);let r=0;for(;r<i.length;){let n=i[r++],a=[];for(let o=0;o<n;++o)a.push(i[r++]);e.faceIndices.push(a)}}},{code:10,name:"vertices",parser:_,isMultiple:!0},{code:92,name:"verticesCount",parser:h},{code:91,name:"subdivisionLevel",parser:h},{code:40,name:"blendCrease",parser:h},{code:72,name:"isBlendCreased",parser:v},{code:71,name:"version",parser:h},{code:100,name:"subclassMarker",parser:Zl,pushContext:!0},...z];class xh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){wh(this,"parser",S(td))}}function bh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}wh(xh,"ForEntityName","MESH");let ed=[{code:42,name:"fillParameters",parser:h,isMultiple:!0},{code:75,name:"fillCount",parser:h},{code:41,name:"parameters",parser:h,isMultiple:!0},{code:74,name:"parameterCount",parser:h}],sd=[{code:[74,41,75,42],name:"elements",parser(s,t){let e=S(ed),i={};return e(s,t,i),i},isMultiple:!0},{code:13,name:"miterDirection",parser:_},{code:12,name:"direction",parser:_},{code:11,name:"position",parser:_}],id=[{code:[11,12,13],name:"segments",parser(s,t){let e=S(sd),i={};return e(s,t,i),i},isMultiple:!0},{code:210,name:"extrusionDirection",parser:_},{code:10,name:"startPosition",parser:_},{code:73,name:"styleCount",parser:h},{code:72,name:"vertexCount",parser:h},{code:71,name:"flags",parser:h},{code:70,name:"justification",parser:h},{code:40,name:"scale",parser:h},{code:340,name:"styleObjectHandle",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h,pushContext:!0},...z];class fh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){bh(this,"parser",S(id))}}bh(fh,"ForEntityName","MLINE");(Le={})[Le.Top=0]="Top",Le[Le.Zero=1]="Zero",Le[Le.Bottom=2]="Bottom";(Zt={})[Zt.HasVertex=1]="HasVertex",Zt[Zt.Closed=2]="Closed",Zt[Zt.SuppressStartCaps=4]="SuppressStartCaps",Zt[Zt.SuppressEndCaps=8]="SuppressEndCaps";(Ne={})[Ne.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",Ne[Ne.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",Ne[Ne.BY_STYLE=5]="BY_STYLE";function Ih(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let rd={},nd=[{code:170,name:"multileaderType",parser:h},{code:291,name:"doglegEnabled",parser:v},{code:40,name:"doglegLength",parser:h},{code:172,name:"contentType",parser:h},{code:3,name:"textContent",parser:h},{code:12,name:"textAnchor",parser:_},{code:344,name:"blockHandle",parser:h},{code:15,name:"blockPosition",parser:_},{code:302,name:"leaderSections",parser:function(s,t,e){let i,r={leaderLines:[]};for(;t.hasNext()&&(i=t.next()).code!==303;)switch(i.code){case 10:r.landingPoint=_(i.value,t);break;case 11:r.doglegVector=_(i.value,t);break;case 40:r.doglegLength=i.value;break;case 304:r.leaderLines.push(function(n){let a,o={vertices:[]};for(;n.hasNext()&&(a=n.next()).code!==305;)a.code===10&&o.vertices.push(_(a.value,n));return o}(t))}return r},isMultiple:!0},...z];class Sh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Ih(this,"parser",S(nd,rd))}}function Eh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Ih(Sh,"ForEntityName","MULTILEADER");let ad={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},od=[{code:50,name:"angle",parser:h},{code:210,name:"extrusionDirection",parser:_},{code:39,name:"thickness",parser:h},{code:10,name:"position",parser:_},{code:100,name:"subclassMarker",parser:h},...z];class Ph{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Eh(this,"parser",S(od,ad))}}function Ah(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Eh(Ph,"ForEntityName","POINT");let hd={startWidth:0,endWidth:0,bulge:0},ld=[{code:91,name:"id",parser:h},{code:[...Bi(71,75)],name:"faces",isMultiple:!0,parser:h},{code:50,name:"tangentDirection",parser:h},{code:70,name:"flag",parser:h},{code:42,name:"bulge",parser:h},{code:41,name:"endWidth",parser:h},{code:40,name:"startWidth",parser:h},{code:30,name:"z",parser:h},{code:20,name:"y",parser:h},{code:10,name:"x",parser:h},{code:100,name:"subclassMarker",parser:h},{code:100},...z];class Yr{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Ah(this,"parser",S(ld,hd))}}function Th(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Ah(Yr,"ForEntityName","VERTEX");let cd={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:[]},dd=[{code:0,name:"vertices",isMultiple:!0,parser:(s,t)=>L(s,0,"VERTEX")?(s=t.next(),new Yr().parseEntity(t,s)):Ws},{code:210,name:"extrusionDirection",parser:_},{code:75,name:"smoothType",parser:h},{code:74,name:"surfaceNDensity",parser:h},{code:73,name:"surfaceMDensity",parser:h},{code:72,name:"meshNVertexCount",parser:h},{code:71,name:"meshMVertexCount",parser:h},{code:41,name:"endWidth",parser:h},{code:40,name:"startWidth",parser:h},{code:70,name:"flag",parser:h},{code:39,name:"thickness",parser:h},{code:30,name:"elevation",parser:h},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:h},...z];class Mh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Th(this,"parser",S(dd,cd))}}Th(Mh,"ForEntityName","POLYLINE");(st={})[st.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",st[st.CURVE_FIT=2]="CURVE_FIT",st[st.SPLINE_FIT=4]="SPLINE_FIT",st[st.POLYLINE_3D=8]="POLYLINE_3D",st[st.POLYGON_3D=16]="POLYGON_3D",st[st.CLOSED_POLYGON=32]="CLOSED_POLYGON",st[st.POLYFACE=64]="POLYFACE",st[st.CONTINUOUS=128]="CONTINUOUS";var ei=((Kt={})[Kt.NONE=0]="NONE",Kt[Kt.QUADRATIC=5]="QUADRATIC",Kt[Kt.CUBIC=6]="CUBIC",Kt[Kt.BEZIER=8]="BEZIER",Kt);function vh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let ud=[{code:11,name:"direction",parser:_},{code:10,name:"position",parser:_},{code:100,name:"subclassMarker",parser:h},...z];class kh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){vh(this,"parser",S(ud))}}function Lh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}vh(kh,"ForEntityName","RAY");let pd=[...Ui("data"),{code:70,name:"version",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class Nh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Lh(this,"parser",S(pd))}}function Oh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Lh(Nh,"ForEntityName","REGION");let md={vertices:[],backLineVertices:[]},gd=[{code:360,name:"geometrySettingHardId",parser:h},{code:12,name:"backLineVertices",isMultiple:!0,parser:_},{code:93,name:"numberOfBackLineVertices",parser:h},{code:11,name:"vertices",isMultiple:!0,parser:_},{code:92,name:"verticesCount",parser:h},{code:[63,411],name:"indicatorColor",parser:h},{code:70,name:"indicatorTransparency",parser:h},{code:41,name:"bottomHeight",parser:h},{code:40,name:"topHeight",parser:h},{code:10,name:"verticalDirection",parser:_},{code:1,name:"name",parser:h},{code:91,name:"flag",parser:h},{code:90,name:"state",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class Ch{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Oh(this,"parser",S(gd,md))}}function Fh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Oh(Ch,"ForEntityName","SECTION");let yd={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},_d=[{code:210,name:"extrusionDirection",parser:_},{code:39,name:"thickness",parser:h},{code:[...Bi(10,14)],name:"points",isMultiple:!0,parser:_},{code:100,name:"subclassMarker",parser:h},...z];class Bh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Fh(this,"parser",S(_d,yd))}}function Rh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Fh(Bh,"ForEntityName","SOLID");let wd=[{code:350,name:"historyObjectSoftId",parser:h},{code:100,name:"subclassMarker",parser:h},...Ui("data"),{code:70,name:"version",parser:h},{code:100},...z];class zh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Rh(this,"parser",S(wd))}}function Vh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Rh(zh,"ForEntityName","3DSOLID");let xd={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},bd=[{code:11,name:"fitPoints",isMultiple:!0,parser:_},{code:10,name:"controlPoints",isMultiple:!0,parser:_},{code:41,name:"weights",isMultiple:!0,parser:h},{code:40,name:"knots",isMultiple:!0,parser:h},{code:13,name:"endTangent",parser:_},{code:12,name:"startTangent",parser:_},{code:44,name:"fitTolerance",parser:h},{code:43,name:"controlTolerance",parser:h},{code:42,name:"knotTolerance",parser:h},{code:74,name:"numberOfFitPoints",parser:h},{code:73,name:"numberOfControlPoints",parser:h},{code:72,name:"numberOfKnots",parser:h},{code:71,name:"degree",parser:h},{code:70,name:"flag",parser:h},{code:210,name:"normal",parser:_},{code:100,name:"subclassMarker",parser:h},...z];class Dh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Vh(this,"parser",S(bd,xd))}}Vh(Dh,"ForEntityName","SPLINE");(bt={})[bt.NONE=0]="NONE",bt[bt.CLOSED=1]="CLOSED",bt[bt.PERIODIC=2]="PERIODIC",bt[bt.RATIONAL=4]="RATIONAL",bt[bt.PLANAR=8]="PLANAR",bt[bt.LINEAR=16]="LINEAR";function jh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let fd=[{code:280,name:"shadowMapSoftness",parser:h},{code:71,name:"shadowMapSize",parser:h},{code:70,name:"shadowType",parser:h},{code:292,name:"isSummerTime",parser:v},{code:92,name:"time",parser:h},{code:91,name:"julianDay",parser:h},{code:291,name:"hasShadow",parser:v},{code:40,name:"intensity",parser:h},{code:421,name:"lightColorInstance",parser:h},{code:63,name:"lightColorIndex",parser:h},{code:290,name:"isOn",parser:v},{code:90,name:"version",parser:h},{code:100,name:"subclassMarker",parser:h,pushContext:!0},...z.filter(s=>s.code!==100)];class Wh{parseEntity(t,e){let i={layer:""};return this.parser(e,t,i),i}constructor(){jh(this,"parser",S(fd))}}jh(Wh,"ForEntityName","SUN");class hi{parseEntity(t,e){let i={};for(;!t.isEOF();){if(e.code===0){t.rewind();break}switch(e.code){case 100:i.subclassMarker=e.value,e=t.next();break;case 2:i.name=e.value,e=t.next();break;case 5:i.handle=e.value,e=t.next();break;case 10:i.startPoint=$n(me(t)),e=t.lastReadGroup;break;case 11:i.directionVector=$n(me(t)),e=t.lastReadGroup;break;case 90:i.tableValue=e.value,e=t.next();break;case 91:i.rowCount=e.value,e=t.next();break;case 92:i.columnCount=e.value,e=t.next();break;case 93:i.overrideFlag=e.value,e=t.next();break;case 94:i.borderColorOverrideFlag=e.value,e=t.next();break;case 95:i.borderLineWeightOverrideFlag=e.value,e=t.next();break;case 96:i.borderVisibilityOverrideFlag=e.value,e=t.next();break;case 141:i.rowHeightArr??(i.rowHeightArr=[]),i.rowHeightArr.push(e.value),e=t.next();break;case 142:i.columnWidthArr??(i.columnWidthArr=[]),i.columnWidthArr.push(e.value),e=t.next();break;case 280:i.version=e.value,e=t.next();break;case 310:i.bmpPreview??(i.bmpPreview=""),i.bmpPreview+=e.value,e=t.next();break;case 330:i.ownerDictionaryId=e.value,e=t.next();break;case 342:i.tableStyleId=e.value,e=t.next();break;case 343:i.blockRecordHandle=e.value,e=t.next();break;case 170:i.attachmentPoint=e.value,e=t.next();break;case 171:i.cells??(i.cells=[]),i.cells.push(function(r,n){let a=!1,o=!1,l={};for(;!r.isEOF()&&n.code!==0&&!o;)switch(n.code){case 171:if(a){o=!0;continue}l.cellType=n.value,a=!0,n=r.next();break;case 172:l.flagValue=n.value,n=r.next();break;case 173:l.mergedValue=n.value,n=r.next();break;case 174:l.autoFit=n.value,n=r.next();break;case 175:l.borderWidth=n.value,n=r.next();break;case 176:l.borderHeight=n.value,n=r.next();break;case 91:l.overrideFlag=n.value,n=r.next();break;case 178:l.virtualEdgeFlag=n.value,n=r.next();break;case 145:l.rotation=n.value,n=r.next();break;case 345:l.fieldObjetId=n.value,n=r.next();break;case 340:l.blockTableRecordId=n.value,n=r.next();break;case 146:l.blockScale=n.value,n=r.next();break;case 177:l.blockAttrNum=n.value,n=r.next();break;case 7:l.textStyle=n.value,n=r.next();break;case 140:l.textHeight=n.value,n=r.next();break;case 170:l.attachmentPoint=n.value,n=r.next();break;case 92:l.extendedCellFlags=n.value,n=r.next();break;case 285:l.rightBorderVisibility=!!(n.value??!0),n=r.next();break;case 286:l.bottomBorderVisibility=!!(n.value??!0),n=r.next();break;case 288:l.leftBorderVisibility=!!(n.value??!0),n=r.next();break;case 289:l.topBorderVisibility=!!(n.value??!0),n=r.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()}})(l,r,n),n=r.next();break;default:return l}return a=!1,o=!1,l}(t,e)),e=t.lastReadGroup;break;default:xc(i,e,t),e=t.next()}}return i}}function Gh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}(sr="ForEntityName")in hi?Object.defineProperty(hi,sr,{value:"ACAD_TABLE",enumerable:!0,configurable:!0,writable:!0}):hi[sr]="ACAD_TABLE";let Id=[{code:11,name:"xAxisDirection",parser:_},{code:210,name:"extrusionDirection",parser:_},{code:1,name:"text",parser:h},{code:10,name:"position",parser:_},{code:3,name:"styleName",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class Hh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Gh(this,"parser",S(Id))}}Gh(Hh,"ForEntityName","TOLERANCE");var Sd=((it={})[it.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",it[it.TANGENT_DEFINED=2]="TANGENT_DEFINED",it[it.NOT_USED=4]="NOT_USED",it[it.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",it[it.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",it[it.FOR_POLYLINE=32]="FOR_POLYLINE",it[it.FOR_POLYGON=64]="FOR_POLYGON",it[it.POLYFACE=128]="POLYFACE",it);let Ed=[{code:[335,343,344,91],name:"softPointers",isMultiple:!0,parser:h},{code:361,name:"sunId",parser:h},{code:431,name:"ambientLightColorName",parser:h},{code:421,name:"ambientLightColorInstance",parser:h},{code:63,name:"ambientLightColorIndex",parser:h},{code:142,name:"contrast",parser:h},{code:141,name:"brightness",parser:h},{code:282,name:"defaultLightingType",parser:h},{code:292,name:"isDefaultLighting",parser:v},{code:348,name:"visualStyleId",parser:h},{code:333,name:"shadePlotId",parser:h},{code:332,name:"backgroundId",parser:h},{code:61,name:"majorGridFrequency",parser:h},{code:170,name:"shadePlotMode",parser:h},{code:146,name:"elevation",parser:h},{code:79,name:"orthographicType",parser:h},{code:346,name:"ucsBaseId",parser:h},{code:345,name:"ucsId",parser:h},{code:112,name:"ucsYAxis",parser:_},{code:111,name:"ucsXAxis",parser:_},{code:110,name:"ucsOrigin",parser:_},{code:74,name:"iconFlag",parser:h},{code:71,name:"ucsPerViewport",parser:h},{code:281,name:"renderMode",parser:h},{code:1,name:"sheetName",parser:h},{code:340,name:"clippingBoundaryId",parser:h},{code:90,name:"statusBitFlags",parser:h},{code:331,name:"frozenLayerIds",isMultiple:!0,parser:h},{code:72,name:"circleZoomPercent",parser:h},{code:51,name:"viewTwistAngle",parser:h},{code:50,name:"snapAngle",parser:h},{code:45,name:"viewHeight",parser:h},{code:44,name:"backClipZ",parser:h},{code:43,name:"frontClipZ",parser:h},{code:42,name:"perspectiveLensLength",parser:h},{code:17,name:"targetPoint",parser:_},{code:16,name:"viewDirection",parser:_},{code:15,name:"gridSpacing",parser:_},{code:14,name:"snapSpacing",parser:_},{code:13,name:"snapBase",parser:_},{code:12,name:"displayCenter",parser:_},{code:69,name:"viewportId",parser:h},{code:68,name:"status",parser:h},{code:41,name:"height",parser:h},{code:40,name:"width",parser:h},{code:10,name:"viewportCenter",parser:_},{code:100,name:"subclassMarker",parser:h,pushContext:!0},...z];class li{parseEntity(t,e){let i={};return S(Ed)(e,t,i),i}}function Uh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}(ir="ForEntityName")in li?Object.defineProperty(li,ir,{value:"VIEWPORT",enumerable:!0,configurable:!0,writable:!0}):li[ir]="VIEWPORT";let Pd={brightness:50,constrast:50,fade:0},Ad=[{code:14,name:"boundary",isMultiple:!0,parser:_},{code:91,name:"numberOfVertices",parser:h},{code:71,name:"boundaryType",parser:h},{code:360,name:"imageDefReactorHardId",parser:h},{code:283,name:"fade",parser:h},{code:282,name:"contrast",parser:h},{code:281,name:"brightness",parser:h},{code:280,name:"isClipping",parser:v},{code:70,name:"displayFlag",parser:h},{code:340,name:"imageDefHardId",parser:h},{code:13,name:"imageSize",parser:_},{code:12,name:"vDirection",parser:_},{code:11,name:"uDirection",parser:_},{code:10,name:"position",parser:_},{code:90,name:"classVersion",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class Xh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Uh(this,"parser",S(Ad,Pd))}}Uh(Xh,"ForEntityName","WIPEOUT");(Qt={})[Qt.ShowImage=1]="ShowImage",Qt[Qt.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Qt[Qt.UseClippingBoundary=4]="UseClippingBoundary",Qt[Qt.Transparency=8]="Transparency";function Yh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let Td=[{code:11,name:"direction",parser:_},{code:10,name:"position",parser:_},{code:100,name:"subclassMarker",parser:h},...z];class $h{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Yh(this,"parser",S(Td))}}Yh($h,"ForEntityName","XLINE");let Md=0;function qh(s){if(!s)throw TypeError("entity cannot be undefined or null");s.handle||(s.handle=Md++)}let vd=Object.fromEntries([Vo,ni,Xo,Zo,Qo,th,ri,sh,rh,lh,dh,ph,gh,_h,oi,xh,fh,$o,Sh,Ph,Mh,kh,Nh,Ch,Bh,zh,Dh,Wh,hi,Ho,Hh,oh,Yr,li,Xh,$h].map(s=>[s.ForEntityName,new s]));function Zh(s,t){let e=[];for(;!L(s,0,"EOF");){if(s.code===0){if(s.value==="ENDBLK"||s.value==="ENDSEC"){t.rewind();break}let i=vd[s.value];if(i){let r=s.value;s=t.next();let n=i.parseEntity(t,s);n.type=r,qh(n),e.push(n)}else t.debug}s=t.next()}return e}function _s(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}class Zn{next(){if(!this.hasNext())return this._eof?this.debug:this.debug,{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=Kn(t,this._data[this._pointer++],this.debug),i={code:t,value:e};return L(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 t={code:parseInt(this._data[this._pointer]),value:0};return t.value=Kn(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){_s(this,"_data",void 0),_s(this,"debug",void 0),_s(this,"_pointer",void 0),_s(this,"_eof",void 0),_s(this,"lastReadGroup",void 0),this._data=t,this.debug=e,this.lastReadGroup={code:0,value:0},this._pointer=0,this._eof=!1}}function Kn(s,t,e=!1){return s<=9?t:s>=10&&s<=59?parseFloat(t.trim()):s>=60&&s<=99?parseInt(t.trim()):s>=100&&s<=109?t:s>=110&&s<=149?parseFloat(t.trim()):s>=160&&s<=179?parseInt(t.trim()):s>=210&&s<=239?parseFloat(t.trim()):s>=270&&s<=289?parseInt(t.trim()):s>=290&&s<=299?function(i){if(i==="0")return!1;if(i==="1")return!0;throw TypeError("String '"+i+"' cannot be cast to Boolean type")}(t.trim()):s>=300&&s<=369?t:s>=370&&s<=389?parseInt(t.trim()):s>=390&&s<=399?t:s>=400&&s<=409?parseInt(t.trim()):s>=410&&s<=419?t:s>=420&&s<=429?parseInt(t.trim()):s>=430&&s<=439?t:s>=440&&s<=459?parseInt(t.trim()):s>=460&&s<=469?parseFloat(t.trim()):s>=470&&s<=481||s===999||s>=1e3&&s<=1009?t:s>=1010&&s<=1059?parseFloat(t.trim()):s>=1060&&s<=1071?parseInt(t.trim()):t}function kd(s,t){let e=null,i={};for(;!L(s,0,"EOF")&&!L(s,0,"ENDSEC");)s.code===9?e=s.value:s.code===10?i[e]=me(t):i[e]=s.value,s=t.next();return i}let oe=[{code:100,name:"subclassMarker",parser:h},{code:330,name:"ownerObjectId",parser:h},{code:102,isMultiple:!0,parser(s,t){for(;!L(s,0,"EOF")&&!L(s,102,"}");)s=t.next()}},{code:5,name:"handle",parser:h}],Ld=[{code:70,name:"flag",parser:h},{code:2,name:"appName",parser:h},{code:100,name:"subclassMarker",parser:h},...oe],Nd=S(Ld),Od=S([{code:310,name:"bmpPreview",parser:h},{code:281,name:"scalability",parser:h},{code:280,name:"explodability",parser:h},{code:70,name:"insertionUnits",parser:h},{code:340,name:"layoutObjects",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...oe]),Cd=S([...Xr.map(s=>({...s,parser:h})),{code:70,name:"standardFlag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},{code:105,name:"handle",parser:h},...oe.filter(s=>s.code!==5)]),Fd=S([{code:347,name:"materialObjectId",parser:h},{code:390,name:"plotStyleNameObjectId",parser:h},{code:370,name:"lineweight",parser:h},{code:290,name:"isPlotting",parser:v},{code:6,name:"lineType",parser:h},{code:62,name:"colorIndex",parser:h},{code:70,name:"standardFlag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...oe]),Bd=S([{code:9,name:"text",parser:h},{code:45,name:"offsetY",parser:h},{code:44,name:"offsetX",parser:h},{code:50,name:"rotation",parser:h},{code:46,name:"scale",parser:h},{code:340,name:"styleObjectId",parser:h},{code:75,name:"shapeNumber",parser:h},{code:74,name:"elementTypeFlag",parser:h},{code:49,name:"elementLength",parser:h}],{elementTypeFlag:0,elementLength:0}),Rd=S([{code:49,name:"pattern",parser(s,t){let e={};return Bd(s,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:h},{code:73,name:"numberOfLineTypes",parser:h},{code:72,parser:h},{code:3,name:"description",parser:h},{code:70,name:"standardFlag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...oe]),zd=S([{code:1e3,name:"extendedFont",parser:h},{code:1001},{code:4,name:"bigFont",parser:h},{code:3,name:"font",parser:h},{code:42,name:"lastHeight",parser:h},{code:71,name:"textGenerationFlag",parser:h},{code:50,name:"obliqueAngle",parser:h},{code:41,name:"widthFactor",parser:h},{code:40,name:"fixedTextHeight",parser:h},{code:70,name:"standardFlag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...oe]),Vd=[{code:13,name:"orthographicOrigin",parser:_},{code:71,name:"orthographicType",parser:h},{code:346,name:"baseUcsHandle",parser:h},{code:146,name:"elevation",parser:h},{code:79,name:"isOrthographic",parser:v},{code:12,name:"yAxis",parser:_},{code:11,name:"xAxis",parser:_},{code:10,name:"origin",parser:_},{code:70,name:"flag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...oe],Dd=S(Vd),jd=[{code:346,name:"baseUcsId",parser:h},{code:345,name:"ucsId",parser:h},{code:146,name:"elevation",parser:h},{code:79,name:"orthographicType",parser:h},{code:112,name:"ucsYAxis",parser:_},{code:111,name:"ucsXAxis",parser:_},{code:110,name:"ucsOrigin",parser:_},{code:361,name:"sunHardId",parser:h},{code:348,name:"styleHardId",parser:h},{code:334,name:"liveSectionSoftId",parser:h},{code:332,name:"backgroundSoftId",parser:h},{code:73,name:"isPlottable",parser:v},{code:72,name:"isUcsAssociated",parser:v},{code:281,name:"renderMode",parser:h},{code:71,name:"viewMode",parser:h},{code:50,name:"twistAngle",parser:h},{code:44,name:"backClippingPlane",parser:h},{code:43,name:"frontClippingPlane",parser:h},{code:42,name:"lensLength",parser:h},{code:12,name:"target",parser:_},{code:11,name:"direction",parser:_},{code:10,name:"center",parser:_},{code:41,name:"width",parser:h},{code:40,name:"height",parser:h},{code:70,name:"flag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...oe],Wd=S(jd),Gd=S([{code:[63,421,431],name:"ambientColor",parser:h},{code:142,name:"contrast",parser:h},{code:141,name:"brightness",parser:h},{code:282,name:"defaultLightingType",parser:h},{code:292,name:"isDefaultLightingOn",parser:v},{code:348,name:"visualStyleObjectId",parser:h},{code:333,name:"shadePlotObjectId",parser:h},{code:332,name:"backgroundObjectId",parser:h},{code:61,name:"majorGridLines",parser:h},{code:170,name:"shadePlotSetting",parser:h},{code:146,name:"elevation",parser:h},{code:79,name:"orthographicType",parser:h},{code:112,name:"ucsYAxis",parser:_},{code:111,name:"ucsXAxis",parser:_},{code:110,name:"ucsOrigin",parser:_},{code:74,name:"ucsIconSetting",parser:h},{code:71,name:"viewMode",parser:h},{code:281,name:"renderMode",parser:h},{code:1,name:"styleSheet",parser:h},{code:[331,441],name:"frozenLayers",parser:h,isMultiple:!0},{code:72,name:"circleSides",parser:h},{code:51,name:"viewTwistAngle",parser:h},{code:50,name:"snapRotationAngle",parser:h},{code:45,name:"viewHeight",parser:h},{code:44,name:"backClippingPlane",parser:h},{code:43,name:"frontClippingPlane",parser:h},{code:42,name:"lensLength",parser:h},{code:17,name:"viewTarget",parser:_},{code:16,name:"viewDirectionFromTarget",parser:_},{code:15,name:"gridSpacing",parser:_},{code:14,name:"snapSpacing",parser:_},{code:13,name:"snapBasePoint",parser:_},{code:12,name:"center",parser:_},{code:11,name:"upperRightCorner",parser:_},{code:10,name:"lowerLeftCorner",parser:_},{code:70,name:"standardFlag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...oe]),Hd={APPID:Nd,BLOCK_RECORD:Od,DIMSTYLE:Cd,LAYER:Fd,LTYPE:Rd,STYLE:zd,UCS:Dd,VIEW:Wd,VPORT:Gd},Ud=S([{code:70,name:"maxNumberOfEntries",parser:h},{code:100,name:"subclassMarker",parser:h},{code:330,name:"ownerObjectId",parser:h},{code:102,parser:zt},{code:102,parser:zt},{code:102,parser:zt},{code:360,isMultiple:!0},{code:5,name:"handle",parser:h},{code:2,name:"name",parser:h}]);function Xd(s,t){var i;let e={};for(;!L(s,0,"EOF")&&!L(s,0,"ENDSEC");){if(L(s,0,"TABLE")){s=t.next();let r={entries:[]};Ud(s,t,r),e[r.name]=r}if(L(s,0)&&!L(s,0,"ENDTAB")){let r=s.value;s=t.next();let n=Hd[r];if(!n){t.debug,s=t.next();continue}let a={};n(s,t,a),(i=e[r])==null||i.entries.push(a)}s=t.next()}return e}function Yd(s,t){let e={};for(;!L(s,0,"EOF")&&!L(s,0,"ENDSEC");){if(L(s,0,"BLOCK")){let i=$d(s=t.next(),t);qh(i),i.name&&(e[i.name]=i)}s=t.next()}return e}function $d(s,t){let e={};for(;!L(s,0,"EOF");){if(L(s,0,"ENDBLK")){for(s=t.next();!L(s,0,"EOF");){if(L(s,100,"AcDbBlockEnd"))return e;s=t.next()}break}switch(s.code){case 1:e.xrefPath=s.value;break;case 2:e.name=s.value;break;case 3:e.name2=s.value;break;case 5:e.handle=s.value;break;case 8:e.layer=s.value;break;case 10:e.position=me(t);break;case 67:e.paperSpace=!!s.value&&s.value==1;break;case 70:s.value!==0&&(e.type=s.value);break;case 100:break;case 330:e.ownerHandle=s.value;break;case 0:e.entities=Zh(s,t)}s=t.next()}return e}let $r=[{code:330,name:"ownerObjectId",parser:h},{code:102,parser:zt},{code:102,parser:zt},{code:102,parser:zt},{code:5,name:"handle",parser:h}],Kh=[{code:333,name:"shadePlotId",parser:h},{code:149,name:"imageOriginY",parser:h},{code:148,name:"imageOriginX",parser:h},{code:147,name:"scaleFactor",parser:h},{code:78,name:"shadePlotCustomDPI",parser:h},{code:77,name:"shadePlotResolution",parser:h},{code:76,name:"shadePlotMode",parser:h},{code:75,name:"standardScaleType",parser:h},{code:7,name:"currentStyleSheet",parser:h},{code:74,name:"plotType",parser:h},{code:73,name:"plotRotation",parser:h},{code:72,name:"plotPaperUnit",parser:h},{code:70,name:"layoutFlag",parser:h},{code:143,name:"printScaleDenominator",parser:h},{code:142,name:"printScaleNumerator",parser:h},{code:141,name:"windowAreaYMax",parser:h},{code:140,name:"windowAreaXMax",parser:h},{code:49,name:"windowAreaYMin",parser:h},{code:48,name:"windowAreaXMin",parser:h},{code:47,name:"plotOriginY",parser:h},{code:46,name:"plotOriginX",parser:h},{code:45,name:"paperHeight",parser:h},{code:44,name:"paperWidth",parser:h},{code:43,name:"marginTop",parser:h},{code:42,name:"marginRight",parser:h},{code:41,name:"marginBottom",parser:h},{code:40,name:"marginLeft",parser:h},{code:6,name:"plotViewName",parser:h},{code:4,name:"paperSize",parser:h},{code:2,name:"configName",parser:h},{code:1,name:"pageSetupName",parser:h},{code:100,name:"subclassMarker",parser:h},...$r],qd=[{code:346,name:"orthographicUcsId",parser:h},{code:345,name:"namedUcsId",parser:h},{code:331,name:"viewportId",parser:h},{code:330,name:"paperSpaceTableId",parser:h},{code:76,name:"orthographicType",parser:h},{code:17,name:"ucsYAxis",parser:_},{code:16,name:"ucsXAxis",parser:_},{code:13,name:"ucsOrigin",parser:_},{code:146,name:"elevation",parser:h},{code:15,name:"maxExtent",parser:_},{code:14,name:"minExtent",parser:_},{code:12,name:"insertionPoint",parser:_},{code:11,name:"maxLimit",parser:_},{code:10,name:"minLimit",parser:_},{code:71,name:"tabOrder",parser:h},{code:70,name:"controlFlag",parser:h},{code:1,name:"layoutName",parser:h},{code:100,name:"subclassMarker",parser:h},...Kh],Zd=[{code:3,name:"entries",parser:(s,t)=>{let e={name:s.value};return(s=t.next()).code===350?e.objectSoftId=s.value:s.code===360?e.objectHardId=s.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:h},{code:280,name:"isHardOwned",parser:v},{code:100,name:"subclassMarker",parser:h},...$r],Kd=[{code:40,name:"wcsToOCSTransform",parser:Qn},{code:40,name:"ocsToWCSTransform",parser:Qn},{code:41,name:"backClippingDistance",parser:h},{code:73,name:"isBackClipping",parser:v,pushContext:!0},{code:40,name:"frontClippingDistance",parser:h},{code:72,name:"isFrontClipping",parser:v,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:v},{code:11,name:"position",parser:_},{code:210,name:"normal",parser:_},{code:10,name:"boundaryVertices",parser:_,isMultiple:!0},{code:70,name:"boundaryCount",parser:h},{code:100,name:"subclassMarker",parser:h},{code:100},...$r];function Qn(s,t){let e=[];for(let i=0;i<3&&L(s,40);++i){let r=[];for(let n=0;n<4&&L(s,40);++n)r.push(s.value),s=t.next();e.push(r)}return t.rewind(),e}let Qd=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:h},{code:90,name:"version",parser:h},{code:1,name:"fileName",parser:h},{code:10,name:"size",parser:_},{code:11,name:"sizeOfOnePixel",parser:_},{code:280,name:"isLoaded",parser:h},{code:281,name:"resolutionUnits",parser:h},{code:100,name:"subclassMarker",parser:h}],Jd={LAYOUT:qd,PLOTSETTINGS:Kh,DICTIONARY:Zd,SPATIAL_FILTER:Kd,IMAGEDEF:Qd};function tu(s,t){let e=[];for(;s.code!==0||!["EOF","ENDSEC"].includes(s.value);){let i=s.value,r=Jd[i];if(s.code===0&&(r!=null&&r.length)){let n=S(r),a={name:i};n(s=t.next(),t,a)?(e.push(a),s=t.peek()):s=t.next()}else s=t.next()}return{byName:gc(e,({name:i})=>i)}}function Ts(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}class eu{constructor(){Ts(this,"encoding","utf-8"),Ts(this,"encodingFailureFatal",!1),Ts(this,"thumbnailImageFormat","base64")}}class su extends EventTarget{parseSync(t,e=!1){let i=new Zn(t.split(/\r\n|\r|\n/g),e);if(!i.hasNext())throw Error("Empty file");return this.parseAll(i)}parseStream(t){let e="",i=this;return new Promise((r,n)=>{t.on("data",a=>{e+=a}),t.on("end",()=>{try{let a=e.split(/\r\n|\r|\n/g),o=new Zn(a);if(!o.hasNext())throw Error("Empty file");r(i.parseAll(o))}catch(a){n(a)}}),t.on("error",a=>{n(a)})})}async parseFromUrl(t,e){let i=await fetch(t,e);if(!i.body)return null;let r=i.body.getReader(),n="";for(;;){let{done:a,value:o}=await r.read();if(a){n+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}n+=this._decoder.decode(o,{stream:!0})}return this.parseSync(n)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},i=t.next();for(;!L(i,0,"EOF");)L(i,0,"SECTION")&&(L(i=t.next(),2,"HEADER")?e.header=kd(i=t.next(),t):L(i,2,"CLASSES")?tc(i=t.next(),t,e):L(i,2,"BLOCKS")?e.blocks=Yd(i=t.next(),t):L(i,2,"ENTITIES")?e.entities=Zh(i=t.next(),t):L(i,2,"TABLES")?e.tables=Xd(i=t.next(),t):L(i,2,"OBJECTS")?e.objects=tu(i=t.next(),t):L(i,2,"THUMBNAILIMAGE")&&(e.thumbnailImage=function(r,n,a="base64"){let o,l="",c=0;for(;!L(r,0,"EOF")&&!L(r,0,"ENDSEC");)r.code===90?c=r.value:r.code===310&&(l+=r.value),r=n.next();if(a==="hex")o=l;else{let d=function(u){let m=u.length/2,p=new Uint8Array(m);for(let g=0;g<m;g++)p[g]=parseInt(u.substr(2*g,2),16);return p}(l);o=a==="buffer"?d:function(u){let m="";for(let p=0;p<u.length;p++)m+=String.fromCharCode(u[p]);return btoa(m)}(d)}return{size:c,data:o}}(i=t.next(),t,this._options.thumbnailImageFormat))),i=t.next();return e}constructor(t={}){super(),Ts(this,"_decoder",void 0),Ts(this,"_options",void 0);let e=new eu;this._options=Object.assign(e,t),this._decoder=new TextDecoder(this._options.encoding,{fatal:this._options.encodingFailureFatal})}}(ft={})[ft.NOT_APPLICABLE=0]="NOT_APPLICABLE",ft[ft.KEEP_EXISTING=1]="KEEP_EXISTING",ft[ft.USE_CLONE=2]="USE_CLONE",ft[ft.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",ft[ft.VALUE_NAME=4]="VALUE_NAME",ft[ft.UNMANGLE_NAME=5]="UNMANGLE_NAME";(Oe={})[Oe.NOUNIT=0]="NOUNIT",Oe[Oe.CENTIMETERS=2]="CENTIMETERS",Oe[Oe.INCH=5]="INCH";(ys={})[ys.PSLTSCALE=1]="PSLTSCALE",ys[ys.LIMCHECK=2]="LIMCHECK";(Ce={})[Ce.INCHES=0]="INCHES",Ce[Ce.MILLIMETERS=1]="MILLIMETERS",Ce[Ce.PIXELS=2]="PIXELS";(It={})[It.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",It[It.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",It[It.DRAWING_LIMITS=2]="DRAWING_LIMITS",It[It.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",It[It.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",It[It.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(Jt={})[Jt.AS_DISPLAYED=0]="AS_DISPLAYED",Jt[Jt.WIREFRAME=1]="WIREFRAME",Jt[Jt.HIDDEN=2]="HIDDEN",Jt[Jt.RENDERED=3]="RENDERED";(St={})[St.DRAFT=0]="DRAFT",St[St.PREVIEW=1]="PREVIEW",St[St.NORMAL=2]="NORMAL",St[St.PRESENTATION=3]="PRESENTATION",St[St.MAXIMUM=4]="MAXIMUM",St[St.CUSTOM=5]="CUSTOM";(te={})[te.NONE=0]="NONE",te[te.AbsoluteRotation=1]="AbsoluteRotation",te[te.TextEmbedded=2]="TextEmbedded",te[te.ShapeEmbedded=4]="ShapeEmbedded";(rr={})[rr.PaperSpace=1]="PaperSpace";(Fe={})[Fe.XrefDependent=16]="XrefDependent",Fe[Fe.XrefResolved=32]="XrefResolved",Fe[Fe.Referenced=64]="Referenced";(Et={})[Et.Off=0]="Off",Et[Et.Perspective=1]="Perspective",Et[Et.ClipFront=2]="ClipFront",Et[Et.ClipBack=4]="ClipBack",Et[Et.UcsFollow=8]="UcsFollow",Et[Et.ClipFrontByFrontZ=16]="ClipFrontByFrontZ";class iu{parse(t){const e=new su,i=this.getDxfInfoFromBuffer(t);let r="";return i.version&&i.version.value<=23&&i.encoding?r=new TextDecoder(i.encoding).decode(t):r=new TextDecoder().decode(t),e.parseSync(r)}getDxfInfoFromBuffer(t){var c,d,u;const i=new TextDecoder("utf-8");let r=0,n="",a=null,o=null,l=!1;for(;r<t.byteLength;){const m=Math.min(r+65536,t.byteLength),p=t.slice(r,m);r=m;const y=(n+i.decode(p,{stream:!0})).split(/\r?\n/);n=y.pop()??"";for(let x=0;x<y.length;x++){const w=y[x].trim();if(w==="SECTION"&&((c=y[x+2])==null?void 0:c.trim())==="HEADER")l=!0;else if(w==="ENDSEC"&&l)return{version:a,encoding:o};if(l&&w==="$ACADVER"){const P=(d=y[x+2])==null?void 0:d.trim();P&&(a=new At(P))}else if(l&&w==="$DWGCODEPAGE"){const P=(u=y[x+2])==null?void 0:u.trim();if(P){const I=Pr[P];o=ga(I)}}if(a&&o)return{version:a,encoding:o}}}return{version:a,encoding:o}}}class Jn{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=="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 xi;return t.vertices.forEach((i,r)=>e.setVertexAt(r,i)),e}convertArc(t){return new mi(t.center,t.radius,N.degToRad(t.startAngle),N.degToRad(t.endAngle),t.extrusionDirection??f.Z_AXIS)}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&Q.Invisible)!==0,e.isConst=(t.attributeFlag&Q.Const)!==0,e.isVerifiable=(t.attributeFlag&Q.Verifiable)!==0,e.isPreset=(t.attributeFlag&Q.Preset)!==0,e.isReallyLocked=!!t.isReallyLocked,e.isMTextAttribute=(t.mtextFlag&Bt.MultiLine)!==0,e.isConstMTextAttribute=(t.mtextFlag&Bt.ConstMultiLine)!==0}convertAttribute(t){const e=new yi;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 gi;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){return new _i(t.center,t.radius,t.extrusionDirection??f.Z_AXIS)}convertEllipse(t){const e=new f(t.majorAxisEndPoint),i=e.length();return new wi(t.center,t.extrusionDirection??f.Z_AXIS,e,i,i*t.axisRatio,t.startAngle,t.endAngle)}convertLine(t){const e=t.startPoint,i=t.endPoint;return new Ns(new b(e.x,e.y,e.z||0),new b(i.x,i.y,i.z||0))}convertSpline(t){try{if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new Cs(t.controlPoints,t.knots,t.weights,t.degree,!!(t.flag&1));if(t.numberOfFitPoints>0)return new Cs(t.fitPoints,"Uniform",t.degree,!!(t.flag&1))}catch{}return null}convertPoint(t){const e=new Ei;return e.position=t.position,e}convertSolid(t){const e=new Ii;return t.points.forEach((i,r)=>e.setPointAt(r,i)),e.thickness=t.thickness,e}convertPolyline(t){const e=!!(t.flag&1),i=!!(t.flag&8),r=!!(t.flag&16),n=!!(t.flag&64),a=!!(t.flag&32),o=[],l=[],c=[];if(t.vertices.map(d=>{d.flag&Sd.SPLINE_CONTROL_POINT||(n&&d.flag&128?d.flag&64?(o.push({x:d.x,y:d.y,z:d.z}),l.push(d.bulge??0)):d.faces&&d.faces.length>=3&&c.push([...d.faces]):(o.push({x:d.x,y:d.y,z:d.z}),l.push(d.bulge??0)))}),r){const d=t.meshMVertexCount,u=t.meshNVertexCount;return new vi(d,u,o,e,a)}else{if(n)return new ki(o,c);if(i){let d=Es.SimplePoly;return t.flag&4&&(t.smoothType==ei.CUBIC?d=Es.CubicSplinePoly:t.smoothType==ei.QUADRATIC&&(d=Es.QuadSplinePoly)),new pi(d,o,e)}else{let d=Xe.SimplePoly;return t.flag&2?d=Xe.FitCurvePoly:t.flag&4&&(t.smoothType==ei.CUBIC?d=Xe.CubicSplinePoly:t.smoothType==ei.QUADRATIC&&(d=Xe.QuadSplinePoly)),new ui(d,o,0,e,t.startWidth,t.endWidth,l)}}}convertLWPolyline(t){const e=new Si;return e.closed=!!(t.flag&1),t.vertices.forEach((i,r)=>{e.addVertexAt(r,new O(i.x,i.y),i.bulge,i.startWidth,i.endWidth)}),e}convertHatch(t){var r;const e=new Ls;return(r=t.definitionLines)==null||r.forEach(n=>{e.definitionLines.push({angle:n.angle,base:n.base,offset:n.offset,dashLengths:n.numberOfDashLengths>0?n.dashLengths:[]})}),e.isSolidFill=t.solidFill==Xl.SolidFill,e.hatchStyle=t.hatchStyle,e.patternName=t.patternName,e.patternType=t.patternType,e.patternAngle=t.patternAngle==null?0:t.patternAngle,e.patternScale=t.patternScale==null?0:t.patternScale,t.boundaryPaths.forEach(n=>{if(n.boundaryPathTypeFlag&2){const o=n,l=new ge;l.closed=o.isClosed,o.vertices.forEach((c,d)=>{l.addVertexAt(d,{x:c.x,y:c.y,bulge:c.bulge})}),e.add(l)}else{const o=n,l=[];o.edges.forEach(d=>{if(d.type==1){const u=d;l.push(new Rt(u.start,u.end))}else if(d.type==2){const u=d;l.push(new Ve(u.center,u.radius,N.degToRad(u.startAngle||0),N.degToRad(u.endAngle||0),!u.isCCW))}else if(d.type==3){const u=d;new U().subVectors(u.end,u.center);const p=Math.sqrt(Math.pow(u.end.x,2)+Math.pow(u.end.y,2)),g=p*u.lengthOfMinorAxis;let y=N.degToRad(u.startAngle||0),x=N.degToRad(u.endAngle||0);const w=Math.atan2(u.end.y,u.end.x);u.isCCW||(y=Math.PI*2-y,x=Math.PI*2-x),l.push(new De({...u.center,z:0},p,g,y,x,!u.isCCW,w))}else if(d.type==4){const u=d;if(u.numberOfControlPoints>0&&u.numberOfKnots>0){const m=u.controlPoints.map(y=>({x:y.x,y:y.y,z:0}));let p=!0;const g=u.controlPoints.map(y=>(y.weight==null&&(p=!1),y.weight||1));l.push(new Lt(m,u.knots,p?g:void 0))}else if(u.numberOfFitData>0){const m=u.fitDatum.map(p=>({x:p.x,y:p.y,z:0}));l.push(new Lt(m,"Uniform"))}}});const c=ks.buildFromEdges(l);c.length==0&&l.length>0?e.add(new ks(l)):c.forEach(d=>e.add(d))}}),e}convertTable(t){const e=new fi(t.name,t.rowCount,t.columnCount);return e.tableDataVersion=t.version,e.tableStyleId=t.tableStyleId,e.owningBlockRecordId=t.blockRecordHandle,t.directionVector&&(e.horizontalDirection=new f(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((i,r)=>e.setColumnWidth(r,i)),t.rowHeightArr.forEach((i,r)=>e.setRowHeight(r,i)),t.cells.forEach((i,r)=>{e.setCell(r,i)}),e}convertText(t){const e=new Ke;return e.textString=t.text,e.styleName=t.styleName,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=N.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 Os;return e.contents=t.text,t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=N.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new f(t.direction)),e.drawingDirection=t.drawingDirection,e}convertLeader(t){const e=new bi;return t.vertices.forEach(i=>{e.appendVertex(i)}),e.hasArrowHead=t.isArrowheadEnabled,e.hasHookLine=t.isHooklineExists,e.isSplined=t.isSpline,e.dimensionStyle=t.styleName,e.annoType=t.leaderCreationFlag,e}convertDimension(t){if(t.subclassMarker=="AcDbAlignedDimension"||t.subclassMarker=="AcDbRotatedDimension"){const e=t,i=new Ni(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return e.insertionPoint&&(i.dimBlockPosition={...e.insertionPoint,z:0}),i.rotation=N.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,i),i}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,i=new Li(e.centerPoint,e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return this.processDimensionCommonAttrs(t,i),i}else if(t.subclassMarker=="AcDbOrdinateDimension"){const e=t,i=new Ci(e.subDefinitionPoint1,e.subDefinitionPoint2);return this.processDimensionCommonAttrs(t,i),i}else if(t.subclassMarker=="AcDbRadialDimension"){const e=t,i=new Fi(e.definitionPoint,e.subDefinitionPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,i),i}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,i=new Oi(e.definitionPoint,e.subDefinitionPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,i),i}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(i=>{e.clipBoundary.push(new O(i))}),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 Fs;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(i=>{e.clipBoundary.push(new O(i))}),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 Ti;return this.processWipeout(t,e),e}convertViewport(t){const e=new Ai;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 Pi;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertXline(t){const e=new Mi;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertBlockReference(t){const e=new Qe(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?N.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=Di.deserialize(t.transparency))}}class ru{convertLayout(t,e){var n,a;const i=new Ds;i.layoutName=t.layoutName,i.tabOrder=t.tabOrder,i.plotSettingsName=t.pageSetupName,i.plotCfgName=t.configName,i.canonicalMediaName=t.paperSize,i.plotViewName=t.plotViewName,i.currentStyleSheet=t.currentStyleSheet,i.plotPaperMargins={left:t.marginLeft,right:t.marginRight,top:t.marginTop,bottom:t.marginBottom},i.plotPaperSize.copy({x:t.paperWidth,y:t.paperHeight}),i.plotOrigin.copy({x:t.plotOriginX,y:t.plotOriginY}),i.plotWindowArea.min.copy({x:t.windowAreaXMin,y:t.windowAreaYMin}),i.plotWindowArea.max.copy({x:t.windowAreaXMax,y:t.windowAreaYMax}),i.customPrintScale={numerator:t.printScaleNumerator,denominator:t.printScaleDenominator},i.plotPaperUnits=t.plotPaperUnit,i.plotRotation=t.plotRotation,i.plotType=t.plotType,i.stdScaleType=t.standardScaleType,i.shadePlot=(()=>{switch(t.shadePlotMode){case 1:return Ye.kWireframe;case 2:return Ye.kHidden;case 3:return Ye.kRendered;default:return Ye.kAsDisplayed}})(),i.shadePlotResLevel=(()=>{switch(t.shadePlotResolution){case 1:return ce.kPreview;case 2:return ce.kNormal;case 3:return ce.kPresentation;case 4:return ce.kMaximum;case 5:return ce.kCustom;default:return ce.kDraft}})(),t.shadePlotCustomDPI!=null&&(i.shadePlotCustomDPI=t.shadePlotCustomDPI),t.shadePlotId&&(i.shadePlotId=t.shadePlotId);const r=t.layoutFlag??0;if(i.plotViewportBorders=(r&1)!==0,i.showPlotStyles=(r&2)!==0,i.plotCentered=(r&4)!==0,i.plotHidden=(r&8)!==0,i.useStandardScale=(r&16)!==0,i.plotPlotStyles=(r&32)!==0,i.scaleLineweights=(r&64)!==0,i.printLineweights=(r&128)!==0,i.drawViewportsFirst=(r&512)!==0,i.modelType=(r&1024)!==0,t.viewportId&&i.viewportArray.push(t.viewportId),t.layoutName==="Model"){const o=K.MODEL_SPACE_NAME.toUpperCase();(n=e.tables.BLOCK_RECORD)==null||n.entries.some(l=>l.name.toUpperCase()===o?(i.blockTableRecordId=l.handle,!0):!1)}else(a=e.tables.BLOCK_RECORD)==null||a.entries.some(o=>o.layoutObjects===t.handle?(i.blockTableRecordId=o.handle,!0):!1),i.blockTableRecordId||(i.blockTableRecordId=t.paperSpaceTableId);return t.minLimit&&i.limits.min.copy(t.minLimit),t.maxLimit&&i.limits.max.copy(t.maxLimit),t.minExtent&&i.extents.min.copy(t.minExtent),t.maxExtent&&i.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,i),i}convertImageDef(t){const e=new xo;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class Qh{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 i=Date.now(),r=this.generateTaskId();try{return await this.executeInWorker(r,t,e||this.config.workerUrl)}catch(n){const a=Date.now()-i;return{success:!1,error:n instanceof Error?n.message:String(n),duration:a}}}async executeInWorker(t,e,i){const r=Date.now();return new Promise((n,a)=>{const o=this.getAvailableWorker(i),l=setTimeout(()=>{this.cleanupTask(t),this.releaseWorker(o),a(new Error(`Worker operation timed out after ${this.config.timeout}ms`))},this.config.timeout);this.pendingTasks.set(t,{resolve:u=>{clearTimeout(l),this.releaseWorker(o),n(u)},reject:u=>{clearTimeout(l),this.releaseWorker(o),a(u)},timeout:l});const c=u=>{const{id:m,success:p,data:g,error:y}=u.data;if(m!==t)return;this.cleanupTask(t);const x=Date.now()-r;n(p?{success:!0,data:g,duration:x}:{success:!1,error:y,duration:x})},d=u=>{this.cleanupTask(t),a(new Error(`Worker error: ${u.message}`))};o.addEventListener("message",c),o.addEventListener("error",d),o.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[i,r]of this.workers)if(!r.isBusy)return r.isBusy=!0,r.worker;if(this.workers.size<this.config.maxConcurrentWorkers){const i=new Worker(t,{type:"module"}),r=this.generateWorkerId(),n={worker:i,isBusy:!0,id:r,createdAt:new Date};return this.workers.set(r,n),i}const e=Array.from(this.workers.values()).sort((i,r)=>i.createdAt.getTime()-r.createdAt.getTime())[0];return e.isBusy=!0,e.worker}releaseWorker(t){for(const[e,i]of this.workers)if(i.worker===t){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(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 Jh{constructor(t){this.framework=new Qh(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function tl(s){return new Jh(s)}class nu{constructor(){this.setupMessageHandler()}setupMessageHandler(){self.onmessage=async t=>{const{id:e,input:i}=t.data;try{const r=await this.executeTask(i);this.sendResponse(e,!0,r)}catch(r){this.sendResponse(e,!1,void 0,r instanceof Error?r.message:String(r))}}}sendResponse(t,e,i,r){const n={id:t,success:e,data:i,error:r};self.postMessage(n)}}class el extends Ur{constructor(t={}){super(t),t.parserWorkerUrl||(t.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(t,e){const i=this.config,r=this.getParserWorkerTimeout(t,e);if(i.useWorker&&i.parserWorkerUrl){const n=tl({workerUrl:i.parserWorkerUrl,timeout:r,maxConcurrentWorkers:1}),a=await n.execute(t);if(n.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 iu().parse(t),data:{unknownEntityCount:0}}}getFonts(t){var n;const e=new Map,i=a=>{if(a){const o=a.lastIndexOf(".");return o>=0?a.substring(0,o).toLowerCase():a.toLowerCase()}};(n=t.tables.STYLE)==null||n.entries.forEach(a=>{const o=[];if(a.font){const l=i(a.font);l&&o.push(l)}if(a.bigFont){const l=i(a.bigFont);l&&o.push(l)}if(a.extendedFont){const l=i(a.extendedFont);l&&o.push(l)}e.set(a.name,o)});const r=new Set;return this.getFontsInBlock(t.entities,t.blocks,e,r),Array.from(r)}getFontsInBlock(t,e,i,r){const n=/\\f(.*?)\|/g;t.forEach(a=>{if(a.type=="MTEXT"){const o=a;[...o.text.matchAll(n)].forEach(d=>{r.add(d[1].toLowerCase())});const c=i.get(o.styleName);c==null||c.forEach(d=>r.add(d))}else if(a.type=="TEXT"){const o=a,l=i.get(o.styleName);l==null||l.forEach(c=>r.add(c))}else if(a.type=="INSERT"){const l=e[a.name];l&&l.entities&&this.getFontsInBlock(l.entities,e,i,r)}})}async processEntities(t,e,i,r,n){const a=new Jn;let o=t.entities;const l=o.length,c=new Sr(l,100-r.value,i);this.config.convertByEntityType&&(o=this.groupAndFlattenByType(o));const d=new Map;for(let m=0;m<l;m++){const p=o[m];if(p.type==="ATTRIB"){const g=a.convert(p);if(g&&g.ownerId&&g.ownerId!=="0"){let y=d.get(g==null?void 0:g.ownerId);y==null&&(y=[],d.set(g.ownerId,y)),y.push(g)}}}const u=e.tables.blockTable.modelSpace;await c.processChunk(async(m,p)=>{let g=[],y=m<p?o[m].type:"";for(let w=m;w<p;w++){const P=o[w];if(!(P.ownerBlockRecordSoftId&&P.ownerBlockRecordSoftId!==u.objectId)&&P.type!=="ATTRIB"){const I=a.convert(P);if(I){if(this.config.convertByEntityType&&P.type!==y&&(u.appendEntity(g),g=[],y=P.type),P.type==="INSERT"){const k=d.get(I.objectId);k&&k.length>0&&k.forEach(A=>{I.appendAttributes(A)})}g.push(I)}}}u.appendEntity(g);let x=r.value+p/l*(100-r.value);x>100&&(x=100),n&&await n(x,"ENTITY","IN-PROGRESS")})}async processEntitiesInBlock(t,e,i=!1){const r=new Jn,n=t.length,a=[],o=e.objectId,l=[];for(let c=0;c<n;c++){const d=t[c],u=r.convert(d);u&&(d.type==="ATTRIB"?l.push(u):(!i||d.ownerBlockRecordSoftId===o)&&a.push(u))}l.forEach(c=>{const d=e.getIdAt(c.ownerId);d&&d.appendAttributes(c)}),e.appendEntity(a)}processBlocks(t,e){const i=t.blocks;for(const[r,n]of Object.entries(i)){let a=e.tables.blockTable.getAt(n.name);a||(a=new K,a.objectId=n.handle,a.name=r,a.origin.copy(n.position),e.tables.blockTable.add(a)),n.entities?this.processEntitiesInBlock(n.entities,a):a.isPaperSapce&&this.processEntitiesInBlock(t.entities,a,!0)}}processHeader(t,e){const i=t.header;i.$ACADVER&&(e.version=i.$ACADVER),e.cecolor.colorIndex=i.$CECOLOR||256,e.angBase=i.$ANGBASE||0,e.angDir=i.$ANGDIR||0,i.$AUNITS!=null&&(e.aunits=i.$AUNITS),e.celtscale=i.$CELTSCALE||1,e.ltscale=i.$LTSCALE||1,i.$EXTMAX&&(e.extmax=i.$EXTMAX),i.$EXTMIN&&(e.extmin=i.$EXTMIN),i.$INSUNITS!=null&&(e.insunits=i.$INSUNITS),e.osmode=i.$OSMODE||0,e.pdmode=i.$PDMODE||0,e.pdsize=i.$PDSIZE||0,e.textstyle=i.$TEXTSTYLE||Y}processBlockTables(t,e){var r;const i=(r=t.tables.BLOCK_RECORD)==null?void 0:r.entries;i&&i.length>0&&(e.tables.blockTable.removeAll(),i.forEach(n=>{const a=new K;a.objectId=n.handle,a.name=n.name,a.layoutId=n.layoutObjects,a.blockInsertUnits=n.insertionUnits,a.explodability=n.explodability,a.blockScaling=n.scalability,n.bmpPreview&&(a.bmpPreview=n.bmpPreview),e.tables.blockTable.add(a)}))}processObjects(t,e){const i=t.objects.byName,r=new ru;if("LAYOUT"in i){const n=e.objects.layout;i.LAYOUT.forEach(a=>{const o=r.convertLayout(a,t);n.setAt(o.layoutName,o)})}if("IMAGEDEF"in i){const n=e.objects.imageDefinition;i.IMAGEDEF.forEach(a=>{const o=r.convertImageDef(a);n.setAt(o.objectId,o)})}}processViewports(t,e){var r;const i=(r=t.tables)==null?void 0:r.VPORT;if(i){this.processCommonTableAttrs(i,e.tables.viewportTable);const n=i.entries;n&&n.length>0&&n.forEach(a=>{const o=new Hr;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),e.tables.viewportTable.add(o)})}}processLayers(t,e){var r;const i=(r=t.tables)==null?void 0:r.LAYER;if(i){this.processCommonTableAttrs(i,e.tables.layerTable);const n=i.entries;n&&n.length>0&&n.forEach(a=>{const o=new J;o.colorIndex=a.colorIndex;const l=new Gi({name:a.name,standardFlags:a.standardFlag,linetype:a.lineType,lineWeight:a.lineweight,isOff:a.colorIndex<0,color:o,isPlottable:a.isPlotting});this.processCommonTableEntryAttrs(a,l),e.tables.layerTable.add(l)})}}processLineTypes(t,e){var r;const i=(r=t.tables)==null?void 0:r.LTYPE;if(i){this.processCommonTableAttrs(i,e.tables.linetypeTable);const n=i.entries;n&&n.length>0&&n.forEach(a=>{const o=new ue(a);this.processCommonTableEntryAttrs(a,o),o.name=a.name,e.tables.linetypeTable.add(o)})}}processTextStyles(t,e){var r;const i=(r=t.tables)==null?void 0:r.STYLE;if(i){this.processCommonTableAttrs(i,e.tables.textStyleTable);const n=i.entries;n&&n.length>0&&n.forEach(a=>{const o=new Hi(a);this.processCommonTableEntryAttrs(a,o),e.tables.textStyleTable.add(o)})}}processDimStyles(t,e){var r;const i=(r=t.tables)==null?void 0:r.DIMSTYLE;if(i){this.processCommonTableAttrs(i,e.tables.dimStyleTable);const n=i.entries;n&&n.length>0&&n.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||Y,dimldrblk:a.DIMLDRBLK||"",dimblk:a.DIMBLK||"",dimblk1:a.DIMBLK1||"",dimblk2:a.DIMBLK2||"",dimlwd:a.DIMLWD,dimlwe:a.DIMLWE},l=new We(o);this.processCommonTableEntryAttrs(a,l),e.tables.dimStyleTable.add(l)})}}processCommonTableAttrs(t,e){t.handle!=null&&(e.objectId=t.handle),e.ownerId=t.ownerObjectId}processCommonTableEntryAttrs(t,e){e.name="name"in t?t.name:"",t.handle!=null&&(e.objectId=t.handle),e.ownerId=t.ownerObjectId}groupAndFlattenByType(t){const e={},i=[];for(const r of t)e[r.type]||(e[r.type]=[],i.push(r.type)),e[r.type].push(r);return i.flatMap(r=>e[r])}}class sl extends Ur{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}getFonts(){return[]}async processEntities(t,e,i,r,n){let a=t.tables.blockTable.modelSpace.newIterator().toArray();const o=a.length,l=new Sr(o,100-r.value,i);this.config.convertByEntityType&&(a=this.groupAndFlattenByType(a));const c=e.tables.blockTable.modelSpace;await l.processChunk(async(d,u)=>{let m=[],p=d<u?a[d].type:"";for(let g=d;g<u;g++){const y=a[g];this.config.convertByEntityType&&y.type!==p&&(this.triggerEvents(c,m),m=[],p=y.type),m.push(y)}if(this.triggerEvents(c,m),n){let g=r.value+u/o*(100-r.value);g>100&&(g=100),await n(g,"ENTITY","IN-PROGRESS")}})}processBlocks(){const t=this._database.tables.blockTable.newIterator();for(const e of t){const i=e.newIterator().toArray();this.triggerEvents(e,i)}}processHeader(){}processBlockTables(){}processObjects(){const t=this._database.objects.layout.newIterator();for(const i of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:i,key:i.layoutName});const e=this._database.objects.imageDefinition.newIterator();for(const i of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:i,key:i.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={},i=[];for(const r of t)e[r.type]||(e[r.type]=[],i.push(r.type)),e[r.type].push(r);return i.flatMap(r=>e[r])}triggerEvents(t,e){(t.isModelSapce||t.isPaperSapce)&&t.database.events.entityAppended.dispatch({database:t.database,entity:e})}}exports.ACAD_APPID=cr;exports.AC_DB_SYSTEM_VARIABLE_NAMES=zl;exports.AcCmColor=J;exports.AcCmColorMethod=E;exports.AcCmColorUtil=le;exports.AcCmEntityColor=rl;exports.AcCmErrors=gt;exports.AcCmEventDispatcher=nl;exports.AcCmEventManager=Z;exports.AcCmLoader=pl;exports.AcCmLoadingManager=la;exports.AcCmObject=na;exports.AcCmPerformanceCollector=br;exports.AcCmTask=oa;exports.AcCmTaskScheduler=ha;exports.AcCmTransparency=Di;exports.AcCmTransparencyMethod=dt;exports.AcDb2dPolyline=ui;exports.AcDb2dVertex=gr;exports.AcDb2dVertexType=Qa;exports.AcDb3PointAngularDimension=Li;exports.AcDb3dPolyline=pi;exports.AcDb3dVertex=yr;exports.AcDb3dVertexType=Ja;exports.AcDbAbstractViewTableRecord=Gr;exports.AcDbAlignedDimension=Ni;exports.AcDbAngleUnits=Er;exports.AcDbArc=mi;exports.AcDbArcDimension=_r;exports.AcDbAttribute=yi;exports.AcDbAttributeDefinition=gi;exports.AcDbAttributeFlags=Q;exports.AcDbAttributeMTextFlag=Bt;exports.AcDbBaseWorker=nu;exports.AcDbBatchProcessing=Sr;exports.AcDbBlockReference=Qe;exports.AcDbBlockScaling=_o;exports.AcDbBlockTable=So;exports.AcDbBlockTableRecord=K;exports.AcDbCircle=_i;exports.AcDbCodePage=Pr;exports.AcDbCurve=rt;exports.AcDbDataGenerator=fo;exports.AcDbDatabase=Vl;exports.AcDbDatabaseConverter=Ur;exports.AcDbDatabaseConverterManager=Ft;exports.AcDbDiametricDimension=Oi;exports.AcDbDictionary=As;exports.AcDbDimArrowType=Io;exports.AcDbDimStyleTable=Eo;exports.AcDbDimStyleTableRecord=We;exports.AcDbDimTextHorizontal=Po;exports.AcDbDimTextVertical=Ao;exports.AcDbDimVerticalJustification=vo;exports.AcDbDimZeroSuppression=To;exports.AcDbDimZeroSuppressionAngular=Mo;exports.AcDbDimension=re;exports.AcDbDuplicateRecordCloning=bo;exports.AcDbDwgVersion=At;exports.AcDbDxfCode=xr;exports.AcDbDxfConverter=el;exports.AcDbDxfFiler=ta;exports.AcDbEllipse=wi;exports.AcDbEntity=pt;exports.AcDbFace=xi;exports.AcDbFileType=fs;exports.AcDbHatch=Ls;exports.AcDbHatchPatternType=Ps;exports.AcDbHatchStyle=so;exports.AcDbHostApplicationServices=ci;exports.AcDbLayerTable=ko;exports.AcDbLayerTableRecord=Gi;exports.AcDbLayout=Ds;exports.AcDbLayoutDictionary=yo;exports.AcDbLayoutManager=wo;exports.AcDbLeader=bi;exports.AcDbLeaderAnnotationType=io;exports.AcDbLine=Ns;exports.AcDbLineSpacingStyle=lo;exports.AcDbLinetypeTable=Lo;exports.AcDbLinetypeTableRecord=ue;exports.AcDbMText=Os;exports.AcDbObject=ne;exports.AcDbObjectIterator=js;exports.AcDbOpenMode=ma;exports.AcDbOrdinateDimension=Ci;exports.AcDbOsnapMode=R;exports.AcDbPlotPaperUnits=co;exports.AcDbPlotRotation=uo;exports.AcDbPlotSettings=go;exports.AcDbPlotShadePlotResLevel=ce;exports.AcDbPlotShadePlotType=Ye;exports.AcDbPlotStdScaleType=mo;exports.AcDbPlotType=po;exports.AcDbPoint=Ei;exports.AcDbPoly2dType=Xe;exports.AcDbPoly3dType=Es;exports.AcDbPolyFaceMesh=ki;exports.AcDbPolyFaceMeshFace=ho;exports.AcDbPolyFaceMeshVertex=oo;exports.AcDbPolygonMesh=vi;exports.AcDbPolygonMeshVertex=ao;exports.AcDbPolyline=Si;exports.AcDbRadialDimension=Fi;exports.AcDbRasterImage=Fs;exports.AcDbRasterImageClipBoundaryType=ro;exports.AcDbRasterImageDef=xo;exports.AcDbRasterImageImageDisplayOpt=no;exports.AcDbRay=Pi;exports.AcDbRegAppTable=Fo;exports.AcDbRegAppTableRecord=wr;exports.AcDbRegenerator=sl;exports.AcDbRenderingCache=Je;exports.AcDbResultBuffer=Ir;exports.AcDbSpline=Cs;exports.AcDbSymbolTable=ae;exports.AcDbSymbolTableRecord=ye;exports.AcDbSysVarManager=Bs;exports.AcDbSystemVariables=D;exports.AcDbTable=fi;exports.AcDbText=Ke;exports.AcDbTextHorizontalMode=to;exports.AcDbTextStyleTable=No;exports.AcDbTextStyleTableRecord=Hi;exports.AcDbTextVerticalMode=eo;exports.AcDbTrace=Ii;exports.AcDbUnitsValue=Wr;exports.AcDbViewTable=Oo;exports.AcDbViewTableRecord=Wl;exports.AcDbViewport=Ai;exports.AcDbViewportTable=Co;exports.AcDbViewportTableRecord=Hr;exports.AcDbWipeout=Ti;exports.AcDbWorkerApi=Jh;exports.AcDbWorkerManager=Qh;exports.AcDbXline=Mi;exports.AcDbXrecord=jr;exports.AcGeArea2d=vs;exports.AcGeBox2d=ut;exports.AcGeBox3d=C;exports.AcGeCatmullRomCurve3d=qa;exports.AcGeCircArc2d=Ve;exports.AcGeCircArc3d=ze;exports.AcGeCurve2d=ts;exports.AcGeEllipseArc2d=De;exports.AcGeEllipseArc3d=Wi;exports.AcGeEuler=Pl;exports.AcGeGeometryUtil=za;exports.AcGeLine2d=Rt;exports.AcGeLine3d=pe;exports.AcGeLoop2d=ks;exports.AcGeMathUtil=N;exports.AcGeMatrix2d=ji;exports.AcGeMatrix3d=Pt;exports.AcGeNurbsCurve=Ct;exports.AcGePlane=zs;exports.AcGePoint2d=O;exports.AcGePoint3d=b;exports.AcGePolyline2d=ge;exports.AcGeQuaternion=Ge;exports.AcGeShape2d=Br;exports.AcGeSpline3d=Lt;exports.AcGeTol=Nr;exports.AcGeVector2d=U;exports.AcGeVector3d=f;exports.AcGiArrowType=Rr;exports.AcGiDefaultLightingType=Dr;exports.AcGiLineWeight=je;exports.AcGiMTextAttachmentPoint=at;exports.AcGiMTextFlowDirection=ie;exports.AcGiOrthographicType=Vr;exports.AcGiRenderMode=zr;exports.AcGiViewport=Za;exports.AcTrStringUtil=ul;exports.ByBlock=di;exports.ByLayer=Ze;exports.DEBUG_MODE=cl;exports.DEFAULT_LINE_TYPE=qe;exports.DEFAULT_TEXT_STYLE=Y;exports.DEFAULT_TOL=Or;exports.DEG2RAD=Ar;exports.DefaultLoadingManager=ca;exports.FLOAT_TOL=Be;exports.MLIGHTCAD_APPID=lr;exports.ORIGIN_POINT_2D=yl;exports.ORIGIN_POINT_3D=Lr;exports.RAD2DEG=Tr;exports.TAU=G;exports.TEMP_OBJECT_ID_PREFIX=si;exports.acdbDisableOsnapMode=Nl;exports.acdbEnableOsnapMode=Ll;exports.acdbHasOsnapMode=kl;exports.acdbHostApplicationServices=fr;exports.acdbMaskToOsnapModes=Ml;exports.acdbOsnapModesToMask=Tl;exports.acdbToggleOsnapMode=vl;exports.basisFunction=Ms;exports.calculateCurveLength=ja;exports.ceilPowerOfTwo=ka;exports.clamp=se;exports.clone=ws;exports.computeParameterValues=Va;exports.createWorkerApi=tl;exports.damp=xa;exports.deepClone=ar;exports.defaults=Rs;exports.degToRad=Ta;exports.dwgCodePageToEncoding=ga;exports.euclideanModulo=Mr;exports.evaluateNurbsPoint=Ss;exports.floorPowerOfTwo=La;exports.generateAveragedKnots=Da;exports.generateChordKnots=wl;exports.generateSqrtChordKnots=xl;exports.generateUUID=ya;exports.generateUniformKnots=_l;exports.has=ea;exports.intPartLength=kr;exports.interpolateControlPoints=bl;exports.interpolateNurbsCurve=Fr;exports.inverseLerp=wa;exports.isBetween=Na;exports.isBetweenAngle=Oa;exports.isEmpty=sa;exports.isEqual=$e;exports.isImperialUnits=Bl;exports.isMetricUnits=Fl;exports.isPointInPolygon=Cr;exports.isPolygonIntersect=Ra;exports.isPowerOfTwo=va;exports.lerp=vr;exports.log=bs;exports.mapLinear=_a;exports.normalizeAngle=Is;exports.pingpong=ba;exports.radToDeg=Ma;exports.randFloat=Ea;exports.randFloatSpread=Pa;exports.randInt=Sa;exports.relativeEps=Ca;exports.seededRandom=Aa;exports.setAcDbHostApplicationServicesProvider=ua;exports.setAcDbLayoutManagerFactory=pa;exports.setLogLevel=dl;exports.smootherstep=Ia;exports.smoothstep=fa;
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 i=this.formatValue(e);return this._lines.push(i===""?"0":i),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 i=this.resolveHandle(e);return i?this.writeString(t,i):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,i=420){if(!t)return this;const r=t.colorIndex;r!=null&&this.writeInt16(e,r);const n=t.RGB;return n!=null&&t.colorIndex==null&&this.writeInt32(i,n),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 i=t.toFixed(this._precision).replace(/\.?0+$/,"");return i===""||i==="-"?"0":i}return String(t)}sanitizeStringForDxfLine(t){return t.replace(/\r\n|\r|\n/g," ").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,"")}}function il(s,t){for(var e=0;e<t.length;e++){const i=t[e];if(typeof i!="string"&&!Array.isArray(i)){for(const r in i)if(r!=="default"&&!(r in s)){const n=Object.getOwnPropertyDescriptor(i,r);n&&Object.defineProperty(s,r,n.get?n:{enumerable:!0,get:()=>i[r]})}}}return Object.freeze(Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}))}var E=(s=>(s[s.ByColor=1]="ByColor",s[s.ByACI=2]="ByACI",s[s.ByLayer=3]="ByLayer",s[s.ByBlock=4]="ByBlock",s[s.None=0]="None",s))(E||{});const Cn={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},Xi=[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 le=class{static getColorByIndex(t){return Xi[t]}static getIndexByColor(t){const e=Xi.length-1;for(let i=1;i<e;++i)if(Xi[i]===t)return i}static getColorByName(t){return Cn[t.toLowerCase()]}static getNameByColor(t){for(const[e,i]of Object.entries(Cn))if(i===t)return e}static getNameByIndex(t){const e=this.getColorByIndex(t);return this.getNameByColor(e)}},J=class ee{constructor(t=E.ByLayer,e){this._colorMethod=t,this._colorMethod==E.ByColor&&e==null?this._value=16777215:this._colorMethod==E.ByACI?e==null?this._value=8:e===0?this._colorMethod=E.ByBlock:e===256?this._colorMethod=E.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 E.ByColor:case E.ByBlock:case E.ByLayer:return this._value;case E.ByACI:return this._value?le.getColorByIndex(this._value):this._value;default:return}}setRGB(t,e,i){const r=Math.max(0,Math.min(255,Math.round(t))),n=Math.max(0,Math.min(255,Math.round(e))),a=Math.max(0,Math.min(255,Math.round(i)));return this._value=r<<16|n<<8|a,this._colorMethod=E.ByColor,this}setRGBValue(t){return t==null||!Number.isFinite(t)?this:(this._value=t&16777215,this._colorMethod=E.ByColor,this)}setRGBFromCss(t){if(!t)return this;const e=t.trim().toLowerCase();if(e.startsWith("#")){let n=0,a=0,o=0;if(e.length===7)n=parseInt(e.substr(1,2),16),a=parseInt(e.substr(3,2),16),o=parseInt(e.substr(5,2),16);else if(e.length===4)n=parseInt(e[1]+e[1],16),a=parseInt(e[2]+e[2],16),o=parseInt(e[3]+e[3],16);else return this;return this.setRGB(n,a,o)}const i=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(i){const n=parseInt(i[1],10),a=parseInt(i[2],10),o=parseInt(i[3],10);return this.setRGB(n,a,o)}const r=le.getColorByName(t);return r!==void 0?this.setRGBValue(r):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===E.ByACI?this._value:this._colorMethod===E.ByLayer?256:this._colorMethod===E.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=E.ByBlock,this._value=void 0):e===256?(this._colorMethod=E.ByLayer,this._value=void 0):(this._colorMethod=E.ByACI,this._value=e)}get isByColor(){return this._colorMethod===E.ByColor}get isByACI(){return this._colorMethod===E.ByACI}get isForeground(){return this._colorMethod===E.ByACI&&this._value===7}setForeground(){return this._colorMethod=E.ByACI,this._value=7,this}get isByLayer(){return this._colorMethod===E.ByLayer}setByLayer(t){return this._colorMethod=E.ByLayer,t==null?this._value=256:this._value=t,this}get isByBlock(){return this._colorMethod===E.ByBlock}setByBlock(t){return this._colorMethod=E.ByBlock,t==null?this._value=0:this._value=t,this}get colorName(){switch(this._colorMethod){case E.ByLayer:return"ByLayer";case E.ByBlock:return"ByBlock";case E.ByColor:return this._value?le.getNameByColor(this._value):"";case E.ByACI:return this._value?le.getNameByIndex(this._value):"";default:return}}set colorName(t){if(!t)return;const e=le.getColorByName(t);e!==void 0&&(this._value=e,this._colorMethod=E.ByColor)}clone(){const t=new ee;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 E.ByLayer:return"ByLayer";case E.ByBlock:return"ByBlock";case E.ByACI:return this._value!==void 0?String(this._value):"";case E.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 ee(E.ByLayer);if(/^byblock$/i.test(e))return new ee(E.ByBlock);const i=e.match(/^rgb\s*:\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})$/i);if(i){const n=Number(i[1]),a=Number(i[2]),o=Number(i[3]),l=new ee(E.ByColor);return l.setRGB(n,a,o),l}if(/^\d{1,3},\d{1,3},\d{1,3}$/.test(e)){const[n,a,o]=e.split(",").map(Number),l=new ee(E.ByColor);return l.setRGB(n,a,o),l}if(/^\d+$/.test(e)){const n=parseInt(e,10);return new ee(E.ByACI,n)}if(/^book\$/i.test(e)){const n=e.substring(e.indexOf("$")+1),a=le.getColorByName(n);return a!=null?new ee(E.ByColor,a):void 0}const r=le.getColorByName(e);if(r!=null)return new ee(E.ByColor,r)}};class rl{constructor(t=E.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=E.ByColor,this._value=this._value&65535|(t&255)<<16}get green(){return this._value>>8&255}set green(t){this._colorMethod=E.ByColor,this._value=this._value&16711935|(t&255)<<8}get blue(){return this._value&255}set blue(t){this._colorMethod=E.ByColor,this._value=this._value&16776960|t&255}setRGB(t,e,i){this._colorMethod=E.ByColor,this._value=(t&255)<<16|(e&255)<<8|i&255}get colorIndex(){return this._value}set colorIndex(t){this._colorMethod=E.ByACI,this._value=t}get layerIndex(){return this._value}set layerIndex(t){this._colorMethod=E.ByLayer,this._value=t}isByColor(){return this._colorMethod===E.ByColor}isByLayer(){return this._colorMethod===E.ByLayer}isByBlock(){return this._colorMethod===E.ByBlock}isByACI(){return this._colorMethod===E.ByACI}isNone(){return this._colorMethod===E.None}get rawValue(){return this._value}set rawValue(t){this._value=t}}const gt={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 nl=class{constructor(){this._listeners={}}addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){if(this._listeners===void 0)return!1;const i=this._listeners;return i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){if(this._listeners===void 0)return;const i=this._listeners[t];if(i!==void 0){const r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(t){if(this._listeners===void 0)return;const e=this._listeners[t.type];if(e!==void 0){t.target=this;const i=e.slice(0);for(let r=0,n=i.length;r<n;r++)i[r].call(this,t)}}},Z=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 i of this.listeners)i.call(null,t,...e)}};function ws(s){return s===null||typeof s!="object"?s:Array.isArray(s)?[...s]:{...s}}function ar(s){if(s===null||typeof s!="object")return s;if(s instanceof Date)return new Date(s.getTime());if(s instanceof RegExp)return new RegExp(s.source,s.flags);if(Array.isArray(s))return s.map(ar);const t={};for(const e in s)Object.prototype.hasOwnProperty.call(s,e)&&(t[e]=ar(s[e]));return t}function Rs(s,...t){for(const e of t)if(e)for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&s[i]===void 0&&(s[i]=e[i]);return s}function ea(s,t){return s!=null&&Object.prototype.hasOwnProperty.call(s,t)}function sa(s){return s==null?!0:Array.isArray(s)||typeof s=="string"?s.length===0:s instanceof Map||s instanceof Set?s.size===0:typeof s=="object"?Object.keys(s).length===0:!1}function $e(s,t){if(s===t)return!0;if(s==null||t==null)return s===t;if(typeof s!=typeof t)return!1;if(typeof s!="object")return s===t;if(Array.isArray(s)!==Array.isArray(t))return!1;if(Array.isArray(s)){if(s.length!==t.length)return!1;for(let r=0;r<s.length;r++)if(!$e(s[r],t[r]))return!1;return!0}const e=Object.keys(s),i=Object.keys(t);if(e.length!==i.length)return!1;for(const r of e)if(!Object.prototype.hasOwnProperty.call(t,r)||!$e(s[r],t[r]))return!1;return!0}var al=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ol(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var ia={exports:{}};(function(s){(function(t,e){s.exports?s.exports=e():t.log=e()})(al,function(){var t=function(){},e="undefined",i=typeof window!==e&&typeof window.navigator!==e&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=["trace","debug","info","warn","error"],n={},a=null;function o(y,x){var w=y[x];if(typeof w.bind=="function")return w.bind(y);try{return Function.prototype.bind.call(w,y)}catch{return function(){return Function.prototype.apply.apply(w,[y,arguments])}}}function l(){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"&&i?l:console[y]!==void 0?o(console,y):console.log!==void 0?o(console,"log"):t}function d(){for(var y=this.getLevel(),x=0;x<r.length;x++){var w=r[x];this[w]=x<y?t:this.methodFactory(w,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 m(y,x,w){return c(y)||u.apply(this,arguments)}function p(y,x){var w=this,P,I,k,A="loglevel";typeof y=="string"?A+=":"+y:typeof y=="symbol"&&(A=void 0);function j(B){var H=(r[B]||"silent").toUpperCase();if(!(typeof window===e||!A)){try{window.localStorage[A]=H;return}catch{}try{window.document.cookie=encodeURIComponent(A)+"="+H+";"}catch{}}}function T(){var B;if(!(typeof window===e||!A)){try{B=window.localStorage[A]}catch{}if(typeof B===e)try{var H=window.document.cookie,_e=encodeURIComponent(A),we=H.indexOf(_e+"=");we!==-1&&(B=/^([^;]+)/.exec(H.slice(we+_e.length+1))[1])}catch{}return w.levels[B]===void 0&&(B=void 0),B}}function $(){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 F(B){var H=B;if(typeof H=="string"&&w.levels[H.toUpperCase()]!==void 0&&(H=w.levels[H.toUpperCase()]),typeof H=="number"&&H>=0&&H<=w.levels.SILENT)return H;throw new TypeError("log.setLevel() called with invalid level: "+B)}w.name=y,w.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},w.methodFactory=x||m,w.getLevel=function(){return k??I??P},w.setLevel=function(B,H){return k=F(B),H!==!1&&j(k),d.call(w)},w.setDefaultLevel=function(B){I=F(B),T()||w.setLevel(B,!1)},w.resetLevel=function(){k=null,$(),d.call(w)},w.enableAll=function(B){w.setLevel(w.levels.TRACE,B)},w.disableAll=function(B){w.setLevel(w.levels.SILENT,B)},w.rebuild=function(){if(a!==w&&(P=F(a.getLevel())),d.call(w),a===w)for(var B in n)n[B].rebuild()},P=F(a?a.getLevel():"WARN");var tt=T();tt!=null&&(k=F(tt)),d.call(w)}a=new p,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=n[y];return x||(x=n[y]=new p(y,a.methodFactory)),x};var g=typeof window!==e?window.log:void 0;return a.noConflict=function(){return typeof window!==e&&window.log===a&&(window.log=g),a},a.getLoggers=function(){return n},a.default=a,a})})(ia);var ra=ia.exports;const hl=ol(ra),ll=il({__proto__:null,default:hl},[ra]),cl=!0,bs=ll;bs.setLevel("debug");const dl=s=>{try{bs.setLevel(s)}catch(t){bs.setLevel("error"),bs.error(t)}};let na=class aa{constructor(t,e){this.events={attrChanged:new Z,modelChanged:new Z},this._changing=!1,this._previousAttributes={},this._pending=!1;const i=t||{};e&&Rs(i,e),this.attributes=i,this.changed={}}get(t){return this.attributes[t]}set(t,e,i){if(t==null)return this;let r;typeof t=="object"?(r=t,i=e):(r={},r[t]=e),i||(i={});const n=i.unset,a=i.silent,o=[],l=this._changing;this._changing=!0,l||(this._previousAttributes=ws(this.attributes),this.changed={});const c=this.attributes,d=this.changed,u=this._previousAttributes;for(const m in r)e=r[m],$e(c[m],e)||o.push(m),$e(u[m],e)?delete d[m]:d[m]=e,n?delete c[m]:c[m]=e;if(!a){o.length&&(this._pending=i);for(let m=0;m<o.length;m++)this.events.attrChanged.dispatch({object:this,attrName:o[m],attrValue:c[o[m]],options:i})}if(l)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(t){return this.get(t)!=null}hasChanged(t){return t==null?!sa(this.changed):ea(this.changed,t)}changedAttributes(t){if(!t)return this.hasChanged()?ws(this.changed):{};const e=this._changing?this._previousAttributes:this.attributes,i={};for(const r in t){const n=t[r];$e(e[r],n)||(i[r]=n)}return i}previous(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]}previousAttributes(){return ws(this._previousAttributes)}clone(){const t=ws(this.attributes);return new aa(t)}},br=class xs{constructor(){this.entries=new Map}static getInstance(){return xs.instance||(xs.instance=new xs),xs.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 ul{static formatBytes(t,e=2){if(t===0)return"0 B";const i=1024,r=Math.max(0,e),n=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(t)/Math.log(i)),o=t/Math.pow(i,a);return`${parseFloat(o.toFixed(r))} ${n[a]}`}}var dt=(s=>(s[s.ByLayer=0]="ByLayer",s[s.ByBlock=1]="ByBlock",s[s.ByAlpha=2]="ByAlpha",s[s.ErrorValue=3]="ErrorValue",s))(dt||{});let Di=class Nt{constructor(t){t!==void 0?(this._method=dt.ByAlpha,this._alpha=Nt.clampAlpha(t)):(this._method=dt.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=Nt.clampAlpha(t),this._method=dt.ByAlpha}get percentage(){if(this._method===dt.ByAlpha)return Math.round((1-this._alpha/255)*100)}set percentage(t){const e=Math.max(0,Math.min(100,t)),i=Math.round(255*(1-e/100));this.alpha=i}static clampAlpha(t){return Math.max(0,Math.min(255,Math.floor(t)))}get isByAlpha(){return this._method===dt.ByAlpha}get isByBlock(){return this._method===dt.ByBlock}get isByLayer(){return this._method===dt.ByLayer}get isClear(){return this.isByAlpha&&this._alpha===0}get isSolid(){return this.isByAlpha&&this._alpha===255}get isInvalid(){return this._method===dt.ErrorValue}serialize(){return this._method<<24|this._alpha}clone(){const t=new Nt;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 n=new Nt;return n._method=dt.ByLayer,n}if(/^byblock$/i.test(e)){const n=new Nt;return n._method=dt.ByBlock,n}const i=Number(e);if(Number.isInteger(i)&&i>=0&&i<=255)return new Nt(i);const r=new Nt;return r._method=dt.ErrorValue,r}static deserialize(t){const e=t>>>24&255,i=t&255,r=Object.values(dt)[e]??dt.ErrorValue,n=new Nt;return n._method=r,n._alpha=Nt.clampAlpha(i),n}};class oa{constructor(t){this.name=t}run(t){throw new Error("run() must be implemented by subclass")}}class ha{constructor(){this.tasks=[],this.onProgress=()=>{},this.onComplete=()=>{},this.onError=()=>!1}scheduleTask(t){return new Promise((e,i)=>{const r=()=>{Promise.resolve(t()).then(e).catch(i)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(r):setTimeout(r,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 i=t;for(let r=0;r<e;r++){const n=this.tasks[r];try{i=await this.scheduleTask(async()=>{const a=await n.run(i);return this.onProgress((r+1)/e,n),a})}catch(a){if(this.onError({error:a,taskIndex:r,task:n}))return Promise.reject(a)}}this.onComplete(i)}}let la=class{constructor(t,e,i){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=i}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,i=this.handlers.length;e<i;e+=2){const r=this.handlers[e],n=this.handlers[e+1];if(r.global&&(r.lastIndex=0),r.test(t))return n}return null}};const ca=new la;class pl{constructor(t){this.manager=t!==void 0?t:ca,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}loadAsync(t,e){return new Promise((i,r)=>{this.load(t,i,e,r)})}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 Re=256,da=[],Fn=256,Zs;for(;Re--;)da[Re]=(Re+256).toString(16).substring(1);function ml(s){var t=0,e=11;if(!Zs||Re+e>Fn*2)for(Zs="",Re=0;t<Fn;t++)Zs+=da[Math.random()*256|0];return Zs.substring(Re,Re+++e)}const si="TEMP_";let or;function ua(s){or=s}class ne{constructor(t,e){if(t=t||{},this._attrs=new na(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 si+ml()}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(si)&&this.database.updateMaxHandle(t)}get isTemp(){const t=this.getAttrWithoutException("objectId");return!!t&&t.startsWith(si)}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(or)return or().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===xr.ExtendedDataRegAppName&&this._xDataMap.set(e.value,t)}removeXData(t){this._xDataMap.delete(t)}createExtensionDictionary(){}close(){}dxfOut(...t){const[e,i=!1]=t;if(e.writeHandle(5,this.objectId),e.writeObjectId(330,this.ownerId),e.writeObjectId(360,this.extensionDictionary),this.dxfOutFields(e),i)for(const r of this._xDataMap.values())e.writeResultBuffer(r);return this}dxfOutFields(t){return this}}let hr;function pa(s){hr=s}function fr(){return ci.instance}const Ri=class Ri{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(!hr)throw new Error("The layout manager factory must be registered before using it!");this._layoutManager=hr()}return this._layoutManager}};Ri.instance=new Ri;let ci=Ri;ua(fr);var ma=(s=>(s.kForRead="kForRead",s.kForWrite="kForWrite",s))(ma||{});class Ir{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 Ir(this._values)}[Symbol.iterator](){return this._values[Symbol.iterator]()}}class Sr{constructor(t,e,i){this._chunkSize=-1,this._minimumChunkSize=50,this._count=t,this._numerOfChunk=e<1?1:e,this._minimumChunkSize=i,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,i)=>{const r=()=>{Promise.resolve(t()).then(e).catch(i)};typeof window<"u"&&typeof window.requestAnimationFrame=="function"?window.requestAnimationFrame(r):setTimeout(r,0)})}async processChunk(t,e){if(this._count<=0){await(e==null?void 0:e());return}let i=0;const r=async()=>{const n=i,a=Math.min(i+this._chunkSize,this._count);await t(n,a),i=a,i<this._count&&await this.scheduleTask(r)};await r(),await(e==null?void 0:e())}}var fs=(s=>(s.DXF="dxf",s.DWG="dwg",s))(fs||{});class Ft{constructor(){this.events={registered:new Z,unregistered:new Z},this._converters=new Map,this.register("dxf",new el)}static createInstance(){return Ft._instance==null&&(Ft._instance=new Ft),this._instance}static get instance(){return Ft._instance||(Ft._instance=new Ft),Ft._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 Er=(s=>(s[s.DecimalDegrees=0]="DecimalDegrees",s[s.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",s[s.Gradians=2]="Gradians",s[s.Radians=3]="Radians",s[s.SurveyorsUnits=4]="SurveyorsUnits",s))(Er||{});class Je{static get instance(){return this._instance||(this._instance=new Je),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,i,r=[],n=!0,a,o){const l=[];if(e!=null){const c=this.createKey(e.name,i);let d;if(this.has(c))d=this.get(c);else{const u=e.newIterator();for(const m of u)m.color.isByBlock&&i?(Bn.copy(m.color),m.color.setRGBValue(i),this.addEntity(m,l,t),m.color.copy(Bn)):this.addEntity(m,l,t);d=t.group(l),d&&n&&K.name&&!K.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&&r&&r.length>0&&(d.bakeTransformToChildren(),r.forEach(u=>d.addChild(u))),d}else return t.group(l)}addEntity(t,e,i){const r=t.worldDraw(i);r&&(this.attachEntityInfo(r,t),e.push(r))}attachEntityInfo(t,e){t.objectId=e.objectId,t.ownerId=e.ownerId,t.layerName=e.layer,t.visible=e.visibility}}const Bn=new J;var Pr=(s=>(s[s.UTF8=0]="UTF8",s[s.US_ASCII=1]="US_ASCII",s[s.ISO_8859_1=2]="ISO_8859_1",s[s.ISO_8859_2=3]="ISO_8859_2",s[s.ISO_8859_3=4]="ISO_8859_3",s[s.ISO_8859_4=5]="ISO_8859_4",s[s.ISO_8859_5=6]="ISO_8859_5",s[s.ISO_8859_6=7]="ISO_8859_6",s[s.ISO_8859_7=8]="ISO_8859_7",s[s.ISO_8859_8=9]="ISO_8859_8",s[s.ISO_8859_9=10]="ISO_8859_9",s[s.CP437=11]="CP437",s[s.CP850=12]="CP850",s[s.CP852=13]="CP852",s[s.CP855=14]="CP855",s[s.CP857=15]="CP857",s[s.CP860=16]="CP860",s[s.CP861=17]="CP861",s[s.CP863=18]="CP863",s[s.CP864=19]="CP864",s[s.CP865=20]="CP865",s[s.CP869=21]="CP869",s[s.CP932=22]="CP932",s[s.MACINTOSH=23]="MACINTOSH",s[s.BIG5=24]="BIG5",s[s.CP949=25]="CP949",s[s.JOHAB=26]="JOHAB",s[s.CP866=27]="CP866",s[s.ANSI_1250=28]="ANSI_1250",s[s.ANSI_1251=29]="ANSI_1251",s[s.ANSI_1252=30]="ANSI_1252",s[s.GB2312=31]="GB2312",s[s.ANSI_1253=32]="ANSI_1253",s[s.ANSI_1254=33]="ANSI_1254",s[s.ANSI_1255=34]="ANSI_1255",s[s.ANSI_1256=35]="ANSI_1256",s[s.ANSI_1257=36]="ANSI_1257",s[s.ANSI_874=37]="ANSI_874",s[s.ANSI_932=38]="ANSI_932",s[s.ANSI_936=39]="ANSI_936",s[s.ANSI_949=40]="ANSI_949",s[s.ANSI_950=41]="ANSI_950",s[s.ANSI_1361=42]="ANSI_1361",s[s.UTF16=43]="UTF16",s[s.ANSI_1258=44]="ANSI_1258",s[s.UNDEFINED=255]="UNDEFINED",s))(Pr||{});const gl=["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"],ga=s=>gl[s],qe="Continuous",Y="Standard",Ze="ByLayer",di="ByBlock",lr="mlightcad",cr="ACAD",nt=["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 Rn=1234567;const Ar=Math.PI/180,Tr=180/Math.PI;function ya(){const s=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(nt[s&255]+nt[s>>8&255]+nt[s>>16&255]+nt[s>>24&255]+"-"+nt[t&255]+nt[t>>8&255]+"-"+nt[t>>16&15|64]+nt[t>>24&255]+"-"+nt[e&63|128]+nt[e>>8&255]+"-"+nt[e>>16&255]+nt[e>>24&255]+nt[i&255]+nt[i>>8&255]+nt[i>>16&255]+nt[i>>24&255]).toLowerCase()}function se(s,t,e){return Math.max(t,Math.min(e,s))}function Mr(s,t){return(s%t+t)%t}function _a(s,t,e,i,r){return i+(s-t)*(r-i)/(e-t)}function wa(s,t,e){return s!==t?(e-s)/(t-s):0}function vr(s,t,e){return(1-e)*s+e*t}function xa(s,t,e,i){return vr(s,t,1-Math.exp(-e*i))}function ba(s,t=1){return t-Math.abs(Mr(s,t*2)-t)}function fa(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*(3-2*s))}function Ia(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*s*(s*(s*6-15)+10))}function Sa(s,t){return s+Math.floor(Math.random()*(t-s+1))}function Ea(s,t){return s+Math.random()*(t-s)}function Pa(s){return s*(.5-Math.random())}function Aa(s){s!==void 0&&(Rn=s);let t=Rn+=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 Ta(s){return s*Ar}function Ma(s){return s*Tr}function va(s){return(s&s-1)===0&&s!==0}function ka(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function La(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function Is(s){const t=Math.PI*2;return(s%t+t)%t}function Na(s,t,e){return s>t&&s<e||s>e&&s<t}function Oa(s,t,e,i=!1){return s=Is(s),t=Is(t),e=Is(e),i?t>e?s<=t&&s>=e:s<=t||s>=e:t<e?s>=t&&s<=e:s>=t||s<=e}function kr(s){return s=Math.abs(s),s<1?0:Math.ceil(Math.log10(Math.abs(s)+1))}function Ca(s,t=1e-7){const e=kr(s);return Math.max(Math.pow(10,e)*t,t)}const N={DEG2RAD:Ar,RAD2DEG:Tr,generateUUID:ya,clamp:se,euclideanModulo:Mr,mapLinear:_a,inverseLerp:wa,lerp:vr,damp:xa,pingpong:ba,smoothstep:fa,smootherstep:Ia,randInt:Sa,randFloat:Ea,randFloatSpread:Pa,seededRandom:Aa,degToRad:Ta,radToDeg:Ma,isPowerOfTwo:va,ceilPowerOfTwo:ka,floorPowerOfTwo:La,normalizeAngle:Is,isBetween:Na,isBetweenAngle:Oa,intPartLength:kr,relativeEps:Ca},dr=class Fa{constructor(t,e){this.x=0,this.y=0;const i=+(t!==void 0)+ +(e!==void 0);if(i!==0){if(i===1&&t instanceof Array){this.x=t[0],this.y=t[1];return}if(i===1){const{x:r,y:n}=t;this.x=r,this.y=n;return}if(i===2){this.x=t,this.y=e;return}throw gt.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 Fa(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,i=this.y,r=t.elements;return this.x=r[0]*e+r[3]*i+r[6],this.y=r[1]*e+r[4]*i+r[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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,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(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 i=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,i)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,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 i=Math.cos(e),r=Math.sin(e),n=this.x-t.x,a=this.y-t.y;return this.x=n*i-a*r+t.x,this.y=n*r+a*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}relativeEps(t=1e-7){return Math.min(N.relativeEps(this.x,t),N.relativeEps(this.y,t))}*[Symbol.iterator](){yield this.x,yield this.y}};dr.EMPTY=Object.freeze(new dr(0,0));let U=dr;const ur=class Ba{constructor(t,e,i,r,n,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&i!=null&&r!=null&&n!=null&&a!=null&&o!=null&&l!=null&&c!=null&&this.set(t,e,i,r,n,a,o,l,c)}set(t,e,i,r,n,a,o,l,c){const d=this.elements;return d[0]=t,d[1]=r,d[2]=o,d[3]=e,d[4]=n,d[5]=l,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(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.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 i=t.elements,r=e.elements,n=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],d=i[4],u=i[7],m=i[2],p=i[5],g=i[8],y=r[0],x=r[3],w=r[6],P=r[1],I=r[4],k=r[7],A=r[2],j=r[5],T=r[8];return n[0]=a*y+o*P+l*A,n[3]=a*x+o*I+l*j,n[6]=a*w+o*k+l*T,n[1]=c*y+d*P+u*A,n[4]=c*x+d*I+u*j,n[7]=c*w+d*k+u*T,n[2]=m*y+p*P+g*A,n[5]=m*x+p*I+g*j,n[8]=m*w+p*k+g*T,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],i=t[1],r=t[2],n=t[3],a=t[4],o=t[5],l=t[6],c=t[7],d=t[8];return e*a*d-e*o*c-i*n*d+i*o*l+r*n*c-r*a*l}invert(){const t=this.elements,e=t[0],i=t[1],r=t[2],n=t[3],a=t[4],o=t[5],l=t[6],c=t[7],d=t[8],u=d*a-o*c,m=o*l-d*n,p=c*n-a*l,g=e*u+i*m+r*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const y=1/g;return t[0]=u*y,t[1]=(r*c-d*i)*y,t[2]=(o*i-r*a)*y,t[3]=m*y,t[4]=(d*e-r*l)*y,t[5]=(r*n-o*e)*y,t[6]=p*y,t[7]=(i*l-c*e)*y,t[8]=(a*e-i*n)*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,i,r,n,a,o){const l=Math.cos(n),c=Math.sin(n);return this.set(i*l,i*c,-i*(l*a+c*o)+a+t,-r*c,r*l,-r*(-c*a+l*o)+o+e,0,0,1),this}scale(t,e){return this.premultiply(Yi.makeScale(t,e)),this}rotate(t){return this.premultiply(Yi.makeRotation(-t)),this}translate(t,e){return this.premultiply(Yi.makeTranslation(t,e)),this}makeTranslation(t,e){return t instanceof U?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),i=Math.sin(t);return this.set(e,-i,0,i,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,i=t.elements;for(let r=0;r<9;r++)if(e[r]!==i[r])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new Ba().fromArray(this.elements)}};ur.IDENTITY=Object.freeze(new ur);let ji=ur;const Yi=new ji,Be=1e-6,G=2*Math.PI,yl={x:0,y:0},Lr={x:0,y:0,z:0};class Nr{constructor(){this.equalPointTol=Be,this.equalVectorTol=Be}equalPoint2d(t,e){return new U(t).sub(e).length()<this.equalPointTol}equalPoint3d(t,e){return new f(t).sub(e).length()<this.equalPointTol}static equalToZero(t,e=Be){return t<e&&t>-e}static equal(t,e,i=Be){return Math.abs(t-e)<i}static great(t,e,i=Be){return t-e>i}static less(t,e,i=Be){return t-e<i}}const Or=new Nr;function Cr(s,t,e=!1){const i=s.x,r=s.y;let n=!1;const a=t.length;for(let o=0,l=a-1;o<a;l=o++){const c=t[o].x,d=t[o].y,u=t[l].x,m=t[l].y;let p=d>r!=m>r;e&&(p=d>=r!=m>=r),p&&i<(u-c)*(r-d)/(m-d)+c&&(n=!n)}return n}function Ra(s,t){if(s.length===0||t.length===0)return!1;const e=new ut().setFromPoints(s),i=new ut().setFromPoints(t);if(!e.intersectsBox(i))return!1;for(let r=0;r<s.length;){if(Cr(s[r],t,!0))return!0;r<s.length-1&&Or.equalPoint2d(s[r+1],s[r])&&++r,++r}return!1}const za={isPointInPolygon:Cr,isPolygonIntersect:Ra};function _l(s,t){const e=[],i=t-1,r=s;for(let n=0;n<=r;n++)e.push(0);for(let n=1;n<=i-r;n++)e.push(n);for(let n=0;n<=r;n++)e.push(i-r+1);return e}function wl(s,t){const e=t.length-1,i=s,r=[0];let n=0;for(let o=1;o<=e;o++){const l=t[o][0]-t[o-1][0],c=t[o][1]-t[o-1][1],d=t[o][2]-t[o-1][2],u=Math.sqrt(l*l+c*c+d*d);n+=u,r.push(n)}const a=[];for(let o=0;o<=i;o++)a.push(0);for(let o=1;o<=e-i;o++){const l=r[o]/n;a.push(l*(e-i+1))}for(let o=0;o<=i;o++)a.push(e-i+1);return a}function Va(s,t="Uniform"){const e=s.length;if(e===0)return[];if(e===1)return[0];const i=e-1;if(t==="Uniform")return new Array(e).fill(0).map((a,o)=>o/i);const r=[0];let n=0;for(let a=1;a<=i;a++){const o=s[a][0]-s[a-1][0],l=s[a][1]-s[a-1][1],c=s[a][2]-s[a-1][2],d=Math.sqrt(o*o+l*l+c*c),u=t==="SqrtChord"?Math.sqrt(d):d;n+=u,r.push(n)}return n<1e-12?new Array(e).fill(0).map((a,o)=>o/i):r.map(a=>a/n)}function Da(s,t){const e=t.length-1,i=s,r=e+i+1,n=new Array(r+1).fill(0),a=t[t.length-1];for(let o=r-i;o<=r;o++)n[o]=a;for(let o=1;o<=e-i;o++){let l=0;for(let c=o;c<o+i;c++)l+=t[c];n[o+i]=l/i}return n}function xl(s,t){const e=t.length-1,i=s,r=[0];let n=0;for(let o=1;o<=e;o++){const l=t[o][0]-t[o-1][0],c=t[o][1]-t[o-1][1],d=t[o][2]-t[o-1][2],u=Math.sqrt(l*l+c*c+d*d),m=Math.sqrt(u);n+=m,r.push(n)}const a=[];for(let o=0;o<=i;o++)a.push(0);for(let o=1;o<=e-i;o++){const l=r[o]/n;a.push(l*(e-i+1))}for(let o=0;o<=i;o++)a.push(e-i+1);return a}function $i(s,t){const e=s.length,i=s.map(a=>a.slice()),r=t.slice();for(let a=0;a<e;a++){let o=a,l=Math.abs(i[a][a]);for(let c=a+1;c<e;c++){const d=Math.abs(i[c][a]);d>l&&(l=d,o=c)}if(l<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=r[a];r[a]=r[o],r[o]=d}for(let c=a+1;c<e;c++){const d=i[c][a]/i[a][a];if(!(Math.abs(d)<1e-14)){for(let u=a;u<e;u++)i[c][u]-=d*i[a][u];r[c]-=d*r[a]}}}const n=new Array(e).fill(0);for(let a=e-1;a>=0;a--){let o=r[a];for(let l=a+1;l<e;l++)o-=i[a][l]*n[l];n[a]=o/i[a][a]}return n}function Fr(s,t,e="Uniform",i,r){if(s.length===0)return{controlPoints:[],knots:[],weights:[]};const n=s.map(F=>[F[0],F[1],F[2]??0]),a=!!i,o=!!r,l=(a?1:0)+(o?1:0),c=n.length-1,d=c+l;if(d<t)throw new Error("Not enough points to interpolate a curve of this degree.");const u=Va(n,e),m=u.slice();a&&m.unshift(u[0]),o&&m.push(u[u.length-1]);const p=Da(t,m),g=d+1,y=new Array(g),x=new Array(g),w=new Array(g),P=new Array(g);let I=0;y[I]=new Array(g).fill(0),y[I][0]=1,x[I]=n[0][0],w[I]=n[0][1],P[I]=n[0][2],I++;for(let F=1;F<=c-1;F++){const tt=u[F];y[I]=new Array(g).fill(0);for(let B=0;B<=d;B++)y[I][B]=Ms(B,t,tt,p);x[I]=n[F][0],w[I]=n[F][1],P[I]=n[F][2],I++}if(y[I]=new Array(g).fill(0),y[I][d]=1,x[I]=n[c][0],w[I]=n[c][1],P[I]=n[c][2],I++,a){const F=p[t+1]-p[0],tt=F!==0?t/F:0;y[I]=new Array(g).fill(0),y[I][0]=-tt,y[I][1]=tt,x[I]=(i==null?void 0:i[0])??0,w[I]=(i==null?void 0:i[1])??0,P[I]=(i==null?void 0:i[2])??0,I++}if(o){const F=p[d+t+1]-p[d],tt=F!==0?t/F:0;y[I]=new Array(g).fill(0),y[I][d-1]=-tt,y[I][d]=tt,x[I]=(r==null?void 0:r[0])??0,w[I]=(r==null?void 0:r[1])??0,P[I]=(r==null?void 0:r[2])??0,I++}const k=$i(y,x),A=$i(y,w),j=$i(y,P),T=new Array(g);for(let F=0;F<g;F++)T[F]=[k[F],A[F],j[F]];const $=new Array(g).fill(1);return{controlPoints:T,knots:p,weights:$}}function Ms(s,t,e,i){if(t===0)return e>=i[s]&&e<i[s+1]?1:0;const r=i[s+t]-i[s],n=i[s+t+1]-i[s+1],a=r>1e-10?(e-i[s])/r:0,o=n>1e-10?(i[s+t+1]-e)/n:0;return a*Ms(s,t-1,e,i)+o*Ms(s+1,t-1,e,i)}function Ss(s,t,e,i,r){const n=i.length-1,a=t;if(s=Math.max(e[a],Math.min(e[n+1],s)),Math.abs(s-e[n+1])<1e-8)return[...i[n]];if(Math.abs(s-e[a])<1e-8)return[...i[0]];const o=[0,0,0];let l=0;for(let c=0;c<=n;c++){const d=Ms(c,a,s,e),u=r[c]*d;o[0]+=i[c][0]*u,o[1]+=i[c][1]*u,o[2]+=i[c][2]*u,l+=u}if(Math.abs(l)<1e-10){const c=e[e.length-a-1];if(Math.abs(s-c)<1e-8)return[...i[n]];if(Math.abs(s-e[a])<1e-8)return[...i[0]]}return Math.abs(l)>=1e-10&&(o[0]/=l,o[1]/=l,o[2]/=l),o}function ja(s,t,e,i){const r=s,n=t[r],a=t[t.length-r-1];let o=0;const l=1e3,c=(a-n)/l;let d=Ss(n,s,t,e,i);for(let y=1;y<=l;y++){const x=n+y*c,w=Ss(x,s,t,e,i),P=w[0]-d[0],I=w[1]-d[1],k=w[2]-d[2];o+=Math.sqrt(P*P+I*I+k*k),d=w}const u=Ss(a,s,t,e,i),m=u[0]-d[0],p=u[1]-d[1],g=u[2]-d[2];return o+=Math.sqrt(m*m+p*p+g*g),o}function bl(s,t=3,e="Uniform",i,r){return s.length===0?[]:Fr(s,t,e,i,r).controlPoints}class Ge{constructor(t=0,e=0,i=0,r=1){this._x=t,this._y=e,this._z=i,this._w=r}static slerpFlat(t,e,i,r,n,a,o){let l=i[r+0],c=i[r+1],d=i[r+2],u=i[r+3];const m=n[a+0],p=n[a+1],g=n[a+2],y=n[a+3];if(o===0){t[e+0]=l,t[e+1]=c,t[e+2]=d,t[e+3]=u;return}if(o===1){t[e+0]=m,t[e+1]=p,t[e+2]=g,t[e+3]=y;return}if(u!==y||l!==m||c!==p||d!==g){let x=1-o;const w=l*m+c*p+d*g+u*y,P=w>=0?1:-1,I=1-w*w;if(I>Number.EPSILON){const A=Math.sqrt(I),j=Math.atan2(A,w*P);x=Math.sin(x*j)/A,o=Math.sin(o*j)/A}const k=o*P;if(l=l*x+m*k,c=c*x+p*k,d=d*x+g*k,u=u*x+y*k,x===1-o){const A=1/Math.sqrt(l*l+c*c+d*d+u*u);l*=A,c*=A,d*=A,u*=A}}t[e]=l,t[e+1]=c,t[e+2]=d,t[e+3]=u}static multiplyQuaternionsFlat(t,e,i,r,n,a){const o=i[r],l=i[r+1],c=i[r+2],d=i[r+3],u=n[a],m=n[a+1],p=n[a+2],g=n[a+3];return t[e]=o*g+d*u+l*p-c*m,t[e+1]=l*g+d*m+c*u-o*p,t[e+2]=c*g+d*p+o*m-l*u,t[e+3]=d*g-o*u-l*m-c*p,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,i,r){return this._x=t,this._y=e,this._z=i,this._w=r,this._onChangeCallback(),this}clone(){return new Ge(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 i=t.x,r=t.y,n=t.z,a=t.order,o=Math.cos,l=Math.sin,c=o(i/2),d=o(r/2),u=o(n/2),m=l(i/2),p=l(r/2),g=l(n/2);switch(a){case"XYZ":this._x=m*d*u+c*p*g,this._y=c*p*u-m*d*g,this._z=c*d*g+m*p*u,this._w=c*d*u-m*p*g;break;case"YXZ":this._x=m*d*u+c*p*g,this._y=c*p*u-m*d*g,this._z=c*d*g-m*p*u,this._w=c*d*u+m*p*g;break;case"ZXY":this._x=m*d*u-c*p*g,this._y=c*p*u+m*d*g,this._z=c*d*g+m*p*u,this._w=c*d*u-m*p*g;break;case"ZYX":this._x=m*d*u-c*p*g,this._y=c*p*u+m*d*g,this._z=c*d*g-m*p*u,this._w=c*d*u+m*p*g;break;case"YZX":this._x=m*d*u+c*p*g,this._y=c*p*u+m*d*g,this._z=c*d*g-m*p*u,this._w=c*d*u-m*p*g;break;case"XZY":this._x=m*d*u-c*p*g,this._y=c*p*u-m*d*g,this._z=c*d*g+m*p*u,this._w=c*d*u+m*p*g;break}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,r=Math.sin(i);return this._x=t.x*r,this._y=t.y*r,this._z=t.z*r,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],r=e[4],n=e[8],a=e[1],o=e[5],l=e[9],c=e[2],d=e[6],u=e[10],m=i+o+u;if(m>0){const p=.5/Math.sqrt(m+1);this._w=.25/p,this._x=(d-l)*p,this._y=(n-c)*p,this._z=(a-r)*p}else if(i>o&&i>u){const p=2*Math.sqrt(1+i-o-u);this._w=(d-l)/p,this._x=.25*p,this._y=(r+a)/p,this._z=(n+c)/p}else if(o>u){const p=2*Math.sqrt(1+o-i-u);this._w=(n-c)/p,this._x=(r+a)/p,this._y=.25*p,this._z=(l+d)/p}else{const p=2*Math.sqrt(1+u-i-o);this._w=(a-r)/p,this._x=(n+c)/p,this._y=(l+d)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<Number.EPSILON?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(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=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(se(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const r=Math.min(1,e/i);return this.slerp(t,r),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 i=t._x,r=t._y,n=t._z,a=t._w,o=e._x,l=e._y,c=e._z,d=e._w;return this._x=i*d+a*o+r*c-n*l,this._y=r*d+a*l+n*o-i*c,this._z=n*d+a*c+i*l-r*o,this._w=a*d-i*o-r*l-n*c,this._onChangeCallback(),this}slerp(t,e){if(e===0)return this;if(e===1)return this.copy(t);const i=this._x,r=this._y,n=this._z,a=this._w;let o=a*t._w+i*t._x+r*t._y+n*t._z;if(o<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,o=-o):this.copy(t),o>=1)return this._w=a,this._x=i,this._y=r,this._z=n,this;const l=1-o*o;if(l<=Number.EPSILON){const p=1-e;return this._w=p*a+e*this._w,this._x=p*i+e*this._x,this._y=p*r+e*this._y,this._z=p*n+e*this._z,this.normalize(),this}const c=Math.sqrt(l),d=Math.atan2(c,o),u=Math.sin((1-e)*d)/c,m=Math.sin(e*d)/c;return this._w=a*u+this._w*m,this._x=i*u+this._x*m,this._y=r*u+this._y*m,this._z=n*u+this._z*m,this._onChangeCallback(),this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),n=Math.sqrt(i);return this.set(r*Math.sin(t),r*Math.cos(t),n*Math.sin(e),n*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 ct=class Wa{constructor(t,e,i){this.x=0,this.y=0,this.z=0;const r=+(t!==void 0)+ +(e!==void 0)+ +(i!==void 0);if(r!==0){if(r===1&&t instanceof Array){this.x=t[0],this.y=t[1],this.z=t[2];return}if(r===1){const{x:n,y:a,z:o}=t;this.x=n,this.y=a,this.z=o||0;return}if(r===3){this.x=t,this.y=e,this.z=i;return}throw gt.ILLEGAL_PARAMETERS}}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,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 Wa(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(zn.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(zn.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,r=this.z,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6]*r,this.y=n[1]*e+n[4]*i+n[7]*r,this.z=n[2]*e+n[5]*i+n[8]*r,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,r=this.z,n=t.elements,a=1/(n[3]*e+n[7]*i+n[11]*r+n[15]);return this.x=(n[0]*e+n[4]*i+n[8]*r+n[12])*a,this.y=(n[1]*e+n[5]*i+n[9]*r+n[13])*a,this.z=(n[2]*e+n[6]*i+n[10]*r+n[14])*a,this}applyQuaternion(t){const e=this.x,i=this.y,r=this.z,n=t.x,a=t.y,o=t.z,l=t.w,c=2*(a*r-o*i),d=2*(o*e-n*r),u=2*(n*i-a*e);return this.x=e+l*c+a*u-o*d,this.y=i+l*d+o*c-n*u,this.z=r+l*u+n*d-a*c,this}transformDirection(t){const e=this.x,i=this.y,r=this.z,n=t.elements;return this.x=n[0]*e+n[4]*i+n[8]*r,this.y=n[1]*e+n[5]*i+n[9]*r,this.z=n[2]*e+n[6]*i+n[10]*r,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 i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,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(t){return this.x*t.x+this.y*t.y+this.z*t.z}isParallelTo(t){const e=this.dot(t),i=this.length(),r=t.length();return Math.abs(e)===i*r}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,r=t.y,n=t.z,a=e.x,o=e.y,l=e.z;return this.x=r*l-n*o,this.y=n*a-i*l,this.z=i*o-r*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return qi.copy(this).projectOnVector(t),this.sub(qi)}reflect(t){return this.sub(qi.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 i=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,i)))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r}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(),i=this.setFromMatrixColumn(t,1).length(),r=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=r,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,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};ct.ORIGIN=Object.freeze(new ct(0,0,0)),ct.X_AXIS=Object.freeze(new ct(1,0,0)),ct.NEGATIVE_X_AXIS=Object.freeze(new ct(-1,0,0)),ct.Y_AXIS=Object.freeze(new ct(0,1,0)),ct.NEGATIVE_Y_AXIS=Object.freeze(new ct(0,-1,0)),ct.Z_AXIS=Object.freeze(new ct(0,0,1)),ct.NEGATIVE_Z_AXIS=Object.freeze(new ct(0,0,-1));let f=ct;const qi=new f,zn=new Ge,pr=class Ga{constructor(t,e,i,r,n,a,o,l,c,d,u,m,p,g,y,x){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!=null&&e!=null&&i!=null&&r!=null&&n!=null&&a!=null&&o!=null&&l!=null&&c!=null&&d!=null&&u!=null&&m!=null&&p!=null&&g!=null&&y!=null&&x!=null&&this.set(t,e,i,r,n,a,o,l,c,d,u,m,p,g,y,x)}set(t,e,i,r,n,a,o,l,c,d,u,m,p,g,y,x){const w=this.elements;return w[0]=t,w[4]=e,w[8]=i,w[12]=r,w[1]=n,w[5]=a,w[9]=o,w[13]=l,w[2]=c,w[6]=d,w[10]=u,w[14]=m,w[3]=p,w[7]=g,w[11]=y,w[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 Ga().fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[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(Or.equalPoint3d(t,f.Z_AXIS))this.identity();else{const e=new f(1,0,0);Math.abs(t.x)<1/64&&Math.abs(t.y)<1/64?e.crossVectors(f.Y_AXIS,t).normalize():e.crossVectors(f.Z_AXIS,t).normalize();const i=t.clone().cross(e).normalize();this.set(e.x,e.y,e.z,0,i.x,i.y,i.z,0,t.x,t.y,t.z,0,0,0,0,1)}return this}extractBasis(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){const e=this.elements,i=t.elements,r=1/He.setFromMatrixColumn(t,0).length(),n=1/He.setFromMatrixColumn(t,1).length(),a=1/He.setFromMatrixColumn(t,2).length();return e[0]=i[0]*r,e[1]=i[1]*r,e[2]=i[2]*r,e[3]=0,e[4]=i[4]*n,e[5]=i[5]*n,e[6]=i[6]*n,e[7]=0,e[8]=i[8]*a,e[9]=i[9]*a,e[10]=i[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(fl,t,Il)}lookAt(t,e,i){const r=this.elements;return yt.subVectors(t,e),yt.lengthSq()===0&&(yt.z=1),yt.normalize(),he.crossVectors(i,yt),he.lengthSq()===0&&(Math.abs(i.z)===1?yt.x+=1e-4:yt.z+=1e-4,yt.normalize(),he.crossVectors(i,yt)),he.normalize(),Ks.crossVectors(yt,he),r[0]=he.x,r[4]=Ks.x,r[8]=yt.x,r[1]=he.y,r[5]=Ks.y,r[9]=yt.y,r[2]=he.z,r[6]=Ks.z,r[10]=yt.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,r=e.elements,n=this.elements,a=i[0],o=i[4],l=i[8],c=i[12],d=i[1],u=i[5],m=i[9],p=i[13],g=i[2],y=i[6],x=i[10],w=i[14],P=i[3],I=i[7],k=i[11],A=i[15],j=r[0],T=r[4],$=r[8],F=r[12],tt=r[1],B=r[5],H=r[9],_e=r[13],we=r[2],Gs=r[6],Hs=r[10],Us=r[14],Xs=r[3],Ys=r[7],$s=r[11],qs=r[15];return n[0]=a*j+o*tt+l*we+c*Xs,n[4]=a*T+o*B+l*Gs+c*Ys,n[8]=a*$+o*H+l*Hs+c*$s,n[12]=a*F+o*_e+l*Us+c*qs,n[1]=d*j+u*tt+m*we+p*Xs,n[5]=d*T+u*B+m*Gs+p*Ys,n[9]=d*$+u*H+m*Hs+p*$s,n[13]=d*F+u*_e+m*Us+p*qs,n[2]=g*j+y*tt+x*we+w*Xs,n[6]=g*T+y*B+x*Gs+w*Ys,n[10]=g*$+y*H+x*Hs+w*$s,n[14]=g*F+y*_e+x*Us+w*qs,n[3]=P*j+I*tt+k*we+A*Xs,n[7]=P*T+I*B+k*Gs+A*Ys,n[11]=P*$+I*H+k*Hs+A*$s,n[15]=P*F+I*_e+k*Us+A*qs,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],i=t[4],r=t[8],n=t[12],a=t[1],o=t[5],l=t[9],c=t[13],d=t[2],u=t[6],m=t[10],p=t[14],g=t[3],y=t[7],x=t[11],w=t[15];return g*(+n*l*u-r*c*u-n*o*m+i*c*m+r*o*p-i*l*p)+y*(+e*l*p-e*c*m+n*a*m-r*a*p+r*c*d-n*l*d)+x*(+e*c*u-e*o*p-n*a*u+i*a*p+n*o*d-i*c*d)+w*(-r*o*d-e*l*u+e*o*m+r*a*u-i*a*m+i*l*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,i){const r=this.elements;return t instanceof f?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],r=t[2],n=t[3],a=t[4],o=t[5],l=t[6],c=t[7],d=t[8],u=t[9],m=t[10],p=t[11],g=t[12],y=t[13],x=t[14],w=t[15],P=u*x*c-y*m*c+y*l*p-o*x*p-u*l*w+o*m*w,I=g*m*c-d*x*c-g*l*p+a*x*p+d*l*w-a*m*w,k=d*y*c-g*u*c+g*o*p-a*y*p-d*o*w+a*u*w,A=g*u*l-d*y*l-g*o*m+a*y*m+d*o*x-a*u*x,j=e*P+i*I+r*k+n*A;if(j===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const T=1/j;return t[0]=P*T,t[1]=(y*m*n-u*x*n-y*r*p+i*x*p+u*r*w-i*m*w)*T,t[2]=(o*x*n-y*l*n+y*r*c-i*x*c-o*r*w+i*l*w)*T,t[3]=(u*l*n-o*m*n-u*r*c+i*m*c+o*r*p-i*l*p)*T,t[4]=I*T,t[5]=(d*x*n-g*m*n+g*r*p-e*x*p-d*r*w+e*m*w)*T,t[6]=(g*l*n-a*x*n-g*r*c+e*x*c+a*r*w-e*l*w)*T,t[7]=(a*m*n-d*l*n+d*r*c-e*m*c-a*r*p+e*l*p)*T,t[8]=k*T,t[9]=(g*u*n-d*y*n-g*i*p+e*y*p+d*i*w-e*u*w)*T,t[10]=(a*y*n-g*o*n+g*i*c-e*y*c-a*i*w+e*o*w)*T,t[11]=(d*o*n-a*u*n-d*i*c+e*u*c+a*i*p-e*o*p)*T,t[12]=A*T,t[13]=(d*y*r-g*u*r+g*i*m-e*y*m-d*i*x+e*u*x)*T,t[14]=(g*o*r-a*y*r-g*i*l+e*y*l+a*i*x-e*o*x)*T,t[15]=(a*u*r-d*o*r+d*i*l-e*u*l-a*i*m+e*o*m)*T,this}scale(t){const e=this.elements,i=t.x,r=t.y,n=t.z;return e[0]*=i,e[4]*=r,e[8]*=n,e[1]*=i,e[5]*=r,e[9]*=n,e[2]*=i,e[6]*=r,e[10]*=n,e[3]*=i,e[7]*=r,e[11]*=n,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],r=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,r))}makeTranslation(t,e,i){return t instanceof f?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,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),r=Math.sin(e),n=1-i,a=t.x,o=t.y,l=t.z,c=n*a,d=n*o;return this.set(c*a+i,c*o-r*l,c*l+r*o,0,c*o+r*l,d*o+i,d*l-r*a,0,c*l-r*o,d*l+r*a,n*l*l+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,r,n,a){return this.set(1,i,n,0,t,1,a,0,e,r,1,0,0,0,0,1),this}compose(t,e,i){const r=this.elements,n=e.x,a=e.y,o=e.z,l=e.w,c=n+n,d=a+a,u=o+o,m=n*c,p=n*d,g=n*u,y=a*d,x=a*u,w=o*u,P=l*c,I=l*d,k=l*u,A=i.x,j=i.y,T=i.z;return r[0]=(1-(y+w))*A,r[1]=(p+k)*A,r[2]=(g-I)*A,r[3]=0,r[4]=(p-k)*j,r[5]=(1-(m+w))*j,r[6]=(x+P)*j,r[7]=0,r[8]=(g+I)*T,r[9]=(x-P)*T,r[10]=(1-(m+y))*T,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this}decompose(t,e,i){const r=this.elements;let n=He.set(r[0],r[1],r[2]).length();const a=He.set(r[4],r[5],r[6]).length(),o=He.set(r[8],r[9],r[10]).length();this.determinant()<0&&(n=-n),t.x=r[12],t.y=r[13],t.z=r[14],Tt.copy(this);const l=1/n,c=1/a,d=1/o;return Tt.elements[0]*=l,Tt.elements[1]*=l,Tt.elements[2]*=l,Tt.elements[4]*=c,Tt.elements[5]*=c,Tt.elements[6]*=c,Tt.elements[8]*=d,Tt.elements[9]*=d,Tt.elements[10]*=d,e.setFromRotationMatrix(Tt),i.x=n,i.y=a,i.z=o,this}equals(t){const e=this.elements,i=t.elements;for(let r=0;r<16;r++)if(e[r]!==i[r])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}};pr.IDENTITY=Object.freeze(new pr);let Pt=pr;const He=new f,Tt=new Pt,fl=new f(0,0,0),Il=new f(1,1,1),he=new f,Ks=new f,yt=new f;let C=class Ha{constructor(t=void 0,e=void 0){this.min=t==null?new f(1/0,1/0,1/0):new f(t.x,t.y,t.z),this.max=e==null?new f(-1/0,-1/0,-1/0):new f(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,i=t.length;e<i;e+=3)this.expandByPoint(Zi.fromArray(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=Zi.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return new Ha().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 f(0,0,0):new f(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new f(0,0,0):new f(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,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Zi).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:(Vt[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Vt[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Vt[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Vt[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Vt[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Vt[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Vt[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Vt[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Vt),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 Vt=[new f,new f,new f,new f,new f,new f,new f,new f],Zi=new f,Vn=new U;let ut=class Ua{constructor(t=void 0,e=void 0){this.min=t==null?new U(1/0,1/0):new U(t.x,t.y),this.max=e==null?new U(-1/0,-1/0):new U(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,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=Vn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this}clone(){return new Ua().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 U(0,0):new U(0,0).addVectors(this.min,this.max).multiplyScalar(.5)}get size(){return this.isEmpty()?new U(0,0):new U(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,Vn).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 Dn=new f,Sl=new f,El=new ji;class zs{constructor(t=new f(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,i,r){return this.normal.set(t,e,i),this.constant=r,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const r=Dn.subVectors(i,e).cross(Sl.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,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 i=e||El.getNormalMatrix(t),r=this.coplanarPoint(Dn).applyMatrix4(t),n=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(n),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 zs().copy(this)}}let O=class extends U{static pointArrayToNumberArray(t){const e=new Array(t.length*2);return t.forEach((i,r)=>{i.toArray(e,r*2)}),e}},b=class extends f{static pointArrayToNumberArray(t,e=!0){const i=e?3:2,r=new Array(t.length*i);return t.forEach((n,a)=>{n.toArray(r,a*i)}),r}};const jn=new Pt,Wn=new Ge,Xa=class mr{constructor(t=0,e=0,i=0,r=mr.DEFAULT_ORDER){this._x=t,this._y=e,this._z=i,this._order=r}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,i,r=this._order){return this._x=t,this._y=e,this._z=i,this._order=r,this._onChangeCallback(),this}clone(){return new mr(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,i=!0){const r=t.elements,n=r[0],a=r[4],o=r[8],l=r[1],c=r[5],d=r[9],u=r[2],m=r[6],p=r[10];switch(e){case"XYZ":this._y=Math.asin(se(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-d,p),this._z=Math.atan2(-a,n)):(this._x=Math.atan2(m,c),this._z=0);break;case"YXZ":this._x=Math.asin(-se(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,n),this._z=0);break;case"ZXY":this._x=Math.asin(se(m,-1,1)),Math.abs(m)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,n));break;case"ZYX":this._y=Math.asin(-se(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(m,p),this._z=Math.atan2(l,n)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(se(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-d,c),this._y=Math.atan2(-u,n)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-se(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(m,c),this._y=Math.atan2(o,n)):(this._x=Math.atan2(-d,p),this._y=0);break}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i=!0){return jn.makeRotationFromQuaternion(t),this.setFromRotationMatrix(jn,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Wn.setFromEuler(this),this.setFromQuaternion(Wn,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}};Xa.DEFAULT_ORDER="XYZ";let Pl=Xa;class Ya{constructor(){this._boundingBoxNeedsUpdate=!1}get boundingBoxNeedUpdate(){return this._boundingBoxNeedsUpdate}}class Br extends Ya{translate(t){return this.transform(new ji().makeTranslation(t.x,t.y))}get box(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box}}class vs extends Br{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 ut}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints(t){const e=[];for(let i=0;i<this.loops.length;++i){const r=this.loops[i].getPoints(t);e.push(r)}return e}buildHierarchy(){var t;const e=this.getPoints(100),i=this.calculateBoundaryBoxes(e),r=this.sortBoundaryBoxesByAreas(i),n=new Map,a=r.length;for(let l=0;l<a;l++)n.set(r[l],{index:r[l],children:[]});const o={index:-1,children:[]};for(let l=0;l<a;l++){const c=r[l],d=e[c],u=i[c];let m=l+1;for(;m<a;m++){const p=r[m],g=e[p];if(i[p].containsBox(u)&&za.isPointInPolygon(d[N.randInt(0,d.length-1)],g)){(t=n.get(p))==null||t.children.push(n.get(c));break}}m===a&&o.children.push(n.get(c))}return o}get area(){if(this._loops.length===0)return 0;let t=0;for(let e=0;e<this._loops.length;e++){const i=this._loops[e].getPoints(128),r=this.polygonArea(i);e===0?t+=Math.abs(r):t-=Math.abs(r)}return t}polygonArea(t){const e=t.length;if(e<3)return 0;let i=0;for(let r=0,n=e-1;r<e;n=r++){const a=t[n],o=t[r];i+=a.x*o.y-o.x*a.y}return i*.5}calculateBoundaryBoxes(t){const e=[];return t.forEach(i=>{e.push(new ut().setFromPoints(i))}),e}sortBoundaryBoxesByAreas(t){const e=[];t.forEach((r,n)=>{const a=r.size,o=a.width*a.height;e.push({area:o,index:n})}),e.sort((r,n)=>r.area-n.area);const i=[];return e.forEach(r=>{i.push(r.index)}),i}}class ts extends Br{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 i=0;i<=t;i++)e.push(this.getPoint(i/t));return e}getSpacedPoints(t=5){const e=[];for(let i=0;i<=t;i++)e.push(this.getPointAt(i/t));return e}getLength(){const t=this.getLengths();return t[t.length-1]}getLengths(t=this.arcLengthDivisions){const e=[];let i,r=this.getPoint(0),n=0;e.push(0);for(let a=1;a<=t;a++)i=this.getPoint(a/t),n+=i.distanceTo(r),e.push(n),r=i;return e}getUtoTmapping(t,e){const i=this.getLengths();let r=0;const n=i.length;let a;e?a=e:a=t*i[n-1];let o=0,l=n-1,c;for(;o<=l;)if(r=Math.floor(o+(l-o)/2),c=i[r]-a,c<0)o=r+1;else if(c>0)l=r-1;else{l=r;break}if(r=l,i[r]===a)return r/(n-1);const d=i[r],u=i[r+1]-d,m=(a-d)/u;return(r+m)/(n-1)}getTangent(t){let e=t-1e-4,i=t+1e-4;e<0&&(e=0),i>1&&(i=1);const r=this.getPoint(e),n=this.getPoint(i),a=new O;return a.copy(n).sub(r).normalize(),a}getTangentAt(t){const e=this.getUtoTmapping(t);return this.getTangent(e)}}let Ve=class $a extends ts{constructor(t,e,i,r,n){super();const a=+(t!==void 0)+ +(e!==void 0)+ +(i!==void 0)+ +(r!==void 0)+ +(n!==void 0);if(a==3)typeof t=="object"&&typeof e=="object"&&typeof i=="object"?this.createByThreePoints(t,e,i):this.createByStartEndPointsAndBulge(t,e,i);else if(a==5){const o=t;this.center=new O(o.x,o.y),this.radius=e,this._clockwise=n,this._startAngle=this._clockwise?this._mirrorAngle(N.normalizeAngle(i)):N.normalizeAngle(i),this._endAngle=this._clockwise?this._mirrorAngle(N.normalizeAngle(r)):N.normalizeAngle(r)}else throw gt.ILLEGAL_PARAMETERS}createByThreePoints(t,e,i){const r=(T,$)=>({x:(T.x+$.x)/2,y:(T.y+$.y)/2}),n=(T,$)=>($.y-T.y)/($.x-T.x),a=T=>-1/T,o=r(t,e),l=r(e,i),c=n(t,e),d=n(e,i),u=a(c),m=a(d),p=(T,$,F,tt)=>{const B=(tt-$)/(T-F),H=T*B+$;return{x:B,y:H}},g=o.y-u*o.x,y=l.y-m*l.x,x=p(u,g,m,y),w=Math.sqrt(Math.pow(t.x-x.x,2)+Math.pow(t.y-x.y,2)),P=(T,$)=>Math.atan2(T.y-$.y,T.x-$.x),I=P(t,x),k=P(e,x),A=P(i,x),j=A>I&&A<k||I>A&&I<k||k>A&&k<I;this.center=x,this.radius=w,this._clockwise=!j,this._startAngle=I,this._endAngle=A}createByStartEndPointsAndBulge(t,e,i){let r,n,a;i<0?(r=Math.atan(-i)*4,n=new U(t),a=new U(e)):(r=Math.atan(i)*4,n=new U(e),a=new U(t));const o=new U().subVectors(a,n),l=o.length(),c=new U().addVectors(n,o.multiplyScalar(.5)),d=Math.abs(l/2/Math.tan(r/2)),u=o.normalize(),m=i<0?-Math.PI/2:Math.PI/2,p=new U(u.x*Math.cos(m)-u.y*Math.sin(m),u.y*Math.cos(m)+u.x*Math.sin(m));let g;r<Math.PI?i<0?g=c.add(p.multiplyScalar(d)):g=c.add(p.multiplyScalar(-d)):i<0?g=c.add(p.multiplyScalar(-d)):g=c.add(p.multiplyScalar(d)),i<0?(this._startAngle=Math.atan2(n.y-g.y,n.x-g.x),this._endAngle=Math.atan2(a.y-g.y,a.x-g.x)):(this._startAngle=Math.atan2(a.y-g.y,a.x-g.x),this._endAngle=Math.atan2(n.y-g.y,n.x-g.x)),this._clockwise=i<0,this.center=g,this.radius=a.sub(g).length()}get center(){return this._center}set center(t){this._center=new O(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(N.normalizeAngle(t)):N.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:N.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?N.normalizeAngle(t-e):N.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?N.normalizeAngle(t-this.deltaAngle/2):N.normalizeAngle(t+this.deltaAngle/2),i=this._clockwise?this._mirrorAngle(e):e;return this.getPointAtAngle(i)}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 n of e){const a=this._getInternalAngle(n);N.isBetweenAngle(a,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&t.push(this.getPointAtAngle(n))}const i=t.map(n=>n.x),r=t.map(n=>n.y);return new ut(new O(Math.min(...i),Math.min(...r)),new O(Math.max(...i),Math.max(...r)))}get length(){return Math.abs(this.deltaAngle*this.radius)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}clone(){return new $a(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)}getPointAtAngle(t){const e=this._getInternalAngle(t),i=this.center.x+this.radius*Math.cos(e),r=this.center.y+this.radius*Math.sin(e);return new O(i,r)}getPoints(t=100){const e=[];let i=this.deltaAngle,r=this._getInternalAngle(this.startAngle);if(this.closed&&(i=G,r=0),this.clockwise)for(let n=0;n<=t;n++){const a=r-i*(n/t),o=this._clockwise?this._mirrorAngle(a):a,l=this.getPointAtAngle(o);e.push(new O(l.x,l.y))}else for(let n=0;n<=t;n++){const a=r+i*(n/t),o=this._clockwise?this._mirrorAngle(a):a,l=this.getPointAtAngle(o);e.push(new O(l.x,l.y))}return e}};class Al extends Ya{translate(t){return this.transform(new Pt().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 Vs extends Al{}class pe extends Vs{constructor(t,e){super(),this._start=new b(t),this._end=new b(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 f().subVectors(this.endPoint,this.startPoint).normalize()}get midPoint(){return new b((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 i=this.delta(xe).normalize();return new b(this._start).addScaledVector(i,t)}else{const i=this.delta(xe).normalize();return new b(this._end).addScaledVector(i,t)}}extend(t,e=!1){if(e){const i=xe.subVectors(this._start,this._end).normalize();this._start=new b(this._start).addScaledVector(i,t)}else{const i=this.delta(xe).normalize();this._end=new b(this._end).addScaledVector(i,t)}return this._boundingBoxNeedsUpdate=!0,this}closestPointToPointParameter(t,e){Gn.subVectors(t,this._start),Qs.subVectors(this.endPoint,this.startPoint);const i=Qs.dot(Qs);let r=Qs.dot(Gn)/i;return e&&(r=N.clamp(r,0,1)),r}closestPointToPoint(t,e,i){const r=this.closestPointToPointParameter(t,e);return this.delta(i).multiplyScalar(r).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,i=xe.subVectors(t,this.startPoint).dot(e);return new b().copy(e).multiplyScalar(i).add(this.startPoint)}perpPoint(t){const e=this.direction,i=this.startPoint,r=xe.subVectors(t,i).dot(e),n=xe.copy(e).multiplyScalar(r);return new b().addVectors(i,n)}calculateBoundingBox(){const t=new b(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 b(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 C(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 pe(this._start.clone(),this._end.clone())}}const xe=new f,Gn=new f,Qs=new f;class ze extends Vs{static computeCenterPoint(t,e,i){const r=new f().addVectors(t,e).multiplyScalar(.5),n=new f().addVectors(t,i).multiplyScalar(.5),a=new f().subVectors(e,t),o=new f().subVectors(i,t),l=new f().crossVectors(a,o).normalize();if(l.lengthSq()===0)return null;const c=new f().crossVectors(a,l).normalize(),d=new f().crossVectors(o,l).normalize(),u=c.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),m=d.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),p=new pe(r,r.clone().add(u)),g=new pe(n,n.clone().add(m)),y=new f;return p.closestPointToPoint(g.startPoint,!0,y)?y:null}static createByThreePoints(t,e,i){const r=ze.computeCenterPoint(t,e,i);if(r){const n=r.distanceTo(t),a=new f().subVectors(t,r),o=new f().subVectors(e,r),l=Math.atan2(a.y,a.x),c=Math.atan2(o.y,o.x);return new ze(r,n,l,c,f.Z_AXIS)}}constructor(t,e,i,r,n,a=f.X_AXIS){super(),this.center=t,this.radius=e,this.startAngle=i,this.endAngle=r,this.normal=n,this.refVec=a,(r-i)%G==0?(this.startAngle=0,this.endAngle=G):(this.startAngle=i,this.endAngle=r)}get center(){return this._center}set center(t){this._center=new b(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get radius(){return this._radius}set radius(t){if(t<0)throw gt.ILLEGAL_PARAMETERS;this._radius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=N.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==G?t:N.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){return N.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 f(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get refVec(){return this._refVec}set refVec(t){this._refVec=new f(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 i=t+e*.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(t){const e=new f(t.x,t.y,t.z||0),i=this.center,r=this.normal,n=e.clone().sub(i).dot(r),a=e.clone().sub(r.clone().multiplyScalar(n)).clone().sub(i);if(a.lengthSq()===0)return this.startPoint.clone();a.normalize().multiplyScalar(this.radius);const o=i.clone().add(a),l=this.getAngle(o.clone()),c=this.startAngle,d=this.deltaAngle;let u=N.normalizeAngle(l-c);u<0&&(u=0),u>d&&(u=d);const m=this.getPointAtAngle(c+u),p=m.distanceTo(e),g=this.startPoint.distanceTo(e),y=this.endPoint.distanceTo(e);return g<p&&g<=y?this.startPoint.clone():y<p&&y<g?this.endPoint.clone():m}tangentPoints(t){const e=[],i=new f(t.x,t.y,t.z||0),r=this.center,n=this.normal,a=this.radius,o=i.clone().sub(r).dot(n),l=i.clone().sub(n.clone().multiplyScalar(o)),c=r.clone(),d=l.clone().sub(c).length();if(d<a)return e;const u=Math.acos(a/d),m=this.getAngle(l.clone()),p=[m+u,m-u];for(const g of p){const y=N.normalizeAngle(g-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 i=new b(t.x,t.y,t.z||0);return e.length===1||e[0].distanceTo(i)<e[1].distanceTo(i)?e[0]:e[1]}calculateBoundingBox(){const t=[this.startAngle,this.endAngle];for(let l=0;l<2*Math.PI;l+=Math.PI/2)N.isBetweenAngle(l,this.startAngle,this.endAngle)&&t.push(l);let e=1/0,i=1/0,r=1/0,n=-1/0,a=-1/0,o=-1/0;for(const l of t){const c=this.getPointAtAngle(l);c.x<e&&(e=c.x),c.y<i&&(i=c.y),c.z<r&&(r=c.z),c.x>n&&(n=c.x),c.y>a&&(a=c.y),c.z>o&&(o=c.z)}return new C({x:e,y:i,z:r},{x:n,y:a,z:o})}get closed(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0}getPoints(t){const e=[];let i=this.deltaAngle,r=this.startAngle;this.closed&&(i=G,r=0);for(let n=0;n<=t;n++){const a=r+i*(n/t),o=this.getPointAtAngle(a);e.push(o)}return e}transform(t){const e=Ki.copy(this.refVec).applyAxisAngle(this.normal,this.startAngle).multiplyScalar(this.radius),i=Ki.copy(this.refVec).applyAxisAngle(this.normal,this.endAngle).multiplyScalar(this.radius);return this.center.applyMatrix4(t),e.applyMatrix4(t),i.applyMatrix4(t),this.normal.applyMatrix4(t).normalize(),this.refVec.applyMatrix4(t).normalize(),this.startAngle=this.getAngle(e),this.endAngle=this.getAngle(i),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 ze(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)}getAngle(t){return t.sub(this.center),Math.atan2(t.dot(Ki.crossVectors(this.refVec,this.normal)),t.dot(this.refVec))}getPointAtAngle(t){const e=this.normal,i=this.refVec,r={x:e.y*i.z-e.z*i.y,y:e.z*i.x-e.x*i.z,z:e.x*i.y-e.y*i.x},n=this.center,a=this.radius;return new b(n.x+a*(i.x*Math.cos(t)+r.x*Math.sin(t)),n.y+a*(i.y*Math.cos(t)+r.y*Math.sin(t)),n.z+a*(i.z*Math.cos(t)+r.z*Math.sin(t)))}get plane(){const t=new f(this.center).distanceTo(Lr);return new zs(this.normal,t)}}const Ki=new f;class De extends ts{constructor(t,e,i,r=0,n=G,a=!1,o=0){super(),this.center=t,this.majorAxisRadius=e,this.minorAxisRadius=i,(n-r)%G==0?(this.startAngle=0,this.endAngle=G):(this.startAngle=r,this.endAngle=n),this.clockwise=a,this.rotation=o}get center(){return this._center}set center(t){this._center=new b(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw gt.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw gt.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=N.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==G?t:N.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 N.normalizeAngle(this.endAngle-this.startAngle)}get isLargeArc(){return Math.abs(this.deltaAngle)>Math.PI?1:0}calculateBoundingBox(){let t=1/0,e=1/0,i=-1/0,r=-1/0;for(let n=0;n<=100;n++){const a=this.getPoint(n/100);t=Math.min(t,a.x),e=Math.min(e,a.y),i=Math.max(i,a.x),r=Math.max(r,a.y)}return new ut({x:t,y:e},{x:i,y:r})}get closed(){return this.deltaAngle==0}getPoint(t){const e=Math.PI*2;let i=this.endAngle-this.startAngle;const r=Math.abs(i)<Number.EPSILON;for(;i<0;)i+=e;for(;i>e;)i-=e;i<Number.EPSILON&&(r?i=0:i=e),this.clockwise===!0&&!r&&(i===e?i=-e:i=i-e);const n=this.startAngle+t*i;let a=this.center.x+this.majorAxisRadius*Math.cos(n),o=this.center.y+this.minorAxisRadius*Math.sin(n);if(this.rotation!==0){const l=Math.cos(this.rotation),c=Math.sin(this.rotation),d=a-this.center.x,u=o-this.center.y;a=d*l-u*c+this.center.x,o=d*c+u*l+this.center.y}return new O(a,o)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}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 De(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)}}class Wi extends Vs{constructor(t,e,i,r,n,a=0,o=G){super(),this.center=t,this.normal=e,this.majorAxis=i,this.majorAxisRadius=r,this.minorAxisRadius=n;const l=Math.abs(o-a);Math.abs(l-G)<1e-10||Math.abs(l-2*G)<1e-10?(this.startAngle=0,this.endAngle=G):(this.startAngle=a,this.endAngle=o)}get center(){return this._center}set center(t){this._center=new b(t.x,t.y,t.z||0),this._boundingBoxNeedsUpdate=!0}get majorAxisRadius(){return this._majorAxisRadius}set majorAxisRadius(t){if(t<0)throw gt.ILLEGAL_PARAMETERS;this._majorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get minorAxisRadius(){return this._minorAxisRadius}set minorAxisRadius(t){if(t<0)throw gt.ILLEGAL_PARAMETERS;this._minorAxisRadius=t,this._boundingBoxNeedsUpdate=!0}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=N.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=this.startAngle==0&&t==G?t:N.normalizeAngle(t),this._boundingBoxNeedsUpdate=!0}get deltaAngle(){const t=this.endAngle-this.startAngle;return Math.abs(t-G)<1e-10?G:N.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 f(t.x,t.y,t.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0}get majorAxis(){return this._majorAxis}set majorAxis(t){this._majorAxis=new f(t.x,t.y,t.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0}get minorAxis(){return new f().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 i=t+e/2;return this.getPointAtAngle(i)}get isCircular(){return Nr.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 i=0,r=this.getPointAtAngle(this.startAngle);for(let n=1;n<=t;n++){const a=this.startAngle+n*e,o=this.getPointAtAngle(a),l=o.x-r.x,c=o.y-r.y,d=o.z-r.z;i+=Math.sqrt(l*l+c*c+d*d),r=o}return i}get area(){const t=this.majorAxisRadius,e=this.minorAxisRadius,i=this.startAngle,r=i+this.deltaAngle;if(Math.abs(this.deltaAngle-G)<1e-10)return Math.PI*t*e;const n=t*e/2*(r-i-(Math.sin(r)*Math.cos(r)-Math.sin(i)*Math.cos(i)));return Math.abs(n)}calculateBoundingBox(){if(this.majorAxis.equals(f.X_AXIS)||this.majorAxis.equals(f.Y_AXIS)||this.majorAxis.isParallelTo(f.X_AXIS)||this.majorAxis.isParallelTo(f.Y_AXIS)){const t=[this.startAngle,this.endAngle];for(let l=0;l<2*Math.PI;l+=Math.PI/2)N.isBetweenAngle(l,this.startAngle,this.endAngle)&&t.push(l);let e=1/0,i=1/0,r=1/0,n=-1/0,a=-1/0,o=-1/0;for(const l of t){const c=this.getPointAtAngle(l);c.x<e&&(e=c.x),c.y<i&&(i=c.y),c.z<r&&(r=c.z),c.x>n&&(n=c.x),c.y>a&&(a=c.y),c.z>o&&(o=c.z)}return new C({x:e,y:i,z:r},{x:n,y:a,z:o})}else{let t=1/0,e=1/0,i=1/0,r=-1/0,n=-1/0,a=-1/0;for(let o=0;o<=100;o++){const l=this.startAngle+this.deltaAngle*(o/100),c=this.getPointAtAngle(l);t=Math.min(t,c.x),e=Math.min(e,c.y),i=Math.min(i,c.z),r=Math.max(r,c.x),n=Math.max(n,c.y),a=Math.max(a,c.z)}return new C({x:t,y:e,z:i},{x:r,y:n,z:a})}}get closed(){return this.deltaAngle==0}getPoints(t=100){const e=[];let i=this.deltaAngle,r=this.startAngle;this.closed&&(i=G,r=0);for(let n=0;n<=t;n++){const a=r+i*(n/t),o=this.getPointAtAngle(a);e.push(o)}return e}getPointAtAngle(t){const e=Math.cos(t),i=Math.sin(t),r=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(i),n=this.majorAxis.clone().multiplyScalar(e*this.majorAxisRadius).add(r);return new b(this.center.x+n.x,this.center.y+n.y,this.center.z+n.z)}contains(t){const e=new f(t).sub(this.center),i=e.dot(this.majorAxis),r=e.dot(this.minorAxis),n=i/this.majorAxisRadius,a=r/this.minorAxisRadius;return n*n+a*a<=1}transform(t){return 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 Wi(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)}get plane(){const t=new f(this.center).distanceTo(Lr);return new zs(this.normal,t)}}class ge extends ts{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 O(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 O(e.x,e.y)}else{const e=this._vertices[t-1];return new O(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 i=0;i<e;++i){const r=this._vertices[i];let n=null;if(i<e-1?n=this._vertices[i+1]:i==e-1&&this.closed&&(n=this._vertices[0]),n)if(r.bulge){const a=new Ve(r,n,r.bulge);t+=a.length}else t+=new O(r.x,r.y).distanceTo(n)}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 O(e.x,e.y)}calculateBoundingBox(){const t=this.getPoints(100);return new ut().setFromPoints(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}getPoints3d(t,e){const i=[];return this.getPoints(t).forEach(r=>i.push(new b().set(r.x,r.y,e))),i}getPoints(t){const e=[],i=this._vertices.length;for(let r=0;r<i;++r){const n=this._vertices[r];if(n.bulge){let a=null;if(r<i-1?a=this._vertices[r+1]:r==i-1&&this.closed&&(a=this._vertices[0]),a){const o=new Ve(n,a,n.bulge).getPoints(t),l=o.length;for(let c=0;c<l;++c){const d=o[c];e.push(new O(d.x,d.y))}}}else e.push(new O(n.x,n.y)),r==i-1&&this.closed&&e.push(e[0])}return e}}class Rt extends ts{constructor(t,e){super(),this._start=new O(t),this._end=new O(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 O(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),e=new O(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new ut(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 Rt(this._start.clone(),this._end.clone())}}let ks=class Ot extends ts{constructor(t=[]){super(),this._curves=t}get curves(){return this._curves}static buildFromEdges(t,e=.001){if(t.length===0)return[];const i=[...t],r=[],n=e*e,a=(o,l)=>{const c=o.x-l.x,d=o.y-l.y;return c*c+d*d<=n};for(;i.length>0;){const o=[],l=i.shift();o.push(l);const c=Ot.getEdgeStartPoint(l);let d=Ot.getEdgeEndPoint(l);if(!a(c,d))for(;i.length>0;){const u=Ot.findConnectingEdge(i,d,n);if(u.index<0)break;let m=i.splice(u.index,1)[0];if(u.reverse&&(m=Ot.reverseEdge(m)),o.push(m),d=Ot.getEdgeEndPoint(m),a(d,c))break}r.push(new Ot(o))}return r}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 O(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 ut;return e.setFromPoints(t),e}transform(t){return this._boundingBoxNeedsUpdate=!0,this}get closed(){return!0}getPoints(t){const e=[];return this.curves.forEach(i=>{i.getPoints(t).forEach(r=>{e.push(new O(r.x,r.y))})}),e}static findConnectingEdge(t,e,i){let r=-1,n=!1,a=Number.POSITIVE_INFINITY;for(let o=0;o<t.length;o++){const l=t[o],c=Ot.getEdgeStartPoint(l),d=Ot.getEdgeEndPoint(l),u=e.x-c.x,m=e.y-c.y,p=u*u+m*m;p<a&&(a=p,r=o,n=!1);const g=e.x-d.x,y=e.y-d.y,x=g*g+y*y;x<a&&(a=x,r=o,n=!0)}return a>i?{index:-1,reverse:!1}:{index:r,reverse:n}}static getEdgeStartPoint(t){const e=t.startPoint;return new O(e.x,e.y)}static getEdgeEndPoint(t){const e=t.endPoint;return new O(e.x,e.y)}static reverseEdge(t){return t instanceof Rt?new Rt(t.endPoint,t.startPoint):t instanceof Ve?new Ve(t.center,t.radius,t.endAngle,t.startAngle,!t.clockwise):t instanceof De?new De(t.center,t.majorAxisRadius,t.minorAxisRadius,t.endAngle,t.startAngle,!t.clockwise,t.rotation):t instanceof Lt?Ot.reverseSplineEdge(t):t}static reverseSplineEdge(t){const e=[...t.controlPoints].reverse(),i=t.knots,r=i[0],n=i[i.length-1],a=i.map(c=>r+n-c).reverse(),o=t.weights,l=o.length>0?[...o].reverse():void 0;return new Lt(e,a,l,t.degree,t.closed)}};class Qi{constructor(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}init(t,e,i,r){this.c0=t,this.c1=i,this.c2=-3*t+3*e-2*i-r,this.c3=2*t-2*e+i+r}initCatmullRom(t,e,i,r,n){this.init(e,i,n*(i-t),n*(r-e))}initNonuniformCatmullRom(t,e,i,r,n,a,o){let l=(e-t)/n-(i-t)/(n+a)+(i-e)/a,c=(i-e)/a-(r-e)/(a+o)+(r-i)/o;l*=a,c*=a,this.init(e,i,l,c)}calc(t){const e=t*t,i=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*i}}class qa extends Vs{constructor(t=[],e=!1,i="centripetal",r=.5){super(),this.isCatmullRomCurve3d=!0,this.type="CatmullRomCurve3d",this._tmp=new f,this._px=new Qi,this._py=new Qi,this._pz=new Qi,this._points=t.map(n=>new b(n)),this._closed=e,this._curveType=i,this._tension=r}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 b}get endPoint(){return this._points.length>0?this._points[this._points.length-1]:new b}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 b){const i=e,r=this._points,n=r.length;if(n===0)return i.set(0,0,0);if(n===1)return i.copy(r[0]);const a=(n-(this._closed?0:1))*t;let o=Math.floor(a),l=a-o;this._closed?o+=o>0?0:(Math.floor(Math.abs(o)/n)+1)*n:l===0&&o===n-1&&(o=n-2,l=1);let c,d;this._closed||o>0?c=r[(o-1)%n]:(this._tmp.subVectors(r[0],r[1]).add(r[0]),c=new b(this._tmp.x,this._tmp.y,this._tmp.z));const u=r[o%n],m=r[(o+1)%n];if(this._closed||o+2<n?d=r[(o+2)%n]:(this._tmp.subVectors(r[n-1],r[n-2]).add(r[n-1]),d=new b(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){const p=this._curveType==="chordal"?.5:.25;let g=Math.pow(c.distanceToSquared(u),p),y=Math.pow(u.distanceToSquared(m),p),x=Math.pow(m.distanceToSquared(d),p);y<1e-4&&(y=1),g<1e-4&&(g=y),x<1e-4&&(x=y),this._px.initNonuniformCatmullRom(c.x,u.x,m.x,d.x,g,y,x),this._py.initNonuniformCatmullRom(c.y,u.y,m.y,d.y,g,y,x),this._pz.initNonuniformCatmullRom(c.z,u.z,m.z,d.z,g,y,x)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(c.x,u.x,m.x,d.x,this._tension),this._py.initCatmullRom(c.y,u.y,m.y,d.y,this._tension),this._pz.initCatmullRom(c.z,u.z,m.z,d.z,this._tension));return i.set(this._px.calc(l),this._py.calc(l),this._pz.calc(l)),i}getPoints(t){const e=[];for(let i=0;i<=t;i++)e.push(this.getPoint(i/t));return e}setPoints(t){this._points=t.map(e=>new b(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}transform(t){return this._points=this._points.map(e=>{const i=new b;return i.copy(e),i.applyMatrix4(t),i}),this._boundingBoxNeedsUpdate=!0,this}calculateBoundingBox(){if(this._points.length===0)return new C;const t=new C;return this._points.forEach(e=>{t.expandByPoint(e)}),t}}let Ct=class ii{constructor(t,e,i,r){this._degree=t,this._knots=[...e],this._controlPoints=i.map(n=>({x:n.x,y:n.y,z:n.z})),this._weights=r?[...r]:new Array(i.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]}point(t){const e=this._controlPoints.map(i=>[i.x,i.y,i.z]);return Ss(t,this._degree,this._knots,e,this._weights)}length(){const t=this._controlPoints.map(e=>[e.x,e.y,e.z]);return ja(this._degree,this._knots,t,this._weights)}static byKnotsControlPointsWeights(t,e,i,r){return new ii(t,e,i,r)}static byPoints(t,e,i="Uniform",r,n){const a=Fr(t,e,i,r,n),o=a.controlPoints.map(l=>({x:l[0],y:l[1],z:l[2]}));return new ii(e,a.knots,o,a.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:i,end:r}=this.getParameterRange();for(let n=0;n<=t;n++){const a=i+(r-i)*(n/t);e.push(this.point(a))}return e}isClosed(t=1e-6){const{start:e,end:i}=this.getParameterRange(),r=this.point(e),n=this.point(i),a=r[0]-n[0],o=r[1]-n[1],l=r[2]-n[2];return Math.sqrt(a*a+o*o+l*l)<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 qa(t,!0,"centripetal"),i=Math.max(50,t.length*2);return e.getPoints(i)}static createClosedCurve(t,e,i="Chord"){const r=this.createFitPointsForClosedCurve(t).map(n=>[n.x,n.y,n.z]);return ii.byPoints(r,e,i)}};class Lt extends Vs{constructor(t,e,i,r,n,a){super();const o=arguments.length;if(this._degree=3,this._closed=!1,Array.isArray(e)){if(o<2||o>5)throw gt.ILLEGAL_PARAMETERS;this._controlPoints=t;let l,c=3,d=!1;if(o>=3&&(Array.isArray(i)?(l=i,o>=4&&(c=r||3),o>=5&&(d=n)):i!==void 0&&(c=i||3,o>=4&&(d=r))),i===void 0&&o>=4&&(c=r||3,o>=5&&(d=n)),this._degree=c,this._closed=d,this._controlPoints.length<this._degree+1)throw gt.ILLEGAL_PARAMETERS;this._nurbsCurve=Ct.byKnotsControlPointsWeights(this._degree,e,this._controlPoints,l)}else{if(o<2||o>6)throw gt.ILLEGAL_PARAMETERS;this._fitPoints=t,this._knotParameterization=e,o>=3&&(this._degree=i||3);const l=typeof r=="boolean";o>=4&&l&&(this._closed=r),l?(o>=5&&(this._startTangent=n),o>=6&&(this._endTangent=a)):(o>=4&&(this._startTangent=r),o>=5&&(this._endTangent=n)),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 gt.ILLEGAL_PARAMETERS;if(this._closed)this._nurbsCurve=Ct.createClosedCurve(this._fitPoints,this._degree,this._knotParameterization);else{const d=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Ct.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=Ct.createFitPointsForClosedCurve(this._fitPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Ct.byPoints(e,this._degree,this._knotParameterization)}else{const t=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Ct.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=Ct.createFitPointsForClosedCurve(this._controlPoints),e=this.toNurbsPoints(t);this._nurbsCurve=Ct.byPoints(e,this._degree,this._knotParameterization),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(i=>[i.x,i.y,i.z||0]))}else{const t=this._nurbsCurve.knots(),e=this._nurbsCurve.weights();this._nurbsCurve=Ct.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(),i=t[e],r=this._nurbsCurve.point(i);return new b(r[0],r[1],r[2])}get endPoint(){const t=this._nurbsCurve.knots(),e=this._nurbsCurve.degree(),i=t[t.length-e-1],r=this._nurbsCurve.point(i);return new b(r[0],r[1],r[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,i=t<0||t>=e?e-1:t,r=this._fitPoints[i];return{x:r.x,y:r.y,z:r.z||0}}getControlPointAt(t){const e=this._controlPoints.length,i=t<0||t>=e?e-1:t;return this._controlPoints[i]}getPoints(t=100){const e=this._nurbsCurve,i=[],r=e.knots(),n=this._nurbsCurve.degree(),a=r[n],o=r[r.length-n-1],l=(o-a)/(t-1);for(let c=0;c<t;c++){const d=c===t-1?o:a+c*l,u=e.point(d);i.push(new b(u[0],u[1],u[2]))}return i}getCurvePoints(t,e){const i=[],r=t.knots(),n=t.degree(),a=r[n],o=(r[r.length-n-1]-a)/(e-1);for(let l=0;l<e;l++){const c=a+l*o;i.push(t.point(c))}return i}calculateBoundingBox(){const t=this.getPoints(100);return new C().setFromPoints(t)}get closed(){return this._closed}set closed(t){this.setClosed(t)}transform(t){return this._boundingBoxNeedsUpdate=!0,this}toNurbsPoints(t){const e=new Array(t.length);return t.forEach((i,r)=>{e[r]=[i.x,i.y,i.z||0]}),e}toGePoints(t){const e=new Array(t.length);return t.forEach((i,r)=>{e[r]={x:i[0],y:i[1],z:i[2]}}),e}toNurbsPoint(t){return[t.x,t.y,t.z||0]}static createClosedSpline(t,e="Uniform",i=3){if(t.length<i+1)throw new Error(`At least ${i+1} points are required for a degree ${i} closed spline`);return new Lt(t,e,i,!0)}}var Rr=(s=>(s.ClosedFilled="",s.Dot="_DOT",s.DotSmall="_DOTSMALL",s.DotBlank="_DOTBLANK",s.Origin="_ORIGIN",s.Origin2="_ORIGIN2",s.Open="_OPEN",s.Open90="_OPEN90",s.Open30="_OPEN30",s.Closed="_CLOSED",s.Small="_SMALL",s.None="_NONE",s.Oblique="_OBLIQUE",s.BoxFilled="_BOXFILLED",s.Box="_BOXBLANK",s.ClosedBlank="_CLOSEDBLANK",s.DatumBlank="_DATUMBLANK",s.DatumFilled="_DATUMFILLED",s.Integral="_INTEGRAL",s.ArchTick="_ARCHTICK",s))(Rr||{}),je=(s=>(s[s.ByBlock=-2]="ByBlock",s[s.ByDIPs=-4]="ByDIPs",s[s.ByLayer=-1]="ByLayer",s[s.ByLineWeightDefault=-3]="ByLineWeightDefault",s[s.LineWeight000=0]="LineWeight000",s[s.LineWeight005=5]="LineWeight005",s[s.LineWeight009=9]="LineWeight009",s[s.LineWeight013=13]="LineWeight013",s[s.LineWeight015=15]="LineWeight015",s[s.LineWeight018=18]="LineWeight018",s[s.LineWeight020=20]="LineWeight020",s[s.LineWeight025=25]="LineWeight025",s[s.LineWeight030=30]="LineWeight030",s[s.LineWeight035=35]="LineWeight035",s[s.LineWeight040=40]="LineWeight040",s[s.LineWeight050=50]="LineWeight050",s[s.LineWeight053=53]="LineWeight053",s[s.LineWeight060=60]="LineWeight060",s[s.LineWeight070=70]="LineWeight070",s[s.LineWeight080=80]="LineWeight080",s[s.LineWeight090=90]="LineWeight090",s[s.LineWeight100=100]="LineWeight100",s[s.LineWeight106=106]="LineWeight106",s[s.LineWeight120=120]="LineWeight120",s[s.LineWeight140=140]="LineWeight140",s[s.LineWeight158=158]="LineWeight158",s[s.LineWeight200=200]="LineWeight200",s[s.LineWeight211=211]="LineWeight211",s))(je||{}),ie=(s=>(s[s.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",s[s.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",s[s.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",s[s.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",s[s.BY_STYLE=5]="BY_STYLE",s))(ie||{}),at=(s=>(s[s.TopLeft=1]="TopLeft",s[s.TopCenter=2]="TopCenter",s[s.TopRight=3]="TopRight",s[s.MiddleLeft=4]="MiddleLeft",s[s.MiddleCenter=5]="MiddleCenter",s[s.MiddleRight=6]="MiddleRight",s[s.BottomLeft=7]="BottomLeft",s[s.BottomCenter=8]="BottomCenter",s[s.BottomRight=9]="BottomRight",s))(at||{}),zr=(s=>(s[s.OPTIMIZED_2D=0]="OPTIMIZED_2D",s[s.WIREFRAME=1]="WIREFRAME",s[s.HIDDEN_LINE=2]="HIDDEN_LINE",s[s.FLAT_SHADED=3]="FLAT_SHADED",s[s.GOURAUD_SHADED=4]="GOURAUD_SHADED",s[s.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",s[s.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME",s))(zr||{}),Vr=(s=>(s[s.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",s[s.TOP=1]="TOP",s[s.BOTTOM=2]="BOTTOM",s[s.FRONT=3]="FRONT",s[s.BACK=4]="BACK",s[s.LEFT=5]="LEFT",s[s.RIGHT=6]="RIGHT",s))(Vr||{}),Dr=(s=>(s[s.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",s[s.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS",s))(Dr||{});let Za=class Ka{constructor(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new b,this._height=0,this._width=0,this._viewCenter=new b,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 ut;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 ut;return t.setFromCenterAndSize(this.viewCenter,{x:this.viewWidth,y:this.viewHeight}),t}clone(){const t=new Ka;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 qr=class qr extends ne{constructor(){super(...arguments),this._lineType=Ze,this._visibility=!0,this._transparency=new Di}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(){let t=this.color;if(t.isByLayer){const e=this.getLayerColor();e&&e.RGB!=null&&(t=e)}else t.isByBlock;return t}get rgbColor(){const e=this.resolvedColor.RGB;return e??16777215}get lineType(){return this._lineType}set lineType(t){this._lineType=t||Ze}get lineWeight(){return this._lineWeight==null&&(this._lineWeight=this.database.celweight??je.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._linetypeScale==null&&(this._linetypeScale=this.database.celtscale??-1),this._lineWeight==null&&(this._lineWeight=this.database.celweight??je.ByLayer)}get properties(){return{type:this.type,groups:[this.getGeneralProperties()]}}subGetGripPoints(){return new Array}subGetOsnapPoints(t,e,i,r,n){}transformBy(t){return this}erase(){return this.database.tables.blockTable.removeEntity(this.objectId)}worldDraw(t,e){const i=t.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,"thickness"in this&&(i.thickness=this.thickness);const r=this.subWorldDraw(t,e);return this.attachEntityInfo(r),r}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 r;const{type:t,name:e}=this.getLineType(),i=(r=this.database)==null?void 0:r.tables.linetypeTable.getAt(e);return i?{type:t,...i.linetype}:{type:t,name:e,standardFlag:0,description:"",totalPatternLength:0}}getLineType(){if(this.lineType==Ze){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return{type:"ByLayer",name:t.linetype}}else return this.lineType==di?{type:"ByBlock",name:qe}:{type:"UserSpecified",name:this.lineType};return{type:"UserSpecified",name:qe}}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)}};qr.typeName="Entity";let pt=qr;const Zr=class Zr extends pt{};Zr.typeName="Curve";let rt=Zr;var Xe=(s=>(s[s.SimplePoly=0]="SimplePoly",s[s.FitCurvePoly=1]="FitCurvePoly",s[s.QuadSplinePoly=2]="QuadSplinePoly",s[s.CubicSplinePoly=3]="CubicSplinePoly",s))(Xe||{});const Kr=class Kr extends rt{get dxfTypeName(){return"POLYLINE"}constructor(t,e,i=0,r=!1,n=0,a=0,o=null){super(),this._polyType=t,this._elevation=i;const l=o&&(o==null?void 0:o.length)===e.length,c=e.map((d,u)=>({x:d.x,y:d.y,bulge:l?o[u]:void 0}));this._geo=new ge(c,r)}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 C({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 i=this._geo.getPointAt(e);t.push(new b(i.x,i.y,0))}return t}subGetOsnapPoints(t,e,i,r){switch(t){case R.EndPoint:for(let n=0;n<this._geo.numberOfVertices;++n){const a=this._geo.getPointAt(n);r.push(new b(a.x,a.y,0))}break}}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(r=>e.push(new b().set(r.x,r.y,this.elevation))),t.lines(e)}dxfOut(t,e=!1){super.dxfOut(t,e);for(let i=0;i<this.numberOfVertices;++i)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(i).x,y:this.getPointAt(i).y,z:this.elevation}),t.writeDouble(42,this.getBulgeAt(i)),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}};Kr.typeName="2dPolyline";let ui=Kr;var Qa=(s=>(s[s.Vertex=0]="Vertex",s[s.CurveFitVertex=1]="CurveFitVertex",s[s.SplineFitVertex=8]="SplineFitVertex",s[s.SplineCtlVertex=9]="SplineCtlVertex",s))(Qa||{});const Qr=class Qr extends pt{get dxfTypeName(){return"VERTEX"}constructor(){super(),this._position=new b,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 C().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subGetOsnapPoints(t,e,i,r){r.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}};Qr.typeName="2dVertex";let gr=Qr;var Es=(s=>(s[s.SimplePoly=0]="SimplePoly",s[s.QuadSplinePoly=1]="QuadSplinePoly",s[s.CubicSplinePoly=2]="CubicSplinePoly",s))(Es||{});const Jr=class Jr extends rt{get dxfTypeName(){return"POLYLINE"}constructor(t,e,i=!1){super(),this._polyType=t,this._geo=new ge(e,i)}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){return this._geo.getPointAt(t)}get geometricExtents(){const t=this._geo.box;return new C({x:t.min.x,y:t.min.y,z:0},{x:t.max.x,y:t.max.y,z:0})}subGetGripPoints(){const t=new Array;for(let e=0;e<this._geo.numberOfVertices;++e){const i=this._geo.getPointAt(e);t.push(new b(i.x,i.y,0))}return t}subGetOsnapPoints(t,e,i,r){switch(t){case R.EndPoint:for(let n=0;n<this._geo.numberOfVertices;++n){const a=this._geo.getPointAt(n);r.push(new b(a.x,a.y,0))}break}}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=[];return this._geo.getPoints(100).forEach(r=>e.push(new b().set(r.x,r.y,0))),t.lines(e)}dxfOut(t,e=!1){super.dxfOut(t,e);for(let i=0;i<this.numberOfVertices;++i){const r=this.getPointAt(i);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:r.x,y:r.y,z:0}),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}};Jr.typeName="3dPolyline";let pi=Jr;var Ja=(s=>(s[s.SimpleVertex=0]="SimpleVertex",s[s.ControlVertex=1]="ControlVertex",s[s.FitVertex=2]="FitVertex",s))(Ja||{});const tn=class tn extends pt{get dxfTypeName(){return"VERTEX"}constructor(){super(),this._position=new b,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 C().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subGetOsnapPoints(t,e,i,r){r.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}};tn.typeName="3dVertex";let yr=tn;const en=class en extends rt{get dxfTypeName(){return"ARC"}constructor(t,e,i,r,n=f.Z_AXIS){super(),this._geo=new ze(t,e,i,r,n,f.X_AXIS)}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:()=>N.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,i,r){const n=this.startPoint,a=this.endPoint;switch(t){case R.EndPoint:r.push(n),r.push(a);break;case R.MidPoint:r.push(this.midPoint);break;case R.Nearest:{const o=this._geo.nearestPoint(e);r.push(o)}break;case R.Perpendicular:break;case R.Tangent:{const o=this._geo.tangentPoints(e);r.push(...o);break}}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){return t.circularArc(this._geo)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbArc"),t.writePoint3d(10,this.center),t.writeDouble(40,this.radius),t.writeAngle(50,this.startAngle),t.writeAngle(51,this.endAngle),t.writeVector3d(210,this.normal),this}};en.typeName="Arc";let mi=en;var to=(s=>(s[s.LEFT=0]="LEFT",s[s.CENTER=1]="CENTER",s[s.RIGHT=2]="RIGHT",s[s.ALIGNED=3]="ALIGNED",s[s.MIDDLE=4]="MIDDLE",s[s.FIT=5]="FIT",s))(to||{}),eo=(s=>(s[s.BASELINE=0]="BASELINE",s[s.BOTTOM=1]="BOTTOM",s[s.MIDDLE=2]="MIDDLE",s[s.TOP=3]="TOP",s))(eo||{});const sn=class sn extends pt{get dxfTypeName(){return"TEXT"}constructor(){super(),this._textString="",this._height=0,this._thickness=1,this._position=new b,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 C}subGetOsnapPoints(t,e,i,r){R.Insertion===t&&r.push(this._position)}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;let e=t.getAt(this.styleName);return e||(e=t.getAt(Y)||t.getAt(Y)),e.textStyle}subWorldDraw(t,e){const i={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:this.position,rotation:this.rotation,drawingDirection:ie.BOTTOM_TO_TOP,attachmentPoint:at.BottomLeft};return t.mtext(i,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}};sn.typeName="Text";let Ke=sn;var Q=(s=>(s[s.Invisible=1]="Invisible",s[s.Const=2]="Const",s[s.Verifiable=4]="Verifiable",s[s.Preset=8]="Preset",s))(Q||{}),Bt=(s=>(s[s.MultiLine=2]="MultiLine",s[s.ConstMultiLine=4]="ConstMultiLine",s))(Bt||{});const rn=class rn extends Ke{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}};rn.typeName="AttDef";let gi=rn;const nn=class nn extends Ke{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&Q.Invisible)!==0}set isInvisible(t){t?this._flags|=Q.Invisible:this._flags&=~Q.Invisible}get isConst(){return(this._flags&Q.Const)!==0}set isConst(t){t?this._flags|=Q.Const:this._flags&=~Q.Const}get isVerifiable(){return(this._flags&Q.Verifiable)!==0}set isVerifiable(t){t?this._flags|=Q.Verifiable:this._flags&=~Q.Verifiable}get isPreset(){return(this._flags&Q.Preset)!==0}set isPreset(t){t?this._flags|=Q.Preset:this._flags&=~Q.Preset}get isMTextAttribute(){return(this._mtextFlag&Bt.MultiLine)!==0}set isMTextAttribute(t){t?this._mtextFlag|=Bt.MultiLine:this._mtextFlag&=~Bt.MultiLine}get isConstMTextAttribute(){return(this._mtextFlag&Bt.ConstMultiLine)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=Bt.ConstMultiLine:this._mtextFlag&=~Bt.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}};nn.typeName="Attrib";let yi=nn;const an=class an extends pt{get dxfTypeName(){return"INSERT"}constructor(t){super(),this._blockName=t,this._position=new b,this._rotation=0,this._normal=new f(0,0,1),this._scaleFactors=new b(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 js(this._attribs)}get blockTransform(){const t=this.blockTableRecord,e=(t==null?void 0:t.origin)??b.ORIGIN,i=new Pt().makeTranslation(-e.x,-e.y,-e.z),r=new Pt().makeScale(this._scaleFactors.x,this._scaleFactors.y,this._scaleFactors.z),n=new Ge().setFromAxisAngle(f.Z_AXIS,this._rotation),a=new Pt().makeRotationFromQuaternion(n),o=new Pt().makeTranslation(this._position.x,this._position.y,this._position.z);return new Pt().multiplyMatrices(o,a).multiply(r).multiply(i)}subGetOsnapPoints(t,e,i,r,n){R.Insertion===t?r.push(this._position):n&&this.subEntityGetOsnapPoints(t,e,i,r,n)}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(i=>{e.properties.push({name:i.tag,type:"string",editable:!i.isConst,skipTranslation:!0,accessor:{get:()=>i.textString,set:r=>{i.textString=r}}})})}return t}get geometricExtents(){const t=new C,e=this.blockTableRecord;if(e!=null){const r=e.newIterator();for(const n of r)t.union(n.geometricExtents)}const i=this.blockTransform;return t.applyMatrix4(i),t}subWorldDraw(t){const e=this.blockTableRecord;if(e!=null){const i=this.blockTransform,r=[];return this._attribs.forEach(a=>{if(!a.isInvisible){const o=a.worldDraw(t);o&&r.push(o)}}),Je.instance.draw(t,e,this.rgbColor,r,!0,i,this._normal)}else return t.group([])}dxfOut(t,e=!1){super.dxfOut(t,e);let i=!1;for(const r of this.attributeIterator())i=!0,t.writeStart("ATTRIB"),r.dxfOut(t);return i&&(t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity")),this}subEntityGetOsnapPoints(t,e,i,r,n){var o;if(n===this.objectId)return;const a=(o=this.database)==null?void 0:o.tables.blockTable;if(a!=null){const l=a.getEntityById(n);if(l){const c=[];l.subGetOsnapPoints(t,e,i,c,n);const d=this.blockTransform;c.forEach(u=>{const m=u.clone().applyMatrix4(d);r.push(m)})}}}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}};an.typeName="BlockReference";let Qe=an;const on=class on extends rt{get dxfTypeName(){return"CIRCLE"}constructor(t,e,i=f.Z_AXIS){super(),this._geo=new ze(t,e,0,G,i,f.X_AXIS)}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,i,r){switch(t){case R.Center:case R.Centroid:r.push(this._geo.center);break;case R.Quadrant:r.push(this._geo.getPointAtAngle(0)),r.push(this._geo.getPointAtAngle(Math.PI/2)),r.push(this._geo.getPointAtAngle(Math.PI)),r.push(this._geo.getPointAtAngle(Math.PI/2*3));break;case R.Nearest:{const n=this._geo.nearestPoint(e);r.push(n)}break;case R.Tangent:{const n=this._geo.tangentPoints(e);r.push(...n);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){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbCircle"),t.writePoint3d(10,this.center),t.writeDouble(40,this.radius),t.writeVector3d(210,this.normal),this}};on.typeName="Circle";let _i=on;const hn=class hn extends rt{get dxfTypeName(){return"ELLIPSE"}constructor(t,e,i,r,n,a,o){super(),this._geo=new Wi(t,e,i,r,n,a,o)}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,i,r){switch(t){case R.EndPoint:this.closed||(r.push(this._geo.startPoint),r.push(this._geo.endPoint));break;case R.MidPoint:this.closed||r.push(this._geo.midPoint);break;case R.Quadrant:this.closed&&(r.push(this._geo.getPointAtAngle(0)),r.push(this._geo.getPointAtAngle(Math.PI/2)),r.push(this._geo.getPointAtAngle(Math.PI)),r.push(this._geo.getPointAtAngle(Math.PI/2*3)));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:"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,i=this.majorAxisRadius;return t.writePoint3d(11,{x:e.x*i,y:e.y*i,z:e.z*i}),t.writeVector3d(210,this.normal),t.writeDouble(40,this.minorAxisRadius/this.majorAxisRadius),t.writeDouble(41,this.startAngle),t.writeDouble(42,this.endAngle),this}};hn.typeName="Ellipse";let wi=hn;const ln=class ln extends pt{get dxfTypeName(){return"3DFACE"}constructor(){super(),this._vertices=[new b,new b,new b],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 b),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 C().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subGetOsnapPoints(t,e,i,r){switch(t){case R.EndPoint:r.push(...this._vertices);break}}subWorldDraw(t){const e=this._vertices.length,i=new Float32Array(e*3),r=new Uint16Array(e*2);for(let n=0;n<e;n++)i[n*3]=this._vertices[n].x,i[n*3+1]=this._vertices[n].y,i[n*3+2]=this._vertices[n].z,this.isEdgeVisibleAt(n)&&(r[n*2]=n,r[n*2+1]=(n+1)%4);return t.lineSegments(i,3,r)}dxfOutFields(t){super.dxfOutFields(t);const e=this.getVertexAt(0),i=this.getVertexAt(1),r=this.getVertexAt(2),n=this.getVertexAt(3);t.writeSubclassMarker("AcDbFace"),t.writePoint3d(10,e),t.writePoint3d(11,i),t.writePoint3d(12,r),t.writePoint3d(13,n);let a=0;for(let o=0;o<4;++o)this.isEdgeVisibleAt(o)||(a|=1<<o);return t.writeInt16(70,a),this}};ln.typeName="Face";let xi=ln;var Ps=(s=>(s[s.UserDefined=0]="UserDefined",s[s.Predefined=1]="Predefined",s[s.Custom=2]="Custom",s))(Ps||{}),so=(s=>(s[s.Normal=0]="Normal",s[s.Outer=1]="Outer",s[s.Ignore=2]="Ignore",s))(so||{});const cn=class cn extends pt{get dxfTypeName(){return"HATCH"}constructor(){super(),this._elevation=0,this._geo=new vs,this._isSolidFill=!1,this._definitionLines=[],this._patternName="",this._patternType=1,this._patternAngle=0,this._patternScale=1,this._hatchStyle=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}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(),i=[],r=(n,a)=>{if(n.index>=0&&a%2===0){const o=new vs;o.add(t[n.index]),n.children.forEach(l=>{l.index>=0&&o.add(t[l.index])}),i.push(o)}n.children.forEach(o=>r(o,a+1))};return e.children.forEach(n=>r(n,0)),i.length>0?i:[this._geo]}getCalculatedAreaValue(){const t=this.buildAreasFromLoops();return t.length===0?0:t.reduce((e,i)=>e+i.area,0)}get geometricExtents(){const t=this.buildAreasFromLoops();if(t.length===0)return new C;const e=new C;return t.forEach(i=>{const r=i.box;e.union(new C({x:r.min.x,y:r.min.y,z:this._elevation},{x:r.max.x,y:r.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:Ps[0],value:0},{label:Ps[1],value:1},{label:Ps[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};const i=this.buildAreasFromLoops();if(i.length===0)return t.area(this._geo);if(i.length===1)return t.area(i[0]);const r=i.map(n=>t.area(n));return t.group(r)}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((i,r)=>{const n=r===0;if(i instanceof ge){const a=i.vertices,o=a.some(c=>(c.bulge??0)!==0);t.writeInt16(92,2),t.writeInt16(72,o?1:0),t.writeInt16(73,i.closed?1:0),t.writeInt16(93,a.length);for(const c of a)t.writePoint2d(10,c),o&&t.writeDouble(42,c.bulge??0);t.writeInt16(97,0);return}if(i instanceof ks){const a=n?1:0;t.writeInt16(92,a),t.writeInt16(93,i.numberOfEdges);for(const o of i.curves){if(o instanceof Rt){t.writeInt16(72,1),t.writePoint2d(10,o.startPoint),t.writePoint2d(11,o.endPoint);continue}if(o instanceof Ve){t.writeInt16(72,2),t.writePoint2d(10,o.center),t.writeDouble(40,o.radius),t.writeAngle(50,o.startAngle),t.writeAngle(51,o.endAngle),t.writeInt16(73,o.clockwise?0:1);continue}if(o instanceof De){t.writeInt16(72,3),t.writePoint2d(10,o.center);const l=new O(o.majorAxisRadius*Math.cos(o.rotation),o.majorAxisRadius*Math.sin(o.rotation));t.writePoint2d(11,l);const c=o.majorAxisRadius===0?0:o.minorAxisRadius/o.majorAxisRadius;t.writeDouble(40,c),t.writeAngle(50,o.startAngle),t.writeAngle(51,o.endAngle),t.writeInt16(73,o.clockwise?0:1);continue}if(o instanceof Lt){const l=o.knots,c=o.controlPoints,d=o.weights,u=o.fitPoints,m=d.some(p=>p!==1);t.writeInt16(72,4),t.writeInt16(94,o.degree),t.writeInt16(73,m?1:0),t.writeInt16(74,o.closed?1:0),t.writeInt16(95,l.length),t.writeInt16(96,c.length),l.forEach(p=>t.writeDouble(40,p)),c.forEach((p,g)=>{t.writePoint2d(10,p),m&&t.writeDouble(42,d[g]??1)}),t.writeInt16(97,(u==null?void 0:u.length)??0),u==null||u.forEach(p=>t.writePoint2d(11,p))}}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(i=>{t.writeAngle(53,i.angle),t.writePoint2d(43,i.base),t.writePoint2d(45,i.offset),t.writeInt16(79,i.dashLengths.length),i.dashLengths.forEach(r=>t.writeDouble(49,r))}),t.writeInt16(98,0),this}};cn.typeName="Hatch";let Ls=cn;var io=(s=>(s[s.MText=0]="MText",s[s.Fcf=1]="Fcf",s[s.BlockReference=2]="BlockReference",s[s.NoAnnotation=3]="NoAnnotation",s))(io||{});const dn=class dn extends rt{get dxfTypeName(){return"LEADER"}constructor(){super(),this._isSplined=!1,this._updated=!1,this._hasArrowHead=!1,this._vertices=[],this._dimensionStyle="",this._hasHookLine=!1,this._annoType=3}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 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}appendVertex(t){this._vertices.push(new b().copy(t)),this._updated=!0}setVertexAt(t,e){throw(t<0||t>=this._vertices.length)&&(this._vertices[t].copy(e),this._updated=!0),new Error("The vertex index is out of range!")}vertexAt(t){throw(t<0||t>=this._vertices.length)&&this._vertices[t],new Error("The vertex index is out of range!")}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new C().setFromPoints(this._vertices)}get closed(){return!1}set closed(t){}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 Lt(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.annoType),t.writeInt16(73,this.hasHookLine?1:0),t.writeInt16(74,this.isSplined?1:0),t.writeInt16(76,this.numVertices);for(const e of this.vertices)t.writePoint3d(10,e);return this}};dn.typeName="Leader";let bi=dn;var R=(s=>(s[s.EndPoint=1]="EndPoint",s[s.MidPoint=2]="MidPoint",s[s.Center=3]="Center",s[s.Node=4]="Node",s[s.Quadrant=5]="Quadrant",s[s.Insertion=7]="Insertion",s[s.Perpendicular=8]="Perpendicular",s[s.Tangent=9]="Tangent",s[s.Nearest=10]="Nearest",s[s.Centroid=11]="Centroid",s))(R||{});function Tl(s){let t=0;for(const e of s)t|=1<<e-1;return t}function Ml(s){const t=[];for(const e of Object.values(R)){if(typeof e!="number")continue;const i=1<<e-1;s&i&&t.push(e)}return t}function vl(s,t){return s^1<<t-1}function kl(s,t){return(s&1<<t-1)!==0}function Ll(s,t){return s|1<<t-1}function Nl(s,t){return s&~(1<<t-1)}const un=class un extends rt{get dxfTypeName(){return"LINE"}constructor(t,e){super(),this._geo=new pe(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,i,r){const n=this.startPoint,a=this.endPoint;switch(t){case R.EndPoint:r.push(n),r.push(a);break;case R.MidPoint:r.push(this.midPoint);break;case R.Nearest:{const o=this._geo.project(e);r.push(o)}break;case R.Perpendicular:{const o=this._geo.perpPoint(e);r.push(o)}break;case R.Tangent:break}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){const e=this.startPoint,i=this.endPoint,r=[new b(e.x,e.y,0),new b(i.x,i.y,0)];return t.lines(r)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbLine"),t.writePoint3d(10,this.startPoint),t.writePoint3d(11,this.endPoint),this}};un.typeName="Line";let Ns=un;const pn=class pn extends pt{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 b,this._attachmentPoint=at.TopLeft,this._direction=new f(1,0,0),this._drawingDirection=ie.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 C}subGetOsnapPoints(t,e,i,r){R.Insertion===t&&r.push(this._location)}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:at[1],value:1},{label:at[2],value:2},{label:at[3],value:3},{label:at[4],value:4},{label:at[5],value:5},{label:at[6],value:6},{label:at[7],value:7},{label:at[8],value:8},{label:at[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:t=>{this.attachmentPoint=t}}},{name:"drawingDirection",type:"enum",editable:!0,options:[{label:ie[1],value:1},{label:ie[2],value:2},{label:ie[3],value:3},{label:ie[4],value:4},{label:ie[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;let e=t.getAt(this.styleName);return e||(e=t.getAt(Y)||t.getAt(Y)),e.textStyle}subWorldDraw(t,e){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 t.mtext(i,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}};pn.typeName="MText";let Os=pn;const mn=class mn extends rt{get dxfTypeName(){return"SPLINE"}constructor(t,e,i,r,n){super(),this.rebuild(t,e,i,r,n)}rebuild(t,e,i,r,n){const a=+(t!==void 0)+ +(e!==void 0)+ +(i!==void 0)+ +(r!==void 0)+ +(n!==void 0);if(a<2||a>5)throw gt.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new Lt(t,e,i,r):this._geo=new Lt(t,e,i,r,n)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}set closed(t){this._geo.closed=t}subGetOsnapPoints(t,e,i,r){switch(t){case R.EndPoint:r.push(this._geo.startPoint),r.push(this._geo.endPoint);break}}subWorldDraw(t){const e=this._geo.getPoints(100);return t.lines(e)}dxfOutFields(t){var i;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,((i=e.fitPoints)==null?void 0:i.length)??0);for(const r of e.knots)t.writeDouble(40,r);for(const r of e.weights)t.writeDouble(41,r);for(const r of e.controlPoints)t.writePoint3d(10,r);for(const r of e.fitPoints??[])t.writePoint3d(11,r);return this}};mn.typeName="Spline";let Cs=mn;const Ol=new f,gn=class gn extends Qe{get dxfTypeName(){return"ACAD_TABLE"}constructor(t,e,i){super(t),this._attachmentPoint=at.TopLeft,this._numColumns=i,this._numRows=e,this._columnWidth=new Array(i),this._rowHeight=new Array(e),this._cells=new Array(e*i)}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,i){var n;const r=t*this._numColumns+e;return(n=this._cells[r])==null?void 0:n.text}setTextString(t,e,i){const r=t*this._numColumns+e;if(!this._cells[r]){this._cells[r]={text:i,attachmentPoint:this._attachmentPoint,cellType:1,textHeight:0};return}this._cells[r].text=i}isEmpty(t,e){var r;const i=t*this._numColumns+e;return!((r=this._cells[i])!=null&&r.text)}get geometricExtents(){return new C}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){let e=0,i=0;const r=new Uint16Array(this.numColumns*this.numRows*8),n=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let a=0;for(let m=0;m<=this.numRows;m++){e-=m>0?this.rowHeight(m-1):0,i=0;for(let p=0;p<=this.numColumns;p++)i+=p>0?this.columnWidth(p-1):0,n[a++]=i,n[a++]=e,n[a++]=0}const o=[],l=new Array(this.numRows*this.numColumns).fill(!1);i=0,a=0;let c=0;for(let m=0;m<this.numColumns;m++){i+=m>0?this.columnWidth(m-1):0,e=0;for(let p=0;p<this.numRows;p++){e+=p>0?this.rowHeight(p-1):0;const g=this.cell(p*this.numColumns+m);if(c=p*this.numColumns+m,g&&!l[c]){const y=g.borderWidth??1,x=g.borderHeight??1;this.fillVisited(l,c,this.numColumns,y,x),r[a++]=m+p*(this.numColumns+1),r[a++]=m+p*(this.numColumns+1)+y;const w=n[r[a-1]*3]-i,P=m+(p+x)*(this.numColumns+1)+y;m+y==this.numColumns&&(r[a++]=m+p*(this.numColumns+1)+y,r[a++]=P);const I=-n[P*3+1]-e;if(p+x==this.numRows&&(r[a++]=m+(p+x)*(this.numColumns+1)+x,r[a++]=m+(p+x)*(this.numColumns+1)),r[a++]=m+(p+x)*(this.numColumns+1),r[a++]=m+p*(this.numColumns+1),g.text){const k=g.attachmentPoint||this.attachmentPoint||at.MiddleCenter,A=this.getTableTextOffset(k,w,I),j={text:g.text,height:g.textHeight,width:w,position:Ol.set(i,-e,0).clone().add(A),rotation:this.rotation,attachmentPoint:k},T=this.getTextStyle(g);o.push(t.mtext(j,T))}}}}o.push(t.lineSegments(n,3,r));const d=t.group(o),u=new Ge;return u.setFromAxisAngle(f.Z_AXIS,this.rotation),Hn.compose(this.position,u,this.scaleFactors),d.applyMatrix(Hn),d}fillVisited(t,e,i,r,n){if(n==1&&r==1)t[e]=!0;else for(let a=0;a<r;++a)for(let o=0;o<n;++o)t[e+a+o*i]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable;let i;return t.textStyle&&(i=e.getAt(t.textStyle)),i||(i=e.getAt(Y)||e.getAt(Y)),i.textStyle}getTableTextOffset(t,e,i){const r=new f;switch(t){case 1:break;case 2:r.setX(e/2);break;case 3:r.setX(e);break;case 4:r.setY(-i/2);break;case 5:r.set(e/2,-i/2,0);break;case 6:r.set(e,-i/2,0);break;case 7:r.setY(-i);break;case 8:r.set(e/2,-i,0);break;case 9:r.set(e,-i,0);break}return r}dxfOutFields(t){var n,a,o,l,c,d,u;super.dxfOutFields(t),t.writeSubclassMarker("AcDbTable");const e=t.version??((n=t.database)==null?void 0:n.version)??((a=this.database)==null?void 0:a.version),i=(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 m=0;m<this.numRows;++m)t.writeDouble(141,this.rowHeight(m));for(let m=0;m<this.numColumns;++m)t.writeDouble(142,this.columnWidth(m));const r=this._cells.length>0?this._cells.length:this.numRows*this.numColumns;for(let m=0;m<r;m++){const p=this._cells[m],g=(p==null?void 0:p.cellType)??(p!=null&&p.blockTableRecordId?2:1);if(t.writeInt16(171,g),t.writeInt16(172,(p==null?void 0:p.flagValue)??0),t.writeInt16(173,(p==null?void 0:p.mergedValue)??0),t.writeBoolean(174,p==null?void 0:p.autoFit),t.writeInt16(175,p==null?void 0:p.borderWidth),t.writeInt16(176,p==null?void 0:p.borderHeight),(p==null?void 0:p.overrideFlag)!=null&&(i?t.writeInt32(91,p.overrideFlag):t.writeInt16(177,p.overrideFlag)),t.writeInt16(178,p==null?void 0:p.virtualEdgeFlag),t.writeAngle(145,p==null?void 0:p.rotation),i&&t.writeInt16(92,p==null?void 0:p.extendedCellFlags),g===1)p!=null&&p.fieldObjetId?t.writeObjectId(344,p.fieldObjetId):this.writeCellText(t,(p==null?void 0:p.text)??"",i,p==null?void 0:p.cellValueBlockBegin);else if(g===2){if(t.writeObjectId(340,p==null?void 0:p.blockTableRecordId),t.writeDouble(144,p==null?void 0:p.blockScale),t.writeInt16(179,p==null?void 0:p.blockAttrNum),(o=p==null?void 0:p.attrDefineId)!=null&&o.length)for(const y of p.attrDefineId)t.writeObjectId(331,y);if((p==null?void 0:p.attrText)!=null)if(Array.isArray(p.attrText))for(const y of p.attrText)t.writeString(300,y);else t.writeString(300,p.attrText)}p!=null&&p.textStyle&&t.writeString(7,p.textStyle),(p==null?void 0:p.textHeight)!=null&&t.writeDouble(140,p.textHeight),(p==null?void 0:p.attachmentPoint)!=null&&t.writeInt16(170,p.attachmentPoint),(p==null?void 0:p.topBorderVisibility)!=null&&t.writeInt16(289,p.topBorderVisibility?1:0),(p==null?void 0:p.rightBorderVisibility)!=null&&t.writeInt16(285,p.rightBorderVisibility?1:0),(p==null?void 0:p.bottomBorderVisibility)!=null&&t.writeInt16(286,p.bottomBorderVisibility?1:0),(p==null?void 0:p.leftBorderVisibility)!=null&&t.writeInt16(288,p.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),(l=this.cellTypeOverrides)!=null&&l.length)for(const m of this.cellTypeOverrides){t.writeString(7,m.textStyle),t.writeDouble(140,m.textHeight),t.writeInt16(170,m.alignment),t.writeInt16(63,m.backgroundColor),t.writeInt16(64,m.contentColor),m.backgroundColorEnabled!=null&&t.writeInt16(283,m.backgroundColorEnabled?1:0);const p=m.borderLineweights;p&&(t.writeInt16(274,p.top),t.writeInt16(275,p.right),t.writeInt16(276,p.bottom),t.writeInt16(277,p.left),t.writeInt16(278,p.insideHorizontal),t.writeInt16(279,p.insideVertical));const g=m.borderVisibility;g&&(t.writeInt16(284,g.top?1:0),t.writeInt16(285,g.right?1:0),t.writeInt16(286,g.bottom?1:0),t.writeInt16(287,g.left?1:0),t.writeInt16(288,g.insideHorizontal?1:0),t.writeInt16(289,g.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 m of this.rowDataTypes)t.writeInt16(97,m);if((d=this.rowUnitTypes)!=null&&d.length)for(const m of this.rowUnitTypes)t.writeInt16(98,m);if((u=this.rowFormats)!=null&&u.length)for(const m of this.rowFormats)t.writeString(4,m);return this}writeCellText(t,e,i,r){if(!i){if(e.length<=250){t.writeString(1,e);return}const o=Math.ceil(e.length/250);for(let l=0;l<o;l++){const c=l*250,d=c+250,u=e.slice(c,d);l===o-1?t.writeString(1,u):t.writeString(2,u)}return}if(t.writeString(301,r??"CELL_VALUE"),e.length<=250){t.writeString(302,e),t.writeString(304,"ACVALUE_END");return}const a=Math.ceil(e.length/250);for(let o=0;o<a;o++){const l=o*250,c=l+250,d=e.slice(l,c);o===a-1?t.writeString(302,d):t.writeString(303,d)}t.writeString(304,"ACVALUE_END")}};gn.typeName="Table";let fi=gn;const Hn=new Pt,yn=class yn extends rt{get dxfTypeName(){return"TRACE"}constructor(){super(),this._elevation=0,this._thickness=1,this._vertices=[new b,new b,new b,new b]}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 C().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subGetOsnapPoints(t,e,i,r){switch(t){case R.EndPoint:r.push(...this._vertices);break}}subWorldDraw(t){const e=new ge(this._vertices,!0),i=new vs;i.add(e);const r=t.subEntityTraits;return r.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},t.area(i)}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}};yn.typeName="Trace";let Ii=yn;const _n=class _n extends rt{get dxfTypeName(){return"LWPOLYLINE"}constructor(){super(),this._elevation=0,this._geo=new ge}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,i=0,r=-1,n=-1){const a=r<0?void 0:r,o=n<0?void 0:n,l={x:e.x,y:e.y,bulge:i,startWidth:a,endWidth:o};this._geo.addVertexAt(t,l)}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 b(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new C({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,i,r){const n=new Array;for(let a=0;a<this.numberOfVertices;++a)n.push(this.getPoint3dAt(a));switch(t){case R.EndPoint:r.push(...n);break}}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(r=>e.push(new b().set(r.x,r.y,this.elevation))),t.lines(e)}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}};_n.typeName="Polyline";let Si=_n;const wn=class wn extends pt{get dxfTypeName(){return"POINT"}constructor(){super(),this._geo=new b}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get geometricExtents(){return new C().expandByPoint(this._geo)}subGetOsnapPoints(t,e,i,r){R.Node===t&&r.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}};wn.typeName="Point";let Ei=wn;var ro=(s=>(s[s.Invalid=0]="Invalid",s[s.Rect=1]="Rect",s[s.Poly=2]="Poly",s))(ro||{}),no=(s=>(s[s.Show=1]="Show",s[s.ShowUnAligned=2]="ShowUnAligned",s[s.Clip=4]="Clip",s[s.Transparent=8]="Transparent",s))(no||{});const xn=class xn extends pt{get dxfTypeName(){return"IMAGE"}constructor(){super(),this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new b,this._scale=new U(1,1),this._rotation=0,this._imageSize=new O,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 C;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)}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,i=this._height,r=new ut;r.setFromPoints(this._clipBoundary);const n=new O;n.setX(this._position.x-r.min.x*e),n.setY(this._position.y-r.min.y*i),this._clipBoundary.forEach(a=>{const o=a.x*e+n.x,l=a.y*i+n.y;t.push(new b(o,l,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){Un.copy(t[1]);for(let e=1;e<4;e++)Js.copy(t[e]),Js.rotateAround(Un,this._rotation),t[e].setX(Js.x),t[e].setY(Js.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,i=this.height*this.scale.y,r=this._imageSize.x>0&&this._imageSize.y>0?this._imageSize:{x:e,y:i},n=r.x>0?e/r.x:e,a=r.y>0?i/r.y:i,o=Math.cos(this._rotation),l=Math.sin(this._rotation);t.writePoint3d(11,{x:n*o,y:n*l,z:0}),t.writePoint3d(12,{x:-a*l,y:a*o,z:0}),t.writePoint2d(13,r),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}};xn.typeName="RasterImage";let Fs=xn;const Un=new O,Js=new O,bn=class bn extends rt{get dxfTypeName(){return"RAY"}constructor(){super(),this._basePoint=new b,this._unitDir=new f}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 C;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,i,r){switch(t){case R.EndPoint:r.push(this.basePoint);break}}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}};bn.typeName="Ray";let Pi=bn;const fn=class fn extends pt{get dxfTypeName(){return"VIEWPORT"}constructor(){super(),this._centerPoint=new b,this._height=0,this._width=0,this._viewCenter=new b,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 C}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 Za;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 i=[];return i.push(e.lines([new b(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new b(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)])),i.push(e.lines([new b(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new b(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)])),i.push(e.lines([new b(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new b(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)])),i.push(e.lines([new b(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new b(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)])),i}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}};fn.typeName="Viewport";let Ai=fn;const In=class In extends Fs{get dxfTypeName(){return"WIPEOUT"}subWorldDraw(t){const e=this.boundaryPath(),i=new vs;return i.add(new ge(e)),t.area(i)}dxfOutFields(t){return super.dxfOutFields(t),this}};In.typeName="Wipeout";let Ti=In;const Sn=class Sn extends rt{get dxfTypeName(){return"XLINE"}constructor(){super(),this._basePoint=new b,this._unitDir=new f}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 C;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}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}};Sn.typeName="Xline";let Mi=Sn;class ao{constructor(t){this.position=new b(t.x,t.y,t.z||0)}}const En=class En extends rt{get dxfTypeName(){return"POLYLINE"}constructor(t,e,i,r=!1,n=!1){super(),this._mCount=t,this._nCount=e,this._closedM=r,this._closedN=n,this._vertices=i.map(a=>new ao(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(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 i=t*this._nCount+e;return this.getVertexAt(i)}get geometricExtents(){if(this._vertices.length===0)return new C(new b(0,0,0),new b(0,0,0));let t=Number.MAX_VALUE,e=Number.MAX_VALUE,i=Number.MAX_VALUE,r=-Number.MAX_VALUE,n=-Number.MAX_VALUE,a=-Number.MAX_VALUE;return this._vertices.forEach(o=>{t=Math.min(t,o.position.x),e=Math.min(e,o.position.y),i=Math.min(i,o.position.z),r=Math.max(r,o.position.x),n=Math.max(n,o.position.y),a=Math.max(a,o.position.z)}),new C(new b(t,e,i),new b(r,n,a))}subGetGripPoints(){const t=new Array;return this._vertices.forEach(e=>{t.push(e.position)}),t}subGetOsnapPoints(t,e,i,r){switch(t){case R.EndPoint:this._vertices.forEach(n=>{r.push(n.position)});break}}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 i=0;i<this._mCount;i++)for(let r=0;r<this._nCount;r++){const n=this.getVertexAtMN(i,r);let a=r+1;if(a>=this._nCount)if(this._closedN)a=0;else continue;const o=this.getVertexAtMN(i,a);e.push(n.position),e.push(o.position)}for(let i=0;i<this._nCount;i++)for(let r=0;r<this._mCount;r++){const n=this.getVertexAtMN(r,i);let a=r+1;if(a>=this._mCount)if(this._closedM)a=0;else continue;const o=this.getVertexAtMN(a,i);e.push(n.position),e.push(o.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 i=0;i<this.numberOfVertices;i++){const r=this.getVertexAt(i);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,r.position),t.writeInt16(70,16)}return t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}};En.typeName="PolygonMesh";let vi=En;class oo{constructor(t){this.position=new b(t.x,t.y,t.z||0)}}class ho{constructor(t){this.vertexIndices=t}}const Pn=class Pn extends rt{get dxfTypeName(){return"POLYLINE"}constructor(t,e){super(),this._vertices=t.map(i=>new oo(i)),this._faces=e.map(i=>new ho(i))}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 C(new b(0,0,0),new b(0,0,0));let t=Number.MAX_VALUE,e=Number.MAX_VALUE,i=Number.MAX_VALUE,r=-Number.MAX_VALUE,n=-Number.MAX_VALUE,a=-Number.MAX_VALUE;return this._vertices.forEach(o=>{t=Math.min(t,o.position.x),e=Math.min(e,o.position.y),i=Math.min(i,o.position.z),r=Math.max(r,o.position.x),n=Math.max(n,o.position.y),a=Math.max(a,o.position.z)}),new C(new b(t,e,i),new b(r,n,a))}subGetGripPoints(){const t=new Array;return this._vertices.forEach(e=>{t.push(e.position)}),t}subGetOsnapPoints(t,e,i,r){switch(t){case R.EndPoint:this._vertices.forEach(n=>{r.push(n.position)});break}}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(i=>{const r=[];if(i.vertexIndices.forEach(n=>{const a=Math.abs(n)-1;a>=0&&a<this._vertices.length&&r.push(this._vertices[a].position)}),r.length>=3)for(let n=0;n<r.length;n++){const a=r[n],o=r[(n+1)%r.length];e.push(a),e.push(o)}}),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 i=0;i<this.numberOfVertices;i++){const r=this.getVertexAt(i);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,r.position),t.writeInt16(70,64)}for(let i=0;i<this.numberOfFaces;i++){const r=this.getFaceAt(i);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),r.vertexIndices.forEach((n,a)=>{t.writeInt32(10+a,n)})}return t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}};Pn.typeName="PolyFaceMesh";let ki=Pn;var lo=(s=>(s[s.AtLeast=1]="AtLeast",s[s.Exactly=2]="Exactly",s))(lo||{});const An=class An extends pt{get dxfTypeName(){return"DIMENSION"}constructor(){super(),this._dimBlockId=null,this._dimBlockPosition=new b,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new b,this._textRotation=0,this._normal=new f(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}get dimensionStyle(){if(this._dimStyle==null){let t;this.dimensionStyleName&&(t=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),t==null&&(t=new We),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()}subWorldDraw(t){if(this.dimBlockId){const i=this.database.tables.blockTable.getAt(this.dimBlockId);if(i){const r=this.computeDimBlockTransform();return Je.instance.draw(t,i,this.rgbColor,[],!1,r,this._normal)}}return t.group([])}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}getLineArrowStyle(t){}findPointOnLine1(t,e,i){const r=new b().subVectors(e,t).normalize();return new b(e).addScaledVector(r,i)}findPointOnLine2(t,e,i){const r=t.x+i*Math.cos(e),n=t.y+i*Math.sin(e);return{x:r,y:n}}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():Rr.Closed}computeDimBlockTransform(){const t=this.dimBlockId?this.database.tables.blockTable.getAt(this.dimBlockId):void 0,e=(t==null?void 0:t.origin)??b.ORIGIN,i=new Pt().makeTranslation(-e.x,-e.y,-e.z),r=new Pt().makeTranslation(this._dimBlockPosition.x,this._dimBlockPosition.y,this._dimBlockPosition.z);return new Pt().multiplyMatrices(r,i)}dxfOutFields(t){super.dxfOutFields(t);const e=this.dimensionStyleName!=null?this.database.tables.dimStyleTable.getAt(this.dimensionStyleName):void 0;return t.writeSubclassMarker("AcDbDimension"),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.writeVector3d(210,this.normal),t.writeObjectId(340,e==null?void 0:e.objectId),this}};An.typeName="Dimension";let re=An;const Tn=class Tn extends re{constructor(t,e,i,r,n=null,a=null){super(),this._centerPoint=new b().copy(t),this._xLine1Point=new b().copy(e),this._xLine2Point=new b().copy(i),this._arcPoint=new b().copy(r),this.dimensionText=n,this.dimensionStyleName=a}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 geometricExtents(){return new C}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}};Tn.typeName="3PointAngularDimension";let Li=Tn;const Mn=class Mn extends re{constructor(t,e,i,r=null,n=null){super(),this._dimLinePoint=new b().copy(i),this._xLine1Point=new b().copy(t),this._xLine2Point=new b().copy(e),this._oblique=0,this._rotation=0,this.calculateRotation(),r?this.dimensionText=r:this.dimensionText=this._xLine1Point.distanceTo(this._xLine2Point).toFixed(3),this.dimensionStyleName=n}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 geometricExtents(){return new C}get isAppendArrow(){return!1}createDimBlock(t){const e=new K;e.name=t;const i=this.createLines();i.forEach(o=>e.appendEntity(new Ns(o.startPoint,o.endPoint))),this.createArrows(i[0]).forEach(o=>e.appendEntity(o));const n=i[0].midPoint,a=this.createMText(n,this._rotation);return a&&e.appendEntity(a),e}createMText(t,e){const i=r=>({x:Math.cos(r),y:Math.sin(r),z:0});if(this.dimensionText){const r=new Os;return r.attachmentPoint=at.MiddleLeft,r.layer="0",r.color=new J(E.ByBlock),r.location=t,r.contents=this.dimensionText??"",r.height=10,r.direction=i(e),r.styleName=this.dimensionStyle.dimtxsty,r}}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,i){const r="_CAXARROW",n=new Qe(r);return n.position=t,n.rotation=e,n.scaleFactors={x:i,y:i,z:i},n}createLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),i=this.createExtensionLine(this._xLine2Point),r=this.findIntersectionPoint(e,this._dimLinePoint),n=this.findIntersectionPoint(i,this._dimLinePoint),a=new pe(r,n);return t.push(a),e.endPoint=r,this.adjustExtensionLine(e),t.push(e),i.endPoint=n,this.adjustExtensionLine(i),t.push(i),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,i=this.findPointOnLine2(t,e,100);return new pe(t,{...i,z:t.z})}findIntersectionPoint(t,e){const i=t.startPoint,r=t.endPoint,n=new f().subVectors(r,i).normalize(),o=new f().subVectors(e,i).dot(n),l=new f().copy(n).multiplyScalar(o);return new f().addVectors(i,l)}calculateRotation(){const t=this._xLine1Point,e=this._xLine2Point,i=e.x-t.x,r=e.y-t.y;this._rotation=Math.atan2(r,i)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbAlignedDimension"),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}};Mn.typeName="AlignedDimension";let Ni=Mn;const vn=class vn extends re{constructor(t,e,i,r,n=null,a=null){super(),this._arcPoint=new b().copy(r),this._xLine1Point=new b().copy(e),this._xLine2Point=new b().copy(i),this._centerPoint=new b().copy(t),this.dimensionText=n,this.dimensionStyleName=a}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 geometricExtents(){return new C}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}};vn.typeName="ArcDimension";let _r=vn;const kn=class kn extends re{constructor(t,e,i=0,r=null,n=null){super(),this._chordPoint=new b().copy(t),this._farChordPoint=new b().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=i,this.dimensionText=r,this.dimensionStyleName=n}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}get geometricExtents(){return new C}drawLines(t,e){const i=[],r=e.length;return r==1?i.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})):r==3?(this.sortLines(e),i.push(this.drawLine(t,e[0],{firstArrow:this.firstArrowStyle})),i.push(this.drawLine(t,e[1])),i.push(this.drawLine(t,e[2],{firstArrow:this.firstArrowStyle}))):e.forEach(n=>{i.push(this.drawLine(t,n))}),i}drawLine(t,e,i){if(i){const r=[e.startPoint,e.endPoint];return t.lines(r)}else return e.worldDraw(t)}sortLines(t){const e=(i,r)=>i.x!==r.x?i.x-r.x:i.y!==r.y?i.y-r.y:i.z-r.z;t.sort((i,r)=>{const n=e(i.startPoint,r.startPoint);return n!==0?n:e(i.endPoint,r.endPoint)})}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}};kn.typeName="DiametricDimension";let Oi=kn;const Ln=class Ln extends re{constructor(t,e,i=null,r=null){super(),this._definingPoint=new b().copy(t),this._leaderEndPoint=new b().copy(e),this.dimensionText=i,this.dimensionStyleName=r}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 geometricExtents(){return new C}get arrowLineCount(){return 0}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbOrdinateDimension"),t.writePoint3d(13,this.definingPoint),t.writePoint3d(14,this.leaderEndPoint),this}};Ln.typeName="OrdinateDimension";let Ci=Ln;const Nn=class Nn extends re{constructor(t,e,i,r=null,n=null){super(),this._center=new b().copy(t),this._chordPoint=new b().copy(e),this._leaderLength=i,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=r,this.dimensionStyleName=n}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 leaderLenght(t){this._leaderLength=t}get geometricExtents(){return new C}getLineArrowStyle(t){return{secondArrow:this.secondArrowStyle}}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}};Nn.typeName="RadialDimension";let Fi=Nn;var co=(s=>(s[s.kInches=0]="kInches",s[s.kMillimeters=1]="kMillimeters",s[s.kPixels=2]="kPixels",s))(co||{}),uo=(s=>(s[s.k0degrees=0]="k0degrees",s[s.k90degrees=1]="k90degrees",s[s.k180degrees=2]="k180degrees",s[s.k270degrees=3]="k270degrees",s))(uo||{}),po=(s=>(s[s.kDisplay=0]="kDisplay",s[s.kExtents=1]="kExtents",s[s.kLimits=2]="kLimits",s[s.kView=3]="kView",s[s.kWindow=4]="kWindow",s[s.kLayout=5]="kLayout",s))(po||{}),ce=(s=>(s[s.kDraft=0]="kDraft",s[s.kPreview=1]="kPreview",s[s.kNormal=2]="kNormal",s[s.kPresentation=3]="kPresentation",s[s.kMaximum=4]="kMaximum",s[s.kCustom=5]="kCustom",s))(ce||{}),Ye=(s=>(s[s.kAsDisplayed=0]="kAsDisplayed",s[s.kWireframe=1]="kWireframe",s[s.kHidden=2]="kHidden",s[s.kRendered=3]="kRendered",s[s.kVisualStyle=4]="kVisualStyle",s[s.kRenderPreset=5]="kRenderPreset",s))(Ye||{}),mo=(s=>(s[s.kScaleToFit=0]="kScaleToFit",s[s.k1_128in_1ft=1]="k1_128in_1ft",s[s.k1_64in_1ft=2]="k1_64in_1ft",s[s.k1_32in_1ft=3]="k1_32in_1ft",s[s.k1_16in_1ft=4]="k1_16in_1ft",s[s.k3_32in_1ft=5]="k3_32in_1ft",s[s.k1_8in_1ft=6]="k1_8in_1ft",s[s.k3_16in_1ft=7]="k3_16in_1ft",s[s.k1_4in_1ft=8]="k1_4in_1ft",s[s.k3_8in_1ft=9]="k3_8in_1ft",s[s.k1_2in_1ft=10]="k1_2in_1ft",s[s.k3_4in_1ft=11]="k3_4in_1ft",s[s.k1in_1ft=12]="k1in_1ft",s[s.k3in_1ft=13]="k3in_1ft",s[s.k6in_1ft=14]="k6in_1ft",s[s.k1ft_1ft=15]="k1ft_1ft",s[s.k1_1=16]="k1_1",s[s.k1_2=17]="k1_2",s[s.k1_4=18]="k1_4",s[s.k1_5=19]="k1_5",s[s.k1_8=20]="k1_8",s[s.k1_10=21]="k1_10",s[s.k1_16=22]="k1_16",s[s.k1_20=23]="k1_20",s[s.k1_30=24]="k1_30",s[s.k1_40=25]="k1_40",s[s.k1_50=26]="k1_50",s[s.k1_100=27]="k1_100",s[s.k2_1=28]="k2_1",s[s.k4_1=29]="k4_1",s[s.k8_1=30]="k8_1",s[s.k10_1=31]="k10_1",s[s.k100_1=32]="k100_1",s[s.k1000_1=33]="k1000_1",s[s.k1and1_2in_1ft=34]="k1and1_2in_1ft",s))(mo||{});const Cl={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 go extends ne{constructor(t=!1){super(),this._plotSettingsName="",this._plotCfgName="",this._canonicalMediaName="",this._currentStyleSheet="",this._plotOrigin=new O,this._customPrintScale={numerator:1,denominator:1},this._plotPaperSize=new O,this._plotPaperMargins={left:0,right:0,top:0,bottom:0},this._plotViewName="",this._plotWindowArea=new ut,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 Cl[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 Ds extends go{constructor(){super(),this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new ut,this._extents=new C,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 js{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 As extends ne{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,i=>this.hasId(i)),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((i,r)=>{i===e&&(this._recordsByName.delete(r),this.database.events.dictObjectErased.dispatch({database:this.database,object:e,key:r}))}),!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 js(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,i]of this._recordsByName)t.writeString(3,e),t.writeObjectId(350,i.objectId);return this}}class yo extends As{getBtrIdAt(t){for(const[e,i]of this._recordsByName)if(i.blockTableRecordId==t)return i}get maxTabOrder(){let t=-1;return this._recordsByName.forEach(e=>{e.tabOrder>t&&(t=e.tabOrder)}),t}}class ye extends ne{constructor(t,e){t=t||{},Rs(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 _o=(s=>(s[s.Any=0]="Any",s[s.Uniform=1]="Uniform",s))(_o||{});const de=class de extends ye{static isModelSapceName(t){return t.toLowerCase()==de.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(de.PAPER_SPACE_NAME_PREFIX.toLowerCase())}constructor(){super(),this._origin=new b,this._layoutId="",this._entities=new Map,this._blockInsertUnits=0,this._explodability=1,this._blockScaling=1,this._bmpPreview=void 0}get isModelSapce(){return de.isModelSapceName(this.name)}get isPaperSapce(){return de.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=i=>{i.database=this.database,i.ownerId=this.objectId,this.database.commitObjectHandle(i,r=>this._entities.has(r)),i.resolveEffectiveProperties(),this._entities.set(i.objectId,i)};if(Array.isArray(t))for(let i=0;i<t.length;++i)e(t[i]);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],i=[];return e.forEach(r=>{const n=this._entities.get(r);n&&i.push(n),this._entities.delete(r)}),i.length>0&&this.database.events.entityErased.dispatch({database:this.database,entity:i}),i.length>0}newIterator(){return new js(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}};de.MODEL_SPACE_NAME="*Model_Space",de.PAPER_SPACE_NAME_PREFIX="*Paper_Space";let K=de;class wo{constructor(){this.events={layoutCreated:new Z,layoutRemoved:new Z,layoutRenamed:new Z,layoutSwitched:new Z}}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 i=this.getWorkingDatabase(e),r=i.objects.layout.getIdAt(t);return this.setCurrentLayoutInternal(r,i)}setCurrentLayoutBtrId(t,e){const i=this.getWorkingDatabase(e),r=i.objects.layout.getBtrIdAt(t);return this.setCurrentLayoutInternal(r,i)}setCurrentLayout(t,e){const i=this.getWorkingDatabase(e),r=i.objects.layout.getAt(t);return this.setCurrentLayoutInternal(r,i)}renameLayout(t,e,i){const n=this.getWorkingDatabase(i).objects.layout.getAt(t);return n?(n.layoutName=e,this.events.layoutRenamed.dispatch({layout:n,oldName:t,newName:e}),!0):!1}layoutExists(t,e){return this.getWorkingDatabase(e).objects.layout.has(t)}deleteLayout(t,e){const i=this.getWorkingDatabase(e).objects.layout,r=i.getAt(t);let n=!1;return r&&(n=i.remove(t),n&&this.events.layoutRemoved.dispatch({layout:r})),n}createLayout(t,e){const i=this.getWorkingDatabase(e),r=new Ds;r.layoutName=t,r.tabOrder=i.objects.layout.maxTabOrder;const n=new K;return n.name=`*Paper_Space${r.tabOrder}`,i.tables.blockTable.add(n),i.objects.layout.setAt(t,r),this.events.layoutCreated.dispatch({layout:r}),{layout:r,btr:n}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.objects.layout.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||fr().workingDatabase}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}pa(()=>new wo);class xo extends ne{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 bo=(s=>(s[s.NotApplicable=0]="NotApplicable",s[s.Ignore=1]="Ignore",s[s.Replace=2]="Replace",s[s.XrefMangleName=3]="XrefMangleName",s[s.MangleName=4]="MangleName",s))(bo||{});class jr extends ne{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(){var e;const t=new jr;return t._data=((e=this._data)==null?void 0:e.clone())??null,t}getDuplicateRecordCloning(){return 0}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbXrecord"),t.writeInt16(280,1),t.writeResultBuffer(this.data),this}}class fo{constructor(t){this.db=t}createDefaultLayer(){const t=new J;return t.colorIndex=7,this.db.tables.layerTable.add(new Gi({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new ue({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new ue({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new ue({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new Hi({name:Y,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new We({name:Y,dimtxsty:Y}))}createDefaultLayout(){const t=new Ds;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 Ls;e.patternName="SOLID";const i=new ks;i.add(new Rt({x:0,y:0},{x:-1,y:.125})),i.add(new Rt({x:-1,y:.125},{x:-1,y:-.125})),i.add(new Rt({x:-1,y:-.125},{x:0,y:0})),e.add(i);const r=new K;r.name="_CAXARROW",r.appendEntity(e),this.db.tables.blockTable.add(r)}}}var Io=(s=>(s.ClosedFilled="",s.Dot="_DOT",s.DotSmall="_DOTSMALL",s.DotBlank="_DOTBLANK",s.Origin="_ORIGIN",s.Origin2="_ORIGIN2",s.Open="_OPEN",s.Open90="_OPEN90",s.Open30="_OPEN30",s.Closed="_CLOSED",s.Small="_SMALL",s.None="_NONE",s.Oblique="_OBLIQUE",s.BoxFilled="_BOXFILLED",s.Box="_BOXBLANK",s.ClosedBlank="_CLOSEDBLANK",s.DatumBlank="_DATUMBLANK",s.DatumFilled="_DATUMFILLED",s.Integral="_INTEGRAL",s.ArchTick="_ARCHTICK",s))(Io||{}),Wr=(s=>(s[s.Undefined=0]="Undefined",s[s.Inches=1]="Inches",s[s.Feet=2]="Feet",s[s.Miles=3]="Miles",s[s.Millimeters=4]="Millimeters",s[s.Centimeters=5]="Centimeters",s[s.Meters=6]="Meters",s[s.Kilometers=7]="Kilometers",s[s.Microinches=8]="Microinches",s[s.Mils=9]="Mils",s[s.Yards=10]="Yards",s[s.Angstroms=11]="Angstroms",s[s.Nanometers=12]="Nanometers",s[s.Microns=13]="Microns",s[s.Decimeters=14]="Decimeters",s[s.Dekameters=15]="Dekameters",s[s.Hectometers=16]="Hectometers",s[s.Gigameters=17]="Gigameters",s[s.Astronomical=18]="Astronomical",s[s.LightYears=19]="LightYears",s[s.Parsecs=20]="Parsecs",s[s.USSurveyFeet=21]="USSurveyFeet",s[s.USSurveyInch=22]="USSurveyInch",s[s.USSurveyYard=23]="USSurveyYard",s[s.USSurveyMile=24]="USSurveyMile",s[s.Max=24]="Max",s))(Wr||{});function Fl(s){return s==4||s==5||s==6||s==7||s==12||s==13||s==14||s==15||s==16||s==17}function Bl(s){return s==1||s==2||s==3||s==8||s==9||s==10||s==21}class ae extends ne{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,i=>this.hasId(i));const e=this.normalizeName(t.name);this._recordsByName.set(e,t),this._recordsById.set(t.objectId,t)}remove(t){const e=this.normalizeName(t),i=this._recordsByName.get(e);return i?(this._recordsById.delete(i.objectId),this._recordsByName.delete(t),!0):!1}removeId(t){const e=this._recordsById.get(t);return e?(this._recordsByName.delete(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 js(this._recordsByName)}normalizeName(t){return t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbSymbolTable"),t.writeInt16(70,this.numEntries),this}}class So extends ae{constructor(t){super(t)}get modelSpace(){let t=this.getAt(K.MODEL_SPACE_NAME);return t||(t=new K,t.name=K.MODEL_SPACE_NAME,this.add(t)),t}getEntityById(t){for(const e of this.database.tables.blockTable.newIterator()){const i=e.getIdAt(t);if(i)return i}}removeEntity(t){let e=!1;for(const i of this.database.tables.blockTable.newIterator())if(i.removeEntity(t)){e=!0;break}return e}normalizeName(t){let e=t;if(K.isModelSapceName(t))e=K.MODEL_SPACE_NAME;else if(K.isPaperSapceName(t)){const i=K.PAPER_SPACE_NAME_PREFIX,r=t.substring(i.length);e=i+r}return e}}class Eo extends ae{constructor(t){super(t)}}var Po=(s=>(s[s.Center=0]="Center",s[s.Left=1]="Left",s[s.Right=2]="Right",s[s.OverFirst=3]="OverFirst",s[s.OverSecond=4]="OverSecond",s))(Po||{}),Ao=(s=>(s[s.Center=0]="Center",s[s.Above=1]="Above",s[s.Outside=2]="Outside",s[s.JIS=3]="JIS",s[s.Below=4]="Below",s))(Ao||{}),To=(s=>(s[s.Feet=0]="Feet",s[s.None=1]="None",s[s.Inch=2]="Inch",s[s.FeetAndInch=3]="FeetAndInch",s[s.Leading=4]="Leading",s[s.Trailing=8]="Trailing",s[s.LeadingAndTrailing=12]="LeadingAndTrailing",s))(To||{}),Mo=(s=>(s[s.None=0]="None",s[s.Leading=1]="Leading",s[s.Trailing=2]="Trailing",s[s.LeadingAndTrailing=3]="LeadingAndTrailing",s))(Mo||{}),vo=(s=>(s[s.Bottom=0]="Bottom",s[s.Middle=1]="Middle",s[s.Top=2]="Top",s))(vo||{});const zi=class zi extends ye{constructor(t,e){t=t||{},Rs(t,zi.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),i=this.database.tables.blockTable.getAt(this.dimldrblk),r=this.database.tables.blockTable.getAt(this.dimblk),n=this.database.tables.blockTable.getAt(this.dimblk1),a=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,i==null?void 0:i.objectId),t.writeObjectId(342,r==null?void 0:r.objectId),t.writeObjectId(343,n==null?void 0:n.objectId),t.writeObjectId(344,a==null?void 0:a.objectId),t.writeInt16(371,this.dimlwd),t.writeInt16(372,this.dimlwe),this}};zi.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:Y,dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let We=zi;class ko extends ae{constructor(t){super(t)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class Gi extends ye{constructor(t,e){t=t||{},Rs(t,{color:new J,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:new Di,linetype:"",lineWeight:1,materialId:-1}),super(t,e),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(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 Lo extends ae{constructor(t){super(t)}}class ue extends ye{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}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 No extends ae{constructor(t){super(t)}get fonts(){const t=new Set,e=r=>{if(r){const n=r.lastIndexOf(".");if(n>=0){const a=r.substring(0,n).toLowerCase();t.add(a)}else t.add(r.toLowerCase())}},i=this.newIterator();for(const r of i)e(r.fileName),e(r.bigFontFileName);return Array.from(t)}}class Hi extends ye{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 i=e.lastIndexOf(".");return i===-1?e:e.substring(0,i)}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 Oo extends ae{constructor(t){super(t)}}class Co extends ae{constructor(t){super(t)}}const Rl=()=>({center:new O,viewDirectionFromTarget:new b(0,0,1),viewTarget:new b(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:zr.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new b(0,0,0),ucsXAxis:new b(1,0,0),ucsYAxis:new b(0,1,0),orthographicType:Vr.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:Dr.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0});class Gr extends ye{constructor(){super(),this._gsView=Rl(),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 Hr extends Gr{constructor(){super(),this._circleSides=100,this._lowerLeftCorner=new O(0,0),this._upperRightCorner=new O(1,1),this._snapBase=new O(0,0),this._snapAngle=0,this._snapSpacing=new O(0,0),this._standardFlag=0,this._gridSpacing=new O,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 Fo extends ae{constructor(t){super(t)}}class wr extends ye{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 V={ACADVER:"ACADVER",ANGBASE:"ANGBASE",ANGDIR:"ANGDIR",AUNITS:"AUNITS",CECOLOR:"CECOLOR",CELTSCALE:"CELTSCALE",CELWEIGHT:"CELWEIGHT",CLAYER:"CLAYER",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",TEXTSTYLE:"TEXTSTYLE",WHITEBKCOLOR:"WHITEBKCOLOR"},zl=Object.freeze(Object.values(V)),Vi=class Vi{constructor(){this.registry=new Map,this.cache=new Map,this.events={sysVarChanged:new Z},this.registerVar({name:V.CECOLOR,type:"color",isDbVar:!0,defaultValue:new J(E.ByLayer)}),this.registerVar({name:V.CELTSCALE,type:"number",isDbVar:!0,defaultValue:-1}),this.registerVar({name:V.CELWEIGHT,type:"number",isDbVar:!0,defaultValue:je.ByLayer}),this.registerVar({name:V.CLAYER,type:"string",isDbVar:!0,defaultValue:"0"}),this.registerVar({name:V.COLORTHEME,type:"number",isDbVar:!1,defaultValue:"0"}),this.registerVar({name:V.DYNMODE,type:"number",isDbVar:!1,defaultValue:3}),this.registerVar({name:V.DYNPROMPT,type:"boolean",isDbVar:!1,defaultValue:!0}),this.registerVar({name:V.LWDISPLAY,type:"boolean",isDbVar:!0,defaultValue:!1}),this.registerVar({name:V.MEASUREMENTCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new J(E.ByColor);return t.setRGB(96,165,250),t})()}),this.registerVar({name:V.OSMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:V.PICKBOX,type:"number",isDbVar:!1,defaultValue:10}),this.registerVar({name:V.TEXTSTYLE,type:"string",isDbVar:!0,defaultValue:Y}),this.registerVar({name:V.WHITEBKCOLOR,type:"boolean",isDbVar:!1,defaultValue:!1})}static instance(){return this._instance||(this._instance=new Vi),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 i=this.getDescriptor(t);if(!i)throw new Error(`System variable ${t} not found!`);if(i.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,i){t=this.normalizeName(t);const r=this.getDescriptor(t);if(r){const n=this.getVar(t,i);if(r.type!=="string"&&(typeof e=="string"||e instanceof String)){if(r.type==="number"){const a=Number(e);if(Number.isNaN(a))throw new Error("Invalid number input!");e=a}else if(r.type==="boolean")e=this.parseBoolean(e);else if(r.type==="color"){const a=J.fromString(e);if(a==null)throw new Error("Invalid color value!");e=a}}r.isDbVar?i[t.toLowerCase()]=e:(this.cache.set(t,e),this.hasValueChanged(n,e)&&this.events.sysVarChanged.dispatch({database:i,name:t,newVal:e,oldVal:n}))}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(),i=new Set(["true","t","1","yes","y"]),r=new Set(["false","f","0","no","n"]);return i.has(e)?!0:(r.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()}};Vi._instance=null;let Bs=Vi;class Vl extends ne{constructor(){super({objectId:"0"}),this.events={dictObjetSet:new Z,dictObjectErased:new Z,entityAppended:new Z,entityModified:new Z,entityErased:new Z,layerAppended:new Z,layerModified:new Z,layerErased:new Z,openProgress:new Z},this._version=new At("AC1014"),this._angBase=0,this._angDir=0,this._aunits=Er.DecimalDegrees,this._celtscale=1,this._cecolor=new J,this._celweight=je.ByLayer,this._clayer="0",this._textstyle=Y,this._extents=new C,this._insunits=Wr.Millimeters,this._ltscale=1,this._lwdisplay=!1,this._pdmode=0,this._pdsize=0,this._osmode=0,this._maxHandle=0,this._tables={appIdTable:new Fo(this),blockTable:new So(this),dimStyleTable:new Eo(this),linetypeTable:new Lo(this),textStyleTable:new No(this),viewTable:new Oo(this),layerTable:new ko(this),viewportTable:new Co(this)},this._objects={dictionary:new As(this),imageDefinition:new As(this),layout:new yo(this),xrecord:new As(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 i=t.getAttrWithoutException("objectId");!i||t.isTemp||e&&e(i)?t.objectId=this.generateHandle():this.updateMaxHandle(i)}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(V.AUNITS,this._aunits,t??0,e=>{this._aunits=e})}get version(){return this._version}set version(t){this.updateSysVar(V.ACADVER,this._version,new At(t),e=>{this._version=e})}get insunits(){return this._insunits}set insunits(t){this.updateSysVar(V.INSUNITS,this._insunits,t??4,e=>{this._insunits=e})}get ltscale(){return this._ltscale}set ltscale(t){this.updateSysVar(V.LTSCALE,this._ltscale,t??1,e=>{this._ltscale=e})}get lwdisplay(){return this._lwdisplay}set lwdisplay(t){this.updateSysVar(V.LWDISPLAY,this._lwdisplay,t??!1,e=>{this._lwdisplay=e})}get cecolor(){return this._cecolor}set cecolor(t){this.updateSysVar(V.CECOLOR,this._cecolor,t||0,e=>{this._cecolor=e.clone()})}get celtscale(){return this._celtscale}set celtscale(t){this.updateSysVar(V.CELTSCALE,this._celtscale,t??1,e=>{this._celtscale=e})}get celweight(){return this._celweight}set celweight(t){this.updateSysVar(V.CELWEIGHT,this._celweight,t??je.ByLayer,e=>{this._celweight=e})}get clayer(){return this._clayer}set clayer(t){this.updateSysVar(V.CLAYER,this._clayer,t??"0",e=>{this._clayer=e})}get textstyle(){return this._textstyle}set textstyle(t){this.updateSysVar(V.TEXTSTYLE,this._textstyle,t??Y,e=>{this._textstyle=e})}get angBase(){return this._angBase}set angBase(t){this.updateSysVar(V.ANGBASE,this._angBase,t??0,e=>{this._angBase=e})}get angDir(){return this._angDir}set angDir(t){this.updateSysVar(V.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(V.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(V.EXTMIN,e,this._extents.min)}}get extents(){return this._extents}get pdmode(){return this._pdmode}set pdmode(t){this.updateSysVar(V.PDMODE,this._pdmode,t??0,e=>{this._pdmode=e})}get pdsize(){return this._pdsize}set pdsize(t){this.updateSysVar(V.PDSIZE,this._pdsize,t??0,e=>{this._pdsize=e})}get osmode(){return this._osmode}set osmode(t){this.updateSysVar(V.OSMODE,this._osmode,t??0,e=>{this._osmode=e})}async read(t,e,i=fs.DXF){const r=Ft.instance.get(i);if(r==null)throw new Error(`Database converter for file type '${i}' isn't registered and can can't read this file!`);this.clear(),await r.read(t,this,e&&e.minimumChunkSize||10,async(n,a,o,l)=>{if(this.events.openProgress.dispatch({database:this,percentage:n,stage:"CONVERSION",subStage:a,subStageStatus:o,data:l}),e&&e.fontLoader&&a=="FONT"&&o=="END"){const c=l||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 p;this.events.openProgress.dispatch({database:this,percentage:0,stage:"FETCH_FILE",subStageStatus:"START"});const i=await fetch(t);if(!i.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 '${i.status}'!`);const r=i.headers.get("content-length"),n=r?parseInt(r,10):null;let a=0;const o=(p=i.body)==null?void 0:p.getReader();if(!o)throw new Error("Failed to get response reader");const l=[];for(;;){const{done:g,value:y}=await o.read();if(g)break;if(l.push(y),a+=y.length,n!==null){const x=Math.round(a/n*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 g of l)c.set(g,d),d+=g.length;const m=this.getFileNameFromUri(t).toLowerCase().split(".").pop();m==="dwg"?await this.read(c.buffer,e,fs.DWG):m==="dxf"?await this.read(c.buffer,e,fs.DXF):await this.read(c.buffer,e,m),this.events.openProgress.dispatch({database:this,percentage:100,stage:"FETCH_FILE",subStageStatus:"END"})}dxfOut(t,e=16,i=this.version.name,r=!1){this.ensureDatabaseDefaults();const n=i instanceof At?i:new At(i),a=new ta({database:this,precision:e,version:n});return this.writeDxfHeaderSection(a),this.writeDxfTablesSection(a,n),this.writeDxfBlocksSection(a),this.writeDxfEntitiesSection(a),this.writeDxfObjectsSection(a),a.writeStart("EOF"),a.toString()}async regen(){await new sl(this).read(null,this,500,async(e,i,r,n)=>{this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:i,subStageStatus:r,data:n})})}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){const e=new fo(this);t.layer&&e.createDefaultLayer(),t.lineType&&e.createDefaultLineType(),t.textStyle&&e.createDefaultTextStyle(),t.dimStyle&&e.createDefaultDimStyle(),t.layout&&e.createDefaultLayout()}ensureDatabaseDefaults(){if(!this.tables.layerTable.has("0")){const e=new J;e.colorIndex=7,this.tables.layerTable.add(new Gi({name:"0",standardFlags:0,linetype:qe,lineWeight:0,isOff:!1,color:e,isPlottable:!0}))}if(this.tables.linetypeTable.has(di)||this.tables.linetypeTable.add(new ue({name:di,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(Ze)||this.tables.linetypeTable.add(new ue({name:Ze,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(qe)||this.tables.linetypeTable.add(new ue({name:qe,standardFlag:0,description:"Solid line",totalPatternLength:0})),this.tables.textStyleTable.has(Y)||this.tables.textStyleTable.add(new Hi({name:Y,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"})),this.tables.dimStyleTable.has(Y)||this.tables.dimStyleTable.add(new We({name:Y,dimtxsty:Y})),!this.tables.viewportTable.has("*Active")){const e=new Hr;e.name="*Active",this.tables.viewportTable.add(e)}const t=this.tables.blockTable.modelSpace;if(!this.objects.layout.getAt("Model")){const e=new Ds;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(cr)||this.tables.appIdTable.add(new wr(cr)),this.tables.appIdTable.has(lr)||this.tables.appIdTable.add(new wr(lr))}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,"$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 i of e.newIterator())this.writeDxfEntity(t,i);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 i of e.newIterator())this.writeDxfEntity(t,i);t.endSection()}writeDxfObjectsSection(t){t.startSection("OBJECTS");const e=this.objects.dictionary;e.ownerId="0";const i=a=>{t.writeStart("DICTIONARY"),a.dxfOut(t)},r=(a,o)=>{e.getAt(a)!==o&&e.setAt(a,o)},n=a=>{e.getAt(a)&&e.remove(a)};r("ACAD_LAYOUT",this.objects.layout),this.objects.imageDefinition.numEntries>0?r("ISM_RASTER_IMAGE_DICT",this.objects.imageDefinition):n("ISM_RASTER_IMAGE_DICT"),this.objects.xrecord.numEntries>0?r("MLIGHT_XRECORD",this.objects.xrecord):n("MLIGHT_XRECORD"),i(e),i(this.objects.layout),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())t.writeStart("LAYOUT"),o.dxfOut(t);for(const[a,o]of this.objects.imageDefinition.entries())t.writeStart("IMAGEDEF"),o.dxfOut(t);for(const[a,o]of this.objects.xrecord.entries())t.writeStart("XRECORD"),o.dxfOut(t);t.endSection()}writeDxfTable(t,e,i,r,n){const a=[...r];t.startTable(e),i.dxfOut(t);for(const o of a){if(n==="BLOCK_RECORD"&&o instanceof K){o.dxfOutBlockRecord(t);continue}t.writeStart(n),o.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._currentSpace=void 0,this._extents.makeEmpty()}updateSysVar(t,e,i,r){this.hasSysVarValueChanged(e,i)&&(r(i),this.triggerSysVarChangedEvent(t,e,i))}hasSysVarValueChanged(t,e){return t instanceof J&&e instanceof J?!t.equals(e):t instanceof At&&e instanceof At?t.value!==e.value:!Object.is(t,e)}triggerSysVarChangedEvent(t,e,i){const r=Bs.instance(),n=t.toLowerCase();r.getDescriptor(n)!=null&&r.events.sysVarChanged.dispatch({database:this,name:n,oldVal:e,newVal:i})}getFileNameFromUri(t){try{const i=new URL(t).pathname.split("/");return i[i.length-1]||""}catch{return""}}}const Bo="Load Database",Xn=3e4,Dl=12e4,jl=1024*1024;class mt extends oa{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=br.getInstance().getEntry(Bo),i=Date.now();this.progress&&await this.progress(this.data.progress.value,this.data.stage,"START");const r=await this.data.task(t);return this.progress&&(await this.progress(this.data.progress.value,this.data.stage,"END",r?r.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()-i),r}}class Ur{constructor(t={}){this.config=t}async read(t,e,i,r,n,a){const o={name:Bo,data:{total:0},format(){let u="";return Object.keys(this.data).forEach(m=>{m!=="total"&&(u+=`- ${m}: ${this.data[m]} ms
4
+ `)}),u+=`- total: ${this.data.total} ms`,u}};br.getInstance().collect(o),this.progress=r;const l={value:0},c=new ha;c.setCompleteCallback(()=>this.onFinished()),c.setErrorCallback(u=>this.onError(u)),c.addTask(new mt({stage:"START",step:1,progress:l,task:async u=>u},r)),c.addTask(new mt({stage:"PARSE",step:5,progress:l,task:async u=>await this.parse(u,n)},r)),c.addTask(new mt({stage:"FONT",step:5,progress:l,task:async u=>{const m=this.getFonts(u.model);return{model:u.model,data:m}}},r)),c.addTask(new mt({stage:"LTYPE",step:1,progress:l,task:async u=>(this.processLineTypes(u.model,e),u)},r)),c.addTask(new mt({stage:"STYLE",step:1,progress:l,task:async u=>(this.processTextStyles(u.model,e),u)},r)),c.addTask(new mt({stage:"DIMSTYLE",step:1,progress:l,task:async u=>(this.processDimStyles(u.model,e),u)},r)),c.addTask(new mt({stage:"LAYER",step:1,progress:l,task:async u=>(this.processLayers(u.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),u)},r)),c.addTask(new mt({stage:"VPORT",step:1,progress:l,task:async u=>(this.processViewports(u.model,e),u)},r)),c.addTask(new mt({stage:"HEADER",step:1,progress:l,task:async u=>{if(this.processHeader(u.model,e),a){const m=Bs.instance();for(const[p,g]of Object.entries(a))m.setVar(p,g,e)}return u}},r)),c.addTask(new mt({stage:"BLOCK_RECORD",step:5,progress:l,task:async u=>(this.processBlockTables(u.model,e),u)},r)),c.addTask(new mt({stage:"OBJECT",step:5,progress:l,task:async u=>(this.processObjects(u.model,e),e.objects.layout.numEntries===0&&e.createDefaultData({layout:!0}),u)},r)),c.addTask(new mt({stage:"BLOCK",step:5,progress:l,task:async u=>(await this.processBlocks(u.model,e),u)},r)),c.addTask(new mt({stage:"ENTITY",step:100,progress:l,task:async u=>(await this.processEntities(u.model,e,i,l,r),u)},r)),c.addTask(new mt({stage:"END",step:0,progress:l,task:async u=>u},r));const d=Date.now();await c.run(t),o.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"),Je.instance.clear())}getParserWorkerTimeout(t,e){const i=e??this.config.timeout;if(i!=null)return i;const r=Math.ceil(t.byteLength/jl),n=Xn+r*1e3;return Math.min(Dl,Math.max(Xn,n))}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,i,r,n){throw new Error("Not impelemented yet!")}}class Wl extends Gr{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 et,es,X,q,ss,Mt,be,Dt,ot,jt,vt,fe,Ie,Se,_t,Wt,is,rs,Ee,Pe,ns,as,os,wt,Gt,W,Ae,hs,M,ht,ls,lt,cs,Ht,D,ds,Ut,Te,Ji,tr,kt,us,Me,xt,Xt,Yt,$t,ps,ms,qt,ve,ke,er,gs,Le,Zt,Ne,st,Kt,bt,sr,it,ir,Qt,ft,Oe,ys,Ce,It,Jt,St,te,rr,Fe,Et;(et={})[et.None=0]="None",et[et.Anonymous=1]="Anonymous",et[et.NonConstant=2]="NonConstant",et[et.Xref=4]="Xref",et[et.XrefOverlay=8]="XrefOverlay",et[et.ExternallyDependent=16]="ExternallyDependent",et[et.ResolvedOrDependent=32]="ResolvedOrDependent",et[et.ReferencedXref=64]="ReferencedXref";(es={})[es.BYBLOCK=0]="BYBLOCK",es[es.BYLAYER=256]="BYLAYER";(X={})[X.Rotated=0]="Rotated",X[X.Aligned=1]="Aligned",X[X.Angular=2]="Angular",X[X.Diameter=3]="Diameter",X[X.Radius=4]="Radius",X[X.Angular3Point=5]="Angular3Point",X[X.Ordinate=6]="Ordinate",X[X.ReferenceIsExclusive=32]="ReferenceIsExclusive",X[X.IsOrdinateXTypeFlag=64]="IsOrdinateXTypeFlag",X[X.IsCustomTextPositionFlag=128]="IsCustomTextPositionFlag";(q={})[q.TopLeft=1]="TopLeft",q[q.TopCenter=2]="TopCenter",q[q.TopRight=3]="TopRight",q[q.MiddleLeft=4]="MiddleLeft",q[q.MiddleCenter=5]="MiddleCenter",q[q.MiddleRight=6]="MiddleRight",q[q.BottomLeft=7]="BottomLeft",q[q.BottomCenter=8]="BottomCenter",q[q.BottomRight=9]="BottomRight";(ss={})[ss.AtLeast=1]="AtLeast",ss[ss.Exact=2]="Exact";var Yn=((Mt={})[Mt.Center=0]="Center",Mt[Mt.Above=1]="Above",Mt[Mt.Outside=2]="Outside",Mt[Mt.JIS=3]="JIS",Mt[Mt.Below=4]="Below",Mt);(be={})[be.WithDimension=0]="WithDimension",be[be.AddLeader=1]="AddLeader",be[be.Independent=2]="Independent";(Dt={})[Dt.BothOutside=0]="BothOutside",Dt[Dt.ArrowFirst=1]="ArrowFirst",Dt[Dt.TextFirst=2]="TextFirst",Dt[Dt.Auto=3]="Auto";var Ue=((ot={})[ot.Feet=0]="Feet",ot[ot.None=1]="None",ot[ot.Inch=2]="Inch",ot[ot.FeetAndInch=3]="FeetAndInch",ot[ot.Leading=4]="Leading",ot[ot.Trailing=8]="Trailing",ot[ot.LeadingAndTrailing=12]="LeadingAndTrailing",ot),Gl=((jt={})[jt.None=0]="None",jt[jt.Leading=1]="Leading",jt[jt.Trailing=2]="Trailing",jt[jt.LeadingAndTrailing=3]="LeadingAndTrailing",jt),Hl=((vt={})[vt.Center=0]="Center",vt[vt.First=1]="First",vt[vt.Second=2]="Second",vt[vt.OverFirst=3]="OverFirst",vt[vt.OverSecond=4]="OverSecond",vt),Ul=((fe={})[fe.Bottom=0]="Bottom",fe[fe.Center=1]="Center",fe[fe.Top=2]="Top",fe);(Ie={})[Ie.None=0]="None",Ie[Ie.UseDrawingBackground=1]="UseDrawingBackground",Ie[Ie.Custom=2]="Custom";(Se={})[Se.Horizontal=0]="Horizontal",Se[Se.Diagonal=1]="Diagonal",Se[Se.NotStacked=2]="NotStacked";(_t={})[_t.Scientific=1]="Scientific",_t[_t.Decimal=2]="Decimal",_t[_t.Engineering=3]="Engineering",_t[_t.Architectural=4]="Architectural",_t[_t.Fractional=5]="Fractional",_t[_t.WindowDesktop=6]="WindowDesktop";(Wt={})[Wt.Decimal=0]="Decimal",Wt[Wt.DegreesMinutesSecond=1]="DegreesMinutesSecond",Wt[Wt.Gradian=2]="Gradian",Wt[Wt.Radian=3]="Radian";var Xl=((is={})[is.PatternFill=0]="PatternFill",is[is.SolidFill=1]="SolidFill",is);(rs={})[rs.NonAssociative=0]="NonAssociative",rs[rs.Associative=1]="Associative";(Ee={})[Ee.Normal=0]="Normal",Ee[Ee.Outer=1]="Outer",Ee[Ee.Ignore=2]="Ignore";(Pe={})[Pe.UserDefined=0]="UserDefined",Pe[Pe.Predefined=1]="Predefined",Pe[Pe.Custom=2]="Custom";(ns={})[ns.NotAnnotated=0]="NotAnnotated",ns[ns.Annotated=1]="Annotated";(as={})[as.Solid=0]="Solid",as[as.Gradient=1]="Gradient";(os={})[os.TwoColor=0]="TwoColor",os[os.OneColor=1]="OneColor";var Yl=((wt={})[wt.Default=0]="Default",wt[wt.External=1]="External",wt[wt.Polyline=2]="Polyline",wt[wt.Derived=4]="Derived",wt[wt.Textbox=8]="Textbox",wt[wt.Outermost=16]="Outermost",wt),ti=((Gt={})[Gt.Line=1]="Line",Gt[Gt.Circular=2]="Circular",Gt[Gt.Elliptic=3]="Elliptic",Gt[Gt.Spline=4]="Spline",Gt),$l=((W={})[W.Off=0]="Off",W[W.Solid=1]="Solid",W[W.Dashed=2]="Dashed",W[W.Dotted=3]="Dotted",W[W.ShotDash=4]="ShotDash",W[W.MediumDash=5]="MediumDash",W[W.LongDash=6]="LongDash",W[W.DoubleShortDash=7]="DoubleShortDash",W[W.DoubleMediumDash=8]="DoubleMediumDash",W[W.DoubleLongDash=9]="DoubleLongDash",W[W.DoubleMediumLongDash=10]="DoubleMediumLongDash",W[W.SparseDot=11]="SparseDot",W);$l.Off;(Ae={})[Ae.Standard=-3]="Standard",Ae[Ae.ByLayer=-2]="ByLayer",Ae[Ae.ByBlock=-1]="ByBlock";(hs={})[hs.English=0]="English",hs[hs.Metric=1]="Metric";(M={})[M.PERSPECTIVE_MODE=1]="PERSPECTIVE_MODE",M[M.FRONT_CLIPPING=2]="FRONT_CLIPPING",M[M.BACK_CLIPPING=4]="BACK_CLIPPING",M[M.UCS_FOLLOW=8]="UCS_FOLLOW",M[M.FRONT_CLIP_NOT_AT_EYE=16]="FRONT_CLIP_NOT_AT_EYE",M[M.UCS_ICON_VISIBILITY=32]="UCS_ICON_VISIBILITY",M[M.UCS_ICON_AT_ORIGIN=64]="UCS_ICON_AT_ORIGIN",M[M.FAST_ZOOM=128]="FAST_ZOOM",M[M.SNAP_MODE=256]="SNAP_MODE",M[M.GRID_MODE=512]="GRID_MODE",M[M.ISOMETRIC_SNAP_STYLE=1024]="ISOMETRIC_SNAP_STYLE",M[M.HIDE_PLOT_MODE=2048]="HIDE_PLOT_MODE",M[M.K_ISO_PAIR_TOP=4096]="K_ISO_PAIR_TOP",M[M.K_ISO_PAIR_RIGHT=8192]="K_ISO_PAIR_RIGHT",M[M.VIEWPORT_ZOOM_LOCKING=16384]="VIEWPORT_ZOOM_LOCKING",M[M.UNUSED=32768]="UNUSED",M[M.NON_RECTANGULAR_CLIPPING=65536]="NON_RECTANGULAR_CLIPPING",M[M.VIEWPORT_OFF=131072]="VIEWPORT_OFF",M[M.GRID_BEYOND_DRAWING_LIMITS=262144]="GRID_BEYOND_DRAWING_LIMITS",M[M.ADAPTIVE_GRID_DISPLAY=524288]="ADAPTIVE_GRID_DISPLAY",M[M.SUBDIVISION_BELOW_SPACING=1048576]="SUBDIVISION_BELOW_SPACING",M[M.GRID_FOLLOWS_WORKPLANE=2097152]="GRID_FOLLOWS_WORKPLANE";(ht={})[ht.OPTIMIZED_2D=0]="OPTIMIZED_2D",ht[ht.WIREFRAME=1]="WIREFRAME",ht[ht.HIDDEN_LINE=2]="HIDDEN_LINE",ht[ht.FLAT_SHADED=3]="FLAT_SHADED",ht[ht.GOURAUD_SHADED=4]="GOURAUD_SHADED",ht[ht.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",ht[ht.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME";(ls={})[ls.UCS_UNCHANGED=0]="UCS_UNCHANGED",ls[ls.HAS_OWN_UCS=1]="HAS_OWN_UCS";(lt={})[lt.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",lt[lt.TOP=1]="TOP",lt[lt.BOTTOM=2]="BOTTOM",lt[lt.FRONT=3]="FRONT",lt[lt.BACK=4]="BACK",lt[lt.LEFT=5]="LEFT",lt[lt.RIGHT=6]="RIGHT";(cs={})[cs.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",cs[cs.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS";(Ht={})[Ht.ByLayer=0]="ByLayer",Ht[Ht.ByBlock=1]="ByBlock",Ht[Ht.ByDictionaryDefault=2]="ByDictionaryDefault",Ht[Ht.ByObject=3]="ByObject";(D={})[D.NotAllowed=0]="NotAllowed",D[D.AllowErase=1]="AllowErase",D[D.AllowTransform=2]="AllowTransform",D[D.AllowChangeColor=4]="AllowChangeColor",D[D.AllowChangeLayer=8]="AllowChangeLayer",D[D.AllowChangeLinetype=16]="AllowChangeLinetype",D[D.AllowChangeLinetypeScale=32]="AllowChangeLinetypeScale",D[D.AllowChangeVisibility=64]="AllowChangeVisibility",D[D.AllowClone=128]="AllowClone",D[D.AllowChangeLineweight=256]="AllowChangeLineweight",D[D.AllowChangePlotStyleName=512]="AllowChangePlotStyleName",D[D.AllowAllExceptClone=895]="AllowAllExceptClone",D[D.AllowAll=1023]="AllowAll",D[D.DisableProxyWarning=1024]="DisableProxyWarning",D[D.R13FormatProxy=32768]="R13FormatProxy";function L(s,t,e){return s.code===t&&(e==null||s.value===e)}function me(s){let t={};s.rewind();let e=s.next(),i=e.code;if(t.x=e.value,(e=s.next()).code!==i+10)throw Error("Expected code for point value to be 20 but got "+e.code+".");return t.y=e.value,(e=s.next()).code!==i+20?s.rewind():t.z=e.value,t}let Ws=Symbol();function S(s,t){return(e,i,r)=>{let n=function(l,c=!1){return l.reduce((d,u)=>{u.pushContext&&d.push({});let m=d[d.length-1];for(let p of typeof u.code=="number"?[u.code]:u.code){let g=m[p]??(m[p]=[]);u.isMultiple&&g.length,g.push(u)}return d},[{}])}(s,i.debug),a=!1,o=n.length-1;for(;!L(e,0,"EOF");){let l=function(x,w,P){return x.find((I,k)=>{var A;return k>=P&&((A=I[w])==null?void 0:A.length)})}(n,e.code,o),c=l==null?void 0:l[e.code],d=c==null?void 0:c[c.length-1];if(!l||!d){i.rewind();break}d.isMultiple||l[e.code].pop();let{name:u,parser:m,isMultiple:p,isReducible:g}=d,y=m==null?void 0:m(e,i,r);if(y===Ws){i.rewind();break}if(u){let[x,w]=ql(r,u);p&&!g?(Object.prototype.hasOwnProperty.call(x,w)||(x[w]=[]),x[w].push(y)):x[w]=y}d.pushContext&&(o-=1),a=!0,e=i.next()}return t&&Object.setPrototypeOf(r,t),a}}function ql(s,t){let e=t.split(".");if(!e.length)throw Error("[parserGenerator::getObjectByPath] Invalid empty path");let i=s;for(let r=0;r<e.length-1;++r){let n=nr(e[r]),a=nr(e[r+1]);Object.prototype.hasOwnProperty.call(i,n)||(typeof a=="number"?i[n]=[]:i[n]={}),i=i[n]}return[i,nr(e[e.length-1])]}function nr(s){let t=Number.parseInt(s);return Number.isNaN(t)?s:t}function h({value:s}){return s}function _(s,t){return me(t)}function v({value:s}){return!!s}function Zl({value:s}){return s.trim()}let Kl=[{code:281,name:"isEntity",parser:v},{code:280,name:"wasProxy",parser:v},{code:91,name:"instanceCount",parser:h},{code:90,name:"proxyFlag",parser:h},{code:3,name:"appName",parser:h},{code:2,name:"cppClassName",parser:h},{code:1,name:"name",parser:h}],Ql=S(Kl),Jl=[{code:0,name:"classes",isMultiple:!0,parser(s,t){if(s.value!=="CLASS")return Ws;s=t.next();let e={};return Ql(s,t,e),e}}],tc=S(Jl);(ds={})[ds.RayTrace=0]="RayTrace",ds[ds.ShadowMap=1]="ShadowMap";function zt(s,t,e){for(;L(s,102);){var i;let r=s.value;if(s=t.next(),!r.startsWith("{")){t.debug,function(a,o){for(;!L(a,102)&&!L(a,0,"EOF");)a=o.next()}(s,t),s=t.next();continue}let n=r.slice(1).trim();e.extensions??(e.extensions={}),(i=e.extensions)[n]??(i[n]=[]),function(a,o,l){for(;!L(a,102,"}")&&!L(a,0,"EOF");)l.push(a),a=o.next()}(s,t,e.extensions[n]),s=t.next()}t.rewind()}let ec=[{code:1001,name:"xdata",isMultiple:!0,parser:Ro}],sc=new Set([1010,1011,1012,1013]);function Ro(s,t){var r;if(!L(s,1001))throw Error("XData must starts with code 1001");let e={appName:s.value,value:[]};s=t.next();let i=[e.value];for(;!L(s,0,"EOF")&&!L(s,1001)&&s.code>=1e3;){let n=i[i.length-1];if(s.code===1002){s.value==="{"?i.push([]):(i.pop(),(r=i[i.length-1])==null||r.push(n)),s=t.next();continue}sc.has(s.code)?n.push(me(t)):n.push(s.value),s=t.next()}return t.rewind(),e}(Ut={})[Ut.CAST_AND_RECEIVE=0]="CAST_AND_RECEIVE",Ut[Ut.CAST=1]="CAST",Ut[Ut.RECEIVE=2]="RECEIVE",Ut[Ut.IGNORE=3]="IGNORE";let z=[...ec,{code:284,name:"shadowMode",parser:h},{code:390,name:"plotStyleHardId",parser:h},{code:380,name:"plotStyleType",parser:h},{code:440,name:"transparency",parser:h},{code:430,name:"colorName",parser:h},{code:420,name:"color",parser:h},{code:310,name:"proxyEntity",isMultiple:!0,isReducible:!0,parser:(s,t,e)=>(e.proxyEntity??"")+s.value},{code:[92,160],name:"proxyByte",parser:h},{code:60,name:"isVisible",parser:v},{code:48,name:"lineTypeScale",parser:h},{code:370,name:"lineweight",parser:h},{code:62,name:"colorIndex",parser:h},{code:347,name:"materialObjectHardId",parser:h},{code:6,name:"lineType",parser:h},{code:8,name:"layer",parser:h},{code:410,name:"layoutTabName",parser:h},{code:67,name:"isInPaperSpace",parser:v},{code:100},{code:330,name:"ownerBlockRecordSoftId",parser:h},{code:102,parser:zt},{code:102,parser:zt},{code:102,parser:zt},{code:5,name:"handle",parser:h}];function Ui(s){return[{code:3,name:s,parser:(t,e,i)=>(i._code3text=(i._code3text??"")+t.value,i._code3text+(i._code1text??"")),isMultiple:!0,isReducible:!0},{code:1,name:s,parser:(t,e,i)=>(i._code1text=t.value,(i._code3text??"")+i._code1text)}]}function zo(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let ic={extrusionDirection:{x:0,y:0,z:1}},rc=[{code:210,name:"extrusionDirection",parser:_},{code:51,name:"endAngle",parser:h},{code:50,name:"startAngle",parser:h},{code:100,name:"subclassMarker",parser:h},{code:40,name:"radius",parser:h},{code:10,name:"center",parser:_},{code:39,name:"thickness",parser:h},{code:100},...z];class Vo{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){zo(this,"parser",S(rc,ic))}}zo(Vo,"ForEntityName","ARC");(Te={})[Te.BeforeText=0]="BeforeText",Te[Te.AboveText=1]="AboveText",Te[Te.None=2]="None";let Xr=[{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:Yn.Above,defaultValueImperial:Yn.Center},{name:"DIMZIN",code:78,defaultValue:Ue.Trailing,defaultValueImperial:Ue.Feet},{name:"DIMAZIN",code:79,defaultValue:Gl.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:Hl.Center},{name:"DIMSD1",code:281,defaultValue:0},{name:"DIMSD2",code:282,defaultValue:0},{name:"DIMTOLJ",code:283,defaultValue:Ul.Center},{name:"DIMTZIN",code:284,defaultValue:Ue.Trailing,defaultValueImperial:Ue.Feet},{name:"DIMALTZ",code:285,defaultValue:Ue.Trailing},{name:"DIMALTTZ",code:286,defaultValue:Ue.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}],Do=[{code:3,name:"styleName",parser:h},{code:210,name:"extrusionDirection",parser:_},{code:51,name:"ocsRotation",parser:h},{code:53,name:"textRotation",parser:h},{code:1,name:"text",parser:h},{code:42,name:"measurement",parser:h},{code:72,name:"textLineSpacingStyle",parser:h},{code:71,name:"attachmentPoint",parser:h},{code:70,name:"dimensionType",parser:h},{code:11,name:"textPoint",parser:_},{code:10,name:"definitionPoint",parser:_},{code:2,name:"name",parser:h},{code:280,name:"version",parser:h},{code:100}],nc=[{code:100},{code:52,name:"obliqueAngle",parser:h},{code:50,name:"rotationAngle",parser:h},{code:14,name:"subDefinitionPoint2",parser:_},{code:13,name:"subDefinitionPoint1",parser:_},{code:12,name:"insertionPoint",parser:_},{code:100,name:"subclassMarker",parser:h}],ac=[{code:16,name:"arcPoint",parser:_},{code:15,name:"centerPoint",parser:_},{code:14,name:"subDefinitionPoint2",parser:_},{code:13,name:"subDefinitionPoint1",parser:_},{code:100,name:"subclassMarker",parser:h}],oc=[{code:14,name:"subDefinitionPoint2",parser:_},{code:13,name:"subDefinitionPoint1",parser:_},{code:100,name:"subclassMarker",parser:h}],hc=[{code:40,name:"leaderLength",parser:h},{code:15,name:"subDefinitionPoint",parser:_},{code:100,name:"subclassMarker",parser:h}],lc=[{code:100,parser(s,t,e){let i=function(r){switch(r){case"AcDbAlignedDimension":return S(nc);case"AcDb3PointAngularDimension":case"AcDb2LineAngularDimension":return S(ac);case"AcDbOrdinateDimension":return S(oc);case"AcDbRadialDimension":case"AcDbDiametricDimension":return S(hc)}return null}(s.value);if(!i)return Ws;i(s,t,e)},pushContext:!0},...Xr.map(s=>({...s,parser:h})),...Do,...z];class ri{parseEntity(t,e){let i={};return S(lc)(e,t,i),i}}(Ji="ForEntityName")in ri?Object.defineProperty(ri,Ji,{value:"DIMENSION",enumerable:!0,configurable:!0,writable:!0}):ri[Ji]="DIMENSION";let cc=[{code:73},{code:17,name:"leaderEnd",parser:_},{code:16,name:"leaderStart",parser:_},{code:71,name:"hasLeader",parser:v},{code:41,name:"endAngle",parser:h},{code:40,name:"startAngle",parser:h},{code:70,name:"isPartial",parser:v},{code:15,name:"centerPoint",parser:_},{code:14,name:"xline2Point",parser:_},{code:13,name:"xline1Point",parser:_},{code:100,name:"subclassMarker",parser:h,pushContext:!0},...Xr.map(s=>({...s,parser:h})),...Do,...z];class ni{parseEntity(t,e){let i={};return S(cc)(e,t,i),i}}(tr="ForEntityName")in ni?Object.defineProperty(ni,tr,{value:"ARC_DIMENSION",enumerable:!0,configurable:!0,writable:!0}):ni[tr]="ARC_DIMENSION";(kt={})[kt.NONE=0]="NONE",kt[kt.INVISIBLE=1]="INVISIBLE",kt[kt.CONSTANT=2]="CONSTANT",kt[kt.VERIFICATION_REQUIRED=4]="VERIFICATION_REQUIRED",kt[kt.PRESET=8]="PRESET";(us={})[us.MULTILINE=2]="MULTILINE",us[us.CONSTANT_MULTILINE=4]="CONSTANT_MULTILINE";(Me={})[Me.NONE=0]="NONE",Me[Me.MIRRORED_X=2]="MIRRORED_X",Me[Me.MIRRORED_Y=4]="MIRRORED_Y";var dc=((xt={})[xt.LEFT=0]="LEFT",xt[xt.CENTER=1]="CENTER",xt[xt.RIGHT=2]="RIGHT",xt[xt.ALIGNED=3]="ALIGNED",xt[xt.MIDDLE=4]="MIDDLE",xt[xt.FIT=5]="FIT",xt),uc=((Xt={})[Xt.BASELINE=0]="BASELINE",Xt[Xt.BOTTOM=1]="BOTTOM",Xt[Xt.MIDDLE=2]="MIDDLE",Xt[Xt.TOP=3]="TOP",Xt);function jo(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let Wo={thickness:0,rotation:0,xScale:1,obliqueAngle:0,styleName:"STANDARD",generationFlag:0,halign:dc.LEFT,valign:uc.BASELINE,extrusionDirection:{x:0,y:0,z:1}},Go=[{code:73,name:"valign",parser:h},{code:100},{code:210,name:"extrusionDirection",parser:_},{code:11,name:"endPoint",parser:_},{code:72,name:"valign",parser:h},{code:72,name:"halign",parser:h},{code:71,name:"generationFlag",parser:h},{code:7,name:"styleName",parser:h},{code:51,name:"obliqueAngle",parser:h},{code:41,name:"xScale",parser:h},{code:50,name:"rotation",parser:h},{code:1,name:"text",parser:h},{code:40,name:"textHeight",parser:h},{code:10,name:"startPoint",parser:_},{code:39,name:"thickness",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class Ho{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){jo(this,"parser",S(Go,Wo))}}function Uo(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}jo(Ho,"ForEntityName","TEXT");let pc={...Wo},mc=[{code:2},{code:40,name:"annotationScale",parser:h},{code:10,name:"alignmentPoint",parser:_},{code:340,name:"secondaryAttributesHardIds",isMultiple:!0,parser:h},{code:70,name:"numberOfSecondaryAttributes",parser:h},{code:70,name:"isReallyLocked",parser:v},{code:70,name:"mtextFlag",parser:h},{code:280,name:"isDuplicatedRecord",parser:v},{code:100},{code:280,name:"isLocked",parser:v},{code:74,name:"valign",parser:h},{code:73},{code:70,name:"attributeFlag",parser:h},{code:2,name:"tag",parser:h},{code:3,name:"prompt",parser:h},{code:280},{code:100,name:"subclassMarker",parser:h},...Go.slice(2)];class Xo{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Uo(this,"parser",S(mc,pc))}}function gc(s,t){let e={};for(let i of s){let r=t(i);r!=null&&(e[r]??(e[r]=[]),e[r].push(i))}return e}function*Bi(s,t=1/0,e=1){for(let i=s;i!==t;i+=e)yield i}function $n(s){return{x:s.x??0,y:s.y??0,z:s.z??0}}Uo(Xo,"ForEntityName","ATTDEF");var yc=[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 _c(s){return yc[s]}function wc(s){s.rewind();let t=s.next();if(t.code!==101)throw Error("Bad call for skipEmbeddedObject()");do t=s.next();while(t.code!==0);s.rewind()}function xc(s,t,e){if(L(t,102))return zt(t,e,s),!0;switch(t.code){case 0:s.type=t.value;break;case 5:s.handle=t.value;break;case 330:s.ownerBlockRecordSoftId=t.value;break;case 67:s.isInPaperSpace=!!t.value;break;case 8:s.layer=t.value;break;case 6:s.lineType=t.value;break;case 347:s.materialObjectHardId=t.value;break;case 62:s.colorIndex=t.value,s.color=_c(Math.abs(t.value));break;case 370:s.lineweight=t.value;break;case 48:s.lineTypeScale=t.value;break;case 60:s.isVisible=!!t.value;break;case 92:s.proxyByte=t.value;break;case 310:s.proxyEntity=t.value;break;case 100:break;case 420:s.color=t.value;break;case 430:s.transparency=t.value;break;case 390:s.plotStyleHardId=t.value;break;case 284:s.shadowMode=t.value;break;case 1001:(s.xdata??(s.xdata=[])).push(Ro(t,e));break;default:return!1}return!0}function Yo(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let bc={textStyle:"STANDARD",extrusionDirection:{x:0,y:0,z:1},rotation:0},ai=[{code:46,name:"annotationHeight",parser:h},{code:101,parser(s,t){wc(t)}},{code:50,name:"columnHeight",parser:h},{code:49,name:"columnGutter",parser:h},{code:48,name:"columnWidth",parser:h},{code:79,name:"columnAutoHeight",parser:h},{code:78,name:"columnFlowReversed",parser:h},{code:76,name:"columnCount",parser:h},{code:75,name:"columnType",parser:h},{code:441,name:"backgroundFillTransparency",parser:h},{code:63,name:"backgroundFillColor",parser:h},{code:45,name:"fillBoxScale",parser:h},{code:[...Bi(430,440)],name:"backgroundColor",parser:h},{code:[...Bi(420,430)],name:"backgroundColor",parser:h},{code:90,name:"backgroundFill",parser:h},{code:44,name:"lineSpacing",parser:h},{code:73,name:"lineSpacingStyle",parser:h},{code:50,name:"rotation",parser:h},{code:43},{code:42},{code:11,name:"direction",parser:_},{code:210,name:"extrusionDirection",parser:_},{code:7,name:"styleName",parser:h},...Ui("text"),{code:72,name:"drawingDirection",parser:h},{code:71,name:"attachmentPoint",parser:h},{code:41,name:"width",parser:h},{code:40,name:"height",parser:h},{code:10,name:"insertionPoint",parser:_},{code:100,name:"subclassMarker",parser:h},...z];class $o{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Yo(this,"parser",S(ai,bc))}}function qo(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Yo($o,"ForEntityName","MTEXT");let fc={thickness:0,rotation:0,scale:1,obliqueAngle:0,textStyle:"STANDARD",textGenerationFlag:0,horizontalJustification:0,verticalJustification:0,extrusionDirection:{x:0,y:0,z:1}},Ic=[...ai.slice(ai.findIndex(({name:s})=>s==="columnType"),ai.findIndex(({name:s})=>s==="subclassMarker")+1),{code:100},{code:0,parser(s){if(!L(s,0,"MTEXT"))return Ws}},{code:2,name:"definitionTag",parser:h},{code:40,name:"annotationScale",parser:h},{code:10,name:"alignmentPoint",parser:_},{code:340,name:"secondaryAttributesHardId",parser:h},{code:70,name:"numberOfSecondaryAttributes",parser:h},{code:70,name:"isReallyLocked",parser:v},{code:70,name:"mtextFlag",parser:h},{code:280,name:"isDuplicatedEntriesKeep",parser:v},{code:100},{code:280,name:"lockPositionFlag",parser:v},{code:210,name:"extrusionDirection",parser:_},{code:11,name:"alignmentPoint",parser:_},{code:74,name:"verticalJustification",parser:h},{code:72,name:"horizontalJustification",parser:h},{code:71,name:"textGenerationFlag",parser:h},{code:7,name:"textStyle",parser:h},{code:51,name:"obliqueAngle",parser:h},{code:41,name:"scale",parser:h},{code:50,name:"rotation",parser:h},{code:73},{code:70,name:"attributeFlag",parser:h},{code:2,name:"tag",parser:h},{code:280},{code:100,name:"subclassMarker",parser:h},{code:1,name:"text",parser:h},{code:40,name:"textHeight",parser:h},{code:10,name:"startPoint",parser:_},{code:39,name:"thickness",parser:h},{code:100},...z];class Zo{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){qo(this,"parser",S(Ic,fc))}}function Ko(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}qo(Zo,"ForEntityName","ATTRIB");let Sc=[...Ui("data"),{code:70,name:"version",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class Qo{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Ko(this,"parser",S(Sc))}}function Jo(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Ko(Qo,"ForEntityName","BODY");let Ec={thickness:0,extrusionDirection:{x:0,y:0,z:1}},Pc=[{code:210,name:"extrusionDirection",parser:_},{code:40,name:"radius",parser:h},{code:10,name:"center",parser:_},{code:39,name:"thickness",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class th{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Jo(this,"parser",S(Pc,Ec))}}function eh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Jo(th,"ForEntityName","CIRCLE");let Ac={extrusionDirection:{x:0,y:0,z:1}},Tc=[{code:42,name:"endAngle",parser:h},{code:41,name:"startAngle",parser:h},{code:40,name:"axisRatio",parser:h},{code:210,name:"extrusionDirection",parser:_},{code:11,name:"majorAxisEndPoint",parser:_},{code:10,name:"center",parser:_},{code:100,name:"subclassMarker",parser:h},...z];class sh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){eh(this,"parser",S(Tc,Ac))}}function ih(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}eh(sh,"ForEntityName","ELLIPSE");let Mc=[{code:13,name:"vertices.3",parser:_},{code:12,name:"vertices.2",parser:_},{code:11,name:"vertices.1",parser:_},{code:10,name:"vertices.0",parser:_},{code:100,name:"subclassMarker",parser:h},...z];class rh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){ih(this,"parser",S(Mc))}}ih(rh,"ForEntityName","3DFACE");(Yt={})[Yt.First=1]="First",Yt[Yt.Second=2]="Second",Yt[Yt.Third=4]="Third",Yt[Yt.Fourth=8]="Fourth";let nh=[{code:330,name:"sourceBoundaryObjects",parser:h,isMultiple:!0},{code:97,name:"numberOfSourceBoundaryObjects",parser:h}],vc=[{code:11,name:"end",parser:_},{code:10,name:"start",parser:_}],kc=[{code:73,name:"isCCW",parser:v},{code:51,name:"endAngle",parser:h},{code:50,name:"startAngle",parser:h},{code:40,name:"radius",parser:h},{code:10,name:"center",parser:_}],Lc=[{code:73,name:"isCCW",parser:v},{code:51,name:"endAngle",parser:h},{code:50,name:"startAngle",parser:h},{code:40,name:"lengthOfMinorAxis",parser:h},{code:11,name:"end",parser:_},{code:10,name:"center",parser:_}],Nc=[{code:13,name:"endTangent",parser:_},{code:12,name:"startTangent",parser:_},{code:11,name:"fitDatum",isMultiple:!0,parser:_},{code:97,name:"numberOfFitData",parser:h},{code:10,name:"controlPoints",isMultiple:!0,parser(s,t){let e={...me(t),weight:1};return(s=t.next()).code===42?e.weight=s.value:t.rewind(),e}},{code:40,name:"knots",isMultiple:!0,parser:h},{code:96,name:"numberOfControlPoints",parser:h},{code:95,name:"numberOfKnots",parser:h},{code:74,name:"isPeriodic",parser:v},{code:73,name:"splineFlag",parser:h},{code:94,name:"degree",parser:h}],Oc={[ti.Line]:vc,[ti.Circular]:kc,[ti.Elliptic]:Lc,[ti.Spline]:Nc},Cc=[...nh,{code:72,name:"edges",parser(s,t){let e={type:s.value},i=S(Oc[e.type]);if(!i)throw Error(`Invalid edge type ${e.type}`);return i(s=t.next(),t,e),e},isMultiple:!0},{code:93,name:"numberOfEdges",parser:h}],Fc=[...nh,{code:10,name:"vertices",parser(s,t){let e={...me(t),bulge:0};return(s=t.next()).code===42?e.bulge=s.value:t.rewind(),e},isMultiple:!0},{code:93,name:"numberOfVertices",parser:h},{code:73,name:"isClosed",parser:v},{code:72,name:"hasBulge",parser:v}];function Bc(s,t){let e={boundaryPathTypeFlag:s.value},i=e.boundaryPathTypeFlag&Yl.Polyline;return s=t.next(),i?S(Fc)(s,t,e):S(Cc)(s,t,e),e}let Rc=[{code:49,name:"dashLengths",parser:h,isMultiple:!0},{code:79,name:"numberOfDashLengths",parser:h},{code:45,name:"offset",parser:qn},{code:43,name:"base",parser:qn},{code:53,name:"angle",parser:h}];function qn(s,t){let e=s.code+1,i={x:s.value,y:1};return(s=t.next()).code===e?i.y=s.value:t.rewind(),i}function zc(s,t){let e={};return S(Rc)(s,t,e),e}function ah(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let Vc={extrusionDirection:{x:0,y:0,z:1},gradientRotation:0,colorTint:0},Dc=[{code:470},{code:463},{code:462,name:"colorTint",parser:h},{code:461,name:"gradientDefinition",parser:h},{code:460,name:"gradientRotation",parser:h},{code:453,name:"numberOfColors",parser:h},{code:452,name:"gradientColorFlag",parser:h},{code:451},{code:450,name:"gradientFlag",parser:h},{code:10,name:"seedPoints",parser:_,isMultiple:!0},{code:99},{code:11,name:"offsetVector",parser:_},{code:98,name:"numberOfSeedPoints",parser:h},{code:47,name:"pixelSize",parser:h},{code:53,name:"definitionLines",parser:zc,isMultiple:!0},{code:78,name:"numberOfDefinitionLines",parser:h},{code:77,name:"isDouble",parser:v},{code:73,name:"isAnnotated",parser:v},{code:41,name:"patternScale",parser:h},{code:52,name:"patternAngle",parser:h},{code:76,name:"patternType",parser:h},{code:75,name:"hatchStyle",parser:h},{code:92,name:"boundaryPaths",parser:Bc,isMultiple:!0},{code:91,name:"numberOfBoundaryPaths",parser:h},{code:71,name:"associativity",parser:h},{code:63,name:"patternFillColor",parser:h},{code:70,name:"solidFill",parser:h},{code:2,name:"patternName",parser:h},{code:210,name:"extrusionDirection",parser:_},{code:10,name:"elevationPoint",parser:_},{code:100,name:"subclassMarker",parser:h,pushContext:!0},...z];class oh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){ah(this,"parser",S(Dc,Vc))}}function hh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}ah(oh,"ForEntityName","HATCH");let jc={brightness:50,contrast:50,fade:0,clippingBoundaryPath:[]},Wc=[{code:290,name:"clipMode",parser:h},{code:14,name:"clippingBoundaryPath",isMultiple:!0,parser:_},{code:91,name:"countBoundaryPoints",parser:h},{code:71,name:"clippingBoundaryType",parser:h},{code:360,name:"imageDefReactorHandle",parser:h},{code:283,name:"fade",parser:h},{code:282,name:"contrast",parser:h},{code:281,name:"brightness",parser:h},{code:280,name:"isClipped",parser:v},{code:70,name:"flags",parser:h},{code:340,name:"imageDefHandle",parser:h},{code:13,name:"imageSize",parser:_},{code:12,name:"vPixel",parser:_},{code:11,name:"uPixel",parser:_},{code:10,name:"position",parser:_},{code:90,name:"version",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class lh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){hh(this,"parser",S(Wc,jc))}}hh(lh,"ForEntityName","IMAGE");($t={})[$t.ShowImage=1]="ShowImage",$t[$t.ShowImageWhenNotAlignedWithScreen=2]="ShowImageWhenNotAlignedWithScreen",$t[$t.UseClippingBoundary=4]="UseClippingBoundary",$t[$t.TransparencyIsOn=8]="TransparencyIsOn";(ps={})[ps.Rectangular=1]="Rectangular",ps[ps.Polygonal=2]="Polygonal";(ms={})[ms.Outside=0]="Outside",ms[ms.Inside=1]="Inside";function ch(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let Gc={xScale:1,yScale:1,zScale:1,rotation:0,columnCount:0,rowCount:0,columnSpacing:0,rowSpacing:0,extrusionDirection:{x:0,y:0,z:1}},Hc=[{code:210,name:"extrusionDirection",parser:_},{code:45,name:"rowSpacing",parser:h},{code:44,name:"columnSpacing",parser:h},{code:71,name:"rowCount",parser:h},{code:70,name:"columnCount",parser:h},{code:50,name:"rotation",parser:h},{code:43,name:"zScale",parser:h},{code:42,name:"yScale",parser:h},{code:41,name:"xScale",parser:h},{code:10,name:"insertionPoint",parser:_},{code:2,name:"name",parser:h},{code:66,name:"isVariableAttributes",parser:v},{code:100,name:"subclassMarker",parser:h},...z];class dh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){ch(this,"parser",S(Hc,Gc))}}function uh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}ch(dh,"ForEntityName","INSERT");let Uc={isArrowheadEnabled:!0},Xc=[{code:213,name:"offsetFromAnnotation",parser:_},{code:212,name:"offsetFromBlock",parser:_},{code:211,name:"horizontalDirection",parser:_},{code:210,name:"normal",parser:_},{code:340,name:"associatedAnnotation",parser:h},{code:77,name:"byBlockColor",parser:h},{code:10,name:"vertices",parser:_,isMultiple:!0},{code:76,name:"numberOfVertices",parser:h},{code:41,name:"textWidth",parser:h},{code:40,name:"textHeight",parser:h},{code:75,name:"isHooklineExists",parser:v},{code:74,name:"isHooklineSameDirection",parser:v},{code:73,name:"leaderCreationFlag",parser:h},{code:72,name:"isSpline",parser:v},{code:71,name:"isArrowheadEnabled",parser:v},{code:3,name:"styleName",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class ph{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){uh(this,"parser",S(Xc,Uc))}}uh(ph,"ForEntityName","LEADER");(qt={})[qt.TextAnnotation=0]="TextAnnotation",qt[qt.ToleranceAnnotation=1]="ToleranceAnnotation",qt[qt.BlockReferenceAnnotation=2]="BlockReferenceAnnotation",qt[qt.NoAnnotation=3]="NoAnnotation";function mh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let Yc={thickness:0,extrusionDirection:{x:0,y:0,z:1}},$c=[{code:210,name:"extrusionDirection",parser:_},{code:11,name:"endPoint",parser:_},{code:10,name:"startPoint",parser:_},{code:39,name:"thickness",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class gh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){mh(this,"parser",S($c,Yc))}}function yh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}mh(gh,"ForEntityName","LINE");let qc=[{code:280,name:"shadowMapSoftness",parser:h},{code:91,name:"shadowMapSize",parser:h},{code:73,name:"shadowType",parser:h},{code:293,name:"isShadowCast",parser:v},{code:51,name:"falloffAngle",parser:h},{code:50,name:"hotspotAngle",parser:h},{code:42,name:"limitEnd",parser:h},{code:41,name:"limitStart",parser:h},{code:292,name:"isAttenuationLimited",parser:v},{code:72,name:"attenuationType",parser:h},{code:11,name:"target",parser:_},{code:10,name:"position",parser:_},{code:40,name:"intensity",parser:h},{code:291,name:"isPlotGlyph",parser:v},{code:290,name:"isOn",parser:v},{code:421,name:"lightColorInstance",parser:h},{code:63,name:"lightColorIndex",parser:h},{code:70,name:"lightType",parser:h},{code:1,name:"name",parser:h},{code:90,name:"version",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class _h{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){yh(this,"parser",S(qc))}}yh(_h,"ForEntityName","LIGHT");(ve={})[ve.Distant=1]="Distant",ve[ve.Point=2]="Point",ve[ve.Spot=3]="Spot";(ke={})[ke.None=0]="None",ke[ke.InverseLinear=1]="InverseLinear",ke[ke.InverseSquare=2]="InverseSquare";let Zc={flag:0,elevation:0,thickness:0,extrusionDirection:{x:0,y:0,z:1},vertices:[]},Kc={bulge:0},Qc=[{code:42,name:"bulge",parser:h},{code:41,name:"endWidth",parser:h},{code:40,name:"startWidth",parser:h},{code:91,name:"id",parser:h},{code:20,name:"y",parser:h},{code:10,name:"x",parser:h}],Jc=[{code:210,name:"extrusionDirection",parser:_},{code:10,name:"vertices",isMultiple:!0,parser(s,t){let e={};return S(Qc,Kc)(s,t,e),e}},{code:39,name:"thickness",parser:h},{code:38,name:"elevation",parser:h},{code:43,name:"constantWidth",parser:h},{code:70,name:"flag",parser:h},{code:90,name:"numberOfVertices",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class oi{parseEntity(t,e){let i={};return S(Jc,Zc)(e,t,i),i}}(er="ForEntityName")in oi?Object.defineProperty(oi,er,{value:"LWPOLYLINE",enumerable:!0,configurable:!0,writable:!0}):oi[er]="LWPOLYLINE";(gs={})[gs.IS_CLOSED=1]="IS_CLOSED",gs[gs.PLINE_GEN=128]="PLINE_GEN";function wh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let td=[{code:90,name:"overridenSubEntityCount",parser:h},{code:140,name:"edgeCreaseWeights",parser:h,isMultiple:!0},{code:95,name:"edgeCreaseCount",parser:h},{code:94,parser(s,t,e){e.edgeCount=s.value,e.edgeIndices=[];for(let i=0;i<e.edgeCount;++i){let r=[];s=t.next(),r[0]=s.value,s=t.next(),r[1]=s.value,e.edgeIndices.push(r)}}},{code:93,parser(s,t,e){e.totalFaceIndices=s.value,e.faceIndices=[];let i=[];for(let n=0;n<e.totalFaceIndices&&!L(s,0);++n)s=t.next(),i.push(s.value);let r=0;for(;r<i.length;){let n=i[r++],a=[];for(let o=0;o<n;++o)a.push(i[r++]);e.faceIndices.push(a)}}},{code:10,name:"vertices",parser:_,isMultiple:!0},{code:92,name:"verticesCount",parser:h},{code:91,name:"subdivisionLevel",parser:h},{code:40,name:"blendCrease",parser:h},{code:72,name:"isBlendCreased",parser:v},{code:71,name:"version",parser:h},{code:100,name:"subclassMarker",parser:Zl,pushContext:!0},...z];class xh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){wh(this,"parser",S(td))}}function bh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}wh(xh,"ForEntityName","MESH");let ed=[{code:42,name:"fillParameters",parser:h,isMultiple:!0},{code:75,name:"fillCount",parser:h},{code:41,name:"parameters",parser:h,isMultiple:!0},{code:74,name:"parameterCount",parser:h}],sd=[{code:[74,41,75,42],name:"elements",parser(s,t){let e=S(ed),i={};return e(s,t,i),i},isMultiple:!0},{code:13,name:"miterDirection",parser:_},{code:12,name:"direction",parser:_},{code:11,name:"position",parser:_}],id=[{code:[11,12,13],name:"segments",parser(s,t){let e=S(sd),i={};return e(s,t,i),i},isMultiple:!0},{code:210,name:"extrusionDirection",parser:_},{code:10,name:"startPosition",parser:_},{code:73,name:"styleCount",parser:h},{code:72,name:"vertexCount",parser:h},{code:71,name:"flags",parser:h},{code:70,name:"justification",parser:h},{code:40,name:"scale",parser:h},{code:340,name:"styleObjectHandle",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h,pushContext:!0},...z];class fh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){bh(this,"parser",S(id))}}bh(fh,"ForEntityName","MLINE");(Le={})[Le.Top=0]="Top",Le[Le.Zero=1]="Zero",Le[Le.Bottom=2]="Bottom";(Zt={})[Zt.HasVertex=1]="HasVertex",Zt[Zt.Closed=2]="Closed",Zt[Zt.SuppressStartCaps=4]="SuppressStartCaps",Zt[Zt.SuppressEndCaps=8]="SuppressEndCaps";(Ne={})[Ne.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",Ne[Ne.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",Ne[Ne.BY_STYLE=5]="BY_STYLE";function Ih(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let rd={},nd=[{code:170,name:"multileaderType",parser:h},{code:291,name:"doglegEnabled",parser:v},{code:40,name:"doglegLength",parser:h},{code:172,name:"contentType",parser:h},{code:3,name:"textContent",parser:h},{code:12,name:"textAnchor",parser:_},{code:344,name:"blockHandle",parser:h},{code:15,name:"blockPosition",parser:_},{code:302,name:"leaderSections",parser:function(s,t,e){let i,r={leaderLines:[]};for(;t.hasNext()&&(i=t.next()).code!==303;)switch(i.code){case 10:r.landingPoint=_(i.value,t);break;case 11:r.doglegVector=_(i.value,t);break;case 40:r.doglegLength=i.value;break;case 304:r.leaderLines.push(function(n){let a,o={vertices:[]};for(;n.hasNext()&&(a=n.next()).code!==305;)a.code===10&&o.vertices.push(_(a.value,n));return o}(t))}return r},isMultiple:!0},...z];class Sh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Ih(this,"parser",S(nd,rd))}}function Eh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Ih(Sh,"ForEntityName","MULTILEADER");let ad={thickness:0,extrusionDirection:{x:0,y:0,z:1},angle:0},od=[{code:50,name:"angle",parser:h},{code:210,name:"extrusionDirection",parser:_},{code:39,name:"thickness",parser:h},{code:10,name:"position",parser:_},{code:100,name:"subclassMarker",parser:h},...z];class Ph{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Eh(this,"parser",S(od,ad))}}function Ah(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Eh(Ph,"ForEntityName","POINT");let hd={startWidth:0,endWidth:0,bulge:0},ld=[{code:91,name:"id",parser:h},{code:[...Bi(71,75)],name:"faces",isMultiple:!0,parser:h},{code:50,name:"tangentDirection",parser:h},{code:70,name:"flag",parser:h},{code:42,name:"bulge",parser:h},{code:41,name:"endWidth",parser:h},{code:40,name:"startWidth",parser:h},{code:30,name:"z",parser:h},{code:20,name:"y",parser:h},{code:10,name:"x",parser:h},{code:100,name:"subclassMarker",parser:h},{code:100},...z];class Yr{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Ah(this,"parser",S(ld,hd))}}function Th(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Ah(Yr,"ForEntityName","VERTEX");let cd={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:[]},dd=[{code:0,name:"vertices",isMultiple:!0,parser:(s,t)=>L(s,0,"VERTEX")?(s=t.next(),new Yr().parseEntity(t,s)):Ws},{code:210,name:"extrusionDirection",parser:_},{code:75,name:"smoothType",parser:h},{code:74,name:"surfaceNDensity",parser:h},{code:73,name:"surfaceMDensity",parser:h},{code:72,name:"meshNVertexCount",parser:h},{code:71,name:"meshMVertexCount",parser:h},{code:41,name:"endWidth",parser:h},{code:40,name:"startWidth",parser:h},{code:70,name:"flag",parser:h},{code:39,name:"thickness",parser:h},{code:30,name:"elevation",parser:h},{code:20},{code:10},{code:66},{code:100,name:"subclassMarker",parser:h},...z];class Mh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Th(this,"parser",S(dd,cd))}}Th(Mh,"ForEntityName","POLYLINE");(st={})[st.CLOSED_POLYLINE=1]="CLOSED_POLYLINE",st[st.CURVE_FIT=2]="CURVE_FIT",st[st.SPLINE_FIT=4]="SPLINE_FIT",st[st.POLYLINE_3D=8]="POLYLINE_3D",st[st.POLYGON_3D=16]="POLYGON_3D",st[st.CLOSED_POLYGON=32]="CLOSED_POLYGON",st[st.POLYFACE=64]="POLYFACE",st[st.CONTINUOUS=128]="CONTINUOUS";var ei=((Kt={})[Kt.NONE=0]="NONE",Kt[Kt.QUADRATIC=5]="QUADRATIC",Kt[Kt.CUBIC=6]="CUBIC",Kt[Kt.BEZIER=8]="BEZIER",Kt);function vh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let ud=[{code:11,name:"direction",parser:_},{code:10,name:"position",parser:_},{code:100,name:"subclassMarker",parser:h},...z];class kh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){vh(this,"parser",S(ud))}}function Lh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}vh(kh,"ForEntityName","RAY");let pd=[...Ui("data"),{code:70,name:"version",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class Nh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Lh(this,"parser",S(pd))}}function Oh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Lh(Nh,"ForEntityName","REGION");let md={vertices:[],backLineVertices:[]},gd=[{code:360,name:"geometrySettingHardId",parser:h},{code:12,name:"backLineVertices",isMultiple:!0,parser:_},{code:93,name:"numberOfBackLineVertices",parser:h},{code:11,name:"vertices",isMultiple:!0,parser:_},{code:92,name:"verticesCount",parser:h},{code:[63,411],name:"indicatorColor",parser:h},{code:70,name:"indicatorTransparency",parser:h},{code:41,name:"bottomHeight",parser:h},{code:40,name:"topHeight",parser:h},{code:10,name:"verticalDirection",parser:_},{code:1,name:"name",parser:h},{code:91,name:"flag",parser:h},{code:90,name:"state",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class Ch{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Oh(this,"parser",S(gd,md))}}function Fh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Oh(Ch,"ForEntityName","SECTION");let yd={points:[],thickness:0,extrusionDirection:{x:0,y:0,z:1}},_d=[{code:210,name:"extrusionDirection",parser:_},{code:39,name:"thickness",parser:h},{code:[...Bi(10,14)],name:"points",isMultiple:!0,parser:_},{code:100,name:"subclassMarker",parser:h},...z];class Bh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Fh(this,"parser",S(_d,yd))}}function Rh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Fh(Bh,"ForEntityName","SOLID");let wd=[{code:350,name:"historyObjectSoftId",parser:h},{code:100,name:"subclassMarker",parser:h},...Ui("data"),{code:70,name:"version",parser:h},{code:100},...z];class zh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Rh(this,"parser",S(wd))}}function Vh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}Rh(zh,"ForEntityName","3DSOLID");let xd={knotTolerance:1e-6,controlTolerance:1e-6,fitTolerance:1e-9,knotValues:[],controlPoints:[],fitPoints:[]},bd=[{code:11,name:"fitPoints",isMultiple:!0,parser:_},{code:10,name:"controlPoints",isMultiple:!0,parser:_},{code:41,name:"weights",isMultiple:!0,parser:h},{code:40,name:"knots",isMultiple:!0,parser:h},{code:13,name:"endTangent",parser:_},{code:12,name:"startTangent",parser:_},{code:44,name:"fitTolerance",parser:h},{code:43,name:"controlTolerance",parser:h},{code:42,name:"knotTolerance",parser:h},{code:74,name:"numberOfFitPoints",parser:h},{code:73,name:"numberOfControlPoints",parser:h},{code:72,name:"numberOfKnots",parser:h},{code:71,name:"degree",parser:h},{code:70,name:"flag",parser:h},{code:210,name:"normal",parser:_},{code:100,name:"subclassMarker",parser:h},...z];class Dh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Vh(this,"parser",S(bd,xd))}}Vh(Dh,"ForEntityName","SPLINE");(bt={})[bt.NONE=0]="NONE",bt[bt.CLOSED=1]="CLOSED",bt[bt.PERIODIC=2]="PERIODIC",bt[bt.RATIONAL=4]="RATIONAL",bt[bt.PLANAR=8]="PLANAR",bt[bt.LINEAR=16]="LINEAR";function jh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let fd=[{code:280,name:"shadowMapSoftness",parser:h},{code:71,name:"shadowMapSize",parser:h},{code:70,name:"shadowType",parser:h},{code:292,name:"isSummerTime",parser:v},{code:92,name:"time",parser:h},{code:91,name:"julianDay",parser:h},{code:291,name:"hasShadow",parser:v},{code:40,name:"intensity",parser:h},{code:421,name:"lightColorInstance",parser:h},{code:63,name:"lightColorIndex",parser:h},{code:290,name:"isOn",parser:v},{code:90,name:"version",parser:h},{code:100,name:"subclassMarker",parser:h,pushContext:!0},...z.filter(s=>s.code!==100)];class Wh{parseEntity(t,e){let i={layer:""};return this.parser(e,t,i),i}constructor(){jh(this,"parser",S(fd))}}jh(Wh,"ForEntityName","SUN");class hi{parseEntity(t,e){let i={};for(;!t.isEOF();){if(e.code===0){t.rewind();break}switch(e.code){case 100:i.subclassMarker=e.value,e=t.next();break;case 2:i.name=e.value,e=t.next();break;case 5:i.handle=e.value,e=t.next();break;case 10:i.startPoint=$n(me(t)),e=t.lastReadGroup;break;case 11:i.directionVector=$n(me(t)),e=t.lastReadGroup;break;case 90:i.tableValue=e.value,e=t.next();break;case 91:i.rowCount=e.value,e=t.next();break;case 92:i.columnCount=e.value,e=t.next();break;case 93:i.overrideFlag=e.value,e=t.next();break;case 94:i.borderColorOverrideFlag=e.value,e=t.next();break;case 95:i.borderLineWeightOverrideFlag=e.value,e=t.next();break;case 96:i.borderVisibilityOverrideFlag=e.value,e=t.next();break;case 141:i.rowHeightArr??(i.rowHeightArr=[]),i.rowHeightArr.push(e.value),e=t.next();break;case 142:i.columnWidthArr??(i.columnWidthArr=[]),i.columnWidthArr.push(e.value),e=t.next();break;case 280:i.version=e.value,e=t.next();break;case 310:i.bmpPreview??(i.bmpPreview=""),i.bmpPreview+=e.value,e=t.next();break;case 330:i.ownerDictionaryId=e.value,e=t.next();break;case 342:i.tableStyleId=e.value,e=t.next();break;case 343:i.blockRecordHandle=e.value,e=t.next();break;case 170:i.attachmentPoint=e.value,e=t.next();break;case 171:i.cells??(i.cells=[]),i.cells.push(function(r,n){let a=!1,o=!1,l={};for(;!r.isEOF()&&n.code!==0&&!o;)switch(n.code){case 171:if(a){o=!0;continue}l.cellType=n.value,a=!0,n=r.next();break;case 172:l.flagValue=n.value,n=r.next();break;case 173:l.mergedValue=n.value,n=r.next();break;case 174:l.autoFit=n.value,n=r.next();break;case 175:l.borderWidth=n.value,n=r.next();break;case 176:l.borderHeight=n.value,n=r.next();break;case 91:l.overrideFlag=n.value,n=r.next();break;case 178:l.virtualEdgeFlag=n.value,n=r.next();break;case 145:l.rotation=n.value,n=r.next();break;case 345:l.fieldObjetId=n.value,n=r.next();break;case 340:l.blockTableRecordId=n.value,n=r.next();break;case 146:l.blockScale=n.value,n=r.next();break;case 177:l.blockAttrNum=n.value,n=r.next();break;case 7:l.textStyle=n.value,n=r.next();break;case 140:l.textHeight=n.value,n=r.next();break;case 170:l.attachmentPoint=n.value,n=r.next();break;case 92:l.extendedCellFlags=n.value,n=r.next();break;case 285:l.rightBorderVisibility=!!(n.value??!0),n=r.next();break;case 286:l.bottomBorderVisibility=!!(n.value??!0),n=r.next();break;case 288:l.leftBorderVisibility=!!(n.value??!0),n=r.next();break;case 289:l.topBorderVisibility=!!(n.value??!0),n=r.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()}})(l,r,n),n=r.next();break;default:return l}return a=!1,o=!1,l}(t,e)),e=t.lastReadGroup;break;default:xc(i,e,t),e=t.next()}}return i}}function Gh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}(sr="ForEntityName")in hi?Object.defineProperty(hi,sr,{value:"ACAD_TABLE",enumerable:!0,configurable:!0,writable:!0}):hi[sr]="ACAD_TABLE";let Id=[{code:11,name:"xAxisDirection",parser:_},{code:210,name:"extrusionDirection",parser:_},{code:1,name:"text",parser:h},{code:10,name:"position",parser:_},{code:3,name:"styleName",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class Hh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Gh(this,"parser",S(Id))}}Gh(Hh,"ForEntityName","TOLERANCE");var Sd=((it={})[it.CREATED_BY_CURVE_FIT=1]="CREATED_BY_CURVE_FIT",it[it.TANGENT_DEFINED=2]="TANGENT_DEFINED",it[it.NOT_USED=4]="NOT_USED",it[it.CREATED_BY_SPLINE_FIT=8]="CREATED_BY_SPLINE_FIT",it[it.SPLINE_CONTROL_POINT=16]="SPLINE_CONTROL_POINT",it[it.FOR_POLYLINE=32]="FOR_POLYLINE",it[it.FOR_POLYGON=64]="FOR_POLYGON",it[it.POLYFACE=128]="POLYFACE",it);let Ed=[{code:[335,343,344,91],name:"softPointers",isMultiple:!0,parser:h},{code:361,name:"sunId",parser:h},{code:431,name:"ambientLightColorName",parser:h},{code:421,name:"ambientLightColorInstance",parser:h},{code:63,name:"ambientLightColorIndex",parser:h},{code:142,name:"contrast",parser:h},{code:141,name:"brightness",parser:h},{code:282,name:"defaultLightingType",parser:h},{code:292,name:"isDefaultLighting",parser:v},{code:348,name:"visualStyleId",parser:h},{code:333,name:"shadePlotId",parser:h},{code:332,name:"backgroundId",parser:h},{code:61,name:"majorGridFrequency",parser:h},{code:170,name:"shadePlotMode",parser:h},{code:146,name:"elevation",parser:h},{code:79,name:"orthographicType",parser:h},{code:346,name:"ucsBaseId",parser:h},{code:345,name:"ucsId",parser:h},{code:112,name:"ucsYAxis",parser:_},{code:111,name:"ucsXAxis",parser:_},{code:110,name:"ucsOrigin",parser:_},{code:74,name:"iconFlag",parser:h},{code:71,name:"ucsPerViewport",parser:h},{code:281,name:"renderMode",parser:h},{code:1,name:"sheetName",parser:h},{code:340,name:"clippingBoundaryId",parser:h},{code:90,name:"statusBitFlags",parser:h},{code:331,name:"frozenLayerIds",isMultiple:!0,parser:h},{code:72,name:"circleZoomPercent",parser:h},{code:51,name:"viewTwistAngle",parser:h},{code:50,name:"snapAngle",parser:h},{code:45,name:"viewHeight",parser:h},{code:44,name:"backClipZ",parser:h},{code:43,name:"frontClipZ",parser:h},{code:42,name:"perspectiveLensLength",parser:h},{code:17,name:"targetPoint",parser:_},{code:16,name:"viewDirection",parser:_},{code:15,name:"gridSpacing",parser:_},{code:14,name:"snapSpacing",parser:_},{code:13,name:"snapBase",parser:_},{code:12,name:"displayCenter",parser:_},{code:69,name:"viewportId",parser:h},{code:68,name:"status",parser:h},{code:41,name:"height",parser:h},{code:40,name:"width",parser:h},{code:10,name:"viewportCenter",parser:_},{code:100,name:"subclassMarker",parser:h,pushContext:!0},...z];class li{parseEntity(t,e){let i={};return S(Ed)(e,t,i),i}}function Uh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}(ir="ForEntityName")in li?Object.defineProperty(li,ir,{value:"VIEWPORT",enumerable:!0,configurable:!0,writable:!0}):li[ir]="VIEWPORT";let Pd={brightness:50,constrast:50,fade:0},Ad=[{code:14,name:"boundary",isMultiple:!0,parser:_},{code:91,name:"numberOfVertices",parser:h},{code:71,name:"boundaryType",parser:h},{code:360,name:"imageDefReactorHardId",parser:h},{code:283,name:"fade",parser:h},{code:282,name:"contrast",parser:h},{code:281,name:"brightness",parser:h},{code:280,name:"isClipping",parser:v},{code:70,name:"displayFlag",parser:h},{code:340,name:"imageDefHardId",parser:h},{code:13,name:"imageSize",parser:_},{code:12,name:"vDirection",parser:_},{code:11,name:"uDirection",parser:_},{code:10,name:"position",parser:_},{code:90,name:"classVersion",parser:h},{code:100,name:"subclassMarker",parser:h},...z];class Xh{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Uh(this,"parser",S(Ad,Pd))}}Uh(Xh,"ForEntityName","WIPEOUT");(Qt={})[Qt.ShowImage=1]="ShowImage",Qt[Qt.ShowImageWhenNotAligned=2]="ShowImageWhenNotAligned",Qt[Qt.UseClippingBoundary=4]="UseClippingBoundary",Qt[Qt.Transparency=8]="Transparency";function Yh(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}let Td=[{code:11,name:"direction",parser:_},{code:10,name:"position",parser:_},{code:100,name:"subclassMarker",parser:h},...z];class $h{parseEntity(t,e){let i={};return this.parser(e,t,i),i}constructor(){Yh(this,"parser",S(Td))}}Yh($h,"ForEntityName","XLINE");let Md=0;function qh(s){if(!s)throw TypeError("entity cannot be undefined or null");s.handle||(s.handle=Md++)}let vd=Object.fromEntries([Vo,ni,Xo,Zo,Qo,th,ri,sh,rh,lh,dh,ph,gh,_h,oi,xh,fh,$o,Sh,Ph,Mh,kh,Nh,Ch,Bh,zh,Dh,Wh,hi,Ho,Hh,oh,Yr,li,Xh,$h].map(s=>[s.ForEntityName,new s]));function Zh(s,t){let e=[];for(;!L(s,0,"EOF");){if(s.code===0){if(s.value==="ENDBLK"||s.value==="ENDSEC"){t.rewind();break}let i=vd[s.value];if(i){let r=s.value;s=t.next();let n=i.parseEntity(t,s);n.type=r,qh(n),e.push(n)}else t.debug}s=t.next()}return e}function _s(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}class Zn{next(){if(!this.hasNext())return this._eof?this.debug:this.debug,{code:0,value:"EOF"};let t=parseInt(this._data[this._pointer++],10),e=Kn(t,this._data[this._pointer++],this.debug),i={code:t,value:e};return L(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 t={code:parseInt(this._data[this._pointer]),value:0};return t.value=Kn(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){_s(this,"_data",void 0),_s(this,"debug",void 0),_s(this,"_pointer",void 0),_s(this,"_eof",void 0),_s(this,"lastReadGroup",void 0),this._data=t,this.debug=e,this.lastReadGroup={code:0,value:0},this._pointer=0,this._eof=!1}}function Kn(s,t,e=!1){return s<=9?t:s>=10&&s<=59?parseFloat(t.trim()):s>=60&&s<=99?parseInt(t.trim()):s>=100&&s<=109?t:s>=110&&s<=149?parseFloat(t.trim()):s>=160&&s<=179?parseInt(t.trim()):s>=210&&s<=239?parseFloat(t.trim()):s>=270&&s<=289?parseInt(t.trim()):s>=290&&s<=299?function(i){if(i==="0")return!1;if(i==="1")return!0;throw TypeError("String '"+i+"' cannot be cast to Boolean type")}(t.trim()):s>=300&&s<=369?t:s>=370&&s<=389?parseInt(t.trim()):s>=390&&s<=399?t:s>=400&&s<=409?parseInt(t.trim()):s>=410&&s<=419?t:s>=420&&s<=429?parseInt(t.trim()):s>=430&&s<=439?t:s>=440&&s<=459?parseInt(t.trim()):s>=460&&s<=469?parseFloat(t.trim()):s>=470&&s<=481||s===999||s>=1e3&&s<=1009?t:s>=1010&&s<=1059?parseFloat(t.trim()):s>=1060&&s<=1071?parseInt(t.trim()):t}function kd(s,t){let e=null,i={};for(;!L(s,0,"EOF")&&!L(s,0,"ENDSEC");)s.code===9?e=s.value:s.code===10?i[e]=me(t):i[e]=s.value,s=t.next();return i}let oe=[{code:100,name:"subclassMarker",parser:h},{code:330,name:"ownerObjectId",parser:h},{code:102,isMultiple:!0,parser(s,t){for(;!L(s,0,"EOF")&&!L(s,102,"}");)s=t.next()}},{code:5,name:"handle",parser:h}],Ld=[{code:70,name:"flag",parser:h},{code:2,name:"appName",parser:h},{code:100,name:"subclassMarker",parser:h},...oe],Nd=S(Ld),Od=S([{code:310,name:"bmpPreview",parser:h},{code:281,name:"scalability",parser:h},{code:280,name:"explodability",parser:h},{code:70,name:"insertionUnits",parser:h},{code:340,name:"layoutObjects",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...oe]),Cd=S([...Xr.map(s=>({...s,parser:h})),{code:70,name:"standardFlag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},{code:105,name:"handle",parser:h},...oe.filter(s=>s.code!==5)]),Fd=S([{code:347,name:"materialObjectId",parser:h},{code:390,name:"plotStyleNameObjectId",parser:h},{code:370,name:"lineweight",parser:h},{code:290,name:"isPlotting",parser:v},{code:6,name:"lineType",parser:h},{code:62,name:"colorIndex",parser:h},{code:70,name:"standardFlag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...oe]),Bd=S([{code:9,name:"text",parser:h},{code:45,name:"offsetY",parser:h},{code:44,name:"offsetX",parser:h},{code:50,name:"rotation",parser:h},{code:46,name:"scale",parser:h},{code:340,name:"styleObjectId",parser:h},{code:75,name:"shapeNumber",parser:h},{code:74,name:"elementTypeFlag",parser:h},{code:49,name:"elementLength",parser:h}],{elementTypeFlag:0,elementLength:0}),Rd=S([{code:49,name:"pattern",parser(s,t){let e={};return Bd(s,t,e),e},isMultiple:!0},{code:40,name:"totalPatternLength",parser:h},{code:73,name:"numberOfLineTypes",parser:h},{code:72,parser:h},{code:3,name:"description",parser:h},{code:70,name:"standardFlag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...oe]),zd=S([{code:1e3,name:"extendedFont",parser:h},{code:1001},{code:4,name:"bigFont",parser:h},{code:3,name:"font",parser:h},{code:42,name:"lastHeight",parser:h},{code:71,name:"textGenerationFlag",parser:h},{code:50,name:"obliqueAngle",parser:h},{code:41,name:"widthFactor",parser:h},{code:40,name:"fixedTextHeight",parser:h},{code:70,name:"standardFlag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...oe]),Vd=[{code:13,name:"orthographicOrigin",parser:_},{code:71,name:"orthographicType",parser:h},{code:346,name:"baseUcsHandle",parser:h},{code:146,name:"elevation",parser:h},{code:79,name:"isOrthographic",parser:v},{code:12,name:"yAxis",parser:_},{code:11,name:"xAxis",parser:_},{code:10,name:"origin",parser:_},{code:70,name:"flag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...oe],Dd=S(Vd),jd=[{code:346,name:"baseUcsId",parser:h},{code:345,name:"ucsId",parser:h},{code:146,name:"elevation",parser:h},{code:79,name:"orthographicType",parser:h},{code:112,name:"ucsYAxis",parser:_},{code:111,name:"ucsXAxis",parser:_},{code:110,name:"ucsOrigin",parser:_},{code:361,name:"sunHardId",parser:h},{code:348,name:"styleHardId",parser:h},{code:334,name:"liveSectionSoftId",parser:h},{code:332,name:"backgroundSoftId",parser:h},{code:73,name:"isPlottable",parser:v},{code:72,name:"isUcsAssociated",parser:v},{code:281,name:"renderMode",parser:h},{code:71,name:"viewMode",parser:h},{code:50,name:"twistAngle",parser:h},{code:44,name:"backClippingPlane",parser:h},{code:43,name:"frontClippingPlane",parser:h},{code:42,name:"lensLength",parser:h},{code:12,name:"target",parser:_},{code:11,name:"direction",parser:_},{code:10,name:"center",parser:_},{code:41,name:"width",parser:h},{code:40,name:"height",parser:h},{code:70,name:"flag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...oe],Wd=S(jd),Gd=S([{code:[63,421,431],name:"ambientColor",parser:h},{code:142,name:"contrast",parser:h},{code:141,name:"brightness",parser:h},{code:282,name:"defaultLightingType",parser:h},{code:292,name:"isDefaultLightingOn",parser:v},{code:348,name:"visualStyleObjectId",parser:h},{code:333,name:"shadePlotObjectId",parser:h},{code:332,name:"backgroundObjectId",parser:h},{code:61,name:"majorGridLines",parser:h},{code:170,name:"shadePlotSetting",parser:h},{code:146,name:"elevation",parser:h},{code:79,name:"orthographicType",parser:h},{code:112,name:"ucsYAxis",parser:_},{code:111,name:"ucsXAxis",parser:_},{code:110,name:"ucsOrigin",parser:_},{code:74,name:"ucsIconSetting",parser:h},{code:71,name:"viewMode",parser:h},{code:281,name:"renderMode",parser:h},{code:1,name:"styleSheet",parser:h},{code:[331,441],name:"frozenLayers",parser:h,isMultiple:!0},{code:72,name:"circleSides",parser:h},{code:51,name:"viewTwistAngle",parser:h},{code:50,name:"snapRotationAngle",parser:h},{code:45,name:"viewHeight",parser:h},{code:44,name:"backClippingPlane",parser:h},{code:43,name:"frontClippingPlane",parser:h},{code:42,name:"lensLength",parser:h},{code:17,name:"viewTarget",parser:_},{code:16,name:"viewDirectionFromTarget",parser:_},{code:15,name:"gridSpacing",parser:_},{code:14,name:"snapSpacing",parser:_},{code:13,name:"snapBasePoint",parser:_},{code:12,name:"center",parser:_},{code:11,name:"upperRightCorner",parser:_},{code:10,name:"lowerLeftCorner",parser:_},{code:70,name:"standardFlag",parser:h},{code:2,name:"name",parser:h},{code:100,name:"subclassMarker",parser:h},...oe]),Hd={APPID:Nd,BLOCK_RECORD:Od,DIMSTYLE:Cd,LAYER:Fd,LTYPE:Rd,STYLE:zd,UCS:Dd,VIEW:Wd,VPORT:Gd},Ud=S([{code:70,name:"maxNumberOfEntries",parser:h},{code:100,name:"subclassMarker",parser:h},{code:330,name:"ownerObjectId",parser:h},{code:102,parser:zt},{code:102,parser:zt},{code:102,parser:zt},{code:360,isMultiple:!0},{code:5,name:"handle",parser:h},{code:2,name:"name",parser:h}]);function Xd(s,t){var i;let e={};for(;!L(s,0,"EOF")&&!L(s,0,"ENDSEC");){if(L(s,0,"TABLE")){s=t.next();let r={entries:[]};Ud(s,t,r),e[r.name]=r}if(L(s,0)&&!L(s,0,"ENDTAB")){let r=s.value;s=t.next();let n=Hd[r];if(!n){t.debug,s=t.next();continue}let a={};n(s,t,a),(i=e[r])==null||i.entries.push(a)}s=t.next()}return e}function Yd(s,t){let e={};for(;!L(s,0,"EOF")&&!L(s,0,"ENDSEC");){if(L(s,0,"BLOCK")){let i=$d(s=t.next(),t);qh(i),i.name&&(e[i.name]=i)}s=t.next()}return e}function $d(s,t){let e={};for(;!L(s,0,"EOF");){if(L(s,0,"ENDBLK")){for(s=t.next();!L(s,0,"EOF");){if(L(s,100,"AcDbBlockEnd"))return e;s=t.next()}break}switch(s.code){case 1:e.xrefPath=s.value;break;case 2:e.name=s.value;break;case 3:e.name2=s.value;break;case 5:e.handle=s.value;break;case 8:e.layer=s.value;break;case 10:e.position=me(t);break;case 67:e.paperSpace=!!s.value&&s.value==1;break;case 70:s.value!==0&&(e.type=s.value);break;case 100:break;case 330:e.ownerHandle=s.value;break;case 0:e.entities=Zh(s,t)}s=t.next()}return e}let $r=[{code:330,name:"ownerObjectId",parser:h},{code:102,parser:zt},{code:102,parser:zt},{code:102,parser:zt},{code:5,name:"handle",parser:h}],Kh=[{code:333,name:"shadePlotId",parser:h},{code:149,name:"imageOriginY",parser:h},{code:148,name:"imageOriginX",parser:h},{code:147,name:"scaleFactor",parser:h},{code:78,name:"shadePlotCustomDPI",parser:h},{code:77,name:"shadePlotResolution",parser:h},{code:76,name:"shadePlotMode",parser:h},{code:75,name:"standardScaleType",parser:h},{code:7,name:"currentStyleSheet",parser:h},{code:74,name:"plotType",parser:h},{code:73,name:"plotRotation",parser:h},{code:72,name:"plotPaperUnit",parser:h},{code:70,name:"layoutFlag",parser:h},{code:143,name:"printScaleDenominator",parser:h},{code:142,name:"printScaleNumerator",parser:h},{code:141,name:"windowAreaYMax",parser:h},{code:140,name:"windowAreaXMax",parser:h},{code:49,name:"windowAreaYMin",parser:h},{code:48,name:"windowAreaXMin",parser:h},{code:47,name:"plotOriginY",parser:h},{code:46,name:"plotOriginX",parser:h},{code:45,name:"paperHeight",parser:h},{code:44,name:"paperWidth",parser:h},{code:43,name:"marginTop",parser:h},{code:42,name:"marginRight",parser:h},{code:41,name:"marginBottom",parser:h},{code:40,name:"marginLeft",parser:h},{code:6,name:"plotViewName",parser:h},{code:4,name:"paperSize",parser:h},{code:2,name:"configName",parser:h},{code:1,name:"pageSetupName",parser:h},{code:100,name:"subclassMarker",parser:h},...$r],qd=[{code:346,name:"orthographicUcsId",parser:h},{code:345,name:"namedUcsId",parser:h},{code:331,name:"viewportId",parser:h},{code:330,name:"paperSpaceTableId",parser:h},{code:76,name:"orthographicType",parser:h},{code:17,name:"ucsYAxis",parser:_},{code:16,name:"ucsXAxis",parser:_},{code:13,name:"ucsOrigin",parser:_},{code:146,name:"elevation",parser:h},{code:15,name:"maxExtent",parser:_},{code:14,name:"minExtent",parser:_},{code:12,name:"insertionPoint",parser:_},{code:11,name:"maxLimit",parser:_},{code:10,name:"minLimit",parser:_},{code:71,name:"tabOrder",parser:h},{code:70,name:"controlFlag",parser:h},{code:1,name:"layoutName",parser:h},{code:100,name:"subclassMarker",parser:h},...Kh],Zd=[{code:3,name:"entries",parser:(s,t)=>{let e={name:s.value};return(s=t.next()).code===350?e.objectSoftId=s.value:s.code===360?e.objectHardId=s.value:t.rewind(),e},isMultiple:!0},{code:281,name:"recordCloneFlag",parser:h},{code:280,name:"isHardOwned",parser:v},{code:100,name:"subclassMarker",parser:h},...$r],Kd=[{code:40,name:"wcsToOCSTransform",parser:Qn},{code:40,name:"ocsToWCSTransform",parser:Qn},{code:41,name:"backClippingDistance",parser:h},{code:73,name:"isBackClipping",parser:v,pushContext:!0},{code:40,name:"frontClippingDistance",parser:h},{code:72,name:"isFrontClipping",parser:v,pushContext:!0},{code:71,name:"isClipBoundaryDisplayed",parser:v},{code:11,name:"position",parser:_},{code:210,name:"normal",parser:_},{code:10,name:"boundaryVertices",parser:_,isMultiple:!0},{code:70,name:"boundaryCount",parser:h},{code:100,name:"subclassMarker",parser:h},{code:100},...$r];function Qn(s,t){let e=[];for(let i=0;i<3&&L(s,40);++i){let r=[];for(let n=0;n<4&&L(s,40);++n)r.push(s.value),s=t.next();e.push(r)}return t.rewind(),e}let Qd=[{code:330,name:"imageDefReactorIdSoft",isMultiple:!0,parser:h},{code:90,name:"version",parser:h},{code:1,name:"fileName",parser:h},{code:10,name:"size",parser:_},{code:11,name:"sizeOfOnePixel",parser:_},{code:280,name:"isLoaded",parser:h},{code:281,name:"resolutionUnits",parser:h},{code:100,name:"subclassMarker",parser:h}],Jd={LAYOUT:qd,PLOTSETTINGS:Kh,DICTIONARY:Zd,SPATIAL_FILTER:Kd,IMAGEDEF:Qd};function tu(s,t){let e=[];for(;s.code!==0||!["EOF","ENDSEC"].includes(s.value);){let i=s.value,r=Jd[i];if(s.code===0&&(r!=null&&r.length)){let n=S(r),a={name:i};n(s=t.next(),t,a)?(e.push(a),s=t.peek()):s=t.next()}else s=t.next()}return{byName:gc(e,({name:i})=>i)}}function Ts(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}class eu{constructor(){Ts(this,"encoding","utf-8"),Ts(this,"encodingFailureFatal",!1),Ts(this,"thumbnailImageFormat","base64")}}class su extends EventTarget{parseSync(t,e=!1){let i=new Zn(t.split(/\r\n|\r|\n/g),e);if(!i.hasNext())throw Error("Empty file");return this.parseAll(i)}parseStream(t){let e="",i=this;return new Promise((r,n)=>{t.on("data",a=>{e+=a}),t.on("end",()=>{try{let a=e.split(/\r\n|\r|\n/g),o=new Zn(a);if(!o.hasNext())throw Error("Empty file");r(i.parseAll(o))}catch(a){n(a)}}),t.on("error",a=>{n(a)})})}async parseFromUrl(t,e){let i=await fetch(t,e);if(!i.body)return null;let r=i.body.getReader(),n="";for(;;){let{done:a,value:o}=await r.read();if(a){n+=this._decoder.decode(new ArrayBuffer(0),{stream:!1});break}n+=this._decoder.decode(o,{stream:!0})}return this.parseSync(n)}parseAll(t){let e={header:{},blocks:{},entities:[],tables:{},objects:{byName:{},byTree:void 0}},i=t.next();for(;!L(i,0,"EOF");)L(i,0,"SECTION")&&(L(i=t.next(),2,"HEADER")?e.header=kd(i=t.next(),t):L(i,2,"CLASSES")?tc(i=t.next(),t,e):L(i,2,"BLOCKS")?e.blocks=Yd(i=t.next(),t):L(i,2,"ENTITIES")?e.entities=Zh(i=t.next(),t):L(i,2,"TABLES")?e.tables=Xd(i=t.next(),t):L(i,2,"OBJECTS")?e.objects=tu(i=t.next(),t):L(i,2,"THUMBNAILIMAGE")&&(e.thumbnailImage=function(r,n,a="base64"){let o,l="",c=0;for(;!L(r,0,"EOF")&&!L(r,0,"ENDSEC");)r.code===90?c=r.value:r.code===310&&(l+=r.value),r=n.next();if(a==="hex")o=l;else{let d=function(u){let m=u.length/2,p=new Uint8Array(m);for(let g=0;g<m;g++)p[g]=parseInt(u.substr(2*g,2),16);return p}(l);o=a==="buffer"?d:function(u){let m="";for(let p=0;p<u.length;p++)m+=String.fromCharCode(u[p]);return btoa(m)}(d)}return{size:c,data:o}}(i=t.next(),t,this._options.thumbnailImageFormat))),i=t.next();return e}constructor(t={}){super(),Ts(this,"_decoder",void 0),Ts(this,"_options",void 0);let e=new eu;this._options=Object.assign(e,t),this._decoder=new TextDecoder(this._options.encoding,{fatal:this._options.encodingFailureFatal})}}(ft={})[ft.NOT_APPLICABLE=0]="NOT_APPLICABLE",ft[ft.KEEP_EXISTING=1]="KEEP_EXISTING",ft[ft.USE_CLONE=2]="USE_CLONE",ft[ft.XREF_VALUE_NAME=3]="XREF_VALUE_NAME",ft[ft.VALUE_NAME=4]="VALUE_NAME",ft[ft.UNMANGLE_NAME=5]="UNMANGLE_NAME";(Oe={})[Oe.NOUNIT=0]="NOUNIT",Oe[Oe.CENTIMETERS=2]="CENTIMETERS",Oe[Oe.INCH=5]="INCH";(ys={})[ys.PSLTSCALE=1]="PSLTSCALE",ys[ys.LIMCHECK=2]="LIMCHECK";(Ce={})[Ce.INCHES=0]="INCHES",Ce[Ce.MILLIMETERS=1]="MILLIMETERS",Ce[Ce.PIXELS=2]="PIXELS";(It={})[It.LAST_SCREEN_DISPLAY=0]="LAST_SCREEN_DISPLAY",It[It.DRAWING_EXTENTS=1]="DRAWING_EXTENTS",It[It.DRAWING_LIMITS=2]="DRAWING_LIMITS",It[It.VIEW_SPECIFIED=3]="VIEW_SPECIFIED",It[It.WINDOW_SPECIFIED=4]="WINDOW_SPECIFIED",It[It.LAYOUT_INFORMATION=5]="LAYOUT_INFORMATION";(Jt={})[Jt.AS_DISPLAYED=0]="AS_DISPLAYED",Jt[Jt.WIREFRAME=1]="WIREFRAME",Jt[Jt.HIDDEN=2]="HIDDEN",Jt[Jt.RENDERED=3]="RENDERED";(St={})[St.DRAFT=0]="DRAFT",St[St.PREVIEW=1]="PREVIEW",St[St.NORMAL=2]="NORMAL",St[St.PRESENTATION=3]="PRESENTATION",St[St.MAXIMUM=4]="MAXIMUM",St[St.CUSTOM=5]="CUSTOM";(te={})[te.NONE=0]="NONE",te[te.AbsoluteRotation=1]="AbsoluteRotation",te[te.TextEmbedded=2]="TextEmbedded",te[te.ShapeEmbedded=4]="ShapeEmbedded";(rr={})[rr.PaperSpace=1]="PaperSpace";(Fe={})[Fe.XrefDependent=16]="XrefDependent",Fe[Fe.XrefResolved=32]="XrefResolved",Fe[Fe.Referenced=64]="Referenced";(Et={})[Et.Off=0]="Off",Et[Et.Perspective=1]="Perspective",Et[Et.ClipFront=2]="ClipFront",Et[Et.ClipBack=4]="ClipBack",Et[Et.UcsFollow=8]="UcsFollow",Et[Et.ClipFrontByFrontZ=16]="ClipFrontByFrontZ";class iu{parse(t){const e=new su,i=this.getDxfInfoFromBuffer(t);let r="";return i.version&&i.version.value<=23&&i.encoding?r=new TextDecoder(i.encoding).decode(t):r=new TextDecoder().decode(t),e.parseSync(r)}getDxfInfoFromBuffer(t){var c,d,u;const i=new TextDecoder("utf-8");let r=0,n="",a=null,o=null,l=!1;for(;r<t.byteLength;){const m=Math.min(r+65536,t.byteLength),p=t.slice(r,m);r=m;const y=(n+i.decode(p,{stream:!0})).split(/\r?\n/);n=y.pop()??"";for(let x=0;x<y.length;x++){const w=y[x].trim();if(w==="SECTION"&&((c=y[x+2])==null?void 0:c.trim())==="HEADER")l=!0;else if(w==="ENDSEC"&&l)return{version:a,encoding:o};if(l&&w==="$ACADVER"){const P=(d=y[x+2])==null?void 0:d.trim();P&&(a=new At(P))}else if(l&&w==="$DWGCODEPAGE"){const P=(u=y[x+2])==null?void 0:u.trim();if(P){const I=Pr[P];o=ga(I)}}if(a&&o)return{version:a,encoding:o}}}return{version:a,encoding:o}}}class Jn{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=="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 xi;return t.vertices.forEach((i,r)=>e.setVertexAt(r,i)),e}convertArc(t){return new mi(t.center,t.radius,N.degToRad(t.startAngle),N.degToRad(t.endAngle),t.extrusionDirection??f.Z_AXIS)}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&Q.Invisible)!==0,e.isConst=(t.attributeFlag&Q.Const)!==0,e.isVerifiable=(t.attributeFlag&Q.Verifiable)!==0,e.isPreset=(t.attributeFlag&Q.Preset)!==0,e.isReallyLocked=!!t.isReallyLocked,e.isMTextAttribute=(t.mtextFlag&Bt.MultiLine)!==0,e.isConstMTextAttribute=(t.mtextFlag&Bt.ConstMultiLine)!==0}convertAttribute(t){const e=new yi;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 gi;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){return new _i(t.center,t.radius,t.extrusionDirection??f.Z_AXIS)}convertEllipse(t){const e=new f(t.majorAxisEndPoint),i=e.length();return new wi(t.center,t.extrusionDirection??f.Z_AXIS,e,i,i*t.axisRatio,t.startAngle,t.endAngle)}convertLine(t){const e=t.startPoint,i=t.endPoint;return new Ns(new b(e.x,e.y,e.z||0),new b(i.x,i.y,i.z||0))}convertSpline(t){try{if(t.numberOfControlPoints>0&&t.numberOfKnots>0)return new Cs(t.controlPoints,t.knots,t.weights,t.degree,!!(t.flag&1));if(t.numberOfFitPoints>0)return new Cs(t.fitPoints,"Uniform",t.degree,!!(t.flag&1))}catch{}return null}convertPoint(t){const e=new Ei;return e.position=t.position,e}convertSolid(t){const e=new Ii;return t.points.forEach((i,r)=>e.setPointAt(r,i)),e.thickness=t.thickness,e}convertPolyline(t){const e=!!(t.flag&1),i=!!(t.flag&8),r=!!(t.flag&16),n=!!(t.flag&64),a=!!(t.flag&32),o=[],l=[],c=[];if(t.vertices.map(d=>{d.flag&Sd.SPLINE_CONTROL_POINT||(n&&d.flag&128?d.flag&64?(o.push({x:d.x,y:d.y,z:d.z}),l.push(d.bulge??0)):d.faces&&d.faces.length>=3&&c.push([...d.faces]):(o.push({x:d.x,y:d.y,z:d.z}),l.push(d.bulge??0)))}),r){const d=t.meshMVertexCount,u=t.meshNVertexCount;return new vi(d,u,o,e,a)}else{if(n)return new ki(o,c);if(i){let d=Es.SimplePoly;return t.flag&4&&(t.smoothType==ei.CUBIC?d=Es.CubicSplinePoly:t.smoothType==ei.QUADRATIC&&(d=Es.QuadSplinePoly)),new pi(d,o,e)}else{let d=Xe.SimplePoly;return t.flag&2?d=Xe.FitCurvePoly:t.flag&4&&(t.smoothType==ei.CUBIC?d=Xe.CubicSplinePoly:t.smoothType==ei.QUADRATIC&&(d=Xe.QuadSplinePoly)),new ui(d,o,0,e,t.startWidth,t.endWidth,l)}}}convertLWPolyline(t){const e=new Si;return e.closed=!!(t.flag&1),t.vertices.forEach((i,r)=>{e.addVertexAt(r,new O(i.x,i.y),i.bulge,i.startWidth,i.endWidth)}),e}convertHatch(t){var r;const e=new Ls;return(r=t.definitionLines)==null||r.forEach(n=>{e.definitionLines.push({angle:n.angle,base:n.base,offset:n.offset,dashLengths:n.numberOfDashLengths>0?n.dashLengths:[]})}),e.isSolidFill=t.solidFill==Xl.SolidFill,e.hatchStyle=t.hatchStyle,e.patternName=t.patternName,e.patternType=t.patternType,e.patternAngle=t.patternAngle==null?0:t.patternAngle,e.patternScale=t.patternScale==null?0:t.patternScale,t.boundaryPaths.forEach(n=>{if(n.boundaryPathTypeFlag&2){const o=n,l=new ge;l.closed=o.isClosed,o.vertices.forEach((c,d)=>{l.addVertexAt(d,{x:c.x,y:c.y,bulge:c.bulge})}),e.add(l)}else{const o=n,l=[];o.edges.forEach(d=>{if(d.type==1){const u=d;l.push(new Rt(u.start,u.end))}else if(d.type==2){const u=d;l.push(new Ve(u.center,u.radius,N.degToRad(u.startAngle||0),N.degToRad(u.endAngle||0),!u.isCCW))}else if(d.type==3){const u=d;new U().subVectors(u.end,u.center);const p=Math.sqrt(Math.pow(u.end.x,2)+Math.pow(u.end.y,2)),g=p*u.lengthOfMinorAxis;let y=N.degToRad(u.startAngle||0),x=N.degToRad(u.endAngle||0);const w=Math.atan2(u.end.y,u.end.x);u.isCCW||(y=Math.PI*2-y,x=Math.PI*2-x),l.push(new De({...u.center,z:0},p,g,y,x,!u.isCCW,w))}else if(d.type==4){const u=d;if(u.numberOfControlPoints>0&&u.numberOfKnots>0){const m=u.controlPoints.map(y=>({x:y.x,y:y.y,z:0}));let p=!0;const g=u.controlPoints.map(y=>(y.weight==null&&(p=!1),y.weight||1));l.push(new Lt(m,u.knots,p?g:void 0))}else if(u.numberOfFitData>0){const m=u.fitDatum.map(p=>({x:p.x,y:p.y,z:0}));l.push(new Lt(m,"Uniform"))}}});const c=ks.buildFromEdges(l);c.length==0&&l.length>0?e.add(new ks(l)):c.forEach(d=>e.add(d))}}),e}convertTable(t){const e=new fi(t.name,t.rowCount,t.columnCount);return e.tableDataVersion=t.version,e.tableStyleId=t.tableStyleId,e.owningBlockRecordId=t.blockRecordHandle,t.directionVector&&(e.horizontalDirection=new f(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((i,r)=>e.setColumnWidth(r,i)),t.rowHeightArr.forEach((i,r)=>e.setRowHeight(r,i)),t.cells.forEach((i,r)=>{e.setCell(r,i)}),e}convertText(t){const e=new Ke;return e.textString=t.text,e.styleName=t.styleName,e.height=t.textHeight,e.position.copy(t.startPoint),e.rotation=N.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 Os;return e.contents=t.text,t.styleName!=null&&(e.styleName=t.styleName),e.height=t.height,e.width=t.width,e.rotation=N.degToRad(t.rotation||0),e.location=t.insertionPoint,e.attachmentPoint=t.attachmentPoint,t.direction&&(e.direction=new f(t.direction)),e.drawingDirection=t.drawingDirection,e}convertLeader(t){const e=new bi;return t.vertices.forEach(i=>{e.appendVertex(i)}),e.hasArrowHead=t.isArrowheadEnabled,e.hasHookLine=t.isHooklineExists,e.isSplined=t.isSpline,e.dimensionStyle=t.styleName,e.annoType=t.leaderCreationFlag,e}convertDimension(t){if(t.subclassMarker=="AcDbAlignedDimension"||t.subclassMarker=="AcDbRotatedDimension"){const e=t,i=new Ni(e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return e.insertionPoint&&(i.dimBlockPosition={...e.insertionPoint,z:0}),i.rotation=N.degToRad(e.rotationAngle||0),this.processDimensionCommonAttrs(t,i),i}else if(t.subclassMarker=="AcDb3PointAngularDimension"){const e=t,i=new Li(e.centerPoint,e.subDefinitionPoint1,e.subDefinitionPoint2,e.definitionPoint);return this.processDimensionCommonAttrs(t,i),i}else if(t.subclassMarker=="AcDbOrdinateDimension"){const e=t,i=new Ci(e.subDefinitionPoint1,e.subDefinitionPoint2);return this.processDimensionCommonAttrs(t,i),i}else if(t.subclassMarker=="AcDbRadialDimension"){const e=t,i=new Fi(e.definitionPoint,e.subDefinitionPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,i),i}else if(t.subclassMarker=="AcDbDiametricDimension"){const e=t,i=new Oi(e.definitionPoint,e.subDefinitionPoint,e.leaderLength);return this.processDimensionCommonAttrs(t,i),i}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(i=>{e.clipBoundary.push(new O(i))}),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 Fs;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(i=>{e.clipBoundary.push(new O(i))}),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 Ti;return this.processWipeout(t,e),e}convertViewport(t){const e=new Ai;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 Pi;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertXline(t){const e=new Mi;return e.basePoint.copy(t.position),e.unitDir.copy(t.direction),e}convertBlockReference(t){const e=new Qe(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?N.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=Di.deserialize(t.transparency))}}class ru{convertLayout(t,e){var n,a;const i=new Ds;i.layoutName=t.layoutName,i.tabOrder=t.tabOrder,i.plotSettingsName=t.pageSetupName,i.plotCfgName=t.configName,i.canonicalMediaName=t.paperSize,i.plotViewName=t.plotViewName,i.currentStyleSheet=t.currentStyleSheet,i.plotPaperMargins={left:t.marginLeft,right:t.marginRight,top:t.marginTop,bottom:t.marginBottom},i.plotPaperSize.copy({x:t.paperWidth,y:t.paperHeight}),i.plotOrigin.copy({x:t.plotOriginX,y:t.plotOriginY}),i.plotWindowArea.min.copy({x:t.windowAreaXMin,y:t.windowAreaYMin}),i.plotWindowArea.max.copy({x:t.windowAreaXMax,y:t.windowAreaYMax}),i.customPrintScale={numerator:t.printScaleNumerator,denominator:t.printScaleDenominator},i.plotPaperUnits=t.plotPaperUnit,i.plotRotation=t.plotRotation,i.plotType=t.plotType,i.stdScaleType=t.standardScaleType,i.shadePlot=(()=>{switch(t.shadePlotMode){case 1:return Ye.kWireframe;case 2:return Ye.kHidden;case 3:return Ye.kRendered;default:return Ye.kAsDisplayed}})(),i.shadePlotResLevel=(()=>{switch(t.shadePlotResolution){case 1:return ce.kPreview;case 2:return ce.kNormal;case 3:return ce.kPresentation;case 4:return ce.kMaximum;case 5:return ce.kCustom;default:return ce.kDraft}})(),t.shadePlotCustomDPI!=null&&(i.shadePlotCustomDPI=t.shadePlotCustomDPI),t.shadePlotId&&(i.shadePlotId=t.shadePlotId);const r=t.layoutFlag??0;if(i.plotViewportBorders=(r&1)!==0,i.showPlotStyles=(r&2)!==0,i.plotCentered=(r&4)!==0,i.plotHidden=(r&8)!==0,i.useStandardScale=(r&16)!==0,i.plotPlotStyles=(r&32)!==0,i.scaleLineweights=(r&64)!==0,i.printLineweights=(r&128)!==0,i.drawViewportsFirst=(r&512)!==0,i.modelType=(r&1024)!==0,t.viewportId&&i.viewportArray.push(t.viewportId),t.layoutName==="Model"){const o=K.MODEL_SPACE_NAME.toUpperCase();(n=e.tables.BLOCK_RECORD)==null||n.entries.some(l=>l.name.toUpperCase()===o?(i.blockTableRecordId=l.handle,!0):!1)}else(a=e.tables.BLOCK_RECORD)==null||a.entries.some(o=>o.layoutObjects===t.handle?(i.blockTableRecordId=o.handle,!0):!1),i.blockTableRecordId||(i.blockTableRecordId=t.paperSpaceTableId);return t.minLimit&&i.limits.min.copy(t.minLimit),t.maxLimit&&i.limits.max.copy(t.maxLimit),t.minExtent&&i.extents.min.copy(t.minExtent),t.maxExtent&&i.extents.max.copy(t.maxExtent),this.processCommonAttrs(t,i),i}convertImageDef(t){const e=new xo;return e.sourceFileName=t.fileName,this.processCommonAttrs(t,e),e}processCommonAttrs(t,e){e.objectId=t.handle,e.ownerId=t.ownerObjectId}}class Qh{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 i=Date.now(),r=this.generateTaskId();try{return await this.executeInWorker(r,t,e||this.config.workerUrl)}catch(n){const a=Date.now()-i;return{success:!1,error:n instanceof Error?n.message:String(n),duration:a}}}async executeInWorker(t,e,i){const r=Date.now();return new Promise((n,a)=>{const o=this.getAvailableWorker(i),l=setTimeout(()=>{this.cleanupTask(t),this.releaseWorker(o),a(new Error(`Worker operation timed out after ${this.config.timeout}ms`))},this.config.timeout);this.pendingTasks.set(t,{resolve:u=>{clearTimeout(l),this.releaseWorker(o),n(u)},reject:u=>{clearTimeout(l),this.releaseWorker(o),a(u)},timeout:l});const c=u=>{const{id:m,success:p,data:g,error:y}=u.data;if(m!==t)return;this.cleanupTask(t);const x=Date.now()-r;n(p?{success:!0,data:g,duration:x}:{success:!1,error:y,duration:x})},d=u=>{this.cleanupTask(t),a(new Error(`Worker error: ${u.message}`))};o.addEventListener("message",c),o.addEventListener("error",d),o.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[i,r]of this.workers)if(!r.isBusy)return r.isBusy=!0,r.worker;if(this.workers.size<this.config.maxConcurrentWorkers){const i=new Worker(t,{type:"module"}),r=this.generateWorkerId(),n={worker:i,isBusy:!0,id:r,createdAt:new Date};return this.workers.set(r,n),i}const e=Array.from(this.workers.values()).sort((i,r)=>i.createdAt.getTime()-r.createdAt.getTime())[0];return e.isBusy=!0,e.worker}releaseWorker(t){for(const[e,i]of this.workers)if(i.worker===t){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(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 Jh{constructor(t){this.framework=new Qh(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function tl(s){return new Jh(s)}class nu{constructor(){this.setupMessageHandler()}setupMessageHandler(){self.onmessage=async t=>{const{id:e,input:i}=t.data;try{const r=await this.executeTask(i);this.sendResponse(e,!0,r)}catch(r){this.sendResponse(e,!1,void 0,r instanceof Error?r.message:String(r))}}}sendResponse(t,e,i,r){const n={id:t,success:e,data:i,error:r};self.postMessage(n)}}class el extends Ur{constructor(t={}){super(t),t.parserWorkerUrl||(t.parserWorkerUrl="/assets/dxf-parser-worker.js")}async parse(t,e){const i=this.config,r=this.getParserWorkerTimeout(t,e);if(i.useWorker&&i.parserWorkerUrl){const n=tl({workerUrl:i.parserWorkerUrl,timeout:r,maxConcurrentWorkers:1}),a=await n.execute(t);if(n.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 iu().parse(t),data:{unknownEntityCount:0}}}getFonts(t){var n;const e=new Map,i=a=>{if(a){const o=a.lastIndexOf(".");return o>=0?a.substring(0,o).toLowerCase():a.toLowerCase()}};(n=t.tables.STYLE)==null||n.entries.forEach(a=>{const o=[];if(a.font){const l=i(a.font);l&&o.push(l)}if(a.bigFont){const l=i(a.bigFont);l&&o.push(l)}if(a.extendedFont){const l=i(a.extendedFont);l&&o.push(l)}e.set(a.name,o)});const r=new Set;return this.getFontsInBlock(t.entities,t.blocks,e,r),Array.from(r)}getFontsInBlock(t,e,i,r){const n=/\\f(.*?)\|/g;t.forEach(a=>{if(a.type=="MTEXT"){const o=a;[...o.text.matchAll(n)].forEach(d=>{r.add(d[1].toLowerCase())});const c=i.get(o.styleName);c==null||c.forEach(d=>r.add(d))}else if(a.type=="TEXT"){const o=a,l=i.get(o.styleName);l==null||l.forEach(c=>r.add(c))}else if(a.type=="INSERT"){const l=e[a.name];l&&l.entities&&this.getFontsInBlock(l.entities,e,i,r)}})}async processEntities(t,e,i,r,n){const a=new Jn;let o=t.entities;const l=o.length,c=new Sr(l,100-r.value,i);this.config.convertByEntityType&&(o=this.groupAndFlattenByType(o));const d=new Map;for(let m=0;m<l;m++){const p=o[m];if(p.type==="ATTRIB"){const g=a.convert(p);if(g&&g.ownerId&&g.ownerId!=="0"){let y=d.get(g==null?void 0:g.ownerId);y==null&&(y=[],d.set(g.ownerId,y)),y.push(g)}}}const u=e.tables.blockTable.modelSpace;await c.processChunk(async(m,p)=>{let g=[],y=m<p?o[m].type:"";for(let w=m;w<p;w++){const P=o[w];if(!(P.ownerBlockRecordSoftId&&P.ownerBlockRecordSoftId!==u.objectId)&&P.type!=="ATTRIB"){const I=a.convert(P);if(I){if(this.config.convertByEntityType&&P.type!==y&&(u.appendEntity(g),g=[],y=P.type),P.type==="INSERT"){const k=d.get(I.objectId);k&&k.length>0&&k.forEach(A=>{I.appendAttributes(A)})}g.push(I)}}}u.appendEntity(g);let x=r.value+p/l*(100-r.value);x>100&&(x=100),n&&await n(x,"ENTITY","IN-PROGRESS")})}async processEntitiesInBlock(t,e,i=!1){const r=new Jn,n=t.length,a=[],o=e.objectId,l=[];for(let c=0;c<n;c++){const d=t[c],u=r.convert(d);u&&(d.type==="ATTRIB"?l.push(u):(!i||d.ownerBlockRecordSoftId===o)&&a.push(u))}l.forEach(c=>{const d=e.getIdAt(c.ownerId);d&&d.appendAttributes(c)}),e.appendEntity(a)}processBlocks(t,e){const i=t.blocks;for(const[r,n]of Object.entries(i)){let a=e.tables.blockTable.getAt(n.name);a||(a=new K,a.objectId=n.handle,a.name=r,a.origin.copy(n.position),e.tables.blockTable.add(a)),n.entities?this.processEntitiesInBlock(n.entities,a):a.isPaperSapce&&this.processEntitiesInBlock(t.entities,a,!0)}}processHeader(t,e){const i=t.header;i.$ACADVER&&(e.version=i.$ACADVER),e.cecolor.colorIndex=i.$CECOLOR||256,e.angBase=i.$ANGBASE||0,e.angDir=i.$ANGDIR||0,i.$AUNITS!=null&&(e.aunits=i.$AUNITS),e.celtscale=i.$CELTSCALE||1,e.ltscale=i.$LTSCALE||1,i.$EXTMAX&&(e.extmax=i.$EXTMAX),i.$EXTMIN&&(e.extmin=i.$EXTMIN),i.$INSUNITS!=null&&(e.insunits=i.$INSUNITS),e.osmode=i.$OSMODE||0,e.pdmode=i.$PDMODE||0,e.pdsize=i.$PDSIZE||0,e.textstyle=i.$TEXTSTYLE||Y}processBlockTables(t,e){var r;const i=(r=t.tables.BLOCK_RECORD)==null?void 0:r.entries;i&&i.length>0&&(e.tables.blockTable.removeAll(),i.forEach(n=>{const a=new K;a.objectId=n.handle,a.name=n.name,a.layoutId=n.layoutObjects,a.blockInsertUnits=n.insertionUnits,a.explodability=n.explodability,a.blockScaling=n.scalability,n.bmpPreview&&(a.bmpPreview=n.bmpPreview),e.tables.blockTable.add(a)}))}processObjects(t,e){const i=t.objects.byName,r=new ru;if("LAYOUT"in i){const n=e.objects.layout;i.LAYOUT.forEach(a=>{const o=r.convertLayout(a,t);n.setAt(o.layoutName,o)})}if("IMAGEDEF"in i){const n=e.objects.imageDefinition;i.IMAGEDEF.forEach(a=>{const o=r.convertImageDef(a);n.setAt(o.objectId,o)})}}processViewports(t,e){var r;const i=(r=t.tables)==null?void 0:r.VPORT;if(i){this.processCommonTableAttrs(i,e.tables.viewportTable);const n=i.entries;n&&n.length>0&&n.forEach(a=>{const o=new Hr;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),e.tables.viewportTable.add(o)})}}processLayers(t,e){var r;const i=(r=t.tables)==null?void 0:r.LAYER;if(i){this.processCommonTableAttrs(i,e.tables.layerTable);const n=i.entries;n&&n.length>0&&n.forEach(a=>{const o=new J;o.colorIndex=a.colorIndex;const l=new Gi({name:a.name,standardFlags:a.standardFlag,linetype:a.lineType,lineWeight:a.lineweight,isOff:a.colorIndex<0,color:o,isPlottable:a.isPlotting});this.processCommonTableEntryAttrs(a,l),e.tables.layerTable.add(l)})}}processLineTypes(t,e){var r;const i=(r=t.tables)==null?void 0:r.LTYPE;if(i){this.processCommonTableAttrs(i,e.tables.linetypeTable);const n=i.entries;n&&n.length>0&&n.forEach(a=>{const o=new ue(a);this.processCommonTableEntryAttrs(a,o),o.name=a.name,e.tables.linetypeTable.add(o)})}}processTextStyles(t,e){var r;const i=(r=t.tables)==null?void 0:r.STYLE;if(i){this.processCommonTableAttrs(i,e.tables.textStyleTable);const n=i.entries;n&&n.length>0&&n.forEach(a=>{const o=new Hi(a);this.processCommonTableEntryAttrs(a,o),e.tables.textStyleTable.add(o)})}}processDimStyles(t,e){var r;const i=(r=t.tables)==null?void 0:r.DIMSTYLE;if(i){this.processCommonTableAttrs(i,e.tables.dimStyleTable);const n=i.entries;n&&n.length>0&&n.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||Y,dimldrblk:a.DIMLDRBLK||"",dimblk:a.DIMBLK||"",dimblk1:a.DIMBLK1||"",dimblk2:a.DIMBLK2||"",dimlwd:a.DIMLWD,dimlwe:a.DIMLWE},l=new We(o);this.processCommonTableEntryAttrs(a,l),e.tables.dimStyleTable.add(l)})}}processCommonTableAttrs(t,e){t.handle!=null&&(e.objectId=t.handle),e.ownerId=t.ownerObjectId}processCommonTableEntryAttrs(t,e){e.name="name"in t?t.name:"",t.handle!=null&&(e.objectId=t.handle),e.ownerId=t.ownerObjectId}groupAndFlattenByType(t){const e={},i=[];for(const r of t)e[r.type]||(e[r.type]=[],i.push(r.type)),e[r.type].push(r);return i.flatMap(r=>e[r])}}class sl extends Ur{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}getFonts(){return[]}async processEntities(t,e,i,r,n){let a=t.tables.blockTable.modelSpace.newIterator().toArray();const o=a.length,l=new Sr(o,100-r.value,i);this.config.convertByEntityType&&(a=this.groupAndFlattenByType(a));const c=e.tables.blockTable.modelSpace;await l.processChunk(async(d,u)=>{let m=[],p=d<u?a[d].type:"";for(let g=d;g<u;g++){const y=a[g];this.config.convertByEntityType&&y.type!==p&&(this.triggerEvents(c,m),m=[],p=y.type),m.push(y)}if(this.triggerEvents(c,m),n){let g=r.value+u/o*(100-r.value);g>100&&(g=100),await n(g,"ENTITY","IN-PROGRESS")}})}processBlocks(){const t=this._database.tables.blockTable.newIterator();for(const e of t){const i=e.newIterator().toArray();this.triggerEvents(e,i)}}processHeader(){}processBlockTables(){}processObjects(){const t=this._database.objects.layout.newIterator();for(const i of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:i,key:i.layoutName});const e=this._database.objects.imageDefinition.newIterator();for(const i of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:i,key:i.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={},i=[];for(const r of t)e[r.type]||(e[r.type]=[],i.push(r.type)),e[r.type].push(r);return i.flatMap(r=>e[r])}triggerEvents(t,e){(t.isModelSapce||t.isPaperSapce)&&t.database.events.entityAppended.dispatch({database:t.database,entity:e})}}exports.ACAD_APPID=cr;exports.AC_DB_SYSTEM_VARIABLE_NAMES=zl;exports.AcCmColor=J;exports.AcCmColorMethod=E;exports.AcCmColorUtil=le;exports.AcCmEntityColor=rl;exports.AcCmErrors=gt;exports.AcCmEventDispatcher=nl;exports.AcCmEventManager=Z;exports.AcCmLoader=pl;exports.AcCmLoadingManager=la;exports.AcCmObject=na;exports.AcCmPerformanceCollector=br;exports.AcCmTask=oa;exports.AcCmTaskScheduler=ha;exports.AcCmTransparency=Di;exports.AcCmTransparencyMethod=dt;exports.AcDb2dPolyline=ui;exports.AcDb2dVertex=gr;exports.AcDb2dVertexType=Qa;exports.AcDb3PointAngularDimension=Li;exports.AcDb3dPolyline=pi;exports.AcDb3dVertex=yr;exports.AcDb3dVertexType=Ja;exports.AcDbAbstractViewTableRecord=Gr;exports.AcDbAlignedDimension=Ni;exports.AcDbAngleUnits=Er;exports.AcDbArc=mi;exports.AcDbArcDimension=_r;exports.AcDbAttribute=yi;exports.AcDbAttributeDefinition=gi;exports.AcDbAttributeFlags=Q;exports.AcDbAttributeMTextFlag=Bt;exports.AcDbBaseWorker=nu;exports.AcDbBatchProcessing=Sr;exports.AcDbBlockReference=Qe;exports.AcDbBlockScaling=_o;exports.AcDbBlockTable=So;exports.AcDbBlockTableRecord=K;exports.AcDbCircle=_i;exports.AcDbCodePage=Pr;exports.AcDbCurve=rt;exports.AcDbDataGenerator=fo;exports.AcDbDatabase=Vl;exports.AcDbDatabaseConverter=Ur;exports.AcDbDatabaseConverterManager=Ft;exports.AcDbDiametricDimension=Oi;exports.AcDbDictionary=As;exports.AcDbDimArrowType=Io;exports.AcDbDimStyleTable=Eo;exports.AcDbDimStyleTableRecord=We;exports.AcDbDimTextHorizontal=Po;exports.AcDbDimTextVertical=Ao;exports.AcDbDimVerticalJustification=vo;exports.AcDbDimZeroSuppression=To;exports.AcDbDimZeroSuppressionAngular=Mo;exports.AcDbDimension=re;exports.AcDbDuplicateRecordCloning=bo;exports.AcDbDwgVersion=At;exports.AcDbDxfCode=xr;exports.AcDbDxfConverter=el;exports.AcDbDxfFiler=ta;exports.AcDbEllipse=wi;exports.AcDbEntity=pt;exports.AcDbFace=xi;exports.AcDbFileType=fs;exports.AcDbHatch=Ls;exports.AcDbHatchPatternType=Ps;exports.AcDbHatchStyle=so;exports.AcDbHostApplicationServices=ci;exports.AcDbLayerTable=ko;exports.AcDbLayerTableRecord=Gi;exports.AcDbLayout=Ds;exports.AcDbLayoutDictionary=yo;exports.AcDbLayoutManager=wo;exports.AcDbLeader=bi;exports.AcDbLeaderAnnotationType=io;exports.AcDbLine=Ns;exports.AcDbLineSpacingStyle=lo;exports.AcDbLinetypeTable=Lo;exports.AcDbLinetypeTableRecord=ue;exports.AcDbMText=Os;exports.AcDbObject=ne;exports.AcDbObjectIterator=js;exports.AcDbOpenMode=ma;exports.AcDbOrdinateDimension=Ci;exports.AcDbOsnapMode=R;exports.AcDbPlotPaperUnits=co;exports.AcDbPlotRotation=uo;exports.AcDbPlotSettings=go;exports.AcDbPlotShadePlotResLevel=ce;exports.AcDbPlotShadePlotType=Ye;exports.AcDbPlotStdScaleType=mo;exports.AcDbPlotType=po;exports.AcDbPoint=Ei;exports.AcDbPoly2dType=Xe;exports.AcDbPoly3dType=Es;exports.AcDbPolyFaceMesh=ki;exports.AcDbPolyFaceMeshFace=ho;exports.AcDbPolyFaceMeshVertex=oo;exports.AcDbPolygonMesh=vi;exports.AcDbPolygonMeshVertex=ao;exports.AcDbPolyline=Si;exports.AcDbRadialDimension=Fi;exports.AcDbRasterImage=Fs;exports.AcDbRasterImageClipBoundaryType=ro;exports.AcDbRasterImageDef=xo;exports.AcDbRasterImageImageDisplayOpt=no;exports.AcDbRay=Pi;exports.AcDbRegAppTable=Fo;exports.AcDbRegAppTableRecord=wr;exports.AcDbRegenerator=sl;exports.AcDbRenderingCache=Je;exports.AcDbResultBuffer=Ir;exports.AcDbSpline=Cs;exports.AcDbSymbolTable=ae;exports.AcDbSymbolTableRecord=ye;exports.AcDbSysVarManager=Bs;exports.AcDbSystemVariables=V;exports.AcDbTable=fi;exports.AcDbText=Ke;exports.AcDbTextHorizontalMode=to;exports.AcDbTextStyleTable=No;exports.AcDbTextStyleTableRecord=Hi;exports.AcDbTextVerticalMode=eo;exports.AcDbTrace=Ii;exports.AcDbUnitsValue=Wr;exports.AcDbViewTable=Oo;exports.AcDbViewTableRecord=Wl;exports.AcDbViewport=Ai;exports.AcDbViewportTable=Co;exports.AcDbViewportTableRecord=Hr;exports.AcDbWipeout=Ti;exports.AcDbWorkerApi=Jh;exports.AcDbWorkerManager=Qh;exports.AcDbXline=Mi;exports.AcDbXrecord=jr;exports.AcGeArea2d=vs;exports.AcGeBox2d=ut;exports.AcGeBox3d=C;exports.AcGeCatmullRomCurve3d=qa;exports.AcGeCircArc2d=Ve;exports.AcGeCircArc3d=ze;exports.AcGeCurve2d=ts;exports.AcGeEllipseArc2d=De;exports.AcGeEllipseArc3d=Wi;exports.AcGeEuler=Pl;exports.AcGeGeometryUtil=za;exports.AcGeLine2d=Rt;exports.AcGeLine3d=pe;exports.AcGeLoop2d=ks;exports.AcGeMathUtil=N;exports.AcGeMatrix2d=ji;exports.AcGeMatrix3d=Pt;exports.AcGeNurbsCurve=Ct;exports.AcGePlane=zs;exports.AcGePoint2d=O;exports.AcGePoint3d=b;exports.AcGePolyline2d=ge;exports.AcGeQuaternion=Ge;exports.AcGeShape2d=Br;exports.AcGeSpline3d=Lt;exports.AcGeTol=Nr;exports.AcGeVector2d=U;exports.AcGeVector3d=f;exports.AcGiArrowType=Rr;exports.AcGiDefaultLightingType=Dr;exports.AcGiLineWeight=je;exports.AcGiMTextAttachmentPoint=at;exports.AcGiMTextFlowDirection=ie;exports.AcGiOrthographicType=Vr;exports.AcGiRenderMode=zr;exports.AcGiViewport=Za;exports.AcTrStringUtil=ul;exports.ByBlock=di;exports.ByLayer=Ze;exports.DEBUG_MODE=cl;exports.DEFAULT_LINE_TYPE=qe;exports.DEFAULT_TEXT_STYLE=Y;exports.DEFAULT_TOL=Or;exports.DEG2RAD=Ar;exports.DefaultLoadingManager=ca;exports.FLOAT_TOL=Be;exports.MLIGHTCAD_APPID=lr;exports.ORIGIN_POINT_2D=yl;exports.ORIGIN_POINT_3D=Lr;exports.RAD2DEG=Tr;exports.TAU=G;exports.TEMP_OBJECT_ID_PREFIX=si;exports.acdbDisableOsnapMode=Nl;exports.acdbEnableOsnapMode=Ll;exports.acdbHasOsnapMode=kl;exports.acdbHostApplicationServices=fr;exports.acdbMaskToOsnapModes=Ml;exports.acdbOsnapModesToMask=Tl;exports.acdbToggleOsnapMode=vl;exports.basisFunction=Ms;exports.calculateCurveLength=ja;exports.ceilPowerOfTwo=ka;exports.clamp=se;exports.clone=ws;exports.computeParameterValues=Va;exports.createWorkerApi=tl;exports.damp=xa;exports.deepClone=ar;exports.defaults=Rs;exports.degToRad=Ta;exports.dwgCodePageToEncoding=ga;exports.euclideanModulo=Mr;exports.evaluateNurbsPoint=Ss;exports.floorPowerOfTwo=La;exports.generateAveragedKnots=Da;exports.generateChordKnots=wl;exports.generateSqrtChordKnots=xl;exports.generateUUID=ya;exports.generateUniformKnots=_l;exports.has=ea;exports.intPartLength=kr;exports.interpolateControlPoints=bl;exports.interpolateNurbsCurve=Fr;exports.inverseLerp=wa;exports.isBetween=Na;exports.isBetweenAngle=Oa;exports.isEmpty=sa;exports.isEqual=$e;exports.isImperialUnits=Bl;exports.isMetricUnits=Fl;exports.isPointInPolygon=Cr;exports.isPolygonIntersect=Ra;exports.isPowerOfTwo=va;exports.lerp=vr;exports.log=bs;exports.mapLinear=_a;exports.normalizeAngle=Is;exports.pingpong=ba;exports.radToDeg=Ma;exports.randFloat=Ea;exports.randFloatSpread=Pa;exports.randInt=Sa;exports.relativeEps=Ca;exports.seededRandom=Aa;exports.setAcDbHostApplicationServicesProvider=ua;exports.setAcDbLayoutManagerFactory=pa;exports.setLogLevel=dl;exports.smootherstep=Ia;exports.smoothstep=fa;