@mlightcad/data-model 1.12.1 → 1.12.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/data-model.cjs +15 -15
  2. package/lib/acis/AcDbAcisDecrypt.d.ts +0 -2
  3. package/lib/acis/AcDbAcisDecrypt.d.ts.map +1 -1
  4. package/lib/acis/AcDbAcisDecrypt.js +0 -2
  5. package/lib/acis/AcDbAcisDecrypt.js.map +1 -1
  6. package/lib/acis/AcDbAcisGeometry.d.ts +3 -0
  7. package/lib/acis/AcDbAcisGeometry.d.ts.map +1 -1
  8. package/lib/acis/AcDbAcisGeometry.js +117 -3
  9. package/lib/acis/AcDbAcisGeometry.js.map +1 -1
  10. package/lib/acis/AcDbAcisSab.d.ts.map +1 -1
  11. package/lib/acis/AcDbAcisSab.js +0 -10
  12. package/lib/acis/AcDbAcisSab.js.map +1 -1
  13. package/lib/acis/AcDbAcisSatWireframe.d.ts +3 -0
  14. package/lib/acis/AcDbAcisSatWireframe.d.ts.map +1 -1
  15. package/lib/acis/AcDbAcisSatWireframe.js +157 -4
  16. package/lib/acis/AcDbAcisSatWireframe.js.map +1 -1
  17. package/lib/acis/AcDbAcisTransform.d.ts +99 -0
  18. package/lib/acis/AcDbAcisTransform.d.ts.map +1 -0
  19. package/lib/acis/AcDbAcisTransform.js +260 -0
  20. package/lib/acis/AcDbAcisTransform.js.map +1 -0
  21. package/lib/acis/AcDbAcisWireframe.d.ts.map +1 -1
  22. package/lib/acis/AcDbAcisWireframe.js +36 -19
  23. package/lib/acis/AcDbAcisWireframe.js.map +1 -1
  24. package/lib/acis/index.d.ts +2 -0
  25. package/lib/acis/index.d.ts.map +1 -1
  26. package/lib/acis/index.js +1 -0
  27. package/lib/acis/index.js.map +1 -1
  28. package/lib/base/AcDbDxfPairReader.d.ts +5 -4
  29. package/lib/base/AcDbDxfPairReader.d.ts.map +1 -1
  30. package/lib/base/AcDbDxfPairReader.js +60 -19
  31. package/lib/base/AcDbDxfPairReader.js.map +1 -1
  32. package/lib/converter/AcDbFontNameCollector.d.ts +18 -2
  33. package/lib/converter/AcDbFontNameCollector.d.ts.map +1 -1
  34. package/lib/converter/AcDbFontNameCollector.js +27 -17
  35. package/lib/converter/AcDbFontNameCollector.js.map +1 -1
  36. package/lib/converter/index.d.ts +1 -1
  37. package/lib/converter/index.d.ts.map +1 -1
  38. package/lib/converter/index.js.map +1 -1
  39. package/lib/converter/worker/AcDbWorkerManager.d.ts.map +1 -1
  40. package/lib/converter/worker/AcDbWorkerManager.js +8 -5
  41. package/lib/converter/worker/AcDbWorkerManager.js.map +1 -1
  42. package/lib/dxf/AcDbDxfDocumentReader.d.ts +12 -4
  43. package/lib/dxf/AcDbDxfDocumentReader.d.ts.map +1 -1
  44. package/lib/dxf/AcDbDxfDocumentReader.js +38 -38
  45. package/lib/dxf/AcDbDxfDocumentReader.js.map +1 -1
  46. package/lib/index.d.ts +1 -1
  47. package/lib/index.d.ts.map +1 -1
  48. package/lib/index.js.map +1 -1
  49. package/lib/misc/AcDbRenderingCache.d.ts.map +1 -1
  50. package/lib/misc/AcDbRenderingCache.js +68 -10
  51. package/lib/misc/AcDbRenderingCache.js.map +1 -1
  52. package/package.json +4 -5
@@ -1,17 +1,17 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Ns=(n=>(n[n.Invalid=-9999]="Invalid",n[n.Start=0]="Start",n[n.Text=1]="Text",n[n.AttributeTag=2]="AttributeTag",n[n.BlockName=2]="BlockName",n[n.ShapeName=2]="ShapeName",n[n.SymbolTableName=2]="SymbolTableName",n[n.SymbolTableRecordName=2]="SymbolTableRecordName",n[n.MlineStyleName=2]="MlineStyleName",n[n.AttributePrompt=3]="AttributePrompt",n[n.Description=3]="Description",n[n.DimPostString=3]="DimPostString",n[n.DimStyleName=3]="DimStyleName",n[n.LinetypeProse=3]="LinetypeProse",n[n.TextFontFile=3]="TextFontFile",n[n.CLShapeName=4]="CLShapeName",n[n.DimensionAlternativePrefixSuffix=4]="DimensionAlternativePrefixSuffix",n[n.SymbolTableRecordComments=4]="SymbolTableRecordComments",n[n.TextBigFontFile=4]="TextBigFontFile",n[n.Handle=5]="Handle",n[n.DimensionBlock=5]="DimensionBlock",n[n.LinetypeName=6]="LinetypeName",n[n.DimBlk1=6]="DimBlk1",n[n.TextStyleName=7]="TextStyleName",n[n.DimBlk2=7]="DimBlk2",n[n.LayerName=8]="LayerName",n[n.CLShapeText=9]="CLShapeText",n[n.XCoordinate=10]="XCoordinate",n[n.YCoordinate=20]="YCoordinate",n[n.ZCoordinate=30]="ZCoordinate",n[n.Real=40]="Real",n[n.TxtSize=40]="TxtSize",n[n.ViewportHeight=40]="ViewportHeight",n[n.Angle=50]="Angle",n[n.ViewportSnapAngle=50]="ViewportSnapAngle",n[n.Visibility=60]="Visibility",n[n.Int16=70]="Int16",n[n.Int32=90]="Int32",n[n.Int64=160]="Int64",n[n.Int8=280]="Int8",n[n.Thickness=39]="Thickness",n[n.Elevation=38]="Elevation",n[n.LinetypeScale=48]="LinetypeScale",n[n.DashLength=49]="DashLength",n[n.MlineOffset=49]="MlineOffset",n[n.LinetypeElement=49]="LinetypeElement",n[n.NormalX=210]="NormalX",n[n.NormalY=220]="NormalY",n[n.NormalZ=230]="NormalZ",n[n.UcsOrg=110]="UcsOrg",n[n.UcsOrientationX=111]="UcsOrientationX",n[n.UcsOrientationY=112]="UcsOrientationY",n[n.ViewHeight=45]="ViewHeight",n[n.ViewWidth=41]="ViewWidth",n[n.ViewLensLength=42]="ViewLensLength",n[n.ViewFrontClip=43]="ViewFrontClip",n[n.ViewBackClip=44]="ViewBackClip",n[n.ViewBrightness=141]="ViewBrightness",n[n.ViewContrast=142]="ViewContrast",n[n.ViewMode=71]="ViewMode",n[n.ViewportActive=68]="ViewportActive",n[n.ViewportAspect=41]="ViewportAspect",n[n.ViewportGrid=76]="ViewportGrid",n[n.ViewportIcon=74]="ViewportIcon",n[n.ViewportNumber=69]="ViewportNumber",n[n.ViewportSnap=75]="ViewportSnap",n[n.ViewportSnapPair=78]="ViewportSnapPair",n[n.ViewportSnapStyle=77]="ViewportSnapStyle",n[n.ViewportTwist=51]="ViewportTwist",n[n.ViewportVisibility=67]="ViewportVisibility",n[n.ViewportZoom=73]="ViewportZoom",n[n.Color=62]="Color",n[n.ColorRgb=420]="ColorRgb",n[n.ColorName=430]="ColorName",n[n.LineWeight=370]="LineWeight",n[n.PlotStyleNameType=380]="PlotStyleNameType",n[n.PlotStyleNameId=390]="PlotStyleNameId",n[n.GradientObjType=450]="GradientObjType",n[n.GradientAngle=460]="GradientAngle",n[n.GradientName=470]="GradientName",n[n.GradientColCount=453]="GradientColCount",n[n.GradientPatType=451]="GradientPatType",n[n.GradientTintType=452]="GradientTintType",n[n.GradientShift=461]="GradientShift",n[n.GradientColVal=463]="GradientColVal",n[n.GradientTintVal=462]="GradientTintVal",n[n.SoftPointerId=330]="SoftPointerId",n[n.HardPointerId=340]="HardPointerId",n[n.SoftOwnershipId=350]="SoftOwnershipId",n[n.HardOwnershipId=360]="HardOwnershipId",n[n.ArbitraryHandle=320]="ArbitraryHandle",n[n.ExtendedDataAsciiString=1e3]="ExtendedDataAsciiString",n[n.ExtendedDataRegAppName=1001]="ExtendedDataRegAppName",n[n.ExtendedDataControlString=1002]="ExtendedDataControlString",n[n.ExtendedDataLayerName=1003]="ExtendedDataLayerName",n[n.ExtendedDataBinaryChunk=1004]="ExtendedDataBinaryChunk",n[n.ExtendedDataHandle=1005]="ExtendedDataHandle",n[n.ExtendedDataXCoordinate=1010]="ExtendedDataXCoordinate",n[n.ExtendedDataWorldXCoordinate=1011]="ExtendedDataWorldXCoordinate",n[n.ExtendedDataWorldXDisp=1012]="ExtendedDataWorldXDisp",n[n.ExtendedDataWorldXDir=1013]="ExtendedDataWorldXDir",n[n.ExtendedDataYCoordinate=1020]="ExtendedDataYCoordinate",n[n.ExtendedDataWorldYCoordinate=1021]="ExtendedDataWorldYCoordinate",n[n.ExtendedDataWorldYDisp=1022]="ExtendedDataWorldYDisp",n[n.ExtendedDataWorldYDir=1023]="ExtendedDataWorldYDir",n[n.ExtendedDataZCoordinate=1030]="ExtendedDataZCoordinate",n[n.ExtendedDataWorldZCoordinate=1031]="ExtendedDataWorldZCoordinate",n[n.ExtendedDataWorldZDisp=1032]="ExtendedDataWorldZDisp",n[n.ExtendedDataWorldZDir=1033]="ExtendedDataWorldZDir",n[n.ExtendedDataReal=1040]="ExtendedDataReal",n[n.ExtendedDataDist=1041]="ExtendedDataDist",n[n.ExtendedDataScale=1042]="ExtendedDataScale",n[n.ExtendedDataInteger16=1070]="ExtendedDataInteger16",n[n.ExtendedDataInteger32=1071]="ExtendedDataInteger32",n[n.XTextString=300]="XTextString",n[n.XReal=140]="XReal",n[n.XInt16=170]="XInt16",n[n.XXInt16=270]="XXInt16",n[n.Subclass=100]="Subclass",n[n.ControlString=102]="ControlString",n[n.EmbeddedObjectStart=101]="EmbeddedObjectStart",n[n.End=-1]="End",n[n.FirstEntityId=-2]="FirstEntityId",n[n.HeaderId=-2]="HeaderId",n[n.XDataStart=-3]="XDataStart",n[n.Operator=-4]="Operator",n[n.PReactors=-5]="PReactors",n[n.XDictionary=-6]="XDictionary",n))(Ns||{});exports.AcCmColorMethod=void 0;(function(n){n[n.ByColor=1]="ByColor",n[n.ByACI=2]="ByACI",n[n.ByLayer=3]="ByLayer",n[n.ByBlock=4]="ByBlock",n[n.None=0]="None"})(exports.AcCmColorMethod||(exports.AcCmColorMethod={}));var gu=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},fu=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},Va={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},Er=[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],$t=(function(){function n(){}return n.getColorByIndex=function(t){return Er[t]},n.getIndexByColor=function(t){for(var e=Er.length-1,i=1;i<e;++i)if(Er[i]===t)return i},n.getColorByName=function(t){return Va[t.toLowerCase()]},n.getNameByColor=function(t){var e,i;try{for(var r=gu(Object.entries(Va)),s=r.next();!s.done;s=r.next()){var a=fu(s.value,2),o=a[0],c=a[1];if(c===t)return o}}catch(l){e={error:l}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}},n.getNameByIndex=function(t){var e=this.getColorByIndex(t);return this.getNameByColor(e)},n})(),pu=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},X=(function(){function n(t,e){t===void 0&&(t=exports.AcCmColorMethod.ByLayer),this._colorMethod=t,this._colorMethod==exports.AcCmColorMethod.ByColor&&e==null?this._value=16777215:this._colorMethod==exports.AcCmColorMethod.ByACI?e==null?this._value=8:e===0?this._colorMethod=exports.AcCmColorMethod.ByBlock:e===256?this._colorMethod=exports.AcCmColorMethod.ByLayer:this._value=Math.max(0,Math.min(e,256)):this._value=e}return Object.defineProperty(n.prototype,"colorMethod",{get:function(){return this._colorMethod},set:function(t){this._colorMethod=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"red",{get:function(){var t=this.RGB;return t!=null?t>>16&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"green",{get:function(){var t=this.RGB;return t!=null?t>>8&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"blue",{get:function(){var t=this.RGB;return t!=null?t&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"RGB",{get:function(){switch(this._colorMethod){case exports.AcCmColorMethod.ByColor:case exports.AcCmColorMethod.ByBlock:case exports.AcCmColorMethod.ByLayer:return this._value;case exports.AcCmColorMethod.ByACI:return this._value?$t.getColorByIndex(this._value):this._value;default:return}},enumerable:!1,configurable:!0}),n.prototype.setRGB=function(t,e,i){var r=Math.max(0,Math.min(255,Math.round(t))),s=Math.max(0,Math.min(255,Math.round(e))),a=Math.max(0,Math.min(255,Math.round(i)));return this._value=r<<16|s<<8|a,this._colorMethod=exports.AcCmColorMethod.ByColor,this},n.prototype.setRGBValue=function(t){return t==null||!Number.isFinite(t)?this:(this._value=t&16777215,this._colorMethod=exports.AcCmColorMethod.ByColor,this)},n.prototype.setRGBFromCss=function(t){if(!t)return this;var e=t.trim().toLowerCase();if(e.startsWith("#")){var i=0,r=0,s=0;if(e.length===7)i=parseInt(e.substr(1,2),16),r=parseInt(e.substr(3,2),16),s=parseInt(e.substr(5,2),16);else if(e.length===4)i=parseInt(e[1]+e[1],16),r=parseInt(e[2]+e[2],16),s=parseInt(e[3]+e[3],16);else return this;return this.setRGB(i,r,s)}var a=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(a){var i=parseInt(a[1],10),r=parseInt(a[2],10),s=parseInt(a[3],10);return this.setRGB(i,r,s)}var o=$t.getColorByName(t);return o!==void 0?this.setRGBValue(o):this},n.prototype.setScalar=function(t){return this.setRGB(t,t,t)},Object.defineProperty(n.prototype,"hexColor",{get:function(){var t=this.RGB;if(t!=null){var e=t.toString(16).padStart(6,"0").toUpperCase();return"0x"+e}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cssColor",{get:function(){var t=this.RGB;if(t!=null)return"rgb(".concat(t>>16&255,",").concat(t>>8&255,",").concat(t&255,")")},enumerable:!1,configurable:!0}),n.prototype.cssColorAlpha=function(t){var e=this.RGB;if(e!=null)return"rgba(".concat(e>>16&255,",").concat(e>>8&255,",").concat(e&255,",").concat(t,")")},Object.defineProperty(n.prototype,"colorIndex",{get:function(){return this._colorMethod===exports.AcCmColorMethod.ByACI?this._value:this._colorMethod===exports.AcCmColorMethod.ByLayer?256:this._colorMethod===exports.AcCmColorMethod.ByBlock?0:void 0},set:function(t){if(t!=null){var e=Math.max(0,Math.min(256,Math.round(t)));e===0?(this._colorMethod=exports.AcCmColorMethod.ByBlock,this._value=void 0):e===256?(this._colorMethod=exports.AcCmColorMethod.ByLayer,this._value=void 0):(this._colorMethod=exports.AcCmColorMethod.ByACI,this._value=e)}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByColor",{get:function(){return this._colorMethod===exports.AcCmColorMethod.ByColor},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByACI",{get:function(){return this._colorMethod===exports.AcCmColorMethod.ByACI},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isForeground",{get:function(){return this._colorMethod===exports.AcCmColorMethod.ByACI&&this._value===7},enumerable:!1,configurable:!0}),n.prototype.setForeground=function(){return this._colorMethod=exports.AcCmColorMethod.ByACI,this._value=7,this},Object.defineProperty(n.prototype,"isByLayer",{get:function(){return this._colorMethod===exports.AcCmColorMethod.ByLayer},enumerable:!1,configurable:!0}),n.prototype.setByLayer=function(t){return this._colorMethod=exports.AcCmColorMethod.ByLayer,t==null?this._value=256:this._value=t,this},Object.defineProperty(n.prototype,"isByBlock",{get:function(){return this._colorMethod===exports.AcCmColorMethod.ByBlock},enumerable:!1,configurable:!0}),n.prototype.setByBlock=function(t){return this._colorMethod=exports.AcCmColorMethod.ByBlock,t==null?this._value=0:this._value=t,this},Object.defineProperty(n.prototype,"colorName",{get:function(){switch(this._colorMethod){case exports.AcCmColorMethod.ByLayer:return"ByLayer";case exports.AcCmColorMethod.ByBlock:return"ByBlock";case exports.AcCmColorMethod.ByColor:return this._value?$t.getNameByColor(this._value):"";case exports.AcCmColorMethod.ByACI:return this._value?$t.getNameByIndex(this._value):"";default:return}},set:function(t){if(t){var e=$t.getColorByName(t);e!==void 0&&(this._value=e,this._colorMethod=exports.AcCmColorMethod.ByColor)}},enumerable:!1,configurable:!0}),n.prototype.clone=function(){var t=new n;return t._colorMethod=this._colorMethod,t._value=this._value,t},n.prototype.copy=function(t){return this._colorMethod=t._colorMethod,this._value=t._value,this},n.prototype.equals=function(t){return this._colorMethod===t._colorMethod&&this._value===t._value},n.prototype.toString=function(){switch(this._colorMethod){case exports.AcCmColorMethod.None:return"None";case exports.AcCmColorMethod.ByLayer:return"ByLayer";case exports.AcCmColorMethod.ByBlock:return"ByBlock";case exports.AcCmColorMethod.ByACI:return this._value!==void 0?String(this._value):"";case exports.AcCmColorMethod.ByColor:return this._value?"RGB:".concat(this.red,",").concat(this.green,",").concat(this.blue):"";default:return""}},n.fromString=function(t){if(t){var e=t.trim();if(/^none$/i.test(e))return new n(exports.AcCmColorMethod.None);if(/^bylayer$/i.test(e))return new n(exports.AcCmColorMethod.ByLayer);if(/^byblock$/i.test(e))return new n(exports.AcCmColorMethod.ByBlock);var i=e.match(/^rgb\s*:\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})$/i);if(i){var r=Number(i[1]),s=Number(i[2]),a=Number(i[3]),o=new n(exports.AcCmColorMethod.ByColor);return o.setRGB(r,s,a),o}if(/^\d{1,3},\d{1,3},\d{1,3}$/.test(e)){var c=pu(e.split(",").map(Number),3),r=c[0],s=c[1],a=c[2],o=new n(exports.AcCmColorMethod.ByColor);return o.setRGB(r,s,a),o}if(/^\d+$/.test(e)){var l=parseInt(e,10);return new n(exports.AcCmColorMethod.ByACI,l)}if(/^book\$/i.test(e)){var h=e.substring(e.indexOf("$")+1),u=$t.getColorByName(h);return u!=null?new n(exports.AcCmColorMethod.ByColor,u):void 0}var d=$t.getColorByName(e);if(d!=null)return new n(exports.AcCmColorMethod.ByColor,d)}},n})(),mu=(function(){function n(t,e){t===void 0&&(t=exports.AcCmColorMethod.ByColor),e===void 0&&(e=0),this._colorMethod=t,this._value=e}return Object.defineProperty(n.prototype,"colorMethd",{get:function(){return this._colorMethod},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"red",{get:function(){return this._value>>16&255},set:function(t){this._colorMethod=exports.AcCmColorMethod.ByColor,this._value=this._value&65535|(t&255)<<16},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"green",{get:function(){return this._value>>8&255},set:function(t){this._colorMethod=exports.AcCmColorMethod.ByColor,this._value=this._value&16711935|(t&255)<<8},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"blue",{get:function(){return this._value&255},set:function(t){this._colorMethod=exports.AcCmColorMethod.ByColor,this._value=this._value&16776960|t&255},enumerable:!1,configurable:!0}),n.prototype.setRGB=function(t,e,i){this._colorMethod=exports.AcCmColorMethod.ByColor,this._value=(t&255)<<16|(e&255)<<8|i&255},Object.defineProperty(n.prototype,"colorIndex",{get:function(){return this._value},set:function(t){this._colorMethod=exports.AcCmColorMethod.ByACI,this._value=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"layerIndex",{get:function(){return this._value},set:function(t){this._colorMethod=exports.AcCmColorMethod.ByLayer,this._value=t},enumerable:!1,configurable:!0}),n.prototype.isByColor=function(){return this._colorMethod===exports.AcCmColorMethod.ByColor},n.prototype.isByLayer=function(){return this._colorMethod===exports.AcCmColorMethod.ByLayer},n.prototype.isByBlock=function(){return this._colorMethod===exports.AcCmColorMethod.ByBlock},n.prototype.isByACI=function(){return this._colorMethod===exports.AcCmColorMethod.ByACI},n.prototype.isNone=function(){return this._colorMethod===exports.AcCmColorMethod.None},Object.defineProperty(n.prototype,"rawValue",{get:function(){return this._value},set:function(t){this._value=t},enumerable:!1,configurable:!0}),n})(),Pt={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")}},yu=(function(){function n(){this._listeners={}}return n.prototype.addEventListener=function(t,e){this._listeners===void 0&&(this._listeners={});var i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)},n.prototype.hasEventListener=function(t,e){if(this._listeners===void 0)return!1;var i=this._listeners;return i[t]!==void 0&&i[t].indexOf(e)!==-1},n.prototype.removeEventListener=function(t,e){if(this._listeners!==void 0){var i=this._listeners,r=i[t];if(r!==void 0){var s=r.indexOf(e);s!==-1&&r.splice(s,1)}}},n.prototype.dispatchEvent=function(t){if(this._listeners!==void 0){var e=this._listeners,i=e[t.type];if(i!==void 0){t.target=this;for(var r=i.slice(0),s=0,a=r.length;s<a;s++)r[s].call(this,t)}}},n})(),bu=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},_u=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},xu=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},at=(function(){function n(){this.listeners=[]}return n.prototype.addEventListener=function(t){this.listeners.push(t)},n.prototype.removeEventListener=function(t){this.listeners=this.listeners.filter(function(e){return e!==t})},n.prototype.replaceEventListener=function(t){this.removeEventListener(t),this.addEventListener(t)},n.prototype.dispatch=function(t){for(var e,i,r=[],s=1;s<arguments.length;s++)r[s-1]=arguments[s];try{for(var a=bu(this.listeners),o=a.next();!o.done;o=a.next()){var c=o.value,l=c;l.call.apply(l,xu([null,t],_u(r),!1))}}catch(h){e={error:h}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(e)throw e.error}}},n})(),is=function(){return is=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},is.apply(this,arguments)},wu=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},vu=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},Vo=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function gi(n){return n===null||typeof n!="object"?n:Array.isArray(n)?vu([],wu(n),!1):is({},n)}function ns(n){if(n===null||typeof n!="object")return n;if(n instanceof Date)return new Date(n.getTime());if(n instanceof RegExp)return new RegExp(n.source,n.flags);if(Array.isArray(n))return n.map(ns);var t={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=ns(n[e]));return t}function Bt(n){for(var t,e,i=[],r=1;r<arguments.length;r++)i[r-1]=arguments[r];try{for(var s=Vo(i),a=s.next();!a.done;a=s.next()){var o=a.value;if(o)for(var c in o)Object.prototype.hasOwnProperty.call(o,c)&&n[c]===void 0&&(n[c]=o[c])}}catch(l){t={error:l}}finally{try{a&&!a.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return n}function Go(n,t){return n!=null&&Object.prototype.hasOwnProperty.call(n,t)}function Uo(n){return n==null?!0:Array.isArray(n)||typeof n=="string"?n.length===0:n instanceof Map||n instanceof Set?n.size===0:typeof n=="object"?Object.keys(n).length===0:!1}function Me(n,t){var e,i;if(n===t)return!0;if(n==null||t==null)return n===t;if(typeof n!=typeof t)return!1;if(typeof n!="object")return n===t;if(Array.isArray(n)!==Array.isArray(t))return!1;if(Array.isArray(n)){if(n.length!==t.length)return!1;for(var r=0;r<n.length;r++)if(!Me(n[r],t[r]))return!1;return!0}var s=Object.keys(n),a=Object.keys(t);if(s.length!==a.length)return!1;try{for(var o=Vo(s),c=o.next();!c.done;c=o.next()){var l=c.value;if(!Object.prototype.hasOwnProperty.call(t,l)||!Me(n[l],t[l]))return!1}}catch(h){e={error:h}}finally{try{c&&!c.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}return!0}function ku(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var bn={exports:{}},Au=bn.exports,Ga;function Su(){return Ga||(Ga=1,(function(n){(function(t,e){n.exports?n.exports=e():t.log=e()})(Au,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"],s={},a=null;function o(f,m){var b=f[m];if(typeof b.bind=="function")return b.bind(f);try{return Function.prototype.bind.call(b,f)}catch{return function(){return Function.prototype.apply.apply(b,[f,arguments])}}}function c(){console.log&&(console.log.apply||Function.prototype.apply.apply(console.log,[console,arguments]))}function l(f){return f==="debug"&&(f="log"),typeof console===e?!1:f==="trace"&&i?c:console[f]!==void 0?o(console,f):console.log!==void 0?o(console,"log"):t}function h(){for(var f=this.getLevel(),m=0;m<r.length;m++){var b=r[m];this[b]=m<f?t:this.methodFactory(b,f,this.name)}if(this.log=this.debug,typeof console===e&&f<this.levels.SILENT)return"No console available for logging"}function u(f){return function(){typeof console!==e&&(h.call(this),this[f].apply(this,arguments))}}function d(f,m,b){return l(f)||u.apply(this,arguments)}function g(f,m){var b=this,_,v,x,S="loglevel";typeof f=="string"?S+=":"+f:typeof f=="symbol"&&(S=void 0);function P(N){var M=(r[N]||"silent").toUpperCase();if(!(typeof window===e||!S)){try{window.localStorage[S]=M;return}catch{}try{window.document.cookie=encodeURIComponent(S)+"="+M+";"}catch{}}}function E(){var N;if(!(typeof window===e||!S)){try{N=window.localStorage[S]}catch{}if(typeof N===e)try{var M=window.document.cookie,A=encodeURIComponent(S),V=M.indexOf(A+"=");V!==-1&&(N=/^([^;]+)/.exec(M.slice(V+A.length+1))[1])}catch{}return b.levels[N]===void 0&&(N=void 0),N}}function O(){if(!(typeof window===e||!S)){try{window.localStorage.removeItem(S)}catch{}try{window.document.cookie=encodeURIComponent(S)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function T(N){var M=N;if(typeof M=="string"&&b.levels[M.toUpperCase()]!==void 0&&(M=b.levels[M.toUpperCase()]),typeof M=="number"&&M>=0&&M<=b.levels.SILENT)return M;throw new TypeError("log.setLevel() called with invalid level: "+N)}b.name=f,b.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},b.methodFactory=m||d,b.getLevel=function(){return x??v??_},b.setLevel=function(N,M){return x=T(N),M!==!1&&P(x),h.call(b)},b.setDefaultLevel=function(N){v=T(N),E()||b.setLevel(N,!1)},b.resetLevel=function(){x=null,O(),h.call(b)},b.enableAll=function(N){b.setLevel(b.levels.TRACE,N)},b.disableAll=function(N){b.setLevel(b.levels.SILENT,N)},b.rebuild=function(){if(a!==b&&(_=T(a.getLevel())),h.call(b),a===b)for(var N in s)s[N].rebuild()},_=T(a?a.getLevel():"WARN");var R=E();R!=null&&(x=T(R)),h.call(b)}a=new g,a.getLogger=function(m){if(typeof m!="symbol"&&typeof m!="string"||m==="")throw new TypeError("You must supply a name when creating a logger.");var b=s[m];return b||(b=s[m]=new g(m,a.methodFactory)),b};var p=typeof window!==e?window.log:void 0;return a.noConflict=function(){return typeof window!==e&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return s},a.default=a,a})})(bn)),bn.exports}var Pu=Su();const Iu=ku(Pu);var Eu=!0,pi=Iu;pi.setLevel("debug");var Lu=function(n){try{pi.setLevel(n)}catch(t){pi.setLevel("error"),pi.error(t)}},rs=(function(){function n(t,e){this.events={attrChanged:new at,modelChanged:new at},this._changing=!1,this._previousAttributes={},this._pending=!1;var i=t||{};e&&Bt(i,e),this.attributes=i,this.changed={}}return n.prototype.get=function(t){return this.attributes[t]},n.prototype.set=function(t,e,i){if(t==null)return this;var r;typeof t=="object"?(r=t,i=e):(r={},r[t]=e),i||(i={});var s=i.unset,a=i.silent,o=[],c=this._changing;this._changing=!0,c||(this._previousAttributes=gi(this.attributes),this.changed={});var l=this.attributes,h=this.changed,u=this._previousAttributes;for(var d in r)e=r[d],Me(l[d],e)||o.push(d),Me(u[d],e)?delete h[d]:h[d]=e,s?delete l[d]:l[d]=e;if(!a){o.length&&(this._pending=i);for(var g=0;g<o.length;g++)this.events.attrChanged.dispatch({object:this,attrName:o[g],attrValue:l[o[g]],options:i})}if(c)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},n.prototype.has=function(t){return this.get(t)!=null},n.prototype.hasChanged=function(t){return t==null?!Uo(this.changed):Go(this.changed,t)},n.prototype.changedAttributes=function(t){if(!t)return this.hasChanged()?gi(this.changed):{};var e=this._changing?this._previousAttributes:this.attributes,i={};for(var r in t){var s=t[r];Me(e[r],s)||(i[r]=s)}return i},n.prototype.previous=function(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]},n.prototype.previousAttributes=function(){return gi(this._previousAttributes)},n.prototype.clone=function(){var t=gi(this.attributes);return new n(t)},n})(),Tu=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Cu=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},Rs=(function(){function n(){this.entries=new Map}return n.getInstance=function(){return n.instance||(n.instance=new n),n.instance},n.prototype.collect=function(t){this.entries.set(t.name,t)},n.prototype.printAll=function(){var t,e;try{for(var i=Tu(this.entries),r=i.next();!r.done;r=i.next())var s=Cu(r.value,2),a=s[0],o=s[1]}catch(c){t={error:c}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}},n.prototype.clear=function(){this.entries.clear()},n.prototype.getAll=function(){return Array.from(this.entries.values())},n.prototype.getEntry=function(t){return this.entries.get(t)},n.prototype.remove=function(t){return this.entries.delete(t)},n})(),Mu=(function(){function n(){}return n.formatBytes=function(t,e){if(e===void 0&&(e=2),t===0)return"0 B";var i=1024,r=Math.max(0,e),s=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(t)/Math.log(i)),o=t/Math.pow(i,a);return"".concat(parseFloat(o.toFixed(r))," ").concat(s[a])},n})();exports.AcCmTransparencyMethod=void 0;(function(n){n[n.ByLayer=0]="ByLayer",n[n.ByBlock=1]="ByBlock",n[n.ByAlpha=2]="ByAlpha",n[n.ErrorValue=3]="ErrorValue"})(exports.AcCmTransparencyMethod||(exports.AcCmTransparencyMethod={}));var ot=(function(){function n(t){t!==void 0?(this._method=exports.AcCmTransparencyMethod.ByAlpha,this._alpha=n.clampAlpha(t)):(this._method=exports.AcCmTransparencyMethod.ByLayer,this._alpha=255)}return Object.defineProperty(n.prototype,"method",{get:function(){return this._method},set:function(t){this._method=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha=n.clampAlpha(t),this._method=exports.AcCmTransparencyMethod.ByAlpha},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"percentage",{get:function(){if(this._method===exports.AcCmTransparencyMethod.ByAlpha)return Math.round((1-this._alpha/255)*100)},set:function(t){var e=Math.max(0,Math.min(100,t)),i=Math.round(255*(1-e/100));this.alpha=i},enumerable:!1,configurable:!0}),n.clampAlpha=function(t){return Math.max(0,Math.min(255,Math.floor(t)))},Object.defineProperty(n.prototype,"isByAlpha",{get:function(){return this._method===exports.AcCmTransparencyMethod.ByAlpha},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByBlock",{get:function(){return this._method===exports.AcCmTransparencyMethod.ByBlock},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByLayer",{get:function(){return this._method===exports.AcCmTransparencyMethod.ByLayer},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isClear",{get:function(){return this.isByAlpha&&this._alpha===0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isSolid",{get:function(){return this.isByAlpha&&this._alpha===255},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isInvalid",{get:function(){return this._method===exports.AcCmTransparencyMethod.ErrorValue},enumerable:!1,configurable:!0}),n.prototype.serialize=function(){var t=this._method;return t<<24|this._alpha},n.prototype.clone=function(){var t=new n;return t._method=this._method,t._alpha=this._alpha,t},n.prototype.equals=function(t){return this._method===t._method&&this._alpha===t._alpha},n.prototype.toString=function(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this._alpha.toString()},n.fromString=function(t){var e=t.trim(),i=e.toLowerCase();if(i===""||i==="."||i==="use current"||i==="bylayer"){var r=new n;return r._method=exports.AcCmTransparencyMethod.ByLayer,r}if(i==="byblock"){var s=new n;return s._method=exports.AcCmTransparencyMethod.ByBlock,s}var a=Number(e);if(Number.isInteger(a)&&a>=0&&a<=255){var o=new n;return a<=90?o.percentage=a:o.alpha=a,o}var c=new n;return c._method=exports.AcCmTransparencyMethod.ErrorValue,c},n.deserialize=function(t){var e=t>>>24&255,i=t&255,r=e>=exports.AcCmTransparencyMethod.ByLayer&&e<=exports.AcCmTransparencyMethod.ErrorValue?e:exports.AcCmTransparencyMethod.ErrorValue,s=new n;return s._method=r,s._alpha=n.clampAlpha(i),s},n})(),Ou=function(n,t,e,i){function r(s){return s instanceof e?s:new e(function(a){a(s)})}return new(e||(e=Promise))(function(s,a){function o(h){try{l(i.next(h))}catch(u){a(u)}}function c(h){try{l(i.throw(h))}catch(u){a(u)}}function l(h){h.done?s(h.value):r(h.value).then(o,c)}l((i=i.apply(n,t||[])).next())})},Nu=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(e=0)),e;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(h){l=[6,h],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Pi=50;function ai(){return new Promise(function(n){typeof globalThis<"u"&&typeof globalThis.requestAnimationFrame=="function"?globalThis.requestAnimationFrame(function(){return n()}):setTimeout(n,0)})}function Ho(){return new Promise(function(n){if(typeof globalThis<"u"&&typeof globalThis.requestAnimationFrame=="function"){var t=globalThis.requestAnimationFrame;t(function(){return t(function(){return n()})})}else setTimeout(n,0)})}var pr=(function(){function n(t){t===void 0&&(t=Pi),this._budgetMs=t,this._lastYieldCompletedAt=n.now()}return Object.defineProperty(n.prototype,"budgetMs",{get:function(){return this._budgetMs},enumerable:!1,configurable:!0}),n.prototype.maybeYield=function(){return Ou(this,arguments,void 0,function(t){var e;return t===void 0&&(t=ai),Nu(this,function(i){switch(i.label){case 0:return e=n.now(),e-this._lastYieldCompletedAt<this._budgetMs?[2,!1]:[4,t()];case 1:return i.sent(),this._lastYieldCompletedAt=n.now(),[2,!0]}})})},n.prototype.mark=function(){this._lastYieldCompletedAt=n.now()},n.now=function(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()},n})(),Lr=function(n,t,e,i){function r(s){return s instanceof e?s:new e(function(a){a(s)})}return new(e||(e=Promise))(function(s,a){function o(h){try{l(i.next(h))}catch(u){a(u)}}function c(h){try{l(i.throw(h))}catch(u){a(u)}}function l(h){h.done?s(h.value):r(h.value).then(o,c)}l((i=i.apply(n,t||[])).next())})},Qi=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(e=0)),e;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(h){l=[6,h],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Wo=(function(){function n(t){this.name=t}return n.prototype.run=function(t){throw new Error("run() must be implemented by subclass")},n})(),$o=(function(){function n(){this.tasks=[],this.onProgress=function(){},this.onComplete=function(){},this.onError=function(){return!1}}return n.prototype.scheduleTask=function(t){return Lr(this,void 0,void 0,function(){return Qi(this,function(e){switch(e.label){case 0:return[4,ai()];case 1:return e.sent(),[2,t()]}})})},n.prototype.addTask=function(t){this.tasks.push(t)},n.prototype.setProgressCallback=function(t){this.onProgress=t},n.prototype.setCompleteCallback=function(t){this.onComplete=t},n.prototype.setErrorCallback=function(t){this.onError=t},n.prototype.run=function(t){return Lr(this,void 0,void 0,function(){var e,i,r,s,a,o,c=this;return Qi(this,function(l){switch(l.label){case 0:e=this.tasks.length,i=t,r=function(h){var u,d,g;return Qi(this,function(p){switch(p.label){case 0:u=s.tasks[h],p.label=1;case 1:return p.trys.push([1,3,,4]),[4,s.scheduleTask(function(){return Lr(c,void 0,void 0,function(){var f;return Qi(this,function(m){switch(m.label){case 0:return[4,u.run(i)];case 1:return f=m.sent(),this.onProgress((h+1)/e,u),[2,f]}})})})];case 2:return i=p.sent(),[3,4];case 3:return d=p.sent(),g=s.onError({error:d,taskIndex:h,task:u}),g?[2,{value:Promise.reject(d)}]:[3,4];case 4:return[2]}})},s=this,a=0,l.label=1;case 1:return a<e?[5,r(a)]:[3,4];case 2:if(o=l.sent(),typeof o=="object")return[2,o.value];l.label=3;case 3:return a++,[3,1];case 4:return this.onComplete(i),[2]}})})},n})(),qo=(function(){function n(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}return n.prototype.itemStart=function(t){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(t,this.itemsLoaded,this.itemsTotal),this.isLoading=!0},n.prototype.itemEnd=function(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())},n.prototype.itemError=function(t){this.onError!==void 0&&this.onError(t)},n.prototype.resolveURL=function(t){return this.urlModifier?this.urlModifier(t):t},n.prototype.setURLModifier=function(t){return this.urlModifier=t,this},n.prototype.addHandler=function(t,e){return this.handlers.push(t,e),this},n.prototype.removeHandler=function(t){var e=this.handlers.indexOf(t);return e!==-1&&this.handlers.splice(e,2),this},n.prototype.getHandler=function(t){for(var e=0,i=this.handlers.length;e<i;e+=2){var r=this.handlers[e],s=this.handlers[e+1];if(r.global&&(r.lastIndex=0),r.test(t))return s}return null},n})(),Ko=new qo,Ru=(function(){function n(t){this.manager=t!==void 0?t:Ko,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}return n.prototype.loadAsync=function(t,e){var i=this;return new Promise(function(r,s){i.load(t,r,e,s)})},n.prototype.parse=function(t){},n.prototype.setCrossOrigin=function(t){return this.crossOrigin=t,this},n.prototype.setWithCredentials=function(t){return this.withCredentials=t,this},n.prototype.setPath=function(t){return this.path=t,this},n.prototype.setResourcePath=function(t){return this.resourcePath=t,this},n.prototype.setRequestHeader=function(t){return this.requestHeader=t,this},n})(),xt=["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"],Ua=1234567,Bs=Math.PI/180,Fs=180/Math.PI;function Zo(){var n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0,r=xt[n&255]+xt[n>>8&255]+xt[n>>16&255]+xt[n>>24&255]+"-"+xt[t&255]+xt[t>>8&255]+"-"+xt[t>>16&15|64]+xt[t>>24&255]+"-"+xt[e&63|128]+xt[e>>8&255]+"-"+xt[e>>16&255]+xt[e>>24&255]+xt[i&255]+xt[i>>8&255]+xt[i>>16&255]+xt[i>>24&255];return r.toLowerCase()}function re(n,t,e){return Math.max(t,Math.min(e,n))}function Ds(n,t){return(n%t+t)%t}function Qo(n,t,e,i,r){return i+(n-t)*(r-i)/(e-t)}function Jo(n,t,e){return n!==t?(e-n)/(t-n):0}function Ys(n,t,e){return(1-e)*n+e*t}function tc(n,t,e,i){return Ys(n,t,1-Math.exp(-e*i))}function ec(n,t){return t===void 0&&(t=1),t-Math.abs(Ds(n,t*2)-t)}function ic(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))}function nc(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))}function rc(n,t){return n+Math.floor(Math.random()*(t-n+1))}function sc(n,t){return n+Math.random()*(t-n)}function ac(n){return n*(.5-Math.random())}function oc(n){n!==void 0&&(Ua=n);var t=Ua+=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 cc(n){return n*Bs}function lc(n){return n*Fs}function hc(n){return(n&n-1)===0&&n!==0}function uc(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function dc(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function mi(n){var t=Math.PI*2;return(n%t+t)%t}function gc(n,t,e){return n>t&&n<e||n>e&&n<t}function fc(n,t,e,i){return i===void 0&&(i=!1),n=mi(n),t=mi(t),e=mi(e),i?t>e?n<=t&&n>=e:n<=t||n>=e:t<e?n>=t&&n<=e:n>=t||n<=e}function Xs(n){return n=Math.abs(n),n<1?0:Math.ceil(Math.log10(Math.abs(n)+1))}function pc(n,t){t===void 0&&(t=1e-7);var e=Xs(n);return Math.max(Math.pow(10,e)*t,t)}var C={DEG2RAD:Bs,RAD2DEG:Fs,generateUUID:Zo,clamp:re,euclideanModulo:Ds,mapLinear:Qo,inverseLerp:Jo,lerp:Ys,damp:tc,pingpong:ec,smoothstep:ic,smootherstep:nc,randInt:rc,randFloat:sc,randFloatSpread:ac,seededRandom:oc,degToRad:cc,radToDeg:lc,isPowerOfTwo:hc,ceilPowerOfTwo:uc,floorPowerOfTwo:dc,normalizeAngle:mi,isBetween:gc,isBetweenAngle:fc,intPartLength:Xs,relativeEps:pc},Bu=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(e=0)),e;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(h){l=[6,h],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},nt=(function(){function n(t,e){this.x=0,this.y=0;var 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){var r=t,s=r.x,a=r.y;this.x=s,this.y=a;return}if(i===2){this.x=t,this.y=e;return}throw Pt.ILLEGAL_PARAMETERS}}return Object.defineProperty(n.prototype,"width",{get:function(){return this.x},set:function(t){this.x=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this.y},set:function(t){this.y=t},enumerable:!1,configurable:!0}),n.prototype.set=function(t,e){return this.x=t,this.y=e,this},n.prototype.setScalar=function(t){return this.x=t,this.y=t,this},n.prototype.setX=function(t){return this.x=t,this},n.prototype.setY=function(t){return this.y=t,this},n.prototype.setComponent=function(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},n.prototype.getComponent=function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},n.prototype.clone=function(){return new n(this.x,this.y)},n.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this},n.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},n.prototype.addScalar=function(t){return this.x+=t,this.y+=t,this},n.prototype.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},n.prototype.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},n.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this},n.prototype.subScalar=function(t){return this.x-=t,this.y-=t,this},n.prototype.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},n.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},n.prototype.multiplyScalar=function(t){return this.x*=t,this.y*=t,this},n.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this},n.prototype.divideScalar=function(t){return this.multiplyScalar(1/t)},n.prototype.applyMatrix2d=function(t){var 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},n.prototype.min=function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},n.prototype.max=function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},n.prototype.clamp=function(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},n.prototype.clampScalar=function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this},n.prototype.clampLength=function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},n.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},n.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},n.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},n.prototype.roundToZero=function(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this},n.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},n.prototype.dot=function(t){return this.x*t.x+this.y*t.y},n.prototype.cross=function(t){return this.x*t.y-this.y*t.x},n.prototype.lengthSq=function(){return this.x*this.x+this.y*this.y},n.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},n.prototype.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)},n.prototype.normalize=function(){return this.divideScalar(this.length()||1)},n.prototype.angle=function(){var t=Math.atan2(-this.y,-this.x)+Math.PI;return t},n.prototype.angleTo=function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;var i=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,i)))},n.prototype.distanceTo=function(t){return Math.sqrt(this.distanceToSquared(t))},n.prototype.distanceToSquared=function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},n.prototype.manhattanDistanceTo=function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},n.prototype.setLength=function(t){return this.normalize().multiplyScalar(t)},n.prototype.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},n.prototype.lerpVectors=function(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this},n.prototype.equals=function(t){return t.x===this.x&&t.y===this.y},n.prototype.fromArray=function(t,e){return e===void 0&&(e=0),this.x=t[e],this.y=t[e+1],this},n.prototype.toArray=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this.x,t[e+1]=this.y,t},n.prototype.rotateAround=function(t,e){var i=Math.cos(e),r=Math.sin(e),s=this.x-t.x,a=this.y-t.y;return this.x=s*i-a*r+t.x,this.y=s*r+a*i+t.y,this},n.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this},n.prototype.relativeEps=function(t){return t===void 0&&(t=1e-7),Math.min(C.relativeEps(this.x,t),C.relativeEps(this.y,t))},n.prototype[Symbol.iterator]=function(){return Bu(this,function(t){switch(t.label){case 0:return[4,this.x];case 1:return t.sent(),[4,this.y];case 2:return t.sent(),[2]}})},n.EMPTY=Object.freeze(new n(0,0)),n})(),Ui=(function(){function n(t,e,i,r,s,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&i!=null&&r!=null&&s!=null&&a!=null&&o!=null&&c!=null&&l!=null&&this.set(t,e,i,r,s,a,o,c,l)}return n.prototype.set=function(t,e,i,r,s,a,o,c,l){var h=this.elements;return h[0]=t,h[1]=r,h[2]=o,h[3]=e,h[4]=s,h[5]=c,h[6]=i,h[7]=a,h[8]=l,this},n.prototype.identity=function(){return this.set(1,0,0,0,1,0,0,0,1),this},n.prototype.copy=function(t){var 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},n.prototype.extractBasis=function(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this},n.prototype.setFromMatrix4=function(t){var 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},n.prototype.multiply=function(t){return this.multiplyMatrices(this,t)},n.prototype.premultiply=function(t){return this.multiplyMatrices(t,this)},n.prototype.multiplyMatrices=function(t,e){var i=t.elements,r=e.elements,s=this.elements,a=i[0],o=i[3],c=i[6],l=i[1],h=i[4],u=i[7],d=i[2],g=i[5],p=i[8],f=r[0],m=r[3],b=r[6],_=r[1],v=r[4],x=r[7],S=r[2],P=r[5],E=r[8];return s[0]=a*f+o*_+c*S,s[3]=a*m+o*v+c*P,s[6]=a*b+o*x+c*E,s[1]=l*f+h*_+u*S,s[4]=l*m+h*v+u*P,s[7]=l*b+h*x+u*E,s[2]=d*f+g*_+p*S,s[5]=d*m+g*v+p*P,s[8]=d*b+g*x+p*E,this},n.prototype.multiplyScalar=function(t){var 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},n.prototype.determinant=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-i*s*h+i*o*c+r*s*l-r*a*c},n.prototype.invert=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=h*a-o*l,d=o*c-h*s,g=l*s-a*c,p=e*u+i*d+r*g;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);var f=1/p;return t[0]=u*f,t[1]=(r*l-h*i)*f,t[2]=(o*i-r*a)*f,t[3]=d*f,t[4]=(h*e-r*c)*f,t[5]=(r*s-o*e)*f,t[6]=g*f,t[7]=(i*c-l*e)*f,t[8]=(a*e-i*s)*f,this},n.prototype.transpose=function(){var t,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},n.prototype.getNormalMatrix=function(t){return this.setFromMatrix4(t).invert().transpose()},n.prototype.transposeIntoArray=function(t){var 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},n.prototype.setUvTransform=function(t,e,i,r,s,a,o){var c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*a+l*o)+a+t,-r*l,r*c,-r*(-l*a+c*o)+o+e,0,0,1),this},n.prototype.scale=function(t,e){return this.premultiply(Tr.makeScale(t,e)),this},n.prototype.rotate=function(t){return this.premultiply(Tr.makeRotation(-t)),this},n.prototype.translate=function(t,e){return this.premultiply(Tr.makeTranslation(t,e)),this},n.prototype.makeTranslation=function(t,e){return t instanceof nt?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},n.prototype.makeRotation=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this},n.prototype.makeScale=function(t,e){return this.set(t,0,0,0,e,0,0,0,1),this},n.prototype.equals=function(t){for(var e=this.elements,i=t.elements,r=0;r<9;r++)if(e[r]!==i[r])return!1;return!0},n.prototype.fromArray=function(t,e){e===void 0&&(e=0);for(var i=0;i<9;i++)this.elements[i]=t[i+e];return this},n.prototype.toArray=function(t,e){t===void 0&&(t=[]),e===void 0&&(e=0);var 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},n.prototype.clone=function(){return new n().fromArray(this.elements)},n.IDENTITY=Object.freeze(new n),n})(),Tr=new Ui,ne=1e-6,j=2*Math.PI,Fu={x:0,y:0},zs={x:0,y:0,z:0},K=(function(){function n(){this.equalPointTol=ne,this.equalVectorTol=ne}return n.prototype.clone=function(){var t=new n;return t.equalPointTol=this.equalPointTol,t.equalVectorTol=this.equalVectorTol,t},n.prototype.equalPoint2d=function(t,e){return new nt(t).sub(e).length()<this.equalPointTol},n.prototype.equalPoint3d=function(t,e){return new w(t).sub(e).length()<this.equalPointTol},n.equalToZero=function(t,e){return e===void 0&&(e=ne),t<e&&t>-e},n.equal=function(t,e,i){return i===void 0&&(i=ne),Math.abs(t-e)<i},n.great=function(t,e,i){return i===void 0&&(i=ne),t-e>i},n.less=function(t,e,i){return i===void 0&&(i=ne),t-e<i},n.isPositive=function(t,e){return e===void 0&&(e=ne),t>e},n.isNonPositive=function(t,e){return e===void 0&&(e=ne),t<=e},n})(),mr=new K,Du=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(e=0)),e;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(h){l=[6,h],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Je=(function(){function n(t,e,i,r){t===void 0&&(t=0),e===void 0&&(e=0),i===void 0&&(i=0),r===void 0&&(r=1),this._x=t,this._y=e,this._z=i,this._w=r}return n.slerpFlat=function(t,e,i,r,s,a,o){var c=i[r+0],l=i[r+1],h=i[r+2],u=i[r+3],d=s[a+0],g=s[a+1],p=s[a+2],f=s[a+3];if(o===0){t[e+0]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u;return}if(o===1){t[e+0]=d,t[e+1]=g,t[e+2]=p,t[e+3]=f;return}if(u!==f||c!==d||l!==g||h!==p){var m=1-o,b=c*d+l*g+h*p+u*f,_=b>=0?1:-1,v=1-b*b;if(v>Number.EPSILON){var x=Math.sqrt(v),S=Math.atan2(x,b*_);m=Math.sin(m*S)/x,o=Math.sin(o*S)/x}var P=o*_;if(c=c*m+d*P,l=l*m+g*P,h=h*m+p*P,u=u*m+f*P,m===1-o){var E=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=E,l*=E,h*=E,u*=E}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u},n.multiplyQuaternionsFlat=function(t,e,i,r,s,a){var o=i[r],c=i[r+1],l=i[r+2],h=i[r+3],u=s[a],d=s[a+1],g=s[a+2],p=s[a+3];return t[e]=o*p+h*u+c*g-l*d,t[e+1]=c*p+h*d+l*u-o*g,t[e+2]=l*p+h*g+o*d-c*u,t[e+3]=h*p-o*u-c*d-l*g,t},Object.defineProperty(n.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"z",{get:function(){return this._z},set:function(t){this._z=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"w",{get:function(){return this._w},set:function(t){this._w=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),n.prototype.set=function(t,e,i,r){return this._x=t,this._y=e,this._z=i,this._w=r,this._onChangeCallback(),this},n.prototype.clone=function(){return new n(this._x,this._y,this._z,this._w)},n.prototype.copy=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},n.prototype.setFromEuler=function(t,e){e===void 0&&(e=!0);var i=t.x,r=t.y,s=t.z,a=t.order,o=Math.cos,c=Math.sin,l=o(i/2),h=o(r/2),u=o(s/2),d=c(i/2),g=c(r/2),p=c(s/2);switch(a){case"XYZ":this._x=d*h*u+l*g*p,this._y=l*g*u-d*h*p,this._z=l*h*p+d*g*u,this._w=l*h*u-d*g*p;break;case"YXZ":this._x=d*h*u+l*g*p,this._y=l*g*u-d*h*p,this._z=l*h*p-d*g*u,this._w=l*h*u+d*g*p;break;case"ZXY":this._x=d*h*u-l*g*p,this._y=l*g*u+d*h*p,this._z=l*h*p+d*g*u,this._w=l*h*u-d*g*p;break;case"ZYX":this._x=d*h*u-l*g*p,this._y=l*g*u+d*h*p,this._z=l*h*p-d*g*u,this._w=l*h*u+d*g*p;break;case"YZX":this._x=d*h*u+l*g*p,this._y=l*g*u+d*h*p,this._z=l*h*p-d*g*u,this._w=l*h*u-d*g*p;break;case"XZY":this._x=d*h*u-l*g*p,this._y=l*g*u-d*h*p,this._z=l*h*p+d*g*u,this._w=l*h*u+d*g*p;break;default:}return e===!0&&this._onChangeCallback(),this},n.prototype.setFromAxisAngle=function(t,e){var 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},n.prototype.setFromRotationMatrix=function(t){var e=t.elements,i=e[0],r=e[4],s=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],u=e[10],d=i+o+u;if(d>0){var g=.5/Math.sqrt(d+1);this._w=.25/g,this._x=(h-c)*g,this._y=(s-l)*g,this._z=(a-r)*g}else if(i>o&&i>u){var g=2*Math.sqrt(1+i-o-u);this._w=(h-c)/g,this._x=.25*g,this._y=(r+a)/g,this._z=(s+l)/g}else if(o>u){var g=2*Math.sqrt(1+o-i-u);this._w=(s-l)/g,this._x=(r+a)/g,this._y=.25*g,this._z=(c+h)/g}else{var g=2*Math.sqrt(1+u-i-o);this._w=(a-r)/g,this._x=(s+l)/g,this._y=(c+h)/g,this._z=.25*g}return this._onChangeCallback(),this},n.prototype.setFromUnitVectors=function(t,e){var 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()},n.prototype.angleTo=function(t){return 2*Math.acos(Math.abs(re(this.dot(t),-1,1)))},n.prototype.rotateTowards=function(t,e){var i=this.angleTo(t);if(i===0)return this;var r=Math.min(1,e/i);return this.slerp(t,r),this},n.prototype.identity=function(){return this.set(0,0,0,1)},n.prototype.invert=function(){return this.conjugate()},n.prototype.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},n.prototype.dot=function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},n.prototype.lengthSq=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},n.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},n.prototype.normalize=function(){var 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},n.prototype.multiply=function(t){return this.multiplyQuaternions(this,t)},n.prototype.premultiply=function(t){return this.multiplyQuaternions(t,this)},n.prototype.multiplyQuaternions=function(t,e){var i=t._x,r=t._y,s=t._z,a=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=i*h+a*o+r*l-s*c,this._y=r*h+a*c+s*o-i*l,this._z=s*h+a*l+i*c-r*o,this._w=a*h-i*o-r*c-s*l,this._onChangeCallback(),this},n.prototype.slerp=function(t,e){if(e===0)return this;if(e===1)return this.copy(t);var i=this._x,r=this._y,s=this._z,a=this._w,o=a*t._w+i*t._x+r*t._y+s*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=s,this;var c=1-o*o;if(c<=Number.EPSILON){var l=1-e;return this._w=l*a+e*this._w,this._x=l*i+e*this._x,this._y=l*r+e*this._y,this._z=l*s+e*this._z,this.normalize(),this}var h=Math.sqrt(c),u=Math.atan2(h,o),d=Math.sin((1-e)*u)/h,g=Math.sin(e*u)/h;return this._w=a*d+this._w*g,this._x=i*d+this._x*g,this._y=r*d+this._y*g,this._z=s*d+this._z*g,this._onChangeCallback(),this},n.prototype.slerpQuaternions=function(t,e,i){return this.copy(t).slerp(e,i)},n.prototype.random=function(){var t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(t),r*Math.cos(t),s*Math.sin(e),s*Math.cos(e))},n.prototype.equals=function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},n.prototype.fromArray=function(t,e){return e===void 0&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this},n.prototype.toArray=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},n.prototype.toJSON=function(){return this.toArray()},n.prototype._onChange=function(t){return this._onChangeCallback=t,this},n.prototype._onChangeCallback=function(){},n.prototype[Symbol.iterator]=function(){return Du(this,function(t){switch(t.label){case 0:return[4,this._x];case 1:return t.sent(),[4,this._y];case 2:return t.sent(),[4,this._z];case 3:return t.sent(),[4,this._w];case 4:return t.sent(),[2]}})},n})(),Yu=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(e=0)),e;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(h){l=[6,h],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},w=(function(){function n(t,e,i){this.x=0,this.y=0,this.z=0;var 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){var s=t,a=s.x,o=s.y,c=s.z;this.x=a,this.y=o,this.z=c||0;return}if(r===3){this.x=t,this.y=e,this.z=i;return}throw Pt.ILLEGAL_PARAMETERS}}return n.prototype.set=function(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,this},n.prototype.setScalar=function(t){return this.x=t,this.y=t,this.z=t,this},n.prototype.setX=function(t){return this.x=t,this},n.prototype.setY=function(t){return this.y=t,this},n.prototype.setZ=function(t){return this.z=t,this},n.prototype.setComponent=function(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},n.prototype.getComponent=function(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)}},n.prototype.clone=function(){return new n(this.x,this.y,this.z)},n.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this},n.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this},n.prototype.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this},n.prototype.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},n.prototype.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},n.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},n.prototype.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this},n.prototype.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},n.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this},n.prototype.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this},n.prototype.multiplyVectors=function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},n.prototype.applyEuler=function(t){return this.applyQuaternion(Ha.setFromEuler(t))},n.prototype.applyAxisAngle=function(t,e){return this.applyQuaternion(Ha.setFromAxisAngle(t,e))},n.prototype.applyMatrix3=function(t){var e=this.x,i=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*r,this.y=s[1]*e+s[4]*i+s[7]*r,this.z=s[2]*e+s[5]*i+s[8]*r,this},n.prototype.applyNormalMatrix=function(t){return this.applyMatrix3(t).normalize()},n.prototype.applyMatrix4=function(t){var e=this.x,i=this.y,r=this.z,s=t.elements,a=1/(s[3]*e+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*e+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*e+s[6]*i+s[10]*r+s[14])*a,this},n.prototype.applyQuaternion=function(t){var e=this.x,i=this.y,r=this.z,s=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*r-o*i),h=2*(o*e-s*r),u=2*(s*i-a*e);return this.x=e+c*l+a*u-o*h,this.y=i+c*h+o*l-s*u,this.z=r+c*u+s*h-a*l,this},n.prototype.transformDirection=function(t){var e=this.x,i=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*r,this.y=s[1]*e+s[5]*i+s[9]*r,this.z=s[2]*e+s[6]*i+s[10]*r,this.normalize()},n.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},n.prototype.divideScalar=function(t){return this.multiplyScalar(1/t)},n.prototype.min=function(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},n.prototype.max=function(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},n.prototype.clamp=function(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},n.prototype.clampScalar=function(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},n.prototype.clampLength=function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},n.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},n.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},n.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},n.prototype.roundToZero=function(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this},n.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},n.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},n.prototype.isParallelTo=function(t){var e=this.dot(t),i=this.length(),r=t.length();return Math.abs(e)===i*r},n.prototype.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z},n.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},n.prototype.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},n.prototype.normalize=function(){return this.divideScalar(this.length()||1)},n.prototype.setLength=function(t){return this.normalize().multiplyScalar(t)},n.prototype.lerp=function(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},n.prototype.lerpVectors=function(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},n.prototype.cross=function(t){return this.crossVectors(this,t)},n.prototype.crossVectors=function(t,e){var i=t.x,r=t.y,s=t.z,a=e.x,o=e.y,c=e.z;return this.x=r*c-s*o,this.y=s*a-i*c,this.z=i*o-r*a,this},n.prototype.projectOnVector=function(t){var e=t.lengthSq();if(e===0)return this.set(0,0,0);var i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)},n.prototype.projectOnPlane=function(t){return Cr.copy(this).projectOnVector(t),this.sub(Cr)},n.prototype.reflect=function(t){return this.sub(Cr.copy(t).multiplyScalar(2*this.dot(t)))},n.prototype.angleTo=function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;var i=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,i)))},n.prototype.distanceTo=function(t){return Math.sqrt(this.distanceToSquared(t))},n.prototype.distanceToSquared=function(t){var e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r},n.prototype.manhattanDistanceTo=function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},n.prototype.setFromMatrixPosition=function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},n.prototype.setFromMatrixScale=function(t){var 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},n.prototype.setFromMatrixColumn=function(t,e){return this.fromArray(t.elements,e*4)},n.prototype.setFromMatrix3Column=function(t,e){return this.fromArray(t.elements,e*3)},n.prototype.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},n.prototype.fromArray=function(t,e){return e===void 0&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},n.prototype.toArray=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},n.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this},n.prototype.randomDirection=function(){var 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},n.prototype[Symbol.iterator]=function(){return Yu(this,function(t){switch(t.label){case 0:return[4,this.x];case 1:return t.sent(),[4,this.y];case 2:return t.sent(),[4,this.z];case 3:return t.sent(),[2]}})},n.ORIGIN=Object.freeze(new n(0,0,0)),n.X_AXIS=Object.freeze(new n(1,0,0)),n.NEGATIVE_X_AXIS=Object.freeze(new n(-1,0,0)),n.Y_AXIS=Object.freeze(new n(0,1,0)),n.NEGATIVE_Y_AXIS=Object.freeze(new n(0,-1,0)),n.Z_AXIS=Object.freeze(new n(0,0,1)),n.NEGATIVE_Z_AXIS=Object.freeze(new n(0,0,-1)),n})(),Cr=new w,Ha=new Je,D=(function(){function n(t,e,i,r,s,a,o,c,l,h,u,d,g,p,f,m){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&&s!=null&&a!=null&&o!=null&&c!=null&&l!=null&&h!=null&&u!=null&&d!=null&&g!=null&&p!=null&&f!=null&&m!=null&&this.set(t,e,i,r,s,a,o,c,l,h,u,d,g,p,f,m)}return n.makeTranslation=function(t,e,i){return new n().makeTranslation(t,e,i)},n.prototype.set=function(t,e,i,r,s,a,o,c,l,h,u,d,g,p,f,m){var b=this.elements;return b[0]=t,b[4]=e,b[8]=i,b[12]=r,b[1]=s,b[5]=a,b[9]=o,b[13]=c,b[2]=l,b[6]=h,b[10]=u,b[14]=d,b[3]=g,b[7]=p,b[11]=f,b[15]=m,this},n.prototype.identity=function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},n.prototype.clone=function(){return new n().fromArray(this.elements)},n.prototype.copy=function(t){var 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},n.prototype.copyPosition=function(t){var e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this},n.prototype.setFromMatrix3=function(t){var 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},n.prototype.setFromExtrusionDirection=function(t){var e=Math.hypot(t.x,t.y,t.z);if(!Number.isFinite(e)||e<1e-12)return this.identity(),this;var i=Math.abs(e-1)>1e-6?t.clone().multiplyScalar(1/e):t;if(mr.equalPoint3d(i,w.Z_AXIS))this.identity();else{var r=new w(1,0,0);Math.abs(i.x)<1/64&&Math.abs(i.y)<1/64?r.crossVectors(w.Y_AXIS,i).normalize():r.crossVectors(w.Z_AXIS,i).normalize();var s=i.clone().cross(r).normalize();this.set(r.x,r.y,r.z,0,s.x,s.y,s.z,0,i.x,i.y,i.z,0,0,0,0,1)}return this},n.prototype.extractBasis=function(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},n.prototype.makeBasis=function(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},n.prototype.extractRotation=function(t){var e=this.elements,i=t.elements,r=1/Re.setFromMatrixColumn(t,0).length(),s=1/Re.setFromMatrixColumn(t,1).length(),a=1/Re.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]*s,e[5]=i[5]*s,e[6]=i[6]*s,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},n.prototype.makeRotationFromQuaternion=function(t){return this.compose(Xu,t,zu)},n.prototype.lookAt=function(t,e,i){var r=this.elements;return It.subVectors(t,e),It.lengthSq()===0&&(It.z=1),It.normalize(),fe.crossVectors(i,It),fe.lengthSq()===0&&(Math.abs(i.z)===1?It.x+=1e-4:It.z+=1e-4,It.normalize(),fe.crossVectors(i,It)),fe.normalize(),Ji.crossVectors(It,fe),r[0]=fe.x,r[4]=Ji.x,r[8]=It.x,r[1]=fe.y,r[5]=Ji.y,r[9]=It.y,r[2]=fe.z,r[6]=Ji.z,r[10]=It.z,this},n.prototype.multiply=function(t){return this.multiplyMatrices(this,t)},n.prototype.premultiply=function(t){return this.multiplyMatrices(t,this)},n.prototype.multiplyMatrices=function(t,e){var i=t.elements,r=e.elements,s=this.elements,a=i[0],o=i[4],c=i[8],l=i[12],h=i[1],u=i[5],d=i[9],g=i[13],p=i[2],f=i[6],m=i[10],b=i[14],_=i[3],v=i[7],x=i[11],S=i[15],P=r[0],E=r[4],O=r[8],T=r[12],R=r[1],N=r[5],M=r[9],A=r[13],V=r[2],$=r[6],Q=r[10],et=r[14],W=r[3],Dt=r[7],B=r[11],Yt=r[15];return s[0]=a*P+o*R+c*V+l*W,s[4]=a*E+o*N+c*$+l*Dt,s[8]=a*O+o*M+c*Q+l*B,s[12]=a*T+o*A+c*et+l*Yt,s[1]=h*P+u*R+d*V+g*W,s[5]=h*E+u*N+d*$+g*Dt,s[9]=h*O+u*M+d*Q+g*B,s[13]=h*T+u*A+d*et+g*Yt,s[2]=p*P+f*R+m*V+b*W,s[6]=p*E+f*N+m*$+b*Dt,s[10]=p*O+f*M+m*Q+b*B,s[14]=p*T+f*A+m*et+b*Yt,s[3]=_*P+v*R+x*V+S*W,s[7]=_*E+v*N+x*$+S*Dt,s[11]=_*O+v*M+x*Q+S*B,s[15]=_*T+v*A+x*et+S*Yt,this},n.prototype.multiplyScalar=function(t){var 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},n.prototype.determinant=function(){var t=this.elements,e=t[0],i=t[4],r=t[8],s=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],u=t[6],d=t[10],g=t[14],p=t[3],f=t[7],m=t[11],b=t[15];return p*(+s*c*u-r*l*u-s*o*d+i*l*d+r*o*g-i*c*g)+f*(+e*c*g-e*l*d+s*a*d-r*a*g+r*l*h-s*c*h)+m*(+e*l*u-e*o*g-s*a*u+i*a*g+s*o*h-i*l*h)+b*(-r*o*h-e*c*u+e*o*d+r*a*u-i*a*d+i*c*h)},n.prototype.transpose=function(){var t=this.elements,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},n.prototype.setPosition=function(t,e,i){var r=this.elements;return t instanceof w?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=i),this},n.prototype.invert=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=t[9],d=t[10],g=t[11],p=t[12],f=t[13],m=t[14],b=t[15],_=u*m*l-f*d*l+f*c*g-o*m*g-u*c*b+o*d*b,v=p*d*l-h*m*l-p*c*g+a*m*g+h*c*b-a*d*b,x=h*f*l-p*u*l+p*o*g-a*f*g-h*o*b+a*u*b,S=p*u*c-h*f*c-p*o*d+a*f*d+h*o*m-a*u*m,P=e*_+i*v+r*x+s*S;if(P===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);var E=1/P;return t[0]=_*E,t[1]=(f*d*s-u*m*s-f*r*g+i*m*g+u*r*b-i*d*b)*E,t[2]=(o*m*s-f*c*s+f*r*l-i*m*l-o*r*b+i*c*b)*E,t[3]=(u*c*s-o*d*s-u*r*l+i*d*l+o*r*g-i*c*g)*E,t[4]=v*E,t[5]=(h*m*s-p*d*s+p*r*g-e*m*g-h*r*b+e*d*b)*E,t[6]=(p*c*s-a*m*s-p*r*l+e*m*l+a*r*b-e*c*b)*E,t[7]=(a*d*s-h*c*s+h*r*l-e*d*l-a*r*g+e*c*g)*E,t[8]=x*E,t[9]=(p*u*s-h*f*s-p*i*g+e*f*g+h*i*b-e*u*b)*E,t[10]=(a*f*s-p*o*s+p*i*l-e*f*l-a*i*b+e*o*b)*E,t[11]=(h*o*s-a*u*s-h*i*l+e*u*l+a*i*g-e*o*g)*E,t[12]=S*E,t[13]=(h*f*r-p*u*r+p*i*d-e*f*d-h*i*m+e*u*m)*E,t[14]=(p*o*r-a*f*r-p*i*c+e*f*c+a*i*m-e*o*m)*E,t[15]=(a*u*r-h*o*r+h*i*c-e*u*c-a*i*d+e*o*d)*E,this},n.prototype.scale=function(t){var e=this.elements,i=t.x,r=t.y,s=t.z;return e[0]*=i,e[4]*=r,e[8]*=s,e[1]*=i,e[5]*=r,e[9]*=s,e[2]*=i,e[6]*=r,e[10]*=s,e[3]*=i,e[7]*=r,e[11]*=s,this},n.prototype.getMaxScaleOnAxis=function(){var 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))},n.prototype.makeTranslation=function(t,e,i){var r;return typeof t=="object"?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,(r=t.z)!==null&&r!==void 0?r:0,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this},n.prototype.makeRotationX=function(t){var 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},n.prototype.makeRotationY=function(t){var 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},n.prototype.makeRotationZ=function(t){var 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},n.prototype.makeRotationAxis=function(t,e){var i=Math.cos(e),r=Math.sin(e),s=1-i,a=t.x,o=t.y,c=t.z,l=s*a,h=s*o;return this.set(l*a+i,l*o-r*c,l*c+r*o,0,l*o+r*c,h*o+i,h*c-r*a,0,l*c-r*o,h*c+r*a,s*c*c+i,0,0,0,0,1),this},n.prototype.makeScale=function(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this},n.prototype.makeShear=function(t,e,i,r,s,a){return this.set(1,i,s,0,t,1,a,0,e,r,1,0,0,0,0,1),this},n.prototype.compose=function(t,e,i){var r=this.elements,s=e.x,a=e.y,o=e.z,c=e.w,l=s+s,h=a+a,u=o+o,d=s*l,g=s*h,p=s*u,f=a*h,m=a*u,b=o*u,_=c*l,v=c*h,x=c*u,S=i.x,P=i.y,E=i.z;return r[0]=(1-(f+b))*S,r[1]=(g+x)*S,r[2]=(p-v)*S,r[3]=0,r[4]=(g-x)*P,r[5]=(1-(d+b))*P,r[6]=(m+_)*P,r[7]=0,r[8]=(p+v)*E,r[9]=(m-_)*E,r[10]=(1-(d+f))*E,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this},n.prototype.decompose=function(t,e,i){var r=this.elements,s=Re.set(r[0],r[1],r[2]).length(),a=Re.set(r[4],r[5],r[6]).length(),o=Re.set(r[8],r[9],r[10]).length(),c=this.determinant();c<0&&(s=-s),t.x=r[12],t.y=r[13],t.z=r[14],Xt.copy(this);var l=1/s,h=1/a,u=1/o;return Xt.elements[0]*=l,Xt.elements[1]*=l,Xt.elements[2]*=l,Xt.elements[4]*=h,Xt.elements[5]*=h,Xt.elements[6]*=h,Xt.elements[8]*=u,Xt.elements[9]*=u,Xt.elements[10]*=u,e.setFromRotationMatrix(Xt),i.x=s,i.y=a,i.z=o,this},n.prototype.equals=function(t){for(var e=this.elements,i=t.elements,r=0;r<16;r++)if(e[r]!==i[r])return!1;return!0},n.prototype.fromArray=function(t,e){e===void 0&&(e=0);for(var i=0;i<16;i++)this.elements[i]=t[i+e];return this},n.prototype.toArray=function(t,e){t===void 0&&(t=[]),e===void 0&&(e=0);var 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},n.IDENTITY=Object.freeze(new n),n})(),Re=new w,Xt=new D,Xu=new w(0,0,0),zu=new w(1,1,1),fe=new w,Ji=new w,It=new w,Y=(function(){function n(t,e){t===void 0&&(t=void 0),e===void 0&&(e=void 0),this.min=t==null?new w(1/0,1/0,1/0):new w(t.x,t.y,t.z),this.max=e==null?new w(-1/0,-1/0,-1/0):new w(e.x,e.y,e.z)}return n.prototype.set=function(t,e){return this.min.copy(t),this.max.copy(e),this},n.prototype.setFromArray=function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e+=3)this.expandByPoint(Mr.fromArray(t,e));return this},n.prototype.setFromPoints=function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},n.prototype.setFromCenterAndSize=function(t,e){var i=Mr.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this},n.prototype.clone=function(){return new n().copy(this)},n.prototype.copy=function(t){return this.min.copy(t.min),this.max.copy(t.max),this},n.prototype.makeEmpty=function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},n.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},n.prototype.getCenter=function(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},n.prototype.getSize=function(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)},Object.defineProperty(n.prototype,"center",{get:function(){return this.isEmpty()?new w(0,0,0):new w(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return this.isEmpty()?new w(0,0,0):new w(0,0,0).subVectors(this.max,this.min)},enumerable:!1,configurable:!0}),n.prototype.expandByPoint=function(t){return this.min.min(t),this.max.max(t),this},n.prototype.expandByVector=function(t){return this.min.sub(t),this.max.add(t),this},n.prototype.expandByScalar=function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},n.prototype.containsPoint=function(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)},n.prototype.containsBox=function(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},n.prototype.getParameter=function(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))},n.prototype.intersectsBox=function(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)},n.prototype.intersectsPlane=function(t){var 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},n.prototype.clampPoint=function(t,e){return e.copy(t).clamp(this.min,this.max)},n.prototype.distanceToPoint=function(t){return this.clampPoint(t,Mr).distanceTo(t)},n.prototype.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},n.prototype.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},n.prototype.applyMatrix4=function(t){return this.isEmpty()?this:(ie[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),ie[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),ie[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),ie[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),ie[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),ie[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),ie[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),ie[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(ie),this)},n.prototype.translate=function(t){return this.min.add(t),this.max.add(t),this},n.prototype.equals=function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},n})(),ie=[new w,new w,new w,new w,new w,new w,new w,new w],Mr=new w,Wa=new nt,yt=(function(){function n(t,e){t===void 0&&(t=void 0),e===void 0&&(e=void 0),this.min=t==null?new nt(1/0,1/0):new nt(t.x,t.y),this.max=e==null?new nt(-1/0,-1/0):new nt(e.x,e.y)}return n.prototype.set=function(t,e){return this.min.copy(t),this.max.copy(e),this},n.prototype.setFromPoints=function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},n.prototype.setFromCenterAndSize=function(t,e){var i=Wa.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this},n.prototype.clone=function(){return new n().copy(this)},n.prototype.copy=function(t){return this.min.copy(t.min),this.max.copy(t.max),this},n.prototype.makeEmpty=function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},n.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y},n.prototype.getCenter=function(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},n.prototype.getSize=function(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)},Object.defineProperty(n.prototype,"center",{get:function(){return this.isEmpty()?new nt(0,0):new nt(0,0).addVectors(this.min,this.max).multiplyScalar(.5)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return this.isEmpty()?new nt(0,0):new nt(0,0).subVectors(this.max,this.min)},enumerable:!1,configurable:!0}),n.prototype.expandByPoint=function(t){return this.min.min(t),this.max.max(t),this},n.prototype.expandByVector=function(t){return this.min.sub(t),this.max.add(t),this},n.prototype.expandByScalar=function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},n.prototype.containsPoint=function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)},n.prototype.containsBox=function(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},n.prototype.getParameter=function(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))},n.prototype.intersectsBox=function(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)},n.prototype.clampPoint=function(t,e){return e.copy(t).clamp(this.min,this.max)},n.prototype.distanceToPoint=function(t){return this.clampPoint(t,Wa).distanceTo(t)},n.prototype.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},n.prototype.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},n.prototype.translate=function(t){return this.min.add(t),this.max.add(t),this},n.prototype.equals=function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},n})(),$a=new w,ju=new w,Vu=new Ui,js=(function(){function n(t,e){t===void 0&&(t=new w(1,0,0)),e===void 0&&(e=0),this.normal=t,this.constant=e}return n.prototype.set=function(t,e){return this.normal.copy(t),this.constant=e,this},n.prototype.setComponents=function(t,e,i,r){return this.normal.set(t,e,i),this.constant=r,this},n.prototype.setFromNormalAndCoplanarPoint=function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},n.prototype.setFromCoplanarPoints=function(t,e,i){var r=$a.subVectors(i,e).cross(ju.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this},n.prototype.copy=function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},n.prototype.normalize=function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},n.prototype.negate=function(){return this.constant*=-1,this.normal.negate(),this},n.prototype.distanceToPoint=function(t){return this.normal.dot(t)+this.constant},n.prototype.projectPoint=function(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))},n.prototype.intersectsBox=function(t){return t.intersectsPlane(this)},n.prototype.coplanarPoint=function(t){return t.copy(this.normal).multiplyScalar(-this.constant)},n.prototype.applyMatrix4=function(t,e){var i=e||Vu.getNormalMatrix(t),r=this.coplanarPoint($a).applyMatrix4(t),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this},n.prototype.translate=function(t){return this.constant-=t.dot(this.normal),this},n.prototype.equals=function(t){return t.normal.equals(this.normal)&&t.constant===this.constant},n.prototype.clone=function(){return new n().copy(this)},n})(),Gu=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),L=(function(n){Gu(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.clone=function(){return new t(this.x,this.y)},t.pointArrayToNumberArray=function(e){var i=new Array(e.length*2);return e.forEach(function(r,s){r.toArray(i,s*2)}),i},t})(nt),Uu=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),y=(function(n){Uu(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.clone=function(){return new t(this.x,this.y,this.z)},t.pointArrayToNumberArray=function(e,i){i===void 0&&(i=!0);var r=i?3:2,s=new Array(e.length*r);return e.forEach(function(a,o){a.toArray(s,o*r)}),s},t})(w),Hu=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(e=0)),e;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(h){l=[6,h],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},qa=new D,Ka=new Je,Wu=(function(){function n(t,e,i,r){t===void 0&&(t=0),e===void 0&&(e=0),i===void 0&&(i=0),r===void 0&&(r=n.DEFAULT_ORDER),this._x=t,this._y=e,this._z=i,this._order=r}return Object.defineProperty(n.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"z",{get:function(){return this._z},set:function(t){this._z=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"order",{get:function(){return this._order},set:function(t){this._order=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),n.prototype.set=function(t,e,i,r){return r===void 0&&(r=this._order),this._x=t,this._y=e,this._z=i,this._order=r,this._onChangeCallback(),this},n.prototype.clone=function(){return new n(this._x,this._y,this._z,this._order)},n.prototype.copy=function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this},n.prototype.setFromRotationMatrix=function(t,e,i){e===void 0&&(e=this._order),i===void 0&&(i=!0);var r=t.elements,s=r[0],a=r[4],o=r[8],c=r[1],l=r[5],h=r[9],u=r[2],d=r[6],g=r[10];switch(e){case"XYZ":this._y=Math.asin(re(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,g),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-re(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,g),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(re(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,g),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-re(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,g),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(re(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,g));break;case"XZY":this._z=Math.asin(-re(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,g),this._y=0);break;default:}return this._order=e,i===!0&&this._onChangeCallback(),this},n.prototype.setFromQuaternion=function(t,e,i){return i===void 0&&(i=!0),qa.makeRotationFromQuaternion(t),this.setFromRotationMatrix(qa,e,i)},n.prototype.setFromVector3=function(t,e){return e===void 0&&(e=this._order),this.set(t.x,t.y,t.z,e)},n.prototype.reorder=function(t){return Ka.setFromEuler(this),this.setFromQuaternion(Ka,t)},n.prototype.equals=function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},n.prototype.fromArray=function(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},n.prototype.toArray=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},n.prototype._onChange=function(t){return this._onChangeCallback=t,this},n.prototype._onChangeCallback=function(){},n.prototype[Symbol.iterator]=function(){return Hu(this,function(t){switch(t.label){case 0:return[4,this._x];case 1:return t.sent(),[4,this._y];case 2:return t.sent(),[4,this._z];case 3:return t.sent(),[4,this._order];case 4:return t.sent(),[2]}})},n.DEFAULT_ORDER="XYZ",n})();function $u(n){var t,e=n;return{x:n.x,y:n.y,z:(t=e.z)!==null&&t!==void 0?t:0}}function qu(n,t){var e,i;n.x+=t.x,n.y+=t.y,n.z=((e=n.z)!==null&&e!==void 0?e:0)+((i=t.z)!==null&&i!==void 0?i:0)}function Ku(n,t,e){e===void 0&&(e=!1);for(var i=n.x,r=n.y,s=!1,a=t.length,o=0,c=a-1;o<a;c=o++){var l=t[o].x,h=t[o].y,u=t[c].x,d=t[c].y,g=h>r!=d>r;e&&(g=h>=r!=d>=r);var p=g&&i<(u-l)*(r-h)/(d-h)+l;p&&(s=!s)}return s}function Zu(n,t){if(n.length===0||t.length===0)return!1;var e=new yt().setFromPoints(n),i=new yt().setFromPoints(t);if(!e.intersectsBox(i))return!1;for(var r=0;r<n.length;){if(wt.isPointInPolygon(n[r],t,!0))return!0;r<n.length-1&&mr.equalPoint2d(n[r+1],n[r])&&++r,++r}return!1}var wt={applyOffsetToPoint3d:qu,isPointInPolygon:Ku,isPolygonIntersect:Zu,point2dToPoint3d:$u},tn=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},en=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))};function Qu(n,t){for(var e=[],i=t-1,r=n,s=0;s<=r;s++)e.push(0);for(var s=1;s<=i-r;s++)e.push(s);for(var s=0;s<=r;s++)e.push(i-r+1);return e}function Ju(n,t){for(var e=t.length-1,i=n,r=[0],s=0,a=1;a<=e;a++){var o=t[a][0]-t[a-1][0],c=t[a][1]-t[a-1][1],l=t[a][2]-t[a-1][2],h=Math.sqrt(o*o+c*c+l*l);s+=h,r.push(s)}for(var u=[],a=0;a<=i;a++)u.push(0);for(var a=1;a<=e-i;a++){var d=r[a]/s;u.push(d*(e-i+1))}for(var a=0;a<=i;a++)u.push(e-i+1);return u}function mc(n,t){t===void 0&&(t="Uniform");var e=n.length;if(e===0)return[];if(e===1)return[0];var i=e-1;if(t==="Uniform")return new Array(e).fill(0).map(function(d,g){return g/i});for(var r=[0],s=0,a=1;a<=i;a++){var o=n[a][0]-n[a-1][0],c=n[a][1]-n[a-1][1],l=n[a][2]-n[a-1][2],h=Math.sqrt(o*o+c*c+l*l),u=t==="SqrtChord"?Math.sqrt(h):h;s+=u,r.push(s)}return s<1e-12?new Array(e).fill(0).map(function(d,g){return g/i}):r.map(function(d){return d/s})}function yc(n,t){for(var e=t.length-1,i=n,r=e+i+1,s=new Array(r+1).fill(0),a=t[t.length-1],o=r-i;o<=r;o++)s[o]=a;for(var c=1;c<=e-i;c++){for(var l=0,o=c;o<c+i;o++)l+=t[o];s[c+i]=l/i}return s}function td(n,t){for(var e=t.length-1,i=n,r=[0],s=0,a=1;a<=e;a++){var o=t[a][0]-t[a-1][0],c=t[a][1]-t[a-1][1],l=t[a][2]-t[a-1][2],h=Math.sqrt(o*o+c*c+l*l),u=Math.sqrt(h);s+=u,r.push(s)}for(var d=[],a=0;a<=i;a++)d.push(0);for(var a=1;a<=e-i;a++){var g=r[a]/s;d.push(g*(e-i+1))}for(var a=0;a<=i;a++)d.push(e-i+1);return d}function Or(n,t){for(var e=n.length,i=n.map(function(m){return m.slice()}),r=t.slice(),s=0;s<e;s++){for(var a=s,o=Math.abs(i[s][s]),c=s+1;c<e;c++){var l=Math.abs(i[c][s]);l>o&&(o=l,a=c)}if(o<1e-12)throw new Error("Interpolation matrix is singular.");if(a!==s){var h=i[s];i[s]=i[a],i[a]=h;var u=r[s];r[s]=r[a],r[a]=u}for(var c=s+1;c<e;c++){var d=i[c][s]/i[s][s];if(!(Math.abs(d)<1e-14)){for(var g=s;g<e;g++)i[c][g]-=d*i[s][g];r[c]-=d*r[s]}}}for(var p=new Array(e).fill(0),c=e-1;c>=0;c--){for(var f=r[c],g=c+1;g<e;g++)f-=i[c][g]*p[g];p[c]=f/i[c][c]}return p}function Vs(n,t,e,i,r){var s,a,o,c,l,h;if(e===void 0&&(e="Uniform"),n.length===0)return{controlPoints:[],knots:[],weights:[]};var u=n.map(function(B){var Yt;return[B[0],B[1],(Yt=B[2])!==null&&Yt!==void 0?Yt:0]}),d=!!i,g=!!r,p=(d?1:0)+(g?1:0),f=u.length-1,m=f+p;if(m<t)throw new Error("Not enough points to interpolate a curve of this degree.");var b=mc(u,e),_=b.slice();d&&_.unshift(b[0]),g&&_.push(b[b.length-1]);var v=yc(t,_),x=m+1,S=new Array(x),P=new Array(x),E=new Array(x),O=new Array(x),T=0;S[T]=new Array(x).fill(0),S[T][0]=1,P[T]=u[0][0],E[T]=u[0][1],O[T]=u[0][2],T++;for(var R=1;R<=f-1;R++){var N=b[R];S[T]=new Array(x).fill(0);for(var M=0;M<=m;M++)S[T][M]=Ae(M,t,N,v);P[T]=u[R][0],E[T]=u[R][1],O[T]=u[R][2],T++}if(S[T]=new Array(x).fill(0),S[T][m]=1,P[T]=u[f][0],E[T]=u[f][1],O[T]=u[f][2],T++,d){var A=v[t+1]-v[0],V=A!==0?t/A:0;S[T]=new Array(x).fill(0),S[T][0]=-V,S[T][1]=V,P[T]=(s=i==null?void 0:i[0])!==null&&s!==void 0?s:0,E[T]=(a=i==null?void 0:i[1])!==null&&a!==void 0?a:0,O[T]=(o=i==null?void 0:i[2])!==null&&o!==void 0?o:0,T++}if(g){var A=v[m+t+1]-v[m],V=A!==0?t/A:0;S[T]=new Array(x).fill(0),S[T][m-1]=-V,S[T][m]=V,P[T]=(c=r==null?void 0:r[0])!==null&&c!==void 0?c:0,E[T]=(l=r==null?void 0:r[1])!==null&&l!==void 0?l:0,O[T]=(h=r==null?void 0:r[2])!==null&&h!==void 0?h:0,T++}for(var $=Or(S,P),Q=Or(S,E),et=Or(S,O),W=new Array(x),R=0;R<x;R++)W[R]=[$[R],Q[R],et[R]];var Dt=new Array(x).fill(1);return{controlPoints:W,knots:v,weights:Dt}}function Ae(n,t,e,i){if(t===0)return e>=i[n]&&e<i[n+1]?1:0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],a=r>1e-10?(e-i[n])/r:0,o=s>1e-10?(i[n+t+1]-e)/s:0;return a*Ae(n,t-1,e,i)+o*Ae(n+1,t-1,e,i)}function yi(n,t,e,i,r){var s=i.length-1,a=t;if(n=Math.max(e[a],Math.min(e[s+1],n)),Math.abs(n-e[s+1])<1e-8)return en([],tn(i[s]),!1);if(Math.abs(n-e[a])<1e-8)return en([],tn(i[0]),!1);for(var o=[0,0,0],c=0,l=0;l<=s;l++){var h=Ae(l,a,n,e),u=r[l]*h;o[0]+=i[l][0]*u,o[1]+=i[l][1]*u,o[2]+=i[l][2]*u,c+=u}if(Math.abs(c)<1e-10){var d=e[e.length-a-1];if(Math.abs(n-d)<1e-8)return en([],tn(i[s]),!1);if(Math.abs(n-e[a])<1e-8)return en([],tn(i[0]),!1)}return Math.abs(c)>=1e-10&&(o[0]/=c,o[1]/=c,o[2]/=c),o}function ss(n,t,e,i){if(t===0)return 0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],a=0;return r>1e-10&&(a+=t/r*Ae(n,t-1,e,i)),s>1e-10&&(a-=t/s*Ae(n+1,t-1,e,i)),a}function ed(n,t,e,i){if(t<=1)return 0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],a=0;return r>1e-10&&(a+=t/r*ss(n,t-1,e,i)),s>1e-10&&(a-=t/s*ss(n+1,t-1,e,i)),a}function id(n,t,e,i,r){var s=i.length-1,a=t,o=e[a],c=e[s+1];n=Math.max(o,Math.min(c,n));for(var l=[0,0,0],h=[0,0,0],u=[0,0,0],d=0,g=0,p=0,f=0;f<=s;f++){var m=Ae(f,a,n,e),b=ss(f,a,n,e),_=ed(f,a,n,e),v=r[f],x=v*m,S=v*b,P=v*_,E=i[f];l[0]+=x*E[0],l[1]+=x*E[1],l[2]+=x*E[2],h[0]+=S*E[0],h[1]+=S*E[1],h[2]+=S*E[2],u[0]+=P*E[0],u[1]+=P*E[1],u[2]+=P*E[2],d+=x,g+=S,p+=P}if(Math.abs(d)<1e-10){var O=yi(n,t,e,i,r);return{point:O,deriv1:[0,0,0],deriv2:[0,0,0]}}var T=d*d,R=[l[0]/d,l[1]/d,l[2]/d],N=[(h[0]*d-l[0]*g)/T,(h[1]*d-l[1]*g)/T,(h[2]*d-l[2]*g)/T],M=u[0]*d-l[0]*p,A=u[1]*d-l[1]*p,V=u[2]*d-l[2]*p,$=[M/T-2*g*N[0]/d,A/T-2*g*N[1]/d,V/T-2*g*N[2]/d];return{point:R,deriv1:N,deriv2:$}}function nd(n,t){var e=n[0],i=n[1],r=t[0],s=t[1],a=e*e+i*i;return a<1e-20?0:(e*s-i*r)/Math.pow(a,1.5)}function bc(n,t,e,i){for(var r=n,s=t[r],a=t[t.length-r-1],o=0,c=1e3,l=(a-s)/c,h=yi(s,n,t,e,i),u=1;u<=c;u++){var d=s+u*l,g=yi(d,n,t,e,i),p=g[0]-h[0],f=g[1]-h[1],m=g[2]-h[2];o+=Math.sqrt(p*p+f*f+m*m),h=g}var b=yi(a,n,t,e,i),_=b[0]-h[0],v=b[1]-h[1],x=b[2]-h[2];return o+=Math.sqrt(_*_+v*v+x*x),o}function rd(n,t,e,i,r){return t===void 0&&(t=3),e===void 0&&(e="Uniform"),n.length===0?[]:Vs(n,t,e,i,r).controlPoints}var Za=new D,Qa=new w,sd=new w,ad=new w,Nr=new y;function _c(n){return new D().setFromExtrusionDirection(new w(n.x,n.y,n.z))}function Ii(n){return Za.setFromExtrusionDirection(new w(n.x,n.y,n.z)),Za.extractBasis(Qa,sd,ad),Qa.clone()}function he(n,t){var e;return new y(n.x,n.y,(e=n.z)!==null&&e!==void 0?e:0).applyMatrix4(_c(t))}function Lt(n,t){var e;return new y(n.x,n.y,(e=n.z)!==null&&e!==void 0?e:0).applyMatrix4(_c(t).invert())}function ae(n,t,e){var i,r,s=Lt(n,e),a=Lt(t,e);return Nr.set(a.x-s.x,a.y-s.y,((i=a.z)!==null&&i!==void 0?i:0)-((r=s.z)!==null&&r!==void 0?r:0)),C.normalizeAngle(Math.atan2(Nr.y,Nr.x))}function xc(n){var t=n.length;if(t<3)return 0;for(var e=0,i=0,r=t-1;i<t;r=i++){var s=n[r],a=n[i];e+=s.x*a.y-a.x*s.y}return e*.5}function od(n){return Math.abs(xc(n))}function cd(n){var t,e,i=n.length;if(i<3)return 0;for(var r=0,s=0,a=0,o=0,c=i-1;o<i;c=o++){var l=n[c],h=n[o],u=l.x,d=l.y,g=(t=l.z)!==null&&t!==void 0?t:0,p=h.x,f=h.y,m=(e=h.z)!==null&&e!==void 0?e:0;r+=(g+m)*(d-f),s+=(u+p)*(g-m),a+=(d+f)*(u-p)}return .5*Math.hypot(r,s,a)}function ld(n){return n.length<3?0:od(n)}function wc(n){return n.length<3?0:cd(n)}var vc=(function(){function n(){this._boundingBoxNeedsUpdate=!1}return Object.defineProperty(n.prototype,"boundingBoxNeedUpdate",{get:function(){return this._boundingBoxNeedsUpdate},enumerable:!1,configurable:!0}),n})(),hd=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Gs=(function(n){hd(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.translate=function(e){return this.transform(new Ui().makeTranslation(e.x,e.y))},Object.defineProperty(t.prototype,"box",{get:function(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box},enumerable:!1,configurable:!0}),t})(vc),ud=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),oi=(function(n){ud(t,n);function t(){var e=n.call(this)||this;return e.arcLengthDivisions=100,e}return Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPoint(0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPoint(1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this.getLength()},enumerable:!1,configurable:!0}),t.prototype.getPoint=function(e){throw new Error("AcGeCurve2d: .getPoint() not implemented.")},t.prototype.getPointAt=function(e){var i=this.getUtoTmapping(e);return this.getPoint(i)},t.prototype.getPoints=function(e){e===void 0&&(e=5);for(var i=[],r=0;r<=e;r++)i.push(this.getPoint(r/e));return i},t.prototype.getSpacedPoints=function(e){e===void 0&&(e=5);for(var i=[],r=0;r<=e;r++)i.push(this.getPointAt(r/e));return i},t.prototype.getLength=function(){var e=this.getLengths();return e[e.length-1]},t.prototype.getLengths=function(e){e===void 0&&(e=this.arcLengthDivisions);var i=[],r,s=this.getPoint(0),a=0;i.push(0);for(var o=1;o<=e;o++)r=this.getPoint(o/e),a+=r.distanceTo(s),i.push(a),s=r;return i},t.prototype.getUtoTmapping=function(e,i){var r=this.getLengths(),s=0,a=r.length,o;i?o=i:o=e*r[a-1];for(var c=0,l=a-1,h;c<=l;)if(s=Math.floor(c+(l-c)/2),h=r[s]-o,h<0)c=s+1;else if(h>0)l=s-1;else{l=s;break}if(s=l,r[s]===o)return s/(a-1);var u=r[s],d=r[s+1],g=d-u,p=(o-u)/g,f=(s+p)/(a-1);return f},t.prototype.getTangent=function(e){var i=1e-4,r=e-i,s=e+i;r<0&&(r=0),s>1&&(s=1);var a=this.getPoint(r),o=this.getPoint(s),c=new L;return c.copy(o).sub(a).normalize(),c},t.prototype.getTangentAt=function(e){var i=this.getUtoTmapping(e);return this.getTangent(i)},t})(Gs),dd=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),nn=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},rn=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},sn=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},vt=(function(n){dd(t,n);function t(e,i,r,s,a){var o=n.call(this)||this,c=+(e!==void 0)+ +(i!==void 0)+ +(r!==void 0)+ +(s!==void 0)+ +(a!==void 0);if(c==3)typeof e=="object"&&typeof i=="object"&&typeof r=="object"?o.createByThreePoints(e,i,r):o.createByStartEndPointsAndBulge(e,i,r);else if(c==5){var l=e;o.center=new L(l.x,l.y),o.radius=i,o._clockwise=a,o._startAngle=o._clockwise?o._mirrorAngle(C.normalizeAngle(r)):C.normalizeAngle(r),o._endAngle=o._clockwise?o._mirrorAngle(C.normalizeAngle(s)):C.normalizeAngle(s)}else throw Pt.ILLEGAL_PARAMETERS;return o}return t.prototype.createByThreePoints=function(e,i,r){var s=function(O,T){return{x:(O.x+T.x)/2,y:(O.y+T.y)/2}},a=function(O,T){return(T.y-O.y)/(T.x-O.x)},o=function(O){return-1/O},c=s(e,i),l=s(i,r),h=a(e,i),u=a(i,r),d=o(h),g=o(u),p=function(O,T,R,N){var M=(N-T)/(O-R),A=O*M+T;return{x:M,y:A}},f=c.y-d*c.x,m=l.y-g*l.x,b=p(d,f,g,m),_=Math.sqrt(Math.pow(e.x-b.x,2)+Math.pow(e.y-b.y,2)),v=function(O,T){return Math.atan2(O.y-T.y,O.x-T.x)},x=v(e,b),S=v(i,b),P=v(r,b),E=P>x&&P<S||x>P&&x<S||S>P&&S<x;this.center=b,this.radius=_,this._clockwise=!E,this._startAngle=x,this._endAngle=P},t.prototype.createByStartEndPointsAndBulge=function(e,i,r){var s,a,o;r<0?(s=Math.atan(-r)*4,a=new nt(e),o=new nt(i)):(s=Math.atan(r)*4,a=new nt(i),o=new nt(e));var c=new nt().subVectors(o,a),l=c.length(),h=new nt().addVectors(a,c.multiplyScalar(.5)),u=Math.abs(l/2/Math.tan(s/2)),d=c.normalize(),g=r<0?-Math.PI/2:Math.PI/2,p=new nt(d.x*Math.cos(g)-d.y*Math.sin(g),d.y*Math.cos(g)+d.x*Math.sin(g)),f;s<Math.PI?r<0?f=h.add(p.multiplyScalar(u)):f=h.add(p.multiplyScalar(-u)):r<0?f=h.add(p.multiplyScalar(-u)):f=h.add(p.multiplyScalar(u)),r<0?(this._startAngle=Math.atan2(a.y-f.y,a.x-f.x),this._endAngle=Math.atan2(o.y-f.y,o.x-f.x)):(this._startAngle=Math.atan2(o.y-f.y,o.x-f.x),this._endAngle=Math.atan2(a.y-f.y,a.x-f.x)),this._clockwise=r<0,this.center=f,this.radius=o.sub(f).length()},Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new L(e.x,e.y),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle},set:function(e){this._startAngle=this._clockwise?this._mirrorAngle(C.normalizeAngle(e)):C.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle},set:function(e){var i=this.startAngle==0&&e==j?e:C.normalizeAngle(e);this._endAngle=this._clockwise?this._mirrorAngle(i):i,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),t.prototype._mirrorAngle=function(e){var i=e*180/Math.PI,r=(360-i)%360;return r*Math.PI/180},t.prototype._getInternalAngle=function(e){return this._clockwise?this._mirrorAngle(e):e},Object.defineProperty(t.prototype,"deltaAngle",{get:function(){var e=this._getInternalAngle(this.startAngle),i=this._getInternalAngle(this.endAngle);return this.clockwise?C.normalizeAngle(e-i):C.normalizeAngle(i-e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this._clockwise},set:function(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this.endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){var e=this._getInternalAngle(this.startAngle),i=this._clockwise?C.normalizeAngle(e-this.deltaAngle/2):C.normalizeAngle(e+this.deltaAngle/2),r=this._clockwise?this._mirrorAngle(i):i;return this.getPointAtAngle(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"closed",{get:function(){var e=this._getInternalAngle(this.startAngle),i=this._getInternalAngle(this.endAngle);return Math.abs(i-e)/Math.PI%2==0},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e,i,r=[this.startPoint,this.endPoint],s=[0,Math.PI/2,Math.PI,3*Math.PI/2];try{for(var a=nn(s),o=a.next();!o.done;o=a.next()){var c=o.value,l=this._getInternalAngle(c);C.isBetweenAngle(l,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&r.push(this.getPointAtAngle(c))}}catch(d){e={error:d}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(e)throw e.error}}var h=r.map(function(d){return d.x}),u=r.map(function(d){return d.y});return new yt(new L(Math.min.apply(Math,sn([],rn(h),!1)),Math.min.apply(Math,sn([],rn(u),!1))),new L(Math.max.apply(Math,sn([],rn(h),!1)),Math.max.apply(Math,sn([],rn(u),!1))))},Object.defineProperty(t.prototype,"length",{get:function(){return Math.abs(this.deltaAngle*this.radius)},enumerable:!1,configurable:!0}),t.prototype.transform=function(e){var i=this,r=e,s=this.center.clone().applyMatrix2d(r),a=this.startPoint.clone().applyMatrix2d(r);if(this.closed)return this.center=s,this.radius=s.distanceTo(a),this._startAngle=Math.atan2(a.y-s.y,a.x-s.x),this._endAngle=this._startAngle,this._clockwise=r.determinant()<0?!this._clockwise:this._clockwise,this._boundingBoxNeedsUpdate=!0,this;var o=this.midPoint.clone().applyMatrix2d(r),c=this.endPoint.clone().applyMatrix2d(r),l=new t(a,o,c),h=r.determinant()<0?!this.clockwise:this.clockwise,u=function(d){var g=C.normalizeAngle(d);return h?i._mirrorAngle(g):g};return this.center=l.center,this.radius=l.radius,this.clockwise=h,this.startAngle=u(Math.atan2(a.y-l.center.y,a.x-l.center.x)),this.endAngle=u(Math.atan2(c.y-l.center.y,c.x-l.center.x)),this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)},t.prototype.getPointAtAngle=function(e){var i=this._getInternalAngle(e),r=this.center.x+this.radius*Math.cos(i),s=this.center.y+this.radius*Math.sin(i);return new L(r,s)},t.prototype.getQuadrantPoints=function(){var e,i,r=[],s=this._getInternalAngle(this.startAngle),a=this._getInternalAngle(this.endAngle),o=[0,Math.PI/2,Math.PI,3*Math.PI/2];try{for(var c=nn(o),l=c.next();!l.done;l=c.next()){var h=l.value,u=this._getInternalAngle(h);C.isBetweenAngle(u,s,a,this.clockwise)&&r.push(this.getPointAtAngle(h))}}catch(d){e={error:d}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(e)throw e.error}}return r},t.prototype.nearestPoint=function(e){var i=new L(e.x,e.y),r=i.x-this.center.x,s=i.y-this.center.y,a=Math.hypot(r,s);if(a<1e-12)return this.startPoint.clone();var o=Math.atan2(s,r),c=this.clockwise?this._mirrorAngle(C.normalizeAngle(o)):C.normalizeAngle(o),l=this._getInternalAngle(c),h=this._getInternalAngle(this.startAngle),u=this._getInternalAngle(this.endAngle);if(C.isBetweenAngle(l,h,u,this.clockwise))return this.getPointAtAngle(c);var d=i.distanceToSquared(this.startPoint),g=i.distanceToSquared(this.endPoint);return d<=g?this.startPoint.clone():this.endPoint.clone()},t.prototype.perpendicularPoints=function(e){var i,r,s=new L(e.x,e.y),a=s.x-this.center.x,o=s.y-this.center.y,c=Math.hypot(a,o);if(c<1e-12)return[];var l=a/c,h=o/c,u=[new L(this.center.x+l*this.radius,this.center.y+h*this.radius),new L(this.center.x-l*this.radius,this.center.y-h*this.radius)],d=[],g=this._getInternalAngle(this.startAngle),p=this._getInternalAngle(this.endAngle);try{for(var f=nn(u),m=f.next();!m.done;m=f.next()){var b=m.value,_=Math.atan2(b.y-this.center.y,b.x-this.center.x),v=this.clockwise?this._mirrorAngle(C.normalizeAngle(_)):C.normalizeAngle(_),x=this._getInternalAngle(v);(this.closed||C.isBetweenAngle(x,g,p,this.clockwise))&&d.push(b)}}catch(S){i={error:S}}finally{try{m&&!m.done&&(r=f.return)&&r.call(f)}finally{if(i)throw i.error}}return d},t.prototype.tangentPoints=function(e){var i,r,s=[],a=e.x-this.center.x,o=e.y-this.center.y,c=Math.hypot(a,o),l=this.radius;if(c<l)return s;var h=Math.acos(l/c),u=Math.atan2(o,a),d=[u+h,u-h],g=this._getInternalAngle(this.startAngle),p=this._getInternalAngle(this.endAngle);try{for(var f=nn(d),m=f.next();!m.done;m=f.next()){var b=m.value,_=this.clockwise?this._mirrorAngle(C.normalizeAngle(b)):C.normalizeAngle(b),v=this._getInternalAngle(_);(this.closed||C.isBetweenAngle(v,g,p,this.clockwise))&&s.push(this.getPointAtAngle(_))}}catch(x){i={error:x}}finally{try{m&&!m.done&&(r=f.return)&&r.call(f)}finally{if(i)throw i.error}}return s},t.prototype.getPoints=function(e){e===void 0&&(e=100);var i=[],r=this.deltaAngle,s=this._getInternalAngle(this.startAngle);if(this.closed&&(r=j,s=0),this.clockwise)for(var a=0;a<=e;a++){var o=s-r*(a/e),c=this._clockwise?this._mirrorAngle(o):o,l=this.getPointAtAngle(c);i.push(new L(l.x,l.y))}else for(var a=0;a<=e;a++){var o=s+r*(a/e),c=this._clockwise?this._mirrorAngle(o):o,l=this.getPointAtAngle(c);i.push(new L(l.x,l.y))}return i},t})(oi),as=function(){return as=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},as.apply(this,arguments)},gd=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},an=1e-6;function kc(n,t){if(Rd(n)){var e=pd(n,t);return e?[e]:[]}var i=Ic(n),r=i.numberOfVertices;if(r<2)return[];var s=Fd(i,t);return s?[s]:[]}function fd(n){return Ic(n)}function pd(n,t){var e,i,r=md(n);if(r.length===0)return null;var s=[];try{for(var a=gd(r),o=a.next();!o.done;o=a.next()){var c=o.value,l=bd(c,t);if(!l)return null;s.push(l)}}catch(g){e={error:g}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(e)throw e.error}}var h=yd(n),u=vd(s,h,n.closed,t);if(u.length<2)return null;var d=new q;return u.forEach(function(g,p){d.addVertexAt(p,{x:g.x,y:g.y})}),d.closed=n.closed,d}function md(n){for(var t,e=[],i=n.numberOfVertices,r=n.closed?i:i-1,s=0;s<r;s++){var a=n.vertices[s],o=n.vertices[(s+1)%i];K.isPositive(Math.abs((t=a.bulge)!==null&&t!==void 0?t:0))?e.push({kind:"arc",arc:new vt(a,o,a.bulge)}):e.push({kind:"line",start:new L(a.x,a.y),end:new L(o.x,o.y)})}return e}function yd(n){for(var t=[],e=0;e<n.numberOfVertices;e++)t.push(n.getPointAt(e));return t}function bd(n,t){if(n.kind==="line"){var e=wd(n.start,n.end,t);return e?as({kind:"line"},e):null}var i=_d(n.arc,n.arc.startPoint,n.arc.endPoint,t);return i?{kind:"arc",arc:i}:null}function _d(n,t,e,i){var r=xd(n,t,e,i),s=n.radius+r;return K.isNonPositive(s)?null:new vt(n.center,s,n.startAngle,n.endAngle,n.clockwise)}function xd(n,t,e,i){var r=e.x-t.x,s=e.y-t.y,a=Math.hypot(r,s);if(K.isNonPositive(a))return n.clockwise?-i:i;var o=-s/a,c=r/a,l=n.center.x-(t.x+e.x)/2,h=n.center.y-(t.y+e.y)/2,u=l*o+h*c>0;return u?-i:i}function wd(n,t,e){var i=t.x-n.x,r=t.y-n.y,s=Math.hypot(i,r);if(K.isNonPositive(s))return null;var a=-r/s*e,o=i/s*e;return{start:new L(n.x+a,n.y+o),end:new L(t.x+a,t.y+o),dx:i,dy:r}}function vd(n,t,e,i){var r,s,a,o=n.length;if(o===0)return[];for(var c=kd(n,t,e,i),l=[(s=(r=c[0].nextSegmentStart)===null||r===void 0?void 0:r.clone())!==null&&s!==void 0?s:c[0].point.clone()],h=0;h<o;h++){var u=n[h],d=h===o-1&&!e?{point:Ed(u)}:c[(h+1)%o];if(h>0&&c[h].filletPoints&&c[h].filletPoints.forEach(function(b){return l.push(b.clone())}),u.kind==="arc")for(var g=(a=c[h].nextSegmentStart)!==null&&a!==void 0?a:c[h].point,p=d.point,f=Ad(u.arc,g,p,Math.max(16,32)),m=1;m<f.length;m++)l.push(f[m]);else l.push(d.point.clone())}return Ec(l)}function kd(n,t,e,i){for(var r=n.length,s=[],a=0;a<r;a++)a===0?s.push(e?Ja(n[r-1],n[0],t[0],i):{point:Id(n[0])}):s.push(Ja(n[a-1],n[a],t[a],i));return s}function Ad(n,t,e,i){for(var r=n.nearestPoint(t),s=n.nearestPoint(e),a=os(n,r),o=os(n,s),c=Pd(n,a,o),l=[],h=0;h<=i;h++){var u=h/i,d=n.clockwise?a-c*u:a+c*u;l.push(n.getPointAtAngle(Sd(n,d)))}return l}function os(n,t){return Math.atan2(t.y-n.center.y,t.x-n.center.x)}function Sd(n,t){var e=C.normalizeAngle(t);return n.clockwise?cs(e):e}function cs(n){var t=n*180/Math.PI;return(360-t)%360*(Math.PI/180)}function Pd(n,t,e){if(n.clockwise){var i=t-e;return K.isNonPositive(i)&&(i+=j),i}var r=e-t;return K.isNonPositive(r)&&(r+=j),r}function Id(n){return n.kind==="line"?n.start.clone():n.arc.startPoint.clone()}function Ed(n){return n.kind==="line"?n.end.clone():n.arc.endPoint.clone()}function Ja(n,t,e,i){return n.kind==="line"&&t.kind==="line"?{point:ls({start:n.start,end:n.end,dx:n.dx,dy:n.dy},{start:t.start,end:t.end,dx:t.dx,dy:t.dy})}:n.kind==="line"&&t.kind==="arc"?to(n,t.arc,e,i,!0):n.kind==="arc"&&t.kind==="line"?to(t,n.arc,e,i,!1):n.kind==="arc"&&t.kind==="arc"?Ld(n.arc,t.arc,e,i):{point:e.clone()}}function Ld(n,t,e,i){var r=Pc(n.endPoint,t.startPoint),s=Nd(n,t),a=s.filter(function(h){return wn(n,h)&&wn(t,h)});if(a.length>0)return{point:Sc(a,r)};var o=n.endPoint.clone(),c=t.startPoint.clone(),l=Ac(e,Math.abs(i),o,c);return{point:o,filletPoints:l,nextSegmentStart:c}}function to(n,t,e,i,r){var s=Pc(r?n.end:n.start,r?t.startPoint:t.endPoint),a=Od(n,t,s);if(Cd(n,a)&&wn(t,a))return{point:a};var o=Td(n,e,i),c=r?t.startPoint.clone():t.endPoint.clone(),l=Ac(e,Math.abs(i),r?o:c,r?c:o);return r?{point:o,filletPoints:l,nextSegmentStart:c}:{point:c,filletPoints:l,nextSegmentStart:o}}function Td(n,t,e){var i=Math.hypot(n.dx,n.dy),r=-n.dy/i*e,s=n.dx/i*e;return new L(t.x+r,t.y+s)}function Cd(n,t){var e=Math.hypot(n.dx,n.dy);if(K.isNonPositive(e))return!1;var i=n.dx/e,r=n.dy/e,s=t.x-n.start.x,a=t.y-n.start.y,o=Math.abs(s*r-a*i);return K.equalToZero(o)}function Ac(n,t,e,i){var r=Math.atan2(e.y-n.y,e.x-n.x),s=Math.atan2(i.y-n.y,i.x-n.x),a=Md(r,s);if(K.equalToZero(Math.abs(a)))return[];for(var o=[],c=Math.max(2,Math.ceil(Math.abs(a)/Math.PI*16)),l=1;l<c;l++){var h=l/c,u=r+a*h;o.push(new L(n.x+t*Math.cos(u),n.y+t*Math.sin(u)))}return o}function Md(n,t){for(var e=t-n;e>Math.PI;)e-=j;for(;e<=-Math.PI;)e+=j;return e}function Od(n,t,e){var i=Math.hypot(n.dx,n.dy);if(K.isNonPositive(i))return e.clone();var r=n.dx/i,s=n.dy/i,a=n.start.x-t.center.x,o=n.start.y-t.center.y,c=2*(a*r+o*s),l=a*a+o*o-t.radius*t.radius,h=c*c-4*l;if(h<0)return e.clone();var u=Math.sqrt(h),d=[(-c-u)/2,(-c+u)/2].map(function(p){return new L(n.start.x+r*p,n.start.y+s*p)}),g=d.filter(function(p){return wn(t,p)});return Sc(g.length>0?g:d,e)}function wn(n,t){var e=Math.abs(Math.hypot(t.x-n.center.x,t.y-n.center.y)-n.radius);if(K.isPositive(e))return!1;var i=os(n,t),r=n.clockwise?cs(C.normalizeAngle(n.startAngle)):C.normalizeAngle(n.startAngle),s=n.clockwise?cs(C.normalizeAngle(n.endAngle)):C.normalizeAngle(n.endAngle);return C.isBetweenAngle(i,r,s,n.clockwise)}function Nd(n,t){var e=t.center.x-n.center.x,i=t.center.y-n.center.y,r=Math.hypot(e,i);if(K.isNonPositive(r))return[];var s=n.radius+t.radius,a=Math.abs(n.radius-t.radius);if(r>s+an)return[];if(r<a-an)return[];var o=(n.radius*n.radius-t.radius*t.radius+r*r)/(2*r),c=n.radius*n.radius-o*o;if(c<-an)return[];var l=n.center.x+o*e/r,h=n.center.y+o*i/r;if(c<=an)return[new L(l,h)];var u=Math.sqrt(c),d=-i*u/r,g=e*u/r;return[new L(l+d,h+g),new L(l-d,h-g)]}function Sc(n,t){for(var e=n[0],i=e.distanceToSquared(t),r=1;r<n.length;r++){var s=n[r].distanceToSquared(t);s<i&&(e=n[r],i=s)}return e.clone()}function Pc(n,t){return new L((n.x+t.x)/2,(n.y+t.y)/2)}function Rd(n){for(var t,e=n.numberOfVertices,i=n.closed?e:e-1,r=0;r<i;r++){var s=n.vertices[r];if(K.isPositive(Math.abs((t=s.bulge)!==null&&t!==void 0?t:0)))return!0}return!1}function Ic(n){var t=Bd(n.vertices.map(function(e){return new L(e.x,e.y)}),n.closed);return t.length===n.numberOfVertices?n:new q(t.map(function(e){return{x:e.x,y:e.y}}),n.closed)}function Bd(n,t){var e=Ec(n);if(!t||e.length<2)return e;var i=e[0],r=e[e.length-1];return K.isNonPositive(Math.hypot(i.x-r.x,i.y-r.y))&&e.pop(),e}function Ec(n){var t=[];return n.forEach(function(e){var i=t[t.length-1];(!i||K.isPositive(Math.hypot(i.x-e.x,i.y-e.y)))&&t.push(new L(e.x,e.y))}),t}function Fd(n,t){for(var e=[],i=0;i<n.numberOfVertices;i++)e.push(n.getPointAt(i));var r=Dd(e,n.closed,t);if(r.length===0)return null;var s=[];if(n.closed){if(r.length<2)return null;for(var a=r.length,i=0;i<a;i++){var o=r[(i-1+a)%a],c=r[i];s.push(ls(o,c))}}else{s.push(r[0].start);for(var i=1;i<r.length;i++)s.push(ls(r[i-1],r[i]));s.push(r[r.length-1].end)}var l=new q;return s.forEach(function(h,u){l.addVertexAt(u,{x:h.x,y:h.y})}),l.closed=n.closed,l}function Dd(n,t,e){for(var i=[],r=t?n.length:n.length-1,s=0;s<r;s++){var a=n[s],o=n[t?(s+1)%n.length:s+1],c=o.x-a.x,l=o.y-a.y,h=Math.hypot(c,l);if(!K.isNonPositive(h)){var u=-l/h*e,d=c/h*e;i.push({start:new L(a.x+u,a.y+d),end:new L(o.x+u,o.y+d),dx:c,dy:l})}}return i}function ls(n,t){var e=n.dx*t.dy-n.dy*t.dx;if(K.equalToZero(e))return new L((n.end.x+t.start.x)/2,(n.end.y+t.start.y)/2);var i=t.start.x-n.start.x,r=t.start.y-n.start.y,s=(i*t.dy-r*t.dx)/e;return new L(n.start.x+s*n.dx,n.start.y+s*n.dy)}var Yd=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),hs=function(){return hs=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},hs.apply(this,arguments)},q=(function(n){Yd(t,n);function t(e,i){e===void 0&&(e=null),i===void 0&&(i=!1);var r=n.call(this)||this;return r._vertices=e||new Array,r._closed=i,r}return Object.defineProperty(t.prototype,"vertices",{get:function(){return this._vertices},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"numberOfVertices",{get:function(){return this._vertices.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"closed",{get:function(){return this._closed},set:function(e){this._closed=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){if(this.numberOfVertices>0){var e=this._vertices[0];return new L(e.x,e.y)}throw new Error("Start point does not exist in an empty polyline.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){var e=this.numberOfVertices;if(e>0)if(this.closed){var i=this._vertices[0];return new L(i.x,i.y)}else{var i=this._vertices[e-1];return new L(i.x,i.y)}throw new Error("End point does not exist in an empty polyline.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){for(var e=0,i=this._vertices.length,r=0;r<i;++r){var s=this._vertices[r],a=null;if(r<i-1?a=this._vertices[r+1]:r==i-1&&this.closed&&(a=this._vertices[0]),a)if(s.bulge){var o=new vt(s,a,s.bulge);e+=o.length}else e+=new L(s.x,s.y).distanceTo(a)}return e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"area",{get:function(){if(!this._closed||this._vertices.length<3)return 0;var e=this.getPoints(128);return ld(e)},enumerable:!1,configurable:!0}),t.prototype.addVertexAt=function(e,i){e<=0?this._vertices.unshift(i):this._vertices.splice(e,0,i),this._boundingBoxNeedsUpdate=!0},t.prototype.removeVertexAt=function(e){if(e<0||e>=this._vertices.length)throw new Error("Index ".concat(e," is out of bounds. Valid range is 0 to ").concat(this._vertices.length-1,"."));this._vertices.splice(e,1),this._boundingBoxNeedsUpdate=!0},t.prototype.reset=function(e,i){e?i!==void 0&&i>=0&&i<this._vertices.length&&(this._vertices=this._vertices.slice(0,i),this._boundingBoxNeedsUpdate=!0):(this._vertices=new Array,this._boundingBoxNeedsUpdate=!0)},t.prototype.getPointAt=function(e){var i=this._vertices[e];return new L(i.x,i.y)},t.prototype.calculateBoundingBox=function(){var e=this.getPoints(100);return new yt().setFromPoints(e)},t.prototype.transform=function(e){var i=e.determinant()<0;return this._vertices.forEach(function(r){var s=new L(r).applyMatrix2d(e);r.x=s.x,r.y=s.y,i&&r.bulge!=null&&(r.bulge=-r.bulge)}),this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this._vertices.map(function(e){return hs({},e)}),this._closed)},t.prototype.getPoints3d=function(e,i){var r=[],s=this.getPoints(e);return s.forEach(function(a){return r.push(new y().set(a.x,a.y,i))}),r},t.prototype.getPoints=function(e){for(var i=[],r=this._vertices.length,s=0;s<r;++s){var a=this._vertices[s];if(a.bulge){var o=null;if(s<r-1?o=this._vertices[s+1]:s==r-1&&this.closed&&(o=this._vertices[0]),o)for(var c=new vt(a,o,a.bulge),l=c.getPoints(e),h=l.length,u=0;u<h;++u){var d=l[u];i.push(new L(d.x,d.y))}}else i.push(new L(a.x,a.y)),s==r-1&&this.closed&&i.push(i[0])}return i},t.prototype.offset=function(e){return kc(this,e)},t})(oi);function Lc(n,t,e){var i=Math.hypot(t.x,t.y);if(K.isNonPositive(i))return null;var r=-t.y/i*e,s=t.x/i*e;return new y(n.x+r,n.y+s,n.z)}function Xd(n,t,e){var i;if(n.length<2)return null;var r=fd(new q(n.map(function(a){return{x:a.x,y:a.y}}),t)),s=kc(r,e);return(i=s[0])!==null&&i!==void 0?i:null}var vn=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},Ke=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))};function zd(n,t,e,i){if(n.length<2||K.equalToZero(e))return null;var r=Cc(n,i),s=r.points,a=r.tangents;if(s.length<2)return null;var o=a??jd(s,t),c=Vd(s,o,e),l=t?Ud(c):Gd(c);if(l.length<2)return null;var h=new q;return l.forEach(function(u,d){h.addVertexAt(d,{x:u.x,y:u.y})}),h.closed=t,h}function jd(n,t){for(var e=n.length,i=new Array(e),r=0;r<e;r++){var s=0,a=0;if(t){var o=n[(r-1+e)%e],c=n[(r+1)%e];s=c.x-o.x,a=c.y-o.y}else r===0?(s=n[1].x-n[0].x,a=n[1].y-n[0].y):r===e-1?(s=n[e-1].x-n[e-2].x,a=n[e-1].y-n[e-2].y):(s=n[r+1].x-n[r-1].x,a=n[r+1].y-n[r-1].y);var l=Math.hypot(s,a);K.isNonPositive(l)?i[r]=new L(1,0):i[r]=new L(s/l,a/l)}return i}function Vd(n,t,e){return n.map(function(i,r){var s=t[r],a=-s.y*e,o=s.x*e;return new L(i.x+a,i.y+o)})}function Gd(n){var t=kn(n);if(t.length<3)return t;for(;;){var e=Tc(t,!1);if(!e||(t=kn(Ke(Ke(Ke([],vn(t.slice(0,e.segmentA+1)),!1),[e.point],!1),vn(t.slice(e.segmentB+1)),!1)),t.length<2))break}return t}function Ud(n){var t=kn(n);if(t.length<4)return t;for(;;){var e=Tc(t,!0);if(!e||(t=kn(Ke(Ke(Ke([],vn(t.slice(0,e.segmentA+1)),!1),[e.point],!1),vn(t.slice(e.segmentB+1)),!1)),t.length<3))break}return t}function Tc(n,t){var e=t?n.length:n.length-1;if(e<2)return null;for(var i=0;i<e;i++)for(var r=n[i],s=n[(i+1)%n.length],a=i+1;a<e;a++)if(!Hd(i,a,e,t)){var o=n[a],c=n[(a+1)%n.length],l=Wd(r,s,o,c);if(l)return{point:l,segmentA:i,segmentB:a}}return null}function Hd(n,t,e,i){return!!(t===n||t===n+1||i&&n===0&&t===e-1)}function Wd(n,t,e,i){var r=t.x-n.x,s=t.y-n.y,a=i.x-e.x,o=i.y-e.y,c=r*o-s*a;if(K.equalToZero(c))return null;var l=e.x-n.x,h=e.y-n.y,u=(l*o-h*a)/c,d=(l*s-h*r)/c,g=mr.equalPointTol;return u<-g||u>1+g||d<-g||d>1+g?null:new L(n.x+u*r,n.y+u*s)}function Cc(n,t){var e=[],i=[],r=t!=null&&t.length===n.length;return n.forEach(function(s,a){var o=e[e.length-1];if((!o||K.isPositive(Math.hypot(o.x-s.x,o.y-s.y)))&&(e.push(new L(s.x,s.y)),r)){var c=t[a];i.push(new L(c.x,c.y))}}),{points:e,tangents:r?i:void 0}}function kn(n){return Cc(n).points}var $d=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Vt=(function(n){$d(t,n);function t(){var e=n.call(this)||this;return e._loops=[],e}return t.prototype.add=function(e){this._loops.push(e),this._boundingBoxNeedsUpdate=!0},Object.defineProperty(t.prototype,"loops",{get:function(){return this._loops},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"outter",{get:function(){if(this._loops.length>0)return this._loops[0]},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e=this.outter;return e?e.box:new yt},t.prototype.transform=function(e){return this._loops.forEach(function(i){i.transform(e)}),this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){var e=new t;return this._loops.forEach(function(i){e.add(i.clone())}),e},t.prototype.getPoints=function(e){for(var i=[],r=0;r<this.loops.length;++r){var s=this.loops[r],a=s.getPoints(e);i.push(a)}return i},t.prototype.buildHierarchy=function(){for(var e,i=this.getPoints(100),r=this.calculateBoundaryBoxes(i),s=this.sortBoundaryBoxesByAreas(r),a=new Map,o=s.length,c=0;c<o;c++)a.set(s[c],{index:s[c],children:[]});for(var l={index:-1,children:[]},c=0;c<o;c++){for(var h=s[c],u=i[h],d=r[h],g=c+1;g<o;g++){var p=s[g],f=i[p],m=r[p];if(m.containsBox(d)&&wt.isPointInPolygon(u[C.randInt(0,u.length-1)],f)){(e=a.get(p))===null||e===void 0||e.children.push(a.get(h));break}}g===o&&l.children.push(a.get(h))}return l},Object.defineProperty(t.prototype,"area",{get:function(){if(this._loops.length===0)return 0;for(var e=0,i=0;i<this._loops.length;i++){var r=this._loops[i],s=r.getPoints(128),a=xc(s);i===0?e+=Math.abs(a):e-=Math.abs(a)}return e},enumerable:!1,configurable:!0}),t.prototype.calculateBoundaryBoxes=function(e){var i=[];return e.forEach(function(r){i.push(new yt().setFromPoints(r))}),i},t.prototype.sortBoundaryBoxesByAreas=function(e){var i=[];e.forEach(function(s,a){var o=s.size,c=o.width*o.height;i.push({area:c,index:a})}),i.sort(function(s,a){return s.area-a.area});var r=[];return i.forEach(function(s){r.push(s.index)}),r},t})(Gs),qd=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Kd=(function(n){qd(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.translate=function(e){return this.transform(new D().makeTranslation(e.x,e.y,e.z))},Object.defineProperty(t.prototype,"box",{get:function(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box},enumerable:!1,configurable:!0}),t})(vc),Zd=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Hi=(function(n){Zd(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t})(Kd),Qd=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),ue=(function(n){Qd(t,n);function t(e,i){var r=n.call(this)||this;return r._start=new y(e),r._end=new y(i),r}return Object.defineProperty(t.prototype,"startPoint",{get:function(){return this._start},set:function(e){this._start.copy(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this._end},set:function(e){this._end.copy(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"direction",{get:function(){return new w().subVectors(this.endPoint,this.startPoint).normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){return new y((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)},enumerable:!1,configurable:!0}),t.prototype.nearestPoint=function(e){return this.project(e)},Object.defineProperty(t.prototype,"length",{get:function(){return this.startPoint.distanceTo(this.endPoint)},enumerable:!1,configurable:!0}),t.prototype.isPointOnLine=function(e){var i=this.project(e),r=1e-6;return i.distanceTo(e)<r},t.prototype.at=function(e,i){return this.delta(i).multiplyScalar(e).add(this._start)},t.prototype.atLength=function(e,i){if(i===void 0&&(i=!1),i){var r=this.delta(Ie).normalize();return new y(this._start).addScaledVector(r,e)}else{var r=this.delta(Ie).normalize();return new y(this._end).addScaledVector(r,e)}},t.prototype.extend=function(e,i){if(i===void 0&&(i=!1),i){var r=Ie.subVectors(this._start,this._end).normalize();this._start=new y(this._start).addScaledVector(r,e)}else{var r=this.delta(Ie).normalize();this._end=new y(this._end).addScaledVector(r,e)}return this._boundingBoxNeedsUpdate=!0,this},t.prototype.closestPointToPointParameter=function(e,i){eo.subVectors(e,this._start),on.subVectors(this.endPoint,this.startPoint);var r=on.dot(on),s=on.dot(eo),a=s/r;return i&&(a=C.clamp(a,0,1)),a},t.prototype.closestPointToPoint=function(e,i,r){var s=this.closestPointToPointParameter(e,i);return this.delta(r).multiplyScalar(s).add(this._start)},t.prototype.delta=function(e){return e.subVectors(this._end,this._start)},t.prototype.distanceSq=function(){return this._start.distanceToSquared(this._end)},t.prototype.distance=function(){return this._start.distanceTo(this._end)},t.prototype.project=function(e){var i=this.direction,r=Ie.subVectors(e,this.startPoint),s=r.dot(i);return new y().copy(i).multiplyScalar(s).add(this.startPoint)},t.prototype.perpPoint=function(e){var i=this.direction,r=this.startPoint,s=Ie.subVectors(e,r),a=s.dot(i),o=Ie.copy(i).multiplyScalar(a);return new y().addVectors(r,o)},t.prototype.calculateBoundingBox=function(){var e=new y(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y),Math.min(this._start.z,this._end.z)),i=new y(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 Y(e,i)},t.prototype.transform=function(e){return this._start.applyMatrix4(e),this._end.applyMatrix4(e),this._boundingBoxNeedsUpdate=!0,this},Object.defineProperty(t.prototype,"closed",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.copy=function(e){return this.startPoint=e.startPoint,this.endPoint=e.endPoint,this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this._start.clone(),this._end.clone())},t.prototype.offset=function(e){var i=this.startPoint,r=this.endPoint,s=Math.hypot(r.x-i.x,r.y-i.y);if(s===0)return this.clone();var a=new w(r.x-i.x,r.y-i.y,0).normalize(),o=new w(-a.y,a.x,0);return new t(new y(i.x+o.x*e,i.y+o.y*e,i.z),new y(r.x+o.x*e,r.y+o.y*e,r.z))},t})(Hi),Ie=new w,eo=new w,on=new w,Jd=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Rr=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Kt=(function(n){Jd(t,n);function t(e,i,r,s,a,o){o===void 0&&(o=w.X_AXIS);var c=n.call(this)||this;return c.center=e,c.radius=i,c.startAngle=r,c.endAngle=s,c.normal=a,c.refVec=o,(s-r)%j==0?(c.startAngle=0,c.endAngle=j):(c.startAngle=r,c.endAngle=s),c}return t.computeCenterPoint=function(e,i,r){var s=new w().addVectors(e,i).multiplyScalar(.5),a=new w().addVectors(e,r).multiplyScalar(.5),o=new w().subVectors(i,e),c=new w().subVectors(r,e),l=new w().crossVectors(o,c).normalize();if(l.lengthSq()===0)return null;var h=new w().crossVectors(o,l).normalize(),u=new w().crossVectors(c,l).normalize(),d=h.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),g=u.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),p=new ue(s,s.clone().add(d)),f=new ue(a,a.clone().add(g)),m=new w,b=p.closestPointToPoint(f.startPoint,!0,m);return b?m:null},t.createByThreePoints=function(e,i,r){var s=t.computeCenterPoint(e,i,r);if(s){var a=s.distanceTo(e),o=new w().subVectors(e,s),c=new w().subVectors(i,s),l=Math.atan2(o.y,o.x),h=Math.atan2(c.y,c.x);return new t(s,a,l,h,w.Z_AXIS)}},Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new y(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"radius",{get:function(){return this._radius},set:function(e){if(e<0)throw Pt.ILLEGAL_PARAMETERS;this._radius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._startAngle},set:function(e){this._startAngle=C.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._endAngle},set:function(e){this._endAngle=this.startAngle==0&&e==j?e:C.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deltaAngle",{get:function(){return C.normalizeAngle(this.endAngle-this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this.deltaAngle<=0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._normal},set:function(e){this._normal=new w(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"refVec",{get:function(){return this._refVec},set:function(e){this._refVec=new w(e.x,e.y,e.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this._startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this._endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){var e=this.startAngle,i=this.deltaAngle;this.closed&&(e=0,i=j);var r=e+i*.5;return this.getPointAtAngle(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"area",{get:function(){return this.closed?Math.PI*this.radius*this.radius:0},enumerable:!1,configurable:!0}),t.prototype.nearestPoint=function(e){var i=new w(e.x,e.y,e.z||0),r=this.center,s=this.normal,a=i.clone().sub(r),o=a.dot(s),c=i.clone().sub(s.clone().multiplyScalar(o)),l=c.clone().sub(r);if(l.lengthSq()===0)return this.startPoint.clone();l.normalize().multiplyScalar(this.radius);var h=r.clone().add(l),u=this.getAngle(h.clone()),d=this.startAngle,g=this.deltaAngle,p=C.normalizeAngle(u-d);p<0&&(p=0),p>g&&(p=g);var f=this.getPointAtAngle(d+p),m=f.distanceTo(i),b=this.startPoint.distanceTo(i),_=this.endPoint.distanceTo(i);return b<m&&b<=_?this.startPoint.clone():_<m&&_<b?this.endPoint.clone():f},t.prototype.tangentPoints=function(e){var i,r,s=[],a=new w(e.x,e.y,e.z||0),o=this.center,c=this.normal,l=this.radius,h=a.clone().sub(o),u=h.dot(c),d=a.clone().sub(c.clone().multiplyScalar(u)),g=o.clone(),p=d.clone().sub(g),f=p.length();if(f<l)return s;var m=Math.acos(l/f),b=this.getAngle(d.clone()),_=[b+m,b-m];try{for(var v=Rr(_),x=v.next();!x.done;x=v.next()){var S=x.value,P=C.normalizeAngle(S-this.startAngle);P>=0&&P<=this.deltaAngle&&s.push(this.getPointAtAngle(this.startAngle+P))}}catch(E){i={error:E}}finally{try{x&&!x.done&&(r=v.return)&&r.call(v)}finally{if(i)throw i.error}}return s},t.prototype.perpendicularPoints=function(e){var i,r,s=[],a=new w(e.x,e.y,e.z||0),o=this.center,c=this.normal,l=this.radius,h=a.clone().sub(o),u=h.dot(c),d=a.clone().sub(c.clone().multiplyScalar(u)),g=d.clone().sub(o);if(g.lengthSq()<1e-24)return s;g.normalize();var p=[o.clone().add(g.clone().multiplyScalar(l)),o.clone().sub(g.clone().multiplyScalar(l))];try{for(var f=Rr(p),m=f.next();!m.done;m=f.next()){var b=m.value,_=this.getAngle(b.clone()),v=C.normalizeAngle(_-this.startAngle);v>=0&&v<=this.deltaAngle&&s.push(new y(b.x,b.y,b.z||0))}}catch(x){i={error:x}}finally{try{m&&!m.done&&(r=f.return)&&r.call(f)}finally{if(i)throw i.error}}return s},t.prototype.nearestTangentPoint=function(e){var i=this.tangentPoints(e);if(i.length===0)return null;var r=new y(e.x,e.y,e.z||0);return i.length===1||i[0].distanceTo(r)<i[1].distanceTo(r)?i[0]:i[1]},t.prototype.calculateBoundingBox=function(){for(var e,i,r=[this.startAngle,this.endAngle],s=0;s<2*Math.PI;s+=Math.PI/2)C.isBetweenAngle(s,this.startAngle,this.endAngle)&&r.push(s);var a=1/0,o=1/0,c=1/0,l=-1/0,h=-1/0,u=-1/0;try{for(var d=Rr(r),g=d.next();!g.done;g=d.next()){var p=g.value,f=this.getPointAtAngle(p);f.x<a&&(a=f.x),f.y<o&&(o=f.y),f.z<c&&(c=f.z),f.x>l&&(l=f.x),f.y>h&&(h=f.y),f.z>u&&(u=f.z)}}catch(m){e={error:m}}finally{try{g&&!g.done&&(i=d.return)&&i.call(d)}finally{if(e)throw e.error}}return new Y({x:a,y:o,z:c},{x:l,y:h,z:u})},Object.defineProperty(t.prototype,"closed",{get:function(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0},enumerable:!1,configurable:!0}),t.prototype.getPoints=function(e){var i=[],r=this.deltaAngle,s=this.startAngle;this.closed&&(r=j,s=0);for(var a=0;a<=e;a++){var o=s+r*(a/e),c=this.getPointAtAngle(o);i.push(c)}return i},t.prototype.transform=function(e){var i=this.center.clone().applyMatrix4(e),r=this.startPoint.clone().applyMatrix4(e),s=this.endPoint.clone().applyMatrix4(e),a=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(e),o=new w(r).sub(i).normalize(),c=i.distanceTo(r),l=new w().crossVectors(new w(r).sub(i),new w(a).sub(i)).normalize();l.lengthSq()===0&&(l=this.normal.clone().transformDirection(e));var h=function(u){var d=new w(u).sub(i);return Math.atan2(d.dot(io.crossVectors(l,o)),d.dot(o))};return this.center=i,this.radius=c,this.normal=l,this.refVec=o,this.startAngle=0,this.endAngle=this.closed?j:h(s),this._boundingBoxNeedsUpdate=!0,this},t.prototype.copy=function(e){return this.center=e.center,this.radius=e.radius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.normal=e.normal,this.refVec=e.refVec,this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)},t.prototype.getAngle=function(e){return e.sub(this.center),Math.atan2(e.dot(io.crossVectors(this.refVec,this.normal)),e.dot(this.refVec))},t.prototype.getPointAtAngle=function(e){var i=this.normal,r=this.refVec,s={x:i.y*r.z-i.z*r.y,y:i.z*r.x-i.x*r.z,z:i.x*r.y-i.y*r.x},a=this.center,o=this.radius;return new y(a.x+o*(r.x*Math.cos(e)+s.x*Math.sin(e)),a.y+o*(r.y*Math.cos(e)+s.y*Math.sin(e)),a.z+o*(r.z*Math.cos(e)+s.z*Math.sin(e)))},Object.defineProperty(t.prototype,"plane",{get:function(){var e=new w(this.center).distanceTo(zs);return new js(this.normal,e)},enumerable:!1,configurable:!0}),t.prototype.offset=function(e){var i=this.radius+e;return i<=0?null:new t(this.center,i,this.startAngle,this.endAngle,this.normal,this.refVec)},t})(Hi),io=new w,tg=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),me=(function(n){tg(t,n);function t(e,i,r,s,a,o,c){s===void 0&&(s=0),a===void 0&&(a=j),o===void 0&&(o=!1),c===void 0&&(c=0);var l=n.call(this)||this;return l.center=e,l.majorAxisRadius=i,l.minorAxisRadius=r,(a-s)%j==0?(l.startAngle=0,l.endAngle=j):(l.startAngle=s,l.endAngle=a),l.clockwise=o,l.rotation=c,l}return Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new y(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"majorAxisRadius",{get:function(){return this._majorAxisRadius},set:function(e){if(e<0)throw Pt.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minorAxisRadius",{get:function(){return this._minorAxisRadius},set:function(e){if(e<0)throw Pt.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._startAngle},set:function(e){this._startAngle=C.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._endAngle},set:function(e){this._endAngle=this.startAngle==0&&e==j?e:C.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this._clockwise},set:function(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deltaAngle",{get:function(){return C.normalizeAngle(this.endAngle-this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){for(var e=100,i=1/0,r=1/0,s=-1/0,a=-1/0,o=0;o<=e;o++){var c=this.getPoint(o/e);i=Math.min(i,c.x),r=Math.min(r,c.y),s=Math.max(s,c.x),a=Math.max(a,c.y)}return new yt({x:i,y:r},{x:s,y:a})},Object.defineProperty(t.prototype,"closed",{get:function(){return this.deltaAngle==0},enumerable:!1,configurable:!0}),t.prototype.getPoint=function(e){for(var i=Math.PI*2,r=this.endAngle-this.startAngle,s=Math.abs(r)<Number.EPSILON;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(s?r=0:r=i),this.clockwise===!0&&!s&&(r===i?r=-i:r=r-i);var a=this.startAngle+e*r,o=this.center.x+this.majorAxisRadius*Math.cos(a),c=this.center.y+this.minorAxisRadius*Math.sin(a);if(this.rotation!==0){var l=Math.cos(this.rotation),h=Math.sin(this.rotation),u=o-this.center.x,d=c-this.center.y;o=u*l-d*h+this.center.x,c=u*h+d*l+this.center.y}return new L(o,c)},t.prototype.transform=function(e){var i=e,r=new L(this.center).applyMatrix2d(i),s=new y(r.x,r.y,this.center.z),a=this.getPointAtAngle(0).clone().applyMatrix2d(i),o=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(i),c=new L(a).sub(r),l=new L(o).sub(r),h=c.length(),u=l.length(),d=Math.atan2(c.y,c.x),g=c.clone().normalize(),p=l.clone().normalize(),f=function(_){var v=new L(_).sub(r),x=v.dot(g),S=v.dot(p);return C.normalizeAngle(Math.atan2(S/u,x/h))},m=i.determinant()<0?!this.clockwise:this.clockwise,b=this.closed?new t(s,h,u,0,j,m,d):new t(s,h,u,f(this.startPoint.clone().applyMatrix2d(i)),f(this.endPoint.clone().applyMatrix2d(i)),m,d);return this.center=b.center,this.majorAxisRadius=b.majorAxisRadius,this.minorAxisRadius=b.minorAxisRadius,this._startAngle=b._startAngle,this._endAngle=b._endAngle,this._clockwise=b._clockwise,this.rotation=b.rotation,this._boundingBoxNeedsUpdate=!0,this},t.prototype.getPointAtAngle=function(e){return this.getPoint(this.closed?e/j:C.normalizeAngle(e-this.startAngle)/this.deltaAngle)},t.prototype.copy=function(e){return this.center=e.center,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this},t.prototype.clone=function(){return new t(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)},t.prototype.getFocusPoints=function(){var e=Math.max(this.majorAxisRadius,this.minorAxisRadius),i=Math.min(this.majorAxisRadius,this.minorAxisRadius);if(e-i<1e-9)return[];var r=Math.sqrt(e*e-i*i),s=Math.cos(this.rotation),a=Math.sin(this.rotation),o=this.majorAxisRadius>=this.minorAxisRadius,c=o?s:-a,l=o?a:s;return[new L(this.center.x-r*c,this.center.y-r*l),new L(this.center.x+r*c,this.center.y+r*l)]},t.prototype.getQuadrantPoints=function(){return this.closed?[this.getPoint(0),this.getPoint(.25),this.getPoint(.5),this.getPoint(.75)]:[]},t.prototype.nearestPoint=function(e){for(var i=new L(e.x,e.y),r=this.getPoint(0),s=i.distanceToSquared(r),a=72,o=1;o<=a;o++){var c=this.getPoint(o/a),l=i.distanceToSquared(c);l<s&&(s=l,r=c)}return r},t.prototype.tangentPoints=function(e){var i=this,r=this._projectPointToLocal(e),s=this._findSnapAngles(r,function(a,o,c,l){var h=-i.majorAxisRadius*l,u=i.minorAxisRadius*c;return(a-r.x)*u-(o-r.y)*h});return s.map(function(a){return i.getPointAtAngle(a)})},t.prototype.perpendicularPoints=function(e){var i=this,r=this._projectPointToLocal(e),s=this._findSnapAngles(r,function(a,o,c,l){var h=i.minorAxisRadius*c,u=i.majorAxisRadius*l;return(a-r.x)*u-(o-r.y)*h});return s.map(function(a){return i.getPointAtAngle(a)})},t.prototype._projectPointToLocal=function(e){var i=e.x-this.center.x,r=e.y-this.center.y,s=Math.cos(-this.rotation),a=Math.sin(-this.rotation);return{x:i*s-r*a,y:i*a+r*s}},t.prototype._findSnapAngles=function(e,i,r){r===void 0&&(r=144);for(var s=this.majorAxisRadius,a=this.minorAxisRadius,o=this.startAngle,c=this.deltaAngle,l=[],h=function(x){var S=Math.cos(x),P=Math.sin(x);return i(s*S,a*P,S,P)},u=o,d=h(u),g=1;g<=r;g++){var p=o+c*g/r,f=h(p);if(Math.abs(d)<1e-10&&l.push(u),d*f<0){for(var m=u,b=p,_=0;_<32;_++){var v=(m+b)/2;h(m)*h(v)<=0?b=v:m=v}l.push((m+b)/2)}u=p,d=f}return l},t})(oi),eg=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),ig=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},An=(function(n){eg(t,n);function t(e,i,r,s,a,o,c){o===void 0&&(o=0),c===void 0&&(c=j);var l=n.call(this)||this;l.center=e,l.normal=i,l.majorAxis=r,l.majorAxisRadius=s,l.minorAxisRadius=a;var h=Math.abs(c-o);return Math.abs(h-j)<1e-10||Math.abs(h-2*j)<1e-10?(l.startAngle=0,l.endAngle=j):(l.startAngle=o,l.endAngle=c),l}return Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new y(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"majorAxisRadius",{get:function(){return this._majorAxisRadius},set:function(e){if(e<0)throw Pt.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minorAxisRadius",{get:function(){return this._minorAxisRadius},set:function(e){if(e<0)throw Pt.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._startAngle},set:function(e){this._startAngle=C.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._endAngle},set:function(e){this._endAngle=this.startAngle==0&&e==j?e:C.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deltaAngle",{get:function(){var e=this.endAngle-this.startAngle;return Math.abs(e-j)<1e-10?j:C.normalizeAngle(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this.deltaAngle<=0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._normal},set:function(e){this._normal=new w(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"majorAxis",{get:function(){return this._majorAxis},set:function(e){this._majorAxis=new w(e.x,e.y,e.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minorAxis",{get:function(){return new w().crossVectors(this.normal,this.majorAxis).normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this._startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this._endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){var e=this.startAngle,i=this.deltaAngle;(this.closed||Math.abs(i-j)<1e-10)&&(e=0,i=j);var r=e+i/2;return this.getPointAtAngle(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCircular",{get:function(){return K.equal(this.majorAxisRadius,this.minorAxisRadius)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);for(var e=1e3,i=this.deltaAngle/e,r=0,s=this.getPointAtAngle(this.startAngle),a=1;a<=e;a++){var o=this.startAngle+a*i,c=this.getPointAtAngle(o),l=c.x-s.x,h=c.y-s.y,u=c.z-s.z;r+=Math.sqrt(l*l+h*h+u*u),s=c}return r},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"area",{get:function(){return Math.abs(this.deltaAngle-j)>=1e-10?0:Math.PI*this.majorAxisRadius*this.minorAxisRadius},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e,i;if(this.majorAxis.equals(w.X_AXIS)||this.majorAxis.equals(w.Y_AXIS)||this.majorAxis.isParallelTo(w.X_AXIS)||this.majorAxis.isParallelTo(w.Y_AXIS)){for(var r=[this.startAngle,this.endAngle],s=0;s<2*Math.PI;s+=Math.PI/2)C.isBetweenAngle(s,this.startAngle,this.endAngle)&&r.push(s);var a=1/0,o=1/0,c=1/0,l=-1/0,h=-1/0,u=-1/0;try{for(var d=ig(r),g=d.next();!g.done;g=d.next()){var p=g.value,f=this.getPointAtAngle(p);f.x<a&&(a=f.x),f.y<o&&(o=f.y),f.z<c&&(c=f.z),f.x>l&&(l=f.x),f.y>h&&(h=f.y),f.z>u&&(u=f.z)}}catch(b){e={error:b}}finally{try{g&&!g.done&&(i=d.return)&&i.call(d)}finally{if(e)throw e.error}}return new Y({x:a,y:o,z:c},{x:l,y:h,z:u})}else{for(var m=100,a=1/0,o=1/0,c=1/0,l=-1/0,h=-1/0,u=-1/0,s=0;s<=m;s++){var p=this.startAngle+this.deltaAngle*(s/m),f=this.getPointAtAngle(p);a=Math.min(a,f.x),o=Math.min(o,f.y),c=Math.min(c,f.z),l=Math.max(l,f.x),h=Math.max(h,f.y),u=Math.max(u,f.z)}return new Y({x:a,y:o,z:c},{x:l,y:h,z:u})}},Object.defineProperty(t.prototype,"closed",{get:function(){return this.deltaAngle==0},enumerable:!1,configurable:!0}),t.prototype.getPoints=function(e){e===void 0&&(e=100);var i=[],r=this.deltaAngle,s=this.startAngle;this.closed&&(r=j,s=0);for(var a=0;a<=e;a++){var o=s+r*(a/e),c=this.getPointAtAngle(o);i.push(c)}return i},t.prototype.getPointAtAngle=function(e){var i=Math.cos(e),r=Math.sin(e),s=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(r),a=this.majorAxis.clone().multiplyScalar(i*this.majorAxisRadius).add(s);return new y(this.center.x+a.x,this.center.y+a.y,this.center.z+a.z)},t.prototype.nearestPoint=function(e,i){i===void 0&&(i=72);for(var r=new y(e.x,e.y,e.z||0),s=this.getPointAtAngle(this.startAngle),a=r.distanceToSquared(s),o=1;o<=i;o++){var c=this.startAngle+this.deltaAngle*o/i,l=this.getPointAtAngle(c),h=r.distanceToSquared(l);h<a&&(a=h,s=l)}var u=r.distanceToSquared(this.startPoint),d=r.distanceToSquared(this.endPoint);return u<a&&u<=d?this.startPoint.clone():d<a&&d<u?this.endPoint.clone():s.clone()},t.prototype.tangentPoints=function(e){var i=this,r=this._projectPointToLocalPlane(e),s=this._findSnapParameterAngles(function(a,o,c,l){var h=-i.majorAxisRadius*l,u=i.minorAxisRadius*c;return(a-r.x)*u-(o-r.y)*h});return s.map(function(a){return i.getPointAtAngle(a)})},t.prototype.perpendicularPoints=function(e){var i=this,r=this._projectPointToLocalPlane(e),s=this._findSnapParameterAngles(function(a,o,c,l){var h=i.minorAxisRadius*c,u=i.majorAxisRadius*l;return(a-r.x)*u-(o-r.y)*h});return s.map(function(a){return i.getPointAtAngle(a)})},t.prototype._projectPointToLocalPlane=function(e){var i=new y(e.x,e.y,e.z||0),r=new w(i).sub(this.center),s=r.dot(this.normal);return r.sub(this.normal.clone().multiplyScalar(s)),{x:r.dot(this.majorAxis),y:r.dot(this.minorAxis)}},t.prototype._findSnapParameterAngles=function(e,i){i===void 0&&(i=144);for(var r=this.majorAxisRadius,s=this.minorAxisRadius,a=this.startAngle,o=this.deltaAngle,c=[],l=function(v){var x=Math.cos(v),S=Math.sin(v);return e(r*x,s*S,x,S)},h=a,u=l(h),d=1;d<=i;d++){var g=a+o*d/i,p=l(g);if(Math.abs(u)<1e-10&&c.push(h),u*p<0){for(var f=h,m=g,b=0;b<32;b++){var _=(f+m)/2;l(f)*l(_)<=0?m=_:f=_}c.push((f+m)/2)}h=g,u=p}return c},t.prototype.contains=function(e){var i=new w(e).sub(this.center),r=i.dot(this.majorAxis),s=i.dot(this.minorAxis),a=r/this.majorAxisRadius,o=s/this.minorAxisRadius;return a*a+o*o<=1},t.prototype.transform=function(e){var i=e,r=this.center.clone().applyMatrix4(i),s=this.getPointAtAngle(0).clone().applyMatrix4(i),a=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(i),o=new w(s).sub(r),c=new w(a).sub(r),l=o.length(),h=c.length(),u=o.clone().normalize(),d=new w().crossVectors(o,c).normalize(),g=new w().crossVectors(d,u).normalize();g.dot(c)<0&&(d.negate(),g=new w().crossVectors(d,u).normalize());var p=function(m){var b=new w(m).sub(r),_=b.dot(u),v=b.dot(g);return C.normalizeAngle(Math.atan2(v/h,_/l))},f=this.closed?new t(r,d,u,l,h,0,j):new t(r,d,u,l,h,p(this.startPoint.clone().applyMatrix4(i)),p(this.endPoint.clone().applyMatrix4(i)));return this.center=f.center,this.normal=f.normal,this.majorAxis=f.majorAxis,this.majorAxisRadius=f.majorAxisRadius,this.minorAxisRadius=f.minorAxisRadius,this._startAngle=f._startAngle,this._endAngle=f._endAngle,this._boundingBoxNeedsUpdate=!0,this},t.prototype.copy=function(e){return this.center=e.center,this.normal=e.normal,this.majorAxis=e.majorAxis,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)},Object.defineProperty(t.prototype,"plane",{get:function(){var e=new w(this.center).distanceTo(zs);return new js(this.normal,e)},enumerable:!1,configurable:!0}),t.prototype.offset=function(e){var i=this.majorAxisRadius+e,r=this.minorAxisRadius+e;return i<=0||r<=0?null:new t(this.center,this.normal,this.majorAxis,i,r,this.startAngle,this.endAngle)},t})(Hi),ng=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),zt=(function(n){ng(t,n);function t(e,i){var r=n.call(this)||this;return r._start=new L(e),r._end=new L(i),r}return Object.defineProperty(t.prototype,"startPoint",{get:function(){return this._start},set:function(e){this._start.copy(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this._end},set:function(e){this._end.copy(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),t.prototype.getPoints=function(){return[this.startPoint,this.endPoint]},Object.defineProperty(t.prototype,"length",{get:function(){return this.startPoint.distanceTo(this.endPoint)},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e=new L(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),i=new L(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new yt(e,i)},t.prototype.transform=function(e){return this._start.applyMatrix2d(e),this._end.applyMatrix2d(e),this._boundingBoxNeedsUpdate=!0,this},Object.defineProperty(t.prototype,"closed",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.copy=function(e){return this.startPoint=e.startPoint,this.endPoint=e.endPoint,this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this._start.clone(),this._end.clone())},t.prototype.project=function(e){var i=this._end.x-this._start.x,r=this._end.y-this._start.y,s=i*i+r*r;if(s<1e-18)return this._start.clone();var a=((e.x-this._start.x)*i+(e.y-this._start.y)*r)/s;return a=Math.max(0,Math.min(1,a)),new L(this._start.x+a*i,this._start.y+a*r)},t.prototype.nearestPoint=function(e){return this.project(e)},t})(oi),rg=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Br=(function(){function n(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}return n.prototype.init=function(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},n.prototype.initCatmullRom=function(t,e,i,r,s){this.init(e,i,s*(i-t),s*(r-e))},n.prototype.initNonuniformCatmullRom=function(t,e,i,r,s,a,o){var c=(e-t)/s-(i-t)/(s+a)+(i-e)/a,l=(i-e)/a-(r-e)/(a+o)+(r-i)/o;c*=a,l*=a,this.init(e,i,c,l)},n.prototype.calc=function(t){var e=t*t,i=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*i},n})(),Mc=(function(n){rg(t,n);function t(e,i,r,s){e===void 0&&(e=[]),i===void 0&&(i=!1),r===void 0&&(r="centripetal"),s===void 0&&(s=.5);var a=n.call(this)||this;return a.isCatmullRomCurve3d=!0,a.type="CatmullRomCurve3d",a._tmp=new w,a._px=new Br,a._py=new Br,a._pz=new Br,a._points=e.map(function(o){return new y(o)}),a._closed=i,a._curveType=r,a._tension=s,a}return Object.defineProperty(t.prototype,"points",{get:function(){return this._points},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"closed",{get:function(){return this._closed},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"curveType",{get:function(){return this._curveType},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tension",{get:function(){return this._tension},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this._points.length>0?this._points[0]:new y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this._points.length>0?this._points[this._points.length-1]:new y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){if(this._points.length<2)return 0;for(var e=0,i=1;i<this._points.length;i++)e+=this._points[i-1].distanceTo(this._points[i]);return this._closed&&this._points.length>2&&(e+=this._points[this._points.length-1].distanceTo(this._points[0])),e},enumerable:!1,configurable:!0}),t.prototype.getPoint=function(e,i){i===void 0&&(i=new y);var r=i,s=this._points,a=s.length;if(a===0)return r.set(0,0,0);if(a===1)return r.copy(s[0]);var o=(a-(this._closed?0:1))*e,c=Math.floor(o),l=o-c;this._closed?c+=c>0?0:(Math.floor(Math.abs(c)/a)+1)*a:l===0&&c===a-1&&(c=a-2,l=1);var h,u;this._closed||c>0?h=s[(c-1)%a]:(this._tmp.subVectors(s[0],s[1]).add(s[0]),h=new y(this._tmp.x,this._tmp.y,this._tmp.z));var d=s[c%a],g=s[(c+1)%a];if(this._closed||c+2<a?u=s[(c+2)%a]:(this._tmp.subVectors(s[a-1],s[a-2]).add(s[a-1]),u=new y(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){var p=this._curveType==="chordal"?.5:.25,f=Math.pow(h.distanceToSquared(d),p),m=Math.pow(d.distanceToSquared(g),p),b=Math.pow(g.distanceToSquared(u),p);m<1e-4&&(m=1),f<1e-4&&(f=m),b<1e-4&&(b=m),this._px.initNonuniformCatmullRom(h.x,d.x,g.x,u.x,f,m,b),this._py.initNonuniformCatmullRom(h.y,d.y,g.y,u.y,f,m,b),this._pz.initNonuniformCatmullRom(h.z,d.z,g.z,u.z,f,m,b)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(h.x,d.x,g.x,u.x,this._tension),this._py.initCatmullRom(h.y,d.y,g.y,u.y,this._tension),this._pz.initCatmullRom(h.z,d.z,g.z,u.z,this._tension));return r.set(this._px.calc(l),this._py.calc(l),this._pz.calc(l)),r},t.prototype.getPoints=function(e){for(var i=[],r=0;r<=e;r++)i.push(this.getPoint(r/e));return i},t.prototype.setPoints=function(e){this._points=e.map(function(i){return new y(i)}),this._boundingBoxNeedsUpdate=!0},t.prototype.setClosed=function(e){this._closed!==e&&(this._closed=e,this._boundingBoxNeedsUpdate=!0)},t.prototype.setCurveType=function(e){this._curveType=e},t.prototype.setTension=function(e){this._tension=e},t.prototype.clone=function(){return new t(this._points.map(function(e){return e.clone()}),this._closed,this._curveType,this._tension)},t.prototype.transform=function(e){return this._points=this._points.map(function(i){var r=new y;return r.copy(i),r.applyMatrix4(e),r}),this._boundingBoxNeedsUpdate=!0,this},t.prototype.calculateBoundingBox=function(){if(this._points.length===0)return new Y;var e=new Y;return this._points.forEach(function(i){e.expandByPoint(i)}),e},t})(Hi),ze=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},je=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))};function no(n,t){var e,i,r=n.x-t[0],s=n.y-t[1],a=((e=n.z)!==null&&e!==void 0?e:0)-((i=t[2])!==null&&i!==void 0?i:0);return r*r+s*s+a*a}var Ct=(function(){function n(t,e,i,r){this._degree=t,this._knots=je([],ze(e),!1),this._controlPoints=i.map(function(s){return{x:s.x,y:s.y,z:s.z}}),this._weights=r?je([],ze(r),!1):new Array(i.length).fill(1)}return n.prototype.degree=function(){return this._degree},n.prototype.knots=function(){return je([],ze(this._knots),!1)},n.prototype.controlPoints=function(){return this._controlPoints.map(function(t){return{x:t.x,y:t.y,z:t.z}})},n.prototype.weights=function(){return je([],ze(this._weights),!1)},n.prototype.clone=function(){return new n(this._degree,this._knots,this._controlPoints,this._weights)},n.prototype.point=function(t){return this.evaluate(t).point},n.prototype.evaluate=function(t){var e=this._controlPoints.map(function(i){return[i.x,i.y,i.z]});return id(t,this._degree,this._knots,e,this._weights)},n.prototype.signedPlanarCurvatureAt=function(t){var e=this.evaluate(t);return nd(e.deriv1,e.deriv2)},n.prototype.getOffsetSamplePath2d=function(t,e){var i=this;e===void 0&&(e=512);for(var r=Math.abs(t),s=this.getParameterRange(),a=s.start,o=s.end,c=this.length(),l=Math.max(64,Math.ceil(c/Math.max(r*.2,1e-6))),h=sg(a,o,Math.min(l,e)),u=0;u<8&&h.length<e;u++){for(var d=[],g=0;g<h.length-1;g++){var p=h[g],f=h[g+1],m=(p+f)/2,b=Math.max(Math.abs(this.signedPlanarCurvatureAt(p)),Math.abs(this.signedPlanarCurvatureAt(f)),Math.abs(this.signedPlanarCurvatureAt(m)));r*b>.85&&d.push(m)}if(d.length===0)break;if(h=ag(h,d),h.length>e){h=h.slice(0,e);break}}var _=[],v=[];return h.forEach(function(x){var S=i.evaluate(x);_.push(new L(S.point[0],S.point[1]));var P=S.deriv1[0],E=S.deriv1[1],O=Math.hypot(P,E);v.push(O>1e-10?new L(P/O,E/O):new L(1,0))}),{points:_,tangents:v}},n.prototype.length=function(){var t=this._controlPoints.map(function(e){return[e.x,e.y,e.z]});return bc(this._degree,this._knots,t,this._weights)},n.byKnotsControlPointsWeights=function(t,e,i,r){return new n(t,e,i,r)},n.byPoints=function(t,e,i,r,s){i===void 0&&(i="Uniform");var a=Vs(t,e,i,r,s),o=a.controlPoints.map(function(c){return{x:c[0],y:c[1],z:c[2]}});return new n(e,a.knots,o,a.weights)},n.prototype.getParameterRange=function(){var t=this._knots[this._degree],e=this._knots[this._knots.length-this._degree-1];return{start:t,end:e}},n.prototype.getPoints=function(t){for(var e=[],i=this.getParameterRange(),r=i.start,s=i.end,a=0;a<=t;a++){var o=r+(s-r)*(a/t);e.push(this.point(o))}return e},n.prototype.isClosed=function(t){t===void 0&&(t=1e-6);var e=this.getParameterRange(),i=e.start,r=e.end,s=this.point(i),a=this.point(r),o=s[0]-a[0],c=s[1]-a[1],l=s[2]-a[2];return Math.sqrt(o*o+c*c+l*l)<t},n.createFitPointsForClosedCurve=function(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");var e=new Mc(t,!0,"centripetal"),i=Math.max(50,t.length*2);return e.getPoints(i)},n.prototype.nearestPoint=function(t,e){var i;e===void 0&&(e=64);for(var r=this.getParameterRange(),s=r.start,a=r.end,o=this.point(s),c=no(t,o),l=0;l<=e;l++){var h=s+(a-s)*l/e,u=this.point(h),d=no(t,u);d<c&&(c=d,o=u)}return{x:o[0],y:o[1],z:(i=o[2])!==null&&i!==void 0?i:0}},n.createClosedCurve=function(t,e,i){i===void 0&&(i="Chord");var r=this.createFitPointsForClosedCurve(t),s=r.map(function(a){return[a.x,a.y,a.z]});return n.byPoints(s,e,i)},n})();function sg(n,t,e){if(e<2)return[n,t];for(var i=[],r=0;r<e;r++)i.push(r===e-1?t:n+(t-n)*r/(e-1));return i}function ag(n,t){var e=je(je([],ze(n),!1),ze(t),!1).sort(function(r,s){return r-s}),i=[];return e.forEach(function(r){var s=i[i.length-1];(s===void 0||Math.abs(s-r)>1e-10)&&i.push(r)}),i}function ro(n){var t,e,i;if(!n)return!1;var r=(t=n.x)!==null&&t!==void 0?t:0,s=(e=n.y)!==null&&e!==void 0?e:0,a=(i=n.z)!==null&&i!==void 0?i:0;return r*r+s*s+a*a>1e-20}function og(n,t,e){var i=n??0;return i<1&&e>0&&t>0&&(i=e-t-1),i<1&&(i=3),i=Math.min(i,t-1),Math.max(1,i)}function cg(n,t,e){var i=n??0;i<1&&(i=3);var r=t+e-1;return i=Math.min(i,r),Math.max(1,i)}function lg(n,t){if(!(!n||n.length!==t))return n}var hg=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),so=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},ao=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},oo=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},jt=(function(n){hg(t,n);function t(e,i,r,s,a,o){var c=n.call(this)||this,l=arguments.length;if(c._degree=3,c._closed=!1,Array.isArray(i)){if(l<2||l>5)throw Pt.ILLEGAL_PARAMETERS;c._controlPoints=e;var g=void 0,p=3,f=!1;if(l>=3&&(Array.isArray(r)?(g=r,l>=4&&(p=s||3),l>=5&&(f=a)):r!==void 0&&(p=r||3,l>=4&&(f=s))),r===void 0&&l>=4&&(p=s||3,l>=5&&(f=a)),c._degree=p,c._closed=f,c._controlPoints.length<c._degree+1)throw Pt.ILLEGAL_PARAMETERS;c._nurbsCurve=Ct.byKnotsControlPointsWeights(c._degree,i,c._controlPoints,g)}else{if(l<2||l>6)throw Pt.ILLEGAL_PARAMETERS;c._fitPoints=e,c._knotParameterization=i,l>=3&&(c._degree=r||3);var h=typeof s=="boolean";l>=4&&h&&(c._closed=s),h?(l>=5&&(c._startTangent=a),l>=6&&(c._endTangent=o)):(l>=4&&(c._startTangent=s),l>=5&&(c._endTangent=a)),c._closed&&(c._startTangent=void 0,c._endTangent=void 0);var u=(c._startTangent?1:0)+(c._endTangent?1:0);if(c._fitPoints.length+u<c._degree+1)throw Pt.ILLEGAL_PARAMETERS;if(c._closed)c._nurbsCurve=Ct.createClosedCurve(c._fitPoints,c._degree,c._knotParameterization);else{var d=c.toNurbsPoints(c._fitPoints);c._nurbsCurve=Ct.byPoints(d,c._degree,c._knotParameterization,c._startTangent?c.toNurbsPoint(c._startTangent):void 0,c._endTangent?c.toNurbsPoint(c._endTangent):void 0)}c._controlPoints=c.toGePoints(c._nurbsCurve.controlPoints().map(function(m){return[m.x,m.y,m.z||0]}))}return c}return t.prototype.buildCurve=function(){if(this._fitPoints&&this._knotParameterization){if(this._closed){var e=Ct.createFitPointsForClosedCurve(this._fitPoints),i=this.toNurbsPoints(e);this._nurbsCurve=Ct.byPoints(i,this._degree,this._knotParameterization)}else{var i=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Ct.byPoints(i,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(function(a){return[a.x,a.y,a.z||0]}))}else if(this._controlPoints)if(this._closed){var e=Ct.createFitPointsForClosedCurve(this._controlPoints),i=this.toNurbsPoints(e);this._nurbsCurve=Ct.byPoints(i,this._degree,this._knotParameterization),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(function(c){return[c.x,c.y,c.z||0]}))}else{var r=this._nurbsCurve.knots(),s=this._nurbsCurve.weights();this._nurbsCurve=Ct.byKnotsControlPointsWeights(this._degree,r,this._controlPoints,s)}},t.prototype.setClosed=function(e){this._closed!==e&&(this._closed=e,this._boundingBoxNeedsUpdate=!0,this.buildCurve())},Object.defineProperty(t.prototype,"degree",{get:function(){return this._degree},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"knotParameterization",{get:function(){return this._knotParameterization},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"controlPoints",{get:function(){return this._controlPoints.map(wt.point2dToPoint3d)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fitPoints",{get:function(){var e;return(e=this._fitPoints)===null||e===void 0?void 0:e.map(wt.point2dToPoint3d)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"knots",{get:function(){return ao([],so(this._nurbsCurve.knots()),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"weights",{get:function(){return ao([],so(this._nurbsCurve.weights()),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){var e=this._nurbsCurve.knots(),i=this._nurbsCurve.degree(),r=e[i],s=this._nurbsCurve.point(r);return new y(s[0],s[1],s[2])},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){var e=this._nurbsCurve.knots(),i=this._nurbsCurve.degree(),r=e[e.length-i-1],s=this._nurbsCurve.point(r);return new y(s[0],s[1],s[2])},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this._nurbsCurve.length()},enumerable:!1,configurable:!0}),t.prototype.nearestPoint=function(e,i){i===void 0&&(i=64);var r=this._nurbsCurve.nearestPoint(e,i);return new y(r.x,r.y,r.z||0)},t.prototype.evaluateAt=function(e){var i=this._nurbsCurve.point(e);return new y(i[0],i[1],i[2])},t.prototype.getFitPointAt=function(e){if(!this._fitPoints)throw new Error("No fit points in this spline");var i=this._fitPoints.length,r=e<0||e>=i?i-1:e,s=this._fitPoints[r];return wt.point2dToPoint3d(s)},t.prototype.getControlPointAt=function(e){var i=this._controlPoints.length,r=e<0||e>=i?i-1:e;return this._controlPoints[r]},Object.defineProperty(t.prototype,"isFitPointSpline",{get:function(){return!!(this._fitPoints&&this._fitPoints.length>0&&this._knotParameterization)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isControlPointSpline",{get:function(){return!this.isFitPointSpline},enumerable:!1,configurable:!0}),t.prototype.getGripPoints=function(){return this.isFitPointSpline?this._fitPoints.map(function(e){var i;return new y(e.x,e.y,(i=e.z)!==null&&i!==void 0?i:0)}):this._controlPoints.map(function(e){var i;return new y(e.x,e.y,(i=e.z)!==null&&i!==void 0?i:0)})},t.prototype.moveGripPointsAt=function(e,i){return this.isFitPointSpline?(this.moveFitPointsAt(e,i),this):(this.moveControlPointsAt(e,i),this)},t.prototype.moveFitPointsAt=function(e,i){var r,s;if(this._fitPoints){try{for(var a=oo(e),o=a.next();!o.done;o=a.next()){var c=o.value;if(!(!Number.isInteger(c)||c<0)){var l=this._fitPoints[c];l&&wt.applyOffsetToPoint3d(l,i)}}}catch(h){r={error:h}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(r)throw r.error}}this._boundingBoxNeedsUpdate=!0,this.buildCurve()}},t.prototype.moveControlPointsAt=function(e,i){var r,s;try{for(var a=oo(e),o=a.next();!o.done;o=a.next()){var c=o.value;if(!(!Number.isInteger(c)||c<0)){var l=this.getControlPointAt(c);l&&wt.applyOffsetToPoint3d(l,i)}}}catch(h){r={error:h}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(r)throw r.error}}this.rebuildAfterControlPointMutation()},t.prototype.rebuildAfterControlPointMutation=function(){var e=this._nurbsCurve.knots(),i=this._nurbsCurve.weights();this.isFitPointSpline&&(this._fitPoints=void 0,this._knotParameterization=void 0,this._startTangent=void 0,this._endTangent=void 0),this._nurbsCurve=Ct.byKnotsControlPointsWeights(this._degree,e,this._controlPoints,i.length>0?i:void 0),this._boundingBoxNeedsUpdate=!0},t.prototype.getOffsetSamplePath2d=function(e){return this._nurbsCurve.getOffsetSamplePath2d(e)},t.prototype.getPoints=function(e){e===void 0&&(e=100);for(var i=this._nurbsCurve,r=[],s=i.knots(),a=this._nurbsCurve.degree(),o=s[a],c=s[s.length-a-1],l=(c-o)/(e-1),h=0;h<e;h++){var u=h===e-1?c:o+h*l,d=i.point(u);r.push(new y(d[0],d[1],d[2]))}return r},t.prototype.getCurvePoints=function(e,i){for(var r=[],s=e.knots(),a=e.degree(),o=s[a],c=s[s.length-a-1],l=(c-o)/(i-1),h=0;h<i;h++){var u=o+h*l;r.push(e.point(u))}return r},t.prototype.calculateBoundingBox=function(){var e=this.getPoints(100);return new Y().setFromPoints(e)},Object.defineProperty(t.prototype,"closed",{get:function(){return this._closed},set:function(e){this.setClosed(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"area",{get:function(){if(!this._closed)return 0;var e=this.getPoints(128);return wc(e)},enumerable:!1,configurable:!0}),t.prototype.transform=function(e){if(this._fitPoints&&this._knotParameterization)this._fitPoints=this._fitPoints.map(function(s){return new y(s).applyMatrix4(e)}),this._startTangent&&(this._startTangent=new y(this._startTangent).transformDirection(e)),this._endTangent&&(this._endTangent=new y(this._endTangent).transformDirection(e)),this.buildCurve();else{var i=this._nurbsCurve.knots(),r=this._nurbsCurve.weights();this._controlPoints=this._controlPoints.map(function(s){return new y(s).applyMatrix4(e)}),this._nurbsCurve=Ct.byKnotsControlPointsWeights(this._degree,i,this._controlPoints,r.length>0?r:void 0)}return this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return this._fitPoints&&this._knotParameterization?new t(this._fitPoints.map(wt.point2dToPoint3d),this._knotParameterization,this._degree,this._closed,this._startTangent?wt.point2dToPoint3d(this._startTangent):void 0,this._endTangent?wt.point2dToPoint3d(this._endTangent):void 0):new t(this._controlPoints.map(wt.point2dToPoint3d),this._nurbsCurve.knots(),this._nurbsCurve.weights(),this._degree,this._closed)},t.prototype.toNurbsPoints=function(e){var i=new Array(e.length);return e.forEach(function(r,s){i[s]=[r.x,r.y,r.z||0]}),i},t.prototype.toGePoints=function(e){var i=new Array(e.length);return e.forEach(function(r,s){i[s]={x:r[0],y:r[1],z:r[2]}}),i},t.prototype.toNurbsPoint=function(e){return[e.x,e.y,e.z||0]},t.createClosedSpline=function(e,i,r){if(i===void 0&&(i="Uniform"),r===void 0&&(r=3),e.length<r+1)throw new Error("At least ".concat(r+1," points are required for a degree ").concat(r," closed spline"));return new t(e,i,r,!0)},t.fromControlPoints=function(e,i,r,s,a){if(e.length<2||i.length<2)return null;var o=og(s,e.length,i.length);if(e.length<o+1)return null;try{return new t(e,i,lg(r,e.length),o,a)}catch{return null}},t.fromFitPoints=function(e,i,r,s,a,o){if(e.length<2)return null;var c=ro(a),l=ro(o),h=(c?1:0)+(l?1:0),u=cg(r,e.length,h);if(e.length+h<u+1)return null;try{return c||l?new t(e,i,u,s,c?a:void 0,l?o:void 0):new t(e,i,u,s)}catch{return null}},t.fromDwgSplineEdge=function(e){if(e.numberOfControlPoints>0&&e.numberOfKnots>0){var i=e.controlPoints.map(wt.point2dToPoint3d),r=!0,s=e.controlPoints.map(function(o){return o.weight==null&&(r=!1),o.weight||1});return t.fromControlPoints(i,e.knots,r?s:void 0,e.degree,!1)}if(e.numberOfFitData>0){var a=e.fitDatum.map(wt.point2dToPoint3d);return t.fromFitPoints(a,"Uniform",e.degree,!1,e.startTangent?wt.point2dToPoint3d(e.startTangent):void 0,e.endTangent?wt.point2dToPoint3d(e.endTangent):void 0)}return null},t})(Hi),ug=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Fr=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},Dr=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},bi=(function(n){ug(t,n);function t(e){e===void 0&&(e=[]);var i=n.call(this)||this;return i._curves=e,i}return Object.defineProperty(t.prototype,"curves",{get:function(){return this._curves},enumerable:!1,configurable:!0}),t.buildFromEdges=function(e,i){if(i===void 0&&(i=.001),e.length===0)return[];for(var r=Dr([],Fr(e),!1),s=[],a=i*i,o=function(p,f){var m=p.x-f.x,b=p.y-f.y;return m*m+b*b<=a};r.length>0;){var c=[],l=r.shift();c.push(l);var h=t.getEdgeStartPoint(l),u=t.getEdgeEndPoint(l);if(!o(h,u))for(;r.length>0;){var d=t.findConnectingEdge(r,u,a);if(d.index<0)break;var g=r.splice(d.index,1)[0];if(d.reverse&&(g=t.reverseEdge(g)),c.push(g),u=t.getEdgeEndPoint(g),o(u,h))break}s.push(new t(c))}return s},t.prototype.add=function(e){this._curves.push(e),this._boundingBoxNeedsUpdate=!0},Object.defineProperty(t.prototype,"numberOfEdges",{get:function(){return this._curves.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){if(this._curves.length>0){var e=this._curves[0].startPoint;return new L(e.x,e.y)}throw new Error("Start point does not exist in an empty loop.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.startPoint},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){var e=0;return this._curves.forEach(function(i){e+=i.length}),e},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e=this.getPoints(100),i=new yt;return i.setFromPoints(e),i},t.prototype.transform=function(e){var i=new D().set(e.elements[0],e.elements[3],0,e.elements[6],e.elements[1],e.elements[4],0,e.elements[7],0,0,1,0,0,0,0,1);return this._curves.forEach(function(r){r instanceof jt?r.transform(i):r.transform(e)}),this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this._curves.map(function(e){return e.clone()}))},Object.defineProperty(t.prototype,"closed",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype.getPoints=function(e){var i=[];return this.curves.forEach(function(r){r.getPoints(e).forEach(function(s){i.push(new L(s.x,s.y))})}),i},t.findConnectingEdge=function(e,i,r){for(var s=-1,a=!1,o=Number.POSITIVE_INFINITY,c=0;c<e.length;c++){var l=e[c],h=t.getEdgeStartPoint(l),u=t.getEdgeEndPoint(l),d=i.x-h.x,g=i.y-h.y,p=d*d+g*g;p<o&&(o=p,s=c,a=!1);var f=i.x-u.x,m=i.y-u.y,b=f*f+m*m;b<o&&(o=b,s=c,a=!0)}return o>r?{index:-1,reverse:!1}:{index:s,reverse:a}},t.getEdgeStartPoint=function(e){var i=e.startPoint;return new L(i.x,i.y)},t.getEdgeEndPoint=function(e){var i=e.endPoint;return new L(i.x,i.y)},t.reverseEdge=function(e){return e instanceof zt?new zt(e.endPoint,e.startPoint):e instanceof vt?t.reverseCircArcEdge(e):e instanceof me?new me(e.center,e.majorAxisRadius,e.minorAxisRadius,e.endAngle,e.startAngle,!e.clockwise,e.rotation):e instanceof jt?t.reverseSplineEdge(e):e},t.reverseCircArcEdge=function(e){var i=e.startPoint,r=e.endPoint,s=!e.clockwise,a=Math.atan2(r.y-e.center.y,r.x-e.center.x),o=Math.atan2(i.y-e.center.y,i.x-e.center.x),c=function(l){var h=C.normalizeAngle(l);return s?C.normalizeAngle(-h):h};return new vt(e.center,e.radius,c(a),c(o),s)},t.reverseSplineEdge=function(e){var i=Dr([],Fr(e.controlPoints),!1).reverse(),r=e.knots,s=r[0],a=r[r.length-1],o=r.map(function(h){return s+a-h}).reverse(),c=e.weights,l=c.length>0?Dr([],Fr(c),!1).reverse():void 0;return new jt(i,o,l,e.degree,e.closed)},t})(oi);const co=[{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 pt{constructor(t){if(typeof t=="string"){const e=co.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=co.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")}get capabilities(){return pt.capabilitiesFor(this.value)}static get latest(){return new pt("AC1032")}static capabilitiesFor(t){const e=t>=19;return{supportsHandles:e,supportsSubclassMarkers:e,supportsClassesSection:e,supportsObjectsSection:e,supportsBlockRecordTable:e,supportsLwPolyline:e,supportsLineWeight:t>=23,supportsTrueColor:t>=25,supportsTransparency:t>=25,supportsUtf8CodePage:t>=27}}}function Wi(n){return n===999?"comment":n===5?"handle":n<=9||n===100||n===102?"string":n===105?"handle":n>=101&&n<=109?"string":n<=59?"double":n<=79?"int":n<=89?"string":n<=99?"int":n<=149?"double":n<=159?"string":n<=169?"long":n<=179?"int":n<=209?"string":n<=239?"double":n<=269?"long":n<=289?"int":n<=299?"bool":n<=309?"string":n<=319?"binary":n<=369?"handle":n<=389?"int":n<=399?"handle":n<=409?"int":n<=419?"string":n<=429?"int":n<=439?"string":n<=449||n<=459?"int":n<=469?"double":n<=479?"string":n===480||n===481?"handle":n===1004?"binary":n===1005?"handle":n>=1e3&&n<=1009?"string":n>=1010&&n<=1059?"double":n>=1060&&n<=1070||n===1071?"int":"string"}function Oc(n){return n>=90&&n<=99||n>=420&&n<=429||n>=440&&n<=449||n>=450&&n<=459||n===1071}var Us=(n=>(n[n.UTF8=0]="UTF8",n[n.US_ASCII=1]="US_ASCII",n[n.ISO_8859_1=2]="ISO_8859_1",n[n.ISO_8859_2=3]="ISO_8859_2",n[n.ISO_8859_3=4]="ISO_8859_3",n[n.ISO_8859_4=5]="ISO_8859_4",n[n.ISO_8859_5=6]="ISO_8859_5",n[n.ISO_8859_6=7]="ISO_8859_6",n[n.ISO_8859_7=8]="ISO_8859_7",n[n.ISO_8859_8=9]="ISO_8859_8",n[n.ISO_8859_9=10]="ISO_8859_9",n[n.CP437=11]="CP437",n[n.CP850=12]="CP850",n[n.CP852=13]="CP852",n[n.CP855=14]="CP855",n[n.CP857=15]="CP857",n[n.CP860=16]="CP860",n[n.CP861=17]="CP861",n[n.CP863=18]="CP863",n[n.CP864=19]="CP864",n[n.CP865=20]="CP865",n[n.CP869=21]="CP869",n[n.CP932=22]="CP932",n[n.MACINTOSH=23]="MACINTOSH",n[n.BIG5=24]="BIG5",n[n.CP949=25]="CP949",n[n.JOHAB=26]="JOHAB",n[n.CP866=27]="CP866",n[n.ANSI_1250=28]="ANSI_1250",n[n.ANSI_1251=29]="ANSI_1251",n[n.ANSI_1252=30]="ANSI_1252",n[n.GB2312=31]="GB2312",n[n.ANSI_1253=32]="ANSI_1253",n[n.ANSI_1254=33]="ANSI_1254",n[n.ANSI_1255=34]="ANSI_1255",n[n.ANSI_1256=35]="ANSI_1256",n[n.ANSI_1257=36]="ANSI_1257",n[n.ANSI_874=37]="ANSI_874",n[n.ANSI_932=38]="ANSI_932",n[n.ANSI_936=39]="ANSI_936",n[n.ANSI_949=40]="ANSI_949",n[n.ANSI_950=41]="ANSI_950",n[n.ANSI_1361=42]="ANSI_1361",n[n.UTF16=43]="UTF16",n[n.ANSI_1258=44]="ANSI_1258",n[n.UNDEFINED=255]="UNDEFINED",n))(Us||{});const dg=["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"],Nc=n=>dg[n],Yr=(()=>{const n=`AutoCAD Binary DXF\r
2
- `,t=new Uint8Array(22);for(let e=0;e<n.length;e++)t[e]=n.charCodeAt(e);return t[20]=26,t[21]=0,t})(),lo=(()=>{const n=new Int8Array(128);for(let t=0;t<10;t++)n[48+t]=t;for(let t=0;t<6;t++)n[65+t]=10+t,n[97+t]=10+t;return n})();function Rc(n){if(n.length<Yr.length)return!1;for(let t=0;t<Yr.length;t++)if(n[t]!==Yr[t])return!1;return!0}function Bc(n){var c,l,h;const e=new TextDecoder("utf-8");let i=0,r="",s=null,a=null,o=!1;for(;i<n.byteLength;){const u=Math.min(i+65536,n.byteLength),d=n.slice(i,u);i=u;const p=(r+e.decode(d,{stream:!0})).split(/\r?\n/);r=p.pop()??"";for(let f=0;f<p.length;f++){const m=p[f].trim();if(m==="SECTION"&&((c=p[f+2])==null?void 0:c.trim())==="HEADER")o=!0;else if(m==="ENDSEC"&&o)return{version:s,encoding:a};if(o&&m==="$ACADVER"){const b=(l=p[f+2])==null?void 0:l.trim();b&&(s=new pt(b))}else if(o&&m==="$DWGCODEPAGE"){const b=(h=p[f+2])==null?void 0:h.trim();if(b){const _=Us[b];a=Nc(_)}}if(s&&a)return{version:s,encoding:a}}}return{version:s,encoding:a}}function gg(n){const t=n.trim(),e=t.length>>>1,i=new Uint8Array(e);for(let r=0;r<e;r++){const s=lo[t.charCodeAt(r*2)&127],a=lo[t.charCodeAt(r*2+1)&127];i[r]=s<<4|a}return i}function Fc(n,t){const e=Wi(n);if(e==="comment")return null;switch(e){case"string":return{code:n,type:e,value:t};case"int":{const i=parseInt(t.trim(),10);return{code:n,type:e,value:Number.isFinite(i)?i:0}}case"long":{const i=t.trim(),r=Number(i);if(Number.isSafeInteger(r))return{code:n,type:e,value:r};try{return{code:n,type:e,value:BigInt(i)}}catch{return{code:n,type:e,value:0}}}case"double":{const i=Number(t.trim());return{code:n,type:e,value:Number.isFinite(i)?i:0}}case"bool":{const i=t.trim();return{code:n,type:e,value:i!=="0"&&i!==""}}case"handle":return{code:n,type:e,value:t.trim()};case"binary":return{code:n,type:e,value:gg(t)};default:return null}}function Hs(n){let t=0,e=1,i,r=!1;function s(){if(t>=n.length)return;let o=t;for(;o<n.length;){const l=n.charCodeAt(o);if(l===10||l===13)break;o++}const c=n.slice(t,o);return o<n.length&&n.charCodeAt(o)===13&&o++,o<n.length&&n.charCodeAt(o)===10&&o++,t=o,e++,c}function a(){for(;;){const o=s();if(o===void 0)return;const c=o.trim();if(c==="")continue;const l=s();if(l===void 0)return;const h=Number(c);if(!Number.isFinite(h)||h===999)continue;const u=Fc(h,l);if(u)return u}}return{kind:"ascii",next(){if(r){const o=i;return i=void 0,r=!1,o}return a()},peek(){return r||(i=a(),r=!0),i},position(){return{line:e,byteOffset:t}}}}function fg(n){const t=n.toLowerCase().replace(/_/g,"-");return t==="utf-8"||t==="utf8"||t==="unicode-1-1-utf-8"}function Dc(n){let t=0;n.length>=3&&n[0]===239&&n[1]===187&&n[2]===191&&(t=3);let e=1,i,r=!1;const s=new TextDecoder("utf-8");function a(){if(t>=n.length)return;let c=t;for(;c<n.length;){const h=n[c];if(h===10||h===13)break;c++}const l=s.decode(n.subarray(t,c));return c<n.length&&n[c]===13&&c++,c<n.length&&n[c]===10&&c++,t=c,e++,l}function o(){for(;;){const c=a();if(c===void 0)return;const l=c.trim();if(l==="")continue;const h=a();if(h===void 0)return;const u=Number(l);if(!Number.isFinite(u)||u===999)continue;const d=Fc(u,h);if(d)return d}}return{kind:"ascii",next(){if(r){const c=i;return i=void 0,r=!1,c}return o()},peek(){return r||(i=o(),r=!0),i},position(){return{line:e,byteOffset:t}}}}function pg(n){const t=BigInt(Number.MAX_SAFE_INTEGER),e=-t;return n>=e&&n<=t?Number(n):n}function Yc(n,t={}){const e=t.encoding??"utf-8",i=t.legacyR12??!1,r=22,s=new DataView(n.buffer,n.byteOffset,n.byteLength);let a=n.length>=r?r:n.length,o,c=!1;function l(){if(a>=n.length)return;if(i){const v=n[a];if(v===void 0)return;if(v===255){if(a+3>n.length)return;a+=1;const x=n[a],S=n[a+1];return a+=2,S<<8|x}return a+=1,v}if(a+2>n.length)return;const _=s.getUint16(a,!0);return a+=2,_}function h(){const _=a;for(;a<n.length&&n[a]!==0;)a+=1;if(a>=n.length)return;const v=n.subarray(_,a);return a+=1,new TextDecoder(e).decode(v)}function u(){if(a+2>n.length)return;const _=s.getInt16(a,!0);return a+=2,_}function d(){if(a+4>n.length)return;const _=s.getInt32(a,!0);return a+=4,_}function g(){if(a+8>n.length)return;const _=s.getBigInt64(a,!0);return a+=8,pg(_)}function p(){if(a+8>n.length)return;const _=s.getFloat64(a,!0);return a+=8,_}function f(){if(a>=n.length)return;const _=n[a];if(_!==void 0)return a+=1,_!==0}function m(){if(a>=n.length)return;const _=n[a];if(_===void 0||(a+=1,a+_>n.length))return;const v=n.slice(a,a+_);return a+=_,v}function b(){for(;a<n.length;){const _=l();if(_===void 0)return;if(_===999){if(h()===void 0)return;continue}switch(Wi(_)){case"string":{const x=h();return x===void 0?void 0:{code:_,type:"string",value:x}}case"int":{const x=Oc(_)?d():u();return x===void 0?void 0:{code:_,type:"int",value:x}}case"long":{const x=g();return x===void 0?void 0:{code:_,type:"long",value:x}}case"double":{const x=p();return x===void 0?void 0:{code:_,type:"double",value:x}}case"bool":{const x=f();return x===void 0?void 0:{code:_,type:"bool",value:x}}case"handle":{const x=h();return x===void 0?void 0:{code:_,type:"handle",value:x}}case"binary":{const x=m();return x===void 0?void 0:{code:_,type:"binary",value:x}}case"comment":continue;default:h();continue}}}return{kind:"binary",next(){if(c){const _=o;return o=void 0,c=!1,_}return b()},peek(){return c||(o=b(),c=!0),o},position(){return{byteOffset:a}}}}function Xc(n,t={}){const e=n instanceof Uint8Array?n:new Uint8Array(n);if(Rc(e)){let a=t.encoding,o=t.legacyR12;if((a==null||o==null)&&(a=a??"utf-8",o==null)){const l=e[22],h=e[23],u=e[24];l===0&&h===83?o=!0:o=!1}return Yc(e,{encoding:a,legacyR12:o})}const i=e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let r=t.encoding;if(r==null){const a=Bc(i);a.version&&!a.version.capabilities.supportsUtf8CodePage&&a.encoding?r=a.encoding:r="utf-8"}if(fg(r))return Dc(e);const s=new TextDecoder(r).decode(e);return Hs(s)}const fi=250,zc=255,jc=127;function Vc(n){const t=n??"";if(t.length<=fi)return[{code:1,value:t}];const e=[];let i=0;for(;t.length-i>fi;)e.push({code:3,value:t.slice(i,i+fi)}),i+=fi;return e.push({code:1,value:t.slice(i)}),e}function Gc(n,t){if(t<=0)return[n??""];const e=n??"";if(e.length===0)return[""];const i=new TextEncoder,r=[];let s="",a=0;for(const o of e){const c=i.encode(o).byteLength;if(c>t){s.length>0&&(r.push(s),s="",a=0),r.push(o);continue}a+c>t&&s.length>0?(r.push(s),s=o,a=c):(s+=o,a+=c)}return s.length>0&&r.push(s),r}function Uc(n,t){if(t<=0)return[n];if(n.byteLength===0)return[n];const e=[];for(let i=0;i<n.byteLength;i+=t)e.push(n.subarray(i,i+t));return e}var Hc=(n=>(n[n.Ok=0]="Ok",n[n.EndOfFile=1]="EndOfFile",n[n.EndOfObject=2]="EndOfObject",n[n.InvalidDxfCode=3]="InvalidDxfCode",n[n.BadDxfSequence=4]="BadDxfSequence",n[n.NotThatKindOfClass=5]="NotThatKindOfClass",n[n.WrongMode=6]="WrongMode",n))(Hc||{});const mg=(()=>{const n=`AutoCAD Binary DXF\r
3
- `,t=new Uint8Array(22);for(let e=0;e<n.length;e++)t[e]=n.charCodeAt(e);return t[20]=26,t[21]=0,t})();class xe{constructor(t={}){this._binaryLength=0,this._pushed=[],this._status=0,this._errorMessage="",this._database=t.database,this._precision=Math.max(0,Math.min(16,t.precision??16)),this._version=t.version instanceof pt?t.version:t.version!=null?new pt(t.version):void 0,this._outputFormat=t.outputFormat??"ascii",this._lines=[],this._binaryChunks=[],this._handleMap=new Map,this._nextHandle=1,this._mode=t.reader?"read":"write",this._reader=t.reader,this._mode==="write"&&this._outputFormat==="binary"&&this.appendBinary(mg)}static forReading(t,e={}){return new xe({...e,reader:t})}static fromBuffer(t,e={}){return xe.forReading(Xc(t),e)}static fromString(t,e={}){return xe.forReading(Hs(t),e)}get mode(){return this._mode}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}get filerStatus(){return this._status}get errorMessage(){return this._errorMessage}setVersion(t){return this._version=t instanceof pt?t:new pt(t),this}setError(t,e=""){return this._status=t,this._errorMessage=e,this}resetStatus(){return this._status=0,this._errorMessage="",this}toString(){if(this.assertWriteMode(),this._outputFormat==="binary")throw new Error("Use toBinary() for binary DXF output");return this._lines.join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Xs=(n=>(n[n.Invalid=-9999]="Invalid",n[n.Start=0]="Start",n[n.Text=1]="Text",n[n.AttributeTag=2]="AttributeTag",n[n.BlockName=2]="BlockName",n[n.ShapeName=2]="ShapeName",n[n.SymbolTableName=2]="SymbolTableName",n[n.SymbolTableRecordName=2]="SymbolTableRecordName",n[n.MlineStyleName=2]="MlineStyleName",n[n.AttributePrompt=3]="AttributePrompt",n[n.Description=3]="Description",n[n.DimPostString=3]="DimPostString",n[n.DimStyleName=3]="DimStyleName",n[n.LinetypeProse=3]="LinetypeProse",n[n.TextFontFile=3]="TextFontFile",n[n.CLShapeName=4]="CLShapeName",n[n.DimensionAlternativePrefixSuffix=4]="DimensionAlternativePrefixSuffix",n[n.SymbolTableRecordComments=4]="SymbolTableRecordComments",n[n.TextBigFontFile=4]="TextBigFontFile",n[n.Handle=5]="Handle",n[n.DimensionBlock=5]="DimensionBlock",n[n.LinetypeName=6]="LinetypeName",n[n.DimBlk1=6]="DimBlk1",n[n.TextStyleName=7]="TextStyleName",n[n.DimBlk2=7]="DimBlk2",n[n.LayerName=8]="LayerName",n[n.CLShapeText=9]="CLShapeText",n[n.XCoordinate=10]="XCoordinate",n[n.YCoordinate=20]="YCoordinate",n[n.ZCoordinate=30]="ZCoordinate",n[n.Real=40]="Real",n[n.TxtSize=40]="TxtSize",n[n.ViewportHeight=40]="ViewportHeight",n[n.Angle=50]="Angle",n[n.ViewportSnapAngle=50]="ViewportSnapAngle",n[n.Visibility=60]="Visibility",n[n.Int16=70]="Int16",n[n.Int32=90]="Int32",n[n.Int64=160]="Int64",n[n.Int8=280]="Int8",n[n.Thickness=39]="Thickness",n[n.Elevation=38]="Elevation",n[n.LinetypeScale=48]="LinetypeScale",n[n.DashLength=49]="DashLength",n[n.MlineOffset=49]="MlineOffset",n[n.LinetypeElement=49]="LinetypeElement",n[n.NormalX=210]="NormalX",n[n.NormalY=220]="NormalY",n[n.NormalZ=230]="NormalZ",n[n.UcsOrg=110]="UcsOrg",n[n.UcsOrientationX=111]="UcsOrientationX",n[n.UcsOrientationY=112]="UcsOrientationY",n[n.ViewHeight=45]="ViewHeight",n[n.ViewWidth=41]="ViewWidth",n[n.ViewLensLength=42]="ViewLensLength",n[n.ViewFrontClip=43]="ViewFrontClip",n[n.ViewBackClip=44]="ViewBackClip",n[n.ViewBrightness=141]="ViewBrightness",n[n.ViewContrast=142]="ViewContrast",n[n.ViewMode=71]="ViewMode",n[n.ViewportActive=68]="ViewportActive",n[n.ViewportAspect=41]="ViewportAspect",n[n.ViewportGrid=76]="ViewportGrid",n[n.ViewportIcon=74]="ViewportIcon",n[n.ViewportNumber=69]="ViewportNumber",n[n.ViewportSnap=75]="ViewportSnap",n[n.ViewportSnapPair=78]="ViewportSnapPair",n[n.ViewportSnapStyle=77]="ViewportSnapStyle",n[n.ViewportTwist=51]="ViewportTwist",n[n.ViewportVisibility=67]="ViewportVisibility",n[n.ViewportZoom=73]="ViewportZoom",n[n.Color=62]="Color",n[n.ColorRgb=420]="ColorRgb",n[n.ColorName=430]="ColorName",n[n.LineWeight=370]="LineWeight",n[n.PlotStyleNameType=380]="PlotStyleNameType",n[n.PlotStyleNameId=390]="PlotStyleNameId",n[n.GradientObjType=450]="GradientObjType",n[n.GradientAngle=460]="GradientAngle",n[n.GradientName=470]="GradientName",n[n.GradientColCount=453]="GradientColCount",n[n.GradientPatType=451]="GradientPatType",n[n.GradientTintType=452]="GradientTintType",n[n.GradientShift=461]="GradientShift",n[n.GradientColVal=463]="GradientColVal",n[n.GradientTintVal=462]="GradientTintVal",n[n.SoftPointerId=330]="SoftPointerId",n[n.HardPointerId=340]="HardPointerId",n[n.SoftOwnershipId=350]="SoftOwnershipId",n[n.HardOwnershipId=360]="HardOwnershipId",n[n.ArbitraryHandle=320]="ArbitraryHandle",n[n.ExtendedDataAsciiString=1e3]="ExtendedDataAsciiString",n[n.ExtendedDataRegAppName=1001]="ExtendedDataRegAppName",n[n.ExtendedDataControlString=1002]="ExtendedDataControlString",n[n.ExtendedDataLayerName=1003]="ExtendedDataLayerName",n[n.ExtendedDataBinaryChunk=1004]="ExtendedDataBinaryChunk",n[n.ExtendedDataHandle=1005]="ExtendedDataHandle",n[n.ExtendedDataXCoordinate=1010]="ExtendedDataXCoordinate",n[n.ExtendedDataWorldXCoordinate=1011]="ExtendedDataWorldXCoordinate",n[n.ExtendedDataWorldXDisp=1012]="ExtendedDataWorldXDisp",n[n.ExtendedDataWorldXDir=1013]="ExtendedDataWorldXDir",n[n.ExtendedDataYCoordinate=1020]="ExtendedDataYCoordinate",n[n.ExtendedDataWorldYCoordinate=1021]="ExtendedDataWorldYCoordinate",n[n.ExtendedDataWorldYDisp=1022]="ExtendedDataWorldYDisp",n[n.ExtendedDataWorldYDir=1023]="ExtendedDataWorldYDir",n[n.ExtendedDataZCoordinate=1030]="ExtendedDataZCoordinate",n[n.ExtendedDataWorldZCoordinate=1031]="ExtendedDataWorldZCoordinate",n[n.ExtendedDataWorldZDisp=1032]="ExtendedDataWorldZDisp",n[n.ExtendedDataWorldZDir=1033]="ExtendedDataWorldZDir",n[n.ExtendedDataReal=1040]="ExtendedDataReal",n[n.ExtendedDataDist=1041]="ExtendedDataDist",n[n.ExtendedDataScale=1042]="ExtendedDataScale",n[n.ExtendedDataInteger16=1070]="ExtendedDataInteger16",n[n.ExtendedDataInteger32=1071]="ExtendedDataInteger32",n[n.XTextString=300]="XTextString",n[n.XReal=140]="XReal",n[n.XInt16=170]="XInt16",n[n.XXInt16=270]="XXInt16",n[n.Subclass=100]="Subclass",n[n.ControlString=102]="ControlString",n[n.EmbeddedObjectStart=101]="EmbeddedObjectStart",n[n.End=-1]="End",n[n.FirstEntityId=-2]="FirstEntityId",n[n.HeaderId=-2]="HeaderId",n[n.XDataStart=-3]="XDataStart",n[n.Operator=-4]="Operator",n[n.PReactors=-5]="PReactors",n[n.XDictionary=-6]="XDictionary",n))(Xs||{});exports.AcCmColorMethod=void 0;(function(n){n[n.ByColor=1]="ByColor",n[n.ByACI=2]="ByACI",n[n.ByLayer=3]="ByLayer",n[n.ByBlock=4]="ByBlock",n[n.None=0]="None"})(exports.AcCmColorMethod||(exports.AcCmColorMethod={}));var Su=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Pu=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},Za={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},Rr=[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],$t=(function(){function n(){}return n.getColorByIndex=function(t){return Rr[t]},n.getIndexByColor=function(t){for(var e=Rr.length-1,i=1;i<e;++i)if(Rr[i]===t)return i},n.getColorByName=function(t){return Za[t.toLowerCase()]},n.getNameByColor=function(t){var e,i;try{for(var r=Su(Object.entries(Za)),s=r.next();!s.done;s=r.next()){var a=Pu(s.value,2),o=a[0],c=a[1];if(c===t)return o}}catch(l){e={error:l}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}},n.getNameByIndex=function(t){var e=this.getColorByIndex(t);return this.getNameByColor(e)},n})(),Iu=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},X=(function(){function n(t,e){t===void 0&&(t=exports.AcCmColorMethod.ByLayer),this._colorMethod=t,this._colorMethod==exports.AcCmColorMethod.ByColor&&e==null?this._value=16777215:this._colorMethod==exports.AcCmColorMethod.ByACI?e==null?this._value=8:e===0?this._colorMethod=exports.AcCmColorMethod.ByBlock:e===256?this._colorMethod=exports.AcCmColorMethod.ByLayer:this._value=Math.max(0,Math.min(e,256)):this._value=e}return Object.defineProperty(n.prototype,"colorMethod",{get:function(){return this._colorMethod},set:function(t){this._colorMethod=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"red",{get:function(){var t=this.RGB;return t!=null?t>>16&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"green",{get:function(){var t=this.RGB;return t!=null?t>>8&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"blue",{get:function(){var t=this.RGB;return t!=null?t&255:void 0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"RGB",{get:function(){switch(this._colorMethod){case exports.AcCmColorMethod.ByColor:case exports.AcCmColorMethod.ByBlock:case exports.AcCmColorMethod.ByLayer:return this._value;case exports.AcCmColorMethod.ByACI:return this._value?$t.getColorByIndex(this._value):this._value;default:return}},enumerable:!1,configurable:!0}),n.prototype.setRGB=function(t,e,i){var r=Math.max(0,Math.min(255,Math.round(t))),s=Math.max(0,Math.min(255,Math.round(e))),a=Math.max(0,Math.min(255,Math.round(i)));return this._value=r<<16|s<<8|a,this._colorMethod=exports.AcCmColorMethod.ByColor,this},n.prototype.setRGBValue=function(t){return t==null||!Number.isFinite(t)?this:(this._value=t&16777215,this._colorMethod=exports.AcCmColorMethod.ByColor,this)},n.prototype.setRGBFromCss=function(t){if(!t)return this;var e=t.trim().toLowerCase();if(e.startsWith("#")){var i=0,r=0,s=0;if(e.length===7)i=parseInt(e.substr(1,2),16),r=parseInt(e.substr(3,2),16),s=parseInt(e.substr(5,2),16);else if(e.length===4)i=parseInt(e[1]+e[1],16),r=parseInt(e[2]+e[2],16),s=parseInt(e[3]+e[3],16);else return this;return this.setRGB(i,r,s)}var a=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(a){var i=parseInt(a[1],10),r=parseInt(a[2],10),s=parseInt(a[3],10);return this.setRGB(i,r,s)}var o=$t.getColorByName(t);return o!==void 0?this.setRGBValue(o):this},n.prototype.setScalar=function(t){return this.setRGB(t,t,t)},Object.defineProperty(n.prototype,"hexColor",{get:function(){var t=this.RGB;if(t!=null){var e=t.toString(16).padStart(6,"0").toUpperCase();return"0x"+e}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"cssColor",{get:function(){var t=this.RGB;if(t!=null)return"rgb(".concat(t>>16&255,",").concat(t>>8&255,",").concat(t&255,")")},enumerable:!1,configurable:!0}),n.prototype.cssColorAlpha=function(t){var e=this.RGB;if(e!=null)return"rgba(".concat(e>>16&255,",").concat(e>>8&255,",").concat(e&255,",").concat(t,")")},Object.defineProperty(n.prototype,"colorIndex",{get:function(){return this._colorMethod===exports.AcCmColorMethod.ByACI?this._value:this._colorMethod===exports.AcCmColorMethod.ByLayer?256:this._colorMethod===exports.AcCmColorMethod.ByBlock?0:void 0},set:function(t){if(t!=null){var e=Math.max(0,Math.min(256,Math.round(t)));e===0?(this._colorMethod=exports.AcCmColorMethod.ByBlock,this._value=void 0):e===256?(this._colorMethod=exports.AcCmColorMethod.ByLayer,this._value=void 0):(this._colorMethod=exports.AcCmColorMethod.ByACI,this._value=e)}},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByColor",{get:function(){return this._colorMethod===exports.AcCmColorMethod.ByColor},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByACI",{get:function(){return this._colorMethod===exports.AcCmColorMethod.ByACI},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isForeground",{get:function(){return this._colorMethod===exports.AcCmColorMethod.ByACI&&this._value===7},enumerable:!1,configurable:!0}),n.prototype.setForeground=function(){return this._colorMethod=exports.AcCmColorMethod.ByACI,this._value=7,this},Object.defineProperty(n.prototype,"isByLayer",{get:function(){return this._colorMethod===exports.AcCmColorMethod.ByLayer},enumerable:!1,configurable:!0}),n.prototype.setByLayer=function(t){return this._colorMethod=exports.AcCmColorMethod.ByLayer,t==null?this._value=256:this._value=t,this},Object.defineProperty(n.prototype,"isByBlock",{get:function(){return this._colorMethod===exports.AcCmColorMethod.ByBlock},enumerable:!1,configurable:!0}),n.prototype.setByBlock=function(t){return this._colorMethod=exports.AcCmColorMethod.ByBlock,t==null?this._value=0:this._value=t,this},Object.defineProperty(n.prototype,"colorName",{get:function(){switch(this._colorMethod){case exports.AcCmColorMethod.ByLayer:return"ByLayer";case exports.AcCmColorMethod.ByBlock:return"ByBlock";case exports.AcCmColorMethod.ByColor:return this._value?$t.getNameByColor(this._value):"";case exports.AcCmColorMethod.ByACI:return this._value?$t.getNameByIndex(this._value):"";default:return}},set:function(t){if(t){var e=$t.getColorByName(t);e!==void 0&&(this._value=e,this._colorMethod=exports.AcCmColorMethod.ByColor)}},enumerable:!1,configurable:!0}),n.prototype.clone=function(){var t=new n;return t._colorMethod=this._colorMethod,t._value=this._value,t},n.prototype.copy=function(t){return this._colorMethod=t._colorMethod,this._value=t._value,this},n.prototype.equals=function(t){return this._colorMethod===t._colorMethod&&this._value===t._value},n.prototype.toString=function(){switch(this._colorMethod){case exports.AcCmColorMethod.None:return"None";case exports.AcCmColorMethod.ByLayer:return"ByLayer";case exports.AcCmColorMethod.ByBlock:return"ByBlock";case exports.AcCmColorMethod.ByACI:return this._value!==void 0?String(this._value):"";case exports.AcCmColorMethod.ByColor:return this._value?"RGB:".concat(this.red,",").concat(this.green,",").concat(this.blue):"";default:return""}},n.fromString=function(t){if(t){var e=t.trim();if(/^none$/i.test(e))return new n(exports.AcCmColorMethod.None);if(/^bylayer$/i.test(e))return new n(exports.AcCmColorMethod.ByLayer);if(/^byblock$/i.test(e))return new n(exports.AcCmColorMethod.ByBlock);var i=e.match(/^rgb\s*:\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})$/i);if(i){var r=Number(i[1]),s=Number(i[2]),a=Number(i[3]),o=new n(exports.AcCmColorMethod.ByColor);return o.setRGB(r,s,a),o}if(/^\d{1,3},\d{1,3},\d{1,3}$/.test(e)){var c=Iu(e.split(",").map(Number),3),r=c[0],s=c[1],a=c[2],o=new n(exports.AcCmColorMethod.ByColor);return o.setRGB(r,s,a),o}if(/^\d+$/.test(e)){var l=parseInt(e,10);return new n(exports.AcCmColorMethod.ByACI,l)}if(/^book\$/i.test(e)){var h=e.substring(e.indexOf("$")+1),u=$t.getColorByName(h);return u!=null?new n(exports.AcCmColorMethod.ByColor,u):void 0}var d=$t.getColorByName(e);if(d!=null)return new n(exports.AcCmColorMethod.ByColor,d)}},n})(),Eu=(function(){function n(t,e){t===void 0&&(t=exports.AcCmColorMethod.ByColor),e===void 0&&(e=0),this._colorMethod=t,this._value=e}return Object.defineProperty(n.prototype,"colorMethd",{get:function(){return this._colorMethod},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"red",{get:function(){return this._value>>16&255},set:function(t){this._colorMethod=exports.AcCmColorMethod.ByColor,this._value=this._value&65535|(t&255)<<16},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"green",{get:function(){return this._value>>8&255},set:function(t){this._colorMethod=exports.AcCmColorMethod.ByColor,this._value=this._value&16711935|(t&255)<<8},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"blue",{get:function(){return this._value&255},set:function(t){this._colorMethod=exports.AcCmColorMethod.ByColor,this._value=this._value&16776960|t&255},enumerable:!1,configurable:!0}),n.prototype.setRGB=function(t,e,i){this._colorMethod=exports.AcCmColorMethod.ByColor,this._value=(t&255)<<16|(e&255)<<8|i&255},Object.defineProperty(n.prototype,"colorIndex",{get:function(){return this._value},set:function(t){this._colorMethod=exports.AcCmColorMethod.ByACI,this._value=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"layerIndex",{get:function(){return this._value},set:function(t){this._colorMethod=exports.AcCmColorMethod.ByLayer,this._value=t},enumerable:!1,configurable:!0}),n.prototype.isByColor=function(){return this._colorMethod===exports.AcCmColorMethod.ByColor},n.prototype.isByLayer=function(){return this._colorMethod===exports.AcCmColorMethod.ByLayer},n.prototype.isByBlock=function(){return this._colorMethod===exports.AcCmColorMethod.ByBlock},n.prototype.isByACI=function(){return this._colorMethod===exports.AcCmColorMethod.ByACI},n.prototype.isNone=function(){return this._colorMethod===exports.AcCmColorMethod.None},Object.defineProperty(n.prototype,"rawValue",{get:function(){return this._value},set:function(t){this._value=t},enumerable:!1,configurable:!0}),n})(),Pt={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")}},Lu=(function(){function n(){this._listeners={}}return n.prototype.addEventListener=function(t,e){this._listeners===void 0&&(this._listeners={});var i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)},n.prototype.hasEventListener=function(t,e){if(this._listeners===void 0)return!1;var i=this._listeners;return i[t]!==void 0&&i[t].indexOf(e)!==-1},n.prototype.removeEventListener=function(t,e){if(this._listeners!==void 0){var i=this._listeners,r=i[t];if(r!==void 0){var s=r.indexOf(e);s!==-1&&r.splice(s,1)}}},n.prototype.dispatchEvent=function(t){if(this._listeners!==void 0){var e=this._listeners,i=e[t.type];if(i!==void 0){t.target=this;for(var r=i.slice(0),s=0,a=r.length;s<a;s++)r[s].call(this,t)}}},n})(),Tu=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Cu=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},Mu=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},at=(function(){function n(){this.listeners=[]}return n.prototype.addEventListener=function(t){this.listeners.push(t)},n.prototype.removeEventListener=function(t){this.listeners=this.listeners.filter(function(e){return e!==t})},n.prototype.replaceEventListener=function(t){this.removeEventListener(t),this.addEventListener(t)},n.prototype.dispatch=function(t){for(var e,i,r=[],s=1;s<arguments.length;s++)r[s-1]=arguments[s];try{for(var a=Tu(this.listeners),o=a.next();!o.done;o=a.next()){var c=o.value,l=c;l.call.apply(l,Mu([null,t],Cu(r),!1))}}catch(h){e={error:h}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(e)throw e.error}}},n})(),ls=function(){return ls=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},ls.apply(this,arguments)},Ou=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},Nu=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},Qo=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};function pi(n){return n===null||typeof n!="object"?n:Array.isArray(n)?Nu([],Ou(n),!1):ls({},n)}function hs(n){if(n===null||typeof n!="object")return n;if(n instanceof Date)return new Date(n.getTime());if(n instanceof RegExp)return new RegExp(n.source,n.flags);if(Array.isArray(n))return n.map(hs);var t={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=hs(n[e]));return t}function Bt(n){for(var t,e,i=[],r=1;r<arguments.length;r++)i[r-1]=arguments[r];try{for(var s=Qo(i),a=s.next();!a.done;a=s.next()){var o=a.value;if(o)for(var c in o)Object.prototype.hasOwnProperty.call(o,c)&&n[c]===void 0&&(n[c]=o[c])}}catch(l){t={error:l}}finally{try{a&&!a.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return n}function Jo(n,t){return n!=null&&Object.prototype.hasOwnProperty.call(n,t)}function tc(n){return n==null?!0:Array.isArray(n)||typeof n=="string"?n.length===0:n instanceof Map||n instanceof Set?n.size===0:typeof n=="object"?Object.keys(n).length===0:!1}function Ne(n,t){var e,i;if(n===t)return!0;if(n==null||t==null)return n===t;if(typeof n!=typeof t)return!1;if(typeof n!="object")return n===t;if(Array.isArray(n)!==Array.isArray(t))return!1;if(Array.isArray(n)){if(n.length!==t.length)return!1;for(var r=0;r<n.length;r++)if(!Ne(n[r],t[r]))return!1;return!0}var s=Object.keys(n),a=Object.keys(t);if(s.length!==a.length)return!1;try{for(var o=Qo(s),c=o.next();!c.done;c=o.next()){var l=c.value;if(!Object.prototype.hasOwnProperty.call(t,l)||!Ne(n[l],t[l]))return!1}}catch(h){e={error:h}}finally{try{c&&!c.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}return!0}function Ru(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var An={exports:{}},Bu=An.exports,Qa;function Fu(){return Qa||(Qa=1,(function(n){(function(t,e){n.exports?n.exports=e():t.log=e()})(Bu,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"],s={},a=null;function o(f,m){var y=f[m];if(typeof y.bind=="function")return y.bind(f);try{return Function.prototype.bind.call(y,f)}catch{return function(){return Function.prototype.apply.apply(y,[f,arguments])}}}function c(){console.log&&(console.log.apply||Function.prototype.apply.apply(console.log,[console,arguments]))}function l(f){return f==="debug"&&(f="log"),typeof console===e?!1:f==="trace"&&i?c:console[f]!==void 0?o(console,f):console.log!==void 0?o(console,"log"):t}function h(){for(var f=this.getLevel(),m=0;m<r.length;m++){var y=r[m];this[y]=m<f?t:this.methodFactory(y,f,this.name)}if(this.log=this.debug,typeof console===e&&f<this.levels.SILENT)return"No console available for logging"}function u(f){return function(){typeof console!==e&&(h.call(this),this[f].apply(this,arguments))}}function d(f,m,y){return l(f)||u.apply(this,arguments)}function g(f,m){var y=this,_,v,x,k="loglevel";typeof f=="string"?k+=":"+f:typeof f=="symbol"&&(k=void 0);function I(N){var O=(r[N]||"silent").toUpperCase();if(!(typeof window===e||!k)){try{window.localStorage[k]=O;return}catch{}try{window.document.cookie=encodeURIComponent(k)+"="+O+";"}catch{}}}function P(){var N;if(!(typeof window===e||!k)){try{N=window.localStorage[k]}catch{}if(typeof N===e)try{var O=window.document.cookie,S=encodeURIComponent(k),G=O.indexOf(S+"=");G!==-1&&(N=/^([^;]+)/.exec(O.slice(G+S.length+1))[1])}catch{}return y.levels[N]===void 0&&(N=void 0),N}}function C(){if(!(typeof window===e||!k)){try{window.localStorage.removeItem(k)}catch{}try{window.document.cookie=encodeURIComponent(k)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function T(N){var O=N;if(typeof O=="string"&&y.levels[O.toUpperCase()]!==void 0&&(O=y.levels[O.toUpperCase()]),typeof O=="number"&&O>=0&&O<=y.levels.SILENT)return O;throw new TypeError("log.setLevel() called with invalid level: "+N)}y.name=f,y.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},y.methodFactory=m||d,y.getLevel=function(){return x??v??_},y.setLevel=function(N,O){return x=T(N),O!==!1&&I(x),h.call(y)},y.setDefaultLevel=function(N){v=T(N),P()||y.setLevel(N,!1)},y.resetLevel=function(){x=null,C(),h.call(y)},y.enableAll=function(N){y.setLevel(y.levels.TRACE,N)},y.disableAll=function(N){y.setLevel(y.levels.SILENT,N)},y.rebuild=function(){if(a!==y&&(_=T(a.getLevel())),h.call(y),a===y)for(var N in s)s[N].rebuild()},_=T(a?a.getLevel():"WARN");var R=P();R!=null&&(x=T(R)),h.call(y)}a=new g,a.getLogger=function(m){if(typeof m!="symbol"&&typeof m!="string"||m==="")throw new TypeError("You must supply a name when creating a logger.");var y=s[m];return y||(y=s[m]=new g(m,a.methodFactory)),y};var p=typeof window!==e?window.log:void 0;return a.noConflict=function(){return typeof window!==e&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return s},a.default=a,a})})(An)),An.exports}var Du=Fu();const Yu=Ru(Du);var Xu=!0,yi=Yu;yi.setLevel("debug");var zu=function(n){try{yi.setLevel(n)}catch(t){yi.setLevel("error"),yi.error(t)}},us=(function(){function n(t,e){this.events={attrChanged:new at,modelChanged:new at},this._changing=!1,this._previousAttributes={},this._pending=!1;var i=t||{};e&&Bt(i,e),this.attributes=i,this.changed={}}return n.prototype.get=function(t){return this.attributes[t]},n.prototype.set=function(t,e,i){if(t==null)return this;var r;typeof t=="object"?(r=t,i=e):(r={},r[t]=e),i||(i={});var s=i.unset,a=i.silent,o=[],c=this._changing;this._changing=!0,c||(this._previousAttributes=pi(this.attributes),this.changed={});var l=this.attributes,h=this.changed,u=this._previousAttributes;for(var d in r)e=r[d],Ne(l[d],e)||o.push(d),Ne(u[d],e)?delete h[d]:h[d]=e,s?delete l[d]:l[d]=e;if(!a){o.length&&(this._pending=i);for(var g=0;g<o.length;g++)this.events.attrChanged.dispatch({object:this,attrName:o[g],attrValue:l[o[g]],options:i})}if(c)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},n.prototype.has=function(t){return this.get(t)!=null},n.prototype.hasChanged=function(t){return t==null?!tc(this.changed):Jo(this.changed,t)},n.prototype.changedAttributes=function(t){if(!t)return this.hasChanged()?pi(this.changed):{};var e=this._changing?this._previousAttributes:this.attributes,i={};for(var r in t){var s=t[r];Ne(e[r],s)||(i[r]=s)}return i},n.prototype.previous=function(t){return t==null||!this._previousAttributes?null:this._previousAttributes[t]},n.prototype.previousAttributes=function(){return pi(this._previousAttributes)},n.prototype.clone=function(){var t=pi(this.attributes);return new n(t)},n})(),ju=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Vu=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},zs=(function(){function n(){this.entries=new Map}return n.getInstance=function(){return n.instance||(n.instance=new n),n.instance},n.prototype.collect=function(t){this.entries.set(t.name,t)},n.prototype.printAll=function(){var t,e;try{for(var i=ju(this.entries),r=i.next();!r.done;r=i.next())var s=Vu(r.value,2),a=s[0],o=s[1]}catch(c){t={error:c}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}},n.prototype.clear=function(){this.entries.clear()},n.prototype.getAll=function(){return Array.from(this.entries.values())},n.prototype.getEntry=function(t){return this.entries.get(t)},n.prototype.remove=function(t){return this.entries.delete(t)},n})(),Gu=(function(){function n(){}return n.formatBytes=function(t,e){if(e===void 0&&(e=2),t===0)return"0 B";var i=1024,r=Math.max(0,e),s=["B","KB","MB","GB","TB"],a=Math.floor(Math.log(t)/Math.log(i)),o=t/Math.pow(i,a);return"".concat(parseFloat(o.toFixed(r))," ").concat(s[a])},n})();exports.AcCmTransparencyMethod=void 0;(function(n){n[n.ByLayer=0]="ByLayer",n[n.ByBlock=1]="ByBlock",n[n.ByAlpha=2]="ByAlpha",n[n.ErrorValue=3]="ErrorValue"})(exports.AcCmTransparencyMethod||(exports.AcCmTransparencyMethod={}));var ot=(function(){function n(t){t!==void 0?(this._method=exports.AcCmTransparencyMethod.ByAlpha,this._alpha=n.clampAlpha(t)):(this._method=exports.AcCmTransparencyMethod.ByLayer,this._alpha=255)}return Object.defineProperty(n.prototype,"method",{get:function(){return this._method},set:function(t){this._method=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha=n.clampAlpha(t),this._method=exports.AcCmTransparencyMethod.ByAlpha},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"percentage",{get:function(){if(this._method===exports.AcCmTransparencyMethod.ByAlpha)return Math.round((1-this._alpha/255)*100)},set:function(t){var e=Math.max(0,Math.min(100,t)),i=Math.round(255*(1-e/100));this.alpha=i},enumerable:!1,configurable:!0}),n.clampAlpha=function(t){return Math.max(0,Math.min(255,Math.floor(t)))},Object.defineProperty(n.prototype,"isByAlpha",{get:function(){return this._method===exports.AcCmTransparencyMethod.ByAlpha},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByBlock",{get:function(){return this._method===exports.AcCmTransparencyMethod.ByBlock},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isByLayer",{get:function(){return this._method===exports.AcCmTransparencyMethod.ByLayer},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isClear",{get:function(){return this.isByAlpha&&this._alpha===0},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isSolid",{get:function(){return this.isByAlpha&&this._alpha===255},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"isInvalid",{get:function(){return this._method===exports.AcCmTransparencyMethod.ErrorValue},enumerable:!1,configurable:!0}),n.prototype.serialize=function(){var t=this._method;return t<<24|this._alpha},n.prototype.clone=function(){var t=new n;return t._method=this._method,t._alpha=this._alpha,t},n.prototype.equals=function(t){return this._method===t._method&&this._alpha===t._alpha},n.prototype.toString=function(){return this.isByLayer?"ByLayer":this.isByBlock?"ByBlock":this._alpha.toString()},n.fromString=function(t){var e=t.trim(),i=e.toLowerCase();if(i===""||i==="."||i==="use current"||i==="bylayer"){var r=new n;return r._method=exports.AcCmTransparencyMethod.ByLayer,r}if(i==="byblock"){var s=new n;return s._method=exports.AcCmTransparencyMethod.ByBlock,s}var a=Number(e);if(Number.isInteger(a)&&a>=0&&a<=255){var o=new n;return a<=90?o.percentage=a:o.alpha=a,o}var c=new n;return c._method=exports.AcCmTransparencyMethod.ErrorValue,c},n.deserialize=function(t){var e=t>>>24&255,i=t&255,r=e>=exports.AcCmTransparencyMethod.ByLayer&&e<=exports.AcCmTransparencyMethod.ErrorValue?e:exports.AcCmTransparencyMethod.ErrorValue,s=new n;return s._method=r,s._alpha=n.clampAlpha(i),s},n})(),Uu=function(n,t,e,i){function r(s){return s instanceof e?s:new e(function(a){a(s)})}return new(e||(e=Promise))(function(s,a){function o(h){try{l(i.next(h))}catch(u){a(u)}}function c(h){try{l(i.throw(h))}catch(u){a(u)}}function l(h){h.done?s(h.value):r(h.value).then(o,c)}l((i=i.apply(n,t||[])).next())})},Hu=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(e=0)),e;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(h){l=[6,h],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},Li=50;function ci(){return new Promise(function(n){typeof globalThis<"u"&&typeof globalThis.requestAnimationFrame=="function"?globalThis.requestAnimationFrame(function(){return n()}):setTimeout(n,0)})}function ec(){return new Promise(function(n){if(typeof globalThis<"u"&&typeof globalThis.requestAnimationFrame=="function"){var t=globalThis.requestAnimationFrame;t(function(){return t(function(){return n()})})}else setTimeout(n,0)})}var vr=(function(){function n(t){t===void 0&&(t=Li),this._budgetMs=t,this._lastYieldCompletedAt=n.now()}return Object.defineProperty(n.prototype,"budgetMs",{get:function(){return this._budgetMs},enumerable:!1,configurable:!0}),n.prototype.maybeYield=function(){return Uu(this,arguments,void 0,function(t){var e;return t===void 0&&(t=ci),Hu(this,function(i){switch(i.label){case 0:return e=n.now(),e-this._lastYieldCompletedAt<this._budgetMs?[2,!1]:[4,t()];case 1:return i.sent(),this._lastYieldCompletedAt=n.now(),[2,!0]}})})},n.prototype.mark=function(){this._lastYieldCompletedAt=n.now()},n.now=function(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()},n})(),Br=function(n,t,e,i){function r(s){return s instanceof e?s:new e(function(a){a(s)})}return new(e||(e=Promise))(function(s,a){function o(h){try{l(i.next(h))}catch(u){a(u)}}function c(h){try{l(i.throw(h))}catch(u){a(u)}}function l(h){h.done?s(h.value):r(h.value).then(o,c)}l((i=i.apply(n,t||[])).next())})},rn=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(e=0)),e;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(h){l=[6,h],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},ic=(function(){function n(t){this.name=t}return n.prototype.run=function(t){throw new Error("run() must be implemented by subclass")},n})(),nc=(function(){function n(){this.tasks=[],this.onProgress=function(){},this.onComplete=function(){},this.onError=function(){return!1}}return n.prototype.scheduleTask=function(t){return Br(this,void 0,void 0,function(){return rn(this,function(e){switch(e.label){case 0:return[4,ci()];case 1:return e.sent(),[2,t()]}})})},n.prototype.addTask=function(t){this.tasks.push(t)},n.prototype.setProgressCallback=function(t){this.onProgress=t},n.prototype.setCompleteCallback=function(t){this.onComplete=t},n.prototype.setErrorCallback=function(t){this.onError=t},n.prototype.run=function(t){return Br(this,void 0,void 0,function(){var e,i,r,s,a,o,c=this;return rn(this,function(l){switch(l.label){case 0:e=this.tasks.length,i=t,r=function(h){var u,d,g;return rn(this,function(p){switch(p.label){case 0:u=s.tasks[h],p.label=1;case 1:return p.trys.push([1,3,,4]),[4,s.scheduleTask(function(){return Br(c,void 0,void 0,function(){var f;return rn(this,function(m){switch(m.label){case 0:return[4,u.run(i)];case 1:return f=m.sent(),this.onProgress((h+1)/e,u),[2,f]}})})})];case 2:return i=p.sent(),[3,4];case 3:return d=p.sent(),g=s.onError({error:d,taskIndex:h,task:u}),g?[2,{value:Promise.reject(d)}]:[3,4];case 4:return[2]}})},s=this,a=0,l.label=1;case 1:return a<e?[5,r(a)]:[3,4];case 2:if(o=l.sent(),typeof o=="object")return[2,o.value];l.label=3;case 3:return a++,[3,1];case 4:return this.onComplete(i),[2]}})})},n})(),rc=(function(){function n(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}return n.prototype.itemStart=function(t){this.itemsTotal++,this.isLoading===!1&&this.onStart!==void 0&&this.onStart(t,this.itemsLoaded,this.itemsTotal),this.isLoading=!0},n.prototype.itemEnd=function(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())},n.prototype.itemError=function(t){this.onError!==void 0&&this.onError(t)},n.prototype.resolveURL=function(t){return this.urlModifier?this.urlModifier(t):t},n.prototype.setURLModifier=function(t){return this.urlModifier=t,this},n.prototype.addHandler=function(t,e){return this.handlers.push(t,e),this},n.prototype.removeHandler=function(t){var e=this.handlers.indexOf(t);return e!==-1&&this.handlers.splice(e,2),this},n.prototype.getHandler=function(t){for(var e=0,i=this.handlers.length;e<i;e+=2){var r=this.handlers[e],s=this.handlers[e+1];if(r.global&&(r.lastIndex=0),r.test(t))return s}return null},n})(),sc=new rc,Wu=(function(){function n(t){this.manager=t!==void 0?t:sc,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={}}return n.prototype.loadAsync=function(t,e){var i=this;return new Promise(function(r,s){i.load(t,r,e,s)})},n.prototype.parse=function(t){},n.prototype.setCrossOrigin=function(t){return this.crossOrigin=t,this},n.prototype.setWithCredentials=function(t){return this.withCredentials=t,this},n.prototype.setPath=function(t){return this.path=t,this},n.prototype.setResourcePath=function(t){return this.resourcePath=t,this},n.prototype.setRequestHeader=function(t){return this.requestHeader=t,this},n})(),xt=["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"],Ja=1234567,js=Math.PI/180,Vs=180/Math.PI;function ac(){var n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0,r=xt[n&255]+xt[n>>8&255]+xt[n>>16&255]+xt[n>>24&255]+"-"+xt[t&255]+xt[t>>8&255]+"-"+xt[t>>16&15|64]+xt[t>>24&255]+"-"+xt[e&63|128]+xt[e>>8&255]+"-"+xt[e>>16&255]+xt[e>>24&255]+xt[i&255]+xt[i>>8&255]+xt[i>>16&255]+xt[i>>24&255];return r.toLowerCase()}function ae(n,t,e){return Math.max(t,Math.min(e,n))}function Gs(n,t){return(n%t+t)%t}function oc(n,t,e,i,r){return i+(n-t)*(r-i)/(e-t)}function cc(n,t,e){return n!==t?(e-n)/(t-n):0}function Us(n,t,e){return(1-e)*n+e*t}function lc(n,t,e,i){return Us(n,t,1-Math.exp(-e*i))}function hc(n,t){return t===void 0&&(t=1),t-Math.abs(Gs(n,t*2)-t)}function uc(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))}function dc(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))}function gc(n,t){return n+Math.floor(Math.random()*(t-n+1))}function fc(n,t){return n+Math.random()*(t-n)}function pc(n){return n*(.5-Math.random())}function mc(n){n!==void 0&&(Ja=n);var t=Ja+=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 yc(n){return n*js}function bc(n){return n*Vs}function _c(n){return(n&n-1)===0&&n!==0}function xc(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function wc(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function bi(n){var t=Math.PI*2;return(n%t+t)%t}function vc(n,t,e){return n>t&&n<e||n>e&&n<t}function kc(n,t,e,i){return i===void 0&&(i=!1),n=bi(n),t=bi(t),e=bi(e),i?t>e?n<=t&&n>=e:n<=t||n>=e:t<e?n>=t&&n<=e:n>=t||n<=e}function Hs(n){return n=Math.abs(n),n<1?0:Math.ceil(Math.log10(Math.abs(n)+1))}function Ac(n,t){t===void 0&&(t=1e-7);var e=Hs(n);return Math.max(Math.pow(10,e)*t,t)}var M={DEG2RAD:js,RAD2DEG:Vs,generateUUID:ac,clamp:ae,euclideanModulo:Gs,mapLinear:oc,inverseLerp:cc,lerp:Us,damp:lc,pingpong:hc,smoothstep:uc,smootherstep:dc,randInt:gc,randFloat:fc,randFloatSpread:pc,seededRandom:mc,degToRad:yc,radToDeg:bc,isPowerOfTwo:_c,ceilPowerOfTwo:xc,floorPowerOfTwo:wc,normalizeAngle:bi,isBetween:vc,isBetweenAngle:kc,intPartLength:Hs,relativeEps:Ac},$u=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(e=0)),e;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(h){l=[6,h],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},nt=(function(){function n(t,e){this.x=0,this.y=0;var 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){var r=t,s=r.x,a=r.y;this.x=s,this.y=a;return}if(i===2){this.x=t,this.y=e;return}throw Pt.ILLEGAL_PARAMETERS}}return Object.defineProperty(n.prototype,"width",{get:function(){return this.x},set:function(t){this.x=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this.y},set:function(t){this.y=t},enumerable:!1,configurable:!0}),n.prototype.set=function(t,e){return this.x=t,this.y=e,this},n.prototype.setScalar=function(t){return this.x=t,this.y=t,this},n.prototype.setX=function(t){return this.x=t,this},n.prototype.setY=function(t){return this.y=t,this},n.prototype.setComponent=function(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},n.prototype.getComponent=function(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+t)}},n.prototype.clone=function(){return new n(this.x,this.y)},n.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this},n.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},n.prototype.addScalar=function(t){return this.x+=t,this.y+=t,this},n.prototype.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this},n.prototype.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this},n.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this},n.prototype.subScalar=function(t){return this.x-=t,this.y-=t,this},n.prototype.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this},n.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},n.prototype.multiplyScalar=function(t){return this.x*=t,this.y*=t,this},n.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this},n.prototype.divideScalar=function(t){return this.multiplyScalar(1/t)},n.prototype.applyMatrix2d=function(t){var 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},n.prototype.min=function(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this},n.prototype.max=function(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this},n.prototype.clamp=function(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},n.prototype.clampScalar=function(t,e){return this.x=Math.max(t,Math.min(e,this.x)),this.y=Math.max(t,Math.min(e,this.y)),this},n.prototype.clampLength=function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},n.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},n.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},n.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},n.prototype.roundToZero=function(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this},n.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this},n.prototype.dot=function(t){return this.x*t.x+this.y*t.y},n.prototype.cross=function(t){return this.x*t.y-this.y*t.x},n.prototype.lengthSq=function(){return this.x*this.x+this.y*this.y},n.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},n.prototype.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)},n.prototype.normalize=function(){return this.divideScalar(this.length()||1)},n.prototype.angle=function(){var t=Math.atan2(-this.y,-this.x)+Math.PI;return t},n.prototype.angleTo=function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;var i=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,i)))},n.prototype.distanceTo=function(t){return Math.sqrt(this.distanceToSquared(t))},n.prototype.distanceToSquared=function(t){var e=this.x-t.x,i=this.y-t.y;return e*e+i*i},n.prototype.manhattanDistanceTo=function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)},n.prototype.setLength=function(t){return this.normalize().multiplyScalar(t)},n.prototype.lerp=function(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this},n.prototype.lerpVectors=function(t,e,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this},n.prototype.equals=function(t){return t.x===this.x&&t.y===this.y},n.prototype.fromArray=function(t,e){return e===void 0&&(e=0),this.x=t[e],this.y=t[e+1],this},n.prototype.toArray=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this.x,t[e+1]=this.y,t},n.prototype.rotateAround=function(t,e){var i=Math.cos(e),r=Math.sin(e),s=this.x-t.x,a=this.y-t.y;return this.x=s*i-a*r+t.x,this.y=s*r+a*i+t.y,this},n.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this},n.prototype.relativeEps=function(t){return t===void 0&&(t=1e-7),Math.min(M.relativeEps(this.x,t),M.relativeEps(this.y,t))},n.prototype[Symbol.iterator]=function(){return $u(this,function(t){switch(t.label){case 0:return[4,this.x];case 1:return t.sent(),[4,this.y];case 2:return t.sent(),[2]}})},n.EMPTY=Object.freeze(new n(0,0)),n})(),Ki=(function(){function n(t,e,i,r,s,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&i!=null&&r!=null&&s!=null&&a!=null&&o!=null&&c!=null&&l!=null&&this.set(t,e,i,r,s,a,o,c,l)}return n.prototype.set=function(t,e,i,r,s,a,o,c,l){var h=this.elements;return h[0]=t,h[1]=r,h[2]=o,h[3]=e,h[4]=s,h[5]=c,h[6]=i,h[7]=a,h[8]=l,this},n.prototype.identity=function(){return this.set(1,0,0,0,1,0,0,0,1),this},n.prototype.copy=function(t){var 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},n.prototype.extractBasis=function(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this},n.prototype.setFromMatrix4=function(t){var 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},n.prototype.multiply=function(t){return this.multiplyMatrices(this,t)},n.prototype.premultiply=function(t){return this.multiplyMatrices(t,this)},n.prototype.multiplyMatrices=function(t,e){var i=t.elements,r=e.elements,s=this.elements,a=i[0],o=i[3],c=i[6],l=i[1],h=i[4],u=i[7],d=i[2],g=i[5],p=i[8],f=r[0],m=r[3],y=r[6],_=r[1],v=r[4],x=r[7],k=r[2],I=r[5],P=r[8];return s[0]=a*f+o*_+c*k,s[3]=a*m+o*v+c*I,s[6]=a*y+o*x+c*P,s[1]=l*f+h*_+u*k,s[4]=l*m+h*v+u*I,s[7]=l*y+h*x+u*P,s[2]=d*f+g*_+p*k,s[5]=d*m+g*v+p*I,s[8]=d*y+g*x+p*P,this},n.prototype.multiplyScalar=function(t){var 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},n.prototype.determinant=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-i*s*h+i*o*c+r*s*l-r*a*c},n.prototype.invert=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=h*a-o*l,d=o*c-h*s,g=l*s-a*c,p=e*u+i*d+r*g;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);var f=1/p;return t[0]=u*f,t[1]=(r*l-h*i)*f,t[2]=(o*i-r*a)*f,t[3]=d*f,t[4]=(h*e-r*c)*f,t[5]=(r*s-o*e)*f,t[6]=g*f,t[7]=(i*c-l*e)*f,t[8]=(a*e-i*s)*f,this},n.prototype.transpose=function(){var t,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},n.prototype.getNormalMatrix=function(t){return this.setFromMatrix4(t).invert().transpose()},n.prototype.transposeIntoArray=function(t){var 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},n.prototype.setUvTransform=function(t,e,i,r,s,a,o){var c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*a+l*o)+a+t,-r*l,r*c,-r*(-l*a+c*o)+o+e,0,0,1),this},n.prototype.scale=function(t,e){return this.premultiply(Fr.makeScale(t,e)),this},n.prototype.rotate=function(t){return this.premultiply(Fr.makeRotation(-t)),this},n.prototype.translate=function(t,e){return this.premultiply(Fr.makeTranslation(t,e)),this},n.prototype.makeTranslation=function(t,e){return t instanceof nt?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},n.prototype.makeRotation=function(t){var e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,i,e,0,0,0,1),this},n.prototype.makeScale=function(t,e){return this.set(t,0,0,0,e,0,0,0,1),this},n.prototype.equals=function(t){for(var e=this.elements,i=t.elements,r=0;r<9;r++)if(e[r]!==i[r])return!1;return!0},n.prototype.fromArray=function(t,e){e===void 0&&(e=0);for(var i=0;i<9;i++)this.elements[i]=t[i+e];return this},n.prototype.toArray=function(t,e){t===void 0&&(t=[]),e===void 0&&(e=0);var 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},n.prototype.clone=function(){return new n().fromArray(this.elements)},n.IDENTITY=Object.freeze(new n),n})(),Fr=new Ki,se=1e-6,V=2*Math.PI,qu={x:0,y:0},Ws={x:0,y:0,z:0},K=(function(){function n(){this.equalPointTol=se,this.equalVectorTol=se}return n.prototype.clone=function(){var t=new n;return t.equalPointTol=this.equalPointTol,t.equalVectorTol=this.equalVectorTol,t},n.prototype.equalPoint2d=function(t,e){return new nt(t).sub(e).length()<this.equalPointTol},n.prototype.equalPoint3d=function(t,e){return new w(t).sub(e).length()<this.equalPointTol},n.equalToZero=function(t,e){return e===void 0&&(e=se),t<e&&t>-e},n.equal=function(t,e,i){return i===void 0&&(i=se),Math.abs(t-e)<i},n.great=function(t,e,i){return i===void 0&&(i=se),t-e>i},n.less=function(t,e,i){return i===void 0&&(i=se),t-e<i},n.isPositive=function(t,e){return e===void 0&&(e=se),t>e},n.isNonPositive=function(t,e){return e===void 0&&(e=se),t<=e},n})(),kr=new K,Ku=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(e=0)),e;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(h){l=[6,h],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},ei=(function(){function n(t,e,i,r){t===void 0&&(t=0),e===void 0&&(e=0),i===void 0&&(i=0),r===void 0&&(r=1),this._x=t,this._y=e,this._z=i,this._w=r}return n.slerpFlat=function(t,e,i,r,s,a,o){var c=i[r+0],l=i[r+1],h=i[r+2],u=i[r+3],d=s[a+0],g=s[a+1],p=s[a+2],f=s[a+3];if(o===0){t[e+0]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u;return}if(o===1){t[e+0]=d,t[e+1]=g,t[e+2]=p,t[e+3]=f;return}if(u!==f||c!==d||l!==g||h!==p){var m=1-o,y=c*d+l*g+h*p+u*f,_=y>=0?1:-1,v=1-y*y;if(v>Number.EPSILON){var x=Math.sqrt(v),k=Math.atan2(x,y*_);m=Math.sin(m*k)/x,o=Math.sin(o*k)/x}var I=o*_;if(c=c*m+d*I,l=l*m+g*I,h=h*m+p*I,u=u*m+f*I,m===1-o){var P=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=P,l*=P,h*=P,u*=P}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u},n.multiplyQuaternionsFlat=function(t,e,i,r,s,a){var o=i[r],c=i[r+1],l=i[r+2],h=i[r+3],u=s[a],d=s[a+1],g=s[a+2],p=s[a+3];return t[e]=o*p+h*u+c*g-l*d,t[e+1]=c*p+h*d+l*u-o*g,t[e+2]=l*p+h*g+o*d-c*u,t[e+3]=h*p-o*u-c*d-l*g,t},Object.defineProperty(n.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"z",{get:function(){return this._z},set:function(t){this._z=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"w",{get:function(){return this._w},set:function(t){this._w=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),n.prototype.set=function(t,e,i,r){return this._x=t,this._y=e,this._z=i,this._w=r,this._onChangeCallback(),this},n.prototype.clone=function(){return new n(this._x,this._y,this._z,this._w)},n.prototype.copy=function(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this},n.prototype.setFromEuler=function(t,e){e===void 0&&(e=!0);var i=t.x,r=t.y,s=t.z,a=t.order,o=Math.cos,c=Math.sin,l=o(i/2),h=o(r/2),u=o(s/2),d=c(i/2),g=c(r/2),p=c(s/2);switch(a){case"XYZ":this._x=d*h*u+l*g*p,this._y=l*g*u-d*h*p,this._z=l*h*p+d*g*u,this._w=l*h*u-d*g*p;break;case"YXZ":this._x=d*h*u+l*g*p,this._y=l*g*u-d*h*p,this._z=l*h*p-d*g*u,this._w=l*h*u+d*g*p;break;case"ZXY":this._x=d*h*u-l*g*p,this._y=l*g*u+d*h*p,this._z=l*h*p+d*g*u,this._w=l*h*u-d*g*p;break;case"ZYX":this._x=d*h*u-l*g*p,this._y=l*g*u+d*h*p,this._z=l*h*p-d*g*u,this._w=l*h*u+d*g*p;break;case"YZX":this._x=d*h*u+l*g*p,this._y=l*g*u+d*h*p,this._z=l*h*p-d*g*u,this._w=l*h*u-d*g*p;break;case"XZY":this._x=d*h*u-l*g*p,this._y=l*g*u-d*h*p,this._z=l*h*p+d*g*u,this._w=l*h*u+d*g*p;break;default:}return e===!0&&this._onChangeCallback(),this},n.prototype.setFromAxisAngle=function(t,e){var 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},n.prototype.setFromRotationMatrix=function(t){var e=t.elements,i=e[0],r=e[4],s=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],u=e[10],d=i+o+u;if(d>0){var g=.5/Math.sqrt(d+1);this._w=.25/g,this._x=(h-c)*g,this._y=(s-l)*g,this._z=(a-r)*g}else if(i>o&&i>u){var g=2*Math.sqrt(1+i-o-u);this._w=(h-c)/g,this._x=.25*g,this._y=(r+a)/g,this._z=(s+l)/g}else if(o>u){var g=2*Math.sqrt(1+o-i-u);this._w=(s-l)/g,this._x=(r+a)/g,this._y=.25*g,this._z=(c+h)/g}else{var g=2*Math.sqrt(1+u-i-o);this._w=(a-r)/g,this._x=(s+l)/g,this._y=(c+h)/g,this._z=.25*g}return this._onChangeCallback(),this},n.prototype.setFromUnitVectors=function(t,e){var 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()},n.prototype.angleTo=function(t){return 2*Math.acos(Math.abs(ae(this.dot(t),-1,1)))},n.prototype.rotateTowards=function(t,e){var i=this.angleTo(t);if(i===0)return this;var r=Math.min(1,e/i);return this.slerp(t,r),this},n.prototype.identity=function(){return this.set(0,0,0,1)},n.prototype.invert=function(){return this.conjugate()},n.prototype.conjugate=function(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this},n.prototype.dot=function(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w},n.prototype.lengthSq=function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},n.prototype.length=function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},n.prototype.normalize=function(){var 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},n.prototype.multiply=function(t){return this.multiplyQuaternions(this,t)},n.prototype.premultiply=function(t){return this.multiplyQuaternions(t,this)},n.prototype.multiplyQuaternions=function(t,e){var i=t._x,r=t._y,s=t._z,a=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=i*h+a*o+r*l-s*c,this._y=r*h+a*c+s*o-i*l,this._z=s*h+a*l+i*c-r*o,this._w=a*h-i*o-r*c-s*l,this._onChangeCallback(),this},n.prototype.slerp=function(t,e){if(e===0)return this;if(e===1)return this.copy(t);var i=this._x,r=this._y,s=this._z,a=this._w,o=a*t._w+i*t._x+r*t._y+s*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=s,this;var c=1-o*o;if(c<=Number.EPSILON){var l=1-e;return this._w=l*a+e*this._w,this._x=l*i+e*this._x,this._y=l*r+e*this._y,this._z=l*s+e*this._z,this.normalize(),this}var h=Math.sqrt(c),u=Math.atan2(h,o),d=Math.sin((1-e)*u)/h,g=Math.sin(e*u)/h;return this._w=a*d+this._w*g,this._x=i*d+this._x*g,this._y=r*d+this._y*g,this._z=s*d+this._z*g,this._onChangeCallback(),this},n.prototype.slerpQuaternions=function(t,e,i){return this.copy(t).slerp(e,i)},n.prototype.random=function(){var t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),r=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(r*Math.sin(t),r*Math.cos(t),s*Math.sin(e),s*Math.cos(e))},n.prototype.equals=function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w},n.prototype.fromArray=function(t,e){return e===void 0&&(e=0),this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this},n.prototype.toArray=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t},n.prototype.toJSON=function(){return this.toArray()},n.prototype._onChange=function(t){return this._onChangeCallback=t,this},n.prototype._onChangeCallback=function(){},n.prototype[Symbol.iterator]=function(){return Ku(this,function(t){switch(t.label){case 0:return[4,this._x];case 1:return t.sent(),[4,this._y];case 2:return t.sent(),[4,this._z];case 3:return t.sent(),[4,this._w];case 4:return t.sent(),[2]}})},n})(),Zu=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(e=0)),e;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(h){l=[6,h],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},w=(function(){function n(t,e,i){this.x=0,this.y=0,this.z=0;var 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){var s=t,a=s.x,o=s.y,c=s.z;this.x=a,this.y=o,this.z=c||0;return}if(r===3){this.x=t,this.y=e,this.z=i;return}throw Pt.ILLEGAL_PARAMETERS}}return n.prototype.set=function(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,this},n.prototype.setScalar=function(t){return this.x=t,this.y=t,this.z=t,this},n.prototype.setX=function(t){return this.x=t,this},n.prototype.setY=function(t){return this.y=t,this},n.prototype.setZ=function(t){return this.z=t,this},n.prototype.setComponent=function(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},n.prototype.getComponent=function(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)}},n.prototype.clone=function(){return new n(this.x,this.y,this.z)},n.prototype.copy=function(t){return this.x=t.x,this.y=t.y,this.z=t.z||0,this},n.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z||0,this},n.prototype.addScalar=function(t){return this.x+=t,this.y+=t,this.z+=t,this},n.prototype.addVectors=function(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this},n.prototype.addScaledVector=function(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this},n.prototype.sub=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},n.prototype.subScalar=function(t){return this.x-=t,this.y-=t,this.z-=t,this},n.prototype.subVectors=function(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this},n.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this},n.prototype.multiplyScalar=function(t){return this.x*=t,this.y*=t,this.z*=t,this},n.prototype.multiplyVectors=function(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this},n.prototype.applyEuler=function(t){return this.applyQuaternion(to.setFromEuler(t))},n.prototype.applyAxisAngle=function(t,e){return this.applyQuaternion(to.setFromAxisAngle(t,e))},n.prototype.applyMatrix3=function(t){var e=this.x,i=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*r,this.y=s[1]*e+s[4]*i+s[7]*r,this.z=s[2]*e+s[5]*i+s[8]*r,this},n.prototype.applyNormalMatrix=function(t){return this.applyMatrix3(t).normalize()},n.prototype.applyMatrix4=function(t){var e=this.x,i=this.y,r=this.z,s=t.elements,a=1/(s[3]*e+s[7]*i+s[11]*r+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*r+s[12])*a,this.y=(s[1]*e+s[5]*i+s[9]*r+s[13])*a,this.z=(s[2]*e+s[6]*i+s[10]*r+s[14])*a,this},n.prototype.applyQuaternion=function(t){var e=this.x,i=this.y,r=this.z,s=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*r-o*i),h=2*(o*e-s*r),u=2*(s*i-a*e);return this.x=e+c*l+a*u-o*h,this.y=i+c*h+o*l-s*u,this.z=r+c*u+s*h-a*l,this},n.prototype.transformDirection=function(t){var e=this.x,i=this.y,r=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*r,this.y=s[1]*e+s[5]*i+s[9]*r,this.z=s[2]*e+s[6]*i+s[10]*r,this.normalize()},n.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this},n.prototype.divideScalar=function(t){return this.multiplyScalar(1/t)},n.prototype.min=function(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},n.prototype.max=function(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},n.prototype.clamp=function(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},n.prototype.clampScalar=function(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},n.prototype.clampLength=function(t,e){var i=this.length();return this.divideScalar(i||1).multiplyScalar(Math.max(t,Math.min(e,i)))},n.prototype.floor=function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},n.prototype.ceil=function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},n.prototype.round=function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},n.prototype.roundToZero=function(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this},n.prototype.negate=function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},n.prototype.dot=function(t){return this.x*t.x+this.y*t.y+this.z*t.z},n.prototype.isParallelTo=function(t){var e=this.dot(t),i=this.length(),r=t.length();return Math.abs(e)===i*r},n.prototype.lengthSq=function(){return this.x*this.x+this.y*this.y+this.z*this.z},n.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},n.prototype.manhattanLength=function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},n.prototype.normalize=function(){return this.divideScalar(this.length()||1)},n.prototype.setLength=function(t){return this.normalize().multiplyScalar(t)},n.prototype.lerp=function(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},n.prototype.lerpVectors=function(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},n.prototype.cross=function(t){return this.crossVectors(this,t)},n.prototype.crossVectors=function(t,e){var i=t.x,r=t.y,s=t.z,a=e.x,o=e.y,c=e.z;return this.x=r*c-s*o,this.y=s*a-i*c,this.z=i*o-r*a,this},n.prototype.projectOnVector=function(t){var e=t.lengthSq();if(e===0)return this.set(0,0,0);var i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)},n.prototype.projectOnPlane=function(t){return Dr.copy(this).projectOnVector(t),this.sub(Dr)},n.prototype.reflect=function(t){return this.sub(Dr.copy(t).multiplyScalar(2*this.dot(t)))},n.prototype.angleTo=function(t){var e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;var i=this.dot(t)/e;return Math.acos(Math.max(-1,Math.min(1,i)))},n.prototype.distanceTo=function(t){return Math.sqrt(this.distanceToSquared(t))},n.prototype.distanceToSquared=function(t){var e=this.x-t.x,i=this.y-t.y,r=this.z-t.z;return e*e+i*i+r*r},n.prototype.manhattanDistanceTo=function(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)},n.prototype.setFromMatrixPosition=function(t){var e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this},n.prototype.setFromMatrixScale=function(t){var 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},n.prototype.setFromMatrixColumn=function(t,e){return this.fromArray(t.elements,e*4)},n.prototype.setFromMatrix3Column=function(t,e){return this.fromArray(t.elements,e*3)},n.prototype.equals=function(t){return t.x===this.x&&t.y===this.y&&t.z===this.z},n.prototype.fromArray=function(t,e){return e===void 0&&(e=0),this.x=t[e],this.y=t[e+1],this.z=t[e+2],this},n.prototype.toArray=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t},n.prototype.random=function(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this},n.prototype.randomDirection=function(){var 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},n.prototype[Symbol.iterator]=function(){return Zu(this,function(t){switch(t.label){case 0:return[4,this.x];case 1:return t.sent(),[4,this.y];case 2:return t.sent(),[4,this.z];case 3:return t.sent(),[2]}})},n.ORIGIN=Object.freeze(new n(0,0,0)),n.X_AXIS=Object.freeze(new n(1,0,0)),n.NEGATIVE_X_AXIS=Object.freeze(new n(-1,0,0)),n.Y_AXIS=Object.freeze(new n(0,1,0)),n.NEGATIVE_Y_AXIS=Object.freeze(new n(0,-1,0)),n.Z_AXIS=Object.freeze(new n(0,0,1)),n.NEGATIVE_Z_AXIS=Object.freeze(new n(0,0,-1)),n})(),Dr=new w,to=new ei,D=(function(){function n(t,e,i,r,s,a,o,c,l,h,u,d,g,p,f,m){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&&s!=null&&a!=null&&o!=null&&c!=null&&l!=null&&h!=null&&u!=null&&d!=null&&g!=null&&p!=null&&f!=null&&m!=null&&this.set(t,e,i,r,s,a,o,c,l,h,u,d,g,p,f,m)}return n.makeTranslation=function(t,e,i){return new n().makeTranslation(t,e,i)},n.prototype.set=function(t,e,i,r,s,a,o,c,l,h,u,d,g,p,f,m){var y=this.elements;return y[0]=t,y[4]=e,y[8]=i,y[12]=r,y[1]=s,y[5]=a,y[9]=o,y[13]=c,y[2]=l,y[6]=h,y[10]=u,y[14]=d,y[3]=g,y[7]=p,y[11]=f,y[15]=m,this},n.prototype.identity=function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},n.prototype.clone=function(){return new n().fromArray(this.elements)},n.prototype.copy=function(t){var 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},n.prototype.copyPosition=function(t){var e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[14],this},n.prototype.setFromMatrix3=function(t){var 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},n.prototype.setFromExtrusionDirection=function(t){var e=Math.hypot(t.x,t.y,t.z);if(!Number.isFinite(e)||e<1e-12)return this.identity(),this;var i=Math.abs(e-1)>1e-6?t.clone().multiplyScalar(1/e):t;if(kr.equalPoint3d(i,w.Z_AXIS))this.identity();else{var r=new w(1,0,0);Math.abs(i.x)<1/64&&Math.abs(i.y)<1/64?r.crossVectors(w.Y_AXIS,i).normalize():r.crossVectors(w.Z_AXIS,i).normalize();var s=i.clone().cross(r).normalize();this.set(r.x,r.y,r.z,0,s.x,s.y,s.z,0,i.x,i.y,i.z,0,0,0,0,1)}return this},n.prototype.extractBasis=function(t,e,i){return t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this},n.prototype.makeBasis=function(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},n.prototype.extractRotation=function(t){var e=this.elements,i=t.elements,r=1/Fe.setFromMatrixColumn(t,0).length(),s=1/Fe.setFromMatrixColumn(t,1).length(),a=1/Fe.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]*s,e[5]=i[5]*s,e[6]=i[6]*s,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},n.prototype.makeRotationFromQuaternion=function(t){return this.compose(Qu,t,Ju)},n.prototype.lookAt=function(t,e,i){var r=this.elements;return It.subVectors(t,e),It.lengthSq()===0&&(It.z=1),It.normalize(),me.crossVectors(i,It),me.lengthSq()===0&&(Math.abs(i.z)===1?It.x+=1e-4:It.z+=1e-4,It.normalize(),me.crossVectors(i,It)),me.normalize(),sn.crossVectors(It,me),r[0]=me.x,r[4]=sn.x,r[8]=It.x,r[1]=me.y,r[5]=sn.y,r[9]=It.y,r[2]=me.z,r[6]=sn.z,r[10]=It.z,this},n.prototype.multiply=function(t){return this.multiplyMatrices(this,t)},n.prototype.premultiply=function(t){return this.multiplyMatrices(t,this)},n.prototype.multiplyMatrices=function(t,e){var i=t.elements,r=e.elements,s=this.elements,a=i[0],o=i[4],c=i[8],l=i[12],h=i[1],u=i[5],d=i[9],g=i[13],p=i[2],f=i[6],m=i[10],y=i[14],_=i[3],v=i[7],x=i[11],k=i[15],I=r[0],P=r[4],C=r[8],T=r[12],R=r[1],N=r[5],O=r[9],S=r[13],G=r[2],$=r[6],Q=r[10],et=r[14],W=r[3],Dt=r[7],B=r[11],Yt=r[15];return s[0]=a*I+o*R+c*G+l*W,s[4]=a*P+o*N+c*$+l*Dt,s[8]=a*C+o*O+c*Q+l*B,s[12]=a*T+o*S+c*et+l*Yt,s[1]=h*I+u*R+d*G+g*W,s[5]=h*P+u*N+d*$+g*Dt,s[9]=h*C+u*O+d*Q+g*B,s[13]=h*T+u*S+d*et+g*Yt,s[2]=p*I+f*R+m*G+y*W,s[6]=p*P+f*N+m*$+y*Dt,s[10]=p*C+f*O+m*Q+y*B,s[14]=p*T+f*S+m*et+y*Yt,s[3]=_*I+v*R+x*G+k*W,s[7]=_*P+v*N+x*$+k*Dt,s[11]=_*C+v*O+x*Q+k*B,s[15]=_*T+v*S+x*et+k*Yt,this},n.prototype.multiplyScalar=function(t){var 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},n.prototype.determinant=function(){var t=this.elements,e=t[0],i=t[4],r=t[8],s=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],u=t[6],d=t[10],g=t[14],p=t[3],f=t[7],m=t[11],y=t[15];return p*(+s*c*u-r*l*u-s*o*d+i*l*d+r*o*g-i*c*g)+f*(+e*c*g-e*l*d+s*a*d-r*a*g+r*l*h-s*c*h)+m*(+e*l*u-e*o*g-s*a*u+i*a*g+s*o*h-i*l*h)+y*(-r*o*h-e*c*u+e*o*d+r*a*u-i*a*d+i*c*h)},n.prototype.transpose=function(){var t=this.elements,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},n.prototype.setPosition=function(t,e,i){var r=this.elements;return t instanceof w?(r[12]=t.x,r[13]=t.y,r[14]=t.z):(r[12]=t,r[13]=e,r[14]=i),this},n.prototype.invert=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=t[9],d=t[10],g=t[11],p=t[12],f=t[13],m=t[14],y=t[15],_=u*m*l-f*d*l+f*c*g-o*m*g-u*c*y+o*d*y,v=p*d*l-h*m*l-p*c*g+a*m*g+h*c*y-a*d*y,x=h*f*l-p*u*l+p*o*g-a*f*g-h*o*y+a*u*y,k=p*u*c-h*f*c-p*o*d+a*f*d+h*o*m-a*u*m,I=e*_+i*v+r*x+s*k;if(I===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);var P=1/I;return t[0]=_*P,t[1]=(f*d*s-u*m*s-f*r*g+i*m*g+u*r*y-i*d*y)*P,t[2]=(o*m*s-f*c*s+f*r*l-i*m*l-o*r*y+i*c*y)*P,t[3]=(u*c*s-o*d*s-u*r*l+i*d*l+o*r*g-i*c*g)*P,t[4]=v*P,t[5]=(h*m*s-p*d*s+p*r*g-e*m*g-h*r*y+e*d*y)*P,t[6]=(p*c*s-a*m*s-p*r*l+e*m*l+a*r*y-e*c*y)*P,t[7]=(a*d*s-h*c*s+h*r*l-e*d*l-a*r*g+e*c*g)*P,t[8]=x*P,t[9]=(p*u*s-h*f*s-p*i*g+e*f*g+h*i*y-e*u*y)*P,t[10]=(a*f*s-p*o*s+p*i*l-e*f*l-a*i*y+e*o*y)*P,t[11]=(h*o*s-a*u*s-h*i*l+e*u*l+a*i*g-e*o*g)*P,t[12]=k*P,t[13]=(h*f*r-p*u*r+p*i*d-e*f*d-h*i*m+e*u*m)*P,t[14]=(p*o*r-a*f*r-p*i*c+e*f*c+a*i*m-e*o*m)*P,t[15]=(a*u*r-h*o*r+h*i*c-e*u*c-a*i*d+e*o*d)*P,this},n.prototype.scale=function(t){var e=this.elements,i=t.x,r=t.y,s=t.z;return e[0]*=i,e[4]*=r,e[8]*=s,e[1]*=i,e[5]*=r,e[9]*=s,e[2]*=i,e[6]*=r,e[10]*=s,e[3]*=i,e[7]*=r,e[11]*=s,this},n.prototype.getMaxScaleOnAxis=function(){var 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))},n.prototype.makeTranslation=function(t,e,i){var r;return typeof t=="object"?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,(r=t.z)!==null&&r!==void 0?r:0,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,i,0,0,0,1),this},n.prototype.makeRotationX=function(t){var 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},n.prototype.makeRotationY=function(t){var 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},n.prototype.makeRotationZ=function(t){var 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},n.prototype.makeRotationAxis=function(t,e){var i=Math.cos(e),r=Math.sin(e),s=1-i,a=t.x,o=t.y,c=t.z,l=s*a,h=s*o;return this.set(l*a+i,l*o-r*c,l*c+r*o,0,l*o+r*c,h*o+i,h*c-r*a,0,l*c-r*o,h*c+r*a,s*c*c+i,0,0,0,0,1),this},n.prototype.makeScale=function(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this},n.prototype.makeShear=function(t,e,i,r,s,a){return this.set(1,i,s,0,t,1,a,0,e,r,1,0,0,0,0,1),this},n.prototype.compose=function(t,e,i){var r=this.elements,s=e.x,a=e.y,o=e.z,c=e.w,l=s+s,h=a+a,u=o+o,d=s*l,g=s*h,p=s*u,f=a*h,m=a*u,y=o*u,_=c*l,v=c*h,x=c*u,k=i.x,I=i.y,P=i.z;return r[0]=(1-(f+y))*k,r[1]=(g+x)*k,r[2]=(p-v)*k,r[3]=0,r[4]=(g-x)*I,r[5]=(1-(d+y))*I,r[6]=(m+_)*I,r[7]=0,r[8]=(p+v)*P,r[9]=(m-_)*P,r[10]=(1-(d+f))*P,r[11]=0,r[12]=t.x,r[13]=t.y,r[14]=t.z,r[15]=1,this},n.prototype.decompose=function(t,e,i){var r=this.elements,s=Fe.set(r[0],r[1],r[2]).length(),a=Fe.set(r[4],r[5],r[6]).length(),o=Fe.set(r[8],r[9],r[10]).length(),c=this.determinant();c<0&&(s=-s),t.x=r[12],t.y=r[13],t.z=r[14],Xt.copy(this);var l=1/s,h=1/a,u=1/o;return Xt.elements[0]*=l,Xt.elements[1]*=l,Xt.elements[2]*=l,Xt.elements[4]*=h,Xt.elements[5]*=h,Xt.elements[6]*=h,Xt.elements[8]*=u,Xt.elements[9]*=u,Xt.elements[10]*=u,e.setFromRotationMatrix(Xt),i.x=s,i.y=a,i.z=o,this},n.prototype.equals=function(t){for(var e=this.elements,i=t.elements,r=0;r<16;r++)if(e[r]!==i[r])return!1;return!0},n.prototype.fromArray=function(t,e){e===void 0&&(e=0);for(var i=0;i<16;i++)this.elements[i]=t[i+e];return this},n.prototype.toArray=function(t,e){t===void 0&&(t=[]),e===void 0&&(e=0);var 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},n.IDENTITY=Object.freeze(new n),n})(),Fe=new w,Xt=new D,Qu=new w(0,0,0),Ju=new w(1,1,1),me=new w,sn=new w,It=new w,Y=(function(){function n(t,e){t===void 0&&(t=void 0),e===void 0&&(e=void 0),this.min=t==null?new w(1/0,1/0,1/0):new w(t.x,t.y,t.z),this.max=e==null?new w(-1/0,-1/0,-1/0):new w(e.x,e.y,e.z)}return n.prototype.set=function(t,e){return this.min.copy(t),this.max.copy(e),this},n.prototype.setFromArray=function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e+=3)this.expandByPoint(Yr.fromArray(t,e));return this},n.prototype.setFromPoints=function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},n.prototype.setFromCenterAndSize=function(t,e){var i=Yr.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this},n.prototype.clone=function(){return new n().copy(this)},n.prototype.copy=function(t){return this.min.copy(t.min),this.max.copy(t.max),this},n.prototype.makeEmpty=function(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this},n.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},n.prototype.getCenter=function(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},n.prototype.getSize=function(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)},Object.defineProperty(n.prototype,"center",{get:function(){return this.isEmpty()?new w(0,0,0):new w(0,0,0).addVectors(this.min,this.max).multiplyScalar(.5)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return this.isEmpty()?new w(0,0,0):new w(0,0,0).subVectors(this.max,this.min)},enumerable:!1,configurable:!0}),n.prototype.expandByPoint=function(t){return this.min.min(t),this.max.max(t),this},n.prototype.expandByVector=function(t){return this.min.sub(t),this.max.add(t),this},n.prototype.expandByScalar=function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},n.prototype.containsPoint=function(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)},n.prototype.containsBox=function(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},n.prototype.getParameter=function(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))},n.prototype.intersectsBox=function(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)},n.prototype.intersectsPlane=function(t){var 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},n.prototype.clampPoint=function(t,e){return e.copy(t).clamp(this.min,this.max)},n.prototype.distanceToPoint=function(t){return this.clampPoint(t,Yr).distanceTo(t)},n.prototype.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},n.prototype.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},n.prototype.applyMatrix4=function(t){return this.isEmpty()?this:(re[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),re[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),re[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),re[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),re[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),re[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),re[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),re[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(re),this)},n.prototype.translate=function(t){return this.min.add(t),this.max.add(t),this},n.prototype.equals=function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},n})(),re=[new w,new w,new w,new w,new w,new w,new w,new w],Yr=new w,eo=new nt,yt=(function(){function n(t,e){t===void 0&&(t=void 0),e===void 0&&(e=void 0),this.min=t==null?new nt(1/0,1/0):new nt(t.x,t.y),this.max=e==null?new nt(-1/0,-1/0):new nt(e.x,e.y)}return n.prototype.set=function(t,e){return this.min.copy(t),this.max.copy(e),this},n.prototype.setFromPoints=function(t){this.makeEmpty();for(var e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this},n.prototype.setFromCenterAndSize=function(t,e){var i=eo.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),this},n.prototype.clone=function(){return new n().copy(this)},n.prototype.copy=function(t){return this.min.copy(t.min),this.max.copy(t.max),this},n.prototype.makeEmpty=function(){return this.min.x=this.min.y=1/0,this.max.x=this.max.y=-1/0,this},n.prototype.isEmpty=function(){return this.max.x<this.min.x||this.max.y<this.min.y},n.prototype.getCenter=function(t){return this.isEmpty()?t.set(0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)},n.prototype.getSize=function(t){return this.isEmpty()?t.set(0,0):t.subVectors(this.max,this.min)},Object.defineProperty(n.prototype,"center",{get:function(){return this.isEmpty()?new nt(0,0):new nt(0,0).addVectors(this.min,this.max).multiplyScalar(.5)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return this.isEmpty()?new nt(0,0):new nt(0,0).subVectors(this.max,this.min)},enumerable:!1,configurable:!0}),n.prototype.expandByPoint=function(t){return this.min.min(t),this.max.max(t),this},n.prototype.expandByVector=function(t){return this.min.sub(t),this.max.add(t),this},n.prototype.expandByScalar=function(t){return this.min.addScalar(-t),this.max.addScalar(t),this},n.prototype.containsPoint=function(t){return!(t.x<this.min.x||t.x>this.max.x||t.y<this.min.y||t.y>this.max.y)},n.prototype.containsBox=function(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},n.prototype.getParameter=function(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))},n.prototype.intersectsBox=function(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)},n.prototype.clampPoint=function(t,e){return e.copy(t).clamp(this.min,this.max)},n.prototype.distanceToPoint=function(t){return this.clampPoint(t,eo).distanceTo(t)},n.prototype.intersect=function(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this},n.prototype.union=function(t){return this.min.min(t.min),this.max.max(t.max),this},n.prototype.translate=function(t){return this.min.add(t),this.max.add(t),this},n.prototype.equals=function(t){return t.min.equals(this.min)&&t.max.equals(this.max)},n})(),io=new w,td=new w,ed=new Ki,$s=(function(){function n(t,e){t===void 0&&(t=new w(1,0,0)),e===void 0&&(e=0),this.normal=t,this.constant=e}return n.prototype.set=function(t,e){return this.normal.copy(t),this.constant=e,this},n.prototype.setComponents=function(t,e,i,r){return this.normal.set(t,e,i),this.constant=r,this},n.prototype.setFromNormalAndCoplanarPoint=function(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this},n.prototype.setFromCoplanarPoints=function(t,e,i){var r=io.subVectors(i,e).cross(td.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(r,t),this},n.prototype.copy=function(t){return this.normal.copy(t.normal),this.constant=t.constant,this},n.prototype.normalize=function(){var t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this},n.prototype.negate=function(){return this.constant*=-1,this.normal.negate(),this},n.prototype.distanceToPoint=function(t){return this.normal.dot(t)+this.constant},n.prototype.projectPoint=function(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))},n.prototype.intersectsBox=function(t){return t.intersectsPlane(this)},n.prototype.coplanarPoint=function(t){return t.copy(this.normal).multiplyScalar(-this.constant)},n.prototype.applyMatrix4=function(t,e){var i=e||ed.getNormalMatrix(t),r=this.coplanarPoint(io).applyMatrix4(t),s=this.normal.applyMatrix3(i).normalize();return this.constant=-r.dot(s),this},n.prototype.translate=function(t){return this.constant-=t.dot(this.normal),this},n.prototype.equals=function(t){return t.normal.equals(this.normal)&&t.constant===this.constant},n.prototype.clone=function(){return new n().copy(this)},n})(),id=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),L=(function(n){id(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.clone=function(){return new t(this.x,this.y)},t.pointArrayToNumberArray=function(e){var i=new Array(e.length*2);return e.forEach(function(r,s){r.toArray(i,s*2)}),i},t})(nt),nd=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),b=(function(n){nd(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.clone=function(){return new t(this.x,this.y,this.z)},t.pointArrayToNumberArray=function(e,i){i===void 0&&(i=!0);var r=i?3:2,s=new Array(e.length*r);return e.forEach(function(a,o){a.toArray(s,o*r)}),s},t})(w),rd=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,l[0]&&(e=0)),e;)try{if(i=1,r&&(s=l[0]&2?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return e.label++,{value:l[1],done:!1};case 5:e.label++,r=l[1],l=[0];continue;case 7:l=e.ops.pop(),e.trys.pop();continue;default:if(s=e.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){e=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){e.label=l[1];break}if(l[0]===6&&e.label<s[1]){e.label=s[1],s=l;break}if(s&&e.label<s[2]){e.label=s[2],e.ops.push(l);break}s[2]&&e.ops.pop(),e.trys.pop();continue}l=t.call(n,e)}catch(h){l=[6,h],r=0}finally{i=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}},no=new D,ro=new ei,sd=(function(){function n(t,e,i,r){t===void 0&&(t=0),e===void 0&&(e=0),i===void 0&&(i=0),r===void 0&&(r=n.DEFAULT_ORDER),this._x=t,this._y=e,this._z=i,this._order=r}return Object.defineProperty(n.prototype,"x",{get:function(){return this._x},set:function(t){this._x=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"y",{get:function(){return this._y},set:function(t){this._y=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"z",{get:function(){return this._z},set:function(t){this._z=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"order",{get:function(){return this._order},set:function(t){this._order=t,this._onChangeCallback()},enumerable:!1,configurable:!0}),n.prototype.set=function(t,e,i,r){return r===void 0&&(r=this._order),this._x=t,this._y=e,this._z=i,this._order=r,this._onChangeCallback(),this},n.prototype.clone=function(){return new n(this._x,this._y,this._z,this._order)},n.prototype.copy=function(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this},n.prototype.setFromRotationMatrix=function(t,e,i){e===void 0&&(e=this._order),i===void 0&&(i=!0);var r=t.elements,s=r[0],a=r[4],o=r[8],c=r[1],l=r[5],h=r[9],u=r[2],d=r[6],g=r[10];switch(e){case"XYZ":this._y=Math.asin(ae(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,g),this._z=Math.atan2(-a,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-ae(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,g),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(ae(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,g),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-ae(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,g),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(ae(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,g));break;case"XZY":this._z=Math.asin(-ae(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,g),this._y=0);break;default:}return this._order=e,i===!0&&this._onChangeCallback(),this},n.prototype.setFromQuaternion=function(t,e,i){return i===void 0&&(i=!0),no.makeRotationFromQuaternion(t),this.setFromRotationMatrix(no,e,i)},n.prototype.setFromVector3=function(t,e){return e===void 0&&(e=this._order),this.set(t.x,t.y,t.z,e)},n.prototype.reorder=function(t){return ro.setFromEuler(this),this.setFromQuaternion(ro,t)},n.prototype.equals=function(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order},n.prototype.fromArray=function(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},n.prototype.toArray=function(t,e){return t===void 0&&(t=[]),e===void 0&&(e=0),t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t},n.prototype._onChange=function(t){return this._onChangeCallback=t,this},n.prototype._onChangeCallback=function(){},n.prototype[Symbol.iterator]=function(){return rd(this,function(t){switch(t.label){case 0:return[4,this._x];case 1:return t.sent(),[4,this._y];case 2:return t.sent(),[4,this._z];case 3:return t.sent(),[4,this._order];case 4:return t.sent(),[2]}})},n.DEFAULT_ORDER="XYZ",n})();function ad(n){var t,e=n;return{x:n.x,y:n.y,z:(t=e.z)!==null&&t!==void 0?t:0}}function od(n,t){var e,i;n.x+=t.x,n.y+=t.y,n.z=((e=n.z)!==null&&e!==void 0?e:0)+((i=t.z)!==null&&i!==void 0?i:0)}function cd(n,t,e){e===void 0&&(e=!1);for(var i=n.x,r=n.y,s=!1,a=t.length,o=0,c=a-1;o<a;c=o++){var l=t[o].x,h=t[o].y,u=t[c].x,d=t[c].y,g=h>r!=d>r;e&&(g=h>=r!=d>=r);var p=g&&i<(u-l)*(r-h)/(d-h)+l;p&&(s=!s)}return s}function ld(n,t){if(n.length===0||t.length===0)return!1;var e=new yt().setFromPoints(n),i=new yt().setFromPoints(t);if(!e.intersectsBox(i))return!1;for(var r=0;r<n.length;){if(wt.isPointInPolygon(n[r],t,!0))return!0;r<n.length-1&&kr.equalPoint2d(n[r+1],n[r])&&++r,++r}return!1}var wt={applyOffsetToPoint3d:od,isPointInPolygon:cd,isPolygonIntersect:ld,point2dToPoint3d:ad},an=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},on=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))};function hd(n,t){for(var e=[],i=t-1,r=n,s=0;s<=r;s++)e.push(0);for(var s=1;s<=i-r;s++)e.push(s);for(var s=0;s<=r;s++)e.push(i-r+1);return e}function ud(n,t){for(var e=t.length-1,i=n,r=[0],s=0,a=1;a<=e;a++){var o=t[a][0]-t[a-1][0],c=t[a][1]-t[a-1][1],l=t[a][2]-t[a-1][2],h=Math.sqrt(o*o+c*c+l*l);s+=h,r.push(s)}for(var u=[],a=0;a<=i;a++)u.push(0);for(var a=1;a<=e-i;a++){var d=r[a]/s;u.push(d*(e-i+1))}for(var a=0;a<=i;a++)u.push(e-i+1);return u}function Sc(n,t){t===void 0&&(t="Uniform");var e=n.length;if(e===0)return[];if(e===1)return[0];var i=e-1;if(t==="Uniform")return new Array(e).fill(0).map(function(d,g){return g/i});for(var r=[0],s=0,a=1;a<=i;a++){var o=n[a][0]-n[a-1][0],c=n[a][1]-n[a-1][1],l=n[a][2]-n[a-1][2],h=Math.sqrt(o*o+c*c+l*l),u=t==="SqrtChord"?Math.sqrt(h):h;s+=u,r.push(s)}return s<1e-12?new Array(e).fill(0).map(function(d,g){return g/i}):r.map(function(d){return d/s})}function Pc(n,t){for(var e=t.length-1,i=n,r=e+i+1,s=new Array(r+1).fill(0),a=t[t.length-1],o=r-i;o<=r;o++)s[o]=a;for(var c=1;c<=e-i;c++){for(var l=0,o=c;o<c+i;o++)l+=t[o];s[c+i]=l/i}return s}function dd(n,t){for(var e=t.length-1,i=n,r=[0],s=0,a=1;a<=e;a++){var o=t[a][0]-t[a-1][0],c=t[a][1]-t[a-1][1],l=t[a][2]-t[a-1][2],h=Math.sqrt(o*o+c*c+l*l),u=Math.sqrt(h);s+=u,r.push(s)}for(var d=[],a=0;a<=i;a++)d.push(0);for(var a=1;a<=e-i;a++){var g=r[a]/s;d.push(g*(e-i+1))}for(var a=0;a<=i;a++)d.push(e-i+1);return d}function Xr(n,t){for(var e=n.length,i=n.map(function(m){return m.slice()}),r=t.slice(),s=0;s<e;s++){for(var a=s,o=Math.abs(i[s][s]),c=s+1;c<e;c++){var l=Math.abs(i[c][s]);l>o&&(o=l,a=c)}if(o<1e-12)throw new Error("Interpolation matrix is singular.");if(a!==s){var h=i[s];i[s]=i[a],i[a]=h;var u=r[s];r[s]=r[a],r[a]=u}for(var c=s+1;c<e;c++){var d=i[c][s]/i[s][s];if(!(Math.abs(d)<1e-14)){for(var g=s;g<e;g++)i[c][g]-=d*i[s][g];r[c]-=d*r[s]}}}for(var p=new Array(e).fill(0),c=e-1;c>=0;c--){for(var f=r[c],g=c+1;g<e;g++)f-=i[c][g]*p[g];p[c]=f/i[c][c]}return p}function qs(n,t,e,i,r){var s,a,o,c,l,h;if(e===void 0&&(e="Uniform"),n.length===0)return{controlPoints:[],knots:[],weights:[]};var u=n.map(function(B){var Yt;return[B[0],B[1],(Yt=B[2])!==null&&Yt!==void 0?Yt:0]}),d=!!i,g=!!r,p=(d?1:0)+(g?1:0),f=u.length-1,m=f+p;if(m<t)throw new Error("Not enough points to interpolate a curve of this degree.");var y=Sc(u,e),_=y.slice();d&&_.unshift(y[0]),g&&_.push(y[y.length-1]);var v=Pc(t,_),x=m+1,k=new Array(x),I=new Array(x),P=new Array(x),C=new Array(x),T=0;k[T]=new Array(x).fill(0),k[T][0]=1,I[T]=u[0][0],P[T]=u[0][1],C[T]=u[0][2],T++;for(var R=1;R<=f-1;R++){var N=y[R];k[T]=new Array(x).fill(0);for(var O=0;O<=m;O++)k[T][O]=Pe(O,t,N,v);I[T]=u[R][0],P[T]=u[R][1],C[T]=u[R][2],T++}if(k[T]=new Array(x).fill(0),k[T][m]=1,I[T]=u[f][0],P[T]=u[f][1],C[T]=u[f][2],T++,d){var S=v[t+1]-v[0],G=S!==0?t/S:0;k[T]=new Array(x).fill(0),k[T][0]=-G,k[T][1]=G,I[T]=(s=i==null?void 0:i[0])!==null&&s!==void 0?s:0,P[T]=(a=i==null?void 0:i[1])!==null&&a!==void 0?a:0,C[T]=(o=i==null?void 0:i[2])!==null&&o!==void 0?o:0,T++}if(g){var S=v[m+t+1]-v[m],G=S!==0?t/S:0;k[T]=new Array(x).fill(0),k[T][m-1]=-G,k[T][m]=G,I[T]=(c=r==null?void 0:r[0])!==null&&c!==void 0?c:0,P[T]=(l=r==null?void 0:r[1])!==null&&l!==void 0?l:0,C[T]=(h=r==null?void 0:r[2])!==null&&h!==void 0?h:0,T++}for(var $=Xr(k,I),Q=Xr(k,P),et=Xr(k,C),W=new Array(x),R=0;R<x;R++)W[R]=[$[R],Q[R],et[R]];var Dt=new Array(x).fill(1);return{controlPoints:W,knots:v,weights:Dt}}function Pe(n,t,e,i){if(t===0)return e>=i[n]&&e<i[n+1]?1:0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],a=r>1e-10?(e-i[n])/r:0,o=s>1e-10?(i[n+t+1]-e)/s:0;return a*Pe(n,t-1,e,i)+o*Pe(n+1,t-1,e,i)}function _i(n,t,e,i,r){var s=i.length-1,a=t;if(n=Math.max(e[a],Math.min(e[s+1],n)),Math.abs(n-e[s+1])<1e-8)return on([],an(i[s]),!1);if(Math.abs(n-e[a])<1e-8)return on([],an(i[0]),!1);for(var o=[0,0,0],c=0,l=0;l<=s;l++){var h=Pe(l,a,n,e),u=r[l]*h;o[0]+=i[l][0]*u,o[1]+=i[l][1]*u,o[2]+=i[l][2]*u,c+=u}if(Math.abs(c)<1e-10){var d=e[e.length-a-1];if(Math.abs(n-d)<1e-8)return on([],an(i[s]),!1);if(Math.abs(n-e[a])<1e-8)return on([],an(i[0]),!1)}return Math.abs(c)>=1e-10&&(o[0]/=c,o[1]/=c,o[2]/=c),o}function ds(n,t,e,i){if(t===0)return 0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],a=0;return r>1e-10&&(a+=t/r*Pe(n,t-1,e,i)),s>1e-10&&(a-=t/s*Pe(n+1,t-1,e,i)),a}function gd(n,t,e,i){if(t<=1)return 0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],a=0;return r>1e-10&&(a+=t/r*ds(n,t-1,e,i)),s>1e-10&&(a-=t/s*ds(n+1,t-1,e,i)),a}function fd(n,t,e,i,r){var s=i.length-1,a=t,o=e[a],c=e[s+1];n=Math.max(o,Math.min(c,n));for(var l=[0,0,0],h=[0,0,0],u=[0,0,0],d=0,g=0,p=0,f=0;f<=s;f++){var m=Pe(f,a,n,e),y=ds(f,a,n,e),_=gd(f,a,n,e),v=r[f],x=v*m,k=v*y,I=v*_,P=i[f];l[0]+=x*P[0],l[1]+=x*P[1],l[2]+=x*P[2],h[0]+=k*P[0],h[1]+=k*P[1],h[2]+=k*P[2],u[0]+=I*P[0],u[1]+=I*P[1],u[2]+=I*P[2],d+=x,g+=k,p+=I}if(Math.abs(d)<1e-10){var C=_i(n,t,e,i,r);return{point:C,deriv1:[0,0,0],deriv2:[0,0,0]}}var T=d*d,R=[l[0]/d,l[1]/d,l[2]/d],N=[(h[0]*d-l[0]*g)/T,(h[1]*d-l[1]*g)/T,(h[2]*d-l[2]*g)/T],O=u[0]*d-l[0]*p,S=u[1]*d-l[1]*p,G=u[2]*d-l[2]*p,$=[O/T-2*g*N[0]/d,S/T-2*g*N[1]/d,G/T-2*g*N[2]/d];return{point:R,deriv1:N,deriv2:$}}function pd(n,t){var e=n[0],i=n[1],r=t[0],s=t[1],a=e*e+i*i;return a<1e-20?0:(e*s-i*r)/Math.pow(a,1.5)}function Ic(n,t,e,i){for(var r=n,s=t[r],a=t[t.length-r-1],o=0,c=1e3,l=(a-s)/c,h=_i(s,n,t,e,i),u=1;u<=c;u++){var d=s+u*l,g=_i(d,n,t,e,i),p=g[0]-h[0],f=g[1]-h[1],m=g[2]-h[2];o+=Math.sqrt(p*p+f*f+m*m),h=g}var y=_i(a,n,t,e,i),_=y[0]-h[0],v=y[1]-h[1],x=y[2]-h[2];return o+=Math.sqrt(_*_+v*v+x*x),o}function md(n,t,e,i,r){return t===void 0&&(t=3),e===void 0&&(e="Uniform"),n.length===0?[]:qs(n,t,e,i,r).controlPoints}var so=new D,ao=new w,yd=new w,bd=new w,zr=new b;function Ec(n){return new D().setFromExtrusionDirection(new w(n.x,n.y,n.z))}function Ti(n){return so.setFromExtrusionDirection(new w(n.x,n.y,n.z)),so.extractBasis(ao,yd,bd),ao.clone()}function de(n,t){var e;return new b(n.x,n.y,(e=n.z)!==null&&e!==void 0?e:0).applyMatrix4(Ec(t))}function Lt(n,t){var e;return new b(n.x,n.y,(e=n.z)!==null&&e!==void 0?e:0).applyMatrix4(Ec(t).invert())}function ce(n,t,e){var i,r,s=Lt(n,e),a=Lt(t,e);return zr.set(a.x-s.x,a.y-s.y,((i=a.z)!==null&&i!==void 0?i:0)-((r=s.z)!==null&&r!==void 0?r:0)),M.normalizeAngle(Math.atan2(zr.y,zr.x))}function Lc(n){var t=n.length;if(t<3)return 0;for(var e=0,i=0,r=t-1;i<t;r=i++){var s=n[r],a=n[i];e+=s.x*a.y-a.x*s.y}return e*.5}function _d(n){return Math.abs(Lc(n))}function xd(n){var t,e,i=n.length;if(i<3)return 0;for(var r=0,s=0,a=0,o=0,c=i-1;o<i;c=o++){var l=n[c],h=n[o],u=l.x,d=l.y,g=(t=l.z)!==null&&t!==void 0?t:0,p=h.x,f=h.y,m=(e=h.z)!==null&&e!==void 0?e:0;r+=(g+m)*(d-f),s+=(u+p)*(g-m),a+=(d+f)*(u-p)}return .5*Math.hypot(r,s,a)}function wd(n){return n.length<3?0:_d(n)}function Tc(n){return n.length<3?0:xd(n)}var Cc=(function(){function n(){this._boundingBoxNeedsUpdate=!1}return Object.defineProperty(n.prototype,"boundingBoxNeedUpdate",{get:function(){return this._boundingBoxNeedsUpdate},enumerable:!1,configurable:!0}),n})(),vd=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Ks=(function(n){vd(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.translate=function(e){return this.transform(new Ki().makeTranslation(e.x,e.y))},Object.defineProperty(t.prototype,"box",{get:function(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box},enumerable:!1,configurable:!0}),t})(Cc),kd=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),li=(function(n){kd(t,n);function t(){var e=n.call(this)||this;return e.arcLengthDivisions=100,e}return Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPoint(0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPoint(1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this.getLength()},enumerable:!1,configurable:!0}),t.prototype.getPoint=function(e){throw new Error("AcGeCurve2d: .getPoint() not implemented.")},t.prototype.getPointAt=function(e){var i=this.getUtoTmapping(e);return this.getPoint(i)},t.prototype.getPoints=function(e){e===void 0&&(e=5);for(var i=[],r=0;r<=e;r++)i.push(this.getPoint(r/e));return i},t.prototype.getSpacedPoints=function(e){e===void 0&&(e=5);for(var i=[],r=0;r<=e;r++)i.push(this.getPointAt(r/e));return i},t.prototype.getLength=function(){var e=this.getLengths();return e[e.length-1]},t.prototype.getLengths=function(e){e===void 0&&(e=this.arcLengthDivisions);var i=[],r,s=this.getPoint(0),a=0;i.push(0);for(var o=1;o<=e;o++)r=this.getPoint(o/e),a+=r.distanceTo(s),i.push(a),s=r;return i},t.prototype.getUtoTmapping=function(e,i){var r=this.getLengths(),s=0,a=r.length,o;i?o=i:o=e*r[a-1];for(var c=0,l=a-1,h;c<=l;)if(s=Math.floor(c+(l-c)/2),h=r[s]-o,h<0)c=s+1;else if(h>0)l=s-1;else{l=s;break}if(s=l,r[s]===o)return s/(a-1);var u=r[s],d=r[s+1],g=d-u,p=(o-u)/g,f=(s+p)/(a-1);return f},t.prototype.getTangent=function(e){var i=1e-4,r=e-i,s=e+i;r<0&&(r=0),s>1&&(s=1);var a=this.getPoint(r),o=this.getPoint(s),c=new L;return c.copy(o).sub(a).normalize(),c},t.prototype.getTangentAt=function(e){var i=this.getUtoTmapping(e);return this.getTangent(i)},t})(Ks),Ad=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),cn=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},ln=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},hn=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},vt=(function(n){Ad(t,n);function t(e,i,r,s,a){var o=n.call(this)||this,c=+(e!==void 0)+ +(i!==void 0)+ +(r!==void 0)+ +(s!==void 0)+ +(a!==void 0);if(c==3)typeof e=="object"&&typeof i=="object"&&typeof r=="object"?o.createByThreePoints(e,i,r):o.createByStartEndPointsAndBulge(e,i,r);else if(c==5){var l=e;o.center=new L(l.x,l.y),o.radius=i,o._clockwise=a,o._startAngle=o._clockwise?o._mirrorAngle(M.normalizeAngle(r)):M.normalizeAngle(r),o._endAngle=o._clockwise?o._mirrorAngle(M.normalizeAngle(s)):M.normalizeAngle(s)}else throw Pt.ILLEGAL_PARAMETERS;return o}return t.prototype.createByThreePoints=function(e,i,r){var s=function(C,T){return{x:(C.x+T.x)/2,y:(C.y+T.y)/2}},a=function(C,T){return(T.y-C.y)/(T.x-C.x)},o=function(C){return-1/C},c=s(e,i),l=s(i,r),h=a(e,i),u=a(i,r),d=o(h),g=o(u),p=function(C,T,R,N){var O=(N-T)/(C-R),S=C*O+T;return{x:O,y:S}},f=c.y-d*c.x,m=l.y-g*l.x,y=p(d,f,g,m),_=Math.sqrt(Math.pow(e.x-y.x,2)+Math.pow(e.y-y.y,2)),v=function(C,T){return Math.atan2(C.y-T.y,C.x-T.x)},x=v(e,y),k=v(i,y),I=v(r,y),P=I>x&&I<k||x>I&&x<k||k>I&&k<x;this.center=y,this.radius=_,this._clockwise=!P,this._startAngle=x,this._endAngle=I},t.prototype.createByStartEndPointsAndBulge=function(e,i,r){var s,a,o;r<0?(s=Math.atan(-r)*4,a=new nt(e),o=new nt(i)):(s=Math.atan(r)*4,a=new nt(i),o=new nt(e));var c=new nt().subVectors(o,a),l=c.length(),h=new nt().addVectors(a,c.multiplyScalar(.5)),u=Math.abs(l/2/Math.tan(s/2)),d=c.normalize(),g=r<0?-Math.PI/2:Math.PI/2,p=new nt(d.x*Math.cos(g)-d.y*Math.sin(g),d.y*Math.cos(g)+d.x*Math.sin(g)),f;s<Math.PI?r<0?f=h.add(p.multiplyScalar(u)):f=h.add(p.multiplyScalar(-u)):r<0?f=h.add(p.multiplyScalar(-u)):f=h.add(p.multiplyScalar(u)),r<0?(this._startAngle=Math.atan2(a.y-f.y,a.x-f.x),this._endAngle=Math.atan2(o.y-f.y,o.x-f.x)):(this._startAngle=Math.atan2(o.y-f.y,o.x-f.x),this._endAngle=Math.atan2(a.y-f.y,a.x-f.x)),this._clockwise=r<0,this.center=f,this.radius=o.sub(f).length()},Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new L(e.x,e.y),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._clockwise?this._mirrorAngle(this._startAngle):this._startAngle},set:function(e){this._startAngle=this._clockwise?this._mirrorAngle(M.normalizeAngle(e)):M.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._clockwise?this._mirrorAngle(this._endAngle):this._endAngle},set:function(e){var i=this.startAngle==0&&e==V?e:M.normalizeAngle(e);this._endAngle=this._clockwise?this._mirrorAngle(i):i,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),t.prototype._mirrorAngle=function(e){var i=e*180/Math.PI,r=(360-i)%360;return r*Math.PI/180},t.prototype._getInternalAngle=function(e){return this._clockwise?this._mirrorAngle(e):e},Object.defineProperty(t.prototype,"deltaAngle",{get:function(){var e=this._getInternalAngle(this.startAngle),i=this._getInternalAngle(this.endAngle);return this.clockwise?M.normalizeAngle(e-i):M.normalizeAngle(i-e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this._clockwise},set:function(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this.endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){var e=this._getInternalAngle(this.startAngle),i=this._clockwise?M.normalizeAngle(e-this.deltaAngle/2):M.normalizeAngle(e+this.deltaAngle/2),r=this._clockwise?this._mirrorAngle(i):i;return this.getPointAtAngle(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"closed",{get:function(){var e=this._getInternalAngle(this.startAngle),i=this._getInternalAngle(this.endAngle);return Math.abs(i-e)/Math.PI%2==0},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e,i,r=[this.startPoint,this.endPoint],s=[0,Math.PI/2,Math.PI,3*Math.PI/2];try{for(var a=cn(s),o=a.next();!o.done;o=a.next()){var c=o.value,l=this._getInternalAngle(c);M.isBetweenAngle(l,this._getInternalAngle(this.startAngle),this._getInternalAngle(this.endAngle),this.clockwise)&&r.push(this.getPointAtAngle(c))}}catch(d){e={error:d}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(e)throw e.error}}var h=r.map(function(d){return d.x}),u=r.map(function(d){return d.y});return new yt(new L(Math.min.apply(Math,hn([],ln(h),!1)),Math.min.apply(Math,hn([],ln(u),!1))),new L(Math.max.apply(Math,hn([],ln(h),!1)),Math.max.apply(Math,hn([],ln(u),!1))))},Object.defineProperty(t.prototype,"length",{get:function(){return Math.abs(this.deltaAngle*this.radius)},enumerable:!1,configurable:!0}),t.prototype.transform=function(e){var i=this,r=e,s=this.center.clone().applyMatrix2d(r),a=this.startPoint.clone().applyMatrix2d(r);if(this.closed)return this.center=s,this.radius=s.distanceTo(a),this._startAngle=Math.atan2(a.y-s.y,a.x-s.x),this._endAngle=this._startAngle,this._clockwise=r.determinant()<0?!this._clockwise:this._clockwise,this._boundingBoxNeedsUpdate=!0,this;var o=this.midPoint.clone().applyMatrix2d(r),c=this.endPoint.clone().applyMatrix2d(r),l=new t(a,o,c),h=r.determinant()<0?!this.clockwise:this.clockwise,u=function(d){var g=M.normalizeAngle(d);return h?i._mirrorAngle(g):g};return this.center=l.center,this.radius=l.radius,this.clockwise=h,this.startAngle=u(Math.atan2(a.y-l.center.y,a.x-l.center.x)),this.endAngle=u(Math.atan2(c.y-l.center.y,c.x-l.center.x)),this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this.center.clone(),this.radius,this._startAngle,this._endAngle,this.clockwise)},t.prototype.getPointAtAngle=function(e){var i=this._getInternalAngle(e),r=this.center.x+this.radius*Math.cos(i),s=this.center.y+this.radius*Math.sin(i);return new L(r,s)},t.prototype.getQuadrantPoints=function(){var e,i,r=[],s=this._getInternalAngle(this.startAngle),a=this._getInternalAngle(this.endAngle),o=[0,Math.PI/2,Math.PI,3*Math.PI/2];try{for(var c=cn(o),l=c.next();!l.done;l=c.next()){var h=l.value,u=this._getInternalAngle(h);M.isBetweenAngle(u,s,a,this.clockwise)&&r.push(this.getPointAtAngle(h))}}catch(d){e={error:d}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(e)throw e.error}}return r},t.prototype.nearestPoint=function(e){var i=new L(e.x,e.y),r=i.x-this.center.x,s=i.y-this.center.y,a=Math.hypot(r,s);if(a<1e-12)return this.startPoint.clone();var o=Math.atan2(s,r),c=this.clockwise?this._mirrorAngle(M.normalizeAngle(o)):M.normalizeAngle(o),l=this._getInternalAngle(c),h=this._getInternalAngle(this.startAngle),u=this._getInternalAngle(this.endAngle);if(M.isBetweenAngle(l,h,u,this.clockwise))return this.getPointAtAngle(c);var d=i.distanceToSquared(this.startPoint),g=i.distanceToSquared(this.endPoint);return d<=g?this.startPoint.clone():this.endPoint.clone()},t.prototype.perpendicularPoints=function(e){var i,r,s=new L(e.x,e.y),a=s.x-this.center.x,o=s.y-this.center.y,c=Math.hypot(a,o);if(c<1e-12)return[];var l=a/c,h=o/c,u=[new L(this.center.x+l*this.radius,this.center.y+h*this.radius),new L(this.center.x-l*this.radius,this.center.y-h*this.radius)],d=[],g=this._getInternalAngle(this.startAngle),p=this._getInternalAngle(this.endAngle);try{for(var f=cn(u),m=f.next();!m.done;m=f.next()){var y=m.value,_=Math.atan2(y.y-this.center.y,y.x-this.center.x),v=this.clockwise?this._mirrorAngle(M.normalizeAngle(_)):M.normalizeAngle(_),x=this._getInternalAngle(v);(this.closed||M.isBetweenAngle(x,g,p,this.clockwise))&&d.push(y)}}catch(k){i={error:k}}finally{try{m&&!m.done&&(r=f.return)&&r.call(f)}finally{if(i)throw i.error}}return d},t.prototype.tangentPoints=function(e){var i,r,s=[],a=e.x-this.center.x,o=e.y-this.center.y,c=Math.hypot(a,o),l=this.radius;if(c<l)return s;var h=Math.acos(l/c),u=Math.atan2(o,a),d=[u+h,u-h],g=this._getInternalAngle(this.startAngle),p=this._getInternalAngle(this.endAngle);try{for(var f=cn(d),m=f.next();!m.done;m=f.next()){var y=m.value,_=this.clockwise?this._mirrorAngle(M.normalizeAngle(y)):M.normalizeAngle(y),v=this._getInternalAngle(_);(this.closed||M.isBetweenAngle(v,g,p,this.clockwise))&&s.push(this.getPointAtAngle(_))}}catch(x){i={error:x}}finally{try{m&&!m.done&&(r=f.return)&&r.call(f)}finally{if(i)throw i.error}}return s},t.prototype.getPoints=function(e){e===void 0&&(e=100);var i=[],r=this.deltaAngle,s=this._getInternalAngle(this.startAngle);if(this.closed&&(r=V,s=0),this.clockwise)for(var a=0;a<=e;a++){var o=s-r*(a/e),c=this._clockwise?this._mirrorAngle(o):o,l=this.getPointAtAngle(c);i.push(new L(l.x,l.y))}else for(var a=0;a<=e;a++){var o=s+r*(a/e),c=this._clockwise?this._mirrorAngle(o):o,l=this.getPointAtAngle(c);i.push(new L(l.x,l.y))}return i},t})(li),gs=function(){return gs=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},gs.apply(this,arguments)},Sd=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},un=1e-6;function Mc(n,t){if(Wd(n)){var e=Id(n,t);return e?[e]:[]}var i=Bc(n),r=i.numberOfVertices;if(r<2)return[];var s=qd(i,t);return s?[s]:[]}function Pd(n){return Bc(n)}function Id(n,t){var e,i,r=Ed(n);if(r.length===0)return null;var s=[];try{for(var a=Sd(r),o=a.next();!o.done;o=a.next()){var c=o.value,l=Td(c,t);if(!l)return null;s.push(l)}}catch(g){e={error:g}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(e)throw e.error}}var h=Ld(n),u=Nd(s,h,n.closed,t);if(u.length<2)return null;var d=new q;return u.forEach(function(g,p){d.addVertexAt(p,{x:g.x,y:g.y})}),d.closed=n.closed,d}function Ed(n){for(var t,e=[],i=n.numberOfVertices,r=n.closed?i:i-1,s=0;s<r;s++){var a=n.vertices[s],o=n.vertices[(s+1)%i];K.isPositive(Math.abs((t=a.bulge)!==null&&t!==void 0?t:0))?e.push({kind:"arc",arc:new vt(a,o,a.bulge)}):e.push({kind:"line",start:new L(a.x,a.y),end:new L(o.x,o.y)})}return e}function Ld(n){for(var t=[],e=0;e<n.numberOfVertices;e++)t.push(n.getPointAt(e));return t}function Td(n,t){if(n.kind==="line"){var e=Od(n.start,n.end,t);return e?gs({kind:"line"},e):null}var i=Cd(n.arc,n.arc.startPoint,n.arc.endPoint,t);return i?{kind:"arc",arc:i}:null}function Cd(n,t,e,i){var r=Md(n,t,e,i),s=n.radius+r;return K.isNonPositive(s)?null:new vt(n.center,s,n.startAngle,n.endAngle,n.clockwise)}function Md(n,t,e,i){var r=e.x-t.x,s=e.y-t.y,a=Math.hypot(r,s);if(K.isNonPositive(a))return n.clockwise?-i:i;var o=-s/a,c=r/a,l=n.center.x-(t.x+e.x)/2,h=n.center.y-(t.y+e.y)/2,u=l*o+h*c>0;return u?-i:i}function Od(n,t,e){var i=t.x-n.x,r=t.y-n.y,s=Math.hypot(i,r);if(K.isNonPositive(s))return null;var a=-r/s*e,o=i/s*e;return{start:new L(n.x+a,n.y+o),end:new L(t.x+a,t.y+o),dx:i,dy:r}}function Nd(n,t,e,i){var r,s,a,o=n.length;if(o===0)return[];for(var c=Rd(n,t,e,i),l=[(s=(r=c[0].nextSegmentStart)===null||r===void 0?void 0:r.clone())!==null&&s!==void 0?s:c[0].point.clone()],h=0;h<o;h++){var u=n[h],d=h===o-1&&!e?{point:Xd(u)}:c[(h+1)%o];if(h>0&&c[h].filletPoints&&c[h].filletPoints.forEach(function(y){return l.push(y.clone())}),u.kind==="arc")for(var g=(a=c[h].nextSegmentStart)!==null&&a!==void 0?a:c[h].point,p=d.point,f=Bd(u.arc,g,p,Math.max(16,32)),m=1;m<f.length;m++)l.push(f[m]);else l.push(d.point.clone())}return Fc(l)}function Rd(n,t,e,i){for(var r=n.length,s=[],a=0;a<r;a++)a===0?s.push(e?oo(n[r-1],n[0],t[0],i):{point:Yd(n[0])}):s.push(oo(n[a-1],n[a],t[a],i));return s}function Bd(n,t,e,i){for(var r=n.nearestPoint(t),s=n.nearestPoint(e),a=fs(n,r),o=fs(n,s),c=Dd(n,a,o),l=[],h=0;h<=i;h++){var u=h/i,d=n.clockwise?a-c*u:a+c*u;l.push(n.getPointAtAngle(Fd(n,d)))}return l}function fs(n,t){return Math.atan2(t.y-n.center.y,t.x-n.center.x)}function Fd(n,t){var e=M.normalizeAngle(t);return n.clockwise?ps(e):e}function ps(n){var t=n*180/Math.PI;return(360-t)%360*(Math.PI/180)}function Dd(n,t,e){if(n.clockwise){var i=t-e;return K.isNonPositive(i)&&(i+=V),i}var r=e-t;return K.isNonPositive(r)&&(r+=V),r}function Yd(n){return n.kind==="line"?n.start.clone():n.arc.startPoint.clone()}function Xd(n){return n.kind==="line"?n.end.clone():n.arc.endPoint.clone()}function oo(n,t,e,i){return n.kind==="line"&&t.kind==="line"?{point:ms({start:n.start,end:n.end,dx:n.dx,dy:n.dy},{start:t.start,end:t.end,dx:t.dx,dy:t.dy})}:n.kind==="line"&&t.kind==="arc"?co(n,t.arc,e,i,!0):n.kind==="arc"&&t.kind==="line"?co(t,n.arc,e,i,!1):n.kind==="arc"&&t.kind==="arc"?zd(n.arc,t.arc,e,i):{point:e.clone()}}function zd(n,t,e,i){var r=Rc(n.endPoint,t.startPoint),s=Hd(n,t),a=s.filter(function(h){return En(n,h)&&En(t,h)});if(a.length>0)return{point:Nc(a,r)};var o=n.endPoint.clone(),c=t.startPoint.clone(),l=Oc(e,Math.abs(i),o,c);return{point:o,filletPoints:l,nextSegmentStart:c}}function co(n,t,e,i,r){var s=Rc(r?n.end:n.start,r?t.startPoint:t.endPoint),a=Ud(n,t,s);if(Vd(n,a)&&En(t,a))return{point:a};var o=jd(n,e,i),c=r?t.startPoint.clone():t.endPoint.clone(),l=Oc(e,Math.abs(i),r?o:c,r?c:o);return r?{point:o,filletPoints:l,nextSegmentStart:c}:{point:c,filletPoints:l,nextSegmentStart:o}}function jd(n,t,e){var i=Math.hypot(n.dx,n.dy),r=-n.dy/i*e,s=n.dx/i*e;return new L(t.x+r,t.y+s)}function Vd(n,t){var e=Math.hypot(n.dx,n.dy);if(K.isNonPositive(e))return!1;var i=n.dx/e,r=n.dy/e,s=t.x-n.start.x,a=t.y-n.start.y,o=Math.abs(s*r-a*i);return K.equalToZero(o)}function Oc(n,t,e,i){var r=Math.atan2(e.y-n.y,e.x-n.x),s=Math.atan2(i.y-n.y,i.x-n.x),a=Gd(r,s);if(K.equalToZero(Math.abs(a)))return[];for(var o=[],c=Math.max(2,Math.ceil(Math.abs(a)/Math.PI*16)),l=1;l<c;l++){var h=l/c,u=r+a*h;o.push(new L(n.x+t*Math.cos(u),n.y+t*Math.sin(u)))}return o}function Gd(n,t){for(var e=t-n;e>Math.PI;)e-=V;for(;e<=-Math.PI;)e+=V;return e}function Ud(n,t,e){var i=Math.hypot(n.dx,n.dy);if(K.isNonPositive(i))return e.clone();var r=n.dx/i,s=n.dy/i,a=n.start.x-t.center.x,o=n.start.y-t.center.y,c=2*(a*r+o*s),l=a*a+o*o-t.radius*t.radius,h=c*c-4*l;if(h<0)return e.clone();var u=Math.sqrt(h),d=[(-c-u)/2,(-c+u)/2].map(function(p){return new L(n.start.x+r*p,n.start.y+s*p)}),g=d.filter(function(p){return En(t,p)});return Nc(g.length>0?g:d,e)}function En(n,t){var e=Math.abs(Math.hypot(t.x-n.center.x,t.y-n.center.y)-n.radius);if(K.isPositive(e))return!1;var i=fs(n,t),r=n.clockwise?ps(M.normalizeAngle(n.startAngle)):M.normalizeAngle(n.startAngle),s=n.clockwise?ps(M.normalizeAngle(n.endAngle)):M.normalizeAngle(n.endAngle);return M.isBetweenAngle(i,r,s,n.clockwise)}function Hd(n,t){var e=t.center.x-n.center.x,i=t.center.y-n.center.y,r=Math.hypot(e,i);if(K.isNonPositive(r))return[];var s=n.radius+t.radius,a=Math.abs(n.radius-t.radius);if(r>s+un)return[];if(r<a-un)return[];var o=(n.radius*n.radius-t.radius*t.radius+r*r)/(2*r),c=n.radius*n.radius-o*o;if(c<-un)return[];var l=n.center.x+o*e/r,h=n.center.y+o*i/r;if(c<=un)return[new L(l,h)];var u=Math.sqrt(c),d=-i*u/r,g=e*u/r;return[new L(l+d,h+g),new L(l-d,h-g)]}function Nc(n,t){for(var e=n[0],i=e.distanceToSquared(t),r=1;r<n.length;r++){var s=n[r].distanceToSquared(t);s<i&&(e=n[r],i=s)}return e.clone()}function Rc(n,t){return new L((n.x+t.x)/2,(n.y+t.y)/2)}function Wd(n){for(var t,e=n.numberOfVertices,i=n.closed?e:e-1,r=0;r<i;r++){var s=n.vertices[r];if(K.isPositive(Math.abs((t=s.bulge)!==null&&t!==void 0?t:0)))return!0}return!1}function Bc(n){var t=$d(n.vertices.map(function(e){return new L(e.x,e.y)}),n.closed);return t.length===n.numberOfVertices?n:new q(t.map(function(e){return{x:e.x,y:e.y}}),n.closed)}function $d(n,t){var e=Fc(n);if(!t||e.length<2)return e;var i=e[0],r=e[e.length-1];return K.isNonPositive(Math.hypot(i.x-r.x,i.y-r.y))&&e.pop(),e}function Fc(n){var t=[];return n.forEach(function(e){var i=t[t.length-1];(!i||K.isPositive(Math.hypot(i.x-e.x,i.y-e.y)))&&t.push(new L(e.x,e.y))}),t}function qd(n,t){for(var e=[],i=0;i<n.numberOfVertices;i++)e.push(n.getPointAt(i));var r=Kd(e,n.closed,t);if(r.length===0)return null;var s=[];if(n.closed){if(r.length<2)return null;for(var a=r.length,i=0;i<a;i++){var o=r[(i-1+a)%a],c=r[i];s.push(ms(o,c))}}else{s.push(r[0].start);for(var i=1;i<r.length;i++)s.push(ms(r[i-1],r[i]));s.push(r[r.length-1].end)}var l=new q;return s.forEach(function(h,u){l.addVertexAt(u,{x:h.x,y:h.y})}),l.closed=n.closed,l}function Kd(n,t,e){for(var i=[],r=t?n.length:n.length-1,s=0;s<r;s++){var a=n[s],o=n[t?(s+1)%n.length:s+1],c=o.x-a.x,l=o.y-a.y,h=Math.hypot(c,l);if(!K.isNonPositive(h)){var u=-l/h*e,d=c/h*e;i.push({start:new L(a.x+u,a.y+d),end:new L(o.x+u,o.y+d),dx:c,dy:l})}}return i}function ms(n,t){var e=n.dx*t.dy-n.dy*t.dx;if(K.equalToZero(e))return new L((n.end.x+t.start.x)/2,(n.end.y+t.start.y)/2);var i=t.start.x-n.start.x,r=t.start.y-n.start.y,s=(i*t.dy-r*t.dx)/e;return new L(n.start.x+s*n.dx,n.start.y+s*n.dy)}var Zd=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),ys=function(){return ys=Object.assign||function(n){for(var t,e=1,i=arguments.length;e<i;e++){t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=t[r])}return n},ys.apply(this,arguments)},q=(function(n){Zd(t,n);function t(e,i){e===void 0&&(e=null),i===void 0&&(i=!1);var r=n.call(this)||this;return r._vertices=e||new Array,r._closed=i,r}return Object.defineProperty(t.prototype,"vertices",{get:function(){return this._vertices},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"numberOfVertices",{get:function(){return this._vertices.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"closed",{get:function(){return this._closed},set:function(e){this._closed=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){if(this.numberOfVertices>0){var e=this._vertices[0];return new L(e.x,e.y)}throw new Error("Start point does not exist in an empty polyline.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){var e=this.numberOfVertices;if(e>0)if(this.closed){var i=this._vertices[0];return new L(i.x,i.y)}else{var i=this._vertices[e-1];return new L(i.x,i.y)}throw new Error("End point does not exist in an empty polyline.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){for(var e=0,i=this._vertices.length,r=0;r<i;++r){var s=this._vertices[r],a=null;if(r<i-1?a=this._vertices[r+1]:r==i-1&&this.closed&&(a=this._vertices[0]),a)if(s.bulge){var o=new vt(s,a,s.bulge);e+=o.length}else e+=new L(s.x,s.y).distanceTo(a)}return e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"area",{get:function(){if(!this._closed||this._vertices.length<3)return 0;var e=this.getPoints(128);return wd(e)},enumerable:!1,configurable:!0}),t.prototype.addVertexAt=function(e,i){e<=0?this._vertices.unshift(i):this._vertices.splice(e,0,i),this._boundingBoxNeedsUpdate=!0},t.prototype.removeVertexAt=function(e){if(e<0||e>=this._vertices.length)throw new Error("Index ".concat(e," is out of bounds. Valid range is 0 to ").concat(this._vertices.length-1,"."));this._vertices.splice(e,1),this._boundingBoxNeedsUpdate=!0},t.prototype.reset=function(e,i){e?i!==void 0&&i>=0&&i<this._vertices.length&&(this._vertices=this._vertices.slice(0,i),this._boundingBoxNeedsUpdate=!0):(this._vertices=new Array,this._boundingBoxNeedsUpdate=!0)},t.prototype.getPointAt=function(e){var i=this._vertices[e];return new L(i.x,i.y)},t.prototype.calculateBoundingBox=function(){var e=this.getPoints(100);return new yt().setFromPoints(e)},t.prototype.transform=function(e){var i=e.determinant()<0;return this._vertices.forEach(function(r){var s=new L(r).applyMatrix2d(e);r.x=s.x,r.y=s.y,i&&r.bulge!=null&&(r.bulge=-r.bulge)}),this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this._vertices.map(function(e){return ys({},e)}),this._closed)},t.prototype.getPoints3d=function(e,i){var r=[],s=this.getPoints(e);return s.forEach(function(a){return r.push(new b().set(a.x,a.y,i))}),r},t.prototype.getPoints=function(e){for(var i=[],r=this._vertices.length,s=0;s<r;++s){var a=this._vertices[s];if(a.bulge){var o=null;if(s<r-1?o=this._vertices[s+1]:s==r-1&&this.closed&&(o=this._vertices[0]),o)for(var c=new vt(a,o,a.bulge),l=c.getPoints(e),h=l.length,u=0;u<h;++u){var d=l[u];i.push(new L(d.x,d.y))}}else i.push(new L(a.x,a.y)),s==r-1&&this.closed&&i.push(i[0])}return i},t.prototype.offset=function(e){return Mc(this,e)},t})(li);function Dc(n,t,e){var i=Math.hypot(t.x,t.y);if(K.isNonPositive(i))return null;var r=-t.y/i*e,s=t.x/i*e;return new b(n.x+r,n.y+s,n.z)}function Qd(n,t,e){var i;if(n.length<2)return null;var r=Pd(new q(n.map(function(a){return{x:a.x,y:a.y}}),t)),s=Mc(r,e);return(i=s[0])!==null&&i!==void 0?i:null}var Ln=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},Qe=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))};function Jd(n,t,e,i){if(n.length<2||K.equalToZero(e))return null;var r=Xc(n,i),s=r.points,a=r.tangents;if(s.length<2)return null;var o=a??tg(s,t),c=eg(s,o,e),l=t?ng(c):ig(c);if(l.length<2)return null;var h=new q;return l.forEach(function(u,d){h.addVertexAt(d,{x:u.x,y:u.y})}),h.closed=t,h}function tg(n,t){for(var e=n.length,i=new Array(e),r=0;r<e;r++){var s=0,a=0;if(t){var o=n[(r-1+e)%e],c=n[(r+1)%e];s=c.x-o.x,a=c.y-o.y}else r===0?(s=n[1].x-n[0].x,a=n[1].y-n[0].y):r===e-1?(s=n[e-1].x-n[e-2].x,a=n[e-1].y-n[e-2].y):(s=n[r+1].x-n[r-1].x,a=n[r+1].y-n[r-1].y);var l=Math.hypot(s,a);K.isNonPositive(l)?i[r]=new L(1,0):i[r]=new L(s/l,a/l)}return i}function eg(n,t,e){return n.map(function(i,r){var s=t[r],a=-s.y*e,o=s.x*e;return new L(i.x+a,i.y+o)})}function ig(n){var t=Tn(n);if(t.length<3)return t;for(;;){var e=Yc(t,!1);if(!e||(t=Tn(Qe(Qe(Qe([],Ln(t.slice(0,e.segmentA+1)),!1),[e.point],!1),Ln(t.slice(e.segmentB+1)),!1)),t.length<2))break}return t}function ng(n){var t=Tn(n);if(t.length<4)return t;for(;;){var e=Yc(t,!0);if(!e||(t=Tn(Qe(Qe(Qe([],Ln(t.slice(0,e.segmentA+1)),!1),[e.point],!1),Ln(t.slice(e.segmentB+1)),!1)),t.length<3))break}return t}function Yc(n,t){var e=t?n.length:n.length-1;if(e<2)return null;for(var i=0;i<e;i++)for(var r=n[i],s=n[(i+1)%n.length],a=i+1;a<e;a++)if(!rg(i,a,e,t)){var o=n[a],c=n[(a+1)%n.length],l=sg(r,s,o,c);if(l)return{point:l,segmentA:i,segmentB:a}}return null}function rg(n,t,e,i){return!!(t===n||t===n+1||i&&n===0&&t===e-1)}function sg(n,t,e,i){var r=t.x-n.x,s=t.y-n.y,a=i.x-e.x,o=i.y-e.y,c=r*o-s*a;if(K.equalToZero(c))return null;var l=e.x-n.x,h=e.y-n.y,u=(l*o-h*a)/c,d=(l*s-h*r)/c,g=kr.equalPointTol;return u<-g||u>1+g||d<-g||d>1+g?null:new L(n.x+u*r,n.y+u*s)}function Xc(n,t){var e=[],i=[],r=t!=null&&t.length===n.length;return n.forEach(function(s,a){var o=e[e.length-1];if((!o||K.isPositive(Math.hypot(o.x-s.x,o.y-s.y)))&&(e.push(new L(s.x,s.y)),r)){var c=t[a];i.push(new L(c.x,c.y))}}),{points:e,tangents:r?i:void 0}}function Tn(n){return Xc(n).points}var ag=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Vt=(function(n){ag(t,n);function t(){var e=n.call(this)||this;return e._loops=[],e}return t.prototype.add=function(e){this._loops.push(e),this._boundingBoxNeedsUpdate=!0},Object.defineProperty(t.prototype,"loops",{get:function(){return this._loops},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"outter",{get:function(){if(this._loops.length>0)return this._loops[0]},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e=this.outter;return e?e.box:new yt},t.prototype.transform=function(e){return this._loops.forEach(function(i){i.transform(e)}),this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){var e=new t;return this._loops.forEach(function(i){e.add(i.clone())}),e},t.prototype.getPoints=function(e){for(var i=[],r=0;r<this.loops.length;++r){var s=this.loops[r],a=s.getPoints(e);i.push(a)}return i},t.prototype.buildHierarchy=function(){for(var e,i=this.getPoints(100),r=this.calculateBoundaryBoxes(i),s=this.sortBoundaryBoxesByAreas(r),a=new Map,o=s.length,c=0;c<o;c++)a.set(s[c],{index:s[c],children:[]});for(var l={index:-1,children:[]},c=0;c<o;c++){for(var h=s[c],u=i[h],d=r[h],g=c+1;g<o;g++){var p=s[g],f=i[p],m=r[p];if(m.containsBox(d)&&wt.isPointInPolygon(u[M.randInt(0,u.length-1)],f)){(e=a.get(p))===null||e===void 0||e.children.push(a.get(h));break}}g===o&&l.children.push(a.get(h))}return l},Object.defineProperty(t.prototype,"area",{get:function(){if(this._loops.length===0)return 0;for(var e=0,i=0;i<this._loops.length;i++){var r=this._loops[i],s=r.getPoints(128),a=Lc(s);i===0?e+=Math.abs(a):e-=Math.abs(a)}return e},enumerable:!1,configurable:!0}),t.prototype.calculateBoundaryBoxes=function(e){var i=[];return e.forEach(function(r){i.push(new yt().setFromPoints(r))}),i},t.prototype.sortBoundaryBoxesByAreas=function(e){var i=[];e.forEach(function(s,a){var o=s.size,c=o.width*o.height;i.push({area:c,index:a})}),i.sort(function(s,a){return s.area-a.area});var r=[];return i.forEach(function(s){r.push(s.index)}),r},t})(Ks),og=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),cg=(function(n){og(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.translate=function(e){return this.transform(new D().makeTranslation(e.x,e.y,e.z))},Object.defineProperty(t.prototype,"box",{get:function(){return(this._box==null||this._boundingBoxNeedsUpdate)&&(this._box=this.calculateBoundingBox(),this._boundingBoxNeedsUpdate=!1),this._box},enumerable:!1,configurable:!0}),t})(Cc),lg=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Zi=(function(n){lg(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t})(cg),hg=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),ge=(function(n){hg(t,n);function t(e,i){var r=n.call(this)||this;return r._start=new b(e),r._end=new b(i),r}return Object.defineProperty(t.prototype,"startPoint",{get:function(){return this._start},set:function(e){this._start.copy(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this._end},set:function(e){this._end.copy(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"direction",{get:function(){return new w().subVectors(this.endPoint,this.startPoint).normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){return new b((this._start.x+this._end.x)/2,(this._start.y+this._end.y)/2,(this._start.z+this._end.z)/2)},enumerable:!1,configurable:!0}),t.prototype.nearestPoint=function(e){return this.project(e)},Object.defineProperty(t.prototype,"length",{get:function(){return this.startPoint.distanceTo(this.endPoint)},enumerable:!1,configurable:!0}),t.prototype.isPointOnLine=function(e){var i=this.project(e),r=1e-6;return i.distanceTo(e)<r},t.prototype.at=function(e,i){return this.delta(i).multiplyScalar(e).add(this._start)},t.prototype.atLength=function(e,i){if(i===void 0&&(i=!1),i){var r=this.delta(Le).normalize();return new b(this._start).addScaledVector(r,e)}else{var r=this.delta(Le).normalize();return new b(this._end).addScaledVector(r,e)}},t.prototype.extend=function(e,i){if(i===void 0&&(i=!1),i){var r=Le.subVectors(this._start,this._end).normalize();this._start=new b(this._start).addScaledVector(r,e)}else{var r=this.delta(Le).normalize();this._end=new b(this._end).addScaledVector(r,e)}return this._boundingBoxNeedsUpdate=!0,this},t.prototype.closestPointToPointParameter=function(e,i){lo.subVectors(e,this._start),dn.subVectors(this.endPoint,this.startPoint);var r=dn.dot(dn),s=dn.dot(lo),a=s/r;return i&&(a=M.clamp(a,0,1)),a},t.prototype.closestPointToPoint=function(e,i,r){var s=this.closestPointToPointParameter(e,i);return this.delta(r).multiplyScalar(s).add(this._start)},t.prototype.delta=function(e){return e.subVectors(this._end,this._start)},t.prototype.distanceSq=function(){return this._start.distanceToSquared(this._end)},t.prototype.distance=function(){return this._start.distanceTo(this._end)},t.prototype.project=function(e){var i=this.direction,r=Le.subVectors(e,this.startPoint),s=r.dot(i);return new b().copy(i).multiplyScalar(s).add(this.startPoint)},t.prototype.perpPoint=function(e){var i=this.direction,r=this.startPoint,s=Le.subVectors(e,r),a=s.dot(i),o=Le.copy(i).multiplyScalar(a);return new b().addVectors(r,o)},t.prototype.calculateBoundingBox=function(){var e=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)),i=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 Y(e,i)},t.prototype.transform=function(e){return this._start.applyMatrix4(e),this._end.applyMatrix4(e),this._boundingBoxNeedsUpdate=!0,this},Object.defineProperty(t.prototype,"closed",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.copy=function(e){return this.startPoint=e.startPoint,this.endPoint=e.endPoint,this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this._start.clone(),this._end.clone())},t.prototype.offset=function(e){var i=this.startPoint,r=this.endPoint,s=Math.hypot(r.x-i.x,r.y-i.y);if(s===0)return this.clone();var a=new w(r.x-i.x,r.y-i.y,0).normalize(),o=new w(-a.y,a.x,0);return new t(new b(i.x+o.x*e,i.y+o.y*e,i.z),new b(r.x+o.x*e,r.y+o.y*e,r.z))},t})(Zi),Le=new w,lo=new w,dn=new w,ug=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),jr=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Zt=(function(n){ug(t,n);function t(e,i,r,s,a,o){o===void 0&&(o=w.X_AXIS);var c=n.call(this)||this;return c.center=e,c.radius=i,c.startAngle=r,c.endAngle=s,c.normal=a,c.refVec=o,(s-r)%V==0?(c.startAngle=0,c.endAngle=V):(c.startAngle=r,c.endAngle=s),c}return t.computeCenterPoint=function(e,i,r){var s=new w().addVectors(e,i).multiplyScalar(.5),a=new w().addVectors(e,r).multiplyScalar(.5),o=new w().subVectors(i,e),c=new w().subVectors(r,e),l=new w().crossVectors(o,c).normalize();if(l.lengthSq()===0)return null;var h=new w().crossVectors(o,l).normalize(),u=new w().crossVectors(c,l).normalize(),d=h.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),g=u.clone().multiplyScalar(Number.MAX_SAFE_INTEGER),p=new ge(s,s.clone().add(d)),f=new ge(a,a.clone().add(g)),m=new w,y=p.closestPointToPoint(f.startPoint,!0,m);return y?m:null},t.createByThreePoints=function(e,i,r){var s=t.computeCenterPoint(e,i,r);if(s){var a=s.distanceTo(e),o=new w().subVectors(e,s),c=new w().subVectors(i,s),l=Math.atan2(o.y,o.x),h=Math.atan2(c.y,c.x);return new t(s,a,l,h,w.Z_AXIS)}},Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new b(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"radius",{get:function(){return this._radius},set:function(e){if(e<0)throw Pt.ILLEGAL_PARAMETERS;this._radius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._startAngle},set:function(e){this._startAngle=M.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._endAngle},set:function(e){this._endAngle=this.startAngle==0&&e==V?e:M.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deltaAngle",{get:function(){return M.normalizeAngle(this.endAngle-this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this.deltaAngle<=0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._normal},set:function(e){this._normal=new w(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"refVec",{get:function(){return this._refVec},set:function(e){this._refVec=new w(e.x,e.y,e.z),this._refVec.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this._startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this._endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){var e=this.startAngle,i=this.deltaAngle;this.closed&&(e=0,i=V);var r=e+i*.5;return this.getPointAtAngle(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this.closed?2*Math.PI*this.radius:Math.abs(this.deltaAngle*this.radius)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"area",{get:function(){return this.closed?Math.PI*this.radius*this.radius:0},enumerable:!1,configurable:!0}),t.prototype.nearestPoint=function(e){var i=new w(e.x,e.y,e.z||0),r=this.center,s=this.normal,a=i.clone().sub(r),o=a.dot(s),c=i.clone().sub(s.clone().multiplyScalar(o)),l=c.clone().sub(r);if(l.lengthSq()===0)return this.startPoint.clone();l.normalize().multiplyScalar(this.radius);var h=r.clone().add(l),u=this.getAngle(h.clone()),d=this.startAngle,g=this.deltaAngle,p=M.normalizeAngle(u-d);p<0&&(p=0),p>g&&(p=g);var f=this.getPointAtAngle(d+p),m=f.distanceTo(i),y=this.startPoint.distanceTo(i),_=this.endPoint.distanceTo(i);return y<m&&y<=_?this.startPoint.clone():_<m&&_<y?this.endPoint.clone():f},t.prototype.tangentPoints=function(e){var i,r,s=[],a=new w(e.x,e.y,e.z||0),o=this.center,c=this.normal,l=this.radius,h=a.clone().sub(o),u=h.dot(c),d=a.clone().sub(c.clone().multiplyScalar(u)),g=o.clone(),p=d.clone().sub(g),f=p.length();if(f<l)return s;var m=Math.acos(l/f),y=this.getAngle(d.clone()),_=[y+m,y-m];try{for(var v=jr(_),x=v.next();!x.done;x=v.next()){var k=x.value,I=M.normalizeAngle(k-this.startAngle);I>=0&&I<=this.deltaAngle&&s.push(this.getPointAtAngle(this.startAngle+I))}}catch(P){i={error:P}}finally{try{x&&!x.done&&(r=v.return)&&r.call(v)}finally{if(i)throw i.error}}return s},t.prototype.perpendicularPoints=function(e){var i,r,s=[],a=new w(e.x,e.y,e.z||0),o=this.center,c=this.normal,l=this.radius,h=a.clone().sub(o),u=h.dot(c),d=a.clone().sub(c.clone().multiplyScalar(u)),g=d.clone().sub(o);if(g.lengthSq()<1e-24)return s;g.normalize();var p=[o.clone().add(g.clone().multiplyScalar(l)),o.clone().sub(g.clone().multiplyScalar(l))];try{for(var f=jr(p),m=f.next();!m.done;m=f.next()){var y=m.value,_=this.getAngle(y.clone()),v=M.normalizeAngle(_-this.startAngle);v>=0&&v<=this.deltaAngle&&s.push(new b(y.x,y.y,y.z||0))}}catch(x){i={error:x}}finally{try{m&&!m.done&&(r=f.return)&&r.call(f)}finally{if(i)throw i.error}}return s},t.prototype.nearestTangentPoint=function(e){var i=this.tangentPoints(e);if(i.length===0)return null;var r=new b(e.x,e.y,e.z||0);return i.length===1||i[0].distanceTo(r)<i[1].distanceTo(r)?i[0]:i[1]},t.prototype.calculateBoundingBox=function(){for(var e,i,r=[this.startAngle,this.endAngle],s=0;s<2*Math.PI;s+=Math.PI/2)M.isBetweenAngle(s,this.startAngle,this.endAngle)&&r.push(s);var a=1/0,o=1/0,c=1/0,l=-1/0,h=-1/0,u=-1/0;try{for(var d=jr(r),g=d.next();!g.done;g=d.next()){var p=g.value,f=this.getPointAtAngle(p);f.x<a&&(a=f.x),f.y<o&&(o=f.y),f.z<c&&(c=f.z),f.x>l&&(l=f.x),f.y>h&&(h=f.y),f.z>u&&(u=f.z)}}catch(m){e={error:m}}finally{try{g&&!g.done&&(i=d.return)&&i.call(d)}finally{if(e)throw e.error}}return new Y({x:a,y:o,z:c},{x:l,y:h,z:u})},Object.defineProperty(t.prototype,"closed",{get:function(){return Math.abs(this.endAngle-this.startAngle)/Math.PI%2==0},enumerable:!1,configurable:!0}),t.prototype.getPoints=function(e){var i=[],r=this.deltaAngle,s=this.startAngle;this.closed&&(r=V,s=0);for(var a=0;a<=e;a++){var o=s+r*(a/e),c=this.getPointAtAngle(o);i.push(c)}return i},t.prototype.transform=function(e){var i=this.center.clone().applyMatrix4(e),r=this.startPoint.clone().applyMatrix4(e),s=this.endPoint.clone().applyMatrix4(e),a=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(e),o=new w(r).sub(i).normalize(),c=i.distanceTo(r),l=new w().crossVectors(new w(r).sub(i),new w(a).sub(i)).normalize();l.lengthSq()===0&&(l=this.normal.clone().transformDirection(e));var h=function(u){var d=new w(u).sub(i);return Math.atan2(d.dot(ho.crossVectors(l,o)),d.dot(o))};return this.center=i,this.radius=c,this.normal=l,this.refVec=o,this.startAngle=0,this.endAngle=this.closed?V:h(s),this._boundingBoxNeedsUpdate=!0,this},t.prototype.copy=function(e){return this.center=e.center,this.radius=e.radius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.normal=e.normal,this.refVec=e.refVec,this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this.center.clone(),this.radius,this.startAngle,this.endAngle,this.normal,this.refVec)},t.prototype.getAngle=function(e){return e.sub(this.center),Math.atan2(e.dot(ho.crossVectors(this.refVec,this.normal)),e.dot(this.refVec))},t.prototype.getPointAtAngle=function(e){var i=this.normal,r=this.refVec,s={x:i.y*r.z-i.z*r.y,y:i.z*r.x-i.x*r.z,z:i.x*r.y-i.y*r.x},a=this.center,o=this.radius;return new b(a.x+o*(r.x*Math.cos(e)+s.x*Math.sin(e)),a.y+o*(r.y*Math.cos(e)+s.y*Math.sin(e)),a.z+o*(r.z*Math.cos(e)+s.z*Math.sin(e)))},Object.defineProperty(t.prototype,"plane",{get:function(){var e=new w(this.center).distanceTo(Ws);return new $s(this.normal,e)},enumerable:!1,configurable:!0}),t.prototype.offset=function(e){var i=this.radius+e;return i<=0?null:new t(this.center,i,this.startAngle,this.endAngle,this.normal,this.refVec)},t})(Zi),ho=new w,dg=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),be=(function(n){dg(t,n);function t(e,i,r,s,a,o,c){s===void 0&&(s=0),a===void 0&&(a=V),o===void 0&&(o=!1),c===void 0&&(c=0);var l=n.call(this)||this;return l.center=e,l.majorAxisRadius=i,l.minorAxisRadius=r,(a-s)%V==0?(l.startAngle=0,l.endAngle=V):(l.startAngle=s,l.endAngle=a),l.clockwise=o,l.rotation=c,l}return Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new b(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"majorAxisRadius",{get:function(){return this._majorAxisRadius},set:function(e){if(e<0)throw Pt.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minorAxisRadius",{get:function(){return this._minorAxisRadius},set:function(e){if(e<0)throw Pt.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._startAngle},set:function(e){this._startAngle=M.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._endAngle},set:function(e){this._endAngle=this.startAngle==0&&e==V?e:M.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this._clockwise},set:function(e){this._clockwise=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deltaAngle",{get:function(){return M.normalizeAngle(this.endAngle-this.startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){for(var e=100,i=1/0,r=1/0,s=-1/0,a=-1/0,o=0;o<=e;o++){var c=this.getPoint(o/e);i=Math.min(i,c.x),r=Math.min(r,c.y),s=Math.max(s,c.x),a=Math.max(a,c.y)}return new yt({x:i,y:r},{x:s,y:a})},Object.defineProperty(t.prototype,"closed",{get:function(){return this.deltaAngle==0},enumerable:!1,configurable:!0}),t.prototype.getPoint=function(e){for(var i=Math.PI*2,r=this.endAngle-this.startAngle,s=Math.abs(r)<Number.EPSILON;r<0;)r+=i;for(;r>i;)r-=i;r<Number.EPSILON&&(s?r=0:r=i),this.clockwise===!0&&!s&&(r===i?r=-i:r=r-i);var a=this.startAngle+e*r,o=this.center.x+this.majorAxisRadius*Math.cos(a),c=this.center.y+this.minorAxisRadius*Math.sin(a);if(this.rotation!==0){var l=Math.cos(this.rotation),h=Math.sin(this.rotation),u=o-this.center.x,d=c-this.center.y;o=u*l-d*h+this.center.x,c=u*h+d*l+this.center.y}return new L(o,c)},t.prototype.transform=function(e){var i=e,r=new L(this.center).applyMatrix2d(i),s=new b(r.x,r.y,this.center.z),a=this.getPointAtAngle(0).clone().applyMatrix2d(i),o=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(i),c=new L(a).sub(r),l=new L(o).sub(r),h=c.length(),u=l.length(),d=Math.atan2(c.y,c.x),g=c.clone().normalize(),p=l.clone().normalize(),f=function(_){var v=new L(_).sub(r),x=v.dot(g),k=v.dot(p);return M.normalizeAngle(Math.atan2(k/u,x/h))},m=i.determinant()<0?!this.clockwise:this.clockwise,y=this.closed?new t(s,h,u,0,V,m,d):new t(s,h,u,f(this.startPoint.clone().applyMatrix2d(i)),f(this.endPoint.clone().applyMatrix2d(i)),m,d);return this.center=y.center,this.majorAxisRadius=y.majorAxisRadius,this.minorAxisRadius=y.minorAxisRadius,this._startAngle=y._startAngle,this._endAngle=y._endAngle,this._clockwise=y._clockwise,this.rotation=y.rotation,this._boundingBoxNeedsUpdate=!0,this},t.prototype.getPointAtAngle=function(e){return this.getPoint(this.closed?e/V:M.normalizeAngle(e-this.startAngle)/this.deltaAngle)},t.prototype.copy=function(e){return this.center=e.center,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this.clockwise=e.clockwise,this.rotation=e.rotation,this},t.prototype.clone=function(){return new t(this.center,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle,this.clockwise,this.rotation)},t.prototype.getFocusPoints=function(){var e=Math.max(this.majorAxisRadius,this.minorAxisRadius),i=Math.min(this.majorAxisRadius,this.minorAxisRadius);if(e-i<1e-9)return[];var r=Math.sqrt(e*e-i*i),s=Math.cos(this.rotation),a=Math.sin(this.rotation),o=this.majorAxisRadius>=this.minorAxisRadius,c=o?s:-a,l=o?a:s;return[new L(this.center.x-r*c,this.center.y-r*l),new L(this.center.x+r*c,this.center.y+r*l)]},t.prototype.getQuadrantPoints=function(){return this.closed?[this.getPoint(0),this.getPoint(.25),this.getPoint(.5),this.getPoint(.75)]:[]},t.prototype.nearestPoint=function(e){for(var i=new L(e.x,e.y),r=this.getPoint(0),s=i.distanceToSquared(r),a=72,o=1;o<=a;o++){var c=this.getPoint(o/a),l=i.distanceToSquared(c);l<s&&(s=l,r=c)}return r},t.prototype.tangentPoints=function(e){var i=this,r=this._projectPointToLocal(e),s=this._findSnapAngles(r,function(a,o,c,l){var h=-i.majorAxisRadius*l,u=i.minorAxisRadius*c;return(a-r.x)*u-(o-r.y)*h});return s.map(function(a){return i.getPointAtAngle(a)})},t.prototype.perpendicularPoints=function(e){var i=this,r=this._projectPointToLocal(e),s=this._findSnapAngles(r,function(a,o,c,l){var h=i.minorAxisRadius*c,u=i.majorAxisRadius*l;return(a-r.x)*u-(o-r.y)*h});return s.map(function(a){return i.getPointAtAngle(a)})},t.prototype._projectPointToLocal=function(e){var i=e.x-this.center.x,r=e.y-this.center.y,s=Math.cos(-this.rotation),a=Math.sin(-this.rotation);return{x:i*s-r*a,y:i*a+r*s}},t.prototype._findSnapAngles=function(e,i,r){r===void 0&&(r=144);for(var s=this.majorAxisRadius,a=this.minorAxisRadius,o=this.startAngle,c=this.deltaAngle,l=[],h=function(x){var k=Math.cos(x),I=Math.sin(x);return i(s*k,a*I,k,I)},u=o,d=h(u),g=1;g<=r;g++){var p=o+c*g/r,f=h(p);if(Math.abs(d)<1e-10&&l.push(u),d*f<0){for(var m=u,y=p,_=0;_<32;_++){var v=(m+y)/2;h(m)*h(v)<=0?y=v:m=v}l.push((m+y)/2)}u=p,d=f}return l},t})(li),gg=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),fg=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Cn=(function(n){gg(t,n);function t(e,i,r,s,a,o,c){o===void 0&&(o=0),c===void 0&&(c=V);var l=n.call(this)||this;l.center=e,l.normal=i,l.majorAxis=r,l.majorAxisRadius=s,l.minorAxisRadius=a;var h=Math.abs(c-o);return Math.abs(h-V)<1e-10||Math.abs(h-2*V)<1e-10?(l.startAngle=0,l.endAngle=V):(l.startAngle=o,l.endAngle=c),l}return Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new b(e.x,e.y,e.z||0),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"majorAxisRadius",{get:function(){return this._majorAxisRadius},set:function(e){if(e<0)throw Pt.ILLEGAL_PARAMETERS;this._majorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minorAxisRadius",{get:function(){return this._minorAxisRadius},set:function(e){if(e<0)throw Pt.ILLEGAL_PARAMETERS;this._minorAxisRadius=e,this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startAngle",{get:function(){return this._startAngle},set:function(e){this._startAngle=M.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endAngle",{get:function(){return this._endAngle},set:function(e){this._endAngle=this.startAngle==0&&e==V?e:M.normalizeAngle(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deltaAngle",{get:function(){var e=this.endAngle-this.startAngle;return Math.abs(e-V)<1e-10?V:M.normalizeAngle(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isLargeArc",{get:function(){return Math.abs(this.deltaAngle)>Math.PI?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clockwise",{get:function(){return this.deltaAngle<=0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._normal},set:function(e){this._normal=new w(e.x,e.y,e.z),this._normal.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"majorAxis",{get:function(){return this._majorAxis},set:function(e){this._majorAxis=new w(e.x,e.y,e.z),this._majorAxis.normalize(),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minorAxis",{get:function(){return new w().crossVectors(this.normal,this.majorAxis).normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this.getPointAtAngle(this._startAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.getPointAtAngle(this._endAngle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){var e=this.startAngle,i=this.deltaAngle;(this.closed||Math.abs(i-V)<1e-10)&&(e=0,i=V);var r=e+i/2;return this.getPointAtAngle(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCircular",{get:function(){return K.equal(this.majorAxisRadius,this.minorAxisRadius)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){if(this.isCircular)return this.majorAxisRadius*Math.abs(this.deltaAngle);for(var e=1e3,i=this.deltaAngle/e,r=0,s=this.getPointAtAngle(this.startAngle),a=1;a<=e;a++){var o=this.startAngle+a*i,c=this.getPointAtAngle(o),l=c.x-s.x,h=c.y-s.y,u=c.z-s.z;r+=Math.sqrt(l*l+h*h+u*u),s=c}return r},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"area",{get:function(){return Math.abs(this.deltaAngle-V)>=1e-10?0:Math.PI*this.majorAxisRadius*this.minorAxisRadius},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e,i;if(this.majorAxis.equals(w.X_AXIS)||this.majorAxis.equals(w.Y_AXIS)||this.majorAxis.isParallelTo(w.X_AXIS)||this.majorAxis.isParallelTo(w.Y_AXIS)){for(var r=[this.startAngle,this.endAngle],s=0;s<2*Math.PI;s+=Math.PI/2)M.isBetweenAngle(s,this.startAngle,this.endAngle)&&r.push(s);var a=1/0,o=1/0,c=1/0,l=-1/0,h=-1/0,u=-1/0;try{for(var d=fg(r),g=d.next();!g.done;g=d.next()){var p=g.value,f=this.getPointAtAngle(p);f.x<a&&(a=f.x),f.y<o&&(o=f.y),f.z<c&&(c=f.z),f.x>l&&(l=f.x),f.y>h&&(h=f.y),f.z>u&&(u=f.z)}}catch(y){e={error:y}}finally{try{g&&!g.done&&(i=d.return)&&i.call(d)}finally{if(e)throw e.error}}return new Y({x:a,y:o,z:c},{x:l,y:h,z:u})}else{for(var m=100,a=1/0,o=1/0,c=1/0,l=-1/0,h=-1/0,u=-1/0,s=0;s<=m;s++){var p=this.startAngle+this.deltaAngle*(s/m),f=this.getPointAtAngle(p);a=Math.min(a,f.x),o=Math.min(o,f.y),c=Math.min(c,f.z),l=Math.max(l,f.x),h=Math.max(h,f.y),u=Math.max(u,f.z)}return new Y({x:a,y:o,z:c},{x:l,y:h,z:u})}},Object.defineProperty(t.prototype,"closed",{get:function(){return this.deltaAngle==0},enumerable:!1,configurable:!0}),t.prototype.getPoints=function(e){e===void 0&&(e=100);var i=[],r=this.deltaAngle,s=this.startAngle;this.closed&&(r=V,s=0);for(var a=0;a<=e;a++){var o=s+r*(a/e),c=this.getPointAtAngle(o);i.push(c)}return i},t.prototype.getPointAtAngle=function(e){var i=Math.cos(e),r=Math.sin(e),s=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(r),a=this.majorAxis.clone().multiplyScalar(i*this.majorAxisRadius).add(s);return new b(this.center.x+a.x,this.center.y+a.y,this.center.z+a.z)},t.prototype.nearestPoint=function(e,i){i===void 0&&(i=72);for(var r=new b(e.x,e.y,e.z||0),s=this.getPointAtAngle(this.startAngle),a=r.distanceToSquared(s),o=1;o<=i;o++){var c=this.startAngle+this.deltaAngle*o/i,l=this.getPointAtAngle(c),h=r.distanceToSquared(l);h<a&&(a=h,s=l)}var u=r.distanceToSquared(this.startPoint),d=r.distanceToSquared(this.endPoint);return u<a&&u<=d?this.startPoint.clone():d<a&&d<u?this.endPoint.clone():s.clone()},t.prototype.tangentPoints=function(e){var i=this,r=this._projectPointToLocalPlane(e),s=this._findSnapParameterAngles(function(a,o,c,l){var h=-i.majorAxisRadius*l,u=i.minorAxisRadius*c;return(a-r.x)*u-(o-r.y)*h});return s.map(function(a){return i.getPointAtAngle(a)})},t.prototype.perpendicularPoints=function(e){var i=this,r=this._projectPointToLocalPlane(e),s=this._findSnapParameterAngles(function(a,o,c,l){var h=i.minorAxisRadius*c,u=i.majorAxisRadius*l;return(a-r.x)*u-(o-r.y)*h});return s.map(function(a){return i.getPointAtAngle(a)})},t.prototype._projectPointToLocalPlane=function(e){var i=new b(e.x,e.y,e.z||0),r=new w(i).sub(this.center),s=r.dot(this.normal);return r.sub(this.normal.clone().multiplyScalar(s)),{x:r.dot(this.majorAxis),y:r.dot(this.minorAxis)}},t.prototype._findSnapParameterAngles=function(e,i){i===void 0&&(i=144);for(var r=this.majorAxisRadius,s=this.minorAxisRadius,a=this.startAngle,o=this.deltaAngle,c=[],l=function(v){var x=Math.cos(v),k=Math.sin(v);return e(r*x,s*k,x,k)},h=a,u=l(h),d=1;d<=i;d++){var g=a+o*d/i,p=l(g);if(Math.abs(u)<1e-10&&c.push(h),u*p<0){for(var f=h,m=g,y=0;y<32;y++){var _=(f+m)/2;l(f)*l(_)<=0?m=_:f=_}c.push((f+m)/2)}h=g,u=p}return c},t.prototype.contains=function(e){var i=new w(e).sub(this.center),r=i.dot(this.majorAxis),s=i.dot(this.minorAxis),a=r/this.majorAxisRadius,o=s/this.minorAxisRadius;return a*a+o*o<=1},t.prototype.transform=function(e){var i=e,r=this.center.clone().applyMatrix4(i),s=this.getPointAtAngle(0).clone().applyMatrix4(i),a=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(i),o=new w(s).sub(r),c=new w(a).sub(r),l=o.length(),h=c.length(),u=o.clone().normalize(),d=new w().crossVectors(o,c).normalize(),g=new w().crossVectors(d,u).normalize();g.dot(c)<0&&(d.negate(),g=new w().crossVectors(d,u).normalize());var p=function(m){var y=new w(m).sub(r),_=y.dot(u),v=y.dot(g);return M.normalizeAngle(Math.atan2(v/h,_/l))},f=this.closed?new t(r,d,u,l,h,0,V):new t(r,d,u,l,h,p(this.startPoint.clone().applyMatrix4(i)),p(this.endPoint.clone().applyMatrix4(i)));return this.center=f.center,this.normal=f.normal,this.majorAxis=f.majorAxis,this.majorAxisRadius=f.majorAxisRadius,this.minorAxisRadius=f.minorAxisRadius,this._startAngle=f._startAngle,this._endAngle=f._endAngle,this._boundingBoxNeedsUpdate=!0,this},t.prototype.copy=function(e){return this.center=e.center,this.normal=e.normal,this.majorAxis=e.majorAxis,this.majorAxisRadius=e.majorAxisRadius,this.minorAxisRadius=e.minorAxisRadius,this.startAngle=e.startAngle,this.endAngle=e.endAngle,this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this.center,this.normal,this.majorAxis,this.majorAxisRadius,this.minorAxisRadius,this.startAngle,this.endAngle)},Object.defineProperty(t.prototype,"plane",{get:function(){var e=new w(this.center).distanceTo(Ws);return new $s(this.normal,e)},enumerable:!1,configurable:!0}),t.prototype.offset=function(e){var i=this.majorAxisRadius+e,r=this.minorAxisRadius+e;return i<=0||r<=0?null:new t(this.center,this.normal,this.majorAxis,i,r,this.startAngle,this.endAngle)},t})(Zi),pg=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),zt=(function(n){pg(t,n);function t(e,i){var r=n.call(this)||this;return r._start=new L(e),r._end=new L(i),r}return Object.defineProperty(t.prototype,"startPoint",{get:function(){return this._start},set:function(e){this._start.copy(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this._end},set:function(e){this._end.copy(e),this._boundingBoxNeedsUpdate=!0},enumerable:!1,configurable:!0}),t.prototype.getPoints=function(){return[this.startPoint,this.endPoint]},Object.defineProperty(t.prototype,"length",{get:function(){return this.startPoint.distanceTo(this.endPoint)},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e=new L(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),i=new L(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new yt(e,i)},t.prototype.transform=function(e){return this._start.applyMatrix2d(e),this._end.applyMatrix2d(e),this._boundingBoxNeedsUpdate=!0,this},Object.defineProperty(t.prototype,"closed",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype.copy=function(e){return this.startPoint=e.startPoint,this.endPoint=e.endPoint,this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this._start.clone(),this._end.clone())},t.prototype.project=function(e){var i=this._end.x-this._start.x,r=this._end.y-this._start.y,s=i*i+r*r;if(s<1e-18)return this._start.clone();var a=((e.x-this._start.x)*i+(e.y-this._start.y)*r)/s;return a=Math.max(0,Math.min(1,a)),new L(this._start.x+a*i,this._start.y+a*r)},t.prototype.nearestPoint=function(e){return this.project(e)},t})(li),mg=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Vr=(function(){function n(){this.c0=0,this.c1=0,this.c2=0,this.c3=0}return n.prototype.init=function(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},n.prototype.initCatmullRom=function(t,e,i,r,s){this.init(e,i,s*(i-t),s*(r-e))},n.prototype.initNonuniformCatmullRom=function(t,e,i,r,s,a,o){var c=(e-t)/s-(i-t)/(s+a)+(i-e)/a,l=(i-e)/a-(r-e)/(a+o)+(r-i)/o;c*=a,l*=a,this.init(e,i,c,l)},n.prototype.calc=function(t){var e=t*t,i=e*t;return this.c0+this.c1*t+this.c2*e+this.c3*i},n})(),zc=(function(n){mg(t,n);function t(e,i,r,s){e===void 0&&(e=[]),i===void 0&&(i=!1),r===void 0&&(r="centripetal"),s===void 0&&(s=.5);var a=n.call(this)||this;return a.isCatmullRomCurve3d=!0,a.type="CatmullRomCurve3d",a._tmp=new w,a._px=new Vr,a._py=new Vr,a._pz=new Vr,a._points=e.map(function(o){return new b(o)}),a._closed=i,a._curveType=r,a._tension=s,a}return Object.defineProperty(t.prototype,"points",{get:function(){return this._points},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"closed",{get:function(){return this._closed},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"curveType",{get:function(){return this._curveType},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tension",{get:function(){return this._tension},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){return this._points.length>0?this._points[0]:new b},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this._points.length>0?this._points[this._points.length-1]:new b},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){if(this._points.length<2)return 0;for(var e=0,i=1;i<this._points.length;i++)e+=this._points[i-1].distanceTo(this._points[i]);return this._closed&&this._points.length>2&&(e+=this._points[this._points.length-1].distanceTo(this._points[0])),e},enumerable:!1,configurable:!0}),t.prototype.getPoint=function(e,i){i===void 0&&(i=new b);var r=i,s=this._points,a=s.length;if(a===0)return r.set(0,0,0);if(a===1)return r.copy(s[0]);var o=(a-(this._closed?0:1))*e,c=Math.floor(o),l=o-c;this._closed?c+=c>0?0:(Math.floor(Math.abs(c)/a)+1)*a:l===0&&c===a-1&&(c=a-2,l=1);var h,u;this._closed||c>0?h=s[(c-1)%a]:(this._tmp.subVectors(s[0],s[1]).add(s[0]),h=new b(this._tmp.x,this._tmp.y,this._tmp.z));var d=s[c%a],g=s[(c+1)%a];if(this._closed||c+2<a?u=s[(c+2)%a]:(this._tmp.subVectors(s[a-1],s[a-2]).add(s[a-1]),u=new b(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){var p=this._curveType==="chordal"?.5:.25,f=Math.pow(h.distanceToSquared(d),p),m=Math.pow(d.distanceToSquared(g),p),y=Math.pow(g.distanceToSquared(u),p);m<1e-4&&(m=1),f<1e-4&&(f=m),y<1e-4&&(y=m),this._px.initNonuniformCatmullRom(h.x,d.x,g.x,u.x,f,m,y),this._py.initNonuniformCatmullRom(h.y,d.y,g.y,u.y,f,m,y),this._pz.initNonuniformCatmullRom(h.z,d.z,g.z,u.z,f,m,y)}else this._curveType==="catmullrom"&&(this._px.initCatmullRom(h.x,d.x,g.x,u.x,this._tension),this._py.initCatmullRom(h.y,d.y,g.y,u.y,this._tension),this._pz.initCatmullRom(h.z,d.z,g.z,u.z,this._tension));return r.set(this._px.calc(l),this._py.calc(l),this._pz.calc(l)),r},t.prototype.getPoints=function(e){for(var i=[],r=0;r<=e;r++)i.push(this.getPoint(r/e));return i},t.prototype.setPoints=function(e){this._points=e.map(function(i){return new b(i)}),this._boundingBoxNeedsUpdate=!0},t.prototype.setClosed=function(e){this._closed!==e&&(this._closed=e,this._boundingBoxNeedsUpdate=!0)},t.prototype.setCurveType=function(e){this._curveType=e},t.prototype.setTension=function(e){this._tension=e},t.prototype.clone=function(){return new t(this._points.map(function(e){return e.clone()}),this._closed,this._curveType,this._tension)},t.prototype.transform=function(e){return this._points=this._points.map(function(i){var r=new b;return r.copy(i),r.applyMatrix4(e),r}),this._boundingBoxNeedsUpdate=!0,this},t.prototype.calculateBoundingBox=function(){if(this._points.length===0)return new Y;var e=new Y;return this._points.forEach(function(i){e.expandByPoint(i)}),e},t})(Zi),Ve=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},Ge=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))};function uo(n,t){var e,i,r=n.x-t[0],s=n.y-t[1],a=((e=n.z)!==null&&e!==void 0?e:0)-((i=t[2])!==null&&i!==void 0?i:0);return r*r+s*s+a*a}var Ct=(function(){function n(t,e,i,r){this._degree=t,this._knots=Ge([],Ve(e),!1),this._controlPoints=i.map(function(s){return{x:s.x,y:s.y,z:s.z}}),this._weights=r?Ge([],Ve(r),!1):new Array(i.length).fill(1)}return n.prototype.degree=function(){return this._degree},n.prototype.knots=function(){return Ge([],Ve(this._knots),!1)},n.prototype.controlPoints=function(){return this._controlPoints.map(function(t){return{x:t.x,y:t.y,z:t.z}})},n.prototype.weights=function(){return Ge([],Ve(this._weights),!1)},n.prototype.clone=function(){return new n(this._degree,this._knots,this._controlPoints,this._weights)},n.prototype.point=function(t){return this.evaluate(t).point},n.prototype.evaluate=function(t){var e=this._controlPoints.map(function(i){return[i.x,i.y,i.z]});return fd(t,this._degree,this._knots,e,this._weights)},n.prototype.signedPlanarCurvatureAt=function(t){var e=this.evaluate(t);return pd(e.deriv1,e.deriv2)},n.prototype.getOffsetSamplePath2d=function(t,e){var i=this;e===void 0&&(e=512);for(var r=Math.abs(t),s=this.getParameterRange(),a=s.start,o=s.end,c=this.length(),l=Math.max(64,Math.ceil(c/Math.max(r*.2,1e-6))),h=yg(a,o,Math.min(l,e)),u=0;u<8&&h.length<e;u++){for(var d=[],g=0;g<h.length-1;g++){var p=h[g],f=h[g+1],m=(p+f)/2,y=Math.max(Math.abs(this.signedPlanarCurvatureAt(p)),Math.abs(this.signedPlanarCurvatureAt(f)),Math.abs(this.signedPlanarCurvatureAt(m)));r*y>.85&&d.push(m)}if(d.length===0)break;if(h=bg(h,d),h.length>e){h=h.slice(0,e);break}}var _=[],v=[];return h.forEach(function(x){var k=i.evaluate(x);_.push(new L(k.point[0],k.point[1]));var I=k.deriv1[0],P=k.deriv1[1],C=Math.hypot(I,P);v.push(C>1e-10?new L(I/C,P/C):new L(1,0))}),{points:_,tangents:v}},n.prototype.length=function(){var t=this._controlPoints.map(function(e){return[e.x,e.y,e.z]});return Ic(this._degree,this._knots,t,this._weights)},n.byKnotsControlPointsWeights=function(t,e,i,r){return new n(t,e,i,r)},n.byPoints=function(t,e,i,r,s){i===void 0&&(i="Uniform");var a=qs(t,e,i,r,s),o=a.controlPoints.map(function(c){return{x:c[0],y:c[1],z:c[2]}});return new n(e,a.knots,o,a.weights)},n.prototype.getParameterRange=function(){var t=this._knots[this._degree],e=this._knots[this._knots.length-this._degree-1];return{start:t,end:e}},n.prototype.getPoints=function(t){for(var e=[],i=this.getParameterRange(),r=i.start,s=i.end,a=0;a<=t;a++){var o=r+(s-r)*(a/t);e.push(this.point(o))}return e},n.prototype.isClosed=function(t){t===void 0&&(t=1e-6);var e=this.getParameterRange(),i=e.start,r=e.end,s=this.point(i),a=this.point(r),o=s[0]-a[0],c=s[1]-a[1],l=s[2]-a[2];return Math.sqrt(o*o+c*c+l*l)<t},n.createFitPointsForClosedCurve=function(t){if(t.length<4)throw new Error("At least 4 points are required for a closed NURBS curve");var e=new zc(t,!0,"centripetal"),i=Math.max(50,t.length*2);return e.getPoints(i)},n.prototype.nearestPoint=function(t,e){var i;e===void 0&&(e=64);for(var r=this.getParameterRange(),s=r.start,a=r.end,o=this.point(s),c=uo(t,o),l=0;l<=e;l++){var h=s+(a-s)*l/e,u=this.point(h),d=uo(t,u);d<c&&(c=d,o=u)}return{x:o[0],y:o[1],z:(i=o[2])!==null&&i!==void 0?i:0}},n.createClosedCurve=function(t,e,i){i===void 0&&(i="Chord");var r=this.createFitPointsForClosedCurve(t),s=r.map(function(a){return[a.x,a.y,a.z]});return n.byPoints(s,e,i)},n})();function yg(n,t,e){if(e<2)return[n,t];for(var i=[],r=0;r<e;r++)i.push(r===e-1?t:n+(t-n)*r/(e-1));return i}function bg(n,t){var e=Ge(Ge([],Ve(n),!1),Ve(t),!1).sort(function(r,s){return r-s}),i=[];return e.forEach(function(r){var s=i[i.length-1];(s===void 0||Math.abs(s-r)>1e-10)&&i.push(r)}),i}function go(n){var t,e,i;if(!n)return!1;var r=(t=n.x)!==null&&t!==void 0?t:0,s=(e=n.y)!==null&&e!==void 0?e:0,a=(i=n.z)!==null&&i!==void 0?i:0;return r*r+s*s+a*a>1e-20}function _g(n,t,e){var i=n??0;return i<1&&e>0&&t>0&&(i=e-t-1),i<1&&(i=3),i=Math.min(i,t-1),Math.max(1,i)}function xg(n,t,e){var i=n??0;i<1&&(i=3);var r=t+e-1;return i=Math.min(i,r),Math.max(1,i)}function wg(n,t){if(!(!n||n.length!==t))return n}var vg=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),fo=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},po=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},mo=function(n){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&n[t],i=0;if(e)return e.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&i>=n.length&&(n=void 0),{value:n&&n[i++],done:!n}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},jt=(function(n){vg(t,n);function t(e,i,r,s,a,o){var c=n.call(this)||this,l=arguments.length;if(c._degree=3,c._closed=!1,Array.isArray(i)){if(l<2||l>5)throw Pt.ILLEGAL_PARAMETERS;c._controlPoints=e;var g=void 0,p=3,f=!1;if(l>=3&&(Array.isArray(r)?(g=r,l>=4&&(p=s||3),l>=5&&(f=a)):r!==void 0&&(p=r||3,l>=4&&(f=s))),r===void 0&&l>=4&&(p=s||3,l>=5&&(f=a)),c._degree=p,c._closed=f,c._controlPoints.length<c._degree+1)throw Pt.ILLEGAL_PARAMETERS;c._nurbsCurve=Ct.byKnotsControlPointsWeights(c._degree,i,c._controlPoints,g)}else{if(l<2||l>6)throw Pt.ILLEGAL_PARAMETERS;c._fitPoints=e,c._knotParameterization=i,l>=3&&(c._degree=r||3);var h=typeof s=="boolean";l>=4&&h&&(c._closed=s),h?(l>=5&&(c._startTangent=a),l>=6&&(c._endTangent=o)):(l>=4&&(c._startTangent=s),l>=5&&(c._endTangent=a)),c._closed&&(c._startTangent=void 0,c._endTangent=void 0);var u=(c._startTangent?1:0)+(c._endTangent?1:0);if(c._fitPoints.length+u<c._degree+1)throw Pt.ILLEGAL_PARAMETERS;if(c._closed)c._nurbsCurve=Ct.createClosedCurve(c._fitPoints,c._degree,c._knotParameterization);else{var d=c.toNurbsPoints(c._fitPoints);c._nurbsCurve=Ct.byPoints(d,c._degree,c._knotParameterization,c._startTangent?c.toNurbsPoint(c._startTangent):void 0,c._endTangent?c.toNurbsPoint(c._endTangent):void 0)}c._controlPoints=c.toGePoints(c._nurbsCurve.controlPoints().map(function(m){return[m.x,m.y,m.z||0]}))}return c}return t.prototype.buildCurve=function(){if(this._fitPoints&&this._knotParameterization){if(this._closed){var e=Ct.createFitPointsForClosedCurve(this._fitPoints),i=this.toNurbsPoints(e);this._nurbsCurve=Ct.byPoints(i,this._degree,this._knotParameterization)}else{var i=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=Ct.byPoints(i,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(function(a){return[a.x,a.y,a.z||0]}))}else if(this._controlPoints)if(this._closed){var e=Ct.createFitPointsForClosedCurve(this._controlPoints),i=this.toNurbsPoints(e);this._nurbsCurve=Ct.byPoints(i,this._degree,this._knotParameterization),this._controlPoints=this.toGePoints(this._nurbsCurve.controlPoints().map(function(c){return[c.x,c.y,c.z||0]}))}else{var r=this._nurbsCurve.knots(),s=this._nurbsCurve.weights();this._nurbsCurve=Ct.byKnotsControlPointsWeights(this._degree,r,this._controlPoints,s)}},t.prototype.setClosed=function(e){this._closed!==e&&(this._closed=e,this._boundingBoxNeedsUpdate=!0,this.buildCurve())},Object.defineProperty(t.prototype,"degree",{get:function(){return this._degree},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"knotParameterization",{get:function(){return this._knotParameterization},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"controlPoints",{get:function(){return this._controlPoints.map(wt.point2dToPoint3d)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fitPoints",{get:function(){var e;return(e=this._fitPoints)===null||e===void 0?void 0:e.map(wt.point2dToPoint3d)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"knots",{get:function(){return po([],fo(this._nurbsCurve.knots()),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"weights",{get:function(){return po([],fo(this._nurbsCurve.weights()),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){var e=this._nurbsCurve.knots(),i=this._nurbsCurve.degree(),r=e[i],s=this._nurbsCurve.point(r);return new b(s[0],s[1],s[2])},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){var e=this._nurbsCurve.knots(),i=this._nurbsCurve.degree(),r=e[e.length-i-1],s=this._nurbsCurve.point(r);return new b(s[0],s[1],s[2])},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){return this._nurbsCurve.length()},enumerable:!1,configurable:!0}),t.prototype.nearestPoint=function(e,i){i===void 0&&(i=64);var r=this._nurbsCurve.nearestPoint(e,i);return new b(r.x,r.y,r.z||0)},t.prototype.evaluateAt=function(e){var i=this._nurbsCurve.point(e);return new b(i[0],i[1],i[2])},t.prototype.getFitPointAt=function(e){if(!this._fitPoints)throw new Error("No fit points in this spline");var i=this._fitPoints.length,r=e<0||e>=i?i-1:e,s=this._fitPoints[r];return wt.point2dToPoint3d(s)},t.prototype.getControlPointAt=function(e){var i=this._controlPoints.length,r=e<0||e>=i?i-1:e;return this._controlPoints[r]},Object.defineProperty(t.prototype,"isFitPointSpline",{get:function(){return!!(this._fitPoints&&this._fitPoints.length>0&&this._knotParameterization)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isControlPointSpline",{get:function(){return!this.isFitPointSpline},enumerable:!1,configurable:!0}),t.prototype.getGripPoints=function(){return this.isFitPointSpline?this._fitPoints.map(function(e){var i;return new b(e.x,e.y,(i=e.z)!==null&&i!==void 0?i:0)}):this._controlPoints.map(function(e){var i;return new b(e.x,e.y,(i=e.z)!==null&&i!==void 0?i:0)})},t.prototype.moveGripPointsAt=function(e,i){return this.isFitPointSpline?(this.moveFitPointsAt(e,i),this):(this.moveControlPointsAt(e,i),this)},t.prototype.moveFitPointsAt=function(e,i){var r,s;if(this._fitPoints){try{for(var a=mo(e),o=a.next();!o.done;o=a.next()){var c=o.value;if(!(!Number.isInteger(c)||c<0)){var l=this._fitPoints[c];l&&wt.applyOffsetToPoint3d(l,i)}}}catch(h){r={error:h}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(r)throw r.error}}this._boundingBoxNeedsUpdate=!0,this.buildCurve()}},t.prototype.moveControlPointsAt=function(e,i){var r,s;try{for(var a=mo(e),o=a.next();!o.done;o=a.next()){var c=o.value;if(!(!Number.isInteger(c)||c<0)){var l=this.getControlPointAt(c);l&&wt.applyOffsetToPoint3d(l,i)}}}catch(h){r={error:h}}finally{try{o&&!o.done&&(s=a.return)&&s.call(a)}finally{if(r)throw r.error}}this.rebuildAfterControlPointMutation()},t.prototype.rebuildAfterControlPointMutation=function(){var e=this._nurbsCurve.knots(),i=this._nurbsCurve.weights();this.isFitPointSpline&&(this._fitPoints=void 0,this._knotParameterization=void 0,this._startTangent=void 0,this._endTangent=void 0),this._nurbsCurve=Ct.byKnotsControlPointsWeights(this._degree,e,this._controlPoints,i.length>0?i:void 0),this._boundingBoxNeedsUpdate=!0},t.prototype.getOffsetSamplePath2d=function(e){return this._nurbsCurve.getOffsetSamplePath2d(e)},t.prototype.getPoints=function(e){e===void 0&&(e=100);for(var i=this._nurbsCurve,r=[],s=i.knots(),a=this._nurbsCurve.degree(),o=s[a],c=s[s.length-a-1],l=(c-o)/(e-1),h=0;h<e;h++){var u=h===e-1?c:o+h*l,d=i.point(u);r.push(new b(d[0],d[1],d[2]))}return r},t.prototype.getCurvePoints=function(e,i){for(var r=[],s=e.knots(),a=e.degree(),o=s[a],c=s[s.length-a-1],l=(c-o)/(i-1),h=0;h<i;h++){var u=o+h*l;r.push(e.point(u))}return r},t.prototype.calculateBoundingBox=function(){var e=this.getPoints(100);return new Y().setFromPoints(e)},Object.defineProperty(t.prototype,"closed",{get:function(){return this._closed},set:function(e){this.setClosed(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"area",{get:function(){if(!this._closed)return 0;var e=this.getPoints(128);return Tc(e)},enumerable:!1,configurable:!0}),t.prototype.transform=function(e){if(this._fitPoints&&this._knotParameterization)this._fitPoints=this._fitPoints.map(function(s){return new b(s).applyMatrix4(e)}),this._startTangent&&(this._startTangent=new b(this._startTangent).transformDirection(e)),this._endTangent&&(this._endTangent=new b(this._endTangent).transformDirection(e)),this.buildCurve();else{var i=this._nurbsCurve.knots(),r=this._nurbsCurve.weights();this._controlPoints=this._controlPoints.map(function(s){return new b(s).applyMatrix4(e)}),this._nurbsCurve=Ct.byKnotsControlPointsWeights(this._degree,i,this._controlPoints,r.length>0?r:void 0)}return this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return this._fitPoints&&this._knotParameterization?new t(this._fitPoints.map(wt.point2dToPoint3d),this._knotParameterization,this._degree,this._closed,this._startTangent?wt.point2dToPoint3d(this._startTangent):void 0,this._endTangent?wt.point2dToPoint3d(this._endTangent):void 0):new t(this._controlPoints.map(wt.point2dToPoint3d),this._nurbsCurve.knots(),this._nurbsCurve.weights(),this._degree,this._closed)},t.prototype.toNurbsPoints=function(e){var i=new Array(e.length);return e.forEach(function(r,s){i[s]=[r.x,r.y,r.z||0]}),i},t.prototype.toGePoints=function(e){var i=new Array(e.length);return e.forEach(function(r,s){i[s]={x:r[0],y:r[1],z:r[2]}}),i},t.prototype.toNurbsPoint=function(e){return[e.x,e.y,e.z||0]},t.createClosedSpline=function(e,i,r){if(i===void 0&&(i="Uniform"),r===void 0&&(r=3),e.length<r+1)throw new Error("At least ".concat(r+1," points are required for a degree ").concat(r," closed spline"));return new t(e,i,r,!0)},t.fromControlPoints=function(e,i,r,s,a){if(e.length<2||i.length<2)return null;var o=_g(s,e.length,i.length);if(e.length<o+1)return null;try{return new t(e,i,wg(r,e.length),o,a)}catch{return null}},t.fromFitPoints=function(e,i,r,s,a,o){if(e.length<2)return null;var c=go(a),l=go(o),h=(c?1:0)+(l?1:0),u=xg(r,e.length,h);if(e.length+h<u+1)return null;try{return c||l?new t(e,i,u,s,c?a:void 0,l?o:void 0):new t(e,i,u,s)}catch{return null}},t.fromDwgSplineEdge=function(e){if(e.numberOfControlPoints>0&&e.numberOfKnots>0){var i=e.controlPoints.map(wt.point2dToPoint3d),r=!0,s=e.controlPoints.map(function(o){return o.weight==null&&(r=!1),o.weight||1});return t.fromControlPoints(i,e.knots,r?s:void 0,e.degree,!1)}if(e.numberOfFitData>0){var a=e.fitDatum.map(wt.point2dToPoint3d);return t.fromFitPoints(a,"Uniform",e.degree,!1,e.startTangent?wt.point2dToPoint3d(e.startTangent):void 0,e.endTangent?wt.point2dToPoint3d(e.endTangent):void 0)}return null},t})(Zi),kg=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Gr=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],a;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(o){a={error:o}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(a)throw a.error}}return s},Ur=function(n,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,s;i<r;i++)(s||!(i in t))&&(s||(s=Array.prototype.slice.call(t,0,i)),s[i]=t[i]);return n.concat(s||Array.prototype.slice.call(t))},xi=(function(n){kg(t,n);function t(e){e===void 0&&(e=[]);var i=n.call(this)||this;return i._curves=e,i}return Object.defineProperty(t.prototype,"curves",{get:function(){return this._curves},enumerable:!1,configurable:!0}),t.buildFromEdges=function(e,i){if(i===void 0&&(i=.001),e.length===0)return[];for(var r=Ur([],Gr(e),!1),s=[],a=i*i,o=function(p,f){var m=p.x-f.x,y=p.y-f.y;return m*m+y*y<=a};r.length>0;){var c=[],l=r.shift();c.push(l);var h=t.getEdgeStartPoint(l),u=t.getEdgeEndPoint(l);if(!o(h,u))for(;r.length>0;){var d=t.findConnectingEdge(r,u,a);if(d.index<0)break;var g=r.splice(d.index,1)[0];if(d.reverse&&(g=t.reverseEdge(g)),c.push(g),u=t.getEdgeEndPoint(g),o(u,h))break}s.push(new t(c))}return s},t.prototype.add=function(e){this._curves.push(e),this._boundingBoxNeedsUpdate=!0},Object.defineProperty(t.prototype,"numberOfEdges",{get:function(){return this._curves.length},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"startPoint",{get:function(){if(this._curves.length>0){var e=this._curves[0].startPoint;return new L(e.x,e.y)}throw new Error("Start point does not exist in an empty loop.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this.startPoint},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"length",{get:function(){var e=0;return this._curves.forEach(function(i){e+=i.length}),e},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e=this.getPoints(100),i=new yt;return i.setFromPoints(e),i},t.prototype.transform=function(e){var i=new D().set(e.elements[0],e.elements[3],0,e.elements[6],e.elements[1],e.elements[4],0,e.elements[7],0,0,1,0,0,0,0,1);return this._curves.forEach(function(r){r instanceof jt?r.transform(i):r.transform(e)}),this._boundingBoxNeedsUpdate=!0,this},t.prototype.clone=function(){return new t(this._curves.map(function(e){return e.clone()}))},Object.defineProperty(t.prototype,"closed",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype.getPoints=function(e){var i=[];return this.curves.forEach(function(r){r.getPoints(e).forEach(function(s){i.push(new L(s.x,s.y))})}),i},t.findConnectingEdge=function(e,i,r){for(var s=-1,a=!1,o=Number.POSITIVE_INFINITY,c=0;c<e.length;c++){var l=e[c],h=t.getEdgeStartPoint(l),u=t.getEdgeEndPoint(l),d=i.x-h.x,g=i.y-h.y,p=d*d+g*g;p<o&&(o=p,s=c,a=!1);var f=i.x-u.x,m=i.y-u.y,y=f*f+m*m;y<o&&(o=y,s=c,a=!0)}return o>r?{index:-1,reverse:!1}:{index:s,reverse:a}},t.getEdgeStartPoint=function(e){var i=e.startPoint;return new L(i.x,i.y)},t.getEdgeEndPoint=function(e){var i=e.endPoint;return new L(i.x,i.y)},t.reverseEdge=function(e){return e instanceof zt?new zt(e.endPoint,e.startPoint):e instanceof vt?t.reverseCircArcEdge(e):e instanceof be?new be(e.center,e.majorAxisRadius,e.minorAxisRadius,e.endAngle,e.startAngle,!e.clockwise,e.rotation):e instanceof jt?t.reverseSplineEdge(e):e},t.reverseCircArcEdge=function(e){var i=e.startPoint,r=e.endPoint,s=!e.clockwise,a=Math.atan2(r.y-e.center.y,r.x-e.center.x),o=Math.atan2(i.y-e.center.y,i.x-e.center.x),c=function(l){var h=M.normalizeAngle(l);return s?M.normalizeAngle(-h):h};return new vt(e.center,e.radius,c(a),c(o),s)},t.reverseSplineEdge=function(e){var i=Ur([],Gr(e.controlPoints),!1).reverse(),r=e.knots,s=r[0],a=r[r.length-1],o=r.map(function(h){return s+a-h}).reverse(),c=e.weights,l=c.length>0?Ur([],Gr(c),!1).reverse():void 0;return new jt(i,o,l,e.degree,e.closed)},t})(li);const yo=[{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 pt{constructor(t){if(typeof t=="string"){const e=yo.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=yo.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")}get capabilities(){return pt.capabilitiesFor(this.value)}static get latest(){return new pt("AC1032")}static capabilitiesFor(t){const e=t>=19;return{supportsHandles:e,supportsSubclassMarkers:e,supportsClassesSection:e,supportsObjectsSection:e,supportsBlockRecordTable:e,supportsLwPolyline:e,supportsLineWeight:t>=23,supportsTrueColor:t>=25,supportsTransparency:t>=25,supportsUtf8CodePage:t>=27}}}function Qi(n){return n===999?"comment":n===5?"handle":n<=9||n===100||n===102?"string":n===105?"handle":n>=101&&n<=109?"string":n<=59?"double":n<=79?"int":n<=89?"string":n<=99?"int":n<=149?"double":n<=159?"string":n<=169?"long":n<=179?"int":n<=209?"string":n<=239?"double":n<=269?"long":n<=289?"int":n<=299?"bool":n<=309?"string":n<=319?"binary":n<=369?"handle":n<=389?"int":n<=399?"handle":n<=409?"int":n<=419?"string":n<=429?"int":n<=439?"string":n<=449||n<=459?"int":n<=469?"double":n<=479?"string":n===480||n===481?"handle":n===1004?"binary":n===1005?"handle":n>=1e3&&n<=1009?"string":n>=1010&&n<=1059?"double":n>=1060&&n<=1070||n===1071?"int":"string"}function jc(n){return n>=90&&n<=99||n>=420&&n<=429||n>=440&&n<=449||n>=450&&n<=459||n===1071}var Zs=(n=>(n[n.UTF8=0]="UTF8",n[n.US_ASCII=1]="US_ASCII",n[n.ISO_8859_1=2]="ISO_8859_1",n[n.ISO_8859_2=3]="ISO_8859_2",n[n.ISO_8859_3=4]="ISO_8859_3",n[n.ISO_8859_4=5]="ISO_8859_4",n[n.ISO_8859_5=6]="ISO_8859_5",n[n.ISO_8859_6=7]="ISO_8859_6",n[n.ISO_8859_7=8]="ISO_8859_7",n[n.ISO_8859_8=9]="ISO_8859_8",n[n.ISO_8859_9=10]="ISO_8859_9",n[n.CP437=11]="CP437",n[n.CP850=12]="CP850",n[n.CP852=13]="CP852",n[n.CP855=14]="CP855",n[n.CP857=15]="CP857",n[n.CP860=16]="CP860",n[n.CP861=17]="CP861",n[n.CP863=18]="CP863",n[n.CP864=19]="CP864",n[n.CP865=20]="CP865",n[n.CP869=21]="CP869",n[n.CP932=22]="CP932",n[n.MACINTOSH=23]="MACINTOSH",n[n.BIG5=24]="BIG5",n[n.CP949=25]="CP949",n[n.JOHAB=26]="JOHAB",n[n.CP866=27]="CP866",n[n.ANSI_1250=28]="ANSI_1250",n[n.ANSI_1251=29]="ANSI_1251",n[n.ANSI_1252=30]="ANSI_1252",n[n.GB2312=31]="GB2312",n[n.ANSI_1253=32]="ANSI_1253",n[n.ANSI_1254=33]="ANSI_1254",n[n.ANSI_1255=34]="ANSI_1255",n[n.ANSI_1256=35]="ANSI_1256",n[n.ANSI_1257=36]="ANSI_1257",n[n.ANSI_874=37]="ANSI_874",n[n.ANSI_932=38]="ANSI_932",n[n.ANSI_936=39]="ANSI_936",n[n.ANSI_949=40]="ANSI_949",n[n.ANSI_950=41]="ANSI_950",n[n.ANSI_1361=42]="ANSI_1361",n[n.UTF16=43]="UTF16",n[n.ANSI_1258=44]="ANSI_1258",n[n.UNDEFINED=255]="UNDEFINED",n))(Zs||{});const Ag=["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"],Vc=n=>Ag[n],Hr=(()=>{const n=`AutoCAD Binary DXF\r
2
+ `,t=new Uint8Array(22);for(let e=0;e<n.length;e++)t[e]=n.charCodeAt(e);return t[20]=26,t[21]=0,t})(),bo=(()=>{const n=new Int8Array(128);for(let t=0;t<10;t++)n[48+t]=t;for(let t=0;t<6;t++)n[65+t]=10+t,n[97+t]=10+t;return n})();function Gc(n){if(n.length<Hr.length)return!1;for(let t=0;t<Hr.length;t++)if(n[t]!==Hr[t])return!1;return!0}function Uc(n){var c,l,h;const e=new TextDecoder("utf-8");let i=0,r="",s=null,a=null,o=!1;for(;i<n.byteLength;){const u=Math.min(i+65536,n.byteLength),d=n.slice(i,u);i=u;const p=(r+e.decode(d,{stream:!0})).split(/\r?\n/);r=p.pop()??"";for(let f=0;f<p.length;f++){const m=p[f].trim();if(m==="SECTION"&&((c=p[f+2])==null?void 0:c.trim())==="HEADER")o=!0;else if(m==="ENDSEC"&&o)return{version:s,encoding:a};if(o&&m==="$ACADVER"){const y=(l=p[f+2])==null?void 0:l.trim();y&&(s=new pt(y))}else if(o&&m==="$DWGCODEPAGE"){const y=(h=p[f+2])==null?void 0:h.trim();if(y){const _=Zs[y];a=Vc(_)}}if(s&&a)return{version:s,encoding:a}}}return{version:s,encoding:a}}function Sg(n){const t=n.trim(),e=t.length>>>1,i=new Uint8Array(e);for(let r=0;r<e;r++){const s=bo[t.charCodeAt(r*2)&127],a=bo[t.charCodeAt(r*2+1)&127];i[r]=s<<4|a}return i}function Hc(n,t){const e=Qi(n);if(e==="comment")return null;switch(e){case"string":return{code:n,type:e,value:t};case"int":{const i=parseInt(t.trim(),10);return{code:n,type:e,value:Number.isFinite(i)?i:0}}case"long":{const i=t.trim(),r=Number(i);if(Number.isSafeInteger(r))return{code:n,type:e,value:r};try{return{code:n,type:e,value:BigInt(i)}}catch{return{code:n,type:e,value:0}}}case"double":{const i=Number(t.trim());return{code:n,type:e,value:Number.isFinite(i)?i:0}}case"bool":{const i=t.trim();return{code:n,type:e,value:i!=="0"&&i!==""}}case"handle":return{code:n,type:e,value:t.trim()};case"binary":return{code:n,type:e,value:Sg(t)};default:return null}}function Qs(n){let t=0,e=1,i,r=!1;function s(){if(t>=n.length)return;let o=t;for(;o<n.length;){const l=n.charCodeAt(o);if(l===10||l===13)break;o++}const c=n.slice(t,o);return o<n.length&&n.charCodeAt(o)===13&&o++,o<n.length&&n.charCodeAt(o)===10&&o++,t=o,e++,c}function a(){for(;;){const o=s();if(o===void 0)return;const c=o.trim();if(c==="")continue;const l=s();if(l===void 0)return;const h=Number(c);if(!Number.isFinite(h)||h===999)continue;const u=Hc(h,l);if(u)return u}}return{kind:"ascii",next(){if(r){const o=i;return i=void 0,r=!1,o}return a()},peek(){return r||(i=a(),r=!0),i},position(){return{line:e,byteOffset:t}}}}function Pg(n){const t=n.toLowerCase().replace(/_/g,"-");return t==="utf-8"||t==="utf8"||t==="unicode-1-1-utf-8"}const Ig=64*1024;function Wc(n){const t=n.length>=3&&n[0]===239&&n[1]===187&&n[2]===191?3:0;let e=1,i,r=!1;const s=new TextDecoder("utf-8");let a=t,o=t,c="",l=0;function h(){if(o>=n.length)return!1;a=o;let g=Math.min(a+Ig,n.length);for(;g<n.length&&n[g]!==10&&n[g]!==13;)g++;return g<n.length&&n[g]===13&&g++,g<n.length&&n[g]===10&&g++,o=g,c=s.decode(n.subarray(a,o)),l=0,!0}function u(){for(;l>=c.length;)if(!h())return;let g=l;for(;g<c.length;){const f=c.charCodeAt(g);if(f===10||f===13)break;g++}const p=c.slice(l,g);return g<c.length&&c.charCodeAt(g)===13&&g++,g<c.length&&c.charCodeAt(g)===10&&g++,l=g,e++,p}function d(){for(;;){const g=u();if(g===void 0)return;const p=g.trim();if(p==="")continue;const f=u();if(f===void 0)return;const m=Number(p);if(!Number.isFinite(m)||m===999)continue;const y=Hc(m,f);if(y)return y}}return{kind:"ascii",next(){if(r){const g=i;return i=void 0,r=!1,g}return d()},peek(){return r||(i=d(),r=!0),i},position(){const g=o-a,p=g>0&&c.length>0?a+Math.round(l/c.length*g):o;return{line:e,byteOffset:p}}}}function Eg(n){const t=BigInt(Number.MAX_SAFE_INTEGER),e=-t;return n>=e&&n<=t?Number(n):n}function $c(n,t={}){const e=t.encoding??"utf-8",i=t.legacyR12??!1,r=22,s=new DataView(n.buffer,n.byteOffset,n.byteLength);let a=n.length>=r?r:n.length,o,c=!1;function l(){if(a>=n.length)return;if(i){const v=n[a];if(v===void 0)return;if(v===255){if(a+3>n.length)return;a+=1;const x=n[a],k=n[a+1];return a+=2,k<<8|x}return a+=1,v}if(a+2>n.length)return;const _=s.getUint16(a,!0);return a+=2,_}function h(){const _=a;for(;a<n.length&&n[a]!==0;)a+=1;if(a>=n.length)return;const v=n.subarray(_,a);return a+=1,new TextDecoder(e).decode(v)}function u(){if(a+2>n.length)return;const _=s.getInt16(a,!0);return a+=2,_}function d(){if(a+4>n.length)return;const _=s.getInt32(a,!0);return a+=4,_}function g(){if(a+8>n.length)return;const _=s.getBigInt64(a,!0);return a+=8,Eg(_)}function p(){if(a+8>n.length)return;const _=s.getFloat64(a,!0);return a+=8,_}function f(){if(a>=n.length)return;const _=n[a];if(_!==void 0)return a+=1,_!==0}function m(){if(a>=n.length)return;const _=n[a];if(_===void 0||(a+=1,a+_>n.length))return;const v=n.slice(a,a+_);return a+=_,v}function y(){for(;a<n.length;){const _=l();if(_===void 0)return;if(_===999){if(h()===void 0)return;continue}switch(Qi(_)){case"string":{const x=h();return x===void 0?void 0:{code:_,type:"string",value:x}}case"int":{const x=jc(_)?d():u();return x===void 0?void 0:{code:_,type:"int",value:x}}case"long":{const x=g();return x===void 0?void 0:{code:_,type:"long",value:x}}case"double":{const x=p();return x===void 0?void 0:{code:_,type:"double",value:x}}case"bool":{const x=f();return x===void 0?void 0:{code:_,type:"bool",value:x}}case"handle":{const x=h();return x===void 0?void 0:{code:_,type:"handle",value:x}}case"binary":{const x=m();return x===void 0?void 0:{code:_,type:"binary",value:x}}case"comment":continue;default:h();continue}}}return{kind:"binary",next(){if(c){const _=o;return o=void 0,c=!1,_}return y()},peek(){return c||(o=y(),c=!0),o},position(){return{byteOffset:a}}}}function qc(n,t={}){const e=n instanceof Uint8Array?n:new Uint8Array(n);if(Gc(e)){let a=t.encoding,o=t.legacyR12;if((a==null||o==null)&&(a=a??"utf-8",o==null)){const l=e[22],h=e[23],u=e[24];l===0&&h===83?o=!0:o=!1}return $c(e,{encoding:a,legacyR12:o})}const i=e.byteOffset===0&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);let r=t.encoding;if(r==null){const a=Uc(i);a.version&&!a.version.capabilities.supportsUtf8CodePage&&a.encoding?r=a.encoding:r="utf-8"}if(Pg(r))return Wc(e);const s=new TextDecoder(r).decode(e);return Qs(s)}const mi=250,Kc=255,Zc=127;function Qc(n){const t=n??"";if(t.length<=mi)return[{code:1,value:t}];const e=[];let i=0;for(;t.length-i>mi;)e.push({code:3,value:t.slice(i,i+mi)}),i+=mi;return e.push({code:1,value:t.slice(i)}),e}function Jc(n,t){if(t<=0)return[n??""];const e=n??"";if(e.length===0)return[""];const i=new TextEncoder,r=[];let s="",a=0;for(const o of e){const c=i.encode(o).byteLength;if(c>t){s.length>0&&(r.push(s),s="",a=0),r.push(o);continue}a+c>t&&s.length>0?(r.push(s),s=o,a=c):(s+=o,a+=c)}return s.length>0&&r.push(s),r}function tl(n,t){if(t<=0)return[n];if(n.byteLength===0)return[n];const e=[];for(let i=0;i<n.byteLength;i+=t)e.push(n.subarray(i,i+t));return e}var el=(n=>(n[n.Ok=0]="Ok",n[n.EndOfFile=1]="EndOfFile",n[n.EndOfObject=2]="EndOfObject",n[n.InvalidDxfCode=3]="InvalidDxfCode",n[n.BadDxfSequence=4]="BadDxfSequence",n[n.NotThatKindOfClass=5]="NotThatKindOfClass",n[n.WrongMode=6]="WrongMode",n))(el||{});const Lg=(()=>{const n=`AutoCAD Binary DXF\r
3
+ `,t=new Uint8Array(22);for(let e=0;e<n.length;e++)t[e]=n.charCodeAt(e);return t[20]=26,t[21]=0,t})();class ve{constructor(t={}){this._binaryLength=0,this._pushed=[],this._status=0,this._errorMessage="",this._database=t.database,this._precision=Math.max(0,Math.min(16,t.precision??16)),this._version=t.version instanceof pt?t.version:t.version!=null?new pt(t.version):void 0,this._outputFormat=t.outputFormat??"ascii",this._lines=[],this._binaryChunks=[],this._handleMap=new Map,this._nextHandle=1,this._mode=t.reader?"read":"write",this._reader=t.reader,this._mode==="write"&&this._outputFormat==="binary"&&this.appendBinary(Lg)}static forReading(t,e={}){return new ve({...e,reader:t})}static fromBuffer(t,e={}){return ve.forReading(qc(t),e)}static fromString(t,e={}){return ve.forReading(Qs(t),e)}get mode(){return this._mode}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}get filerStatus(){return this._status}get errorMessage(){return this._errorMessage}setVersion(t){return this._version=t instanceof pt?t:new pt(t),this}setError(t,e=""){return this._status=t,this._errorMessage=e,this}resetStatus(){return this._status=0,this._errorMessage="",this}toString(){if(this.assertWriteMode(),this._outputFormat==="binary")throw new Error("Use toBinary() for binary DXF output");return this._lines.join(`
4
4
  `)+`
5
- `}toBinary(){if(this.assertWriteMode(),this._outputFormat!=="binary")throw new Error("Filer is not in binary output mode");const t=new Uint8Array(this._binaryLength);let e=0;for(const i of this._binaryChunks)t.set(i,e),e+=i.length;return t}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)}get atEof(){var t;return this._mode!=="read"||this._pushed.length>0?!1:((t=this._reader)==null?void 0:t.peek())===void 0}position(){return this._mode!=="read"||!this._reader?{byteOffset:0}:this._reader.position()}get atEndOfObject(){if(this._mode!=="read")return!0;const t=this.peekPair();return t===void 0||t.code===0}get atExtendedData(){if(this._mode!=="read")return!1;const t=this.peekPair();return t?t.code===1001||t.code===1e3||t.code===1002:!1}atSubclassData(t){if(this._mode!=="read")return!1;const e=this.peekPair();return!e||e.code!==100||typeof e.value!="string"||e.value!==t?!1:(this.readPair(),!0)}peekItem(){const t=this.peekPair();return t?this.pairToTypedValue(t):void 0}readItem(){const t=this.readPair();if(!t){this._status=1;return}return this._status=0,this.pairToTypedValue(t)}pushBackItem(t){if(t&&"type"in t){this._pushed.push(t);return}if(t){this._pushed.push(this.typedValueToPair(t));return}this._lastRead&&this._pushed.push(this._lastRead)}skipToEndOfObject(){for(;!this.atEndOfObject&&!this.atEof;)this.readPair()}readString(t){const e=this.readPair();if(e){if(t!=null&&e.code!==t){this.pushBackPair(e),this.setError(3,`Expected group code ${t}, got ${e.code}`);return}return e.type==="string"||e.type==="handle"?e.value:String(e.value)}}readInt16(t){return this.readNumber(t)}readInt32(t){return this.readNumber(t)}readInt64(t){const e=this.readPair();if(!e)return;if(t!=null&&e.code!==t){this.pushBackPair(e),this.setError(3,`Expected group code ${t}, got ${e.code}`);return}if(e.type==="long"||e.type==="int"||e.type==="double")return e.value;if(e.type==="bool")return e.value?1:0;const i=Number(e.value);return Number.isFinite(i)?i:0}readDouble(t){return this.readNumber(t)}readBoolean(t){const e=this.readPair();if(e){if(t!=null&&e.code!==t){this.pushBackPair(e),this.setError(3,`Expected group code ${t}, got ${e.code}`);return}return e.type==="bool"?e.value:typeof e.value=="number"?e.value!==0:typeof e.value=="string"?e.value!=="0"&&e.value!=="":!!e.value}}readHandle(t){const e=this.readPair();if(e){if(t!=null&&e.code!==t){this.pushBackPair(e),this.setError(3,`Expected group code ${t}, got ${e.code}`);return}return e.type==="handle"||e.type==="string"?e.value:String(e.value)}}readObjectId(t){return this.readHandle(t)}readPoint2d(t){const e=this.readDouble(t);if(e===void 0)return;const i=this.peekPair();let r=0;return i&&i.code===t+10&&(r=this.readNumber()??0),new L(e,r)}readPoint3d(t){const e=this.readDouble(t);if(e===void 0)return;let i=0,r=0;const s=this.peekPair();s&&s.code===t+10&&(i=this.readNumber()??0);const a=this.peekPair();return a&&a.code===t+20&&(r=this.readNumber()??0),new y(e,i,r)}readVector3d(t){const e=this.readPoint3d(t);return e?new w(e.x,e.y,e.z):void 0}readCmColorInto(t,e=62,i=420){const r=this.peekPair();if(!r)return!1;if(r.code===e){const s=this.readNumber();return s!=null&&(t.colorIndex=s),!0}if(r.code===i){const s=this.readNumber();return s!=null&&t.setRGBValue(s),!0}return!1}writeGroup(t,e){if(this.assertWriteMode(),e==null)return this;if(this._outputFormat==="binary")return this.writeBinaryGroup(t,e);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)}get capabilities(){return(this._version??pt.latest).capabilities}writeSubclassMarker(t){return this.capabilities.supportsSubclassMarkers?this.writeString(100,t):this}writeString(t,e){return!e&&e!==""?this:this.writeGroup(t,e)}writeMTextContents(t){for(const e of Vc(t??""))this.writeString(e.code,e.value);return this}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){if(!this.capabilities.supportsHandles)return this;const i=this.resolveHandle(e);return i?this.writeString(t,i):this}writeObjectId(t,e){return this.writeHandle(t,e)}writeLineWeight(t,e){return e==null||!this.capabilities.supportsLineWeight?this:this.writeInt16(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 s=t.RGB;return s!=null&&t.colorIndex==null&&(this.capabilities.supportsTrueColor?this.writeInt32(i,s):this.writeInt16(e,7)),this}writeTransparency(t,e=440){return!t||t.method===exports.AcCmTransparencyMethod.ErrorValue||!this.capabilities.supportsTransparency?this:this.writeInt32(e,t.serialize())}writeResultBuffer(t){if(!t)return this;for(const e of t){const i=Number(e.code);if(i===1e3&&typeof e.value=="string"){for(const r of Gc(e.value,zc))this.writeGroup(1e3,r);continue}if(i===1004){const r=e.value instanceof Uint8Array?e.value:typeof e.value=="string"?yg(e.value):void 0;if(r){for(const s of Uc(r,jc))this._outputFormat==="binary"?this.writeGroup(1004,s):this.writeGroup(1004,ho(s));continue}}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}assertWriteMode(){if(this._mode!=="write")throw new Error("AcDbDxfFiler is in read mode")}appendBinary(t){this._binaryChunks.push(t),this._binaryLength+=t.length}writeBinaryCode(t){const e=Math.trunc(t)&65535;if(!this.capabilities.supportsSubclassMarkers){e<=255?this.appendBinary(Uint8Array.of(e)):this.appendBinary(Uint8Array.of(255,e&255,e>>8&255));return}const r=new Uint8Array(2);new DataView(r.buffer).setUint16(0,e,!0),this.appendBinary(r)}writeBinaryGroup(t,e){const i=Wi(Math.trunc(t));switch(this.writeBinaryCode(Math.trunc(t)),i){case"string":case"handle":{const r=typeof e=="string"?this.sanitizeStringForDxfLine(e):this.formatValue(e),s=new TextEncoder().encode(r===""?"0":r),a=new Uint8Array(s.length+1);a.set(s),a[s.length]=0,this.appendBinary(a);break}case"int":{const r=Math.trunc(Number(e))||0;if(Oc(Math.trunc(t))){const s=new Uint8Array(4);new DataView(s.buffer).setInt32(0,r,!0),this.appendBinary(s)}else{const s=new Uint8Array(2);new DataView(s.buffer).setInt16(0,r,!0),this.appendBinary(s)}break}case"long":{const r=new Uint8Array(8),s=new DataView(r.buffer);typeof e=="bigint"?s.setBigInt64(0,e,!0):s.setBigInt64(0,BigInt(Math.trunc(Number(e))||0),!0),this.appendBinary(r);break}case"double":{const r=new Uint8Array(8),s=Number(e);new DataView(r.buffer).setFloat64(0,Number.isFinite(s)?s:0,!0),this.appendBinary(r);break}case"bool":{const r=typeof e=="boolean"?e:Number(e)!==0&&e!==""&&e!=null;this.appendBinary(Uint8Array.of(r?1:0));break}case"binary":{const r=e instanceof Uint8Array?e:new Uint8Array(0),s=Math.min(255,r.length),a=new Uint8Array(1+s);a[0]=s,a.set(r.subarray(0,s),1),this.appendBinary(a);break}default:{const r=this.formatValue(e),s=new TextEncoder().encode(r===""?"0":r),a=new Uint8Array(s.length+1);a.set(s),a[s.length]=0,this.appendBinary(a);break}}return this}assertReadMode(){if(this._mode!=="read"||!this._reader)throw new Error("AcDbDxfFiler is not in read mode")}peekPair(){return this.assertReadMode(),this._pushed.length>0?this._pushed[this._pushed.length-1]:this._reader.peek()}readPair(){if(this.assertReadMode(),this._pushed.length>0){const e=this._pushed.pop();return this._lastRead=e,e}const t=this._reader.next();return this._lastRead=t,t}pushBackPair(t){this._pushed.push(t)}readNumber(t){const e=this.readPair();if(!e)return;if(t!=null&&e.code!==t){this.pushBackPair(e),this.setError(3,`Expected group code ${t}, got ${e.code}`);return}if(e.type==="double"||e.type==="int"||e.type==="long"){const r=e.value;return typeof r=="bigint"?Number(r):r}if(e.type==="bool")return e.value?1:0;const i=Number(e.value);return Number.isFinite(i)?i:0}pairToTypedValue(t){return{code:t.code,value:t.value}}typedValueToPair(t){const e=Number(t.code),i=t.value;return typeof i=="boolean"?{code:e,type:"bool",value:i}:typeof i=="number"?Number.isInteger(i)?{code:e,type:"int",value:i}:{code:e,type:"double",value:i}:typeof i=="bigint"?{code:e,type:"long",value:i}:i instanceof Uint8Array?{code:e,type:"binary",value:i}:{code:e,type:"string",value:String(i??"")}}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 t instanceof Uint8Array?ho(t):String(t)}sanitizeStringForDxfLine(t){return t.replace(/\r\n|\r|\n/g," ").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,"")}}function ho(n){let t="";for(let e=0;e<n.length;e++)t+=(n[e]??0).toString(16).padStart(2,"0").toUpperCase();return t}function yg(n){const t=n.replace(/\s+/g,""),e=t.length>>>1,i=new Uint8Array(e);for(let r=0;r<e;r++)i[r]=Number.parseInt(t.slice(r*2,r*2+2),16)||0;return i}var Te=256,Wc=[],uo=256,cn;for(;Te--;)Wc[Te]=(Te+256).toString(16).substring(1);function bg(n){var t=0,e=11;if(!cn||Te+e>uo*2)for(cn="",Te=0;t<uo;t++)cn+=Wc[Math.random()*256|0];return cn.substring(Te,Te+++e)}class Oe{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 Oe(this._values)}[Symbol.iterator](){return this._values[Symbol.iterator]()}}const be="TEMP_";let Ne;function $c(n){Ne=n}function qc(n){Ne&&(Ne().workingDatabase=n)}function Kc(){if(Ne)return Ne().workingDatabase;throw new Error("The current working database must be set before using it!")}const Wt=class Wt{constructor(t,e){t=t||{},this._attrs=new rs(t,e),this._xDataMap=new Map,this._attrs.get("objectId")||(this._database?this._attrs.set("objectId",this._database.generateHandle()):this._attrs.set("objectId",this.generateTemporaryHandle()))}generateTemporaryHandle(){return be+bg()}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(be)&&this._database&&this._database.updateMaxHandle(t)}get isTemp(){const t=this.getAttrWithoutException("objectId");return!!t&&t.startsWith(be)}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(Ne)return Ne().workingDatabase;throw new Error("The current working database must be set before using it!")}set database(t){this.assignDatabase(t)}assignDatabase(t){this._database=t}getXData(t){return this._xDataMap.get(t)}setXData(t){for(const e of t)e.code===Ns.ExtendedDataRegAppName&&this._xDataMap.set(e.value,t)}removeXData(t){this._xDataMap.delete(t)}createExtensionDictionary(){}close(){}getOwnSnapshotKeys(){return Reflect.ownKeys(this).filter(t=>typeof t=="string"&&!Wt.SNAPSHOT_EXCLUDED_KEYS.has(t))}cloneAttrs(t){const e=this.cloneValue(t.attributes);return new rs(e)}restoreAttrsFrom(t){const e=this.cloneValue(t.attributes),i=this._attrs.attributes;for(const r of Object.keys(i))r in e||this._attrs.set(r,void 0,{unset:!0,silent:!0});this._attrs.set(e,{silent:!0})}restoreXDataMapFrom(t){this._xDataMap.clear();for(const[e,i]of t.entries())this._xDataMap.set(e,this.cloneValue(i))}copySnapshotStateTo(t){t._attrs=this.cloneAttrs(this._attrs),t._xDataMap=this.cloneValue(this._xDataMap);const e=this,i=t;for(const r of this.getOwnSnapshotKeys())Wt.SNAPSHOT_INTERNAL_KEYS.has(r)||(i[r]=this.cloneValue(e[r]))}clone(){const t=Object.create(Object.getPrototypeOf(this));return this.copySnapshotStateTo(t),t.objectId=this.generateTemporaryHandle(),t}clonePreservingIdentity(){const t=this.clone(),e=this.getAttrWithoutException("objectId");e&&t._attrs.set("objectId",e);const i=this.getAttrWithoutException("ownerId");return i!==void 0&&t._attrs.set("ownerId",i),this._database&&(t._database=this._database),t}restoreFrom(t){const e=this.objectId,i=this._database;this.restoreAttrsFrom(t._attrs),this.restoreXDataMapFrom(t._xDataMap);const r=t,s=this,a=new Set(t.getOwnSnapshotKeys());for(const o of a)Wt.SNAPSHOT_INTERNAL_KEYS.has(o)||Wt.SNAPSHOT_EXCLUDED_KEYS.has(o)||(s[o]=this.cloneValue(r[o]));for(const o of this.getOwnSnapshotKeys())Wt.SNAPSHOT_INTERNAL_KEYS.has(o)||Wt.SNAPSHOT_EXCLUDED_KEYS.has(o)||a.has(o)||delete s[o];this.objectId=e,i&&(this.database=i)}cloneValue(t){if(t==null||typeof t!="object")return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t.source,t.flags);if(Array.isArray(t))return t.map(r=>this.cloneValue(r));if(t instanceof Map){const r=new Map;for(const[s,a]of t.entries())r.set(this.cloneValue(s),this.cloneValue(a));return r}if(t instanceof Set){const r=new Set;for(const s of t.values())r.add(this.cloneValue(s));return r}if(ArrayBuffer.isView(t)){if(t instanceof DataView)return new DataView(t.buffer.slice(0));const r=t.constructor;return new r(t)}if(t instanceof ArrayBuffer)return t.slice(0);if(t&&typeof t=="object"&&"tables"in t&&"transactionManager"in t)return t;if("clone"in t&&typeof t.clone=="function")return t.clone();const e=Object.create(Object.getPrototypeOf(t)),i=t;for(const r of Object.keys(i))e[r]=this.cloneValue(i[r]);return e}dxfOut(...t){const[e,i=!1]=t;return e.writeHandle(5,this.objectId),e.writeObjectId(330,this.ownerId),e.writeObjectId(360,this.extensionDictionary),this.dxfOutFields(e),i&&this.dxfOutXData(e),this}dxfOutXData(t){for(const e of this._xDataMap.values())t.writeResultBuffer(e)}dxfOutFields(t){return this}dxfIn(t){for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===5||i===105)this.objectId=String(e.value);else if(i===330)this.ownerId=String(e.value);else if(i===360)this.extensionDictionary=String(e.value);else if(i===102)this.dxfInControlString(t,String(e.value));else if(i===100){t.pushBackItem(e);break}else{t.pushBackItem(e);break}}return this.dxfInFields(t),t.atExtendedData&&this.dxfInXData(t),this}dxfInControlString(t,e){const i=e==="{ACAD_XDICTIONARY"||e==="ACAD_XDICTIONARY";for(;!t.atEndOfObject&&!t.atEof;){const r=t.readItem();if(!r)break;const s=Number(r.code);if(s===102){const a=String(r.value);if(a==="}"||a==="")break;this.dxfInControlString(t,a);continue}i&&s===360&&!this.extensionDictionary&&(this.extensionDictionary=String(r.value))}}dxfInFields(t){return this}dxfInXData(t){let e;const i=()=>{e&&e.length>0&&this.setXData(e),e=void 0};for(;!t.atEndOfObject&&!t.atEof;){const r=t.readItem();if(!r)break;const s=Number(r.code);if(s===1001)i(),e=new Oe([{code:r.code,value:r.value}]);else if(s>=1e3&&s<=1071)e||(e=new Oe),e.add({code:r.code,value:r.value});else{t.pushBackItem(r);break}}i()}};Wt.SNAPSHOT_EXCLUDED_KEYS=new Set(["_database","transactionManager"]),Wt.SNAPSHOT_INTERNAL_KEYS=new Set(["_attrs","_xDataMap"]);let bt=Wt;exports.AcGiArrowType=void 0;(function(n){n.ClosedFilled="",n.Dot="_DOT",n.DotSmall="_DOTSMALL",n.DotBlank="_DOTBLANK",n.Origin="_ORIGIN",n.Origin2="_ORIGIN2",n.Open="_OPEN",n.Open90="_OPEN90",n.Open30="_OPEN30",n.Closed="_CLOSED",n.Small="_SMALL",n.None="_NONE",n.Oblique="_OBLIQUE",n.BoxFilled="_BOXFILLED",n.Box="_BOXBLANK",n.ClosedBlank="_CLOSEDBLANK",n.DatumBlank="_DATUMBLANK",n.DatumFilled="_DATUMFILLED",n.Integral="_INTEGRAL",n.ArchTick="_ARCHTICK"})(exports.AcGiArrowType||(exports.AcGiArrowType={}));exports.AcGiLineWeight=void 0;(function(n){n[n.ByBlock=-2]="ByBlock",n[n.ByDIPs=-4]="ByDIPs",n[n.ByLayer=-1]="ByLayer",n[n.ByLineWeightDefault=-3]="ByLineWeightDefault",n[n.LineWeight000=0]="LineWeight000",n[n.LineWeight005=5]="LineWeight005",n[n.LineWeight009=9]="LineWeight009",n[n.LineWeight013=13]="LineWeight013",n[n.LineWeight015=15]="LineWeight015",n[n.LineWeight018=18]="LineWeight018",n[n.LineWeight020=20]="LineWeight020",n[n.LineWeight025=25]="LineWeight025",n[n.LineWeight030=30]="LineWeight030",n[n.LineWeight035=35]="LineWeight035",n[n.LineWeight040=40]="LineWeight040",n[n.LineWeight050=50]="LineWeight050",n[n.LineWeight053=53]="LineWeight053",n[n.LineWeight060=60]="LineWeight060",n[n.LineWeight070=70]="LineWeight070",n[n.LineWeight080=80]="LineWeight080",n[n.LineWeight090=90]="LineWeight090",n[n.LineWeight100=100]="LineWeight100",n[n.LineWeight106=106]="LineWeight106",n[n.LineWeight120=120]="LineWeight120",n[n.LineWeight140=140]="LineWeight140",n[n.LineWeight158=158]="LineWeight158",n[n.LineWeight200=200]="LineWeight200",n[n.LineWeight211=211]="LineWeight211"})(exports.AcGiLineWeight||(exports.AcGiLineWeight={}));var yr=(function(){function n(t){t===void 0&&(t={});var e,i,r,s;this.database=t.database,this.foregroundOnDark=(e=t.foregroundOnDark)!==null&&e!==void 0?e:Ei,this.foregroundOnLight=(i=t.foregroundOnLight)!==null&&i!==void 0?i:Li,this.backgroundIsDark=(r=t.backgroundIsDark)!==null&&r!==void 0?r:!0,this.fallbackRgb=(s=t.fallbackRgb)!==null&&s!==void 0?s:16777215}return n.prototype.resolveSubEntityTraitsRgb=function(t){var e,i,r,s=t.color;return s.isForeground?this.backgroundIsDark?this.foregroundOnDark:this.foregroundOnLight:s.isByLayer||s.isByBlock?(e=this.fallbackRgb)!==null&&e!==void 0?e:16777215:(r=(i=s.RGB)!==null&&i!==void 0?i:this.fallbackRgb)!==null&&r!==void 0?r:16777215},n.fromBackgroundColor=function(t,e){return t===void 0&&(t=Zc),new n({database:e,foregroundOnDark:Ei,foregroundOnLight:Li,backgroundIsDark:!Qc(t),fallbackRgb:16777215})},n})(),Zc=0,Ei=16777215,Li=0,_g=16777215,xg=128,wg=new yr({database:void 0,foregroundOnDark:Ei,foregroundOnLight:Li,backgroundIsDark:!0,fallbackRgb:16777215});function Qc(n){var t=n>>16&255,e=n>>8&255,i=n&255;return .299*t+.587*e+.114*i>xg}function vg(n){var t=yr.fromBackgroundColor(n);return t.backgroundIsDark?t.foregroundOnDark:t.foregroundOnLight}function kg(n){return n?Li:Ei}function Ag(n,t){return yr.fromBackgroundColor(t).resolveSubEntityTraitsRgb(n)}exports.AcGiMTextFlowDirection=void 0;(function(n){n[n.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",n[n.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",n[n.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",n[n.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",n[n.BY_STYLE=5]="BY_STYLE"})(exports.AcGiMTextFlowDirection||(exports.AcGiMTextFlowDirection={}));exports.AcGiMTextAttachmentPoint=void 0;(function(n){n[n.TopLeft=1]="TopLeft",n[n.TopCenter=2]="TopCenter",n[n.TopRight=3]="TopRight",n[n.MiddleLeft=4]="MiddleLeft",n[n.MiddleCenter=5]="MiddleCenter",n[n.MiddleRight=6]="MiddleRight",n[n.BottomLeft=7]="BottomLeft",n[n.BottomCenter=8]="BottomCenter",n[n.BottomRight=9]="BottomRight",n[n.BaselineLeft=10]="BaselineLeft",n[n.BaselineCenter=11]="BaselineCenter",n[n.BaselineRight=12]="BaselineRight"})(exports.AcGiMTextAttachmentPoint||(exports.AcGiMTextAttachmentPoint={}));exports.AcGiRenderMode=void 0;(function(n){n[n.OPTIMIZED_2D=0]="OPTIMIZED_2D",n[n.WIREFRAME=1]="WIREFRAME",n[n.HIDDEN_LINE=2]="HIDDEN_LINE",n[n.FLAT_SHADED=3]="FLAT_SHADED",n[n.GOURAUD_SHADED=4]="GOURAUD_SHADED",n[n.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",n[n.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME"})(exports.AcGiRenderMode||(exports.AcGiRenderMode={}));exports.AcGiOrthographicType=void 0;(function(n){n[n.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",n[n.TOP=1]="TOP",n[n.BOTTOM=2]="BOTTOM",n[n.FRONT=3]="FRONT",n[n.BACK=4]="BACK",n[n.LEFT=5]="LEFT",n[n.RIGHT=6]="RIGHT"})(exports.AcGiOrthographicType||(exports.AcGiOrthographicType={}));exports.AcGiDefaultLightingType=void 0;(function(n){n[n.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",n[n.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS"})(exports.AcGiDefaultLightingType||(exports.AcGiDefaultLightingType={}));var Jc=(function(){function n(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new y,this._height=0,this._width=0,this._viewCenter=new y,this._viewTarget=new y,this._viewTwistAngle=0,this._viewHeight=0}return Object.defineProperty(n.prototype,"number",{get:function(){return this._number},set:function(t){this._number=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"id",{get:function(){return this._id},set:function(t){this._id=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"groupId",{get:function(){return this._groupId},set:function(t){this._groupId=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"centerPoint",{get:function(){return this._centerPoint},set:function(t){this._centerPoint.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"box",{get:function(){var t=new yt;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"viewCenter",{get:function(){return this._viewCenter},set:function(t){this._viewCenter.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"viewTarget",{get:function(){return this._viewTarget},set:function(t){this._viewTarget.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"viewTwistAngle",{get:function(){return this._viewTwistAngle},set:function(t){this._viewTwistAngle=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"viewHeight",{get:function(){return this._viewHeight},set:function(t){this._viewHeight=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"viewWidth",{get:function(){return this.viewHeight*(this.width/this.height)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"viewBox",{get:function(){var t=n.dcsCenterToWcs(this.viewCenter,this.viewTarget,this.viewTwistAngle),e=new yt;return e.setFromCenterAndSize(t,{x:this.viewWidth,y:this.viewHeight}),e},enumerable:!1,configurable:!0}),n.dcsCenterToWcs=function(t,e,i){var r=t.x,s=t.y;if(Number.isFinite(i)&&i!==0){var a=Math.cos(i),o=Math.sin(i);r=t.x*a-t.y*o,s=t.x*o+t.y*a}return e&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&(r+=e.x,s+=e.y),new y(r,s,0)},n.prototype.clone=function(){var t=new n;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.viewTarget.copy(this.viewTarget),t.viewTwistAngle=this.viewTwistAngle,t.viewHeight=this.viewHeight,t},n.prototype.copy=function(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.viewTarget.copy(t.viewTarget),this.viewTwistAngle=t.viewTwistAngle,this.viewHeight=t.viewHeight,this},n})();const we="Continuous",Z="Standard",oe="Standard",ce="Standard",Sg="ANSI31",tl="ANGLE",Ce="SOLID",el="USER",il="LINEAR",lt="ByLayer",Qt="ByBlock",ti="*Active",us="mlightcad",ds="ACAD",Pg=Object.freeze({x:0,y:0}),Ig=Object.freeze({x:0,y:0}),Eg=Object.freeze({x:1,y:1}),Lg=Object.freeze({x:0,y:0,z:1}),Tg=Object.freeze({x:0,y:0,z:0}),nl=150,gs=1,fs=255,rl=12,ps=1,ms=255,Cg=0,Mg=32767,Og=0,Ng=2,sl=5,ys=1,bs=255,aa=class aa extends bt{constructor(){super(...arguments),this._visibility=!0,this._transparency=new ot,this._transparencySet=!1,this._dxfPaperSpace=!1}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.getEntityColor()}set color(t){this.setEntityColor(t)}get resolvedColor(){return this.resolveStandardColor()}resolveStandardColor(){let t=this.color;if(t.isByLayer){const e=this.getLayerColor();e&&e.RGB!=null&&(t=e)}else t.isByBlock&&(t=new X().setForeground());return t}get lineType(){var t;return this._lineType==null&&(this._lineType=((t=this.database)==null?void 0:t.celtype)??lt),this._lineType}set lineType(t){t?t.toUpperCase()==="BYLAYER"?this._lineType=lt:t.toUpperCase()==="BYBLOCK"?this._lineType=Qt:this._lineType=t:this._lineType=lt}get lineWeight(){return this._lineWeight==null&&(this._lineWeight=this.database.celweight??exports.AcGiLineWeight.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(),this._transparencySet=!0}hasExplicitLayer(){return this._layer!=null}hasExplicitColor(){return this._color!=null}getEntityColor(){return this._color==null&&(this._color=new X,this.database.cecolor&&this._color.copy(this.database.cecolor)),this._color}setEntityColor(t){this._color==null&&(this._color=new X),this._color.copy(t)}shouldResolveColorFromCecolor(){return!0}hasExplicitTransparency(){return this._transparencySet}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.writeLineWeight(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}dxfInFields(t){if(super.dxfInFields(t),!t.atSubclassData("AcDbEntity")){const e=t.peekItem();if(e&&Number(e.code)===100)return this}for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}switch(i){case 8:this.layer=String(e.value);break;case 6:this.lineType=String(e.value);break;case 48:this.linetypeScale=Number(e.value);break;case 60:this.visibility=Number(e.value)===0;break;case 62:this.color.colorIndex=Number(e.value);break;case 420:this.color.setRGBValue(Number(e.value));break;case 370:this.lineWeight=Number(e.value);break;case 440:this.transparency=ot.deserialize(Number(e.value));break;case 67:this._dxfPaperSpace=Number(e.value)!==0;break}}return this}get dxfPaperSpace(){return this._dxfPaperSpace}resolveEffectiveProperties(){this._layer==null&&(this._layer=this.database.clayer??"0"),this._color==null&&this.shouldResolveColorFromCecolor()&&(this._color=new X,this.database.cecolor&&this._color.copy(this.database.cecolor)),this._lineType==null&&(this._lineType=this.database.celtype??lt),this._linetypeScale==null&&(this._linetypeScale=this.database.celtscale??-1),this._lineWeight==null&&(this._lineWeight=this.database.celweight??exports.AcGiLineWeight.ByLayer)}get properties(){return{type:this.type,groups:[this.getGeneralProperties()]}}subGetGripPoints(){return new Array}subMoveGripPointsAt(t,e){return this}subGetOsnapPoints(t,e,i,r,s,a){}transformBy(t){return this}erase(){return this.database.tables.blockTable.removeEntity(this.objectId)}worldDraw(t,e){if(!this.database.isLayerDrawable(this.layer))return;const i=t.subEntityTraits;i.color=this.resolvedColor,i.lineType=this.lineStyle,i.lineTypeScale=this.linetypeScale,i.lineWeight=this.lineWeight,i.transparency=this.transparency,i.layer=this.layer,i.drawOrder=0,"thickness"in this&&(i.thickness=this.thickness),t.context.database=this.database;const r=this.subWorldDraw(t,e);return this.attachEntityInfo(r),r}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=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==lt){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return{type:"ByLayer",name:t.linetype}}else return this.lineType==Qt?{type:"ByBlock",name:we}:{type:"UserSpecified",name:this.lineType};return{type:"UserSpecified",name:we}}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)}};aa.typeName="Entity";let H=aa;class ei{constructor(t){this.i=0,t instanceof Map?(this._records=t,this._array=null,this._keys=Array.from(t.keys())):(this._records=null,this._array=t,this._keys=[])}get count(){var t;return((t=this._records)==null?void 0:t.size)??this._array.length}toArray(){return this._records?Array.from(this._records.values()):[...this._array]}[Symbol.iterator](){return this}next(){if(this._array){if(this.i<this._array.length){const t=this._array[this.i];return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}}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 _e extends Error{constructor(t="Unexpected end of buffer."){super(t),this.name="AcDbProxyGraphicEndOfBufferError"}}function al(n){return n instanceof ArrayBuffer?new Uint8Array(n):n}class Mt{constructor(t,e=4){this._index=0,this._buffer=al(t),this._align=e}get index(){return this._index}get hasData(){return this._index<this._buffer.length}alignIndex(t){const e=t%this._align;return e?t+this._align-e:t}readStruct(t){if(!this.hasData)throw new _e;const e=[];let i=0;for(const r of t){const s=new DataView(this._buffer.buffer,this._buffer.byteOffset+this._index+i,r);if(r===8)e.push(s.getFloat64(0,!0));else if(r===4)e.push(s.getUint32(0,!0));else throw new Error(`Unsupported struct size: ${r}`);i+=r}return this._index=this.alignIndex(this._index+i),e}readFloat(){return this.readStruct([8])[0]}readLong(){return this.readStruct([4])[0]}readSignedLong(){if(!this.hasData)throw new _e;const e=new DataView(this._buffer.buffer,this._buffer.byteOffset+this._index,4).getInt32(0,!0);return this._index=this.alignIndex(this._index+4),e}readVertex(){return this.readStruct([8,8,8])}readPaddedString(t="utf-8"){const e=this._buffer;for(let i=this._index;i<e.length;i++)if(e[i]===0){const r=this._index;this._index=this.alignIndex(i+1);const s=e.subarray(r,i);return new TextDecoder(t).decode(s)}throw new _e("Did not detect terminating zero byte.")}readPaddedUnicodeString(){const t=this._buffer;for(let e=this._index;e<t.length;e+=2)if(e+1<t.length&&t[e]===0&&t[e+1]===0){const i=this._index;this._index=this.alignIndex(e+2);const r=t.subarray(i,e);return new TextDecoder("utf-16le").decode(r)}throw new _e("Did not detect terminating zero bytes.")}}class ol{constructor(t,e="AC1015",i="cp1252"){this._bitIndex=0,this._buffer=al(t),this.dxfversion=e,this.encoding=i}get hasData(){return this._bitIndex>>3<this._buffer.length}readBit(){const t=this._bitIndex;this._bitIndex+=1;const e=t>>3;if(e>=this._buffer.length)throw new _e;return this._buffer[e]&128>>(t&7)?1:0}readBits(t){const e=this._bitIndex,i=e+t;if(i-1>>3>=this._buffer.length)throw new _e;this._bitIndex=i;let r=128>>(e&7),s=e>>3,a=0,o=this._buffer[s];for(;t>0;)a<<=1,o&r&&(a|=1),t-=1,r>>=1,!r&&t&&(r=128,s+=1,o=this._buffer[s]);return a}readUnsignedByte(){return this.readBits(8)}readSignedByte(){const t=this.readBits(8);return t&128?-((~t&255)+1):t}readAlignedBytes(t){const e=this._bitIndex>>3,i=e+t;if(i>this._buffer.length)throw new _e;return this._bitIndex+=t<<3,this._buffer.subarray(e,i)}readUnsignedShort(){if(this._bitIndex&7){const e=this.readBits(8);return(this.readBits(8)<<8)+e}const t=this.readAlignedBytes(2);return t[1]<<8|t[0]}readSignedShort(){const t=this.readUnsignedShort();return t&32768?-((~t&65535)+1):t}readUnsignedLong(){if(this._bitIndex&7){const e=this.readBits(8),i=this.readBits(8),r=this.readBits(8);return(this.readBits(8)<<24)+(r<<16)+(i<<8)+e}const t=this.readAlignedBytes(4);return(t[3]<<24)+(t[2]<<16)+(t[1]<<8)+t[0]}readSignedLong(){const t=this.readUnsignedLong();return t&2147483648?-((~t&4294967295)+1):t}readFloat(){if(this._bitIndex&7){const i=new Uint8Array(8);for(let r=0;r<8;r++)i[r]=this.readBits(8);return new DataView(i.buffer).getFloat64(0,!0)}const t=this.readAlignedBytes(8),e=new Uint8Array(t);return new DataView(e.buffer).getFloat64(0,!0)}readRawDouble(t=1){return t===1?this.readFloat():Array.from({length:t},()=>this.readFloat())}readBitShort(t=1){const e=()=>{const i=this.readBits(2);return i===0?this.readSignedShort():i===1?this.readUnsignedByte():i===2?0:256};return t===1?e():Array.from({length:t},()=>e())}readBitLong(t=1){const e=()=>{const i=this.readBits(2);return i===0?this.readSignedLong():i===1?this.readUnsignedByte():i===2?0:256};return t===1?e():Array.from({length:t},()=>e())}readBitDouble(t=1){const e=()=>{const i=this.readBits(2);return i===0?this.readFloat():i===1?1:0};return t===1?e():Array.from({length:t},()=>e())}readBitDoubleDefault(t=1,e=0){const i=new Uint8Array(8);new DataView(i.buffer).setFloat64(0,e,!0);const r=()=>{const s=this.readBits(2);if(s===0)return e;if(s===1){const a=new Uint8Array(i);return a[0]=this.readUnsignedByte(),a[1]=this.readUnsignedByte(),a[2]=this.readUnsignedByte(),a[3]=this.readUnsignedByte(),new DataView(a.buffer).getFloat64(0,!0)}if(s===2){const a=new Uint8Array(i);return a[4]=this.readUnsignedByte(),a[5]=this.readUnsignedByte(),a[0]=this.readUnsignedByte(),a[1]=this.readUnsignedByte(),a[2]=this.readUnsignedByte(),a[3]=this.readUnsignedByte(),new DataView(a.buffer).getFloat64(0,!0)}return this.readFloat()};return t===1?r():Array.from({length:t},()=>r())}}function br(n){return Array.from(n,t=>t.toString(16).padStart(2,"0")).join("").toUpperCase()}function Ws(n){const t=n.reduce((r,s)=>r+Math.floor(s.length/2),0),e=new Uint8Array(t);let i=0;for(const r of n)for(let s=0;s<r.length;s+=2)e[i++]=parseInt(r.slice(s,s+2),16);return e}function $i(n){if(n.length===0)return new Uint8Array;const t=[];for(const s of n)s instanceof Uint8Array?t.push(s):t.push(Ws([String(s)]));const e=t.reduce((s,a)=>s+a.length,0),i=new Uint8Array(e);let r=0;for(const s of t)i.set(s,r),r+=s.length;return i}class ge extends bt{constructor(t,e){t=t||{},Bt(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}setAttr(t,e){this.assertOpenForWrite(),super.setAttr(t,e)}assertOpenForWrite(){if(this.isTemp)return;const t=this.database;if(!t)return;const e=t.transactionManager;if(!e.isApplyingUndoRedo()){if(e.strictMode&&!e.isRecording())throw new Error("Cannot modify symbol table records outside an active transaction.");if(e.isRecording()&&!e.isOpenedForWriteInTransaction(this.objectId))throw new Error(`Symbol table record "${this.name||this.objectId}" is not open for write. Use openObjectForWrite().`)}}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbSymbolTableRecord"),this}}var cl=(n=>(n[n.Any=0]="Any",n[n.Uniform=1]="Uniform",n))(cl||{}),_i=(n=>(n[n.None=0]="None",n[n.Anonymous=1]="Anonymous",n[n.HasNonConstantAttributes=2]="HasNonConstantAttributes",n[n.Xref=4]="Xref",n[n.XrefOverlay=8]="XrefOverlay",n[n.ExternallyDependent=16]="ExternallyDependent",n[n.Resolved=32]="Resolved",n[n.Referenced=64]="Referenced",n))(_i||{});const pe=class pe extends ge{static isModelSapceName(t){return t.toLowerCase()==pe.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(pe.PAPER_SPACE_NAME_PREFIX.toLowerCase())}static sanitizeImportedFlags(t){return t&-97}constructor(t,e){t=t||{},Bt(t,{origin:new y,layoutId:"",flags:0,pathName:"",blockInsertUnits:0,explodability:1,blockScaling:1,previewIcon:void 0}),super(t,e),this._entities=[]}get isModelSapce(){return pe.isModelSapceName(this.name)}get isPaperSapce(){return pe.isPaperSapceName(this.name)}get origin(){return this.getAttr("origin")}set origin(t){this.getAttr("origin").copy(t)}get layoutId(){return this.getAttr("layoutId")}set layoutId(t){this.setAttr("layoutId",t)}get flags(){return this.getAttr("flags")}set flags(t){this.setAttr("flags",t)}get pathName(){return this.getAttr("pathName")}set pathName(t){this.setAttr("pathName",t)}get isXref(){return(this.flags&12)!==0}get isOverlayReference(){return(this.flags&8)!==0}get isUnresolvedXref(){return!this.isXref||(this.flags&32)!==0?!1:this._entities.length===0}get blockInsertUnits(){return this.getAttr("blockInsertUnits")}set blockInsertUnits(t){this.setAttr("blockInsertUnits",t)}get explodability(){return this.getAttr("explodability")}set explodability(t){this.setAttr("explodability",t)}get blockScaling(){return this.getAttr("blockScaling")}set blockScaling(t){this.setAttr("blockScaling",t)}get previewIcon(){return this.getAttrWithoutException("previewIcon")}set previewIcon(t){if(!t||t.length===0){this.setAttr("previewIcon",void 0);return}this.setAttr("previewIcon",t)}appendEntity(t){const e=this.database.transactionManager;if(e.strictMode&&!e.isRecording()&&!e.isApplyingUndoRedo())throw new Error("Cannot append entities outside an active transaction.");const i=s=>{s.database=this.database,s.ownerId=this.objectId,this.database.ensureEntityStyleDefaults(s),this.database.commitObjectHandle(s,a=>this.hasEntityId(a)),s.resolveEffectiveProperties(),this._entities.push(s),s.dxfTypeName==="INSERT"&&"syncAttributeDatabases"in s&&typeof s.syncAttributeDatabases=="function"&&s.syncAttributeDatabases()},r=Array.isArray(t)?t:[t];for(const s of r)i(s);if(e.isRecording())for(const s of r)e.recordAppend({type:"blockTableRecord",ownerId:this.objectId},s);(this.isModelSapce||this.isPaperSapce)&&!e.isRecording()&&!e.isApplyingUndoRedo()&&this.database.notifyEntityAppended(t)}removeEntity(t){const e=this.database.transactionManager;if(e.strictMode&&!e.isRecording()&&!e.isApplyingUndoRedo())throw new Error("Cannot remove entities outside an active transaction.");const i=Array.isArray(t)?t:[t];if(i.length===0)return!1;const r=new Set(i),s=[];let a=0;for(const o of this._entities)r.has(o.objectId)?(e.isRecording()&&e.recordRemove({type:"blockTableRecord",ownerId:this.objectId},o),s.push(o),this.database.releaseObjectHandle(o)):this._entities[a++]=o;return this._entities.length=a,s.length>0&&!e.isRecording()&&!e.isApplyingUndoRedo()&&this.database.notifyEntityErased(s),s.length>0}newIterator(){return new ei(this._entities)}getIdAt(t){const e=this.database.getObjectById(t);if(!(!(e instanceof H)||e.getAttrWithoutException("ownerId")!==this.objectId))return e}hasEntityId(t){return this.getIdAt(t)!==void 0}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,this.flags),t.writePoint3d(10,this.origin),t.writeString(3,this.name),this.pathName&&t.writeString(1,this.pathName),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}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbBlockTableRecord");const e=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const i=t.readItem();if(!i)break;const r=Number(i.code);if(r===100){t.pushBackItem(i);break}switch(r){case 2:this.name=String(i.value);break;case 70:this.blockInsertUnits=Number(i.value);break;case 280:this.explodability=Number(i.value);break;case 281:this.blockScaling=Number(i.value);break;case 340:this.layoutId=String(i.value);break;case 310:{const s=String(i.value).replace(/\s+/g,"");s&&e.push(s);break}}}return e.length>0&&(this.previewIcon=Ws(e)),this}};pe.MODEL_SPACE_NAME="*Model_Space",pe.PAPER_SPACE_NAME_PREFIX="*Paper_Space";let tt=pe;var ll=(n=>(n[n.kInches=0]="kInches",n[n.kMillimeters=1]="kMillimeters",n[n.kPixels=2]="kPixels",n))(ll||{}),hl=(n=>(n[n.k0degrees=0]="k0degrees",n[n.k90degrees=1]="k90degrees",n[n.k180degrees=2]="k180degrees",n[n.k270degrees=3]="k270degrees",n))(hl||{}),ul=(n=>(n[n.kDisplay=0]="kDisplay",n[n.kExtents=1]="kExtents",n[n.kLimits=2]="kLimits",n[n.kView=3]="kView",n[n.kWindow=4]="kWindow",n[n.kLayout=5]="kLayout",n))(ul||{}),dl=(n=>(n[n.kDraft=0]="kDraft",n[n.kPreview=1]="kPreview",n[n.kNormal=2]="kNormal",n[n.kPresentation=3]="kPresentation",n[n.kMaximum=4]="kMaximum",n[n.kCustom=5]="kCustom",n))(dl||{}),gl=(n=>(n[n.kAsDisplayed=0]="kAsDisplayed",n[n.kWireframe=1]="kWireframe",n[n.kHidden=2]="kHidden",n[n.kRendered=3]="kRendered",n[n.kVisualStyle=4]="kVisualStyle",n[n.kRenderPreset=5]="kRenderPreset",n))(gl||{}),fl=(n=>(n[n.kScaleToFit=0]="kScaleToFit",n[n.k1_128in_1ft=1]="k1_128in_1ft",n[n.k1_64in_1ft=2]="k1_64in_1ft",n[n.k1_32in_1ft=3]="k1_32in_1ft",n[n.k1_16in_1ft=4]="k1_16in_1ft",n[n.k3_32in_1ft=5]="k3_32in_1ft",n[n.k1_8in_1ft=6]="k1_8in_1ft",n[n.k3_16in_1ft=7]="k3_16in_1ft",n[n.k1_4in_1ft=8]="k1_4in_1ft",n[n.k3_8in_1ft=9]="k3_8in_1ft",n[n.k1_2in_1ft=10]="k1_2in_1ft",n[n.k3_4in_1ft=11]="k3_4in_1ft",n[n.k1in_1ft=12]="k1in_1ft",n[n.k3in_1ft=13]="k3in_1ft",n[n.k6in_1ft=14]="k6in_1ft",n[n.k1ft_1ft=15]="k1ft_1ft",n[n.k1_1=16]="k1_1",n[n.k1_2=17]="k1_2",n[n.k1_4=18]="k1_4",n[n.k1_5=19]="k1_5",n[n.k1_8=20]="k1_8",n[n.k1_10=21]="k1_10",n[n.k1_16=22]="k1_16",n[n.k1_20=23]="k1_20",n[n.k1_30=24]="k1_30",n[n.k1_40=25]="k1_40",n[n.k1_50=26]="k1_50",n[n.k1_100=27]="k1_100",n[n.k2_1=28]="k2_1",n[n.k4_1=29]="k4_1",n[n.k8_1=30]="k8_1",n[n.k10_1=31]="k10_1",n[n.k100_1=32]="k100_1",n[n.k1000_1=33]="k1000_1",n[n.k1and1_2in_1ft=34]="k1and1_2in_1ft",n))(fl||{});const Rg={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 pl extends bt{constructor(t=!1){super(),this._plotSettingsName="",this._plotCfgName="",this._canonicalMediaName="",this._currentStyleSheet="",this._plotOrigin=new L,this._customPrintScale={numerator:1,denominator:1},this._plotPaperSize=new L,this._plotPaperMargins={left:0,right:0,top:0,bottom:0},this._plotViewName="",this._paperImageOrigin=new L,this._plotWindowArea=new yt,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 paperImageOrigin(){return this._paperImageOrigin}set paperImageOrigin(t){this._paperImageOrigin=t}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 Rg[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.writeDouble(148,this.paperImageOrigin.x),t.writeDouble(149,this.paperImageOrigin.y),t.writeObjectId(333,this.shadePlotId),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbPlotSettings");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code),r=Number(e.value);switch(i){case 1:this.plotSettingsName=String(e.value);break;case 2:this.plotCfgName=String(e.value);break;case 4:this.canonicalMediaName=String(e.value);break;case 6:this.plotViewName=String(e.value);break;case 7:this.currentStyleSheet=String(e.value);break;case 40:this.plotPaperMargins.left=r;break;case 41:this.plotPaperMargins.bottom=r;break;case 42:this.plotPaperMargins.right=r;break;case 43:this.plotPaperMargins.top=r;break;case 44:this.plotPaperSize.x=r;break;case 45:this.plotPaperSize.y=r;break;case 46:this.plotOrigin.x=r;break;case 47:this.plotOrigin.y=r;break;case 48:this.plotWindowArea.min.x=r;break;case 49:this.plotWindowArea.min.y=r;break;case 140:this.plotWindowArea.max.x=r;break;case 141:this.plotWindowArea.max.y=r;break;case 142:this.customPrintScale.numerator=r;break;case 143:this.customPrintScale.denominator=r;break;case 70:{const s=r;this.plotViewportBorders=(s&1)!==0,this.showPlotStyles=(s&2)!==0,this.plotCentered=(s&4)!==0,this.plotHidden=(s&8)!==0,this.useStandardScale=(s&16)!==0,this.plotPlotStyles=(s&32)!==0,this.scaleLineweights=(s&64)!==0,this.printLineweights=(s&128)!==0,this.drawViewportsFirst=(s&512)!==0,this.modelType=(s&1024)!==0;break}case 72:this.plotPaperUnits=r;break;case 73:this.plotRotation=r;break;case 74:this.plotType=r;break;case 75:this.stdScaleType=r;break;case 76:this.shadePlot=r;break;case 77:this.shadePlotResLevel=r;break;case 78:this.shadePlotCustomDPI=r;break;case 147:break;case 148:this.paperImageOrigin.x=r;break;case 149:this.paperImageOrigin.y=r;break;case 333:this.shadePlotId=String(e.value);break;case 100:return t.pushBackItem(e),this}}return this}}class qi extends pl{constructor(){super(),this._insertionPoint=new y,this._ucsOrigin=new y,this._ucsXAxis=new w(1,0,0),this._ucsYAxis=new w(0,1,0),this._elevation=0,this._orthographicType=0,this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new yt,this._extents=new Y,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()}get namedUcsId(){return this._namedUcsId}set namedUcsId(t){this._namedUcsId=t}get orthographicUcsId(){return this._orthographicUcsId}set orthographicUcsId(t){this._orthographicUcsId=t}get insertionPoint(){return this._insertionPoint}set insertionPoint(t){this._insertionPoint.copy(t)}get ucsOrigin(){return this._ucsOrigin}set ucsOrigin(t){this._ucsOrigin.copy(t)}get ucsXAxis(){return this._ucsXAxis}set ucsXAxis(t){this._ucsXAxis.copy(t)}get ucsYAxis(){return this._ucsYAxis}set ucsYAxis(t){this._ucsYAxis.copy(t)}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get orthographicType(){return this._orthographicType}set orthographicType(t){this._orthographicType=t}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),t.writePoint3d(12,this.insertionPoint),t.writePoint3d(13,this.ucsOrigin),t.writeVector3d(16,this.ucsXAxis),t.writeVector3d(17,this.ucsYAxis),t.writeDouble(146,this.elevation),t.writeInt16(76,this.orthographicType),t.writeObjectId(345,this._namedUcsId),t.writeObjectId(346,this._orthographicUcsId),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbLayout");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code),r=Number(e.value);switch(i){case 1:this.layoutName=String(e.value);break;case 70:this.tabSelected=r!==0;break;case 71:this.tabOrder=r;break;case 330:this.blockTableRecordId=String(e.value);break;case 331:{const s=String(e.value);s&&s!=="0"&&(this.viewportArray=[s]);break}case 10:this.limits.min.x=r;break;case 20:this.limits.min.y=r;break;case 11:this.limits.max.x=r;break;case 21:this.limits.max.y=r;break;case 14:this.extents.min.x=r;break;case 24:this.extents.min.y=r;break;case 34:this.extents.min.z=r;break;case 15:this.extents.max.x=r;break;case 25:this.extents.max.y=r;break;case 35:this.extents.max.z=r;break;case 345:this.namedUcsId=String(e.value);break;case 346:this.orthographicUcsId=String(e.value);break;case 12:this.insertionPoint.x=r;break;case 22:this.insertionPoint.y=r;break;case 32:this.insertionPoint.z=r;break;case 13:this.ucsOrigin.x=r;break;case 23:this.ucsOrigin.y=r;break;case 33:this.ucsOrigin.z=r;break;case 16:this.ucsXAxis.x=r;break;case 26:this.ucsXAxis.y=r;break;case 36:this.ucsXAxis.z=r;break;case 17:this.ucsYAxis.x=r;break;case 27:this.ucsYAxis.y=r;break;case 37:this.ucsYAxis.z=r;break;case 76:this.orthographicType=r;break;case 146:this.elevation=r;break;case 100:return t.pushBackItem(e),this}}return this}}class ml{constructor(){this.events={layoutCreated:new at,layoutRemoved:new at,layoutRenamed:new at,layoutSwitched:new at}}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 s=this.getWorkingDatabase(i).objects.layout.getAt(t);return s?(s.layoutName=e,this.events.layoutRenamed.dispatch({layout:s,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 s=!1;return r&&(s=i.remove(t),s&&this.events.layoutRemoved.dispatch({layout:r})),s}createLayout(t,e){const i=this.getWorkingDatabase(e),r=new qi;r.layoutName=t,r.tabOrder=i.objects.layout.maxTabOrder;const s=new tt;return s.name=`*Paper_Space${r.tabOrder}`,i.tables.blockTable.add(s),i.objects.layout.setAt(t,r),this.events.layoutCreated.dispatch({layout:r}),{layout:r,btr:s}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.objects.layout.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||Kc()}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}let _n;function Bg(n){_n=n}function yl(){return Sn.instance}const sr=class sr{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(){return this._layoutManager||(_n||(_n=()=>new ml),this._layoutManager=_n()),this._layoutManager}};sr.instance=new sr;let Sn=sr;$c(yl);var ii=(n=>(n.kForRead="kForRead",n.kForWrite="kForWrite",n))(ii||{});function Fg(n){let t="";for(let e=0;e<n.length;e++){const i=n.charCodeAt(e);t+=i<=32?n[e]:String.fromCharCode(159-i)}return t}function Dg(n){const t=n.trimStart();return!(!t||/^\d/.test(t)||/^ACIS/i.test(t)||/^ASM/i.test(t)||/^(body|point|plane|cone|cylinder|sphere|torus|lump|shell|face|edge|wire|transform)\b/i.test(t)||/\b(body|point|straight-curve|ellipse-curve)\s+\$/.test(t))}function Yg(n){return!n||!Dg(n)?n:Fg(n)}function Xg(n){return n.length===0?"":n.map(t=>Yg(t)).join(`
6
- `)}function go(n,t,e){if(t===1){n.push(e);return}if(n.length===0){n.push(e);return}n[n.length-1]+=e}const zg=["ACIS BinaryFile","ASM BinaryFile4"],bl=new Set(["End-of-ACIS-data","End-of-ASM-data","End-of-ACIS-History-data"]),U={Int:4,Double:6,Str:7,BoolTrue:10,BoolFalse:11,Pointer:12,EntityType:13,EntityTypeEx:14,SubtypeStart:15,SubtypeEnd:16,RecordEnd:17,LiteralStr:18,LocationVec:19,DirectionVec:20,Enum:21,Unknown0x17:23};class jg{constructor(t){this.data=t,this.index=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}get hasData(){return this.index<this.data.length}require(t){if(this.index+t>this.data.length)throw new RangeError(`SAB: read past end of data (need ${String(t)} at ${String(this.index)})`)}readByte(){return this.require(1),this.data[this.index++]??0}readInt(){this.require(4);const t=this.view.getInt32(this.index,!0);return this.index+=4,t}readFloat(){this.require(8);const t=this.view.getFloat64(this.index,!0);return this.index+=8,t}readStr(t){this.require(t);const e=Vg.decode(this.data.subarray(this.index,this.index+t));return this.index+=t,e}}const Vg=new TextDecoder("latin1");function Gg(n,t){let e="";for(const g of zg)if(Wg(t,g)){e=g,n.index=g.length;break}if(e==="")throw new RangeError("SAB: not a SAB stream (missing signature)");const i=n.readInt(),r=n.readInt(),s=n.readInt(),a=n.readInt(),o=Xr(n),c=Xr(n),l=Xr(n),h=zr(n),u=zr(n),d=zr(n);return{signature:e,version:i,numRecords:r,numEntities:s,flags:a,productId:o,acisVersion:c,creationDate:l,unitsInMm:h,resTol:u,norTol:d}}function Xr(n){if(n.readByte()!==U.Str)throw new RangeError("SAB: expected string tag (0x07)");return n.readStr(n.readByte())}function zr(n){if(n.readByte()!==U.Double)throw new RangeError("SAB: expected double tag (0x06)");return n.readFloat()}function Ug(n){const t=[],e=[];let i="",r=0;for(;;){if(!n.hasData){if(bl.has(i))return{type:i,tokens:t};throw new RangeError("SAB: premature end of data")}const s=n.readByte();switch(s){case U.Int:t.push({tag:s,value:n.readInt()});break;case U.Double:t.push({tag:s,value:n.readFloat()});break;case U.Str:t.push({tag:s,value:n.readStr(n.readByte())});break;case U.Pointer:t.push({tag:s,value:n.readInt()});break;case U.BoolTrue:t.push({tag:s,value:!0});break;case U.BoolFalse:t.push({tag:s,value:!1});break;case U.LiteralStr:t.push({tag:s,value:n.readStr(n.readInt())});break;case U.EntityTypeEx:e.push(n.readStr(n.readByte()));break;case U.EntityType:{e.push(n.readStr(n.readByte()));const a=e.join("-");e.length=0,i===""&&(i=a),t.push({tag:s,value:a});break}case U.LocationVec:t.push({tag:s,value:fo(n)});break;case U.DirectionVec:t.push({tag:s,value:fo(n)});break;case U.Enum:t.push({tag:s,value:n.readInt()});break;case U.Unknown0x17:t.push({tag:s,value:n.readFloat()});break;case U.SubtypeStart:r++,t.push({tag:s,value:r});break;case U.SubtypeEnd:t.push({tag:s,value:r}),r--;break;case U.RecordEnd:return{type:i,tokens:t};default:throw new RangeError(`SAB: unknown tag 0x${s.toString(16)} (${String(s)}) in record '${i}'`)}}}function fo(n){return[n.readFloat(),n.readFloat(),n.readFloat()]}function Hg(n){const t=new jg(n),e=Gg(t,n),i=[];for(;t.hasData;){const r=Ug(t);if(i.push(r),bl.has(r.type))break}return{header:e,records:i}}function Wg(n,t){if(n.length<t.length)return!1;for(let e=0;e<t.length;e++)if(n[e]!==t.charCodeAt(e))return!1;return!0}const $g=new Set(["End-of-ACIS-data","End-of-ASM-data","End-of-ACIS-History-data"]);function qg(n){const e=n.records.map((a,o)=>({index:o,type:a.type,record:a,refs:[]}));for(const a of e)for(const o of a.record.tokens){if(o.tag!==U.Pointer)continue;const c=o.value;a.refs.push(c>=0&&c<e.length?e[c]:null)}const i=e,r=new Map,s=new Map;for(const a of i){if($g.has(a.type))continue;let o=r.get(a.type);o===void 0&&(o=[],r.set(a.type,o)),o.push(a),s.set(a.type,(s.get(a.type)??0)+1)}return{header:n.header,nodes:i,bodies:r.get("body")??[],typeCounts:s,nodesOfType:a=>r.get(a)??[],pointLocations(){const a=[];for(const o of r.get("point")??[]){const c=o.record.tokens.find(l=>l.tag===U.LocationVec);c!==void 0&&a.push(c.value)}return a}}}const Kg=["ACIS BinaryFile","ASM BinaryFile","ASM BinaryFile4"];function Zg(n,t){if(t.length===0||n.length<t.length)return-1;const e=t.charCodeAt(0);for(let i=0;i<=n.length-t.length;i++){if(n[i]!==e)continue;let r=!0;for(let s=1;s<t.length;s++)if(n[i+s]!==t.charCodeAt(s)){r=!1;break}if(r)return i}return-1}function Qg(n){for(const t of Kg){const e=Zg(n,t);if(e>=0)return e}return-1}function Jg(n){if(n.length===0)return null;const t=Qg(n);if(t<0)return null;try{return qg(Hg(n.subarray(t)))}catch{return null}}class _l{constructor(t){this.tokens=t,this.i=0}next(...t){for(;this.i<this.tokens.length;){const e=this.tokens[this.i++];if(e!==void 0&&t.includes(e.tag))return e}}nextVec(){var t;return(t=this.next(U.LocationVec,U.DirectionVec))==null?void 0:t.value}nextDouble(){var t;return(t=this.next(U.Double))==null?void 0:t.value}}const Ve=(n,t)=>n.refs.find(e=>e!==null&&(e.type===t||e.type.endsWith(t)))??null,xl=(n,t)=>n.refs.filter(e=>e!==null&&e.type===t);function jr(n){if(n===null)return null;const t=Ve(n,"point");if(t===null)return null;const e=t.record.tokens.find(i=>i.tag===U.LocationVec);return e?e.value:null}function tf(n){const t=new _l(n.record.tokens);if(n.type==="straight-curve"){const e=t.nextVec(),i=t.nextVec();if(e&&i)return{kind:"straight",origin:e,direction:i}}else if(n.type==="ellipse-curve"){const e=t.nextVec(),i=t.nextVec(),r=t.nextVec(),s=t.nextDouble();if(e&&i&&r&&s!==void 0)return{kind:"ellipse",center:e,normal:i,majorAxis:r,ratio:s}}else if(n.type==="intcurve-curve")return{kind:"intcurve",controlPoints:ef(n.record.tokens)};return{kind:"unknown"}}function ef(n){var a,o,c;const t=n.findIndex(l=>l.tag===U.EntityType&&(l.value==="nubs"||l.value==="nurbs"));if(t<0)return[];let e=t+1,i=-1;for(;e<n.length;e++){const l=n[e];if(l===void 0||l.tag===U.Double)break;if(l.tag===U.Int&&(i=l.value),l.tag===U.EntityType||l.tag===U.SubtypeEnd)return[]}if(i<0)return[];for(let l=0;l<i;l++){if(((a=n[e])==null?void 0:a.tag)!==U.Double)return[];e+=1,((o=n[e])==null?void 0:o.tag)===U.Int&&(e+=1)}const r=[];for(;((c=n[e])==null?void 0:c.tag)===U.Double;){const l=n[e];if(l===void 0)break;r.push(l.value),e+=1}const s=[];for(let l=0;l+3<=r.length;l+=3){const h=r[l],u=r[l+1],d=r[l+2];if(h===void 0||u===void 0||d===void 0)break;s.push([h,u,d])}return s}function wl(n){const t=new _l(n.record.tokens);if(n.type==="plane-surface"){const e=t.nextVec(),i=t.nextVec(),r=t.nextVec();if(e&&i)return r?{kind:"plane",origin:e,normal:i,uDir:r}:{kind:"plane",origin:e,normal:i}}else if(n.type==="cone-surface"){const e=t.nextVec(),i=t.nextVec(),r=t.nextVec(),s=t.nextDouble(),a=t.nextDouble(),o=t.nextDouble();if(e&&i&&r&&s!==void 0&&a!==void 0&&o!==void 0)return{kind:"cone",origin:e,axis:i,majorAxis:r,ratio:s,sineAngle:a,cosineAngle:o}}else if(n.type==="torus-surface"){const e=t.nextVec(),i=t.nextVec(),r=t.nextDouble(),s=t.nextDouble();if(e&&i&&r!==void 0&&s!==void 0)return{kind:"torus",center:e,axis:i,majorRadius:r,minorRadius:s}}else if(n.type==="sphere-surface"){const e=t.nextVec(),i=t.nextDouble(),r=t.nextVec(),s=t.nextVec();if(e&&i!==void 0&&r&&s)return{kind:"sphere",center:e,radius:i,uDir:r,poleAxis:s}}return{kind:"unknown"}}function nf(n){return wl(n)}const rf={"plane-surface":"plane","cone-surface":"cone","torus-surface":"torus","sphere-surface":"sphere","spline-surface":"spline"},sf={"straight-curve":"straight","ellipse-curve":"ellipse","intcurve-curve":"intcurve"};function af(n){const t=Ve(n,"coedge");if(t===null)return 0;const e=new Set;let i=t;for(;i!==null&&!e.has(i.index);)e.add(i.index),i=xl(i,"coedge")[0]??null;return e.size}function of(n){const t=[];let e=1/0,i=1/0,r=1/0,s=-1/0,a=-1/0,o=-1/0;const c=g=>{g[0]<e&&(e=g[0]),g[0]>s&&(s=g[0]),g[1]<i&&(i=g[1]),g[1]>a&&(a=g[1]),g[2]<r&&(r=g[2]),g[2]>o&&(o=g[2])},l=n.nodesOfType("vertex").map(g=>{const p=jr(g);return p===null?t.push(`vertex#${String(g.index)}: no resolvable point`):c(p),{nodeIndex:g.index,point:p}}),h=n.nodesOfType("edge").map(g=>{const p=xl(g,"vertex"),f=jr(p[0]??null),m=jr(p[1]??null),b=Ve(g,"-curve"),_=b?sf[b.type]??"unknown":"unknown",v=b?tf(b):void 0;return f!==null&&m!==null&&f[0]===m[0]&&f[1]===m[1]&&f[2]===m[2]&&t.push(`edge#${String(g.index)}: degenerate (coincident endpoints)`),v===void 0||v.kind==="unknown"?{nodeIndex:g.index,start:f,end:m,curveType:_}:{nodeIndex:g.index,start:f,end:m,curveType:_,curve:v}}),u=n.nodesOfType("face").map(g=>{const p=Ve(g,"-surface"),f=p?rf[p.type]??"unknown":"unknown",m=p?wl(p):void 0,b=[],_=new Set;let v=Ve(g,"loop");for(;v!==null&&!_.has(v.index);)_.add(v.index),b.push({nodeIndex:v.index,coedgeCount:af(v)}),v=Ve(v,"loop");return p===null&&t.push(`face#${String(g.index)}: no surface`),m===void 0||m.kind==="unknown"?{nodeIndex:g.index,surfaceType:f,loops:b}:{nodeIndex:g.index,surfaceType:f,surface:m,loops:b}});return{vertices:l,edges:h,faces:u,bbox:e===1/0?null:{min:[e,i,r],max:[s,a,o]},diagnostics:t}}const Le=(n,t)=>[n[0]+t[0],n[1]+t[1],n[2]+t[2]],ye=(n,t)=>[n[0]*t,n[1]*t,n[2]*t],cf=n=>Math.hypot(n[0],n[1],n[2]),xn=(n,t)=>[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]],Ye=n=>{const t=Math.hypot(n[0],n[1],n[2]);return t>0?[n[0]/t,n[1]/t,n[2]/t]:[0,0,0]};function lf(n){const t=[];for(const r of n.record.tokens)if(r.tag===U.Double&&(t.push(r.value),t.length===2))break;const e=t[0],i=t[1];return e===void 0||i===void 0?null:[e,i]}function vl(n,t,e,i){const r=ye(xn(Ye(n.normal),n.majorAxis),n.ratio),s=Math.max(1,i),a=[];for(let o=0;o<=s;o++){const c=t+(e-t)*o/s;a.push(Le(n.center,Le(ye(n.majorAxis,Math.cos(c)),ye(r,Math.sin(c)))))}return a}function hf(n,t=16){const e=Ye(n.poleAxis);let i=Ye(n.uDir),r=xn(e,i);cf(r)<1e-9?(i=Math.abs(e[0])<.9?[1,0,0]:[0,1,0],r=Ye(xn(e,i))):r=Ye(r),i=Ye(xn(r,e));const s=[],a=(o,c)=>{const l=[],h=Math.max(8,t);for(let u=0;u<=h;u++){const d=Math.PI*2*u/h;l.push(Le(n.center,Le(ye(o,n.radius*Math.cos(d)),ye(c,n.radius*Math.sin(d)))))}s.push(l)};a(i,r),a(i,e),a(r,e);for(const o of[-.5,.5]){const c=ye(e,n.radius*o),l=Le(n.center,c),h=n.radius*Math.sqrt(Math.max(0,1-o*o));if(h>1e-6){const u=[],d=Math.max(8,t);for(let g=0;g<=d;g++){const p=Math.PI*2*g/d;u.push(Le(l,Le(ye(i,h*Math.cos(p)),ye(r,h*Math.sin(p)))))}s.push(u)}}return s}const uf=16,df=(n,t)=>n.refs.find(e=>e!==null&&(e.type===t||e.type.endsWith(t)))??null;function kl(n,t,e){n.push(t[0],t[1],t[2],e[0],e[1],e[2])}function _s(n,t){for(let e=0;e+1<t.length;e++){const i=t[e],r=t[e+1];i&&r&&kl(n,i,r)}}function gf(n){const t=[];for(const e of n.nodesOfType("face")){const i=df(e,"-surface");if((i==null?void 0:i.type)!=="sphere-surface")continue;const r=nf(i);if(r.kind==="sphere")for(const s of hf(r))_s(t,s)}return new Float32Array(t)}function ff(n,t){var i,r;const e=[];for(const s of n.edges){const a=t==null?void 0:t.nodes[s.nodeIndex];if(((i=s.curve)==null?void 0:i.kind)==="ellipse"){const o=a!==void 0?lf(a):null,c=(o==null?void 0:o[0])??0,l=(o==null?void 0:o[1])??Math.PI*2;_s(e,vl(s.curve,c,l,uf));continue}if(((r=s.curve)==null?void 0:r.kind)==="intcurve"&&s.curve.controlPoints.length>0){_s(e,s.curve.controlPoints);continue}s.start&&s.end&&kl(e,s.start,s.end)}return new Float32Array(e)}function pf(n){const t=Jg(n);if(t===null)return null;const e=of(t),i=ff(e,t);if(i.length>0)return i;const r=gf(t);return r.length>0?r:null}const mf=16;function Al(n,t=!0){const e=n.split(/\s+/),i=[];let r=!t;for(const s of e){if(!r&&/^-?\d+$/.test(s)){r=!0;continue}if(s.startsWith("$")||s==="I"||s==="F"||s==="#")continue;const a=Number.parseFloat(s);Number.isFinite(a)&&i.push(a)}return i}function po(n,t,e){n.push(t[0],t[1],t[2],e[0],e[1],e[2])}function yf(n){return n.split("#").map(t=>t.trim()).filter(t=>t.length>0)}function bf(n){if(!n.includes("straight-curve"))return null;const t=Al(n);if(t.length<6)return null;const e=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5];return[[e,i,r],[e+s,i+a,r+o]]}function _f(n){if(!n.includes("ellipse-curve"))return null;const t=Al(n);return t.length<10?null:{kind:"ellipse",center:[t[0],t[1],t[2]],normal:[t[3],t[4],t[5]],majorAxis:[t[6],t[7],t[8]],ratio:t[9]}}function xf(n){const t=[];if(!n||n.trim().length===0)return new Float32Array(0);for(const e of yf(n)){const i=bf(e);if(i!==null){po(t,i[0],i[1]);continue}const r=_f(e);if(r!==null){const s=vl(r,0,Math.PI*2,mf);for(let a=1;a<s.length;a++)po(t,s[a-1],s[a])}}return new Float32Array(t)}const wf=/\bpoint\s+(?:\$-?\d+\s+){1,4}([-\d.eE+]+)\s+([-\d.eE+]+)\s+([-\d.eE+]+)/g;function vf(n){return n.split("#").map(t=>t.trim()).filter(t=>t.length>0)}function kf(n,t=1){const e=n.split(/\s+/),i=[];for(let r=t;r<e.length;r++){const s=e[r];if(s.startsWith("$")||s==="I"||s==="F")continue;const a=Number.parseFloat(s);Number.isFinite(a)&&i.push(a)}return i}function Af(n){const t=[];for(const e of n.matchAll(wf)){const i=Number.parseFloat(e[1]),r=Number.parseFloat(e[2]),s=Number.parseFloat(e[3]);Number.isFinite(i)&&Number.isFinite(r)&&Number.isFinite(s)&&t.push(new y(i,r,s))}if(t.length>0)return t;for(const e of vf(n)){if(!e.startsWith("point "))continue;const i=kf(e);if(i.length>=3){const r=i[i.length-3],s=i[i.length-2],a=i[i.length-1];t.push(new y(r,s,a))}}return t}function Sf(n){const t=[];for(let e=0;e<n.length;e+=3){const i=n[e],r=n[e+1],s=n[e+2];t.push(new y(i,r,s))}return t}function Pf(n,t){return typeof n=="string"?{satText:n,version:t}:{sabBytes:n.sabBytes,satText:n.satText??n.acisData??"",version:n.version??t}}const oa=class oa extends H{constructor(t,e){super(),this._points=[],this._wireframe=new Float32Array(0);const i=Pf(t,e);this._acisData=i.satText,this._sabBytes=i.sabBytes,this._version=i.version,this.rebuildGeometryCaches()}get dxfTypeName(){return"3DSOLID"}get acisData(){return this._acisData}get version(){return this._version}get historyObjectSoftId(){return this._historyObjectSoftId}set historyObjectSoftId(t){this._historyObjectSoftId=t}get guid(){return this._guid}set guid(t){this._guid=t}get satCache(){return this._satCache}set satCache(t){this._satCache=t}setAcisData(t,e){this._acisData=t??"",e!=null&&(this._version=e),this.rebuildGeometryCaches()}setSabBytes(t){this._sabBytes=t&&t.length>0?t:void 0,this.rebuildGeometryCaches()}get sabBytes(){return this._sabBytes}rebuildGeometryCaches(){let t=new Float32Array(0);this._sabBytes&&this._sabBytes.length>0&&(t=pf(this._sabBytes)??new Float32Array(0)),t.length===0&&this._acisData&&(t=xf(this._acisData)),this._wireframe=t,this._points=t.length>0?Sf(t):Af(this._acisData)}get hasRenderableGeometry(){return this._wireframe.length>0||this._points.length>0}get geometricExtents(){return this._points.length===0?new Y(new y(0,0,0),new y(0,0,0)):new Y().setFromPoints(this._points)}transformBy(t){if(this._points.forEach(e=>e.applyMatrix4(t)),this._wireframe.length>0){const e=new Float32Array(this._wireframe.length);for(let i=0;i<this._wireframe.length;i+=3){const r=new y(this._wireframe[i],this._wireframe[i+1],this._wireframe[i+2]);r.applyMatrix4(t),e[i]=r.x,e[i+1]=r.y,e[i+2]=r.z}this._wireframe=e}return this}subWorldDraw(t){if(this._wireframe.length>=6){const c=this._wireframe.length/3,l=new Uint16Array(c);for(let h=0;h<c;h++)l[h]=h;return t.lineSegments(this._wireframe,3,l)}if(this._points.length===0)return;const e=this.geometricExtents,i=e.min,r=e.max,s=[new y(i.x,i.y,i.z),new y(r.x,i.y,i.z),new y(r.x,r.y,i.z),new y(i.x,r.y,i.z),new y(i.x,i.y,r.z),new y(r.x,i.y,r.z),new y(r.x,r.y,r.z),new y(i.x,r.y,r.z)],a=new Float32Array(s.length*3);s.forEach((c,l)=>{a[l*3]=c.x,a[l*3+1]=c.y,a[l*3+2]=c.z});const o=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);return t.lineSegments(a,3,o)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDb3dSolid"),this._version!=null&&t.writeInt16(70,this._version),this._guid!=null&&t.writeString(2,this._guid),this._satCache!=null&&t.writeInt16(290,this._satCache?1:0);const e=255,i=this._acisData.split(`
7
- `);for(let r=0;r<i.length;r++){const s=r===i.length-1;let a=i[r];for(;a.length>e;)t.writeString(3,a.slice(0,e)),a=a.slice(e);t.writeString(s?1:3,a)}return this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbModelerGeometry");const e=[];let i=this._version;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const r=t.peekItem();if(!r)break;const s=Number(r.code);if(s===100){if(t.readItem(),String(r.value)==="AcDb3dSolid")continue;t.pushBackItem(r);break}t.readItem();const a=Number(r.value);switch(s){case 1:go(e,1,String(r.value));break;case 3:go(e,3,String(r.value));break;case 70:i=a;break;case 350:this._historyObjectSoftId=String(r.value);break;case 2:this._guid=String(r.value);break;case 290:this._satCache=a!==0;break}}return this.setAcisData(Xg(e),i),this}};oa.typeName="3dSolid";let Ti=oa;var k=(n=>(n[n.EndPoint=1]="EndPoint",n[n.MidPoint=2]="MidPoint",n[n.Center=3]="Center",n[n.Node=4]="Node",n[n.Quadrant=5]="Quadrant",n[n.Insertion=7]="Insertion",n[n.Perpendicular=8]="Perpendicular",n[n.Tangent=9]="Tangent",n[n.Nearest=10]="Nearest",n[n.Centroid=11]="Centroid",n))(k||{});function If(n){let t=0;for(const e of n)t|=1<<e-1;return t}function Ef(n){const t=[];for(const e of Object.values(k)){if(typeof e!="number")continue;const i=1<<e-1;(n&i)!==0&&t.push(e)}return t}function Lf(n,t){return n^1<<t-1}function Tf(n,t){return(n&1<<t-1)!==0}const ca=class ca extends H{getOffsetSideAtPoint(t){return 1}};ca.typeName="Curve";let _t=ca;function ht(n,t){for(const e of n)Number.isInteger(e)&&e>=0&&t(e)}function te(n,t,e){ht(n,i=>{i===0&&e.add(t)})}function xi(n,t,e){const i=n[t];i&&(i.x+=e.x,i.y+=e.y)}function ci(n,t,e){ht(n,i=>{const r=e[i];r&&r.add(t)})}function mo(n,t){const e=n.x-t.x,i=n.y-t.y,r=(n.z||0)-(t.z||0);return e*e+i*i+r*r}function Ft(n,t){if(t.length===0)return;let e=new y(t[0].x,t[0].y,t[0].z||0),i=mo(n,e);for(let r=1;r<t.length;r++){const s=t[r],a=new y(s.x,s.y,s.z||0),o=mo(n,a);o<i&&(e=a,i=o)}return e}function li(n,t,e,i,r){const s=new y(n.x,n.y,n.z||0),a=new y(t.x,t.y,t.z||0),o=new ue(s,a);switch(e){case k.EndPoint:r.push(s,a);break;case k.MidPoint:r.push(o.midPoint);break;case k.Nearest:r.push(o.nearestPoint(i));break;case k.Perpendicular:r.push(o.perpPoint(i));break}}function Ci(n,t,e,i,r,s,a){if(e){const o=new vt(n,t,e);switch(r){case k.EndPoint:a.push(new y(o.startPoint.x,o.startPoint.y,i),new y(o.endPoint.x,o.endPoint.y,i));break;case k.MidPoint:a.push(new y(o.midPoint.x,o.midPoint.y,i));break;case k.Nearest:{const c=o.nearestPoint({x:s.x,y:s.y});a.push(new y(c.x,c.y,i));break}case k.Perpendicular:{o.perpendicularPoints({x:s.x,y:s.y}).forEach(l=>a.push(new y(l.x,l.y,i)));break}case k.Tangent:{o.tangentPoints({x:s.x,y:s.y}).forEach(l=>a.push(new y(l.x,l.y,i)));break}}return}li(new y(n.x,n.y,i),new y(t.x,t.y,i),r,s,a)}function _r(n,t,e,i,r){if(n.length!==0)switch(e){case k.EndPoint:n.forEach(s=>r.push(new y(s.x,s.y,s.z||0)));break;case k.MidPoint:case k.Nearest:case k.Perpendicular:{const s=n.length,a=[];for(let o=0;o<s;o++){const c=[];li(n[o],n[(o+1)%n.length],e,i,c),a.push(...c)}if(e===k.MidPoint)r.push(...a);else{const o=Ft(i,a);o&&r.push(o)}break}}}const ar=class ar extends _t{constructor(t,e,i,r,s=w.Z_AXIS){super(),this._thickness=0;const a=Ii(s);this._geo=new Kt(t,e,i,r,s,a)}get dxfTypeName(){return"ARC"}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 thickness(){return this._thickness}set thickness(t){this._thickness=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 area(){return this._geo.area}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:()=>C.radToDeg(Math.abs(this._geo.deltaAngle))}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this.area}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.center),t.push(this.startPoint),t.push(this.endPoint),t}subMoveGripPointsAt(t,e){return ht(t,i=>{this.moveGripAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){const s=this.startPoint,a=this.endPoint;switch(t){case k.EndPoint:r.push(s),r.push(a);break;case k.MidPoint:r.push(this.midPoint);break;case k.Center:case k.Centroid:r.push(this._geo.center);break;case k.Quadrant:{const o=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const c of o)C.isBetweenAngle(c,this.startAngle,this.endAngle)&&r.push(this._geo.getPointAtAngle(c));break}case k.Nearest:{const o=this._geo.nearestPoint(e);r.push(o)}break;case k.Perpendicular:{const o=this._geo.perpendicularPoints(e),c=Ft(e,o);c&&r.push(c);break}case k.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){super.dxfOutFields(t);const e=Lt(this.center,this.normal);return t.writeSubclassMarker("AcDbCircle"),this.thickness!==0&&t.writeDouble(39,this.thickness),t.writePoint3d(10,e),t.writeDouble(40,this.radius),t.writeVector3d(210,this.normal),t.writeSubclassMarker("AcDbArc"),t.writeAngle(50,ae(this.center,this.startPoint,this.normal)),t.writeAngle(51,ae(this.center,this.endPoint,this.normal)),this}dxfInFields(t){var d;super.dxfInFields(t);let e=0,i=0,r=0,s=this.radius,a=C.radToDeg(this.startAngle),o=C.radToDeg(this.endAngle),c=this.normal.x,l=this.normal.y,h=this.normal.z;const u=g=>{for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const p=t.readItem();if(!p)break;const f=Number(p.code);if(g&&f===100)return t.pushBackItem(p),!0;const m=Number(p.value);switch(f){case 10:e=m;break;case 20:i=m;break;case 30:r=m;break;case 40:s=m;break;case 39:this.thickness=m;break;case 50:a=m;break;case 51:o=m;break;case 210:c=m;break;case 220:l=m;break;case 230:h=m;break}}return!1};return t.atSubclassData("AcDbCircle")&&u(!0),(t.atSubclassData("AcDbArc")||!t.peekItem()||Number((d=t.peekItem())==null?void 0:d.code)!==100)&&u(!1),this.applyDxfInGeometry(e,i,r,s,a,o,c,l,h),this}applyDxfInGeometry(t,e,i,r,s,a,o,c,l){const h=new w(o,c,l);this.normal.copy(h),this.center=he({x:t,y:e,z:i},h),this.radius=r,this.startAngle=C.degToRad(s),this.endAngle=C.degToRad(a)}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.center,i=this.radius;return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)>=i?1:-1}moveGripAt(t,e){switch(t){case 0:this.transformBy(D.makeTranslation(e));break;case 1:{const i=this._geo.startPoint;this._geo.startAngle=ae(this._geo.center,{x:i.x+e.x,y:i.y+e.y,z:(i.z??0)+(e.z??0)},this._geo.normal);break}case 2:{const i=this._geo.endPoint;this._geo.endAngle=ae(this._geo.center,{x:i.x+e.x,y:i.y+e.y,z:(i.z??0)+(e.z??0)},this._geo.normal);break}}}createOffsetCurve(t){const e=this._geo.offset(t);return e?new ar(e.center,e.radius,e.startAngle,e.endAngle,e.normal):null}};ar.typeName="Arc";let Pn=ar;const Cf=1,Mf=/\\[fF][^\\|{}]*(?:\|[^;\\|{}]*)*;./i,Of=/\\[fF][^\\|{}]*(?:\|[^;\\|{}]*)*;./gi;function $s(n){return n.replace(/\\[PpNn]/g,`
8
- `).replace(/\\[A-Za-z][^;]*;/g,"").replace(/[{}]/g,"")}function Nf(n){return n.replace(/\\[PpNn]/g,`
9
- `).replace(Of,"").replace(/\\[A-Za-z][^;]*;/g,"").replace(/[{}]/g,"").trim()}function Rf(n,t,e=1){const i=n.trim();if(!i||t<=0)return 0;const r=Nf(i),s=Mf.test(i);return r?Math.max(t,Ki(r,t,e)):s?t:0}function Ki(n,t,e=1){if(!n||t<=0)return 0;const i=$s(n),r=Math.max(...i.split(/\r\n|\r|\n/g).map(s=>s.length),0);return r===0?0:Math.max(t,r*t*Cf*e)}function Sl(n){const t=$s(n);return Math.max(t.split(/\r\n|\r|\n/g).length,1)}function Pl(n,t,e){if(t<=0||n<=0)return 0;if(n===1)return t;const i=Math.max(e,0)*(5/3);return t+(n-1)*t*i}function qs(n,t,e){switch(e){case exports.AcGiMTextAttachmentPoint.TopCenter:return{minX:-n/2,minY:-t,maxX:n/2,maxY:0};case exports.AcGiMTextAttachmentPoint.TopRight:return{minX:-n,minY:-t,maxX:0,maxY:0};case exports.AcGiMTextAttachmentPoint.MiddleLeft:return{minX:0,minY:-t/2,maxX:n,maxY:t/2};case exports.AcGiMTextAttachmentPoint.MiddleCenter:return{minX:-n/2,minY:-t/2,maxX:n/2,maxY:t/2};case exports.AcGiMTextAttachmentPoint.MiddleRight:return{minX:-n,minY:-t/2,maxX:0,maxY:t/2};case exports.AcGiMTextAttachmentPoint.BottomLeft:case exports.AcGiMTextAttachmentPoint.BaselineLeft:return{minX:0,minY:0,maxX:n,maxY:t};case exports.AcGiMTextAttachmentPoint.BottomCenter:case exports.AcGiMTextAttachmentPoint.BaselineCenter:return{minX:-n/2,minY:0,maxX:n/2,maxY:t};case exports.AcGiMTextAttachmentPoint.BottomRight:case exports.AcGiMTextAttachmentPoint.BaselineRight:return{minX:-n,minY:0,maxX:0,maxY:t};case exports.AcGiMTextAttachmentPoint.TopLeft:default:return{minX:0,minY:-t,maxX:n,maxY:0}}}function Ks(n,t){let e;t&&t.lengthSq()>0?e=t.clone().normalize():e=new w(Math.cos(n),Math.sin(n),0);const i=new w(-e.y,e.x,e.z);return i.lengthSq()===0?i.set(0,1,0):i.normalize(),{xAxis:e,yAxis:i}}function Il(n,t,e,i,r,s=0,a){if(e<=0&&i<=0)return n.expandByPoint(t),n;const o=qs(e,i,r),{xAxis:c,yAxis:l}=Ks(s,a?new w(a.x,a.y,a.z||0):void 0),h=[[o.minX,o.minY],[o.maxX,o.minY],[o.maxX,o.maxY],[o.minX,o.maxY]];for(const[u,d]of h)n.expandByPoint(new y(t.x+c.x*u+l.x*d,t.y+c.y*u+l.y*d,t.z+c.z*u+l.z*d));return n}function Bf(n){const t=n.extentsWidth>0?n.extentsWidth:n.width>0?n.width:Ki(n.contents,n.height),e=Pl(Sl(n.contents),n.height,n.lineSpacingFactor);return{width:t,height:e,attachment:n.attachmentPoint,rotation:n.rotation,direction:n.direction.lengthSq()>0?n.direction.clone():void 0,location:new y(n.location.x,n.location.y,n.location.z??0)}}function Ff(n,t){const{xAxis:e,yAxis:i}=Ks(t.rotation,t.direction),r=n.x-t.location.x,s=n.y-t.location.y,a=(n.z??0)-t.location.z;return{x:r*e.x+s*e.y+a*e.z,y:r*i.x+s*i.y+a*i.z}}function Df(n){const t=qs(n.width,n.height,n.attachment),{xAxis:e,yAxis:i}=Ks(n.rotation,n.direction);return[[t.minX,t.minY],[t.maxX,t.minY],[t.maxX,t.maxY],[t.minX,t.maxY]].map(([s,a])=>new y(n.location.x+e.x*s+i.x*a,n.location.y+e.y*s+i.y*a,n.location.z+e.z*s+i.z*a))}function Yf(n,t,e){const i=qs(t.width,t.height,t.attachment),{x:r,y:s}=Ff(n,t),a=i.minX-e.padX,o=i.maxX+e.padX,c=i.minY-e.padYBelow,l=i.maxY+e.padYAbove;if(r<a||r>o||s<c||s>l)return null;const h=r<i.minX?i.minX-r:r>i.maxX?i.maxX-r:0,u=s<i.minY?i.minY-s:s>i.maxY?s-i.maxY:0;return h+u}var El=(n=>(n[n.LEFT=0]="LEFT",n[n.CENTER=1]="CENTER",n[n.RIGHT=2]="RIGHT",n[n.ALIGNED=3]="ALIGNED",n[n.MIDDLE=4]="MIDDLE",n[n.FIT=5]="FIT",n))(El||{}),Ll=(n=>(n[n.BASELINE=0]="BASELINE",n[n.BOTTOM=1]="BOTTOM",n[n.MIDDLE=2]="MIDDLE",n[n.TOP=3]="TOP",n))(Ll||{});const la=class la extends H{constructor(){super(),this._generationFlag=0,this._normal=new w(0,0,1),this._textString="",this._height=0,this._thickness=1,this._position=new y,this._alignmentPoint=new y,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=2,this._styleName="",this._widthFactor=1}get dxfTypeName(){return"TEXT"}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 alignmentPoint(){return this._alignmentPoint}set alignmentPoint(t){this._alignmentPoint.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 generationFlag(){return this._generationFlag}set generationFlag(t){this._generationFlag=t}get isBackward(){return(this._generationFlag&2)!==0}set isBackward(t){this._generationFlag=t?this._generationFlag|2:this._generationFlag&-3}get isUpsideDown(){return(this._generationFlag&4)!==0}set isUpsideDown(t){this._generationFlag=t?this._generationFlag|4:this._generationFlag&-5}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get geometricExtents(){const t=new Y,{anchor:e,attachmentPoint:i}=this.resolveTextAnchor(),r=Ki(this.textString,this.height,this.widthFactor);return Il(t,e,r,this.height,i,this.rotation)}subGetGripPoints(){return[this._position]}subMoveGripPointsAt(t,e){return te(t,e,this._position),this._alignmentPoint.add(e),this}subGetOsnapPoints(t,e,i,r){k.Insertion===t&&r.push(this._position)}transformBy(t){const e=this._position.clone(),i=this._position.clone().add(new w(Math.cos(this._rotation),Math.sin(this._rotation),0)),r=this._position.clone().add(new w(-Math.sin(this._rotation),Math.cos(this._rotation),0)),s=this._position.clone().add(new w(0,0,1));e.applyMatrix4(t),i.applyMatrix4(t),r.applyMatrix4(t),s.applyMatrix4(t);const a=new w(i).sub(e),o=new w(r).sub(e),c=new w(s).sub(e),l=o.length(),h=a.length(),u=c.length();this._position.copy(e),h>0&&(this._rotation=Math.atan2(a.y,a.x)),l>0&&(this._height*=l,h>0&&(this._widthFactor*=h/l)),u>0&&(this._thickness*=u);const d=this._alignmentPoint.clone();return d.applyMatrix4(t),this._alignmentPoint.copy(d),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.textString,set:t=>{this.textString=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"widthFactor",type:"float",editable:!0,accessor:{get:()=>this.widthFactor,set:t=>{this.widthFactor=t}}},{name:"oblique",type:"float",editable:!0,accessor:{get:()=>this.oblique,set:t=>{this.oblique=t}}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable.resolveAt(this.styleName);if(!t)throw new Error("No valid text style found in text style table.");return t.textStyle}subWorldDraw(t,e){const{anchor:i,attachmentPoint:r}=this.resolveTextAnchor(),s={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:i,rotation:this.rotation,drawingDirection:exports.AcGiMTextFlowDirection.BOTTOM_TO_TOP,attachmentPoint:r};return t.mtext(s,this.getTextStyle(),e)}resolveTextAnchor(){const t=this.resolveAttachmentPoint();if(t===exports.AcGiMTextAttachmentPoint.BaselineLeft)return{anchor:this._position,attachmentPoint:t};const e=this._alignmentPoint;return e.x===0&&e.y===0&&e.z===0||e.x===this._position.x&&e.y===this._position.y&&e.z===this._position.z?{anchor:this._position,attachmentPoint:exports.AcGiMTextAttachmentPoint.BaselineLeft}:{anchor:e,attachmentPoint:t}}resolveAttachmentPoint(){const t=this._horizontalMode,e=this._verticalModel;if(t===4)return exports.AcGiMTextAttachmentPoint.MiddleCenter;if(t===3||t===5)return exports.AcGiMTextAttachmentPoint.BaselineLeft;switch(e){case 3:return t===1?exports.AcGiMTextAttachmentPoint.TopCenter:t===2?exports.AcGiMTextAttachmentPoint.TopRight:exports.AcGiMTextAttachmentPoint.TopLeft;case 2:return t===1?exports.AcGiMTextAttachmentPoint.MiddleCenter:t===2?exports.AcGiMTextAttachmentPoint.MiddleRight:exports.AcGiMTextAttachmentPoint.MiddleLeft;case 1:return t===1?exports.AcGiMTextAttachmentPoint.BottomCenter:t===2?exports.AcGiMTextAttachmentPoint.BottomRight:exports.AcGiMTextAttachmentPoint.BottomLeft;case 0:default:return t===1?exports.AcGiMTextAttachmentPoint.BaselineCenter:t===2?exports.AcGiMTextAttachmentPoint.BaselineRight:exports.AcGiMTextAttachmentPoint.BaselineLeft}}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),this.generationFlag!==0&&t.writeInt16(71,this.generationFlag),t.writeInt16(72,this.horizontalMode),t.writeInt16(73,this.verticalMode),t.writePoint3d(11,this.alignmentPoint),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbText");let e=this.position.x,i=this.position.y,r=this.position.z,s=this.alignmentPoint.x,a=this.alignmentPoint.y,o=this.alignmentPoint.z,c=!1,l=this.normal.x,h=this.normal.y,u=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const d=t.readItem();if(!d)break;const g=Number(d.code),p=Number(d.value);switch(g){case 10:e=p;break;case 20:i=p;break;case 30:r=p;break;case 11:s=p,c=!0;break;case 21:a=p,c=!0;break;case 31:o=p,c=!0;break;case 1:this.textString=String(d.value);break;case 7:this.styleName=String(d.value);break;case 39:this.thickness=p;break;case 40:this.height=p;break;case 41:this.widthFactor=p;break;case 50:this.rotation=C.degToRad(p);break;case 51:this.oblique=C.degToRad(p);break;case 71:this.generationFlag=p;break;case 72:this.horizontalMode=p;break;case 73:this.verticalMode=p;break;case 210:l=p;break;case 220:h=p;break;case 230:u=p;break;case 100:{if(String(d.value)==="AcDbText")break;return t.pushBackItem(d),this.finishTextDxfIn(e,i,r,s,a,o,c,l,h,u),this}}}return this.finishTextDxfIn(e,i,r,s,a,o,c,l,h,u),this}finishTextDxfIn(t,e,i,r,s,a,o,c,l,h){this.position=new y(t,e,i),o&&!(r===0&&s===0&&a===0)?this.alignmentPoint=new y(r,s,a):this.alignmentPoint=new y(t,e,i);const u=new w(c,l,h);u.lengthSq()>0&&this.normal.copy(u.normalize())}};la.typeName="Text";let ni=la;var dt=(n=>(n[n.Invisible=1]="Invisible",n[n.Const=2]="Const",n[n.Verifiable=4]="Verifiable",n[n.Preset=8]="Preset",n))(dt||{}),Ht=(n=>(n[n.MultiLine=2]="MultiLine",n[n.ConstMultiLine=4]="ConstMultiLine",n))(Ht||{});const ha=class ha extends ni{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}isLooseInDrawingSpace(){const t=this.database;if(!t||!this.ownerId)return!0;const e=t.tables.blockTable.getIdAt(this.ownerId);return e?e.isModelSapce||e.isPaperSapce:!0}resolveDisplayText(){if(!this.isInvisible)return this.isLooseInDrawingSpace()?this.tag||this.textString:this.textString}subWorldDraw(t,e){const i=this.resolveDisplayText();if(i===void 0)return;if(i===this.textString)return super.subWorldDraw(t,e);const r=this.textString;this.textString=i;try{return super.subWorldDraw(t,e)}finally{this.textString=r}}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbAttributeDefinition"),t.writeString(3,this.prompt),t.writeString(2,this.tag),t.writeInt16(70,this._flags),t.writeInt16(73,this.fieldLength),t.writeInt16(74,this.lockPositionInBlock?1:0),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbAttributeDefinition");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code),r=Number(e.value);switch(i){case 2:this.tag=String(e.value);break;case 3:this.prompt=String(e.value);break;case 70:this.isInvisible=(r&1)!==0,this.isConst=(r&2)!==0,this.isVerifiable=(r&4)!==0,this.isPreset=(r&8)!==0;break;case 71:this.isMTextAttribute=(r&2)!==0,this.isConstMTextAttribute=(r&4)!==0;break;case 73:this.fieldLength=r;break;case 74:this.verticalMode=r;break;case 280:this.lockPositionInBlock=r!==0;break}}return this}};ha.typeName="AttDef";let In=ha;function Xf(n){return n!=null&&typeof n=="object"&&"blockTableRecord"in n}const ua=class ua extends ni{get dxfTypeName(){return"ATTRIB"}get resolvedColor(){var t;if(this.color.isByBlock){const e=(t=this.database)==null?void 0:t.tables.blockTable.getEntityById(this.ownerId);if(Xf(e))return e.resolvedColor}return this.resolveStandardColor()}constructor(){super(),this._flags=0,this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&dt.Invisible)!==0}set isInvisible(t){t?this._flags|=dt.Invisible:this._flags&=~dt.Invisible}get isConst(){return(this._flags&dt.Const)!==0}set isConst(t){t?this._flags|=dt.Const:this._flags&=~dt.Const}get isVerifiable(){return(this._flags&dt.Verifiable)!==0}set isVerifiable(t){t?this._flags|=dt.Verifiable:this._flags&=~dt.Verifiable}get isPreset(){return(this._flags&dt.Preset)!==0}set isPreset(t){t?this._flags|=dt.Preset:this._flags&=~dt.Preset}get isMTextAttribute(){return(this._mtextFlag&Ht.MultiLine)!==0}set isMTextAttribute(t){t?this._mtextFlag|=Ht.MultiLine:this._mtextFlag&=~Ht.MultiLine}get isConstMTextAttribute(){return(this._mtextFlag&Ht.ConstMultiLine)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=Ht.ConstMultiLine:this._mtextFlag&=~Ht.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}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbAttribute");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code),r=Number(e.value);switch(i){case 2:this.tag=String(e.value);break;case 70:this.isInvisible=(r&dt.Invisible)!==0,this.isConst=(r&dt.Const)!==0,this.isVerifiable=(r&dt.Verifiable)!==0,this.isPreset=(r&dt.Preset)!==0;break;case 71:this.isMTextAttribute=(r&Ht.MultiLine)!==0,this.isConstMTextAttribute=(r&Ht.ConstMultiLine)!==0;break;case 73:this.fieldLength=r;break;case 74:this.verticalMode=r;break;case 280:this.lockPositionInBlock=r!==0;break}}return this}};ua.typeName="Attrib";let Mi=ua;const zf=()=>({hits:0,misses:0,hitMs:0,missBuildMs:0,missCompactMs:0,cloneMs:0,setCloneMs:0,applyMs:0}),yo=()=>({hits:0,misses:0,hitMs:0,missBuildMs:0,missCompactMs:0,cloneMs:0,setCloneMs:0,applyMs:0,topLevel:zf(),blockMisses:[]}),ct=class ct{static get profileStats(){return this._profileStats}static resetProfile(){this._profileStats=yo(),this._drawDepth=0}static get instance(){return this._instance||(this._instance=new ct),this._instance}constructor(){this._blocks=new Map}createKey(t,e){let i=e.toString();return!i&&e.isByColor&&(i=`RGB:${e.red},${e.green},${e.blue}`),`${t}_${i}`}createCacheKey(t,e,i){return i?this.createKey(t,e):t}set(t,e){if(ct.profiling){const i=performance.now();e=e.fastDeepClone();const r=performance.now()-i;ct._profileStats.setCloneMs+=r,ct._drawDepth===1&&(ct._profileStats.topLevel.setCloneMs+=r)}else e=e.fastDeepClone();return this._blocks.set(t,e),e}get(t){let e=this._blocks.get(t);if(e)if(ct.profiling){const i=performance.now();e=e.fastDeepClone();const r=performance.now()-i;ct._profileStats.cloneMs+=r,ct._drawDepth===1&&(ct._profileStats.topLevel.cloneMs+=r)}else e=e.fastDeepClone();return e}has(t){return this._blocks.has(t)}clear(){this._blocks.forEach(t=>{var e;(e=t.dispose)==null||e.call(t)}),this._blocks.clear()}async prebuildAll(t,e,i){const r=[];for(const l of e)!l||!l.name||this.shouldSkipPrebuild(l)||r.push(l);const s=r.length;let a=0;const o=new X().setForeground(),c=new pr;for(const l of r){const h=this.createCacheKey(l.name,o,!1);this.has(h)||this.draw(t,l,o,[],!0),a++,i&&await i(a,s,l.name),await c.maybeYield(ai)}}draw(t,e,i,r=[],s=!0,a,o){const c=ct.profiling;c&&ct._drawDepth++;const l=c&&ct._drawDepth===1,h=ct._profileStats,u=[];try{if(e!=null){const d=i.RGB??0,g=this.blockHasByBlockColor(e),p=this.createCacheKey(e.name,i,g);let f;if(this.has(p)){const b=c?performance.now():0;if(f=this.get(p),c){const _=performance.now()-b;h.hits++,h.hitMs+=_,l&&(h.topLevel.hits++,h.topLevel.hitMs+=_)}}else{const b=c?performance.now():0,_=e.newIterator();for(const P of _)if(P.visibility)if(P.color.isByBlock){const E=new X().copy(P.color);try{i.isForeground?P.color.setForeground():P.color.setRGBValue(d),this.addEntity(P,u,t)}finally{P.color.copy(E)}}else this.addEntity(P,u,t);f=t.group(u);let v=0;c&&(v=performance.now()-b,h.missBuildMs+=v,l&&(h.topLevel.missBuildMs+=v));let x=0;if(f!=null&&f.compactForInstancing){const P=c?performance.now():0;f.compactForInstancing(),c&&(x=performance.now()-P,h.missCompactMs+=x,l&&(h.topLevel.missCompactMs+=x))}const S=c?h.setCloneMs:0;f&&s&&e.name&&!e.name.startsWith("*U")&&this.set(p,f),c&&(h.misses++,l&&h.topLevel.misses++,h.blockMisses.push({blockName:e.name||"(unnamed)",buildMs:v,compactMs:x,setCloneMs:h.setCloneMs-S}))}const m=c?performance.now():0;if(f&&a&&(ln.copy(a),f.applyMatrix(ln),o&&(o.x!=0||o.y!=0||o.z!=1)&&(Vr.setFromExtrusionDirection(o),f.applyMatrix(Vr),ln.premultiply(Vr))),f&&r&&r.length>0){const b=a!=null?jf.copy(ln).invert():void 0;r.forEach(_=>{b&&_.applyMatrix(b),f.addChild(_)})}if(c){const b=performance.now()-m;h.applyMs+=b,l&&(h.topLevel.applyMs+=b)}return f}else return t.group(u)}finally{c&&ct._drawDepth--}}shouldSkipPrebuild(t){const e=t.name;if(tt.isModelSapceName(e)||tt.isPaperSapceName(e)||e.startsWith("*U")||this.blockHasByBlockColor(t))return!0;for(const i of t.newIterator())if(i.visibility)return!1;return!0}blockHasByBlockColor(t){for(const e of t.newIterator())if(e.visibility&&e.color.isByBlock)return!0;return!1}addEntity(t,e,i){if(!t.visibility)return;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}};ct.profiling=!1,ct._profileStats=yo(),ct._drawDepth=0;let Se=ct;const ln=new D,Vr=new D,jf=new D,He=class He extends H{constructor(t){super(),this._columnCount=1,this._rowCount=1,this._columnSpacing=0,this._rowSpacing=0,this._blockName=t,this._position=new y,this._rotation=0,this._normal=new w(0,0,1),this._scaleFactors=new y(1,1,1),this._attribs=new Map}get dxfTypeName(){return"INSERT"}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}set blockName(t){this._blockName=t}get columnCount(){return this._columnCount}set columnCount(t){this._columnCount=Math.max(1,Math.floor(t)||1)}get rowCount(){return this._rowCount}set rowCount(t){this._rowCount=Math.max(1,Math.floor(t)||1)}get columnSpacing(){return this._columnSpacing}set columnSpacing(t){this._columnSpacing=t}get rowSpacing(){return this._rowSpacing}set rowSpacing(t){this._rowSpacing=t}get blockTableRecord(){return this.database.tables.blockTable.getAt(this._blockName)}appendAttributes(t){this._attribs.set(t.objectId,t),t.ownerId=this.objectId,this.syncAttributeDatabases()}syncAttributeDatabases(){try{const t=this.database,e=new Map;this._attribs.forEach(i=>{i.database=t,i.ownerId=this.objectId,t.commitObjectHandle(i),e.set(i.objectId,i)}),this._attribs=e}catch{}}attributeIterator(){return new ei(this._attribs)}get blockTransform(){const t=this.blockTableRecord,e=(t==null?void 0:t.origin)??y.ORIGIN,i=new D().makeTranslation(-e.x,-e.y,-e.z),r=new D().makeScale(this._scaleFactors.x,this._scaleFactors.y,this._scaleFactors.z),s=new Je().setFromAxisAngle(w.Z_AXIS,this._rotation),a=new D().makeRotationFromQuaternion(s),o=new D().makeTranslation(this._position.x,this._position.y,this._position.z);return new D().multiplyMatrices(o,a).multiply(r).multiply(i)}subGetGripPoints(){return[this._position]}subMoveGripPointsAt(t,e){return te(t,e,this._position),this}subGetOsnapPoints(t,e,i,r,s,a){const o=a??new D;k.Insertion===t?r.push(this.getInsertionPoint(o)):s?this.subEntityGetOsnapPoints(t,e,i,r,s,o):this.collectBlockOsnapPoints(t,e,i,r,o)}transformBy(t){const e=new D().setFromExtrusionDirection(this._normal),i=new D().makeRotationZ(this._rotation),r=new D().multiplyMatrices(e,i),s=this._position.clone(),a=new y(this._scaleFactors.x,0,0).applyMatrix4(r).add(s),o=new y(0,this._scaleFactors.y,0).applyMatrix4(r).add(s),c=new y(0,0,this._scaleFactors.z).applyMatrix4(r).add(s);s.applyMatrix4(t),a.applyMatrix4(t),o.applyMatrix4(t),c.applyMatrix4(t);const l=new w(a).sub(s),h=new w(o).sub(s),u=new w(c).sub(s);let d=new w().crossVectors(l,h);d.lengthSq()===0?d=this._normal.clone().transformDirection(t):d.normalize();const p=new D().setFromExtrusionDirection(d).clone().invert(),f=l.clone().applyMatrix4(p);return this._position.copy(s),this._normal.copy(d),this._rotation=Math.atan2(f.y,f.x),this._scaleFactors.set(l.length(),h.length(),u.length()),this._attribs.forEach(m=>m.transformBy(t)),this}get properties(){const t={type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"blockName",type:"float",editable:!1,accessor:{get:()=>this._blockName}},{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:e=>{this.position.x=e}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:e=>{this.position.y=e}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:e=>{this.position.z=e}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:e=>{this.rotation=e}}},{name:"scaleFactorsX",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.x,set:e=>{this.scaleFactors.x=e}}},{name:"scaleFactorsY",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.y,set:e=>{this.scaleFactors.y=e}}},{name:"scaleFactorsZ",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.z,set:e=>{this.scaleFactors.z=e}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:e=>{this.normal.x=e}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:e=>{this.normal.y=e}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:e=>{this.normal.z=e}}}]}]};if(this._attribs.size>0){const e={groupName:"attribute",properties:[]};t.groups.push(e),this._attribs.forEach(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 Y,e=this.blockTableRecord;if(e!=null){const r=e.newIterator();for(const s of r)t.union(s.geometricExtents)}const i=this.blockTransform;return t.applyMatrix4(i),t}subWorldDraw(t){const e=this.blockTableRecord;if(e!=null){const i=[];this._attribs.forEach(o=>{if(!o.isInvisible){const c=o.worldDraw(t);c&&i.push(c)}});const r=Math.max(1,this.columnCount),s=Math.max(1,this.rowCount);if(r===1&&s===1)return Se.instance.draw(t,e,this.resolvedColor,i,!0,this.blockTransform,this._normal);const a=[];for(let o=0;o<s;o++)for(let c=0;c<r;c++){const l=new D().makeTranslation(c*this.columnSpacing,o*this.rowSpacing,0),h=new D().multiplyMatrices(this.blockTransform,l),u=Se.instance.draw(t,e,this.resolvedColor,c===0&&o===0?i:[],!0,h,this._normal);u&&a.push(u)}return t.group(a)}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,e);return i&&(t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity")),this}collectBlockOsnapPoints(t,e,i,r,s){const a=this.blockTableRecord;if(!a)return;const o=new D().multiplyMatrices(s,this.getFullInsertionTransform()),c=o.clone().invert(),l=new y(e).applyMatrix4(c),h=new y(i).applyMatrix4(c),u=[];for(const d of a.newIterator()){const g=[];if(d instanceof He){d.subGetOsnapPoints(t,e,i,g,void 0,o),u.push(...g);continue}d.subGetOsnapPoints(t,l,h,g,void 0,o),g.forEach(p=>u.push(new y(p).applyMatrix4(o)))}if(u.length!==0)if(t===k.Nearest||t===k.Perpendicular||t===k.Tangent){const d=Ft(e,u);d&&r.push(d)}else r.push(...u)}subEntityGetOsnapPoints(t,e,i,r,s,a,o=new Set){if(s===this.objectId||o.has(this.objectId))return!1;o.add(this.objectId);try{const c=this.blockTableRecord;if(c==null)return!1;const l=new D().multiplyMatrices(a,this.getFullInsertionTransform());for(const h of c.newIterator()){if(h.objectId===s){const u=new y(e).applyMatrix4(l.clone().invert()),d=new y(i).applyMatrix4(l.clone().invert()),g=[];return h.subGetOsnapPoints(t,u,d,g,s,l),h instanceof He?g.forEach(p=>{r.push(p.clone())}):g.forEach(p=>{r.push(new y(p).applyMatrix4(l))}),!0}if(h instanceof He&&h.subEntityGetOsnapPoints(t,e,i,r,s,l,o))return!0}return!1}finally{o.delete(this.objectId)}}getInsertionPoint(t){var r;const e=((r=this.blockTableRecord)==null?void 0:r.origin)??y.ORIGIN,i=new D().multiplyMatrices(t,this.getFullInsertionTransform());return new y(e).applyMatrix4(i)}getFullInsertionTransform(){const t=new D().setFromExtrusionDirection(this._normal);return new D().multiplyMatrices(t,this.blockTransform)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbBlockReference"),t.writePoint3d(10,this.position),t.writeString(2,this.blockName),t.writeDouble(41,this.scaleFactors.x),t.writeDouble(42,this.scaleFactors.y),t.writeDouble(43,this.scaleFactors.z),t.writeAngle(50,this.rotation),this.columnCount>1&&t.writeInt16(70,this.columnCount),this.rowCount>1&&t.writeInt16(71,this.rowCount),this.columnSpacing!==0&&t.writeDouble(44,this.columnSpacing),this.rowSpacing!==0&&t.writeDouble(45,this.rowSpacing),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbBlockReference");let e=this.position.x,i=this.position.y,r=this.position.z,s=this.scaleFactors.x,a=this.scaleFactors.y,o=this.scaleFactors.z,c=C.radToDeg(this.rotation),l=this.normal.x,h=this.normal.y,u=this.normal.z,d=this.columnCount,g=this.rowCount,p=this.columnSpacing,f=this.rowSpacing;const m=()=>{this.position=new y(e,i,r),this.scaleFactors=new y(s,a,o),this.rotation=C.degToRad(c),this.normal.copy(new w(l,h,u)),this.columnCount=d>0?d:1,this.rowCount=g>0?g:1,this.columnSpacing=p,this.rowSpacing=f};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const b=t.readItem();if(!b)break;const _=Number(b.code),v=Number(b.value);switch(_){case 10:e=v;break;case 20:i=v;break;case 30:r=v;break;case 2:this.blockName=String(b.value);break;case 41:s=v;break;case 42:a=v;break;case 43:o=v;break;case 44:p=v;break;case 45:f=v;break;case 50:c=v;break;case 66:break;case 70:d=v;break;case 71:g=v;break;case 210:l=v;break;case 220:h=v;break;case 230:u=v;break;case 100:return t.pushBackItem(b),m(),this}}return m(),this}};He.typeName="BlockReference";let Jt=He;const bo=[0,Math.PI/2,Math.PI,Math.PI/2*3],or=class or extends _t{constructor(t,e,i=w.Z_AXIS){super(),this._thickness=0;const r=Ii(i);this._geo=new Kt(t,e,0,j,i,r)}get dxfTypeName(){return"CIRCLE"}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 thickness(){return this._thickness}set thickness(t){this._thickness=t}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}get area(){return this._geo.area}subGetOsnapPoints(t,e,i,r){switch(t){case k.Center:case k.Centroid:r.push(this._geo.center);break;case k.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 k.Nearest:{const s=this._geo.nearestPoint(e);r.push(s)}break;case k.Tangent:{const s=this._geo.tangentPoints(e);r.push(...s);break}case k.Perpendicular:{const s=this._geo.perpendicularPoints(e),a=Ft(e,s);a&&r.push(a);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.area}}]}]}}subGetGripPoints(){const t=new Array;t.push(this.center);for(const e of bo)t.push(this._geo.getPointAtAngle(e));return t}subMoveGripPointsAt(t,e){return ht(t,i=>{this.moveGripAt(i,e)}),this}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){return t.circularArc(this._geo)}dxfOutFields(t){super.dxfOutFields(t);const e=Lt(this.center,this.normal);return t.writeSubclassMarker("AcDbCircle"),t.writePoint3d(10,e),t.writeDouble(40,this.radius),this.thickness!==0&&t.writeDouble(39,this.thickness),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbCircle");let e=0,i=0,r=0,s=this.radius,a=this.normal.x,o=this.normal.y,c=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const l=t.readItem();if(!l)break;const h=Number(l.code),u=Number(l.value);switch(h){case 10:e=u;break;case 20:i=u;break;case 30:r=u;break;case 40:s=u;break;case 39:this.thickness=u;break;case 210:a=u;break;case 220:o=u;break;case 230:c=u;break}}return this.applyDxfInGeometry(e,i,r,s,a,o,c),this}applyDxfInGeometry(t,e,i,r,s,a,o){const c=new w(s,a,o);this.normal.copy(c),this.center=he({x:t,y:e,z:i},c),this.radius=r}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.center,i=this.radius;return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)>=i?1:-1}createOffsetCurve(t){const e=this._geo.offset(t);return e?new or(e.center,e.radius,e.normal):null}moveGripAt(t,e){switch(t){case 0:this.transformBy(D.makeTranslation(e));break;case 1:case 2:case 3:case 4:{const i=bo[t-1],r=this._geo.getPointAtAngle(i),a=new y(r.x+e.x,r.y+e.y,(r.z??0)+(e.z??0)).distanceTo(this.center);a>0&&(this.radius=a);break}}}};or.typeName="Circle";let En=or;const di=[0,Math.PI/2,Math.PI,Math.PI/2*3],cr=class cr extends _t{get dxfTypeName(){return"ELLIPSE"}constructor(t,e,i,r,s,a,o){super(),this._geo=new An(t,e,i,r,s,a,o)}get center(){return this._geo.center}set center(t){this._geo.center=t}get majorAxis(){return this._geo.majorAxis}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||Math.abs(this._geo.deltaAngle-j)<1e-10}get area(){return this._geo.area}subGetGripPoints(){const t=new Array;if(t.push(this._geo.center),this.closed)for(const e of di)t.push(this._geo.getPointAtAngle(e));else t.push(this._geo.startPoint),t.push(this._geo.endPoint);return t}subMoveGripPointsAt(t,e){return ht(t,i=>{this.moveGripAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){switch(t){case k.EndPoint:this.closed||(r.push(this._geo.startPoint),r.push(this._geo.endPoint));break;case k.MidPoint:this.closed||r.push(this._geo.midPoint);break;case k.Center:case k.Centroid:r.push(this._geo.center);break;case k.Quadrant:if(this.closed)for(const s of di)r.push(this._geo.getPointAtAngle(s));break;case k.Nearest:r.push(this._geo.nearestPoint(e));break;case k.Tangent:r.push(...this._geo.tangentPoints(e));break;case k.Perpendicular:{const s=this._geo.perpendicularPoints(e),a=Ft(e,s);a&&r.push(a);break}}}transformBy(t){return this._geo.transform(t),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"majorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.majorAxisRadius,set:t=>{this.center.x=t}}},{name:"minorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.minorAxisRadius,set:t=>{this.minorAxisRadius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this.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}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbEllipse");let e=this.center.x,i=this.center.y,r=this.center.z,s=this.majorAxis.x*this.majorAxisRadius,a=this.majorAxis.y*this.majorAxisRadius,o=this.majorAxis.z*this.majorAxisRadius,c=this.normal.x,l=this.normal.y,h=this.normal.z,u=this.majorAxisRadius>0?this.minorAxisRadius/this.majorAxisRadius:1,d=this.startAngle,g=this.endAngle;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const p=t.readItem();if(!p)break;const f=Number(p.code),m=Number(p.value);switch(f){case 10:e=m;break;case 20:i=m;break;case 30:r=m;break;case 11:s=m;break;case 21:a=m;break;case 31:o=m;break;case 210:c=m;break;case 220:l=m;break;case 230:h=m;break;case 40:u=m;break;case 41:d=m;break;case 42:g=m;break}}return this.applyDxfInGeometry(e,i,r,s,a,o,c,l,h,u,d,g),this}applyDxfInGeometry(t,e,i,r,s,a,o,c,l,h,u,d){const g=Math.hypot(r,s,a)||1;this._geo=new An({x:t,y:e,z:i},{x:o,y:c,z:l},{x:r,y:s,z:a},g,g*h,u,d)}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.center,i=t.x-e.x,r=t.y-e.y,s=this.majorAxis,a=Math.hypot(s.x,s.y)||1,o=this.minorAxisRadius/this.majorAxisRadius*a||1,c=s.x/a,l=s.y/a,h=-l,u=c,d=i*c+r*l,g=i*h+r*u;return(d/a)**2+(g/o)**2>=1?1:-1}moveGripAt(t,e){switch(t){case 0:this.transformBy(D.makeTranslation(e));break;case 1:if(this.closed)this.moveQuadrantGripAt(di[0],e);else{const i=this._geo.startPoint;this._geo.startAngle=ae(this._geo.center,{x:i.x+e.x,y:i.y+e.y,z:(i.z??0)+(e.z??0)},this._geo.normal)}break;case 2:if(this.closed)this.moveQuadrantGripAt(di[1],e);else{const i=this._geo.endPoint;this._geo.endAngle=ae(this._geo.center,{x:i.x+e.x,y:i.y+e.y,z:(i.z??0)+(e.z??0)},this._geo.normal)}break;case 3:case 4:this.closed&&this.moveQuadrantGripAt(di[t-1],e);break}}moveQuadrantGripAt(t,e){const i=this._geo.getPointAtAngle(t),r=new y(i.x+e.x,i.y+e.y,(i.z??0)+(e.z??0)),s=this._geo.center,a=r.x-s.x,o=r.y-s.y,c=(r.z??0)-(s.z??0),l=t===0||t===Math.PI?this._geo.majorAxis:this._geo.minorAxis,h=a*l.x+o*l.y+c*l.z,u=Math.abs(h);u<=0||(t===0||t===Math.PI?this.majorAxisRadius=u:this.minorAxisRadius=u)}createOffsetCurve(t){const e=this._geo.offset(t);return e?new cr(e.center,e.normal,e.majorAxis,e.majorAxisRadius,e.minorAxisRadius,e.startAngle,e.endAngle):null}};cr.typeName="Ellipse";let Ln=cr;const da=class da extends H{get dxfTypeName(){return"3DFACE"}constructor(){super(),this._vertices=[new y,new y,new y],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 y),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 Y().setFromPoints(this._vertices)}get area(){const t=[this.getVertexAt(0),this.getVertexAt(1),this.getVertexAt(2)],e=this.getVertexAt(3);return(e.x!==t[2].x||e.y!==t[2].y||e.z!==t[2].z)&&t.push(e),wc(t)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subMoveGripPointsAt(t,e){return ci(t,e,this._vertices),this}subGetOsnapPoints(t,e,i,r){_r(this._vertices,!0,t,e,r)}transformBy(t){return this._vertices.forEach(e=>e.applyMatrix4(t)),this}subWorldDraw(t){const e=this._vertices.length,i=new Float32Array(e*3),r=new Uint16Array(e*2);for(let s=0;s<e;s++)i[s*3]=this._vertices[s].x,i[s*3+1]=this._vertices[s].y,i[s*3+2]=this._vertices[s].z,this.isEdgeVisibleAt(s)&&(r[s*2]=s,r[s*2+1]=(s+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),s=this.getVertexAt(3);t.writeSubclassMarker("AcDbFace"),t.writePoint3d(10,e),t.writePoint3d(11,i),t.writePoint3d(12,r),t.writePoint3d(13,s);let a=0;for(let o=0;o<4;++o)this.isEdgeVisibleAt(o)||(a|=1<<o);return t.writeInt16(70,a),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbFace");const e=[0,1,2,3].map(r=>{const s=this._vertices[r];return s?{x:s.x,y:s.y,z:s.z}:{x:0,y:0,z:0}});let i=this._edgeInvisibilities;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const r=t.readItem();if(!r)break;const s=Number(r.code),a=Number(r.value);switch(s){case 10:case 11:case 12:case 13:e[s-10].x=a;break;case 20:case 21:case 22:case 23:e[s-20].y=a;break;case 30:case 31:case 32:case 33:e[s-30].z=a;break;case 70:i=a;break}}return e.forEach((r,s)=>this.setVertexAt(s,r)),this._edgeInvisibilities=i,this}};da.typeName="Face";let Tn=da;var St=(n=>(n[n.DecimalDegrees=0]="DecimalDegrees",n[n.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",n[n.Gradians=2]="Gradians",n[n.Radians=3]="Radians",n[n.SurveyorsUnits=4]="SurveyorsUnits",n))(St||{}),rt=(n=>(n[n.Scientific=1]="Scientific",n[n.Decimal=2]="Decimal",n[n.Engineering=3]="Engineering",n[n.Architectural=4]="Architectural",n[n.Fractional=5]="Fractional",n[n.WindowsDesktop=6]="WindowsDesktop",n))(rt||{}),J=(n=>(n[n.Undefined=0]="Undefined",n[n.Inches=1]="Inches",n[n.Feet=2]="Feet",n[n.Miles=3]="Miles",n[n.Millimeters=4]="Millimeters",n[n.Centimeters=5]="Centimeters",n[n.Meters=6]="Meters",n[n.Kilometers=7]="Kilometers",n[n.Microinches=8]="Microinches",n[n.Mils=9]="Mils",n[n.Yards=10]="Yards",n[n.Angstroms=11]="Angstroms",n[n.Nanometers=12]="Nanometers",n[n.Microns=13]="Microns",n[n.Decimeters=14]="Decimeters",n[n.Dekameters=15]="Dekameters",n[n.Hectometers=16]="Hectometers",n[n.Gigameters=17]="Gigameters",n[n.Astronomical=18]="Astronomical",n[n.LightYears=19]="LightYears",n[n.Parsecs=20]="Parsecs",n[n.USSurveyFeet=21]="USSurveyFeet",n[n.USSurveyInch=22]="USSurveyInch",n[n.USSurveyYard=23]="USSurveyYard",n[n.USSurveyMile=24]="USSurveyMile",n[n.Max=24]="Max",n))(J||{});function Vf(n){return n==4||n==5||n==6||n==7||n==12||n==13||n==14||n==15||n==16||n==17}function Gf(n){return n==1||n==2||n==3||n==8||n==9||n==10||n==21}const I={ACADVER:"ACADVER",ANGBASE:"ANGBASE",ANGDIR:"ANGDIR",AUNITS:"AUNITS",AUPREC:"AUPREC",CECOLOR:"CECOLOR",CELTSCALE:"CELTSCALE",CELTYPE:"CELTYPE",CELWEIGHT:"CELWEIGHT",CETRANSPARENCY:"CETRANSPARENCY",CLAYER:"CLAYER",CMLEADERSTYLE:"CMLEADERSTYLE",CMLSCALE:"CMLSCALE",CMLSTYLE:"CMLSTYLE",COLORTHEME:"COLORTHEME",DYNMODE:"DYNMODE",DYNPROMPT:"DYNPROMPT",DWGNAME:"DWGNAME",EXTMAX:"EXTMAX",EXTMIN:"EXTMIN",GRIPCOLOR:"GRIPCOLOR",GRIPHOT:"GRIPHOT",GRIPOBJLIMIT:"GRIPOBJLIMIT",GRIPS:"GRIPS",GRIPSIZE:"GRIPSIZE",HPANG:"HPANG",HPASSOC:"HPASSOC",HPBACKGROUNDCOLOR:"HPBACKGROUNDCOLOR",HPCOLOR:"HPCOLOR",HPDOUBLE:"HPDOUBLE",HPISLANDDETECTION:"HPISLANDDETECTION",HPLAYER:"HPLAYER",HPNAME:"HPNAME",HPSCALE:"HPSCALE",HPSEPARATE:"HPSEPARATE",HPTRANSPARENCY:"HPTRANSPARENCY",INSUNITS:"INSUNITS",LTSCALE:"LTSCALE",LUNITS:"LUNITS",LUPREC:"LUPREC",LWDISPLAY:"LWDISPLAY",MEASUREMENT:"MEASUREMENT",MEASUREMENTCOLOR:"MEASUREMENTCOLOR",MODELBKCOLOR:"MODELBKCOLOR",OSMODE:"OSMODE",ORTHOMODE:"ORTHOMODE",OPENPROF:"OPENPROF",PAPERBKCOLOR:"PAPERBKCOLOR",PDMODE:"PDMODE",PDSIZE:"PDSIZE",PICKBOX:"PICKBOX",POLARADDANG:"POLARADDANG",POLARMODE:"POLARMODE",POLARANG:"POLARANG",SHORTCUTMENU:"SHORTCUTMENU",TEXTSTYLE:"TEXTSTYLE",DIMSTYLE:"DIMSTYLE",UNITMODE:"UNITMODE"},Uf=Object.freeze(Object.values(I)),lr=class lr{constructor(){this.registry=new Map,this.cache=new Map,this.events={sysVarChanged:new at},this.registerVar({name:I.ANGBASE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:I.ANGDIR,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:I.AUNITS,type:"number",isDbVar:!0,defaultValue:St.DecimalDegrees}),this.registerVar({name:I.AUPREC,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:I.CECOLOR,type:"color",isDbVar:!0,defaultValue:new X(exports.AcCmColorMethod.ByLayer)}),this.registerVar({name:I.CELTSCALE,type:"number",isDbVar:!0,defaultValue:-1}),this.registerVar({name:I.CELTYPE,type:"string",isDbVar:!0,defaultValue:lt}),this.registerVar({name:I.CELWEIGHT,type:"number",isDbVar:!0,defaultValue:exports.AcGiLineWeight.ByLayer}),this.registerVar({name:I.CETRANSPARENCY,type:"transparency",isDbVar:!0,defaultValue:new ot}),this.registerVar({name:I.CLAYER,type:"string",isDbVar:!0,defaultValue:"0"}),this.registerVar({name:I.CMLEADERSTYLE,type:"string",isDbVar:!0,defaultValue:ce}),this.registerVar({name:I.CMLSCALE,type:"number",isDbVar:!0,defaultValue:1}),this.registerVar({name:I.CMLSTYLE,type:"string",isDbVar:!0,defaultValue:oe}),this.registerVar({name:I.COLORTHEME,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:I.DYNMODE,type:"number",isDbVar:!1,defaultValue:3}),this.registerVar({name:I.DYNPROMPT,type:"boolean",isDbVar:!1,defaultValue:!0}),this.registerVar({name:I.DWGNAME,type:"string",isDbVar:!0,readOnly:!0,defaultValue:"Drawing1.dwg"}),this.registerVar({name:I.GRIPCOLOR,type:"number",isDbVar:!1,defaultValue:nl}),this.registerVar({name:I.GRIPHOT,type:"number",isDbVar:!1,defaultValue:rl}),this.registerVar({name:I.GRIPOBJLIMIT,type:"number",isDbVar:!1,defaultValue:100}),this.registerVar({name:I.GRIPS,type:"number",isDbVar:!1,defaultValue:2}),this.registerVar({name:I.GRIPSIZE,type:"number",isDbVar:!1,defaultValue:sl}),this.registerVar({name:I.HPANG,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:I.HPASSOC,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:I.HPBACKGROUNDCOLOR,type:"color",isDbVar:!0,defaultValue:new X(exports.AcCmColorMethod.None)}),this.registerVar({name:I.HPCOLOR,type:"color",isDbVar:!0,defaultValue:new X(exports.AcCmColorMethod.ByLayer)}),this.registerVar({name:I.HPDOUBLE,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:I.HPISLANDDETECTION,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:I.HPLAYER,type:"string",isDbVar:!0,defaultValue:"."}),this.registerVar({name:I.HPNAME,type:"string",isDbVar:!1,defaultValue:tl}),this.registerVar({name:I.HPSCALE,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:I.HPSEPARATE,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:I.HPTRANSPARENCY,type:"transparency",isDbVar:!0,defaultValue:new ot}),this.registerVar({name:I.INSUNITS,type:"number",isDbVar:!0,defaultValue:J.Millimeters}),this.registerVar({name:I.LUNITS,type:"number",isDbVar:!0,defaultValue:rt.Decimal}),this.registerVar({name:I.LUPREC,type:"number",isDbVar:!0,defaultValue:4}),this.registerVar({name:I.LWDISPLAY,type:"boolean",isDbVar:!0,defaultValue:!1}),this.registerVar({name:I.MEASUREMENT,type:"number",isDbVar:!0,defaultValue:1}),this.registerVar({name:I.MEASUREMENTCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new X(exports.AcCmColorMethod.ByColor);return t.setRGB(96,165,250),t})()}),this.registerVar({name:I.MODELBKCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new X(exports.AcCmColorMethod.ByColor);return t.setRGB(0,0,0),t})()}),this.registerVar({name:I.OSMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:I.ORTHOMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:I.OPENPROF,type:"boolean",isDbVar:!1,defaultValue:!1}),this.registerVar({name:I.PAPERBKCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new X(exports.AcCmColorMethod.ByColor);return t.setRGB(255,255,255),t})()}),this.registerVar({name:I.PICKBOX,type:"number",isDbVar:!1,defaultValue:10}),this.registerVar({name:I.POLARADDANG,type:"string",isDbVar:!1,defaultValue:""}),this.registerVar({name:I.POLARMODE,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:I.POLARANG,type:"number",isDbVar:!1,defaultValue:90}),this.registerVar({name:I.SHORTCUTMENU,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:I.TEXTSTYLE,type:"string",isDbVar:!0,defaultValue:Z}),this.registerVar({name:I.UNITMODE,type:"number",isDbVar:!0,defaultValue:0})}static instance(){return this._instance||(this._instance=new lr),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}applyVarMutation(t,e,i,r,s){const a=this.normalizeName(t);if(this.hasValueChanged(e,i)){if(r.transactionManager.isRecording())r.transactionManager.recordSysvar(a,e);else if(r.transactionManager.strictMode&&!r.transactionManager.isApplyingUndoRedo())throw new Error(`Cannot change system variable ${a} outside an active transaction.`);s(),!r.transactionManager.isApplyingUndoRedo()&&!r.transactionManager.isRecording()&&this.events.sysVarChanged.dispatch({database:r,name:a,newVal:i,oldVal:e})}}setVar(t,e,i){t=this.normalizeName(t);const r=this.getDescriptor(t);if(r){if(r.readOnly)throw new Error(`System variable ${t} is read-only!`);const s=this.getVar(t,i);if(r.type==="transparency"){const a=this.parseTransparency(e);if(a==null||a.isInvalid)throw new Error("Invalid transparency value!");e=a}else 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=this.parseColorSysVar(t,e,i);if(a==null)throw new Error("Invalid color value!");e=a}}if(t===I.GRIPCOLOR.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<gs||a>fs)throw new Error(`Invalid GRIPCOLOR value! Valid range is ${gs} to ${fs}.`);e=a}if(t===I.GRIPHOT.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<ps||a>ms)throw new Error(`Invalid GRIPHOT value! Valid range is ${ps} to ${ms}.`);e=a}if(t===I.GRIPOBJLIMIT.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<0||a>32767)throw new Error("Invalid GRIPOBJLIMIT value! Valid range is 0 to 32767.");e=a}if(t===I.GRIPS.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<0||a>2)throw new Error("Invalid GRIPS value! Valid range is 0 to 2.");e=a}if(t===I.GRIPSIZE.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<ys||a>bs)throw new Error(`Invalid GRIPSIZE value! Valid range is ${ys} to ${bs}.`);e=a}r.isDbVar?this.applyVarMutation(t,s,e,i,()=>{i[t.toLowerCase()]=e}):this.applyVarMutation(t,s,e,i,()=>{this.cache.set(t,e)})}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)}parseColorSysVar(t,e,i){const r=e.trim().toLowerCase();return t===I.HPCOLOR.toLowerCase()&&(r==="."||r==="use current")?i.cecolor.clone():t===I.HPBACKGROUNDCOLOR.toLowerCase()&&(r===""||r==="."||r==="none")?new X(exports.AcCmColorMethod.None):X.fromString(e)}parseTransparency(t){if(t instanceof ot)return t;if(typeof t=="number")return ot.deserialize(t);if(!(typeof t!="string"&&!(t instanceof String)))return ot.fromString(String(t))}hasValueChanged(t,e){return t instanceof X&&e instanceof X||t instanceof ot&&e instanceof ot?!t.equals(e):!Object.is(t,e)}normalizeName(t){return t.toLowerCase()}};lr._instance=null;let gt=lr;const Tl="Load Database",_o=3e4,Hf=12e4,Wf=1024*1024;class At extends Wo{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=Rs.getInstance().getEntry(Tl),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 Zs{constructor(t={}){this.config={useWorker:t.useWorker??!0,...t}}async read(t,e,i,r,s,a){const o={name:Tl,data:{total:0},format(){let u="";return Object.keys(this.data).forEach(d=>{d!=="total"&&(u+=`- ${d}: ${this.data[d]} ms
10
- `)}),u+=`- total: ${this.data.total} ms`,u}};Rs.getInstance().collect(o),this.progress=r;const c={value:0},l=new $o;l.setCompleteCallback(()=>this.onFinished()),l.setErrorCallback(u=>this.onError(u)),l.addTask(new At({stage:"START",step:1,progress:c,task:async u=>u},r)),l.addTask(new At({stage:"PARSE",step:5,progress:c,task:async u=>await this.parse(u,s)},r)),l.addTask(new At({stage:"FONT",step:5,progress:c,task:async u=>{const d=this.getFonts(u.model);return{model:u.model,data:d}}},r)),l.addTask(new At({stage:"LTYPE",step:1,progress:c,task:async u=>(this.processLineTypes(u.model,e),u)},r)),l.addTask(new At({stage:"STYLE",step:1,progress:c,task:async u=>(this.processTextStyles(u.model,e),u)},r)),l.addTask(new At({stage:"DIMSTYLE",step:1,progress:c,task:async u=>(this.processDimStyles(u.model,e),u)},r)),l.addTask(new At({stage:"LAYER",step:1,progress:c,task:async u=>(this.processLayers(u.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),u)},r)),l.addTask(new At({stage:"VPORT",step:1,progress:c,task:async u=>(this.processViewports(u.model,e),u)},r)),l.addTask(new At({stage:"HEADER",step:1,progress:c,task:async u=>{if(this.processClasses(u.model,e),this.processHeader(u.model,e),a){const d=gt.instance();for(const[g,p]of Object.entries(a))d.setVar(g,p,e)}return u}},r)),l.addTask(new At({stage:"BLOCK_RECORD",step:5,progress:c,task:async u=>(this.processBlockTables(u.model,e),u)},r)),l.addTask(new At({stage:"OBJECT",step:5,progress:c,task:async u=>(this.processObjects(u.model,e),e.objects.layout.numEntries===0&&e.createDefaultData({layout:!0}),u)},r)),l.addTask(new At({stage:"BLOCK",step:5,progress:c,task:async u=>(await this.processBlocks(u.model,e),u)},r)),l.addTask(new At({stage:"ENTITY",step:100,progress:c,task:async u=>(await this.processEntities(u.model,e,i,c,r),u)},r)),l.addTask(new At({stage:"END",step:0,progress:c,task:async u=>u},r));const h=Date.now();await l.run(t),o.data.total=Date.now()-h}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"),Se.instance.clear())}getParserWorkerTimeout(t,e){const i=e??this.config.timeout;if(i!=null)return i;const r=Math.ceil(t.byteLength/Wf),s=_o+r*1e3;return Math.min(Hf,Math.max(_o,s))}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!")}processClasses(t,e){}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,s){throw new Error("Not impelemented yet!")}}class Cl{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)}async scheduleTask(t){await ai(),await t()}async processChunk(t,e){if(this._count<=0){await(e==null?void 0:e());return}let i=0;const r=async()=>{const s=i,a=Math.min(i+this._chunkSize,this._count);await t(s,a),i=a,i<this._count&&await this.scheduleTask(r)};await r(),await(e==null?void 0:e())}}class Ml extends Zs{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}getFonts(){return[]}async processEntities(t,e,i,r,s){let a=t.tables.blockTable.modelSpace.newIterator().toArray();const o=a.length,c=new Cl(o,100-r.value,i);this.config.convertByEntityType&&(a=this.groupAndFlattenByType(a));const l=e.tables.blockTable.modelSpace;await c.processChunk(async(h,u)=>{let d=[],g=h<u?a[h].type:"";for(let p=h;p<u;p++){const f=a[p];this.config.convertByEntityType&&f.type!==g&&(this.triggerEvents(l,d),d=[],g=f.type),d.push(f)}if(this.triggerEvents(l,d),s){let p=r.value+u/o*(100-r.value);p>100&&(p=100),await s(p,"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(){}processClasses(){}processBlockTables(){}processObjects(){const t=this._database.objects.layout.newIterator();for(const a of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.layoutName});const e=this._database.objects.imageDefinition.newIterator();for(const a of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.objectId});const i=this._database.objects.mleaderStyle.newIterator();for(const a of i)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.objectId});const r=this._database.objects.layerFilter.newIterator();for(const a of r)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.objectId});const s=this._database.objects.layerIndex.newIterator();for(const a of s)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.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})}}const $f=/\\[fF](.*?)\|/g,qf=/\\[fF]([^|;]+);/g;class ft{constructor(t){this.styles=t.styles,this.styleMap=ft.buildStyleFontMap(this.styles),this.textStyleVar=t.textStyleVar??Z}collect(t,e){const i=new Set;for(const r of ft.collectShapeDefinitionFonts(this.styles))i.add(r);for(const r of ft.collectNamedStyleTableFonts(this.styles))i.add(r);return this.collectFromEntities(t,e,i),Array.from(i)}static normalizeFontFileName(t){if(!t)return;const e=t.lastIndexOf(".");return e>=0?t.substring(0,e).toLowerCase():t.toLowerCase()}collectFromEntities(t,e,i){for(const r of t){const s=e.getEntityFontInfo(r);if(s){if(s.formattedText)for(const a of ft.extractInlineMTextFonts(s.formattedText))i.add(a);if(s.resolveStyle&&this.addResolvedStyleFonts(s.styleName,i),s.blockName&&e.getBlockEntities){const a=e.getBlockEntities(s.blockName);a&&this.collectFromEntities(a,e,i)}}}}resolveStyleFontNames(t){const e=[],i=r=>{const s=r==null?void 0:r.trim();s&&!e.includes(s)&&e.push(s)};i(t),i(this.textStyleVar),i(Z),i("STANDARD");for(const r of e){const s=this.styleMap.get(r);if(s)return s;const a=r.toUpperCase();for(const[o,c]of this.styleMap)if(o.toUpperCase()===a)return c}return this.styleMap.values().next().value}addResolvedStyleFonts(t,e){const i=this.resolveStyleFontNames(t);i==null||i.forEach(r=>e.add(r))}static buildStyleFontMap(t){const e=new Map;for(const i of t)e.set(i.name,ft.collectStyleEntryFontNames(i));return e}static collectStyleEntryFontNames(t){const e=[];for(const i of[t.font,t.bigFont,t.extendedFont]){const r=ft.normalizeFontFileName(i);r&&e.push(r)}return e}static collectNamedStyleTableFonts(t){const e=[];for(const i of t)i.standardFlag&&i.standardFlag&1||e.push(...ft.collectStyleEntryFontNames(i));return e}static collectShapeDefinitionFonts(t){const e=[];for(const i of t)if(i.standardFlag&&i.standardFlag&1){const r=ft.normalizeFontFileName(i.font);r&&e.push(r)}return e}static extractInlineMTextFonts(t){const e=new Set;for(const i of t.matchAll($f))e.add(i[1].toLowerCase());for(const i of t.matchAll(qf))e.add(i[1].toLowerCase());return Array.from(e)}static collectInlineMTextFonts(t){return ft.extractInlineMTextFonts(t)}}var Ol=(n=>(n[n.Center=0]="Center",n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.OverFirst=3]="OverFirst",n[n.OverSecond=4]="OverSecond",n))(Ol||{}),Qs=(n=>(n[n.Center=0]="Center",n[n.Above=1]="Above",n[n.Outside=2]="Outside",n[n.JIS=3]="JIS",n[n.Below=4]="Below",n))(Qs||{}),Nl=(n=>(n[n.Feet=0]="Feet",n[n.None=1]="None",n[n.Inch=2]="Inch",n[n.FeetAndInch=3]="FeetAndInch",n[n.Leading=4]="Leading",n[n.Trailing=8]="Trailing",n[n.LeadingAndTrailing=12]="LeadingAndTrailing",n))(Nl||{}),Rl=(n=>(n[n.None=0]="None",n[n.Leading=1]="Leading",n[n.Trailing=2]="Trailing",n[n.LeadingAndTrailing=3]="LeadingAndTrailing",n))(Rl||{}),Bl=(n=>(n[n.Bottom=0]="Bottom",n[n.Middle=1]="Middle",n[n.Top=2]="Top",n))(Bl||{});const hr=class hr extends ge{constructor(t,e){t=t||{},Bt(t,hr.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)}dxfOut(...t){const[e,i=!1]=t;return e.writeHandle(105,this.objectId),e.writeObjectId(330,this.ownerId),e.writeObjectId(360,this.extensionDictionary),this.dxfOutFields(e),i&&this.dxfOutXData(e),this}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),s=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,s==null?void 0:s.objectId),t.writeObjectId(344,a==null?void 0:a.objectId),t.writeInt16(371,this.dimlwd),t.writeInt16(372,this.dimlwe),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbDimStyleTableRecord");const e=i=>i===0?0:1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const i=t.readItem();if(!i)break;const r=Number(i.code);if(r===100){t.pushBackItem(i);break}const s=Number(i.value);switch(r){case 2:this.name=String(i.value);break;case 70:break;case 3:this.dimpost=String(i.value);break;case 4:this.dimapost=String(i.value);break;case 5:this.dimblk=String(i.value);break;case 6:this.dimblk1=String(i.value);break;case 7:this.dimblk2=String(i.value);break;case 40:this.dimscale=s;break;case 41:this.dimasz=s;break;case 42:this.dimexo=s;break;case 43:this.dimdli=s;break;case 44:this.dimexe=s;break;case 45:this.dimrnd=s;break;case 46:this.dimdle=s;break;case 47:this.dimtp=s;break;case 48:this.dimtm=s;break;case 140:this.dimtxt=s;break;case 141:this.dimcen=s;break;case 142:this.dimtsz=s;break;case 143:this.dimaltf=s;break;case 144:this.dimlfac=s;break;case 145:this.dimtvp=s;break;case 146:this.dimtfac=s;break;case 147:this.dimgap=s;break;case 148:this.dimaltrnd=s;break;case 71:this.dimtol=e(s);break;case 72:this.dimlim=e(s);break;case 73:this.dimtih=e(s);break;case 74:this.dimtoh=e(s);break;case 75:this.dimse1=e(s);break;case 76:this.dimse2=e(s);break;case 77:this.dimtad=s;break;case 78:this.dimzin=s;break;case 79:this.dimazin=s;break;case 170:this.dimalt=e(s);break;case 171:this.dimaltd=s;break;case 172:this.dimtofl=e(s);break;case 173:this.dimsah=e(s);break;case 174:this.dimtix=e(s);break;case 175:this.dimsoxd=e(s);break;case 176:this.dimclrd=s;break;case 177:this.dimclre=s;break;case 178:this.dimclrt=s;break;case 179:this.dimadec=s;break;case 270:this.dimunit=s;break;case 271:this.dimdec=s;break;case 272:this.dimtdec=s;break;case 273:this.dimaltu=s;break;case 274:this.dimalttd=s;break;case 275:this.dimaunit=s;break;case 276:this.dimfrac=s;break;case 277:this.dimlunit=s;break;case 278:this.dimdsep=typeof i.value=="string"?i.value:String.fromCharCode(s||46);break;case 279:this.dimtmove=s;break;case 280:this.dimjust=s;break;case 281:this.dimsd1=e(s);break;case 282:this.dimsd2=e(s);break;case 283:this.dimtolj=s;break;case 284:this.dimtzin=s;break;case 285:this.dimaltz=s;break;case 286:this.dimalttz=s;break;case 287:this.dimfit=s;break;case 288:this.dimupt=e(s);break;case 289:this.dimatfit=s;break;case 340:this.dimtxsty=String(i.value);break;case 341:this.dimldrblk=String(i.value);break;case 342:this.dimblk=String(i.value);break;case 343:this.dimblk1=String(i.value);break;case 344:this.dimblk2=String(i.value);break;case 371:this.dimlwd=s;break;case 372:this.dimlwe=s;break}}return this}};hr.DEFAULT_DIM_VALUES={name:"",dimpost:"",dimapost:"",dimscale:1,dimasz:2.5,dimexo:.625,dimdli:.38,dimexe:.18,dimrnd:0,dimdle:0,dimtp:0,dimtm:0,dimtxt:2.5,dimcen:2.5,dimtsz:0,dimaltf:0,dimlfac:1,dimtvp:0,dimtfac:1,dimgap:1,dimaltrnd:0,dimtol:0,dimlim:0,dimtih:0,dimtoh:0,dimse1:0,dimse2:0,dimtad:0,dimzin:0,dimazin:0,dimalt:0,dimaltd:2,dimtofl:0,dimsah:0,dimtix:0,dimsoxd:0,dimclrd:0,dimclre:0,dimclrt:0,dimadec:0,dimunit:2,dimdec:4,dimtdec:4,dimaltu:2,dimalttd:2,dimaunit:0,dimfrac:0,dimlunit:2,dimdsep:".",dimtmove:0,dimjust:0,dimsd1:0,dimsd2:0,dimtolj:0,dimtzin:0,dimaltz:0,dimalttz:0,dimfit:0,dimupt:0,dimatfit:3,dimtxsty:Z,dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let Tt=hr;function Fl(){return{color:new X,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:new ot,linetype:"",lineWeight:1,materialId:-1}}const Kf=["name",...Object.keys(Fl())];class Zi extends ge{constructor(t,e){t=t||{},Bt(t,Fl()),super(t,e)}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.writeLineWeight(370,this.lineWeight),t.writeTransparency(this.transparency),this.description&&t.writeString(4,this.description),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbLayerTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}switch(i){case 2:this.name=String(e.value);break;case 70:this.standardFlags=Number(e.value);break;case 62:{const r=Number(e.value);this.isOff=r<0,this.color.colorIndex=Math.abs(r);break}case 420:this.color.setRGBValue(Number(e.value));break;case 6:this.linetype=String(e.value);break;case 290:this.isPlottable=Number(e.value)!==0;break;case 370:this.lineWeight=Number(e.value);break;case 440:this.transparency=ot.deserialize(Number(e.value));break;case 4:this.description=String(e.value);break}}return this}}class ve extends ge{constructor(t,e){t=t||{},Bt(t,{standardFlag:0,description:"",totalPatternLength:0}),super(t,e)}get numDashes(){const t=this.getAttrWithoutException("pattern");return t?t.length:0}get patternLength(){return this.getAttr("totalPatternLength")}get comments(){return this.getAttr("description")}get linetype(){return{name:this.name,standardFlag:this.getAttr("standardFlag"),description:this.getAttr("description"),totalPatternLength:this.getAttr("totalPatternLength"),pattern:this.getAttrWithoutException("pattern")}}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.getAttr("pattern")[t].elementLength}toPreviewSvgString(t){const e=Math.max((t==null?void 0:t.width)??220,1),i=Math.max((t==null?void 0:t.height)??36,1),r=Math.min(Math.max((t==null?void 0:t.padding)??8,0),Math.floor(e/2)),s=Math.max((t==null?void 0:t.strokeWidth)??2,.5),a=this.escapeSvgAttribute((t==null?void 0:t.stroke)??"currentColor"),o=Math.max((t==null?void 0:t.repeats)??4,1),c=i/2,l=r,h=Math.max(e-r,l+1),u=h-l,d=this.getAttrWithoutException("pattern")??[];if(d.length===0||this.patternLength<=0||!d.some(v=>v.elementLength!==0))return this.buildSvgString({width:e,height:i,stroke:a,strokeWidth:s,lineSegments:[[l,h]],dots:[],y:c});const g=[],p=[],f=u/(this.patternLength*o),m=.5,b=Math.max(s*2,2);let _=l;for(;_<h;)for(const v of d){if(_>=h)break;const x=v.elementLength;if(x===0){p.push(_),_=Math.min(_+b,h);continue}const S=Math.max(Math.abs(x)*f,m),P=Math.min(_+S,h);x>0&&P>_&&g.push([_,P]),_=P}return this.buildSvgString({width:e,height:i,stroke:a,strokeWidth:s,lineSegments:g,dots:p,y:c})}buildSvgString(t){const{width:e,height:i,stroke:r,strokeWidth:s,lineSegments:a,dots:o,y:c}=t,l=a.map(([u,d])=>`<line x1="${u.toFixed(2)}" y1="${c.toFixed(2)}" x2="${d.toFixed(2)}" y2="${c.toFixed(2)}" stroke="${r}" stroke-width="${s.toFixed(2)}" stroke-linecap="round" />`).join(""),h=o.map(u=>`<circle cx="${u.toFixed(2)}" cy="${c.toFixed(2)}" r="${(s/2).toFixed(2)}" fill="${r}" />`).join("");return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}" viewBox="0 0 ${e} ${i}" role="img" aria-label="${this.escapeSvgAttribute(this.name)} linetype preview">${l}${h}</svg>`}escapeSvgAttribute(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;")}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLinetypeTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.getAttr("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.getAttrWithoutException("pattern")??[])t.writeDouble(49,e.elementLength),t.writeInt16(74,e.elementTypeFlag);return this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbLinetypeTableRecord");const e=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const i=t.readItem();if(!i)break;const r=Number(i.code);if(r===100){t.pushBackItem(i);break}switch(r){case 2:this.name=String(i.value);break;case 70:this.setAttr("standardFlag",Number(i.value));break;case 3:this.setAttr("description",String(i.value));break;case 72:break;case 73:break;case 40:this.setAttr("totalPatternLength",Number(i.value));break;case 49:e.push({elementLength:Number(i.value),elementTypeFlag:0});break;case 74:e.length>0&&(e[e.length-1].elementTypeFlag=Number(i.value));break}}return this.setAttr("pattern",e),this}}class Cn extends ge{constructor(t){typeof t=="string"&&(t={name:t}),super(t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRegAppTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbRegAppTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}switch(i){case 2:this.name=String(e.value);break}}return this}}class xr extends ge{constructor(t,e){t=t||{},Bt(t,{standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:0,font:"",bigFont:""}),super(t,e),this.setAttr("font",this.getFileNameWithoutExtension(this.getAttr("font")||this.getAttrWithoutException("extendedFont")||this.name))}get obliquingAngle(){return this.getAttr("obliqueAngle")}set obliquingAngle(t){this.setAttr("obliqueAngle",t)}get priorSize(){return this.getAttr("lastHeight")}set priorSize(t){this.setAttr("lastHeight",t)}get textSize(){return this.getAttr("fixedTextHeight")}set textSize(t){this.setAttr("fixedTextHeight",t)}get xScale(){return this.getAttr("widthFactor")}set xScale(t){this.setAttr("widthFactor",t)}get isVertical(){return(this.getAttr("standardFlag")&4)===4}set isVertical(t){const e=this.getAttr("standardFlag");this.setAttr("standardFlag",t?e|4:e&-5)}get isShapeFile(){return(this.getAttr("standardFlag")&1)===1}set isShapeFile(t){const e=this.getAttr("standardFlag");this.setAttr("standardFlag",t?e|1:e&-2)}get fileName(){return this.getAttr("font")}set fileName(t){this.setAttr("font",t)}get bigFontFileName(){return this.getAttr("bigFont")}set bigFontFileName(t){this.setAttr("bigFont",t)}get textStyle(){return{name:this.name,standardFlag:this.getAttr("standardFlag"),fixedTextHeight:this.getAttr("fixedTextHeight"),widthFactor:this.getAttr("widthFactor"),obliqueAngle:this.getAttr("obliqueAngle"),textGenerationFlag:this.getAttr("textGenerationFlag"),lastHeight:this.getAttr("lastHeight"),font:this.getAttr("font"),bigFont:this.getAttr("bigFont"),extendedFont:this.getAttrWithoutException("extendedFont")}}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const i=e.lastIndexOf(".");return i===-1?e:e.substring(0,i)}return t}get dxfFontFileName(){var e;const t=((e=this.fileName)==null?void 0:e.trim())??"";return!t||!this.isShapeFile||/\.[^./\\]+$/i.test(t)?t:`${t}.shx`}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbTextStyleTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.getAttr("standardFlag")),t.writeDouble(40,this.textSize),t.writeDouble(41,this.xScale),t.writeAngle(50,this.obliquingAngle),t.writeInt16(71,this.getAttr("textGenerationFlag")),t.writeDouble(42,this.priorSize),t.writeString(3,this.dxfFontFileName),t.writeString(4,this.bigFontFileName),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbTextStyleTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}switch(i){case 2:this.name=String(e.value);break;case 70:this.setAttr("standardFlag",Number(e.value));break;case 40:this.textSize=Number(e.value);break;case 41:this.xScale=Number(e.value);break;case 50:this.obliquingAngle=Number(e.value);break;case 71:this.setAttr("textGenerationFlag",Number(e.value));break;case 42:this.priorSize=Number(e.value);break;case 3:this.fileName=this.getFileNameWithoutExtension(String(e.value));break;case 4:this.bigFontFileName=String(e.value);break}}return this}dxfInXData(t){super.dxfInXData(t),this.applyExtendedFontFromXData()}applyExtendedFontFromXData(){const t=this.getXData("ACAD");if(t){for(const i of t)if(Number(i.code)===1e3&&i.value!=null){const r=String(i.value).trim();if(r){this.setAttr("extendedFont",r);break}}}if(!(this.getAttr("font")??"").trim()){const i=this.getAttrWithoutException("extendedFont")||this.name||"";i&&(this.fileName=this.getFileNameWithoutExtension(i))}}}class Dl extends ge{constructor(t,e){t=t||{},Bt(t,{standardFlags:0,origin:new y(0,0,0),xAxis:new y(1,0,0),yAxis:new y(0,1,0),isOrthographic:!1,elevation:0}),super(t,e)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get origin(){return this.getAttr("origin")}set origin(t){this.setAttr("origin",t.clone())}get xAxis(){return this.getAttr("xAxis")}set xAxis(t){this.setAttr("xAxis",t.clone())}get yAxis(){return this.getAttr("yAxis")}set yAxis(t){this.setAttr("yAxis",t.clone())}get isOrthographic(){return this.getAttr("isOrthographic")}set isOrthographic(t){this.setAttr("isOrthographic",t)}get elevation(){return this.getAttr("elevation")}set elevation(t){this.setAttr("elevation",t)}get baseUcsId(){return this.getAttrWithoutException("baseUcsId")}set baseUcsId(t){this.setAttr("baseUcsId",t)}get orthographicType(){return this.getAttrWithoutException("orthographicType")}set orthographicType(t){this.setAttr("orthographicType",t)}get orthographicOrigin(){return this.getAttrWithoutException("orthographicOrigin")}set orthographicOrigin(t){this.setAttr("orthographicOrigin",t==null?void 0:t.clone())}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbUCSTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.standardFlags),t.writePoint3d(10,this.origin),t.writePoint3d(11,this.xAxis),t.writePoint3d(12,this.yAxis),t.writeDouble(146,this.elevation),t.writeInt16(79,this.isOrthographic?1:0),this.isOrthographic&&t.writeObjectId(346,this.baseUcsId),this.orthographicType!=null&&this.orthographicOrigin&&(t.writeInt16(71,this.orthographicType),t.writePoint3d(13,this.orthographicOrigin)),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbUCSTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}const r=Number(e.value);switch(i){case 2:this.name=String(e.value);break;case 70:this.standardFlags=r;break;case 10:this.origin.x=r;break;case 20:this.origin.y=r;break;case 30:this.origin.z=r;break;case 11:this.xAxis.x=r;break;case 21:this.xAxis.y=r;break;case 31:this.xAxis.z=r;break;case 12:this.yAxis.x=r;break;case 22:this.yAxis.y=r;break;case 32:this.yAxis.z=r;break;case 79:this.isOrthographic=r!==0;break;case 146:this.elevation=r;break;case 346:this.baseUcsId=String(e.value);break;case 71:this.orthographicType=r;break;case 13:this.orthographicOrigin=this.orthographicOrigin??new y,this.orthographicOrigin.x=r;break;case 23:this.orthographicOrigin&&(this.orthographicOrigin.y=r);break;case 33:this.orthographicOrigin&&(this.orthographicOrigin.z=r);break}}return this}}const Zf=()=>({center:new L,viewDirectionFromTarget:new y(0,0,1),viewTarget:new y(0,0,0),lensLength:500,frontClippingPlane:0,backClippingPlane:0,viewHeight:1e3,viewTwistAngle:0,frozenLayers:[],styleSheet:"",renderMode:exports.AcGiRenderMode.OPTIMIZED_2D,viewMode:0,ucsIconSetting:0,ucsOrigin:new y(0,0,0),ucsXAxis:new y(1,0,0),ucsYAxis:new y(0,1,0),orthographicType:exports.AcGiOrthographicType.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:exports.AcGiDefaultLightingType.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0,aspectRatio:void 0});class Js extends ge{constructor(t,e){t=t||{},Bt(t,{gsView:Zf()}),super(t,e)}get gsView(){return this.getAttr("gsView")}get centerPoint(){return this.gsView.center}set centerPoint(t){this.gsView.center.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}get aspectRatio(){return this.gsView.aspectRatio}set aspectRatio(t){this.gsView.aspectRatio=t}}const xo=2,Qf=.45,Jf=1e5;function tp(n){var i;const t=n,e=t.aspectRatio??((i=t.gsView)==null?void 0:i.aspectRatio);return Number.isFinite(e)?e:void 0}function ep(n,t){if(Number.isFinite(t)&&t>0)return t;const e=tp(n);return e!=null&&e>0?e:1}function ip(n,t){const e=Math.max(n.min.x,t.min.x),i=Math.max(n.min.y,t.min.y),r=Math.min(n.max.x,t.max.x),s=Math.min(n.max.y,t.max.y);return e>=r||i>=s?0:(r-e)*(s-i)}function wo(n){return{x:(n.min.x+n.max.x)/2,y:(n.min.y+n.max.y)/2}}function np(n){if(!n||n.isEmpty())return!1;const t=n.max.x-n.min.x,e=n.max.y-n.min.y;return t>0&&e>0}class ke extends Js{static isActiveVportName(t){return t.toLowerCase()===ti.toLowerCase()}constructor(t,e){t=t||{},Bt(t,{circleSides:100,lowerLeftCorner:new L(0,0),upperRightCorner:new L(1,1),snapBase:new L(0,0),snapAngle:0,snapSpacing:new L(0,0),standardFlag:0,gridSpacing:new L,gridMajor:10,ucsElevation:0}),super(t,e)}get circleSides(){return this.getAttr("circleSides")}set circleSides(t){this.setAttr("circleSides",t)}get center(){return this.centerPoint}set center(t){this.centerPoint=t}get lowerLeftCorner(){return this.getAttr("lowerLeftCorner")}set lowerLeftCorner(t){this.getAttr("lowerLeftCorner").copy(t)}get upperRightCorner(){return this.getAttr("upperRightCorner")}set upperRightCorner(t){this.getAttr("upperRightCorner").copy(t)}get snapBase(){return this.getAttr("snapBase")}set snapBase(t){this.getAttr("snapBase").copy(t)}get snapAngle(){return this.getAttr("snapAngle")}set snapAngle(t){this.setAttr("snapAngle",t)}get snapIncrements(){return this.getAttr("snapSpacing")}set snapIncrements(t){this.getAttr("snapSpacing").copy(t)}get gridMajor(){return this.getAttr("gridMajor")}set gridMajor(t){this.setAttr("gridMajor",t)}get gridIncrements(){return this.getAttr("gridSpacing")}set gridIncrements(t){this.getAttr("gridSpacing").copy(t)}get standardFlag(){return this.getAttr("standardFlag")}set standardFlag(t){this.setAttr("standardFlag",t)}get snapEnabled(){return!!(this.standardFlag&256)}get backgroundObjectId(){return this.getAttrWithoutException("backgroundObjectId")}set backgroundObjectId(t){this.setAttr("backgroundObjectId",t)}get ucsElevation(){return this.getAttr("ucsElevation")}set ucsElevation(t){this.setAttr("ucsElevation",t)}modelViewBox(t){const e=this.centerPoint,i=this.viewHeight;if(!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(i)||i<=0)return;const r=this.viewTwistAngle;let s=e.x,a=e.y;if(Number.isFinite(r)&&r!==0){const d=Math.cos(r),g=Math.sin(r);s=e.x*d-e.y*g,a=e.x*g+e.y*d}const o=this.viewTarget;o&&Number.isFinite(o.x)&&Number.isFinite(o.y)&&(s+=o.x,a+=o.y);const c=ep(this,t),l=i*c,h=i/2,u=l/2;return new yt().expandByPoint({x:s-u,y:a-h}).expandByPoint({x:s+u,y:a+h})}static isModelViewBoxUsable(t,e){if(t.isEmpty()||e.isEmpty())return!1;const i=t.max.x-t.min.x,r=t.max.y-t.min.y,s=e.max.x-e.min.x,a=e.max.y-e.min.y;if(i<=0||r<=0||s<=0||a<=0||i>s*xo||r>a*xo)return!1;const o=Math.max(s,a)*Qf,c=wo(t),l=wo(e);if(Math.hypot(c.x-l.x,c.y-l.y)>o)return!1;const u=i*r,d=ip(t,e);return!(d<=0||d/u<.25)}resolveModelViewBox(t,e){const i=this.modelViewBox(t);if(!(!i||!ke.isModelViewBoxStructurallyValid(i))){if(np(e)){if(!ke.isModelViewBoxUsable(i,e))return}else if(!ke.isModelViewBoxPlausibleWithoutExtents(i))return;return i}}static isModelViewBoxStructurallyValid(t){if(t.isEmpty())return!1;const e=t.max.x-t.min.x,i=t.max.y-t.min.y;return Number.isFinite(e)&&Number.isFinite(i)&&e>0&&i>0}static isModelViewBoxPlausibleWithoutExtents(t){const e=t.max.x-t.min.x,i=t.max.y-t.min.y;return Math.max(e,i)<=Jf}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbViewportTableRecord"),t.writeString(2,this.name),t.writeDouble(40,this.gsView.viewHeight),this.gsView.aspectRatio!=null&&Number.isFinite(this.gsView.aspectRatio)&&t.writeDouble(41,this.gsView.aspectRatio),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.writeDouble(146,this.ucsElevation),t.writeInt16(170,this.shadePlotSetting),t.writeInt16(282,this.defaultLightingType),t.writeInt16(292,this.isDefaultLightingOn?1:0),t.writeInt16(281,this.backgroundObjectId?1:0),t.writeObjectId(332,this.backgroundObjectId),t.writeObjectId(333,this.shadePlotObjectId),t.writeObjectId(348,this.gsView.visualStyleObjectId),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbAbstractViewTableRecord"),t.atSubclassData("AcDbViewportTableRecord");const e=[...this.gsView.frozenLayers??[]];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const i=t.readItem();if(!i)break;const r=Number(i.code);if(r===100){t.pushBackItem(i);break}const s=Number(i.value);switch(r){case 2:this.name=String(i.value);break;case 1:this.gsView.styleSheet=String(i.value);break;case 10:this.lowerLeftCorner.x=s;break;case 20:this.lowerLeftCorner.y=s;break;case 11:this.upperRightCorner.x=s;break;case 21:this.upperRightCorner.y=s;break;case 12:this.center.x=s,this.gsView.center.x=s;break;case 22:this.center.y=s,this.gsView.center.y=s;break;case 13:this.snapBase.x=s;break;case 23:this.snapBase.y=s;break;case 14:this.snapIncrements.x=s;break;case 24:this.snapIncrements.y=s;break;case 15:this.gridIncrements.x=s;break;case 25:this.gridIncrements.y=s;break;case 16:this.gsView.viewDirectionFromTarget.x=s;break;case 26:this.gsView.viewDirectionFromTarget.y=s;break;case 36:this.gsView.viewDirectionFromTarget.z=s;break;case 17:this.gsView.viewTarget.x=s;break;case 27:this.gsView.viewTarget.y=s;break;case 37:this.gsView.viewTarget.z=s;break;case 40:case 45:this.gsView.viewHeight=s;break;case 41:Number.isFinite(s)&&s>0&&(this.gsView.aspectRatio=s);break;case 42:this.gsView.lensLength=s;break;case 43:this.gsView.frontClippingPlane=s;break;case 44:this.gsView.backClippingPlane=s;break;case 50:this.snapAngle=s;break;case 51:this.gsView.viewTwistAngle=s;break;case 61:this.gridMajor=s;break;case 70:this.standardFlag=s;break;case 71:s>=1&&s<=2e4&&(this.circleSides=s),this.gsView.viewMode=s;break;case 72:this.circleSides=s;break;case 74:this.gsView.ucsIconSetting=s;break;case 110:this.gsView.ucsOrigin.x=s;break;case 120:this.gsView.ucsOrigin.y=s;break;case 130:this.gsView.ucsOrigin.z=s;break;case 111:this.gsView.ucsXAxis.x=s;break;case 121:this.gsView.ucsXAxis.y=s;break;case 131:this.gsView.ucsXAxis.z=s;break;case 112:this.gsView.ucsYAxis.x=s;break;case 122:this.gsView.ucsYAxis.y=s;break;case 132:this.gsView.ucsYAxis.z=s;break;case 79:this.gsView.orthographicType=s;break;case 281:this.gsView.renderMode=s;break;case 331:case 441:e.push(String(i.value));break;case 332:this.backgroundObjectId=String(i.value);break;case 146:this.ucsElevation=s;break;case 170:this.shadePlotSetting=s;break;case 282:this.defaultLightingType=s;break;case 292:this.isDefaultLightingOn=s!==0;break;case 333:this.shadePlotObjectId=String(i.value);break;case 348:this.gsView.visualStyleObjectId=String(i.value);break}}return this.gsView.frozenLayers=e,this}}class Yl extends Js{constructor(t,e){t=t||{};const i=t.viewWidth!==void 0;Bt(t,{standardFlags:0,ucsAssociated:!1,cameraPlottable:!1,ucsElevation:0}),super(t,e),i||(this.viewWidth=this.viewHeight)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get viewWidth(){return this.getAttr("viewWidth")}set viewWidth(t){this.setAttr("viewWidth",t)}get ucsAssociated(){return this.getAttr("ucsAssociated")}set ucsAssociated(t){this.setAttr("ucsAssociated",t)}get cameraPlottable(){return this.getAttr("cameraPlottable")}set cameraPlottable(t){this.setAttr("cameraPlottable",t)}get ucsElevation(){return this.getAttr("ucsElevation")}set ucsElevation(t){this.setAttr("ucsElevation",t)}get ucsObjectId(){return this.getAttrWithoutException("ucsObjectId")}set ucsObjectId(t){this.setAttr("ucsObjectId",t)}get ucsBaseObjectId(){return this.getAttrWithoutException("ucsBaseObjectId")}set ucsBaseObjectId(t){this.setAttr("ucsBaseObjectId",t)}get backgroundObjectId(){return this.getAttrWithoutException("backgroundObjectId")}set backgroundObjectId(t){this.setAttr("backgroundObjectId",t)}get liveSectionObjectId(){return this.getAttrWithoutException("liveSectionObjectId")}set liveSectionObjectId(t){this.setAttr("liveSectionObjectId",t)}get sunObjectId(){return this.getAttrWithoutException("sunObjectId")}set sunObjectId(t){this.setAttr("sunObjectId",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),t.writeObjectId(361,this.sunObjectId),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}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbAbstractViewTableRecord"),t.atSubclassData("AcDbViewTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}const r=Number(e.value);switch(i){case 2:this.name=String(e.value);break;case 70:this.standardFlags=r;break;case 40:this.gsView.viewHeight=r;break;case 10:this.centerPoint.x=r;break;case 20:this.centerPoint.y=r;break;case 41:this.viewWidth=r;break;case 11:this.gsView.viewDirectionFromTarget.x=r;break;case 21:this.gsView.viewDirectionFromTarget.y=r;break;case 31:this.gsView.viewDirectionFromTarget.z=r;break;case 12:this.gsView.viewTarget.x=r;break;case 22:this.gsView.viewTarget.y=r;break;case 32:this.gsView.viewTarget.z=r;break;case 42:this.gsView.lensLength=r;break;case 43:this.gsView.frontClippingPlane=r;break;case 44:this.gsView.backClippingPlane=r;break;case 50:this.gsView.viewTwistAngle=r*Math.PI/180;break;case 71:this.gsView.viewMode=r;break;case 281:this.gsView.renderMode=r;break;case 72:this.ucsAssociated=r!==0;break;case 73:this.cameraPlottable=r!==0;break;case 332:this.backgroundObjectId=String(e.value);break;case 334:this.liveSectionObjectId=String(e.value);break;case 348:this.gsView.visualStyleObjectId=String(e.value);break;case 361:this.sunObjectId=String(e.value);break;case 110:this.gsView.ucsOrigin.x=r;break;case 120:this.gsView.ucsOrigin.y=r;break;case 130:this.gsView.ucsOrigin.z=r;break;case 111:this.gsView.ucsXAxis.x=r;break;case 121:this.gsView.ucsXAxis.y=r;break;case 131:this.gsView.ucsXAxis.z=r;break;case 112:this.gsView.ucsYAxis.x=r;break;case 122:this.gsView.ucsYAxis.y=r;break;case 132:this.gsView.ucsYAxis.z=r;break;case 79:this.gsView.orthographicType=r;break;case 146:this.ucsElevation=r;break;case 345:this.ucsObjectId=String(e.value);break;case 346:this.ucsBaseObjectId=String(e.value);break}}return this}}const ga=class ga extends H{constructor(){super(),this._normal=new w(0,0,1),this._annotationHeight=0,this._columnType=0,this._columnCount=0,this._columnFlowReversed=!1,this._columnAutoHeight=!1,this._columnWidth=0,this._columnGutter=0,this._contents="",this._height=0,this._width=0,this._extentsWidth=0,this._lineSpacingFactor=1,this._lineSpacingStyle=0,this._backgroundFill=!1,this._backgroundFillColor=13158600,this._backgroundFillTransparency=1,this._backgroundScaleFactor=1,this._rotation=0,this._styleName="",this._location=new y,this._attachmentPoint=exports.AcGiMTextAttachmentPoint.TopLeft,this._direction=new w(1,0,0),this._drawingDirection=exports.AcGiMTextFlowDirection.LEFT_TO_RIGHT}get dxfTypeName(){return"MTEXT"}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 extentsWidth(){return this._extentsWidth}set extentsWidth(t){this._extentsWidth=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 normal(){return this._normal}set normal(t){this._normal.copy(t)}get annotationHeight(){return this._annotationHeight}set annotationHeight(t){this._annotationHeight=t}get columnType(){return this._columnType}set columnType(t){this._columnType=t}get columnCount(){return this._columnCount}set columnCount(t){this._columnCount=t}get columnFlowReversed(){return this._columnFlowReversed}set columnFlowReversed(t){this._columnFlowReversed=t}get columnAutoHeight(){return this._columnAutoHeight}set columnAutoHeight(t){this._columnAutoHeight=t}get columnWidth(){return this._columnWidth}set columnWidth(t){this._columnWidth=t}get columnGutter(){return this._columnGutter}set columnGutter(t){this._columnGutter=t}get geometricExtents(){const t=new Y,e=this.extentsWidth>0?this.extentsWidth:this.width>0?this.width:Ki(this.contents,this.height),i=Sl(this.contents),r=Pl(i,this.height,this.lineSpacingFactor);return Il(t,this._location,e,r,this.attachmentPoint,this.rotation,this.direction)}subGetGripPoints(){return[this._location]}subMoveGripPointsAt(t,e){return te(t,e,this._location),this}subGetOsnapPoints(t,e,i,r){k.Insertion===t&&r.push(this._location)}transformBy(t){const e=this._location.clone(),i=this._direction.lengthSq()>0?this._direction.clone().normalize():new w(Math.cos(this._rotation),Math.sin(this._rotation),0),r=new w(-i.y,i.x,i.z);r.lengthSq()===0&&r.set(0,1,0),r.normalize();const s=e.clone().add(i),a=e.clone().add(r);e.applyMatrix4(t),s.applyMatrix4(t),a.applyMatrix4(t);const o=new w(s).sub(e),c=new w(a).sub(e),l=o.length(),h=c.length();return this._location.copy(e),l>0&&(this._direction.copy(o).normalize(),this._rotation=Math.atan2(this._direction.y,this._direction.x),this._width*=l,this._extentsWidth>0&&(this._extentsWidth*=l)),h>0&&(this._height*=h),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:t=>{this.contents=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"attachmentPoint",type:"enum",editable:!0,options:[{label:exports.AcGiMTextAttachmentPoint[1],value:1},{label:exports.AcGiMTextAttachmentPoint[2],value:2},{label:exports.AcGiMTextAttachmentPoint[3],value:3},{label:exports.AcGiMTextAttachmentPoint[4],value:4},{label:exports.AcGiMTextAttachmentPoint[5],value:5},{label:exports.AcGiMTextAttachmentPoint[6],value:6},{label:exports.AcGiMTextAttachmentPoint[7],value:7},{label:exports.AcGiMTextAttachmentPoint[8],value:8},{label:exports.AcGiMTextAttachmentPoint[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:t=>{this.attachmentPoint=t}}},{name:"drawingDirection",type:"enum",editable:!0,options:[{label:exports.AcGiMTextFlowDirection[1],value:1},{label:exports.AcGiMTextFlowDirection[2],value:2},{label:exports.AcGiMTextFlowDirection[3],value:3},{label:exports.AcGiMTextFlowDirection[4],value:4},{label:exports.AcGiMTextFlowDirection[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.resolveAt(this.styleName);if(!t)throw new Error("No valid text style found in text style table.");return t.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),this.extentsWidth>0&&t.writeDouble(42,this.extentsWidth),t.writeMTextContents(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.annotationHeight!==0&&t.writeDouble(46,this.annotationHeight),this.columnType!==0&&(t.writeInt16(75,this.columnType),t.writeInt16(76,this.columnCount),t.writeInt16(78,this.columnFlowReversed?1:0),t.writeInt16(79,this.columnAutoHeight?1:0),t.writeDouble(48,this.columnWidth),t.writeDouble(49,this.columnGutter)),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbMText");let e=this.location.x,i=this.location.y,r=this.location.z,s=this.direction.x,a=this.direction.y,o=this.direction.z,c=this.normal.x,l=this.normal.y,h=this.normal.z,u=!1;const d=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const g=t.readItem();if(!g)break;const p=Number(g.code),f=Number(g.value);switch(p){case 10:e=f;break;case 20:i=f;break;case 30:r=f;break;case 11:s=f,u=!0;break;case 21:a=f,u=!0;break;case 31:o=f,u=!0;break;case 1:case 3:d.push(String(g.value));break;case 7:this.styleName=String(g.value);break;case 40:this.height=f;break;case 41:this.width=f;break;case 42:f>0&&(this.extentsWidth=f);break;case 43:break;case 44:this.lineSpacingFactor=f;break;case 45:this.backgroundScaleFactor=f;break;case 46:this.annotationHeight=f;break;case 48:this.columnWidth=f;break;case 49:this.columnGutter=f;break;case 50:this.rotation=C.degToRad(f);break;case 71:this.attachmentPoint=f;break;case 72:this.drawingDirection=f;break;case 73:this.lineSpacingStyle=f;break;case 75:this.columnType=f;break;case 76:this.columnCount=f;break;case 78:this.columnFlowReversed=f!==0;break;case 79:this.columnAutoHeight=f!==0;break;case 90:this.backgroundFill=f!==0;break;case 63:this.backgroundFillColor=f;break;case 441:this.backgroundFillTransparency=f;break;case 101:for(;!t.atEndOfObject&&!t.atEof&&t.readItem(););break;case 210:c=f;break;case 220:l=f;break;case 230:h=f;break;case 100:return t.pushBackItem(g),this.finishMTextDxfIn(d,e,i,r,s,a,o,u,c,l,h),this}}return this.finishMTextDxfIn(d,e,i,r,s,a,o,u,c,l,h),this}finishMTextDxfIn(t,e,i,r,s,a,o,c,l,h,u){t.length>0&&(this.contents=t.join("")),this.location={x:e,y:i,z:r},c&&(this.direction={x:s,y:a,z:o});const d=new w(l,h,u);d.lengthSq()>0&&this.normal.copy(d.normalize())}};ga.typeName="MText";let Pe=ga;const wr=192,Oi=193,vr=194,kr=195,Xl=200;function Gr(n){if(n.isByBlock)return Oi<<24>>0;if(n.isByLayer)return wr<<24>>0;const t=n.colorIndex;if(t!=null&&t>0&&t<256)return(kr<<24|t&255)>>0;const e=n.RGB;return e!=null?(vr<<24|e&16777215)>>0:Oi<<24>>0}function Zt(n){const t=new X(exports.AcCmColorMethod.ByBlock);switch(n>>>24&255){case wr:t.setByLayer();break;case Oi:case Xl:t.setByBlock();break;case kr:t.colorIndex=n&255;break;case vr:t.setRGBValue(n&16777215);break;default:n===256?t.setByLayer():n===0?t.setByBlock():n>0&&n<256&&(t.colorIndex=n);break}return t}const rp=127;var zl=(n=>(n[n.Extents=1]="Extents",n[n.Circle=2]="Circle",n[n.Circle3P=3]="Circle3P",n[n.CircularArc=4]="CircularArc",n[n.CircularArc3P=5]="CircularArc3P",n[n.Polyline=6]="Polyline",n[n.Polygon=7]="Polygon",n[n.Mesh=8]="Mesh",n[n.Shell=9]="Shell",n[n.Text=10]="Text",n[n.Text2=11]="Text2",n[n.Xline=12]="Xline",n[n.Ray=13]="Ray",n[n.AttributeColor=14]="AttributeColor",n[n.AttributeLayer=16]="AttributeLayer",n[n.AttributeLinetype=18]="AttributeLinetype",n[n.AttributeMarker=19]="AttributeMarker",n[n.AttributeFill=20]="AttributeFill",n[n.AttributeTrueColor=22]="AttributeTrueColor",n[n.AttributeLineweight=23]="AttributeLineweight",n[n.AttributeLtscale=24]="AttributeLtscale",n[n.AttributeThickness=25]="AttributeThickness",n[n.PushMatrix=29]="PushMatrix",n[n.PopMatrix=31]="PopMatrix",n[n.PolylineWithNormals=32]="PolylineWithNormals",n[n.LwPolyline=33]="LwPolyline",n[n.UnicodeText=36]="UnicodeText",n[n.UnicodeText2=38]="UnicodeText2",n[n.EllipticArc=44]="EllipticArc",n))(zl||{});const Ee=w.Z_AXIS,sp=529;function ap(n){const t=n>>24&255;return t===vr?{rgb:n&16777215}:t===wr?{colorIndex:256}:t===Oi?{colorIndex:0}:t===kr?{colorIndex:n&255}:{colorIndex:n&255}}function Ur(n){return new w(n.x,n.y,n.z??0)}function Hr(n){return new y(n.x,n.y,n.z??0)}function vo(n){return{x:n[0],y:n[1],z:n[2]}}class xs{constructor(t,e={}){this._index=8,this._colorIndex=256,this._layer="0",this._linetype=lt,this._lineweight=exports.AcGiLineWeight.ByLineWeightDefault,this._ltscale=1,this._thickness=0,this._fill=!1,this._layers=[],this._linetypes=[],this._matrices=[],this._buffer=t,this._database=e.database,this._dxfversion=e.dxfversion??"AC1015",this._encoding=e.encoding??(this._dxfversion<"AC1024"?"windows-1252":"utf-8"),this._layer=e.defaultLayer??"0",this._database&&(this._database.tables.layerTable.newIterator().toArray().forEach(i=>this._layers.push(i.name)),this._database.tables.linetypeTable.newIterator().toArray().forEach(i=>this._linetypes.push(i.name)))}get extents(){return this._extents}scanExtents(){var i;const t=this._buffer;let e=this._index;for(;e<t.length;){const r=new DataView(t.buffer,t.byteOffset+e,8),s=r.getUint32(0,!0),a=r.getUint32(4,!0);if(s<8)break;if(a===1){const o=t.subarray(e+8,e+s);return this.readExtents(o),((i=this._extents)==null?void 0:i.length)===2?[this._extents[0],this._extents[1]]:void 0}e+=s}}worldDraw(t){const e=[],i=t.subEntityTraits,r={color:i.color.clone(),lineType:i.lineType,lineTypeScale:i.lineTypeScale,lineWeight:i.lineWeight,layer:i.layer,thickness:i.thickness},s=this._buffer;let a=this._index;for(;a<s.length;){const o=new DataView(s.buffer,s.byteOffset+a,8),c=o.getUint32(0,!0),l=o.getUint32(4,!0);if(c<8)break;const h=s.subarray(a+8,a+c);this.dispatchChunk(t,e,l,h),l!==20&&(this._fill=!1),a+=c}if(i.color=r.color,i.lineType=r.lineType,i.lineTypeScale=r.lineTypeScale,i.lineWeight=r.lineWeight,i.layer=r.layer,i.thickness=r.thickness,e.length!==0)return t.group(e)}dispatchChunk(t,e,i,r){switch(i){case 1:this.readExtents(r);break;case 2:this.drawCircle(t,e,r);break;case 3:this.drawCircle3P(t,e,r);break;case 4:this.drawCircularArc(t,e,r);break;case 5:this.drawCircularArc3P(t,e,r);break;case 44:this.drawEllipticArc(t,e,r);break;case 6:this.drawPolyline(t,e,r,!1);break;case 32:this.drawPolyline(t,e,r,!0);break;case 7:this.drawPolygon(t,e,r);break;case 33:this.drawLwPolyline(t,e,r);break;case 9:this.drawShell(t,e,r);break;case 10:this.drawText(t,e,r,!1);break;case 36:this.drawText(t,e,r,!0);break;case 11:this.drawText2(t,e,r,!1);break;case 38:this.drawText2(t,e,r,!0);break;case 12:this.drawXline(t,e,r,!1);break;case 13:this.drawXline(t,e,r,!0);break;case 14:this.readAttributeColor(r);break;case 16:this.readAttributeLayer(r);break;case 18:this.readAttributeLinetype(r);break;case 20:this.readAttributeFill(r);break;case 22:this.readAttributeTrueColor(r);break;case 23:this.readAttributeLineweight(r);break;case 24:this.readAttributeLtscale(r);break;case 25:this.readAttributeThickness(r);break;case 29:this.pushMatrix(r);break;case 31:this.popMatrix();break}}applyTraits(t){const e=t.subEntityTraits;e.layer=this._layer,e.lineTypeScale=this._ltscale,e.thickness=this._thickness,e.lineWeight=this._lineweight,this._rgbColor!=null?e.color=new X(exports.AcCmColorMethod.ByColor,this._rgbColor):this._colorIndex===256?e.color=new X(exports.AcCmColorMethod.ByLayer):this._colorIndex===0?e.color=new X(exports.AcCmColorMethod.ByBlock):this._colorIndex===7?e.color=new X(exports.AcCmColorMethod.ByACI,7):e.color=new X(exports.AcCmColorMethod.ByACI,this._colorIndex),e.lineType={name:this._linetype,type:this.resolveLineStyleType(),standardFlag:0,description:"",totalPatternLength:0}}resolveLineStyleType(){return this._linetype===lt?"ByLayer":this._linetype===Qt?"ByBlock":"UserSpecified"}transformPoint(t){const e=Array.isArray(t)?vo(t):t,i=Hr(e);return this._matrices.length>0&&i.applyMatrix4(this._matrices[this._matrices.length-1]),i}transformVector(t){const e=Array.isArray(t)?vo(t):t,i=Ur(e);return this._matrices.length>0&&i.transformDirection(this._matrices[this._matrices.length-1]),!Number.isFinite(i.lengthSq())||i.lengthSq()<1e-24?Ee.clone():i.normalize()}pushEntity(t,e){e&&t.push(e)}readExtents(t){const e=new Mt(t),i=e.readVertex(),r=e.readVertex();this._extents=[new y(i[0],i[1],i[2]),new y(r[0],r[1],r[2])]}readAttributeColor(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);this._rgbColor=void 0,this._colorIndex=e>256||e<0?256:e}readAttributeLayer(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);e<this._layers.length&&(this._layer=this._layers[e])}readAttributeLinetype(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);e+2<this._linetypes.length?this._linetype=this._linetypes[e+2]:e===32766?this._linetype=Qt:this._linetype=lt}readAttributeFill(t){this._fill=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0)!==0}readAttributeTrueColor(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0),i=ap(e);this._rgbColor=i.rgb,i.colorIndex!=null&&(this._colorIndex=i.colorIndex)}readAttributeLineweight(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);e>sp?this._lineweight=e-4294967296:this._lineweight=e}readAttributeLtscale(t){this._ltscale=new DataView(t.buffer,t.byteOffset,8).getFloat64(0,!0)}readAttributeThickness(t){this._thickness=new DataView(t.buffer,t.byteOffset,8).getFloat64(0,!0)}pushMatrix(t){const e=new Float64Array(t.buffer,t.byteOffset,16),i=new D().fromArray(Array.from(e));i.transpose(),this._matrices.push(i)}popMatrix(){this._matrices.length>0&&this._matrices.pop()}loadVertices(t,e){const i=new Mt(t);let r=i.readLong();e&&(r+=1);const s=[];for(;r>0;){const[o,c,l]=i.readVertex();s.push(this.transformPoint({x:o,y:c,z:l})),r-=1}let a=Ee;return e&&s.length>0&&(a=Ur(s.pop())),{vertices:s,normal:a}}drawCircle(t,e,i){const r=new Mt(i),s=r.readVertex(),a=r.readFloat(),o=this.transformVector(r.readVertex());let c=Hr({x:s[0],y:s[1],z:s[2]});o.equals(Ee)||(c=Lt(c,o)),c=this.transformPoint(c);const l=Ii(o),h=new Kt(he(c,o),a,0,j,o,l);this.applyTraits(t),this.pushEntity(e,t.circularArc(h))}drawCircle3P(t,e,i){const r=new Mt(i),s=this.transformPoint(r.readVertex()),a=this.transformPoint(r.readVertex()),o=this.transformPoint(r.readVertex()),c=Kt.computeCenterPoint(s,a,o);if(!c)return;const l=c.distanceTo(s),h=new Kt(c,l,0,j,Ee);this.applyTraits(t),this.pushEntity(e,t.circularArc(h))}drawCircularArc(t,e,i){const r=new Mt(i),s=r.readVertex(),a=r.readFloat(),o=r.readVertex(),c=r.readVertex(),l=r.readFloat(),h=this.transformVector(o),u=Hr({x:s[0],y:s[1],z:s[2]}),d=Ur({x:c[0],y:c[1],z:c[2]});this._matrices.length>0&&d.transformDirection(this._matrices[this._matrices.length-1]);const g=Number.isFinite(d.lengthSq())&&d.lengthSq()>=1e-24?d.normalize():Ii(h),p=0,f=l,m=new Kt(this.transformPoint(u),a,p,f,h,g);this.applyTraits(t),this.pushEntity(e,t.circularArc(m))}drawCircularArc3P(t,e,i){const r=new Mt(i),s=this.transformPoint(r.readVertex()),a=this.transformPoint(r.readVertex()),o=this.transformPoint(r.readVertex()),c=Kt.computeCenterPoint(s,o,a);if(!c)return;const l=c.distanceTo(s),h=ae(c,s,Ee),u=ae(c,o,Ee),d=new Kt(c,l,h,u,Ee);this.applyTraits(t),this.pushEntity(e,t.circularArc(d))}drawEllipticArc(t,e,i){const r=new Mt(i),s=this.transformPoint(r.readVertex()),a=this.transformVector(r.readVertex()),o=r.readFloat(),c=r.readFloat(),l=r.readFloat(),h=r.readFloat(),u=r.readFloat(),d=he({x:Math.cos(u)*o,y:Math.sin(u)*o,z:0},a),g=new An(s,a,d,o,c,l,h);this.applyTraits(t),this.pushEntity(e,t.ellipticalArc(g))}drawPolyline(t,e,i,r){var a,o;const{vertices:s}=this.loadVertices(i,r);if(s.length!==0){if(s.length===1){this.applyTraits(t);const c=((a=this._database)==null?void 0:a.pdmode)??0,l=((o=this._database)==null?void 0:o.pdsize)??0;this.pushEntity(e,t.point(s[0],{displayMode:c,displaySize:l}));return}this.applyTraits(t),this.pushEntity(e,t.lines(s))}}drawPolygon(t,e,i){const{vertices:r}=this.loadVertices(i,!1);if(r.length<2)return;if(this._fill){const a=new q(r.map(l=>({x:l.x,y:l.y})),!0),o=new Vt;o.add(a);const c=t.subEntityTraits;c.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},c.drawOrder=-1,this.applyTraits(t),this.pushEntity(e,t.area(o));return}const s=[...r,r[0]];this.applyTraits(t),this.pushEntity(e,t.lines(s))}drawLwPolyline(t,e,i){const r=new ol(i,this._dxfversion,this._encoding);let s=0,a=!1;r.readUnsignedLong();const o=r.readBitShort();o&8&&(s=r.readBitDouble()),o&512&&(a=!0);const c=r.readBitLong();if(c<=0)return;const l=o&16?r.readBitLong():0;this._dxfversion>="AC1024"&&(o&1024&&r.readBitLong(),o&32&&r.readBitLong());const h=r.readRawDouble(2),u=[this.transformPoint({x:h[0],y:h[1],z:s})];let d=h;for(let g=1;g<c;g++){const p=r.readBitDoubleDefault(1,d[0]),f=r.readBitDoubleDefault(1,d[1]);d=[p,f],u.push(this.transformPoint({x:p,y:f,z:s}))}for(let g=0;g<l;g++)r.readBitDouble();a&&u.length>1&&u.push(u[0].clone()),this.applyTraits(t),this.pushEntity(e,t.lines(u))}drawShell(t,e,i){const r=new Mt(i),s=r.readLong(),a=[];for(let h=0;h<s;h++){const[u,d,g]=r.readVertex();a.push(this.transformPoint({x:u,y:d,z:g}))}const o=r.readLong(),c=[];let l=0;for(;l<o;){const h=Math.abs(r.readSignedLong());l+=1+h;const u=[];for(let g=0;g<h;g++)u.push(r.readLong());const d=u.map(g=>a[g]).filter(Boolean);if(d.length>=3)for(let g=0;g<d.length;g++)c.push(d[g]),c.push(d[(g+1)%d.length])}c.length!==0&&(this.applyTraits(t),this.pushEntity(e,t.lines(c)))}drawText(t,e,i,r){const s=new Mt(i),a=this.transformPoint(s.readVertex()),o=this.transformVector(s.readVertex()),c=this.transformVector(s.readVertex()),[l,h,u]=s.readStruct([8,8,8]),d=r?s.readPaddedUnicodeString():s.readPaddedString(this._encoding);this.drawTextPrimitive(t,e,{insert:a,normal:o,textDirection:c,text:d,height:l,widthFactor:h,obliqueAngle:u})}drawText2(t,e,i,r){const s=new Mt(i),a=this.transformPoint(s.readVertex()),o=this.transformVector(s.readVertex()),c=this.transformVector(s.readVertex()),l=r?s.readPaddedUnicodeString():s.readPaddedString(this._encoding);s.readSignedLong(),s.readSignedLong();const[h,u,d]=s.readStruct([8,8,8]);s.readFloat(),this.drawTextPrimitive(t,e,{insert:a,normal:o,textDirection:c,text:l,height:h,widthFactor:u,obliqueAngle:d})}drawTextPrimitive(t,e,i){const r=Math.atan2(i.textDirection.y,i.textDirection.x),s={text:i.text,height:i.height,width:1/0,widthFactor:i.widthFactor,position:i.insert,rotation:r*180/Math.PI,drawingDirection:exports.AcGiMTextFlowDirection.BOTTOM_TO_TOP,attachmentPoint:exports.AcGiMTextAttachmentPoint.BaselineLeft},a={name:Z,standardFlag:0,fixedTextHeight:0,widthFactor:i.widthFactor,obliqueAngle:i.obliqueAngle*180/Math.PI,textGenerationFlag:0,lastHeight:i.height,font:"txt",bigFont:""};this.applyTraits(t),this.pushEntity(e,t.mtext(s,a))}drawXline(t,e,i,r){const s=new Mt(i),a=this.transformPoint(s.readVertex()),o=this.transformPoint(s.readVertex()),c=new w().subVectors(o,a);if(c.lengthSq()===0)return;const l=1e6,h=r?a.clone().add(c.normalize().multiplyScalar(l)):a.clone().sub(c.normalize().multiplyScalar(l)),u=o.clone().add(c.normalize().multiplyScalar(l));this.applyTraits(t),this.pushEntity(e,t.lines([h,u]))}}function op(n,t){if(!(t!=null&&t.length))return;const e=$i(t);return n!=null&&n>0&&e.length>=n?e.subarray(0,n):e}const cp="ASM_Data";function ws(n){return String(n).trim().toUpperCase()}function lp(n){let t,e;const i={};for(;!n.atEndOfObject&&!n.atEof;){const r=n.readItem();if(!r)break;switch(Number(r.code)){case 320:t=ws(String(r.value));break;case 2:e=String(r.value),i[e]??(i[e]=[]);break;case 310:e&&(r.value instanceof Uint8Array?i[e].push(r.value):i[e].push(String(r.value)));break}}return{ownerHandle:t,hexChunks:i[cp]??[]}}function hp(n){const t={};for(;!n.atEof;){const e=n.peekItem();if(!e)break;if(Number(e.code)!==0){n.readItem();continue}const i=String(e.value).toUpperCase();if(i==="ENDSEC"||i==="EOF"){n.readItem();break}if(n.readItem(),i==="ACDSRECORD"){const r=lp(n);if(r.ownerHandle&&r.hexChunks.length>0){const s=$i(r.hexChunks);s.length>0&&(t[r.ownerHandle]=s)}}else n.skipToEndOfObject()}return{byOwnerHandle:t}}function jl(n,t){for(;!n.atEof;){const e=n.peekItem();if(!e)break;if(Number(e.code)===0){if(String(e.value).toUpperCase()==="ENDSEC"){n.readItem();break}break}if(n.readItem(),Number(e.code)!==9)continue;const i=String(e.value).toUpperCase();up(n,t,i)}}function up(n,t,e){switch(e){case"$ACADVER":{const i=Gt(n);i&&(t.version=i);break}case"$CECOLOR":{const i=it(n);t.cecolor.colorIndex=i??256;break}case"$ANGBASE":t.angbase=it(n)??0;break;case"$ANGDIR":t.angdir=it(n)??0;break;case"$AUNITS":{const i=it(n);i!=null&&(t.aunits=i);break}case"$AUPREC":{const i=it(n);i!=null&&(t.auprec=i);break}case"$LUNITS":{const i=it(n);i!=null&&(t.lunits=i);break}case"$LUPREC":{const i=it(n);i!=null&&(t.luprec=i);break}case"$UNITMODE":{const i=it(n);i!=null&&(t.unitmode=i);break}case"$MEASUREMENT":{const i=it(n);i!=null&&(t.measurement=i);break}case"$CELTYPE":t.celtype=Gt(n)||lt;break;case"$CETRANSPARENCY":{const i=Gt(n)||"ByLayer";gt.instance().setVar(I.CETRANSPARENCY,i,t);break}case"$CELTSCALE":t.celtscale=it(n)??1;break;case"$CELWEIGHT":{const i=it(n);i!=null&&(t.celweight=i);break}case"$LWDISPLAY":t.lwdisplay=(it(n)??0)!==0;break;case"$TILEMODE":t.tilemode=(it(n)??1)!==0;break;case"$PSLTSCALE":t.psltscale=(it(n)??1)!==0;break;case"$CMLSTYLE":case"CMLSTYLE":t.cmlstyle=Gt(n)||oe;break;case"$CMLSCALE":case"CMLSCALE":{const i=it(n);i!=null&&Number.isFinite(i)&&(t.cmlscale=i);break}case"$CMLEADERSTYLE":case"CMLEADERSTYLE":t.cmleaderstyle=Gt(n)||ce;break;case"$HPLAYER":case"HPLAYER":t.hplayer=Gt(n)||".";break;case"$LTSCALE":t.ltscale=it(n)??1;break;case"$EXTMAX":{const i=ko(n);i&&(t.extmax=i);break}case"$EXTMIN":{const i=ko(n);i&&(t.extmin=i);break}case"$INSUNITS":{const i=it(n);i!=null&&(t.insunits=i);break}case"$OSMODE":t.osmode=it(n)??0;break;case"$ORTHOMODE":t.orthomode=it(n)??0;break;case"$PDMODE":t.pdmode=it(n)??0;break;case"$PDSIZE":t.pdsize=it(n)??0;break;case"$TEXTSTYLE":t.textstyle=Gt(n)||Z;break;case"$DIMSTYLE":t.dimstyle=Gt(n)||Z;break;case"$CLAYER":t.clayer=Gt(n)||"0";break;case"$HANDSEED":{const i=Gt(n);i&&t.initializeHandleSeed(i);break}default:dp(n);break}}function Gt(n){const t=n.readItem();if(t){if(Number(t.code)===9||Number(t.code)===0){n.pushBackItem(t);return}return String(t.value)}}function it(n){const t=n.readItem();if(!t)return;if(Number(t.code)===9||Number(t.code)===0){n.pushBackItem(t);return}const e=Number(t.value);return Number.isFinite(e)?e:void 0}function ko(n){let t=0,e=0,i=0,r=!1;for(;!n.atEof;){const s=n.peekItem();if(!s)break;const a=Number(s.code);if(a===9||a===0)break;n.readItem();const o=Number(s.value);a===10?(t=o,r=!0):a===20?(e=o,r=!0):a===30&&(i=o,r=!0)}return r?new y(t,e,i):void 0}function dp(n){for(;!n.atEof;){const t=n.peekItem();if(!t)break;const e=Number(t.code);if(e===9||e===0)break;n.readItem()}}class Vl{constructor(t){this._expression=t}get expression(){return this._expression}}var Gl=(n=>(n[n.Cancel=0]="Cancel",n[n.Ok=1]="Ok",n))(Gl||{});class Ar{constructor(){this._name="",this._filterExpression="",this._nestedFilters=[],this._parent=null,this._allowDelete=!0,this._allowRename=!0,this._dynamicallyGenerated=!1,this._isProxy=!1}get name(){return this._name}setName(t){return!this.allowRename()&&this._name.length>0?!1:(this._name=t,!0)}set name(t){this.setName(t)}get filterExpression(){return this._filterExpression}setFilterExpression(t){return this.isIdFilter()?!1:(this._filterExpression=t??"",!0)}set filterExpression(t){this.setFilterExpression(t)}filterExpressionTree(){return this.isIdFilter()||!this._filterExpression?null:new Vl(this._filterExpression)}getNestedFilters(){return this._nestedFilters}get nestedFilters(){return this._nestedFilters}parent(){return this._parent}isIdFilter(){return!1}allowNested(){return!0}allowDelete(){return this._allowDelete}setAllowDelete(t){this._allowDelete=t}allowRename(){return this._allowRename}setAllowRename(t){this._allowRename=t}dynamicallyGenerated(){return this._dynamicallyGenerated}setDynamicallyGenerated(t){this._dynamicallyGenerated=t}isProxy(){return this._isProxy}setIsProxy(t){this._isProxy=t}addNested(t){return!t||t===this||!this.allowNested()||!(this._parent==null)&&!this.isIdFilter()&&t.isIdFilter()||this._nestedFilters.includes(t)?!1:(t._parent&&t._parent.removeNested(t),t._parent=this,this._nestedFilters.push(t),!0)}removeNested(t){const e=this._nestedFilters.indexOf(t);return e<0?!1:(this._nestedFilters.splice(e,1),t._parent===this&&(t._parent=null),!0)}generateNested(){return!1}compareTo(t){return t?this.isIdFilter()===t.isIdFilter()&&this._name===t._name&&this._filterExpression===t._filterExpression:!1}filter(t){return t?this._filterExpression?gp(this._filterExpression,t):!0:!1}showEditor(){return 0}}function gp(n,t){const e=n.trim();return e?Ao(e,"OR").some(r=>Ao(r,"AND").every(a=>fp(a,t))):!0}function Ao(n,t){const e=new RegExp(`\\s+${t}\\s+`,"i");return n.split(e).map(i=>i.trim()).filter(i=>i.length>0)}function fp(n,t){var a;const e=n.trim().match(/^([A-Za-z_]+)\s*(==|=)\s*"?(.*?)"?\s*$/);if(!e)return!1;const i=e[1].toUpperCase(),r=e[3],s=mp(r);switch(i){case"NAME":return pp(t.name,r);case"LOCKED":return s!=null?t.isLocked===s:!1;case"FROZEN":return s!=null?t.isFrozen===s:!1;case"OFF":return s!=null?t.isOff===s:!1;case"PLOT":return s!=null?t.isPlottable===s:!1;case"COLOR":{const o=(a=t.color)==null?void 0:a.colorIndex;return o!=null&&String(o)===r}case"LINETYPE":return t.linetype.localeCompare(r,void 0,{sensitivity:"accent"})===0;default:return!1}}function pp(n,t){return/[*?]/.test(t)?new RegExp(`^${t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")}$`,"i").test(n):n.localeCompare(t,void 0,{sensitivity:"accent"})===0}function mp(n){const t=n.trim().toLowerCase();return t==="true"||t==="1"?!0:t==="false"||t==="0"?!1:null}class le{constructor(t,e){this._root=t??le.createDefaultRoot(),this._current=e===void 0?this._root:e}static createDefaultRoot(){const t=new Ar;return t.setName("All"),t.setAllowDelete(!1),t.setAllowRename(!1),t.setFilterExpression(""),t}get root(){return this._root}get current(){return this._current}set current(t){this._current=t}clone(){return new le(this._root,this._current)}}class Ul extends Ar{constructor(){super(),this._layerIds=[]}isIdFilter(){return!0}layerIds(){return this._layerIds}get layerIdList(){return this._layerIds}addLayerId(t){return!t||this._layerIds.includes(t)?!1:(this._layerIds.push(t),!0)}removeLayerId(t){const e=this._layerIds.indexOf(t);return e<0?!1:(this._layerIds.splice(e,1),!0)}filter(t){return t?this._layerIds.includes(t.objectId):!1}setFilterExpression(t){return!1}}const Sr="ACAD_LAYERFILTERS",ri="ACLYDICTIONARY";function Hl(n){const t=le.createDefaultRoot(),e=new le(t,t),i=So(n,ri),r=So(n,Sr);if(i){for(const[s,a]of Object.entries(i.entries)){const o=vs(n,a,s);o&&t.addNested(o)}return e}if(r)for(const[s,a]of Object.entries(r.entries)){const o=vs(n,a,s);o&&t.addNested(o)}return e}function Wl(n){const t=[];for(const e of n.root.getNestedFilters())t.push(Kl(e));return{nodes:t}}function $l(n){const t=new Oe;for(const e of n)t.add({code:e.code,value:e.value});return t}function yp(n){return n?n.toArray().map(t=>({code:Number(t.code),value:t.value})):[]}function So(n,t){let e;for(const i of n.dictionaries.values()){const r=i.entries[t];if(!r)continue;const s=n.dictionaries.get(se(r));if(!s)continue;if(!(i.ownerObjectId?n.xrecords.has(se(i.ownerObjectId)):!1))return s;e=s}return e}function vs(n,t,e){const i=n.xrecords.get(se(t));if(!i)return;const r=ql(i.data,e),s=r.isIdFilter?new Ul:new Ar;if(s.setAllowRename(!0),s.setName(r.name||e),!r.isIdFilter)s.setFilterExpression(r.filterExpression);else{const a=s;for(const o of r.layerIds)a.addLayerId(o)}for(const a of bp(n,i)){const o=vs(n,a.handle,a.key);o&&s.addNested(o)}return s}function bp(n,t){const e=[],i=new Set,r=se(t.handle),s=t.extensionDictionaryId?se(t.extensionDictionaryId):void 0,a=(o,c)=>{const l=se(c);i.has(l)||(i.add(l),e.push({key:o,handle:c}))};for(const o of n.dictionaries.values()){const c=o.ownerObjectId?se(o.ownerObjectId):void 0;if(!c||!(c===r||c===s))continue;const h=o.entries[ri];if(h){const u=n.dictionaries.get(se(h));if(u){for(const[d,g]of Object.entries(u.entries))a(d,g);continue}}for(const[u,d]of Object.entries(o.entries))u===ri||u===Sr||a(u,d)}return e}function ql(n,t=""){const e=[],i=[];let r=0,s,a,o;for(const p of n){const f=Number(p.code),m=p.value;f===1&&typeof m=="string"?e.push(m):f===300&&typeof m=="string"?a=m:f===301&&typeof m=="string"?o=m:f===70||f===90?r=Number(m)||0:f===290||f===280?s=Number(m)===1:(f===330||f===340||f===350||f===360)&&m!=null&&String(m).length>0&&i.push(se(String(m)))}const c=e[0],h=a||(c==="AcLyLayerFilter"||c==="AcLyLayerGroup"?void 0:c)||t,u=e[1]??"";let d=o??u;!o&&d&&d!=="*"&&!/==/.test(d)&&(d=`NAME=="${d}"`);const g=o!=null&&o.length>0?!1:s===!0&&i.length>0?!0:i.length>0&&(d.length===0||d==="*");return{name:h,filterExpression:g?"":d,flags:r,layerIds:i,isIdFilter:g}}function Kl(n){const t=n.isIdFilter(),e=Zl(n),i=n.getNestedFilters().map(s=>Kl(s));return{key:n.name||(t?"Group":"Filter"),isIdFilter:t,data:e,children:i}}function Zl(n){const t=[];if(t.push({code:1,value:n.name}),n.isIdFilter()){t.push({code:1,value:""}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:70,value:0}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:290,value:1});const e=n;for(const i of e.layerIds())t.push({code:330,value:i})}else t.push({code:1,value:n.filterExpression||"*"}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:70,value:0}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:290,value:0});return t}function se(n){return n.trim().toUpperCase()}class Ql extends bt{constructor(){super(...arguments),this._name="",this._unnamed=!1,this._selectable=!0,this._entityIds=[]}get name(){return this._name}set name(t){this._name=t}get unnamed(){return this._unnamed}set unnamed(t){this._unnamed=t}get selectable(){return this._selectable}set selectable(t){this._selectable=t}get entityIds(){return this._entityIds}set entityIds(t){this._entityIds=[...t]}addEntityId(t){this._entityIds.push(t)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbGroup"),this.name&&t.writeString(300,this.name),t.writeInt16(70,this.unnamed?1:0),t.writeInt16(71,this.selectable?1:0);for(const e of this._entityIds)t.writeObjectId(340,e);return this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbGroup"),this._entityIds=[];!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}switch(i){case 300:this._name=String(e.value);break;case 70:this._unnamed=Number(e.value)!==0;break;case 71:this._selectable=Number(e.value)!==0;break;case 340:this._entityIds.push(String(e.value));break}}return this}}class Jl extends bt{constructor(){super(),this._boundaryVertices=[],this._clipBoundaryDisplayEnabled=!1,this._frontClippingEnabled=!1,this._backClippingEnabled=!1}get boundaryVertices(){return this._boundaryVertices}set boundaryVertices(t){this._boundaryVertices=t.map(e=>e.clone())}get clipBoundaryNormal(){return this._clipBoundaryNormal}set clipBoundaryNormal(t){this._clipBoundaryNormal=t==null?void 0:t.clone()}get clipBoundaryOrigin(){return this._clipBoundaryOrigin}set clipBoundaryOrigin(t){this._clipBoundaryOrigin=t==null?void 0:t.clone()}get clipBoundaryDisplayEnabled(){return this._clipBoundaryDisplayEnabled}set clipBoundaryDisplayEnabled(t){this._clipBoundaryDisplayEnabled=t}get frontClippingEnabled(){return this._frontClippingEnabled}set frontClippingEnabled(t){this._frontClippingEnabled=t}get frontClippingDistance(){return this._frontClippingDistance}set frontClippingDistance(t){this._frontClippingDistance=t}get backClippingEnabled(){return this._backClippingEnabled}set backClippingEnabled(t){this._backClippingEnabled=t}get backClippingDistance(){return this._backClippingDistance}set backClippingDistance(t){this._backClippingDistance=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbFilter"),this._boundaryVertices.length>0&&(t.writeInt16(70,this._boundaryVertices.length),this._boundaryVertices.forEach(e=>t.writePoint2d(10,e)),t.writeVector3d(210,this._clipBoundaryNormal),t.writePoint3d(11,this._clipBoundaryOrigin),t.writeInt16(71,this._clipBoundaryDisplayEnabled?1:0),t.writeInt16(72,this._frontClippingEnabled?1:0),this._frontClippingEnabled&&this._frontClippingDistance!=null&&t.writeDouble(40,this._frontClippingDistance),t.writeInt16(73,this._backClippingEnabled?1:0),this._backClippingEnabled&&this._backClippingDistance!=null&&t.writeDouble(41,this._backClippingDistance)),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbFilter");let e=null,i=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const r=t.readItem();if(!r)break;const s=Number(r.code);if(s===100){t.pushBackItem(r);break}const a=Number(r.value);switch(s){case 70:break;case 10:e&&this._boundaryVertices.push(new L(e.x,e.y)),e={x:a,y:0};break;case 20:e&&(e.y=a);break;case 210:this._clipBoundaryNormal=this._clipBoundaryNormal??new y,this._clipBoundaryNormal.x=a;break;case 220:this._clipBoundaryNormal&&(this._clipBoundaryNormal.y=a);break;case 230:this._clipBoundaryNormal&&(this._clipBoundaryNormal.z=a);break;case 11:this._clipBoundaryOrigin=this._clipBoundaryOrigin??new y,this._clipBoundaryOrigin.x=a;break;case 21:this._clipBoundaryOrigin&&(this._clipBoundaryOrigin.y=a);break;case 31:this._clipBoundaryOrigin&&(this._clipBoundaryOrigin.z=a);break;case 71:this._clipBoundaryDisplayEnabled=a!==0;break;case 72:this._frontClippingEnabled=a!==0;break;case 73:this._backClippingEnabled=a!==0;break;case 40:i||(this._frontClippingDistance=a,i=!0);break;case 41:this._backClippingDistance=a;break}}return e&&this._boundaryVertices.push(new L(e.x,e.y)),this}}class th extends Jl{constructor(){super(),this._layerNames=[]}get layerNames(){return this._layerNames}set layerNames(t){this._layerNames=[...t]}add(t){const e=t==null?void 0:t.trim();return!e||this._layerNames.includes(e)?!1:(this._layerNames.push(e),!0)}getAt(t){if(t<0||t>=this._layerNames.length)throw new Error("The layer index is out of range!");return this._layerNames[t]}remove(t){const e=this._layerNames.indexOf(t);return e<0?!1:(this._layerNames.splice(e,1),!0)}layerCount(){return this._layerNames.length}indexClass(){return"AcDbLayerIndex"}isValid(){return this._layerNames.some(t=>t.length>0)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayerFilter");for(const e of this._layerNames)t.writeString(8,e);return this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbLayerFilter");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;switch(Number(e.code)){case 8:this.add(String(e.value));break;case 100:return t.pushBackItem(e),this}}return this}}class eh extends bt{constructor(){super(),this._lastUpdatedAt=0,this._lastUpdatedAtU=0,this._isUptoDate=!1,this._objectBeingIndexedId=""}get lastUpdatedAt(){return this._lastUpdatedAt}set lastUpdatedAt(t){this._lastUpdatedAt=t}get lastUpdatedAtU(){return this._lastUpdatedAtU}set lastUpdatedAtU(t){this._lastUpdatedAtU=t}get isUptoDate(){return this._isUptoDate}set isUptoDate(t){this._isUptoDate=t}objectBeingIndexedId(){return this._objectBeingIndexedId}setObjectBeingIndexedId(t){this._objectBeingIndexedId=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbIndex"),t.writeDouble(40,this.lastUpdatedAt),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbIndex");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;switch(Number(e.code)){case 40:this.lastUpdatedAt=Number(e.value),this.lastUpdatedAtU=this.lastUpdatedAt;break;case 100:return t.pushBackItem(e),this}}return this}}class ih extends eh{constructor(){super(),this._layerNames=[],this._idBufferIds=[],this._idBufferEntryCounts=[]}get layerNames(){return this._layerNames}set layerNames(t){this._layerNames=[...t]}get idBufferIds(){return this._idBufferIds}set idBufferIds(t){this._idBufferIds=[...t]}get idBufferEntryCounts(){return this._idBufferEntryCounts}set idBufferEntryCounts(t){this._idBufferEntryCounts=[...t]}get entries(){const t=Math.max(this._layerNames.length,this._idBufferIds.length,this._idBufferEntryCounts.length),e=[];for(let i=0;i<t;i++)e.push({layerName:this._layerNames[i]??"",idBufferId:this._idBufferIds[i]??"",idBufferEntryCount:this._idBufferEntryCounts[i]??0});return e}set entries(t){this._layerNames=t.map(e=>e.layerName),this._idBufferIds=t.map(e=>e.idBufferId),this._idBufferEntryCounts=t.map(e=>e.idBufferEntryCount)}compute(t,e){if(e&&this.setObjectBeingIndexedId(e.objectId),t){this._layerNames=[];for(const i of t.newIterator())this._layerNames.push(i.name)}return this.lastUpdatedAt=Date.now(),this.lastUpdatedAtU=Date.now(),this.isUptoDate=!0,!0}newIterator(t){return null}rebuildFull(t){return this.lastUpdatedAt=Date.now(),this.lastUpdatedAtU=Date.now(),this.isUptoDate=!0,!0}rebuildModified(t){return this.lastUpdatedAt=Date.now(),this.lastUpdatedAtU=Date.now(),this.isUptoDate=!0,!0}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayerIndex");const e=Math.max(this._layerNames.length,this._idBufferIds.length,this._idBufferEntryCounts.length);for(let i=0;i<e;i++)this._layerNames[i]!=null&&t.writeString(8,this._layerNames[i]),this._idBufferIds[i]&&t.writeHandle(360,this._idBufferIds[i]),this._idBufferEntryCounts[i]!=null&&t.writeInt32(90,this._idBufferEntryCounts[i]);return this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbLayerIndex");const e=[],i=[],r=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const s=t.readItem();if(!s)break;switch(Number(s.code)){case 8:e.push(String(s.value));break;case 360:i.push(String(s.value));break;case 90:r.push(Number(s.value));break;case 100:return t.pushBackItem(s),this.layerNames=e,this.idBufferIds=i,this.idBufferEntryCounts=r,this.isUptoDate=!0,this}}return this.layerNames=e,this.idBufferIds=i,this.idBufferEntryCounts=r,this.isUptoDate=!0,this}}class Pr extends bt{constructor(){super(),this._contentType=2,this._drawMLeaderOrderType=1,this._drawLeaderOrderType=0,this._bitFlags=0,this._maxLeaderSegmentsPoints=-1,this._firstSegmentAngleConstraint=0,this._secondSegmentAngleConstraint=0,this._leaderLineType=1,this._leaderLineColor=new X(exports.AcCmColorMethod.ByLayer),this._leaderLineWeight=-2,this._enableLanding=!0,this._landingGap=2,this._enableDogleg=!0,this._doglegLength=8,this._description="",this._arrowSize=4,this._defaultMTextContents="",this._textLeftAttachmentType=1,this._textAngleType=1,this._textAlignmentType=0,this._textRightAttachmentType=1,this._textColor=new X(exports.AcCmColorMethod.ByLayer),this._textHeight=4,this._enableFrameText=!1,this._textAlignAlwaysLeft=!1,this._alignSpace=0,this._blockColor=new X(exports.AcCmColorMethod.ByBlock),this._blockScale=new w(1,1,1),this._enableBlockScale=!0,this._blockRotation=0,this._enableBlockRotation=!1,this._blockConnectionType=0,this._scale=1,this._overwritePropChanged=!1,this._annotative=!1,this._breakSize=0,this._textAttachmentDirection=0,this._bottomTextAttachmentType=9,this._topTextAttachmentType=9,this._extendLeaderToText=!1}get unknown1(){return this._unknown1}set unknown1(t){this._unknown1=t}get contentType(){return this._contentType}set contentType(t){this._contentType=t}get drawMLeaderOrderType(){return this._drawMLeaderOrderType}set drawMLeaderOrderType(t){this._drawMLeaderOrderType=t}get drawLeaderOrderType(){return this._drawLeaderOrderType}set drawLeaderOrderType(t){this._drawLeaderOrderType=t}get bitFlags(){return this._bitFlags}set bitFlags(t){this._bitFlags=t}get maxLeaderSegmentsPoints(){return this._maxLeaderSegmentsPoints}set maxLeaderSegmentsPoints(t){this._maxLeaderSegmentsPoints=t}get maxLeaderSegmentPoints(){return this.maxLeaderSegmentsPoints}set maxLeaderSegmentPoints(t){this.maxLeaderSegmentsPoints=t}get firstSegmentAngleConstraint(){return this._firstSegmentAngleConstraint}set firstSegmentAngleConstraint(t){this._firstSegmentAngleConstraint=t}get secondSegmentAngleConstraint(){return this._secondSegmentAngleConstraint}set secondSegmentAngleConstraint(t){this._secondSegmentAngleConstraint=t}get leaderLineType(){return this._leaderLineType}set leaderLineType(t){this._leaderLineType=t}get leaderLineColor(){return this._leaderLineColor}set leaderLineColor(t){this._leaderLineColor.copy(t)}get leaderLineTypeId(){return this._leaderLineTypeId}set leaderLineTypeId(t){this._leaderLineTypeId=t}get leaderLineWeight(){return this._leaderLineWeight}set leaderLineWeight(t){this._leaderLineWeight=t}get enableLanding(){return this._enableLanding}set enableLanding(t){this._enableLanding=t}get landingEnabled(){return this.enableLanding}set landingEnabled(t){this.enableLanding=t}get landingGap(){return this._landingGap}set landingGap(t){this._landingGap=t}get enableDogleg(){return this._enableDogleg}set enableDogleg(t){this._enableDogleg=t}get doglegEnabled(){return this.enableDogleg}set doglegEnabled(t){this.enableDogleg=t}get doglegLength(){return this._doglegLength}set doglegLength(t){this._doglegLength=t}get description(){return this._description}set description(t){this._description=t}get arrowSymbolId(){return this._arrowSymbolId}set arrowSymbolId(t){this._arrowSymbolId=t}get arrowheadId(){return this.arrowSymbolId}set arrowheadId(t){this.arrowSymbolId=t}get arrowSize(){return this._arrowSize}set arrowSize(t){this._arrowSize=t}get arrowheadSize(){return this.arrowSize}set arrowheadSize(t){this.arrowSize=t}get defaultMTextContents(){return this._defaultMTextContents}set defaultMTextContents(t){this._defaultMTextContents=t}get defaultMText(){return this.defaultMTextContents}set defaultMText(t){this.defaultMTextContents=t}get textString(){return this.defaultMTextContents}set textString(t){this.defaultMTextContents=t}get textStyleId(){return this._textStyleId}set textStyleId(t){this._textStyleId=t}get textStyle(){return this.textStyleId}set textStyle(t){this.textStyleId=t}get textLeftAttachmentType(){return this._textLeftAttachmentType}set textLeftAttachmentType(t){this._textLeftAttachmentType=t}get textAngleType(){return this._textAngleType}set textAngleType(t){this._textAngleType=t}get textAlignmentType(){return this._textAlignmentType}set textAlignmentType(t){this._textAlignmentType=t}get textRightAttachmentType(){return this._textRightAttachmentType}set textRightAttachmentType(t){this._textRightAttachmentType=t}get textColor(){return this._textColor}set textColor(t){this._textColor.copy(t)}get textHeight(){return this._textHeight}set textHeight(t){this._textHeight=t}get enableFrameText(){return this._enableFrameText}set enableFrameText(t){this._enableFrameText=t}get textFrameEnabled(){return this.enableFrameText}set textFrameEnabled(t){this.enableFrameText=t}get textAlignAlwaysLeft(){return this._textAlignAlwaysLeft}set textAlignAlwaysLeft(t){this._textAlignAlwaysLeft=t}get alignSpace(){return this._alignSpace}set alignSpace(t){this._alignSpace=t}get blockId(){return this._blockId}set blockId(t){this._blockId=t}get blockContentId(){return this.blockId}set blockContentId(t){this.blockId=t}get blockColor(){return this._blockColor}set blockColor(t){this._blockColor.copy(t)}get blockContentColor(){return this.blockColor}set blockContentColor(t){this.blockColor=t}get blockScale(){return this._blockScale.clone()}set blockScale(t){this._blockScale.copy(t)}get blockContentScale(){return this.blockScale}set blockContentScale(t){this.blockScale=t}get enableBlockScale(){return this._enableBlockScale}set enableBlockScale(t){this._enableBlockScale=t}get blockContentScaleEnabled(){return this.enableBlockScale}set blockContentScaleEnabled(t){this.enableBlockScale=t}get blockRotation(){return this._blockRotation}set blockRotation(t){this._blockRotation=t}get blockContentRotation(){return this.blockRotation}set blockContentRotation(t){this.blockRotation=t}get enableBlockRotation(){return this._enableBlockRotation}set enableBlockRotation(t){this._enableBlockRotation=t}get blockContentRotationEnabled(){return this.enableBlockRotation}set blockContentRotationEnabled(t){this.enableBlockRotation=t}get blockConnectionType(){return this._blockConnectionType}set blockConnectionType(t){this._blockConnectionType=t}get blockContentConnectionType(){return this.blockConnectionType}set blockContentConnectionType(t){this.blockConnectionType=t}get scale(){return this._scale}set scale(t){this._scale=t}get scaleFactor(){return this.scale}set scaleFactor(t){this.scale=t}get overwritePropChanged(){return this._overwritePropChanged}set overwritePropChanged(t){this._overwritePropChanged=t}get overwritePropertyValue(){return this.overwritePropChanged}set overwritePropertyValue(t){this.overwritePropChanged=t}get annotative(){return this._annotative}set annotative(t){this._annotative=t}get breakSize(){return this._breakSize}set breakSize(t){this._breakSize=t}get breakGapSize(){return this.breakSize}set breakGapSize(t){this.breakSize=t}get textAttachmentDirection(){return this._textAttachmentDirection}set textAttachmentDirection(t){this._textAttachmentDirection=t}get bottomTextAttachmentType(){return this._bottomTextAttachmentType}set bottomTextAttachmentType(t){this._bottomTextAttachmentType=t}get bottomTextAttachmentDirection(){return this.bottomTextAttachmentType}set bottomTextAttachmentDirection(t){this.bottomTextAttachmentType=t}get topTextAttachmentType(){return this._topTextAttachmentType}set topTextAttachmentType(t){this._topTextAttachmentType=t}get topTextAttachmentDirection(){return this.topTextAttachmentType}set topTextAttachmentDirection(t){this.topTextAttachmentType=t}get extendLeaderToText(){return this._extendLeaderToText}set extendLeaderToText(t){this._extendLeaderToText=t}get unknown2(){return this._unknown2}set unknown2(t){this._unknown2=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMLeaderStyle"),t.writeInt16(179,this.unknown1),t.writeInt16(170,this.contentType),t.writeInt16(171,this.drawMLeaderOrderType),t.writeInt16(172,this.drawLeaderOrderType),t.writeInt32(90,this.maxLeaderSegmentsPoints),t.writeDouble(40,this.firstSegmentAngleConstraint),t.writeDouble(41,this.secondSegmentAngleConstraint),t.writeInt16(173,this.leaderLineType),t.writeInt32(91,Gr(this.leaderLineColor)),t.writeHandle(340,this.leaderLineTypeId),t.writeInt32(92,this.leaderLineWeight),t.writeBoolean(290,this.enableLanding),t.writeDouble(42,this.landingGap),t.writeBoolean(291,this.enableDogleg),t.writeDouble(43,this.doglegLength),t.writeString(3,this.description),t.writeHandle(341,this.arrowSymbolId),t.writeDouble(44,this.arrowSize),t.writeString(300,this.defaultMTextContents),t.writeHandle(342,this.textStyleId),t.writeInt16(174,this.textLeftAttachmentType),t.writeInt16(175,this.textAngleType),t.writeInt16(176,this.textAlignmentType),t.writeInt16(178,this.textRightAttachmentType),t.writeInt32(93,Gr(this.textColor)),t.writeDouble(45,this.textHeight),t.writeBoolean(292,this.enableFrameText),t.writeBoolean(297,this.textAlignAlwaysLeft),t.writeDouble(46,this.alignSpace),t.writeHandle(343,this.blockId),t.writeInt32(94,Gr(this.blockColor)),t.writeDouble(47,this._blockScale.x),t.writeDouble(49,this._blockScale.y),t.writeDouble(140,this._blockScale.z),t.writeBoolean(293,this.enableBlockScale),t.writeDouble(141,this.blockRotation),t.writeBoolean(294,this.enableBlockRotation),t.writeInt16(177,this.blockConnectionType),t.writeDouble(142,this.scale),t.writeBoolean(295,this.overwritePropChanged),t.writeBoolean(296,this.annotative),t.writeDouble(143,this.breakSize),t.writeInt16(271,this.textAttachmentDirection),t.writeInt16(272,this.bottomTextAttachmentType),t.writeInt16(273,this.topTextAttachmentType),t.writeBoolean(298,this.unknown2),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbMLeaderStyle");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code),r=Number(e.value);switch(i){case 179:this.unknown1=r;break;case 170:this.contentType=r;break;case 171:this.drawMLeaderOrderType=r;break;case 172:this.drawLeaderOrderType=r;break;case 90:this.maxLeaderSegmentsPoints=r;break;case 40:this.firstSegmentAngleConstraint=r;break;case 41:this.secondSegmentAngleConstraint=r;break;case 173:this.leaderLineType=r;break;case 91:this.leaderLineColor=Zt(r);break;case 340:this.leaderLineTypeId=String(e.value);break;case 92:this.leaderLineWeight=r;break;case 290:this.enableLanding=r!==0;break;case 42:this.landingGap=r;break;case 291:this.enableDogleg=r!==0;break;case 43:this.doglegLength=r;break;case 3:this.description=String(e.value);break;case 341:this.arrowSymbolId=String(e.value);break;case 44:this.arrowSize=r;break;case 300:this.defaultMTextContents=String(e.value);break;case 342:this.textStyleId=String(e.value);break;case 174:this.textLeftAttachmentType=r;break;case 175:this.textAngleType=r;break;case 176:this.textAlignmentType=r;break;case 178:this.textRightAttachmentType=r;break;case 93:this.textColor=Zt(r);break;case 45:this.textHeight=r;break;case 292:this.enableFrameText=r!==0;break;case 297:this.textAlignAlwaysLeft=r!==0;break;case 46:this.alignSpace=r;break;case 343:this.blockId=String(e.value);break;case 94:this.blockColor=Zt(r);break;case 47:this._blockScale.x=r;break;case 49:this._blockScale.y=r;break;case 140:this._blockScale.z=r;break;case 293:this.enableBlockScale=r!==0;break;case 141:this.blockRotation=r;break;case 294:this.enableBlockRotation=r!==0;break;case 177:this.blockConnectionType=r;break;case 142:this.scale=r;break;case 295:this.overwritePropChanged=r!==0;break;case 296:this.annotative=r!==0;break;case 143:this.breakSize=r;break;case 271:this.textAttachmentDirection=r;break;case 272:this.bottomTextAttachmentType=r;break;case 273:this.topTextAttachmentType=r;break;case 298:this.unknown2=r!==0;break;case 100:return t.pushBackItem(e),this}}return this}}class ta extends bt{constructor(){super(),this._styleName="STANDARD",this._flags=0,this._description="",this._fillColor=new X,this._startAngle=90,this._endAngle=90,this._elements=[]}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get flags(){return this._flags}set flags(t){this._flags=t}get description(){return this._description}set description(t){this._description=t}get fillColor(){return this._fillColor}set fillColor(t){this._fillColor.copy(t)}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=t}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=t}get elementCount(){return this._elements.length}get elements(){return this._elements.map(t=>({offset:t.offset,color:t.color.clone(),lineType:t.lineType}))}set elements(t){this._elements=t.map(e=>({offset:e.offset,color:e.color.clone(),lineType:e.lineType}))}addElement(t){this._elements.push({offset:t.offset,color:t.color.clone(),lineType:t.lineType})}removeElementAt(t){if(t<0||t>=this._elements.length)throw new Error("The element index is out of range!");this._elements.splice(t,1)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMlineStyle"),t.writeString(2,this.styleName),t.writeInt16(70,this.flags),t.writeString(3,this.description),t.writeCmColor(this.fillColor),t.writeDouble(51,this.startAngle),t.writeDouble(52,this.endAngle),t.writeInt16(71,this.elementCount),this._elements.forEach(e=>{t.writeDouble(49,e.offset),t.writeCmColor(e.color),t.writeString(6,e.lineType)}),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbMlineStyle");const e=[];let i,r=0;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const s=t.readItem();if(!s)break;const a=Number(s.code),o=Number(s.value);switch(a){case 2:this.styleName=String(s.value);break;case 70:this.flags=o;break;case 3:this.description=String(s.value);break;case 51:this.startAngle=o;break;case 52:this.endAngle=o;break;case 71:r=o;break;case 49:{i={offset:o,color:new X,lineType:"BYLAYER"},i.color.colorIndex=256,e.push(i);break}case 62:i?i.color.colorIndex=o:this.fillColor.colorIndex=o;break;case 420:i?i.color.setRGBValue(o):this.fillColor.setRGBValue(o);break;case 6:i&&(i.lineType=String(s.value));break;case 100:return t.pushBackItem(s),this.finishMlineElements(e,r),this}}return this.finishMlineElements(e,r),this}finishMlineElements(t,e){const i=Math.max(e,t.length);if(i<=0){this.elements=[];return}this.elements=Array.from({length:i},(r,s)=>{const a=t[s];if(a)return a;const o=new X;return o.colorIndex=256,{offset:0,color:o,lineType:"BYLAYER"}})}}class nh extends bt{constructor(){super(),this._isLoaded=!0,this._resolutionUnits=0,this._sourceFileName="",this._classVersion=0,this._imageSize=new L,this._pixelSize=new L(1,1)}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}get classVersion(){return this._classVersion}set classVersion(t){this._classVersion=t}get imageSize(){return this._imageSize}set imageSize(t){this._imageSize.copy(t)}get pixelSize(){return this._pixelSize}set pixelSize(t){this._pixelSize.copy(t)}get isLoaded(){return this._isLoaded}set isLoaded(t){this._isLoaded=t}get resolutionUnits(){return this._resolutionUnits}set resolutionUnits(t){this._resolutionUnits=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRasterImageDef"),t.writeInt32(90,this.classVersion),t.writeString(1,this.sourceFileName),t.writePoint2d(10,this.imageSize),t.writeDouble(11,this.pixelSize.x),t.writeDouble(12,this.pixelSize.y),t.writeInt16(280,this.isLoaded?1:0),t.writeInt16(281,this.resolutionUnits),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbRasterImageDef");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code),r=Number(e.value);switch(i){case 1:this.sourceFileName=String(e.value);break;case 90:this.classVersion=r;break;case 10:this.imageSize.x=r;break;case 20:this.imageSize.y=r;break;case 11:this.pixelSize.x=r;break;case 12:this.pixelSize.y=r;break;case 280:this.isLoaded=r!==0;break;case 281:this.resolutionUnits=r;break;case 100:return t.pushBackItem(e),this}}return this}}class rh extends bt{constructor(){super(...arguments),this._entityIds=[]}get entityIds(){return this._entityIds}set entityIds(t){this._entityIds=[...t]}addEntityId(t){this._entityIds.push(t)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbSortentsTable");for(const e of this._entityIds)t.writeObjectId(331,e);return this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSortentsTable"),this._entityIds=[];!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}switch(i){case 331:this._entityIds.push(String(e.value));break}}return this}}var sh=(n=>(n[n.NotApplicable=0]="NotApplicable",n[n.Ignore=1]="Ignore",n[n.Replace=2]="Replace",n[n.XrefMangleName=3]="XrefMangleName",n[n.MangleName=4]="MangleName",n))(sh||{});class ea extends bt{constructor(){super(...arguments),this._data=null}get data(){return this._data}set data(t){this._data=t}clear(){var t;(t=this._data)==null||t.clear()}clone(){return super.clone()}getDuplicateRecordCloning(){return this._cloningFlag??0}setDuplicateRecordCloning(t){this._cloningFlag=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbXrecord"),t.writeInt16(280,this._cloningFlag??1),t.writeResultBuffer(this.data),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbXrecord");const e=new Oe;for(;!t.atEndOfObject&&!t.atEof;){const i=t.readItem();if(!i)break;const r=Number(i.code);if(r===1001||r>=1e3&&r<=1071){t.pushBackItem(i);break}if(r===100){t.pushBackItem(i);break}switch(r){case 280:this._cloningFlag=Number(i.value);break;default:e.add({code:i.code,value:i.value});break}}return this._data=e.length>0?e:null,this}}const Et=n=>n?n.trim().toUpperCase():"";class ah{constructor(t){this._db=t,this._dictionaries=new Map,this._xrecords=new Map,this._unknownObjectCount=0}get unknownObjectCount(){return this._unknownObjectCount}read(t){for(this._unknownObjectCount=0;!t.atEof;){const e=t.peekItem();if(!e)break;if(Number(e.code)!==0){t.readItem();continue}const i=String(e.value).toUpperCase();if(i==="ENDSEC"){t.readItem();break}t.readItem(),this.readObject(t,i)}this.finishNamedObjectDictionaries(),this.finishLayerFilterTree(),this.linkLayoutsToBlockTableRecords(),this._db.objects.layout.numEntries===0&&this._db.createDefaultData({layout:!0})}readObject(t,e){switch(e){case"LAYOUT":{const i=new qi;i.dxfIn(t),i.layoutName&&this._db.objects.layout.setAt(i.layoutName,i);break}case"IMAGEDEF":{const i=new nh;i.dxfIn(t),this._db.objects.imageDefinition.setAt(i.objectId,i);break}case"LAYER_FILTER":{const i=new th;i.dxfIn(t),this._db.objects.layerFilter.setAt(i.objectId,i);break}case"LAYER_INDEX":{const i=new ih;i.dxfIn(t),this._db.objects.layerIndex.setAt(i.objectId,i);break}case"MLEADERSTYLE":{const i=new Pr;i.dxfIn(t),this._db.objects.mleaderStyle.setAt(i.objectId,i);break}case"MLINESTYLE":{const i=new ta;i.dxfIn(t),this._db.objects.mlineStyle.setAt(i.styleName||i.objectId,i);break}case"GROUP":{const i=new Ql;i.dxfIn(t);const r=i.name||i.objectId;this._db.objects.group.setAt(r,i);break}case"SORTENTSTABLE":{const i=new rh;i.dxfIn(t),this._db.objects.sortentsTable.setAt(i.objectId,i);break}case"DICTIONARY":{const i=this.readPersistDictionary(t);i.handle&&this._dictionaries.set(Et(i.handle),i);break}case"XRECORD":{const i=new ea;i.dxfIn(t);const r=Et(i.objectId);if(r){this._db.objects.xrecord.setAt(r,i);const s={handle:r,ownerObjectId:Et(i.ownerId),data:i.data?i.data.toArray().map(a=>({code:Number(a.code),value:a.value})):[]};i.extensionDictionary&&(s.extensionDictionaryId=Et(i.extensionDictionary)),this._xrecords.set(r,s)}break}default:this._unknownObjectCount+=1,t.skipToEndOfObject();break}}finishNamedObjectDictionaries(){if(this._dictionaries.size===0)return;let t;for(const s of this._dictionaries.values())if(!s.ownerObjectId||s.ownerObjectId==="0"){t=s;break}if(!(t!=null&&t.handle))return;const e=this._db.objects.dictionary;e.objectId=t.handle,e.ownerId="0";const i={ACAD_LAYOUT:this._db.objects.layout,ACAD_GROUP:this._db.objects.group,ACAD_SORTENTS:this._db.objects.sortentsTable,ACAD_MLEADERSTYLE:this._db.objects.mleaderStyle,ACAD_MLINESTYLE:this._db.objects.mlineStyle,ISM_RASTER_IMAGE_DICT:this._db.objects.imageDefinition,MLIGHT_XRECORD:this._db.objects.xrecord},r=this.collectLoadedObjectsByHandle();for(const[s,a]of Object.entries(t.entries)){const o=i[s.toUpperCase()];if(!o)continue;o.objectId=a,o.ownerId=t.handle,e.setAt(s,o);const c=this._dictionaries.get(Et(a));if(c)for(const[l,h]of Object.entries(c.entries)){const u=r.get(Et(h));u&&(o.getAt(l)||o.setAt(l,u))}}}collectLoadedObjectsByHandle(){const t=new Map,e=i=>{const r=Et(i.objectId);r&&t.set(r,i)};for(const[,i]of this._db.objects.layout.entries())e(i);for(const[,i]of this._db.objects.group.entries())e(i);for(const[,i]of this._db.objects.sortentsTable.entries())e(i);for(const[,i]of this._db.objects.imageDefinition.entries())e(i);for(const[,i]of this._db.objects.mleaderStyle.entries())e(i);for(const[,i]of this._db.objects.mlineStyle.entries())e(i);for(const[,i]of this._db.objects.layerFilter.entries())e(i);for(const[,i]of this._db.objects.layerIndex.entries())e(i);for(const[,i]of this._db.objects.xrecord.entries())e(i);return t}readPersistDictionary(t){const e={handle:"",ownerObjectId:"",entries:{}};let i;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const r=t.readItem();if(!r)break;const s=Number(r.code);switch(s){case 5:e.handle=String(r.value);break;case 330:e.ownerObjectId=String(r.value);break;case 100:case 280:case 281:break;case 3:i=String(r.value);break;case 350:case 340:case 360:{const a=Et(String(r.value));i?(e.entries[i]=a,i=void 0):s===360&&!e.extensionDictionaryId&&(e.extensionDictionaryId=a);break}}}return e.handle=Et(e.handle),e.ownerObjectId=Et(e.ownerObjectId),e.extensionDictionaryId&&(e.extensionDictionaryId=Et(e.extensionDictionaryId)),e}finishLayerFilterTree(){if(this._dictionaries.size===0&&this._xrecords.size===0)return;const t=Hl({dictionaries:this._dictionaries,xrecords:this._xrecords});t.root.getNestedFilters().length>0&&(this._db.layerFilters=t),this._dictionaries.clear(),this._xrecords.clear()}linkLayoutsToBlockTableRecords(){const t=this._db.tables.blockTable,e=tt.MODEL_SPACE_NAME.toUpperCase();for(const[,i]of this._db.objects.layout.entries()){if(i.layoutName==="Model"){const a=t.modelSpace;i.blockTableRecordId=a.objectId,a.layoutId=i.objectId;continue}const r=Et(i.objectId);let s=!1;for(const a of t.newIterator())if(Et(a.layoutId)===r){i.blockTableRecordId=a.objectId,s=!0;break}if(!s&&i.blockTableRecordId){const a=t.getIdAt(i.blockTableRecordId);a&&(a.layoutId=i.objectId)}else if(!s){for(const a of t.newIterator())if(a.isPaperSapce&&a.name.toUpperCase()!==e&&!a.layoutId){i.blockTableRecordId=a.objectId,a.layoutId=i.objectId;break}}}}}class oh{constructor(t,e={}){this._db=t,this._options=e,this._unknownEntityCount=0,this._unknownObjectCount=0,this._fonts=new Set,this._attributeMap=new Map,this._yieldGate=new pr(this._options.yieldBudgetMs??Pi)}get unknownEntityCount(){return this._unknownEntityCount}get unknownObjectCount(){return this._unknownObjectCount}get fonts(){return[...this._fonts]}async read(t){for(this._unknownEntityCount=0,this._unknownObjectCount=0,this._fonts.clear(),this._attributeMap.clear(),t.database=this._db;!t.atEof;){const e=t.readItem();if(!e)break;if(Number(e.code)!==0)continue;const i=String(e.value).toUpperCase();if(i==="EOF")break;if(i==="SECTION"){const r=this.readSectionName(t);await this.readSection(t,r);continue}}return this.flushRemainingAttributes(),{unknownEntityCount:this._unknownEntityCount,unknownObjectCount:this._unknownObjectCount,fonts:this.fonts}}readSectionName(t){const e=t.readItem();return e&&Number(e.code)===2?String(e.value).toUpperCase():(e&&t.pushBackItem(e),"")}async readSection(t,e){switch(e){case"HEADER":jl(t,this._db),await this.reportParseProgress(t);break;case"CLASSES":this.readClassesSection(t),await this.reportParseProgress(t);break;case"TABLES":this.readTablesSection(t),await this.reportParseProgress(t);break;case"BLOCKS":await this.readBlocksSection(t),await this.reportParseProgress(t);break;case"ENTITIES":await this.readEntitiesSection(t),await this.reportParseProgress(t);break;case"OBJECTS":{const i=new ah(this._db);i.read(t),this._unknownObjectCount+=i.unknownObjectCount}await this.reportParseProgress(t);break;case"ACDSDATA":this.applyAcdsDataToSolids(hp(t)),await this.reportParseProgress(t);break;case"THUMBNAILIMAGE":this.readThumbnailImageSection(t),await this.reportParseProgress(t);break;default:this.skipUntilEndSec(t),await this.reportParseProgress(t);break}}applyAcdsDataToSolids(t){const e=Object.keys(t.byOwnerHandle);if(e.length===0)return;const i=new Map;for(const r of this._db.tables.blockTable.newIterator())for(const s of r.newIterator())s instanceof Ti&&i.set(ws(s.objectId),s);for(const r of e){const s=t.byOwnerHandle[r];if(!s)continue;const a=i.get(ws(r));a&&a.setSabBytes(s)}}readThumbnailImageSection(t){let e=0;const i=[];for(;!t.atEof;){const s=t.readItem();if(!s)break;if(Number(s.code)===0){if(String(s.value).toUpperCase()==="ENDSEC")break;t.pushBackItem(s);break}Number(s.code)===90?e=Number(s.value)||0:Number(s.code)===310&&(s.value instanceof Uint8Array?i.push(s.value):i.push(String(s.value)))}if(i.length===0)return;const r=$i(i);!r||r.length===0||(this._db.thumbnailImage=e>0&&r.length>e?r.subarray(0,e):r)}readClassesSection(t){const e=[];for(;!t.atEof;){const i=t.peekItem();if(!i)break;if(Number(i.code)!==0){t.readItem();continue}const r=String(i.value).toUpperCase();if(r==="ENDSEC"){t.readItem();break}if(r==="CLASS"){t.readItem();const s=this.readClassRecord(t);(s.name||s.cppClassName)&&e.push(s);continue}t.readItem(),t.skipToEndOfObject()}e.length>0&&(this._db.classes=e)}readClassRecord(t){const e={name:"",cppClassName:"",appName:"",proxyFlag:0,instanceCount:0,wasProxy:!1,isEntity:!1};for(;!t.atEndOfObject&&!t.atEof;){const i=t.readItem();if(!i)break;switch(Number(i.code)){case 1:e.name=String(i.value);break;case 2:e.cppClassName=String(i.value);break;case 3:e.appName=String(i.value);break;case 90:e.proxyFlag=Number(i.value);break;case 91:e.instanceCount=Number(i.value);break;case 280:e.wasProxy=Number(i.value)!==0;break;case 281:e.isEntity=Number(i.value)!==0;break}}return e}readTablesSection(t){for(;!t.atEof;){const e=t.peekItem();if(!e)break;if(Number(e.code)!==0){t.readItem();continue}const i=String(e.value).toUpperCase();if(i==="ENDSEC"){t.readItem();break}if(i==="TABLE"){t.readItem();const r=this.readTableName(t);this.readTable(t,r);continue}t.readItem(),t.skipToEndOfObject()}this._db.ensureTextStyleDefaults()}readTableName(t){for(;!t.atEof;){const e=t.peekItem();if(!e)return"";const i=Number(e.code);if(i===0)return"";if(t.readItem(),i===2)return String(e.value).toUpperCase()}return""}readTable(t,e){switch(e){case"LAYER":this.readNamedTable(t,"LAYER",()=>new Zi,i=>{i.name&&this._db.tables.layerTable.add(i)});break;case"LTYPE":this.readNamedTable(t,"LTYPE",()=>new ve,i=>{i.name&&this._db.tables.linetypeTable.add(i)});break;case"STYLE":this.readNamedTable(t,"STYLE",()=>new xr,i=>{this._db.tables.textStyleTable.add(i),this.collectFontFromStyleRecord(i)});break;case"DIMSTYLE":this.readNamedTable(t,"DIMSTYLE",()=>new Tt,i=>{i.name&&this._db.tables.dimStyleTable.add(i)});break;case"VPORT":this.readNamedTable(t,"VPORT",()=>new ke,i=>{i.name&&this._db.tables.viewportTable.add(i)});break;case"APPID":this.readNamedTable(t,"APPID",()=>new Cn,i=>{i.name&&this._db.tables.appIdTable.add(i)});break;case"VIEW":this.readNamedTable(t,"VIEW",()=>new Yl,i=>{i.name&&this._db.tables.viewTable.add(i)});break;case"UCS":this.readNamedTable(t,"UCS",()=>new Dl,i=>{i.name&&this._db.tables.ucsTable.add(i)});break;case"BLOCK_RECORD":this.readBlockRecordTable(t);break;default:this.skipUntilEndTab(t);break}}readNamedTable(t,e,i,r){for(;!t.atEof;){const s=t.peekItem();if(!s)break;if(Number(s.code)!==0){t.readItem();continue}const a=String(s.value).toUpperCase();if(a==="ENDTAB"){t.readItem();break}if(a==="ENDSEC")break;if(a===e){t.readItem();const o=i();o.dxfIn(t),r(o);continue}t.readItem(),t.skipToEndOfObject()}}readBlockRecordTable(t){let e=!1;for(;!t.atEof;){const i=t.peekItem();if(!i)break;if(Number(i.code)!==0){t.readItem();continue}const r=String(i.value).toUpperCase();if(r==="ENDTAB"){t.readItem();break}if(r==="ENDSEC")break;if(r==="BLOCK_RECORD"){t.readItem(),e||(this._db.tables.blockTable.removeAll(),e=!0);const s=new tt;s.dxfIn(t),s.name&&this._db.tables.blockTable.add(s);continue}t.readItem(),t.skipToEndOfObject()}}skipUntilEndTab(t){for(;!t.atEof;){const e=t.readItem();if(!e||Number(e.code)===0&&String(e.value).toUpperCase()==="ENDTAB")break}}async readBlocksSection(t){const e=Math.max(1,this._options.entityBatchSize??200);let i=0;for(;!t.atEof;){const r=t.peekItem();if(!r)break;if(Number(r.code)!==0){t.readItem();continue}const s=String(r.value).toUpperCase();if(s==="ENDSEC"){t.readItem();break}if(s==="BLOCK"){t.readItem(),i=await this.readBlockDefinition(t,e,i);continue}t.readItem(),t.skipToEndOfObject()}}async readBlockDefinition(t,e,i){const r=this.readBlockBeginFields(t),s=this.ensureBlockTableRecord(r);for(;!t.atEof;){const a=t.peekItem();if(!a)break;if(Number(a.code)!==0){t.readItem();continue}const o=String(a.value).toUpperCase();if(o==="ENDBLK"){t.readItem(),t.skipToEndOfObject();break}if(o==="ENDSEC")break;if(t.readItem(),this.consumeSeqend(t,o)){i+=1,i>=e&&(i=0,await this.yieldAndReportProgress(t));continue}const c=Cs(t,o);c?this.shouldAcceptBlockEntity(s)&&this.acceptEntity(c,s):(this._unknownEntityCount+=1,t.skipToEndOfObject()),i+=1,i>=e&&(i=0,await this.yieldAndReportProgress(t))}return i}shouldAcceptBlockEntity(t){return!t.isModelSapce&&!t.isPaperSapce}consumeSeqend(t,e){return e!=="SEQEND"?!1:(t.skipToEndOfObject(),!0)}readBlockBeginFields(t){const e=new y;let i="",r=0,s="",a,o;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const c=t.readItem();if(!c)break;const l=Number(c.code);if(l===100)continue;const h=Number(c.value);switch(l){case 5:a=String(c.value);break;case 330:o=String(c.value);break;case 2:case 3:i||(i=String(c.value));break;case 70:r=h;break;case 10:e.x=h;break;case 20:e.y=h;break;case 30:e.z=h;break;case 1:s=String(c.value);break}}return{name:i,flags:r,origin:e,pathName:s,objectId:a,ownerId:o}}ensureBlockTableRecord(t){let e=t.name?this._db.tables.blockTable.getAt(t.name):void 0;e||(e=new tt,e.name=t.name||"*UNKNOWN",t.objectId&&(e.objectId=t.objectId),this._db.tables.blockTable.add(e)),e.origin.copy(t.origin);let i=tt.sanitizeImportedFlags(t.flags);return t.pathName&&(e.pathName=t.pathName,(i&(_i.Xref|_i.XrefOverlay))===0&&(i=i|_i.Xref)),e.flags=i,e}async readEntitiesSection(t){const e=Math.max(1,this._options.entityBatchSize??200);let i=0;const r=this._db.tables.blockTable.modelSpace;for(;!t.atEof;){const s=t.peekItem();if(!s)break;if(Number(s.code)!==0){t.readItem();continue}const a=String(s.value).toUpperCase();if(a==="ENDSEC"){t.readItem();break}if(t.readItem(),this.consumeSeqend(t,a)){i+=1,i>=e&&(i=0,await this.yieldAndReportProgress(t));continue}const o=Cs(t,a);o?this.acceptEntity(o,this.resolveEntityOwner(o,r)):(this._unknownEntityCount+=1,t.skipToEndOfObject()),i+=1,i>=e&&(i=0,await this.yieldAndReportProgress(t))}}resolveEntityOwner(t,e){const i=t.getAttrWithoutException("ownerId");if(i){const r=this._db.tables.blockTable.getIdAt(i);if(r&&(r.isModelSapce||r.isPaperSapce))return r}if(t.dxfPaperSpace){const r=this._db.tables.blockTable.getAt(tt.PAPER_SPACE_NAME_PREFIX);if(r)return r}return e}acceptEntity(t,e){if(t instanceof Mi){this.collectFontFromEntity(t),this.linkOrDeferAttribute(t,e);return}if(e.appendEntity(t),this.collectFontFromEntity(t),t instanceof Jt){const i=this._attributeMap.get(t.objectId);if(i&&i.length>0){for(const r of i)t.appendAttributes(r);this._attributeMap.delete(t.objectId)}}}linkOrDeferAttribute(t,e){const i=t.getAttrWithoutException("ownerId");if(!i||i==="0")return;const r=e.getIdAt(i)??this._db.tables.blockTable.getEntityById(i);if(r instanceof Jt){r.appendAttributes(t);return}let s=this._attributeMap.get(i);s||(s=[],this._attributeMap.set(i,s)),s.push(t)}flushRemainingAttributes(){for(const[t,e]of this._attributeMap){const i=this._db.tables.blockTable.getEntityById(t);if(i instanceof Jt)for(const r of e)i.appendAttributes(r)}this._attributeMap.clear()}collectFontFromStyleRecord(t){if(t.fileName){const r=ft.normalizeFontFileName(t.fileName);r?this._fonts.add(r):this._fonts.add(t.fileName)}const e=t.textStyle.extendedFont;if(e){const r=ft.normalizeFontFileName(e);r&&this._fonts.add(r)}const i=t.bigFontFileName;if(i){const r=ft.normalizeFontFileName(i);r&&this._fonts.add(r)}}collectFontFromEntity(t){const e=i=>{if(!i)return;const r=this._db.tables.textStyleTable.resolveAt(i);if(r){this.collectFontFromStyleRecord(r);return}this._fonts.add(i)};if(e(typeof t.styleName=="string"?t.styleName:void 0),e(typeof t.textStyleName=="string"?t.textStyleName:void 0),typeof t.textStyleId=="string"&&t.textStyleId){const i=this._db.tables.textStyleTable.getIdAt(t.textStyleId);i&&this.collectFontFromStyleRecord(i)}if(t instanceof Pe&&t.contents)for(const i of ft.collectInlineMTextFonts(t.contents))this._fonts.add(i)}skipUntilEndSec(t){for(;!t.atEof;){const e=t.readItem();if(!e||Number(e.code)===0&&String(e.value).toUpperCase()==="ENDSEC")break}}async reportParseProgress(t){const{onProgress:e,totalBytes:i}=this._options;if(!e||!i||i<=0)return;const r=Math.min(1,Math.max(0,t.position().byteOffset/i));await e(r)}async yieldAndReportProgress(t){await this.reportParseProgress(t),await this._yieldGate.maybeYield(ai)}}const hn=1,Wr=12,_p=13,xp=18,un=20,dn=98;class ch extends Zs{constructor(t={}){super({useWorker:!1,...t})}async read(t,e,i,r,s,a){this.progress=r;const o=async(l,h,u,d)=>{r&&await r(l,h,u,d)};await o(0,"START","START"),await o(hn,"PARSE","START"),await Ho(),e.beginEventBatch();let c=!0;try{const l=xe.fromBuffer(t,{database:e}),h=t.byteLength;let u=hn;const g=await new oh(e,{entityBatchSize:Math.max(1,i||200),yieldBudgetMs:Pi,totalBytes:h,onProgress:async b=>{const _=Math.min(Wr-1,hn+Math.floor(b*(Wr-hn)));_<=u||(u=_,await o(_,"PARSE","IN-PROGRESS"))}}).read(l);await o(Wr,"PARSE","END",{unknownEntityCount:g.unknownEntityCount}),await o(_p,"FONT","START"),await o(xp,"FONT","END",g.fonts),await o(un,"ENTITY","START");const p=Math.max(1,i||200);let f=un;const m=new pr(Pi);await e.endEventBatchChunked(p,async(b,_)=>{const v=_<=0?dn:Math.min(dn,un+Math.floor(b/_*(dn-un)));v>f&&(f=v,await o(v,"ENTITY","IN-PROGRESS")),await m.maybeYield()}),c=!1,await o(dn,"ENTITY","END"),await o(100,"END","END")}catch(l){throw c&&e.endEventBatch(),l}}async parse(t){return{model:null,data:{unknownEntityCount:0}}}getFonts(t){return[]}}var wi=(n=>(n.DXF="dxf",n.DWG="dwg",n))(wi||{});class qt{constructor(){this.events={registered:new at,unregistered:new at},this._converters=new Map,this.register("dxf",new ch)}static createInstance(){return qt._instance==null&&(qt._instance=new qt),this._instance}static get instance(){return qt._instance||(qt._instance=new qt),qt._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}))}}const We=class We extends _t{constructor(){super(),this._thickness=0,this._normal=new w(0,0,1),this._elevation=0,this._geo=new q}get dxfTypeName(){return"LWPOLYLINE"}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get closed(){return this._geo.closed}get area(){return this._geo.area}set closed(t){this._geo.closed=t}addVertexAt(t,e,i=0,r=-1,s=-1){const a=r<0?void 0:r,o=s<0?void 0:s,c={x:e.x,y:e.y,bulge:i,startWidth:a,endWidth:o};this._geo.addVertexAt(t,c)}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 y(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new Y({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 this.shouldIncludeSegmentMidpointGrips()&&this.appendSegmentMidpointGrips(t),t}subMoveGripPointsAt(t,e){const i=this.numberOfVertices,r=this.shouldIncludeSegmentMidpointGrips(),s=r?this.getSegmentCount():0;return ht(t,a=>{if(a<i){xi(this._geo.vertices,a,e);return}if(!r||a>=i+s)return;const o=a-i;xi(this._geo.vertices,o,e),xi(this._geo.vertices,(o+1)%i,e)}),this}shouldIncludeSegmentMidpointGrips(){return this.getGripsMode()>=2}getGripsMode(){try{const t=gt.instance().getVar(I.GRIPS,this.database);return typeof t=="number"?t:2}catch{return 2}}getSegmentCount(){const t=this.numberOfVertices;return t<2?0:this.closed?t:t-1}appendSegmentMidpointGrips(t){var a;const e=this._geo,i=this._elevation,r=this.getSegmentCount(),s=e.numberOfVertices;for(let o=0;o<r;o++){const c=[];Ci(e.getPointAt(o),e.getPointAt((o+1)%s),(a=e.vertices[o])==null?void 0:a.bulge,i,k.MidPoint,{x:0,y:0,z:0},c),t.push(...c)}}subGetOsnapPoints(t,e,i,r){var c;const s=this._geo,a=this._elevation,o=s.numberOfVertices;if(o!==0)switch(t){case k.EndPoint:for(let l=0;l<o;l++){const h=s.getPointAt(l);r.push(new y(h.x,h.y,a))}break;case k.MidPoint:case k.Nearest:case k.Perpendicular:case k.Tangent:{const l=this.closed?o:o-1,h=[];for(let u=0;u<l;u++){const d=[];Ci(s.getPointAt(u),s.getPointAt((u+1)%o),(c=s.vertices[u])==null?void 0:c.bulge,a,t,e,d),h.push(...d)}if(t===k.MidPoint)r.push(...h);else{const u=Ft(e,h);u&&r.push(u)}break}}}transformBy(t){const e=t.determinant()<0;let i=this._elevation;return this._geo.vertices.forEach(r=>{const s=new y(r.x,r.y,this._elevation).applyMatrix4(t);r.x=s.x,r.y=s.y,i=s.z,e&&r.bulge!=null&&(r.bulge=-r.bulge)}),this._elevation=i,this._geo._boundingBoxNeedsUpdate=!0,this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=this._geo.getPoints(100),i=this.createWidthProfile();if(i!=null){const s=vp(i,this.closed);if(s!=null){const a=t.subEntityTraits;return a.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},t.area(s)}}const r=[];return e.forEach(s=>r.push(new y().set(s.x,s.y,this.elevation))),t.lines(r)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPolyline"),t.writeInt32(90,this.numberOfVertices),t.writeInt16(70,this.closed?1:0);const e=this.resolveConstantWidth();e!=null&&t.writeDouble(43,e),t.writeDouble(38,this.elevation),this.thickness!==0&&t.writeDouble(39,this.thickness);const i=this._geo.vertices;for(let r=0;r<i.length;++r){const s=i[r];t.writePoint2d(10,this.getPoint2dAt(r)),e==null&&(s.startWidth!=null&&t.writeDouble(40,s.startWidth),s.endWidth!=null&&t.writeDouble(41,s.endWidth));const a=s.bulge??0;a!==0&&t.writeDouble(42,a),s.identifier!=null&&t.writeInt32(91,s.identifier)}return t.writeVector3d(210,this.normal),this}dxfOutAs2dPolyline(t,e=!1){var r,s,a;t.writeHandle(5,this.objectId),t.writeObjectId(330,this.ownerId),t.writeObjectId(360,this.extensionDictionary),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.writeLineWeight(370,this.lineWeight),t.writeTransparency(this.transparency);const i=(r=this.database)==null?void 0:r.tables.blockTable.getIdAt(this.ownerId);i!=null&&i.isPaperSapce&&t.writeInt16(67,1),t.writeSubclassMarker("AcDb2dPolyline"),t.writeInt16(66,this.numberOfVertices>0?1:0),t.writeInt16(70,this.closed?1:0),t.writeDouble(10,0),t.writeDouble(20,0),t.writeDouble(30,this.elevation);for(let o=0;o<this.numberOfVertices;++o){const c=this._geo.vertices[o];t.writeStart("VERTEX"),t.writeHandle(5,(s=this.database)==null?void 0:s.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbVertex"),t.writeSubclassMarker("AcDb2dVertex"),t.writePoint3d(10,{x:this.getPoint2dAt(o).x,y:this.getPoint2dAt(o).y,z:this.elevation});const l=(c==null?void 0:c.bulge)??0;l!==0&&t.writeDouble(42,l),t.writeInt16(70,0)}return t.writeStart("SEQEND"),t.writeHandle(5,(a=this.database)==null?void 0:a.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbPolyline"),this.reset(!1);let e=!1,i=this.elevation,r=this.thickness,s=this.normal.x,a=this.normal.y,o=this.normal.z,c=-1,l=0,h=0,u=!1,d=0,g=-1,p=-1,f,m=0;const b=()=>{if(!u)return;const v=g<0?c:g,x=p<0?c:p;if(this.addVertexAt(m++,new L(l,h),d,v,x),f!=null){const S=this._geo.vertices[m-1];S&&(S.identifier=f)}u=!1,d=0,g=-1,p=-1,f=void 0};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const v=t.readItem();if(!v)break;const x=Number(v.code),S=Number(v.value);switch(x){case 90:break;case 70:e=(S&1)!==0;break;case 43:c=S;break;case 38:i=S;break;case 39:r=S;break;case 10:b(),l=S,h=0,u=!0;break;case 20:h=S;break;case 40:g=S;break;case 41:p=S;break;case 42:d=S;break;case 91:f=S;break;case 210:s=S;break;case 220:a=S;break;case 230:o=S;break}}b(),this.closed=e,this.elevation=i,this.thickness=r;const _=new w(s,a,o);return _.lengthSq()>0&&this.normal.copy(_.normalize()),this}resolveConstantWidth(){const t=this._geo.vertices;if(t.length===0)return;let e;for(const i of t){const r=i.startWidth,s=i.endWidth;if(r==null&&s==null){if(e!=null&&e!==0)return;e=e??0;continue}const a=r??0;if(a!==(s??0))return;if(e==null)e=a;else if(e!==a)return}return e!=null&&e!==0?e:void 0}createWidthProfile(){const t=this._geo.vertices,e=t.length;if(e<2)return null;const i=this.closed?e:e-1,r=[];let s=!1;for(let a=0;a<i;a++){const o=t[a],c=t[(a+1)%e],l=Math.max(0,o.startWidth??0),h=Math.max(0,o.endWidth??0);(l>mt||h>mt)&&(s=!0);const u=this.sampleSegment(o,c),d=u.length-1;for(let g=0;g<=d;g++){if(g===0&&r.length>0||this.closed&&a===i-1&&g===d)continue;const p=d>0?g/d:0;r.push({x:u[g].x,y:u[g].y,width:Cp(l,h,p)})}}return s&&r.length>=2?r:null}sampleSegment(t,e){if(t.bulge&&Math.abs(t.bulge)>mt){const r=new vt(t,e,t.bulge).getPoints(32);if(r.length>1)return r.map(s=>new L(s.x,s.y))}return[new L(t.x,t.y),new L(e.x,e.y)]}static from2dPoints(t,e){const i=new We;return t.forEach((r,s)=>i.addVertexAt(s,r)),i.closed=e,i}static fromGePolyline(t){const e=new We;return t.vertices.forEach((i,r)=>{e.addVertexAt(r,new L(i.x,i.y),i.bulge??0)}),e.closed=t.closed,e}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.numberOfVertices;let i=1/0,r=1;const s=this.closed?e:e-1;for(let a=0;a<s;a++){const o=this.getPoint2dAt(a),c=this.getPoint2dAt((a+1)%e),l=c.x-o.x,h=c.y-o.y,u=l*l+h*h;if(u===0)continue;const d=Math.max(0,Math.min(1,((t.x-o.x)*l+(t.y-o.y)*h)/u)),g=(t.x-o.x-d*l)**2+(t.y-o.y-d*h)**2;g<i&&(i=g,r=l*(t.y-o.y)-h*(t.x-o.x)>=0?1:-1)}return r}createOffsetCurve(t){const e=this._geo.offset(t);return e.length===0?null:We.fromGePolyline(e[0])}};We.typeName="Polyline";let kt=We;function Ir(n,t,e){const i=Xd(n,t,e);return i?kt.fromGePolyline(i):null}const mt=1e-6,Po=4,wp=.75;function vp(n,t){if(n.length<2)return null;if(t)return $r(n,!0);const e=kp(n);if(e.length===1)return $r(e[0],!1);const i=new Vt;let r=!1;for(const s of e){const a=$r(s,!1);if(a!=null){for(const o of a.loops)i.add(o);r=!0}}return r?i:null}function $r(n,t){const e=Lp(n,t);if(e.length<2)return null;const{left:i,right:r}=lh(e,t);if(Eo(i)<2||Eo(r)<2)return null;const s=new Vt;if(t){const a=Mn(i),o=Mn(r);if(!Ri(a)||!Ri(o))return null;const c=Math.abs(Ni(a)),l=Math.abs(Ni(o)),[h,u]=c>=l?[a,o]:[o,a];return s.add(new q(h,!0)),s.add(new q(u,!0)),s}return Sp(e)&&Pp(s,e)||Ep(s,i,r)?s:null}function kp(n){if(n.length<2)return[n];const t=[];let e=0;const i=new Map;for(let s=0;s<n.length;s++){const a=Io(n[s]),o=i.get(a);if(o!=null&&s-o>1){const c=n.slice(e,s+1);c.length>=2&&t.push(c),e=o,i.clear();for(let l=e;l<=s;l++)i.set(Io(n[l]),l);continue}i.set(a,s)}const r=n.slice(e);return r.length>=2&&t.push(r),t.length>0?t:[n]}function Io(n){return`${n.x.toFixed(4)}:${n.y.toFixed(4)}`}function Ap(n,t){const e=Math.max(n,t),i=Math.min(n,t);return e<=mt||e-i<=mt?!1:i/e<=wp}function Sp(n){const t=n[0],e=n[n.length-1],i=Math.hypot(e.x-t.x,e.y-t.y);if(i<=mt)return!0;const r=Math.max(...n.map(s=>s.width));return r<=mt?!1:i<=r*4}function Pp(n,t){const{left:e,right:i}=lh(t,!0),r=Mn(e),s=Mn(i);if(!Ri(r)||!Ri(s))return!1;const a=Math.abs(Ni(r)),o=Math.abs(Ni(s));if(!Ap(a,o))return!1;const[c,l]=a>=o?[r,s]:[s,r];return n.add(new q(c,!0)),n.add(new q(l,!0)),!0}function lh(n,t){const e=new Array(n.length),i=new Array(n.length);for(let r=0;r<n.length;r++){const s=n[r],a=Math.max(0,s.width)/2;if(a<=mt){e[r]=null,i[r]=null;continue}const o=Tp(n,r,t);if(o==null){e[r]=null,i[r]=null;continue}e[r]={x:s.x+o.x*a,y:s.y+o.y*a},i[r]={x:s.x-o.x*a,y:s.y-o.y*a}}return{left:e,right:i}}function Ip(n,t,e,i,r){const s=[t,e,i,r];return Ri(s)?(n.add(new q(s,!0)),!0):!1}function Ep(n,t,e){let i=!1;for(let r=0;r<t.length-1;r++){const s=t[r],a=t[r+1],o=e[r],c=e[r+1];s==null||a==null||o==null||c==null||Ip(n,s,a,c,o)&&(i=!0)}return i}function Eo(n){return n.reduce((t,e)=>e==null?t:t+1,0)}function Mn(n){return n.filter(t=>t!=null)}function Lp(n,t){const e=[];if(n.forEach(i=>{const r=e[e.length-1];(!r||Math.abs(r.x-i.x)>mt||Math.abs(r.y-i.y)>mt||Math.abs(r.width-i.width)>mt)&&e.push(i)}),t&&e.length>1){const i=e[0],r=e[e.length-1];Math.abs(i.x-r.x)<=mt&&Math.abs(i.y-r.y)<=mt&&e.pop()}return e}function Tp(n,t,e){const i=n.length,r=n[t],s=n[(t-1+i)%i],a=n[(t+1)%i];let o=Lo(r.x-s.x,r.y-s.y),c=Lo(a.x-r.x,a.y-r.y);if(e||(t===0&&(o=c),t===i-1&&(c=o)),o==null&&c==null)return null;if(o==null)return gn(c);if(c==null)return gn(o);const l=gn(o),h=gn(c),u=l.x+h.x,d=l.y+h.y,g=Math.hypot(u,d);if(g<=mt)return h;const p={x:u/g,y:d/g},f=Math.abs(p.x*h.x+p.y*h.y),m=f<=mt?Po:Math.min(1/f,Po);return{x:p.x*m,y:p.y*m}}function Lo(n,t){const e=Math.hypot(n,t);return e<=mt?null:{x:n/e,y:t/e}}function gn(n){return{x:-n.y,y:n.x}}function Ni(n){let t=0;const e=n.length;for(let i=0;i<e;i++){const r=n[i],s=n[(i+1)%e];t+=r.x*s.y-s.x*r.y}return t/2}function Ri(n){return n.length>=3&&Math.abs(Ni(n))>mt}function Cp(n,t,e){return n+(t-n)*e}const Mp={patterns:[{name:"SOLID",description:"",lines:[]},{name:"ANGLE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.275,dashes:[.2,-.075],sourceLine:23},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.275,dashes:[.2,-.075],sourceLine:24}]},{name:"ANSI31",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:26}]},{name:"ANSI32",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.375,dashes:[],sourceLine:28},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.375,dashes:[],sourceLine:29}]},{name:"ANSI33",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:31},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.25,dashes:[.125,-.0625],sourceLine:32}]},{name:"ANSI34",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:34},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:35},{angle:45,originX:.353553391,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:36},{angle:45,originX:.530330086,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:37}]},{name:"ANSI35",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:39},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.25,dashes:[.3125,-.0625,0,-.0625],sourceLine:40}]},{name:"ANSI36",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:.21875,deltaY:.125,dashes:[.3125,-.0625,0,-.0625],sourceLine:42}]},{name:"ANSI37",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:44},{angle:135,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:45}]},{name:"ANSI38",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:47},{angle:135,originX:0,originY:0,deltaX:.25,deltaY:.125,dashes:[.3125,-.1875],sourceLine:48}]},{name:"AR-B816",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:8,dashes:[],sourceLine:54},{angle:90,originX:0,originY:0,deltaX:8,deltaY:8,dashes:[8,-8],sourceLine:55}]},{name:"AR-B816C",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:8,deltaY:8,dashes:[15.625,-.375],sourceLine:57},{angle:0,originX:-8,originY:.375,deltaX:8,deltaY:8,dashes:[15.625,-.375],sourceLine:58},{angle:90,originX:0,originY:0,deltaX:8,deltaY:8,dashes:[-8.375,7.625],sourceLine:59},{angle:90,originX:-.375,originY:0,deltaX:8,deltaY:8,dashes:[-8.375,7.625],sourceLine:60}]},{name:"AR-B88",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:8,dashes:[],sourceLine:62},{angle:90,originX:0,originY:0,deltaX:8,deltaY:4,dashes:[8,-8],sourceLine:63}]},{name:"AR-BRELM",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5.334,dashes:[7.625,-.375],sourceLine:65},{angle:0,originX:0,originY:2.25,deltaX:0,deltaY:5.334,dashes:[7.625,-.375],sourceLine:66},{angle:0,originX:2,originY:2.667,deltaX:0,deltaY:5.334,dashes:[3.625,-.375],sourceLine:67},{angle:0,originX:2,originY:4.917,deltaX:0,deltaY:5.334,dashes:[3.625,-.375],sourceLine:68},{angle:90,originX:0,originY:0,deltaX:0,deltaY:8,dashes:[2.25,-3.084],sourceLine:69},{angle:90,originX:-.375,originY:0,deltaX:0,deltaY:8,dashes:[2.25,-3.084],sourceLine:70},{angle:90,originX:2,originY:2.667,deltaX:0,deltaY:4,dashes:[2.25,-3.084],sourceLine:71},{angle:90,originX:1.625,originY:2.667,deltaX:0,deltaY:4,dashes:[2.25,-3.084],sourceLine:72}]},{name:"AR-BRSTD",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:2.667,dashes:[],sourceLine:74},{angle:90,originX:0,originY:0,deltaX:2.667,deltaY:4,dashes:[2.667,-2.667],sourceLine:75}]},{name:"AR-CONC",description:"",lines:[{angle:50,originX:0,originY:0,deltaX:4.12975034,deltaY:-5.89789472,dashes:[.75,-8.25],sourceLine:77},{angle:355,originX:0,originY:0,deltaX:-2.03781207,deltaY:7.3723684,dashes:[.6,-6.6],sourceLine:78},{angle:100.45144446,originX:.59771681,originY:-.05229344,deltaX:5.7305871,deltaY:-6.9397673,dashes:[.63740192,-7.01142112],sourceLine:79},{angle:46.1842,originX:0,originY:2,deltaX:6.19462554,deltaY:-8.84684596,dashes:[1.125,-12.375],sourceLine:80},{angle:96.63563549,originX:.88936745,originY:1.86206693,deltaX:8.59588239,deltaY:-10.40964966,dashes:[.95610342,-10.5171376],sourceLine:81},{angle:351.18416399,originX:0,originY:2,deltaX:7.74327494,deltaY:11.05855746,dashes:[.9,-9.90000001],sourceLine:82},{angle:21,originX:1,originY:1.5,deltaX:4.12975034,deltaY:-5.89789472,dashes:[.75,-8.25],sourceLine:83},{angle:326,originX:1,originY:1.5,deltaX:-2.03781207,deltaY:7.3723684,dashes:[.6,-6.6],sourceLine:84},{angle:71.45144474,originX:1.49742254,originY:1.16448426,deltaX:5.7305871,deltaY:-6.9397673,dashes:[.6374019,-7.01142112],sourceLine:85},{angle:37.5,originX:0,originY:0,deltaX:2.123,deltaY:2.567,dashes:[0,-6.52,0,-6.7,0,-6.625],sourceLine:86},{angle:7.5,originX:0,originY:0,deltaX:3.123,deltaY:3.567,dashes:[0,-3.82,0,-6.37,0,-2.525],sourceLine:87},{angle:-32.5,originX:-2.23,originY:0,deltaX:4.6234,deltaY:2.678,dashes:[0,-2.5,0,-7.8,0,-10.35],sourceLine:88},{angle:-42.5,originX:-3.23,originY:0,deltaX:3.6234,deltaY:4.678,dashes:[0,-3.25,0,-5.18,0,-7.35],sourceLine:89}]},{name:"AR-HBONE",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:4,deltaY:4,dashes:[12,-4],sourceLine:91},{angle:135,originX:2.828427125,originY:2.828427125,deltaX:4,deltaY:-4,dashes:[12,-4],sourceLine:92}]},{name:"AR-PARQ1",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:94},{angle:90,originX:2,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:95},{angle:90,originX:4,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:96},{angle:90,originX:6,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:97},{angle:90,originX:8,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:98},{angle:90,originX:10,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:99},{angle:90,originX:12,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:100},{angle:0,originX:0,originY:12,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:101},{angle:0,originX:0,originY:14,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:102},{angle:0,originX:0,originY:16,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:103},{angle:0,originX:0,originY:18,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:104},{angle:0,originX:0,originY:20,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:105},{angle:0,originX:0,originY:22,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:106},{angle:0,originX:0,originY:24,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:107}]},{name:"AR-RROOF",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:2.2,deltaY:1,dashes:[15,-2,5,-1],sourceLine:109},{angle:0,originX:1.33,originY:.5,deltaX:-1,deltaY:1.33,dashes:[3,-.33,6,-.75],sourceLine:110},{angle:0,originX:.5,originY:.85,deltaX:5.2,deltaY:.67,dashes:[8,-1.4,4,-1],sourceLine:111}]},{name:"AR-RSHKE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:25.5,deltaY:12,dashes:[6,-5,7,-3,9,-4],sourceLine:113},{angle:0,originX:6,originY:.5,deltaX:25.5,deltaY:12,dashes:[5,-19,4,-6],sourceLine:114},{angle:0,originX:18,originY:-.75,deltaX:25.5,deltaY:12,dashes:[3,-31],sourceLine:115},{angle:90,originX:0,originY:0,deltaX:12,deltaY:8.5,dashes:[11.5,-36.5],sourceLine:116},{angle:90,originX:6,originY:0,deltaX:12,deltaY:8.5,dashes:[11.25,-36.75],sourceLine:117},{angle:90,originX:11,originY:0,deltaX:12,deltaY:8.5,dashes:[10.5,-37.5],sourceLine:118},{angle:90,originX:18,originY:-.75,deltaX:12,deltaY:8.5,dashes:[11.5,-36.5],sourceLine:119},{angle:90,originX:21,originY:-.75,deltaX:12,deltaY:8.5,dashes:[11.5,-36.5],sourceLine:120},{angle:90,originX:30,originY:0,deltaX:12,deltaY:8.5,dashes:[11,-37],sourceLine:121}]},{name:"AR-SAND",description:"",lines:[{angle:37.5,originX:0,originY:0,deltaX:1.123,deltaY:1.567,dashes:[0,-1.52,0,-1.7,0,-1.625],sourceLine:123},{angle:7.5,originX:0,originY:0,deltaX:2.123,deltaY:2.567,dashes:[0,-.82,0,-1.37,0,-.525],sourceLine:124},{angle:-32.5,originX:-1.23,originY:0,deltaX:2.6234,deltaY:1.678,dashes:[0,-.5,0,-1.8,0,-2.35],sourceLine:125},{angle:-42.5,originX:-1.23,originY:0,deltaX:1.6234,deltaY:2.678,dashes:[0,-.25,0,-1.18,0,-1.35],sourceLine:126}]},{name:"BOX",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[],sourceLine:128},{angle:90,originX:.25,originY:0,deltaX:0,deltaY:1,dashes:[],sourceLine:129},{angle:0,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[-.25,.25],sourceLine:130},{angle:0,originX:0,originY:.25,deltaX:0,deltaY:1,dashes:[-.25,.25],sourceLine:131},{angle:0,originX:0,originY:.5,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:132},{angle:0,originX:0,originY:.75,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:133},{angle:90,originX:.5,originY:0,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:134},{angle:90,originX:.75,originY:0,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:135}]},{name:"BRASS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:137},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.25,dashes:[.125,-.0625],sourceLine:138}]},{name:"BRICK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:140},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.5,dashes:[.25,-.25],sourceLine:141},{angle:90,originX:.25,originY:0,deltaX:0,deltaY:.5,dashes:[-.25,.25],sourceLine:142}]},{name:"BRSTONE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.33,dashes:[],sourceLine:144},{angle:90,originX:.9,originY:0,deltaX:.33,deltaY:.5,dashes:[.33,-.33],sourceLine:145},{angle:90,originX:.8,originY:0,deltaX:.33,deltaY:.5,dashes:[.33,-.33],sourceLine:146},{angle:0,originX:.9,originY:.055,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:147},{angle:0,originX:.9,originY:.11,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:148},{angle:0,originX:.9,originY:.165,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:149},{angle:0,originX:.9,originY:.22,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:150},{angle:0,originX:.9,originY:.275,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:151}]},{name:"CLAY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.1875,dashes:[],sourceLine:153},{angle:0,originX:0,originY:.03125,deltaX:0,deltaY:.1875,dashes:[],sourceLine:154},{angle:0,originX:0,originY:.0625,deltaX:0,deltaY:.1875,dashes:[],sourceLine:155},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.1875,dashes:[.1875,-.125],sourceLine:156}]},{name:"CORK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:158},{angle:135,originX:.0625,originY:-.0625,deltaX:0,deltaY:.35355339,dashes:[.176776696,-.176776696],sourceLine:159},{angle:135,originX:.09375,originY:-.0625,deltaX:0,deltaY:.35355339,dashes:[.176776696,-.176776696],sourceLine:160},{angle:135,originX:.125,originY:-.0625,deltaX:0,deltaY:.35355339,dashes:[.176776696,-.176776696],sourceLine:161}]},{name:"CROSS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.25,deltaY:.25,dashes:[.125,-.375],sourceLine:163},{angle:90,originX:.0625,originY:-.0625,deltaX:.25,deltaY:.25,dashes:[.125,-.375],sourceLine:164}]},{name:"DASH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.125,deltaY:.125,dashes:[.125,-.125],sourceLine:166}]},{name:"DOLMIT",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:168},{angle:45,originX:0,originY:0,deltaX:0,deltaY:.70710678,dashes:[.3535533905932738,-.7071067811865476],sourceLine:169}]},{name:"DOTS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.03125,deltaY:.0625,dashes:[0,-.0625],sourceLine:171}]},{name:"EARTH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:173},{angle:0,originX:0,originY:.09375,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:174},{angle:0,originX:0,originY:.1875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:175},{angle:90,originX:.03125,originY:.21875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:176},{angle:90,originX:.125,originY:.21875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:177},{angle:90,originX:.21875,originY:.21875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:178}]},{name:"ESCHER",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[1.1,-.1],sourceLine:180},{angle:180,originX:0,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[1.1,-.1],sourceLine:181},{angle:300,originX:0,originY:0,deltaX:.6,deltaY:1.039230484,dashes:[1.1,-.1],sourceLine:182},{angle:60,originX:.1,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:183},{angle:300,originX:.1,originY:0,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:184},{angle:60,originX:-.05,originY:.08660254,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:185},{angle:180,originX:-.05,originY:.08660254,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:186},{angle:300,originX:-.05,originY:-.08660254,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:187},{angle:180,originX:-.05,originY:-.08660254,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:188},{angle:60,originX:-.4,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:189},{angle:300,originX:-.4,originY:0,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:190},{angle:60,originX:.2,originY:-.346410161,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:191},{angle:180,originX:.2,originY:-.346410161,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:192},{angle:300,originX:.2,originY:.346410161,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:193},{angle:180,originX:.2,originY:.346410161,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:194},{angle:0,originX:.2,originY:.173205081,deltaX:-.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:195},{angle:0,originX:.2,originY:-.173205081,deltaX:-.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:196},{angle:120,originX:.05,originY:.259807621,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:197},{angle:120,originX:-.25,originY:.08660254,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:198},{angle:240,originX:-.25,originY:-.08660254,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:199},{angle:240,originX:.05,originY:-.259807621,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:200}]},{name:"FLEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[.25,-.25],sourceLine:202},{angle:45,originX:.25,originY:0,deltaX:.176776695296,deltaY:.176776695296,dashes:[.0625,-.2285533906,.0625,-.353553390593],sourceLine:203}]},{name:"GOST_GLASS",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:6,deltaY:-6,dashes:[5,-7],sourceLine:205},{angle:45,originX:2.12132,originY:0,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:206},{angle:45,originX:0,originY:2.12132,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:207}]},{name:"GOST_WOOD",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:209},{angle:90,originX:2,originY:-2,deltaX:0,deltaY:-6,dashes:[6,-1.5,3,-1.5],sourceLine:210},{angle:90,originX:4,originY:-5,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:211}]},{name:"GOST_GROUND",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:213},{angle:45,originX:3,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:214},{angle:45,originX:6,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:215}]},{name:"GRASS",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:.707106781,deltaY:.707106781,dashes:[.1875,-1.226713563],sourceLine:217},{angle:45,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[.1875,-.8125],sourceLine:218},{angle:135,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[.1875,-.8125],sourceLine:219}]},{name:"GRATE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.03125,dashes:[],sourceLine:221},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:222}]},{name:"GRAVEL",description:"",lines:[{angle:228.012787504,originX:.72,originY:1,deltaX:12.0413651692039,deltaY:.0743294146632,dashes:[.134536,-13.3190880470737],sourceLine:224},{angle:184.969740728,originX:.63,originY:.9,deltaX:-12.0415166747131,deltaY:.0433148081592,dashes:[.230868,-22.85592476123],sourceLine:225},{angle:132.510447078,originX:.4,originY:.88,deltaX:-14.8659418273816,deltaY:.061429511683,dashes:[.162788,-16.1160325960997],sourceLine:226},{angle:267.273689006,originX:.01,originY:.63,deltaX:-20.0249279039043,deltaY:.0475651493827,dashes:[.210238,-20.813558041629],sourceLine:227},{angle:292.833654178,originX:0,originY:.42,deltaX:-12.9999095019474,deltaY:.048507125026,dashes:[.206155,-20.4093731280883],sourceLine:228},{angle:357.273689006,originX:.08,originY:.23,deltaX:-20.0249279039043,deltaY:.0475651493827,dashes:[.210238,-20.813558041629],sourceLine:229},{angle:37.6942404667,originX:.29,originY:.22,deltaX:-16.4011800288558,deltaY:.0359675000664,dashes:[.278029,-27.524848548916],sourceLine:230},{angle:72.2553283749,originX:.51,originY:.39,deltaX:23.0867613281116,deltaY:.0380969659053,dashes:[.262488,-25.9863214968134],sourceLine:231},{angle:121.429565615,originX:.59,originY:.64,deltaX:15.2642639131074,deltaY:.047404546271,dashes:[.21095,-20.884073109729],sourceLine:232},{angle:175.236358309,originX:.48,originY:.82,deltaX:-11.0450488205478,deltaY:.083045479801,dashes:[.240832,-11.8007625787923],sourceLine:233},{angle:222.397437798,originX:.24,originY:.84,deltaX:16.2787889313724,deltaY:.0321080648114,dashes:[.311448,-30.8333750047949],sourceLine:234},{angle:138.814074834,originX:1,originY:.62,deltaX:9.2190645101588,deltaY:.0940720868851,dashes:[.106301,-10.5238448127347],sourceLine:235},{angle:171.46923439,originX:.92,originY:.69,deltaX:-13.1528534931484,deltaY:.0494468176315,dashes:[.202237,-20.021511416157],sourceLine:236},{angle:225,originX:.72,originY:.72,deltaX:.7071067811865,deltaY:.7071067811865,dashes:[.141421,-1.2727925623731],sourceLine:237},{angle:203.198590514,originX:.65,originY:.84,deltaX:-5.3835637472478,deltaY:.1313064328928,dashes:[.076158,-7.5396151058639],sourceLine:238},{angle:291.801409486,originX:.58,originY:.81,deltaX:-3.156820749011,deltaY:.185695338158,dashes:[.107703,-5.2774618071345],sourceLine:239},{angle:30.9637565321,originX:.62,originY:.71,deltaX:3.6014702879928,deltaY:.1714985851408,dashes:[.174929,-5.6560228948453],sourceLine:240},{angle:161.565051177,originX:.77,originY:.8,deltaX:-2.2135943621183,deltaY:.3162277660138,dashes:[.126491,-3.0357866601684],sourceLine:241},{angle:16.389540334,originX:0,originY:.81,deltaX:10.4401539876873,deltaY:.0564332648047,dashes:[.1772,-17.5428451466694],sourceLine:242},{angle:70.3461759419,originX:.17,originY:.86,deltaX:-11.7045066155395,deltaY:.0672672793901,dashes:[.148661,-14.717407747319],sourceLine:243},{angle:293.198590514,originX:.77,originY:1,deltaX:-5.3835637472478,deltaY:.1313064328928,dashes:[.152315,-7.4634581058639],sourceLine:244},{angle:343.610459666,originX:.83,originY:.86,deltaX:-10.4401539876873,deltaY:.0564332648047,dashes:[.1772,-17.542845146669],sourceLine:245},{angle:339.44395478,originX:0,originY:.19,deltaX:-5.3838927710229,deltaY:.117041147157,dashes:[.17088,-8.3731237453175],sourceLine:246},{angle:294.775140569,originX:.16,originY:.13,deltaX:-12.0828441168135,deltaY:.0698430296124,dashes:[.143178,-14.174643063276],sourceLine:247},{angle:66.8014094864,originX:.78,originY:0,deltaX:5.3835637472487,deltaY:.1313064328552,dashes:[.152315,-7.4634581058639],sourceLine:248},{angle:17.3540246363,originX:.84,originY:.14,deltaX:-13.6013396869991,deltaY:.0596549986364,dashes:[.167631,-16.59542361424],sourceLine:249},{angle:69.4439547804,originX:.29,originY:0,deltaX:-5.383892771022,deltaY:.1170411471946,dashes:[.08544,-8.4585637453175],sourceLine:250},{angle:101.309932474,originX:.72,originY:0,deltaX:4.1184388379018,deltaY:.1961161351396,dashes:[.05099,-5.0480295135928],sourceLine:251},{angle:165.963756532,originX:.71,originY:.05,deltaX:-3.1529631254726,deltaY:.2425356250323,dashes:[.206155,-3.9169506256177],sourceLine:252},{angle:186.009005957,originX:.51,originY:.1,deltaX:-10.0497393137326,deltaY:.0523423921723,dashes:[.19105,-18.9139231745428],sourceLine:253},{angle:303.690067526,originX:.62,originY:.62,deltaX:-2.2188007849008,deltaY:.2773500981134,dashes:[.144222,-3.461329275464],sourceLine:254},{angle:353.157226587,originX:.7,originY:.5,deltaX:17.1171966955143,deltaY:.0397150736497,dashes:[.251794,-24.9275626240283],sourceLine:255},{angle:60.9453959009,originX:.95,originY:.47,deltaX:-8.0616726575653,deltaY:.0971285862325,dashes:[.102956,-10.192674140987],sourceLine:256},{angle:90,originX:1,originY:.56,deltaX:1,deltaY:1,dashes:[.06,-.94],sourceLine:257},{angle:120.256437164,originX:.49,originY:.13,deltaX:-8.0619364083848,deltaY:.0719815751411,dashes:[.138924,-13.7535199894498],sourceLine:258},{angle:48.0127875042,originX:.42,originY:.25,deltaX:12.0413651692041,deltaY:.0743294146212,dashes:[.269072,-13.1845520470737],sourceLine:259},{angle:0,originX:.6,originY:.45,deltaX:1,deltaY:1,dashes:[.26,-.74],sourceLine:260},{angle:325.304846469,originX:.86,originY:.45,deltaX:12.2063917682497,deltaY:-.063245553253,dashes:[.158114,-15.653274300842],sourceLine:261},{angle:254.054604099,originX:.99,originY:.36,deltaX:4.1208169184605,deltaY:.1373605639542,dashes:[.145602,-7.1345078892805],sourceLine:262},{angle:207.645975364,originX:.95,originY:.22,deltaX:21.4708691170287,deltaY:.0421824539631,dashes:[.237065,-23.4694741822594],sourceLine:263},{angle:175.42607874,originX:.74,originY:.11,deltaX:13.0383438432524,deltaY:.039872611164,dashes:[.250799,-24.8290734079689],sourceLine:264}]},{name:"HEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.21650635094610965,dashes:[.125,-.25],sourceLine:266},{angle:120,originX:0,originY:0,deltaX:0,deltaY:.21650635094610965,dashes:[.125,-.25],sourceLine:267},{angle:60,originX:.125,originY:0,deltaX:0,deltaY:.21650635094610965,dashes:[.125,-.25],sourceLine:268}]},{name:"HONEY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.1875,deltaY:.10825317547305482,dashes:[.125,-.25],sourceLine:270},{angle:120,originX:0,originY:0,deltaX:.1875,deltaY:.10825317547305482,dashes:[.125,-.25],sourceLine:271},{angle:60,originX:0,originY:0,deltaX:.1875,deltaY:.10825317547305482,dashes:[-.25,.125],sourceLine:272}]},{name:"HOUND",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.25,deltaY:.0625,dashes:[1,-.5],sourceLine:274},{angle:90,originX:0,originY:0,deltaX:-.25,deltaY:.0625,dashes:[1,-.5],sourceLine:275}]},{name:"INSUL",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.375,dashes:[],sourceLine:277},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.375,dashes:[.125,-.125],sourceLine:278},{angle:0,originX:0,originY:.25,deltaX:0,deltaY:.375,dashes:[.125,-.125],sourceLine:279}]},{name:"ACAD_ISO02W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3],sourceLine:292}]},{name:"ACAD_ISO03W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-18],sourceLine:294}]},{name:"ACAD_ISO04W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3],sourceLine:296}]},{name:"ACAD_ISO05W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-3],sourceLine:298}]},{name:"ACAD_ISO06W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-6.5],sourceLine:300},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-34,.5,-3],sourceLine:301}]},{name:"ACAD_ISO07W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[.5,-3],sourceLine:303}]},{name:"ACAD_ISO08W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3],sourceLine:305}]},{name:"ACAD_ISO09W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3,6,-3],sourceLine:307}]},{name:"ACAD_ISO10W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3],sourceLine:309}]},{name:"ACAD_ISO11W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-3],sourceLine:311}]},{name:"ACAD_ISO12W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-3],sourceLine:313}]},{name:"ACAD_ISO13W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-6.5],sourceLine:315},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3],sourceLine:316}]},{name:"ACAD_ISO14W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-6.5],sourceLine:318},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-22,.5,-3],sourceLine:319}]},{name:"ACAD_ISO15W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-10],sourceLine:321},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3,.5,-3],sourceLine:322}]},{name:"LINE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:327}]},{name:"MUDST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.5,deltaY:.25,dashes:[.25,-.25,0,-.25,0,-.25],sourceLine:329}]},{name:"NET",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:331},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:332}]},{name:"NET3",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:334},{angle:60,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:335},{angle:120,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:336}]},{name:"PLAST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:338},{angle:0,originX:0,originY:.03125,deltaX:0,deltaY:.25,dashes:[],sourceLine:339},{angle:0,originX:0,originY:.0625,deltaX:0,deltaY:.25,dashes:[],sourceLine:340}]},{name:"PLASTI",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:342},{angle:0,originX:0,originY:.03125,deltaX:0,deltaY:.25,dashes:[],sourceLine:343},{angle:0,originX:0,originY:.0625,deltaX:0,deltaY:.25,dashes:[],sourceLine:344},{angle:0,originX:0,originY:.15625,deltaX:0,deltaY:.25,dashes:[],sourceLine:345}]},{name:"SACNCR",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.09375,dashes:[],sourceLine:347},{angle:45,originX:.066291261,originY:0,deltaX:0,deltaY:.09375,dashes:[0,-.09375],sourceLine:348}]},{name:"SQUARE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[.125,-.125],sourceLine:350},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[.125,-.125],sourceLine:351}]},{name:"STARS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.216506351,dashes:[.125,-.125],sourceLine:353},{angle:60,originX:0,originY:0,deltaX:0,deltaY:.216506351,dashes:[.125,-.125],sourceLine:354},{angle:120,originX:.0625,originY:.108253176,deltaX:0,deltaY:.216506351,dashes:[.125,-.125],sourceLine:355}]},{name:"STEEL",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:357},{angle:45,originX:0,originY:.0625,deltaX:0,deltaY:.125,dashes:[],sourceLine:358}]},{name:"SWAMP",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.5,deltaY:.866025403,dashes:[.125,-.875],sourceLine:360},{angle:90,originX:.0625,originY:0,deltaX:.866025403,deltaY:.5,dashes:[.0625,-1.669550806],sourceLine:361},{angle:90,originX:.078125,originY:0,deltaX:.866025403,deltaY:.5,dashes:[.05,-1.682050806],sourceLine:362},{angle:90,originX:.046875,originY:0,deltaX:.866025403,deltaY:.5,dashes:[.05,-1.682050806],sourceLine:363},{angle:60,originX:.09375,originY:0,deltaX:.5,deltaY:.866025403,dashes:[.04,-.96],sourceLine:364},{angle:120,originX:.03125,originY:0,deltaX:.5,deltaY:.866025403,dashes:[.04,-.96],sourceLine:365}]},{name:"TRANS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:367},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.25,dashes:[.125,-.125],sourceLine:368}]},{name:"TRIANG",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:.1875,deltaY:.324759526,dashes:[.1875,-.1875],sourceLine:370},{angle:120,originX:0,originY:0,deltaX:.1875,deltaY:.324759526,dashes:[.1875,-.1875],sourceLine:371},{angle:0,originX:-.09375,originY:.162379763,deltaX:.1875,deltaY:.324759526,dashes:[.1875,-.1875],sourceLine:372}]},{name:"ZIGZAG",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.125,deltaY:.125,dashes:[.125,-.125],sourceLine:374},{angle:90,originX:.125,originY:0,deltaX:.125,deltaY:.125,dashes:[.125,-.125],sourceLine:375}]}],issues:[]},hh={patterns:[{name:"SOLID",description:"",lines:[]},{name:"ANGLE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.985,dashes:[5.08,-1.905],sourceLine:20},{angle:90,originX:0,originY:0,deltaX:0,deltaY:6.985,dashes:[5.08,-1.905],sourceLine:21}]},{name:"ANSI31",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:23}]},{name:"ANSI32",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:9.525,dashes:[],sourceLine:25},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:9.525,dashes:[],sourceLine:26}]},{name:"ANSI33",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:28},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:6.35,dashes:[3.175,-1.5875],sourceLine:29}]},{name:"ANSI34",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:31},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:32},{angle:45,originX:8.98026,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:33},{angle:45,originX:13.4704,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:34}]},{name:"ANSI35",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:36},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:6.35,dashes:[7.9375,-1.5875,0,-1.5875],sourceLine:37}]},{name:"ANSI36",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:5.55625,deltaY:3.175,dashes:[7.9375,-1.5875,0,-1.5875],sourceLine:39}]},{name:"ANSI37",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:41},{angle:135,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:42}]},{name:"ANSI38",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:44},{angle:135,originX:0,originY:0,deltaX:6.35,deltaY:3.175,dashes:[7.9375,-4.7625],sourceLine:45}]},{name:"AR-B816",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:203.2,dashes:[],sourceLine:47},{angle:90,originX:0,originY:0,deltaX:203.2,deltaY:203.2,dashes:[203.2,-203.2],sourceLine:48}]},{name:"AR-B816C",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:203.2,deltaY:203.2,dashes:[396.875,-9.525],sourceLine:50},{angle:0,originX:-203.2,originY:9.525,deltaX:203.2,deltaY:203.2,dashes:[396.875,-9.525],sourceLine:51},{angle:90,originX:0,originY:0,deltaX:203.2,deltaY:203.2,dashes:[-212.725,193.675],sourceLine:52},{angle:90,originX:-9.525,originY:0,deltaX:203.2,deltaY:203.2,dashes:[-212.725,193.675],sourceLine:53}]},{name:"AR-B88",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:203.2,dashes:[],sourceLine:55},{angle:90,originX:0,originY:0,deltaX:203.2,deltaY:101.6,dashes:[203.2,-203.2],sourceLine:56}]},{name:"AR-BRELM",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:135.484,dashes:[193.675,-9.525],sourceLine:58},{angle:0,originX:0,originY:57.15,deltaX:0,deltaY:135.484,dashes:[193.675,-9.525],sourceLine:59},{angle:0,originX:50.8,originY:67.7418,deltaX:0,deltaY:135.484,dashes:[92.075,-9.525],sourceLine:60},{angle:0,originX:50.8,originY:124.892,deltaX:0,deltaY:135.484,dashes:[92.075,-9.525],sourceLine:61},{angle:90,originX:0,originY:0,deltaX:0,deltaY:203.2,dashes:[57.15,-78.334],sourceLine:62},{angle:90,originX:-9.525,originY:0,deltaX:0,deltaY:203.2,dashes:[57.15,-78.334],sourceLine:63},{angle:90,originX:50.8,originY:67.7418,deltaX:0,deltaY:101.6,dashes:[57.15,-78.334],sourceLine:64},{angle:90,originX:41.275,originY:67.7418,deltaX:0,deltaY:101.6,dashes:[57.15,-78.334],sourceLine:65}]},{name:"AR-BRSTD",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:67.7418,dashes:[],sourceLine:67},{angle:90,originX:0,originY:0,deltaX:67.7418,deltaY:101.6,dashes:[67.7418,-67.7418],sourceLine:68}]},{name:"AR-CONC",description:"",lines:[{angle:50,originX:0,originY:0,deltaX:104.896,deltaY:-149.807,dashes:[19.05,-209.55],sourceLine:70},{angle:355,originX:0,originY:0,deltaX:-51.76101082,deltaY:187.25814969,dashes:[15.24,-167.64058417],sourceLine:71},{angle:100.4514447,originX:15.182007,originY:-1.3282535,deltaX:145.5569059,deltaY:-176.270089,dashes:[16.1900088,-178.0902446],sourceLine:72},{angle:46.1842,originX:0,originY:50.8,deltaX:157.343,deltaY:-224.71,dashes:[28.575,-314.325],sourceLine:73},{angle:96.63555761,originX:22.5899,originY:47.2965,deltaX:218.33577212,deltaY:-264.40480444,dashes:[24.28502314,-267.13560816],sourceLine:74},{angle:351.18415117,originX:0,originY:50.8,deltaX:196.67912063,deltaY:280.88740361,dashes:[22.85996707,-251.45973192],sourceLine:75},{angle:21,originX:25.4,originY:38.1,deltaX:104.89565868,deltaY:-149.80652586,dashes:[19.05,-209.55],sourceLine:76},{angle:326,originX:25.4,originY:38.1,deltaX:-51.7604,deltaY:187.258,dashes:[15.24,-167.64],sourceLine:77},{angle:71.451445,originX:38.0345326,originY:29.5779001,deltaX:145.5567546,deltaY:-176.2700748,dashes:[16.1900088,-178.0899376],sourceLine:78},{angle:37.5,originX:0,originY:0,deltaX:53.9242,deltaY:65.2018,dashes:[0,-165.608,0,-170.18,0,-168.275],sourceLine:79},{angle:7.5,originX:0,originY:0,deltaX:79.3242,deltaY:90.6018,dashes:[0,-97.028,0,-161.798,0,-64.135],sourceLine:80},{angle:-32.5,originX:-56.642,originY:0,deltaX:117.434,deltaY:68.0212,dashes:[0,-63.5,0,-198.12,0,-262.89],sourceLine:81},{angle:-42.5,originX:-82.042,originY:0,deltaX:92.0344,deltaY:118.821,dashes:[0,-82.55,0,-131.572,0,-186.69],sourceLine:82}]},{name:"AR-HBONE",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:101.6,deltaY:101.6,dashes:[304.8,-101.6],sourceLine:84},{angle:135,originX:71.842,originY:71.842,deltaX:101.6,deltaY:-101.6,dashes:[304.8,-101.6],sourceLine:85}]},{name:"AR-PARQ1",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:87},{angle:90,originX:50.8,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:88},{angle:90,originX:101.6,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:89},{angle:90,originX:152.4,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:90},{angle:90,originX:203.2,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:91},{angle:90,originX:254,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:92},{angle:90,originX:304.8,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:93},{angle:0,originX:0,originY:304.8,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:94},{angle:0,originX:0,originY:355.6,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:95},{angle:0,originX:0,originY:406.4,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:96},{angle:0,originX:0,originY:457.2,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:97},{angle:0,originX:0,originY:508,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:98},{angle:0,originX:0,originY:558.8,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:99},{angle:0,originX:0,originY:609.6,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:100}]},{name:"AR-RROOF",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:55.88,deltaY:25.4,dashes:[381,-50.8,127,-25.4],sourceLine:102},{angle:0,originX:33.782,originY:12.7,deltaX:-25.4,deltaY:33.782,dashes:[76.2,-8.382,152.4,-19.05],sourceLine:103},{angle:0,originX:12.7,originY:21.59,deltaX:132.08,deltaY:17.018,dashes:[203.2,-35.56,101.6,-25.4],sourceLine:104}]},{name:"AR-RSHKE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:647.7,deltaY:304.8,dashes:[152.4,-127,177.8,-76.2,228.6,-101.6],sourceLine:106},{angle:0,originX:152.4,originY:12.7,deltaX:647.7,deltaY:304.8,dashes:[127,-482.6,101.6,-152.4],sourceLine:107},{angle:0,originX:457.2,originY:-19.05,deltaX:647.7,deltaY:304.8,dashes:[76.2,-787.4],sourceLine:108},{angle:90,originX:0,originY:0,deltaX:304.8,deltaY:215.9,dashes:[292.1,-927.1],sourceLine:109},{angle:90,originX:152.4,originY:0,deltaX:304.8,deltaY:215.9,dashes:[285.75,-933.45],sourceLine:110},{angle:90,originX:279.4,originY:0,deltaX:304.8,deltaY:215.9,dashes:[266.7,-952.5],sourceLine:111},{angle:90,originX:457.2,originY:-19.05,deltaX:304.8,deltaY:215.9,dashes:[292.1,-927.1],sourceLine:112},{angle:90,originX:533.4,originY:-19.05,deltaX:304.8,deltaY:215.9,dashes:[292.1,-927.1],sourceLine:113},{angle:90,originX:762,originY:0,deltaX:304.8,deltaY:215.9,dashes:[279.4,-939.8],sourceLine:114}]},{name:"AR-SAND",description:"",lines:[{angle:37.5,originX:0,originY:0,deltaX:28.5242,deltaY:39.8018,dashes:[0,-38.608,0,-43.18,0,-41.275],sourceLine:116},{angle:7.5,originX:0,originY:0,deltaX:53.9242,deltaY:65.2018,dashes:[0,-20.828,0,-34.798,0,-13.335],sourceLine:117},{angle:-32.5,originX:-31.242,originY:0,deltaX:66.6344,deltaY:42.6212,dashes:[0,-12.7,0,-45.72,0,-59.69],sourceLine:118},{angle:-42.5,originX:-31.242,originY:0,deltaX:41.2344,deltaY:68.0212,dashes:[0,-6.35,0,-29.972,0,-34.29],sourceLine:119}]},{name:"BOX",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[],sourceLine:121},{angle:90,originX:6.35,originY:0,deltaX:0,deltaY:25.4,dashes:[],sourceLine:122},{angle:0,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[-6.35,6.35],sourceLine:123},{angle:0,originX:0,originY:6.35,deltaX:0,deltaY:25.4,dashes:[-6.35,6.35],sourceLine:124},{angle:0,originX:0,originY:12.7,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:125},{angle:0,originX:0,originY:19.05,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:126},{angle:90,originX:12.7,originY:0,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:127},{angle:90,originX:19.05,originY:0,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:128}]},{name:"BRASS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:130},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:6.35,dashes:[3.175,-1.5875],sourceLine:131}]},{name:"BRICK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:133},{angle:90,originX:0,originY:0,deltaX:0,deltaY:12.7,dashes:[6.35,-6.35],sourceLine:134},{angle:90,originX:6.35,originY:0,deltaX:0,deltaY:12.7,dashes:[-6.35,6.35],sourceLine:135}]},{name:"BRSTONE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:8.382,dashes:[],sourceLine:137},{angle:90,originX:22.86,originY:0,deltaX:8.382,deltaY:12.7,dashes:[8.382,-8.382],sourceLine:138},{angle:90,originX:20.32,originY:0,deltaX:8.382,deltaY:12.7,dashes:[8.382,-8.382],sourceLine:139},{angle:0,originX:22.86,originY:1.397,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:140},{angle:0,originX:22.86,originY:2.794,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:141},{angle:0,originX:22.86,originY:4.191,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:142},{angle:0,originX:22.86,originY:5.588,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:143},{angle:0,originX:22.86,originY:6.985,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:144}]},{name:"CLAY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:4.7625,dashes:[],sourceLine:146},{angle:0,originX:0,originY:.79375,deltaX:0,deltaY:4.7625,dashes:[],sourceLine:147},{angle:0,originX:0,originY:1.5875,deltaX:0,deltaY:4.7625,dashes:[],sourceLine:148},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:4.7625,dashes:[4.7625,-3.175],sourceLine:149}]},{name:"CORK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:151},{angle:135,originX:1.5875,originY:-1.5875,deltaX:0,deltaY:8.98026,dashes:[4.49013,-4.49013],sourceLine:152},{angle:135,originX:2.38125,originY:-1.5875,deltaX:0,deltaY:8.98026,dashes:[4.49013,-4.49013],sourceLine:153},{angle:135,originX:3.175,originY:-1.5875,deltaX:0,deltaY:8.98026,dashes:[4.49013,-4.49013],sourceLine:154}]},{name:"CROSS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:6.35,deltaY:6.35,dashes:[3.175,-9.525],sourceLine:156},{angle:90,originX:1.5875,originY:-1.5875,deltaX:6.35,deltaY:6.35,dashes:[3.175,-9.525],sourceLine:157}]},{name:"DASH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:3.175,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:159}]},{name:"DOLMIT",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:161},{angle:45,originX:0,originY:0,deltaX:0,deltaY:17.9605,dashes:[8.980256121069154,-17.960512242138307],sourceLine:162}]},{name:"DOTS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.79375,deltaY:1.5875,dashes:[0,-1.5875],sourceLine:164}]},{name:"EARTH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:166},{angle:0,originX:0,originY:2.38125,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:167},{angle:0,originX:0,originY:4.7625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:168},{angle:90,originX:.79375,originY:5.55625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:169},{angle:90,originX:3.175,originY:5.55625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:170},{angle:90,originX:5.55625,originY:5.55625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:171}]},{name:"ESCHER",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[27.94,-2.54],sourceLine:173},{angle:180,originX:0,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[27.94,-2.54],sourceLine:174},{angle:300,originX:0,originY:0,deltaX:15.24,deltaY:26.3964542936,dashes:[27.94,-2.54],sourceLine:175},{angle:60,originX:2.54,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:176},{angle:300,originX:2.54,originY:0,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:177},{angle:60,originX:-1.27,originY:2.199704516,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:178},{angle:180,originX:-1.27,originY:2.199704516,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:179},{angle:300,originX:-1.27,originY:-2.199704516,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:180},{angle:180,originX:-1.27,originY:-2.199704516,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:181},{angle:60,originX:-10.16,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:182},{angle:300,originX:-10.16,originY:0,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:183},{angle:60,originX:5.08,originY:-8.7988180894,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:184},{angle:180,originX:5.08,originY:-8.7988180894,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:185},{angle:300,originX:5.08,originY:8.7988180894,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:186},{angle:180,originX:5.08,originY:8.7988180894,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:187},{angle:0,originX:5.08,originY:4.3994090574,deltaX:-15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:188},{angle:0,originX:5.08,originY:-4.3994090574,deltaX:-15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:189},{angle:120,originX:1.27,originY:6.5991135734,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:190},{angle:120,originX:-6.35,originY:2.199704516,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:191},{angle:240,originX:-6.35,originY:-2.199704516,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:192},{angle:240,originX:1.27,originY:-6.5991135734,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:193}]},{name:"FLEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:195},{angle:45,originX:6.35,originY:0,deltaX:4.490128053,deltaY:4.490128053,dashes:[1.5875,-5.8052561314,1.5875,-8.9802561314],sourceLine:196}]},{name:"GOST_GLASS",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:6,deltaY:-6,dashes:[5,-7],sourceLine:198},{angle:45,originX:2.12132,originY:0,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:199},{angle:45,originX:0,originY:2.12132,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:200}]},{name:"GOST_WOOD",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:202},{angle:90,originX:2,originY:-2,deltaX:0,deltaY:-6,dashes:[6,-1.5,3,-1.5],sourceLine:203},{angle:90,originX:4,originY:-5,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:204}]},{name:"GOST_GROUND",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:206},{angle:45,originX:3,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:207},{angle:45,originX:6,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:208}]},{name:"GRASS",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:17.96051224,deltaY:17.96051224,dashes:[4.7625,-31.15852448],sourceLine:210},{angle:45,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[4.7625,-20.6375],sourceLine:211},{angle:135,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[4.7625,-20.6375],sourceLine:212}]},{name:"GRATE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.79375,dashes:[],sourceLine:214},{angle:90,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:215}]},{name:"GRAVEL",description:"",lines:[{angle:228.0127875,originX:18.288,originY:25.4,deltaX:305.85067529778,deltaY:1.88796713245,dashes:[3.4172144,-338.30483639565],sourceLine:217},{angle:184.969741,originX:16.002,originY:22.86,deltaX:-305.8545235377,deltaY:1.10019612724,dashes:[5.8640472,-580.54048893524],sourceLine:218},{angle:132.5104471,originX:10.16,originY:22.352,deltaX:-377.59492241548,deltaY:1.56030959675,dashes:[4.1348152,-409.347227941],sourceLine:219},{angle:267.273689,originX:.254,originY:16.002,deltaX:-508.63316875916,deltaY:1.20815479432,dashes:[5.3400452,-528.66437425738],sourceLine:220},{angle:292.83365418,originX:0,originY:10.668,deltaX:-330.19770134945,deltaY:1.23208097566,dashes:[5.236337,-518.39807745344],sourceLine:221},{angle:357.273689,originX:2.032,originY:5.842,deltaX:-508.63316875916,deltaY:1.20815479432,dashes:[5.3400452,-528.66437425738],sourceLine:222},{angle:37.69424047,originX:7.366,originY:5.588,deltaX:-416.58997273292,deltaY:.91357450169,dashes:[7.0619366,-699.13115314247],sourceLine:223},{angle:72.25532837,originX:12.954,originY:9.906,deltaX:586.40373773403,deltaY:.96766293399,dashes:[6.6671952,-660.05256601905],sourceLine:224},{angle:121.42956562,originX:14.986,originY:16.256,deltaX:387.71230339293,deltaY:1.2040754753,dashes:[5.35813,-530.45545698712],sourceLine:225},{angle:175.2363583,originX:12.192,originY:20.828,deltaX:-280.5442400419,deltaY:2.10935518695,dashes:[6.1171328,-299.7393695],sourceLine:226},{angle:222.3974378,originX:6.096,originY:21.336,deltaX:413.48123885686,deltaY:.81554484621,dashes:[7.9107792,-783.16772512177],sourceLine:227},{angle:138.81407483,originX:25.4,originY:15.748,deltaX:234.164238558,deltaY:2.38943100688,dashes:[2.7000454,-267.30565824344],sourceLine:228},{angle:171.4692344,originX:23.368,originY:17.526,deltaX:-334.082478726,deltaY:1.25594916784,dashes:[5.1368198,-508.5463899704],sourceLine:229},{angle:225,originX:18.288,originY:18.288,deltaX:17.96051224214,deltaY:17.96051224214,dashes:[3.5920934,-32.32893108428],sourceLine:230},{angle:203.19859051,originX:16.51,originY:21.336,deltaX:-136.74251918,deltaY:3.33518339548,dashes:[1.9344132,-191.50622368894],sourceLine:231},{angle:291.80140949,originX:14.732,originY:20.574,deltaX:-80.18324702488,deltaY:4.71666158921,dashes:[2.7356562,-134.0475299],sourceLine:232},{angle:30.96375653,originX:15.748,originY:18.034,deltaX:91.47734531502,deltaY:4.35606406258,dashes:[4.4431966,-143.6629815291],sourceLine:233},{angle:161.56505118,originX:19.558,originY:20.32,deltaX:-56.2252967978,deltaY:8.03218525675,dashes:[3.2128714,-77.10898116828],sourceLine:234},{angle:16.389540334,originX:0,originY:20.574,deltaX:265.17991128726,deltaY:1.43340492604,dashes:[4.50088,-445.58826672539],sourceLine:235},{angle:70.34617594,originX:4.318,originY:21.844,deltaX:-297.29446803469,deltaY:1.70858889651,dashes:[3.7759894,-373.822156782],sourceLine:236},{angle:293.19859051,originX:19.558,originY:25.4,deltaX:-136.7425191801,deltaY:3.33518339548,dashes:[3.868801,-189.57183588894],sourceLine:237},{angle:343.61045967,originX:21.082,originY:21.844,deltaX:-265.17991128725,deltaY:1.433404926,dashes:[4.50088,-445.5882667254],sourceLine:238},{angle:339.44395478,originX:0,originY:4.826,deltaX:-136.75087638398,deltaY:2.97284513779,dashes:[4.340352,-212.67734313106],sourceLine:239},{angle:294.7751406,originX:4.064,originY:3.302,deltaX:-306.90424056705,deltaY:1.77401295215,dashes:[3.6367212,-360.0359338072],sourceLine:240},{angle:66.80140949,originX:19.812,originY:0,deltaX:136.74251918012,deltaY:3.33518339452,dashes:[3.868801,-189.57183588894],sourceLine:241},{angle:17.35402464,originX:21.336,originY:3.556,deltaX:-345.47402804977,deltaY:1.51523696536,dashes:[4.2578274,-421.523759802],sourceLine:242},{angle:69.44395478,originX:7.366,originY:0,deltaX:-136.75087638396,deltaY:2.97284513874,dashes:[2.170176,-214.84751913106],sourceLine:243},{angle:101.309932474,originX:18.288,originY:0,deltaX:104.60834648271,deltaY:4.98134983255,dashes:[1.295146,-128.21994964526],sourceLine:244},{angle:165.963756532,originX:18.034,originY:1.27,deltaX:-80.085263387,deltaY:6.16040487582,dashes:[5.236337,-99.49054589069],sourceLine:245},{angle:186.00900596,originX:12.954,originY:2.54,deltaX:-255.26337856879,deltaY:1.32949676118,dashes:[4.85267,-480.41364863337],sourceLine:246},{angle:303.69006753,originX:15.748,originY:15.748,deltaX:-56.35753993648,deltaY:7.0446924921,dashes:[3.6632388,-87.9177635968],sourceLine:247},{angle:353.15722659,originX:17.78,originY:12.7,deltaX:434.77679606606,deltaY:1.0087628707,dashes:[6.3955676,-633.16009065031],sourceLine:248},{angle:60.9453959,originX:24.13,originY:11.938,deltaX:-204.76648550216,deltaY:2.46706609031,dashes:[2.6150824,-258.8939231811],sourceLine:249},{angle:90,originX:25.4,originY:14.224,deltaX:25.4,deltaY:25.4,dashes:[1.524,-23.876],sourceLine:250},{angle:120.25643716,originX:12.446,originY:3.302,deltaX:-204.77318477297,deltaY:1.8283320086,dashes:[3.5286696,-349.339407732],sourceLine:251},{angle:48.0127875,originX:10.668,originY:6.35,deltaX:305.85067529778,deltaY:1.88796713138,dashes:[6.8344288,-334.88762199565],sourceLine:252},{angle:0,originX:15.24,originY:11.43,deltaX:25.4,deltaY:25.4,dashes:[6.604,-18.796],sourceLine:253},{angle:325.3048465,originX:21.844,originY:11.43,deltaX:310.04235091354,deltaY:-1.6064370526,dashes:[4.0160956,-397.5931672414],sourceLine:254},{angle:254.0546041,originX:25.146,originY:9.144,deltaX:104.6687497289,deltaY:3.48895832444,dashes:[3.6982908,-181.21650038772],sourceLine:255},{angle:207.64597536,originX:24.13,originY:5.588,deltaX:545.36007557253,deltaY:1.07143433066,dashes:[6.021451,-596.12464422938],sourceLine:256},{angle:175.42607874,originX:18.796,originY:2.794,deltaX:331.1739336186,deltaY:1.01276432357,dashes:[6.3702946,-630.6584645624],sourceLine:257}]},{name:"HEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-6.35],sourceLine:259},{angle:120,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-6.35],sourceLine:260},{angle:60,originX:3.175,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-6.35],sourceLine:261}]},{name:"HONEY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:4.7625,deltaY:2.749630645,dashes:[3.175,-6.35],sourceLine:263},{angle:120,originX:0,originY:0,deltaX:4.7625,deltaY:2.749630645,dashes:[3.175,-6.35],sourceLine:264},{angle:60,originX:0,originY:0,deltaX:4.7625,deltaY:2.749630645,dashes:[-6.35,3.175],sourceLine:265}]},{name:"HOUND",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:6.35,deltaY:1.5875,dashes:[25.4,-12.7],sourceLine:267},{angle:90,originX:0,originY:0,deltaX:-6.35,deltaY:1.5875,dashes:[25.4,-12.7],sourceLine:268}]},{name:"INSUL",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:9.525,dashes:[],sourceLine:270},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:9.525,dashes:[3.175,-3.175],sourceLine:271},{angle:0,originX:0,originY:6.35,deltaX:0,deltaY:9.525,dashes:[3.175,-3.175],sourceLine:272}]},{name:"ACAD_ISO02W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3],sourceLine:285}]},{name:"ACAD_ISO03W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-18],sourceLine:287}]},{name:"ACAD_ISO04W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3],sourceLine:289}]},{name:"ACAD_ISO05W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-3],sourceLine:291}]},{name:"ACAD_ISO06W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-6.5],sourceLine:293},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-34,.5,-3],sourceLine:294}]},{name:"ACAD_ISO07W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[.5,-3],sourceLine:296}]},{name:"ACAD_ISO08W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3],sourceLine:298}]},{name:"ACAD_ISO09W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3,6,-3],sourceLine:300}]},{name:"ACAD_ISO10W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3],sourceLine:302}]},{name:"ACAD_ISO11W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-3],sourceLine:304}]},{name:"ACAD_ISO12W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-3],sourceLine:306}]},{name:"ACAD_ISO13W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-6.5],sourceLine:308},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3],sourceLine:309}]},{name:"ACAD_ISO14W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-6.5],sourceLine:311},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-22,.5,-3],sourceLine:312}]},{name:"ACAD_ISO15W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-10],sourceLine:314},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3,.5,-3],sourceLine:315}]},{name:"JIS_LC_20",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:322},{angle:45,originX:.4,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:323}]},{name:"JIS_LC_20A",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:325},{angle:45,originX:1,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:326}]},{name:"JIS_LC_8",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:328},{angle:45,originX:.4,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:329}]},{name:"JIS_LC_8A",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:331},{angle:45,originX:1,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:332}]},{name:"JIS_RC_10",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:10,dashes:[],sourceLine:334},{angle:45,originX:.725,originY:0,deltaX:0,deltaY:10,dashes:[],sourceLine:335},{angle:45,originX:1.45,originY:0,deltaX:0,deltaY:10,dashes:[],sourceLine:336}]},{name:"JIS_RC_15",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:15,dashes:[],sourceLine:338},{angle:45,originX:.725,originY:0,deltaX:0,deltaY:15,dashes:[],sourceLine:339},{angle:45,originX:1.45,originY:0,deltaX:0,deltaY:15,dashes:[],sourceLine:340}]},{name:"JIS_RC_18",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:18,dashes:[],sourceLine:342},{angle:45,originX:1,originY:0,deltaX:0,deltaY:18,dashes:[],sourceLine:343},{angle:45,originX:2,originY:0,deltaX:0,deltaY:18,dashes:[],sourceLine:344}]},{name:"JIS_RC_30",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:30,dashes:[],sourceLine:346},{angle:45,originX:1,originY:0,deltaX:0,deltaY:30,dashes:[],sourceLine:347},{angle:45,originX:2,originY:0,deltaX:0,deltaY:30,dashes:[],sourceLine:348}]},{name:"JIS_STN_1E",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[],sourceLine:350},{angle:45,originX:.705,originY:0,deltaX:0,deltaY:1,dashes:[1,-.5],sourceLine:351}]},{name:"JIS_STN_2.5",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:2.5,dashes:[],sourceLine:353},{angle:45,originX:1.765,originY:0,deltaX:0,deltaY:2.5,dashes:[1.2,-.5],sourceLine:354}]},{name:"JIS_WOOD",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.70710678,dashes:[],sourceLine:356}]},{name:"LINE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:359}]},{name:"MUDST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:12.7,deltaY:6.35,dashes:[6.35,-6.35,0,-6.35,0,-6.35],sourceLine:361}]},{name:"NET",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:363},{angle:90,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:364}]},{name:"NET3",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:366},{angle:60,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:367},{angle:120,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:368}]},{name:"PLAST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:370},{angle:0,originX:0,originY:.79375,deltaX:0,deltaY:6.35,dashes:[],sourceLine:371},{angle:0,originX:0,originY:1.5875,deltaX:0,deltaY:6.35,dashes:[],sourceLine:372}]},{name:"PLASTI",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:374},{angle:0,originX:0,originY:.79375,deltaX:0,deltaY:6.35,dashes:[],sourceLine:375},{angle:0,originX:0,originY:1.5875,deltaX:0,deltaY:6.35,dashes:[],sourceLine:376},{angle:0,originX:0,originY:3.96875,deltaX:0,deltaY:6.35,dashes:[],sourceLine:377}]},{name:"SACNCR",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:2.38125,dashes:[],sourceLine:379},{angle:45,originX:1.6838,originY:0,deltaX:0,deltaY:2.38125,dashes:[0,-2.38125],sourceLine:380}]},{name:"SQUARE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:382},{angle:90,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:383}]},{name:"STARS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-3.175],sourceLine:385},{angle:60,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-3.175],sourceLine:386},{angle:120,originX:1.5875,originY:2.7496306704,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-3.175],sourceLine:387}]},{name:"STEEL",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:389},{angle:45,originX:0,originY:1.5875,deltaX:0,deltaY:3.175,dashes:[],sourceLine:390}]},{name:"SWAMP",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:12.7,deltaY:21.9970452362,dashes:[3.175,-22.225],sourceLine:392},{angle:90,originX:1.5875,originY:0,deltaX:21.9970452362,deltaY:12.7,dashes:[1.5875,-42.4065904724],sourceLine:393},{angle:90,originX:1.984375,originY:0,deltaX:21.9970452362,deltaY:12.7,dashes:[1.27,-42.7240904724],sourceLine:394},{angle:90,originX:1.190625,originY:0,deltaX:21.9970452362,deltaY:12.7,dashes:[1.27,-42.7240904724],sourceLine:395},{angle:60,originX:2.38125,originY:0,deltaX:12.7,deltaY:21.9970452362,dashes:[1.016,-24.384],sourceLine:396},{angle:120,originX:.79375,originY:0,deltaX:12.7,deltaY:21.9970452362,dashes:[1.016,-24.384],sourceLine:397}]},{name:"TRANS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:399},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:6.35,dashes:[3.175,-3.175],sourceLine:400}]},{name:"TRIANG",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:4.7625,deltaY:8.2488919604,dashes:[4.7625,-4.7625],sourceLine:402},{angle:120,originX:0,originY:0,deltaX:4.7625,deltaY:8.2488919604,dashes:[4.7625,-4.7625],sourceLine:403},{angle:0,originX:-2.38125,originY:4.1244459802,deltaX:4.7625,deltaY:8.2488919604,dashes:[4.7625,-4.7625],sourceLine:404}]},{name:"ZIGZAG",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:3.175,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:406},{angle:90,originX:3.175,originY:0,deltaX:3.175,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:407}]}],issues:[]};var vi=(n=>(n[n.UserDefined=0]="UserDefined",n[n.Predefined=1]="Predefined",n[n.Custom=2]="Custom",n))(vi||{}),uh=(n=>(n[n.Normal=0]="Normal",n[n.Outer=1]="Outer",n[n.Ignore=2]="Ignore",n))(uh||{}),dh=(n=>(n[n.HatchObject=0]="HatchObject",n[n.GradientObject=1]="GradientObject",n))(dh||{}),gh=(n=>(n[n.PreDefinedGradient=0]="PreDefinedGradient",n[n.UserDefinedGradient=1]="UserDefinedGradient",n))(gh||{});const fa=class fa extends H{constructor(){super(),this._gradientAngle=0,this._elevation=0,this._geo=new Vt,this._isSolidFill=!1,this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1,this._patternName="",this._patternNameSet=!1,this._patternType=1,this._patternAngle=0,this._patternAngleSet=!1,this._patternScale=1,this._patternScaleSet=!1,this._associative=!1,this._associativeSet=!1,this._backgroundColor=void 0,this._backgroundColorSet=!1,this._patternDouble=!1,this._patternDoubleSet=!1,this._hatchStyle=0,this._hatchStyleSet=!1,this._hatchObjectType=0,this._gradientAngle=0,this._gradientShift=0,this._shadeTintValue=0,this._gradientStartColor=void 0,this._gradientEndColor=void 0,this._pixelSize=void 0,this._gradientType=0,this._gradientName="",this._gradientOneColorMode=!1}get dxfTypeName(){return"HATCH"}get isGradient(){return this._hatchObjectType===1}get isHatch(){return this._hatchObjectType===0}get isSolidFill(){return this._isSolidFill||this.getEffectivePatternName().trim().toUpperCase()===Ce}set isSolidFill(t){this._isSolidFill=t}get color(){if(this.hasExplicitColor())return this.getEntityColor();const t=this.database,e=gt.instance().getVar(I.HPCOLOR,t);return e instanceof X&&e.colorMethod!==exports.AcCmColorMethod.None?e.clone():t.cecolor.clone()}set color(t){this.setEntityColor(t)}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t??"",this._isSolidFill=this._patternName.trim().toUpperCase()===Ce,this._patternNameSet=!0,this.updatePredefinedPatternDefinitionLines()}get patternType(){return this._patternType}set patternType(t){this._patternType=t,t!==1&&this._definitionLinesAutoGenerated&&(this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1),this.updatePredefinedPatternDefinitionLines()}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t,this._patternAngleSet=!0}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t,this._patternScaleSet=!0,this.updatePredefinedPatternDefinitionLines()}get associative(){return this._associative}set associative(t){this._associative=!!t,this._associativeSet=!0}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){this._backgroundColor=t==null?void 0:t.clone(),this._backgroundColorSet=!0}get patternDouble(){return this._patternDouble}set patternDouble(t){this._patternDouble=!!t,this._patternDoubleSet=!0}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t,this._hatchStyleSet=!0}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get hatchObjectType(){return this._hatchObjectType}set hatchObjectType(t){this._hatchObjectType=t}get gradientAngle(){return this._gradientAngle}set gradientAngle(t){this._gradientAngle=t}get gradientShift(){return this._gradientShift}set gradientShift(t){this._gradientShift=t}get gradientType(){return this._gradientType}set gradientType(t){this._gradientType=t}get gradientName(){return this.isGradient&&this._gradientName.trim()===""?il:this._gradientName}set gradientName(t){this._gradientName=t??""}get gradientOneColorMode(){return this._gradientOneColorMode}set gradientOneColorMode(t){this._gradientOneColorMode=t}get shadeTintValue(){return this._shadeTintValue}set shadeTintValue(t){this._shadeTintValue=t}get gradientStartColor(){return this._gradientStartColor}set gradientStartColor(t){this._gradientStartColor=t==null||!Number.isFinite(t)?void 0:t&16777215}get gradientEndColor(){return this._gradientEndColor}set gradientEndColor(t){this._gradientEndColor=t==null||!Number.isFinite(t)?void 0:t&16777215}get pixelSize(){return this._pixelSize}set pixelSize(t){this._pixelSize=t}applyPatternDefaultsFromSysVars(t){const e=gt.instance();if(!this.hasExplicitLayer()){const i=e.getVar(I.HPLAYER,t);this.shouldUseSysVarOverride(i)&&(this.layer=i)}if(!this.hasExplicitTransparency()){const i=this.parseHpTransparency(e.getVar(I.HPTRANSPARENCY,t));i&&(this.transparency=i)}if(this._backgroundColorSet||(this._backgroundColor=this.parseHpBackgroundColor(e.getVar(I.HPBACKGROUNDCOLOR,t)),this._backgroundColorSet=!0),!this._patternNameSet){const i=e.getVar(I.HPNAME,t);this._patternName=typeof i=="string"?i:"",this._patternNameSet=!0}if(!this._patternAngleSet){const i=e.getVar(I.HPANG,t);this._patternAngle=typeof i=="number"&&Number.isFinite(i)?i:0,this._patternAngleSet=!0}if(this._patternScaleSet||(this._patternScale=this.normalizePatternScale(e.getVar(I.HPSCALE,t)),this._patternScaleSet=!0),!this._associativeSet){const i=e.getVar(I.HPASSOC,t);this._associative=typeof i=="number"?i!==0:!1,this._associativeSet=!0}if(this._hatchStyleSet||(this._hatchStyle=this.normalizeHatchStyle(e.getVar(I.HPISLANDDETECTION,t)),this._hatchStyleSet=!0),!this._patternDoubleSet){const i=e.getVar(I.HPDOUBLE,t);this._patternDouble=typeof i=="number"?i!==0:!1,this._patternDoubleSet=!0}this.updatePredefinedPatternDefinitionLines()}getEffectivePatternName(){if(this._patternNameSet)return this._patternName;const t=this.database,e=gt.instance().getVar(I.HPNAME,t);return typeof e=="string"?e:this._patternName}shouldResolveColorFromCecolor(){return!1}getEffectivePatternAngle(){if(this._patternAngleSet)return this._patternAngle;const t=this.database,e=gt.instance().getVar(I.HPANG,t);return typeof e=="number"&&Number.isFinite(e)?e:this._patternAngle}getRenderablePatternAngle(){return!this._definitionLinesAutoGenerated&&this._definitionLines.length>0?0:this.getEffectivePatternAngle()}getEffectivePatternScale(){if(this._patternScaleSet)return this._patternScale;const t=this.database;return this.normalizePatternScale(gt.instance().getVar(I.HPSCALE,t))}getEffectiveAssociative(){if(this._associativeSet)return this._associative;const t=this.database,e=gt.instance().getVar(I.HPASSOC,t);return typeof e=="number"?e!==0:this._associative}normalizePatternScale(t){return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1}normalizeHatchStyle(t){return typeof t!="number"||!Number.isFinite(t)?1:t===0?0:t===2?2:1}shouldUseSysVarOverride(t){if(typeof t!="string")return!1;const e=t.trim().toLowerCase();return e!==""&&e!=="."&&e!=="use current"}parseHpBackgroundColor(t){if(t instanceof X)return t.colorMethod===exports.AcCmColorMethod.None?void 0:t.clone();if(typeof t!="string")return;const e=t.trim().toLowerCase();if(!(!e||e==="."||e==="none"))return X.fromString(t)}parseHpTransparency(t){if(t instanceof ot)return t.clone();if(!this.shouldUseSysVarOverride(t))return;const e=t.trim();if(/^bylayer$/i.test(e)||/^byblock$/i.test(e))return ot.fromString(e);const i=Number(e);if(Number.isInteger(i)&&i>=0&&i<=90){const r=new ot;return r.percentage=i,r}}updatePredefinedPatternDefinitionLines(t=this.getEffectivePatternName(),e=this.getEffectivePatternScale()){if(this.patternType!==1||!(this._definitionLinesAutoGenerated||this._definitionLines.length===0))return;const r=t.trim().toUpperCase();if(!r||r===Ce){this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1;return}const s=this.normalizePatternScale(e);if(this._definitionLinesAutoGenerated&&this._definitionLinesPatternName===r&&this._definitionLinesPatternScale===s)return;const a=hh.patterns.find(o=>o.name.trim().toUpperCase()===r);if(!a){this._definitionLinesAutoGenerated&&(this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1);return}this._definitionLines=a.lines.map(o=>({angle:o.angle*Math.PI/180,base:{x:o.originX*s,y:o.originY*s},offset:{x:o.deltaX*s,y:o.deltaY*s},dashLengths:o.dashes.map(c=>c*s)})),this._definitionLinesAutoGenerated=!0,this._definitionLinesPatternName=r,this._definitionLinesPatternScale=s}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=(s,a)=>{if(s.index>=0&&a%2===0){const o=new Vt;o.add(t[s.index]),s.children.forEach(c=>{c.index>=0&&o.add(t[c.index])}),i.push(o)}s.children.forEach(o=>r(o,a+1))};return e.children.forEach(s=>r(s,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 area(){return this.getCalculatedAreaValue()}get geometricExtents(){const t=this.buildAreasFromLoops();if(t.length===0)return new Y;const e=new Y;return t.forEach(i=>{const r=i.box;e.union(new Y({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:vi[0],value:0},{label:vi[1],value:1},{label:vi[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}}},{name:"associative",type:"boolean",editable:!0,accessor:{get:()=>this.associative,set:t=>{this.associative=t}}},{name:"backgroundColor",type:"color",editable:!0,accessor:{get:()=>this.backgroundColor,set:t=>{this.backgroundColor=t}}},{name:"patternDouble",type:"boolean",editable:!0,accessor:{get:()=>this.patternDouble,set:t=>{this.patternDouble=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.area}}]}]}}subGetGripPoints(){return this.associative?[]:this.collectBoundaryGripPoints()}subMoveGripPointsAt(t,e){return this.associative?this:(ht(t,i=>{this.moveBoundaryGripPointAt(i,e)}),this)}collectBoundaryGripPoints(){const t=new Array,e=this._elevation,i=new Set,r=s=>{const a=`${s.x},${s.y},${s.z??0}`;i.has(a)||(i.add(a),t.push(new y(s.x,s.y,s.z??e)))};return this._geo.loops.forEach(s=>{if(s instanceof q){const a=s.numberOfVertices;for(let o=0;o<a;o++){const c=s.getPointAt(o);r({x:c.x,y:c.y,z:e})}return}s.curves.forEach(a=>{if(a instanceof zt)r({x:a.startPoint.x,y:a.startPoint.y,z:e}),r({x:a.endPoint.x,y:a.endPoint.y,z:e});else if(a instanceof vt)r({x:a.startPoint.x,y:a.startPoint.y,z:e}),r({x:a.endPoint.x,y:a.endPoint.y,z:e}),r({x:a.midPoint.x,y:a.midPoint.y,z:e});else if(a instanceof me){r({x:a.startPoint.x,y:a.startPoint.y,z:e}),r({x:a.endPoint.x,y:a.endPoint.y,z:e});const o=a.getPoint(.5);r({x:o.x,y:o.y,z:e})}})}),t}moveBoundaryGripPointAt(t,e){let i=0;const r=this._elevation,s=new Set,a=(o,c)=>{const l=`${o.x},${o.y},${o.z??0}`;s.has(l)||(s.add(l),i===t&&c(),i++)};this._geo.loops.forEach(o=>{if(o instanceof q){const c=o.numberOfVertices;for(let l=0;l<c;l++){const h=o.vertices[l];h&&a({x:h.x,y:h.y,z:r},()=>{xi(o.vertices,l,e)})}return}o.curves.forEach(c=>{if(c instanceof zt)a({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>{c.startPoint.x+=e.x,c.startPoint.y+=e.y}),a({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>{c.endPoint.x+=e.x,c.endPoint.y+=e.y});else if(c instanceof vt)a({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"start",e)),a({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"end",e)),a({x:c.midPoint.x,y:c.midPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"mid",e));else if(c instanceof me){a({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"start",e)),a({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"end",e));const l=c.getPoint(.5);a({x:l.x,y:l.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"mid",e))}})})}moveCircArc2dGripPoint(t,e,i){const r=t.center;switch(e){case"start":{const s=t.startPoint;t.startAngle=Math.atan2(s.y+i.y-r.y,s.x+i.x-r.x);break}case"end":{const s=t.endPoint;t.endAngle=Math.atan2(s.y+i.y-r.y,s.x+i.x-r.x);break}case"mid":{const s=t.midPoint,a=new vt(t.startPoint,{x:s.x+i.x,y:s.y+i.y},t.endPoint);t.center=a.center,t.radius=a.radius,t.startAngle=a.startAngle,t.endAngle=a.endAngle,t.clockwise=a.clockwise;break}}}moveEllipseArc2dGripPoint(t,e,i){const r=t.center;switch(e){case"start":{const s=t.startPoint;t.startAngle=Math.atan2(s.y+i.y-r.y,s.x+i.x-r.x);break}case"end":{const s=t.endPoint;t.endAngle=Math.atan2(s.y+i.y-r.y,s.x+i.x-r.x);break}case"mid":{const s=t.getPoint(.5),a=s.x+i.x-t.center.x,o=s.y+i.y-t.center.y,c=Math.hypot(s.x-t.center.x,s.y-t.center.y),l=Math.hypot(a,o);if(c>0&&l>0){const h=l/c;t.majorAxisRadius*=h,t.minorAxisRadius*=h}break}}}subGetOsnapPoints(t,e,i,r){const s=this._elevation,a=[];if(this._geo.loops.forEach(o=>{var c;if(o instanceof q){const l=o,h=l.numberOfVertices;if(h===0)return;switch(t){case k.EndPoint:for(let u=0;u<h;u++){const d=l.getPointAt(u);r.push(new y(d.x,d.y,s))}break;case k.MidPoint:case k.Nearest:case k.Perpendicular:case k.Tangent:{const u=o.closed?h:h-1;for(let d=0;d<u;d++){const g=[];Ci(l.getPointAt(d),l.getPointAt((d+1)%h),(c=l.vertices[d])==null?void 0:c.bulge,s,t,e,g),t===k.MidPoint?r.push(...g):a.push(...g)}break}}return}o.curves.forEach(l=>{if(l instanceof zt){const h=[];Ci(l.startPoint,l.endPoint,void 0,s,t,e,h),t===k.MidPoint?r.push(...h):t===k.Nearest||t===k.Perpendicular||t===k.Tangent?a.push(...h):r.push(...h)}else if(l instanceof vt)switch(t){case k.EndPoint:r.push(new y(l.startPoint.x,l.startPoint.y,s),new y(l.endPoint.x,l.endPoint.y,s));break;case k.MidPoint:r.push(new y(l.midPoint.x,l.midPoint.y,s));break;case k.Nearest:{const h=l.nearestPoint({x:e.x,y:e.y});a.push(new y(h.x,h.y,s));break}case k.Perpendicular:{l.perpendicularPoints({x:e.x,y:e.y}).forEach(u=>a.push(new y(u.x,u.y,s)));break}case k.Tangent:{l.tangentPoints({x:e.x,y:e.y}).forEach(u=>a.push(new y(u.x,u.y,s)));break}}else if(l instanceof me)switch(t){case k.EndPoint:r.push(new y(l.startPoint.x,l.startPoint.y,s),new y(l.endPoint.x,l.endPoint.y,s));break;case k.MidPoint:{const h=l.getPoint(.5);r.push(new y(h.x,h.y,s));break}case k.Nearest:{const h=l.nearestPoint({x:e.x,y:e.y});a.push(new y(h.x,h.y,s));break}case k.Perpendicular:{l.perpendicularPoints({x:e.x,y:e.y}).forEach(u=>a.push(new y(u.x,u.y,s)));break}case k.Tangent:{l.tangentPoints({x:e.x,y:e.y}).forEach(u=>a.push(new y(u.x,u.y,s)));break}}})}),(t===k.Nearest||t===k.Perpendicular||t===k.Tangent)&&a.length>0){const o=Ft(e,a);r.length=0,o&&r.push(o)}}subWorldDraw(t){var s;this.updatePredefinedPatternDefinitionLines();const e=t.subEntityTraits;e.fillType={solidFill:this.isSolidFill,patternAngle:this.getRenderablePatternAngle(),definitionLines:this.definitionLines,backgroundColor:(s=this.backgroundColor)==null?void 0:s.clone(),gradient:this.isGradient?{name:this.gradientName,angle:this.gradientAngle,shift:this.gradientShift,oneColorMode:this.gradientOneColorMode,shadeTintValue:this.shadeTintValue,startColor:this.gradientStartColor,endColor:this.gradientEndColor}:void 0},e.drawOrder=-1;const 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(a=>t.area(a));return t.group(r)}transformBy(t){const e=t.elements,i=new Ui(e[0],e[4],e[12],e[1],e[5],e[13],0,0,1);this._geo.transform(i),this._elevation=new y(0,0,this._elevation).applyMatrix4(t).z;const r=new y(1,0,0).applyMatrix4(t),s=new y().applyMatrix4(t),a=new y(r).sub(s);if(a.length()>0){const o=Math.atan2(a.y,a.x);this._patternAngle=this.getEffectivePatternAngle()+o,this._gradientAngle+=o,this._patternScale=this.getEffectivePatternScale()*a.length(),this._patternAngleSet=!0,this._patternScaleSet=!0,this.updatePredefinedPatternDefinitionLines()}return this}dxfOutFields(t){super.dxfOutFields(t);const e=this._geo.loops,i=this.getEffectivePatternName(),r=this.getEffectivePatternAngle(),s=this.getEffectivePatternScale();if(this.updatePredefinedPatternDefinitionLines(i,s),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,i||(this.isSolidFill?Ce:el)),t.writeInt16(70,this.isSolidFill?1:0),t.writeInt16(71,this.getEffectiveAssociative()?1:0),t.writeInt16(91,e.length),e.forEach((a,o)=>{const c=o===0;if(a instanceof q){const l=a.vertices,h=l.some(d=>(d.bulge??0)!==0);t.writeInt16(92,2),t.writeInt16(72,h?1:0),t.writeInt16(73,a.closed?1:0),t.writeInt16(93,l.length);for(const d of l)t.writePoint2d(10,d),h&&t.writeDouble(42,d.bulge??0);t.writeInt16(97,0);return}if(a instanceof bi){const l=c?1:0;t.writeInt16(92,l),t.writeInt16(93,a.numberOfEdges);for(const h of a.curves){if(h instanceof zt){t.writeInt16(72,1),t.writePoint2d(10,h.startPoint),t.writePoint2d(11,h.endPoint);continue}if(h instanceof vt){t.writeInt16(72,2),t.writePoint2d(10,h.center),t.writeDouble(40,h.radius),t.writeAngle(50,h.startAngle),t.writeAngle(51,h.endAngle),t.writeInt16(73,h.clockwise?0:1);continue}if(h instanceof me){t.writeInt16(72,3),t.writePoint2d(10,h.center);const u=new L(h.majorAxisRadius*Math.cos(h.rotation),h.majorAxisRadius*Math.sin(h.rotation));t.writePoint2d(11,u);const d=h.majorAxisRadius===0?0:h.minorAxisRadius/h.majorAxisRadius;t.writeDouble(40,d),t.writeAngle(50,h.startAngle),t.writeAngle(51,h.endAngle),t.writeInt16(73,h.clockwise?0:1);continue}if(h instanceof jt){const u=h.knots,d=h.controlPoints,g=h.weights,p=h.fitPoints,f=g.some(m=>m!==1);t.writeInt16(72,4),t.writeInt16(94,h.degree),t.writeInt16(73,f?1:0),t.writeInt16(74,h.closed?1:0),t.writeInt16(95,u.length),t.writeInt16(96,d.length),u.forEach(m=>t.writeDouble(40,m)),d.forEach((m,b)=>{t.writePoint2d(10,m),f&&t.writeDouble(42,g[b]??1)}),t.writeInt16(97,(p==null?void 0:p.length)??0),p==null||p.forEach(m=>t.writePoint2d(11,m))}}t.writeInt16(97,0)}}),t.writeInt16(75,this.hatchStyle),t.writeInt16(76,this.patternType),t.writeAngle(52,r),t.writeDouble(41,s),t.writeInt16(77,0),t.writeInt16(78,this.definitionLines.length),this.definitionLines.forEach(a=>{t.writeAngle(53,a.angle),t.writeDouble(43,a.base.x),t.writeDouble(44,a.base.y),t.writeDouble(45,a.offset.x),t.writeDouble(46,a.offset.y),t.writeInt16(79,a.dashLengths.length),a.dashLengths.forEach(o=>t.writeDouble(49,o))}),this._pixelSize!=null&&t.writeDouble(47,this._pixelSize),this.isGradient){t.writeInt16(450,this._hatchObjectType),t.writeInt16(451,0),t.writeDouble(460,this._gradientAngle),t.writeDouble(461,this._gradientShift),t.writeInt16(452,this._gradientOneColorMode?1:0),t.writeDouble(462,this._shadeTintValue);const a=this._gradientStartColor,o=this._gradientEndColor,c=a!=null&&o!=null?2:a!=null||o!=null?1:0;t.writeInt16(453,c);const l=(h,u)=>{t.writeDouble(463,h);const d=$t.getIndexByColor(u);d!=null&&t.writeInt16(63,d),t.writeInt32(421,u)};a!=null&&l(0,a),o!=null&&l(1,o),t.writeString(470,this.gradientName)}return t.writeInt16(98,0),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbHatch"),this.definitionLines.length=0;let e=this.elevation,i=this.patternAngle*180/Math.PI,r=0,s=!1,a=!1,o=!1,c=[],l=null,h=[],u=null,d="type",g=0,p=!1,f=null,m=!1,b=0,_;const v=N=>{b===0?this.gradientStartColor=N:this.gradientEndColor=N,b++,_=void 0},x=()=>{if(_==null)return;const N=$t.getColorByIndex(_);N!=null?v(N):_=void 0},S=()=>{l&&(c.push(l),l=null)},P=()=>{if(S(),c.length===0)return;const N=new q;N.closed=o,c.forEach((M,A)=>{N.addVertexAt(A,{x:M.x,y:M.y,bulge:M.bulge??0})}),this.add(N),c=[]},E=()=>{if(h.length===0)return;const N=[];for(const A of h)if(A.kind==="line")N.push(new zt({x:A.sx,y:A.sy},{x:A.ex,y:A.ey}));else if(A.kind==="arc")N.push(new vt({x:A.cx,y:A.cy},A.radius,A.startDeg*Math.PI/180,A.endDeg*Math.PI/180,!A.isCcw));else if(A.kind==="ellipse"){const V=Math.hypot(A.mx,A.my),$=V*A.ratio;let Q=A.startDeg*Math.PI/180,et=A.endDeg*Math.PI/180;const W=Math.atan2(A.my,A.mx);A.isCcw||(Q=Math.PI*2-Q,et=Math.PI*2-et),N.push(new me({x:A.cx,y:A.cy,z:0},V,$,Q,et,!A.isCcw,W))}else{const V=jt.fromDwgSplineEdge({degree:A.degree,numberOfControlPoints:A.controlPoints.length,numberOfKnots:A.knots.length,numberOfFitData:A.fitPoints.length,knots:A.knots,controlPoints:A.controlPoints.map($=>({x:$.x,y:$.y,z:0,weight:A.rational?$.weight??1:void 0})),fitDatum:A.fitPoints.map($=>({x:$.x,y:$.y,z:0})),startTangent:null,endTangent:null});V&&N.push(V)}const M=bi.buildFromEdges(N);M.length===0&&N.length>0?this.add(new bi(N)):M.forEach(A=>this.add(A)),h=[],u=null},O=()=>{s?P():E()},T=()=>{u&&(h.push(u),u=null)},R=()=>{T(),O(),g=Math.max(0,g-1),g===0&&(m=!0)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const N=t.readItem();if(!N)break;const M=Number(N.code),A=Number(N.value);if(p||m){switch(M){case 75:this.hatchStyle=A,m=!0;break;case 76:this.patternType=A;break;case 52:i=A;break;case 41:this.patternScale=A;break;case 77:break;case 78:p=!0;break;case 53:f&&this.definitionLines.push(f),f={angle:A*Math.PI/180,base:{x:0,y:0},offset:{x:0,y:0},dashLengths:[]};break;case 43:f&&(f.base.x=A);break;case 44:f&&(f.base.y=A);break;case 45:f&&(f.offset.x=A);break;case 46:f&&(f.offset.y=A);break;case 79:break;case 49:f&&f.dashLengths.push(A);break;case 47:this.pixelSize=A;break;case 99:break;case 450:this.hatchObjectType=A,this.gradientStartColor=void 0,this.gradientEndColor=void 0,b=0,_=void 0;break;case 451:break;case 452:this.gradientOneColorMode=A!==0;break;case 453:break;case 460:this.gradientAngle=A;break;case 461:this.gradientShift=A;break;case 462:this.shadeTintValue=A;break;case 463:x();break;case 63:_=A;break;case 421:v(A);break;case 470:x(),this.gradientName=String(N.value);break}continue}switch(M){case 10:s||u&&u.kind!=="line"&&u.kind!=="arc"&&u.kind!=="ellipse"&&u.kind,g>0&&s?(S(),l={x:A,y:0}):(u==null?void 0:u.kind)==="line"&&d==="type"?u.sx=A:(u==null?void 0:u.kind)==="arc"||(u==null?void 0:u.kind)==="ellipse"?u.cx=A:(u==null?void 0:u.kind)==="spline"&&u.controlPoints.push({x:A,y:0});break;case 20:g>0&&s&&l?l.y=A:(u==null?void 0:u.kind)==="line"&&d==="type"?u.sy=A:(u==null?void 0:u.kind)==="arc"||(u==null?void 0:u.kind)==="ellipse"?u.cy=A:(u==null?void 0:u.kind)==="spline"&&u.controlPoints.length>0&&(u.controlPoints[u.controlPoints.length-1].y=A);break;case 30:g<=0&&!m&&(e=A);break;case 2:this.patternName=String(N.value);break;case 70:this.isSolidFill=A!==0;break;case 71:this.associative=A!==0;break;case 91:g=A;break;case 92:g>0&&(c.length>0||h.length>0||u)&&(T(),O()),r=A,s=(r&2)!==0,a=!1,o=!1,c=[],h=[],u=null,d="type";break;case 72:s?a=A!==0:(T(),A===1?(u={kind:"line",sx:0,sy:0,ex:0,ey:0},d="type"):A===2?u={kind:"arc",cx:0,cy:0,radius:0,startDeg:0,endDeg:0,isCcw:!0}:A===3?u={kind:"ellipse",cx:0,cy:0,mx:0,my:0,ratio:1,startDeg:0,endDeg:0,isCcw:!0}:A===4?u={kind:"spline",degree:3,rational:!1,closed:!1,knots:[],controlPoints:[],fitPoints:[],expectedKnots:0,expectedControls:0,expectedFits:0,fitCountSeen:!1}:u=null);break;case 73:s?o=A!==0:(u==null?void 0:u.kind)==="arc"||(u==null?void 0:u.kind)==="ellipse"?u.isCcw=A!==0:(u==null?void 0:u.kind)==="spline"&&(u.rational=A!==0);break;case 74:(u==null?void 0:u.kind)==="spline"&&(u.closed=A!==0);break;case 93:break;case 42:s&&a&&l?l.bulge=A:(u==null?void 0:u.kind)==="spline"&&u.rational&&u.controlPoints.length>0&&(u.controlPoints[u.controlPoints.length-1].weight=A);break;case 11:(u==null?void 0:u.kind)==="line"?(u.ex=A,d="line-end"):(u==null?void 0:u.kind)==="ellipse"?u.mx=A:(u==null?void 0:u.kind)==="spline"&&u.fitPoints.push({x:A,y:0});break;case 21:(u==null?void 0:u.kind)==="line"?u.ey=A:(u==null?void 0:u.kind)==="ellipse"?u.my=A:(u==null?void 0:u.kind)==="spline"&&u.fitPoints.length>0&&(u.fitPoints[u.fitPoints.length-1].y=A);break;case 40:(u==null?void 0:u.kind)==="arc"?u.radius=A:(u==null?void 0:u.kind)==="ellipse"?u.ratio=A:(u==null?void 0:u.kind)==="spline"&&u.knots.push(A);break;case 50:((u==null?void 0:u.kind)==="arc"||(u==null?void 0:u.kind)==="ellipse")&&(u.startDeg=A);break;case 51:((u==null?void 0:u.kind)==="arc"||(u==null?void 0:u.kind)==="ellipse")&&(u.endDeg=A);break;case 94:(u==null?void 0:u.kind)==="spline"&&(u.degree=A);break;case 95:(u==null?void 0:u.kind)==="spline"&&(u.expectedKnots=A);break;case 96:(u==null?void 0:u.kind)==="spline"&&(u.expectedControls=A);break;case 97:if((u==null?void 0:u.kind)==="spline"&&!u.fitCountSeen&&(u.controlPoints.length>0||u.knots.length>0)){u.expectedFits=A,u.fitCountSeen=!0;break}R();break;case 75:T(),O(),g=0,m=!0,this.hatchStyle=A;break}}return u&&(h.push(u),u=null),O(),f&&this.definitionLines.push(f),x(),this.elevation=e,this.patternAngle=i*Math.PI/180,this}};fa.typeName="Hatch";let Bi=fa;class fh{constructor(t){this.db=t}createDefaultLayer(){const t=new X;return t.colorIndex=7,this.db.tables.layerTable.add(new Zi({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new ve({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new ve({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new ve({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new xr({name:Z,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new Tt({name:Z,dimtxsty:Z}))}createDefaultLayout(){const t=new qi;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 Bi;e.patternName=Ce;const i=new bi;i.add(new zt({x:0,y:0},{x:-1,y:.125})),i.add(new zt({x:-1,y:.125},{x:-1,y:-.125})),i.add(new zt({x:-1,y:-.125},{x:0,y:0})),e.add(i);const r=new tt;r.name="_CAXARROW",r.appendEntity(e),this.db.tables.blockTable.add(r)}}}const ks=Math.PI/200;class ph{constructor(t){this.database=t}formatLength(t,e){const i=this.createContext(e);return Be(t,i)}formatPoint2d(t,e){const i=this.createContext(e);return`${Be(t.x,i)}, ${Be(t.y,i)}`}formatPoint3d(t,e){const i=this.createContext(e);return`${Be(t.x,i)}, ${Be(t.y,i)}, ${Be(t.z,i)}`}formatAngle(t,e){const i=this.createContext(e),s=(e==null?void 0:e.applyAngbaseAngdir)??!0?Np(t,this.database.angbase,this.database.angdir):C.normalizeAngle(t);return Op(s,i)}createContext(t){return{lunits:this.database.lunits,luprec:Fi(this.database.luprec),insunits:this.database.insunits,unitmode:this.database.unitmode,measurement:this.database.measurement,aunits:this.database.aunits,auprec:Fi(this.database.auprec),showUnits:(t==null?void 0:t.showUnits)??!1,showApproximate:(t==null?void 0:t.showApproximate)??!1}}}function Be(n,t){let e;switch(t.lunits){case rt.Scientific:e=qr(Vp(n,t.luprec),t);break;case rt.Engineering:e=Gp(n,t);break;case rt.Architectural:e=Up(n,t);break;case rt.Fractional:e=qr(Hp(n,t),t);break;case rt.WindowsDesktop:case rt.Decimal:default:e=qr(ui(n,t.luprec),t)}return mh(e,Rp(n,t),t)}function Op(n,t){let e;switch(t.aunits){case St.DegreesMinutesSeconds:e=_h(n,t);break;case St.Gradians:e=qp(n,t);break;case St.Radians:e=$p(n,t);break;case St.SurveyorsUnits:e=Kp(n,t);break;case St.DecimalDegrees:default:e=Wp(n,t)}return mh(e,Bp(n,t),t)}function Np(n,t,e){let i=n-t;return e===1&&(i=-i),C.normalizeAngle(i)}function ia(n){const t=n.showUnits?'"':"";return n.unitmode===1?{feetInchSeparator:"",fractionSeparator:"-",inchSuffix:t}:{feetInchSeparator:"-",fractionSeparator:" ",inchSuffix:t}}function Fi(n,t=0,e=8){return Number.isFinite(n)?Math.max(t,Math.min(e,Math.round(n))):t}function hi(n){return Object.is(n,-0)?0:n}function mh(n,t,e){return!e.showApproximate||!t?n:`~ ${n}`}function Rp(n,t){if(!Number.isFinite(n))return!1;const e=Dp(n,t);return na(n,e)}function Bp(n,t){if(!Number.isFinite(n))return!1;if(t.aunits===St.SurveyorsUnits)return Fp(n,t.auprec);const e=Yp(n,t);return na(n,e)}function Fp(n,t){const i=((90-C.radToDeg(n))%360+360)%360,r=xh(i),s=Math.min(Math.abs(i-r.base),Math.abs(r.base+90-i)),a=C.degToRad(s),o=yh(a,t);return na(a,o)}function Dp(n,t){const e=hi(n);switch(t.lunits){case rt.Scientific:return Xp(e,t.luprec);case rt.Engineering:case rt.Architectural:case rt.Fractional:return zp(e,t);case rt.WindowsDesktop:case rt.Decimal:default:return Ze(e,t.luprec)}}function Yp(n,t){const e=hi(n);switch(t.aunits){case St.DegreesMinutesSeconds:return yh(e,t.auprec);case St.Gradians:return Ze(e/ks,t.auprec)*ks;case St.Radians:return Ze(e,t.auprec);case St.DecimalDegrees:default:return C.degToRad(Ze(C.radToDeg(e),t.auprec))}}function Ze(n,t){if(!Number.isFinite(n))return 0;const e=10**t;return Math.round(hi(n)*e)/e}function Xp(n,t){if(!Number.isFinite(n))return 0;const e=hi(n);if(e===0)return 0;const i=e.toExponential(t);return Number(i)}function zp(n,t){if(!Number.isFinite(n))return 0;const e=n<0?-1:1,i=Math.abs(n),r=Math.floor(i/12),s=i-r*12;if(t.lunits===rt.Architectural||t.lunits===rt.Fractional){const a=1<<Fi(t.luprec,0,8),o=jp(s,a);return e*(r*12+o)}return e*(r*12+Ze(s,t.luprec))}function jp(n,t){const e=Math.floor(n),i=n-e,r=Math.round(i*t);return r>=t?e+1:e+r/t}function yh(n,t){const e=C.radToDeg(n),i=e<0?-1:1,r=Math.abs(e),s=Math.floor(r),a=(r-s)*60,o=Math.floor(a),c=Ze((a-o)*60,t),l=s+o/60+c/3600;return C.degToRad(i*l)}function na(n,t){if(n===t)return!1;const e=Math.max(Math.abs(n),Math.abs(t),1);return Math.abs(n-t)>e*Number.EPSILON*8}function ui(n,t){if(!Number.isFinite(n))return"0";const e=hi(n);if(Number.isInteger(e)&&t===0)return String(e);const r=e.toFixed(t).replace(/\.?0+$/,"");return r===""||r==="-"?"0":r}function Vp(n,t){if(!Number.isFinite(n))return"0";const e=hi(n);if(e===0)return"0";const i=e.toExponential(t).match(/^(.+)e([+-])(\d+)$/i);if(!i)return"0";const[,r,s,a]=i,o=a.length<2?a.padStart(2,"0"):a;return`${r}E${s}${o}`.toUpperCase()}function Gp(n,t){if(!Number.isFinite(n))return"0";const e=ia(t),i=n<0?"-":"",r=Math.abs(n),s=Math.floor(r/12),a=r-s*12,o=ui(a,t.luprec);return s===0?`${i}${o}${e.inchSuffix}`:`${i}${s}'${e.feetInchSeparator}${o}${e.inchSuffix}`}function Up(n,t){if(!Number.isFinite(n))return"0";const e=ia(t),i=n<0?"-":"",r=Math.abs(n),s=Math.floor(r/12),a=r-s*12,o=1<<Fi(t.luprec,0,8),c=bh(a,o,e.fractionSeparator);return s===0?`${i}${c}${e.inchSuffix}`:`${i}${s}'${e.feetInchSeparator}${c}${e.inchSuffix}`}function Hp(n,t){if(!Number.isFinite(n))return"0";const e=ia(t),i=n<0?"-":"",r=Math.abs(n),s=1<<Fi(t.luprec,0,8);return`${i}${bh(r,s,e.fractionSeparator)}`}function bh(n,t,e){const i=Math.floor(n),r=n-i;let s=Math.round(r*t);if(s>=t)return String(i+1);if(s===0)return String(i);const a=t0(s,t);s/=a;const o=t/a,c=`${s}/${o}`;return i===0?c:`${i}${e}${c}`}function Wp(n,t){const e=C.radToDeg(n);return`${ui(e,t.auprec)}${t.showUnits?"°":""}`}function $p(n,t){return`${ui(n,t.auprec)}${t.showUnits?" rad":""}`}function qp(n,t){const e=n/ks;return`${ui(e,t.auprec)}${t.showUnits?"g":""}`}function _h(n,t){const e=C.radToDeg(n),i=e<0?"-":"",r=Math.abs(e),s=Math.floor(r),a=(r-s)*60,o=Math.floor(a),c=(a-o)*60,l=ui(c,t.auprec),h=t.showUnits?'"':"";return`${i}${s}d${o}'${l}${h}`}function Kp(n,t){const i=((90-C.radToDeg(n))%360+360)%360,r=xh(i),s=Math.min(Math.abs(i-r.base),Math.abs(r.base+90-i)),o=_h(C.degToRad(s),t).replace(/^-/,"");return`${r.prefix} ${o} ${r.suffix}`.trim()}function xh(n){return n<90?{prefix:"N",suffix:"E",base:0}:n<180?{prefix:"S",suffix:"E",base:90}:n<270?{prefix:"S",suffix:"W",base:180}:{prefix:"N",suffix:"W",base:270}}function qr(n,t){if(!t.showUnits||t.lunits===rt.Engineering||t.lunits===rt.Architectural)return n;const e=Zp(t.insunits,t.measurement);return e?`${n}${e}`:n}function Zp(n,t){return n===J.Undefined?t===0?'"':" mm":Vf(n)?Qp(n):Gf(n)?Jp(n):""}function Qp(n){switch(n){case J.Millimeters:return" mm";case J.Centimeters:return" cm";case J.Meters:return" m";case J.Kilometers:return" km";case J.Decimeters:return" dm";case J.Microns:return" µm";case J.Nanometers:return" nm";default:return""}}function Jp(n){switch(n){case J.Inches:case J.Microinches:case J.Mils:case J.USSurveyInch:return'"';case J.Feet:case J.USSurveyFeet:return"'";case J.Miles:case J.USSurveyMile:return" mi";case J.Yards:case J.USSurveyYard:return" yd";default:return""}}function t0(n,t){let e=Math.abs(n),i=Math.abs(t);for(;i!==0;){const r=i;i=e%i,e=r}return e||1}class Nt extends bt{constructor(t){super(),this.database=t,this.objectId=t.generateHandle(),this._recordsByName=new Map}get numEntries(){return this._recordsByName.size}setAt(t,e){const i=this.database.transactionManager;if(i.strictMode&&!i.isRecording()&&!i.isApplyingUndoRedo())throw new Error("Cannot modify dictionary entries outside an active transaction.");const r=this.getAt(t);r&&(i.isRecording()&&i.recordRemove({type:"dictionary",dictionaryId:this.objectId,key:t},r),this.database.releaseObjectHandle(r)),e.database=this.database,e.ownerId=this.objectId,this.database.commitObjectHandle(e,s=>this.hasId(s)),this._recordsByName.set(t,e),i.isRecording()&&i.recordAppend({type:"dictionary",dictionaryId:this.objectId,key:t},e),!i.isRecording()&&!i.isApplyingUndoRedo()&&this.database.notifyDictObjectSet(e,t)}remove(t){const e=this.getAt(t);return e?(this.removeStoredObject(e,t),!0):!1}removeId(t){const e=this.getIdAt(t);if(e){let i="";return this._recordsByName.forEach((r,s)=>{r===e&&(i=s)}),this.removeStoredObject(e,i),!0}return!1}removeStoredObject(t,e){const i=this.database.transactionManager;if(i.strictMode&&!i.isRecording()&&!i.isApplyingUndoRedo())throw new Error("Cannot remove dictionary entries outside an active transaction.");i.isRecording()&&i.recordRemove({type:"dictionary",dictionaryId:this.objectId,key:e},t),this._recordsByName.forEach((r,s)=>{r===t&&this._recordsByName.delete(s)}),this.database.releaseObjectHandle(t),e&&!i.isRecording()&&!i.isApplyingUndoRedo()&&this.database.notifyDictObjectErased(t,e)}removeAll(){this._recordsByName.forEach((t,e)=>{this.database.releaseObjectHandle(t),this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:e})}),this._recordsByName.clear()}has(t){return this._recordsByName.has(t.toUpperCase())}hasId(t){return this.getIdAt(t)!==void 0}getAt(t){return this._recordsByName.get(t)}getIdAt(t){const e=this.database.getObjectById(t);if(!(!e||e.getAttrWithoutException("ownerId")!==this.objectId))return e}newIterator(){return new ei(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}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbDictionary");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;if(Number(e.code)===100){t.pushBackItem(e);break}}return this}}class ee extends bt{constructor(t){super(),this.database=t,this.objectId=t.generateHandle(),this.ownerId=t.objectId,this._recordsByName=new Map,this._unnamedRecords=[]}get numEntries(){return this._recordsByName.size}get totalRecordCount(){return this._recordsByName.size+this._unnamedRecords.length}add(t){const e=this.database.transactionManager;if(e.strictMode&&!e.isRecording()&&!e.isApplyingUndoRedo())throw new Error("Cannot add symbol table records outside an active transaction.");const i=e.resolveSymbolTableName(this);t.database=this.database,t.ownerId=this.objectId,this.database.commitObjectHandle(t,s=>this.hasId(s));const r=this.normalizeName(t.name);r?this._recordsByName.set(r,t):this._unnamedRecords.push(t),e.isRecording()&&e.recordAppend({type:"symbolTable",tableName:i},t)}remove(t){const e=this.normalizeName(t),i=this._recordsByName.get(e);return i?(this.removeRecord(i),!0):!1}removeId(t){const e=this.getIdAt(t);return e?(this.removeRecord(e),!0):!1}removeRecord(t){const e=this.database.transactionManager;if(e.strictMode&&!e.isRecording()&&!e.isApplyingUndoRedo())throw new Error("Cannot remove symbol table records outside an active transaction.");if(e.isRecording()){const i=e.resolveSymbolTableName(this);e.recordRemove({type:"symbolTable",tableName:i},t)}this.removeFromMembership(t),this.database.releaseObjectHandle(t)}removeAll(){for(const t of this._recordsByName.values())this.database.releaseObjectHandle(t);for(const t of this._unnamedRecords)this.database.releaseObjectHandle(t);this._recordsByName.clear(),this._unnamedRecords.length=0}has(t){const e=this.normalizeName(t);return this._recordsByName.has(e)}hasId(t){return this.getIdAt(t)!==void 0}getAt(t){const e=this.normalizeName(t);return this._recordsByName.get(e)}getIdAt(t){const e=this.database.getObjectById(t);if(!(!e||e.getAttrWithoutException("ownerId")!==this.objectId))return e}getOwnerIdAt(t){return this.getIdAt(t)}newIterator(t=!1){return t?new ei([...this._recordsByName.values(),...this._unnamedRecords]):new ei(this._recordsByName)}normalizeName(t){return t.trim().toUpperCase()}get dxfEntryCount(){return this.numEntries}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbSymbolTable"),t.writeInt16(70,this.dxfEntryCount),this}removeFromMembership(t){const e=this.normalizeName(t.name);if(e){this._recordsByName.delete(e);return}const i=this._unnamedRecords.indexOf(t);i>=0&&this._unnamedRecords.splice(i,1)}}class wh extends ee{constructor(t){super(t)}get modelSpace(){let t=this.getAt(tt.MODEL_SPACE_NAME);return t||(t=new tt,t.name=tt.MODEL_SPACE_NAME,this.add(t)),t}getEntityById(t){const e=this.database.getObjectById(t);if(e instanceof H)return e}removeEntity(t){let e=!1;for(const i of this.database.tables.blockTable.newIterator())if(i.removeEntity(t)){e=!0;break}return e}getXrefs(){const t=[];for(const e of this.newIterator())e.isXref&&t.push(e);return t}getUnresolvedXrefs(){return this.getXrefs().filter(t=>t.isUnresolvedXref)}normalizeName(t){const e=t.trim();if(tt.isModelSapceName(e))return tt.MODEL_SPACE_NAME;if(tt.isPaperSapceName(e)){const i=tt.PAPER_SPACE_NAME_PREFIX,r=e.substring(i.length);return i+r}return super.normalizeName(e)}}const Rt=class Rt extends Error{constructor(t,e,i){super(t),this.name="AcDbOpenDatabaseError",this.code=e,this.stage=i==null?void 0:i.stage}static isWorkerOutOfMemoryMessage(t){const e=t.toLowerCase();return Rt.WORKER_OOM_PATTERNS.some(i=>e.includes(i))}static classifyWorkerErrorMessage(t){return Rt.isWorkerOutOfMemoryMessage(t)?"worker_oom":t.toLowerCase().includes("timed out")?"worker_timeout":"worker_error"}static from(t,e){if(t instanceof Rt)return t;const i=t instanceof Error?t.message:String(t),r=Rt.classifyWorkerErrorMessage(i);return new Rt(i,r,{stage:e,cause:t})}static fromTask(t){const e=t.task.name;return Rt.from(t.error,e)}static throwOnWorkerParseFailure(t,e="PARSE"){if(t.success)return;const i=t.error!=null?`Failed to parse drawing due to error: '${t.error}'`:"Failed to parse drawing due to an unknown worker error",r=Rt.mapWorkerResultCode(t.errorCode,t.error);throw new Rt(i,r,{stage:e})}static mapWorkerResultCode(t,e){switch(t){case"worker_oom":return"worker_oom";case"worker_timeout":return"worker_timeout";case"worker_error":return"worker_error";default:return Rt.classifyWorkerErrorMessage(e??"")}}};Rt.WORKER_OOM_PATTERNS=["out of memory","data cannot be cloned","allocation failed","memory access out of bounds"];let Di=Rt;class vh extends ee{constructor(t){super(t)}}class kh extends ee{constructor(t){super(t)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class Ah extends ee{constructor(t){super(t)}}class Sh extends ee{constructor(t){super(t)}get dxfEntryCount(){return this.totalRecordCount}resolveAt(t){this.database.ensureTextStyleDefaults();const e=[],i=r=>{const s=r==null?void 0:r.trim();s&&!e.includes(s)&&e.push(s)};i(t),i(this.database.textstyle),i(Z),i("STANDARD");for(const r of e){const s=this.getAt(r);if(s)return s;const a=r.toUpperCase();for(const o of this.newIterator())if(o.name.toUpperCase()===a)return o}return this.newIterator().next().value??void 0}get shapeFiles(){return this.newIterator(!0).toArray().filter(t=>t.isShapeFile)}get fonts(){const t=new Set;for(const e of this.newIterator()){const i=ft.normalizeFontFileName(e.fileName);i&&t.add(i);const r=ft.normalizeFontFileName(e.bigFontFileName);r&&t.add(r)}return Array.from(t)}}class Ph extends ee{constructor(t){super(t)}}class Ih extends ee{constructor(t){super(t)}}class Eh extends ee{constructor(t){super(t)}normalizeName(t){const e=t.trim();return ke.isActiveVportName(e)?ti:super.normalizeName(e)}getActiveVport(){return this.getAt(ti)}getActiveVportBox(t,e){const i=this.getActiveVport();return i==null?void 0:i.resolveModelViewBox(t,e)}}class Lh extends ee{constructor(t){super(t)}}class Th extends Nt{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 Ch{constructor(t){this.database=t}applyForward(t){for(const e of t)this.applyChange(e,!0)}applyInverse(t){for(let e=t.length-1;e>=0;e--)this.applyChange(t[e],!1)}applyChange(t,e){switch(t.kind){case"modify":this.applyModify(t,e);break;case"append":e?this.applyAppend(t.container,t.object):this.applyRemove(t.container,t.object);break;case"remove":e?this.applyRemove(t.container,t.object):this.applyAppend(t.container,t.object);break;case"sysvar":this.applySysvar(t,e);break}}applyModify(t,e){const i=this.database.getObjectById(t.objectId);if(!i)return;const r=e?t.after:t.before;r&&i.restoreFrom(r)}applySysvar(t,e){const i=e?t.after:t.before;i!==void 0&&gt.instance().setVar(t.name,i,this.database)}applyAppend(t,e){switch(t.type){case"blockTableRecord":{const i=this.database.tables.blockTable.getIdAt(t.ownerId);i&&i.appendEntity(e);break}case"symbolTable":{const i=this.getSymbolTable(t.tableName);i&&i.add(e);break}case"dictionary":{const i=this.database.getObjectById(t.dictionaryId);i&&i.setAt(t.key,e);break}}}applyRemove(t,e){switch(t.type){case"blockTableRecord":{const i=this.database.tables.blockTable.getIdAt(t.ownerId);i&&i.removeEntity(e.objectId);break}case"symbolTable":{const i=this.getSymbolTable(t.tableName);i&&i.removeId(e.objectId);break}case"dictionary":{const i=this.database.getObjectById(t.dictionaryId);i&&i.removeId(e.objectId);break}}}getSymbolTable(t){const e=this.database.tables;switch(t){case"appIdTable":return e.appIdTable;case"blockTable":return e.blockTable;case"dimStyleTable":return e.dimStyleTable;case"linetypeTable":return e.linetypeTable;case"textStyleTable":return e.textStyleTable;case"viewTable":return e.viewTable;case"layerTable":return e.layerTable;case"viewportTable":return e.viewportTable;default:return}}}function As(n,t){const e=[],i=[],r=[];for(const s of t)if(s.kind==="modify"){const a=n.getObjectById(s.objectId);a instanceof H&&e.push(a)}else if(s.kind==="append"){if(s.container.type==="blockTableRecord"){const a=n.tables.blockTable.getEntityById(s.object.objectId)??(s.object instanceof H?s.object:void 0);a&&i.push(a)}}else s.kind==="remove"&&s.container.type==="blockTableRecord"&&s.object instanceof H&&r.push(s.object);return{modified:e,appended:i,erased:r}}function To(n,t){const e=[],i=[];for(const r of t){if(r.kind!=="append"&&r.kind!=="remove"||r.container.type!=="dictionary")continue;const s=r.container.key;if(r.kind==="append"){const a=n.getObjectById(r.object.objectId)??r.object;e.push({object:a,key:s})}else r.kind==="remove"&&i.push({object:r.object,key:s})}return{set:e,erased:i}}function Co(n,t){const e={};for(const i of Kf){const r=n.getAttrWithoutException(i),s=t.getAttrWithoutException(i);Me(r,s)||(e[i]=s)}return e}function Mo(n,t,e=!1){const i=[];for(const r of t){if(r.kind!=="modify")continue;const s=n.getObjectById(r.objectId);if(!(s instanceof Zi))continue;const a=r.before,o=r.after;if(!a||!o)continue;const c=e?Co(o,a):Co(a,o);Object.keys(c).length!==0&&i.push({database:n,layer:s,changes:c})}return i}function e0(n,t){if(n.type!==t.type)return!1;switch(n.type){case"blockTableRecord":return t.type==="blockTableRecord"&&n.ownerId===t.ownerId;case"symbolTable":return t.type==="symbolTable"&&n.tableName===t.tableName;case"dictionary":return t.type==="dictionary"&&n.dictionaryId===t.dictionaryId&&n.key===t.key}}class Mh{constructor(){this.changes=[]}getChanges(){return this.changes}clear(){this.changes.length=0}mergeFrom(t){for(const e of t.getChanges())this.mergeChange(e)}recordModify(t){const e=t.objectId;this.changes.find(r=>r.kind==="modify"&&r.objectId===e)||this.changes.push({kind:"modify",objectId:e,before:t.clonePreservingIdentity()})}hasModify(t){return this.changes.some(e=>e.kind==="modify"&&e.objectId===t)}recordAppend(t,e){this.recordStructuralChange({kind:"append",container:t,object:e.clonePreservingIdentity()})}recordRemove(t,e){this.recordStructuralChange({kind:"remove",container:t,object:e.clonePreservingIdentity()})}recordSysvar(t,e){const i=t.toLowerCase();this.changes.find(s=>s.kind==="sysvar"&&s.name===i)||this.changes.push({kind:"sysvar",name:i,before:e})}finalize(t){for(const e of this.changes)if(e.kind==="modify"){const i=t.getObjectById(e.objectId);i&&(e.after=i.clonePreservingIdentity())}else e.kind==="sysvar"&&(e.after=this.getSysvarValue(t,e.name))}recordStructuralChange(t){const e=t.kind==="append"?"remove":"append",i=this.findStructuralChangeIndex(e,t.container,t.object.objectId);if(i>=0){this.changes.splice(i,1);return}this.changes.push(t)}mergeChange(t){if(t.kind==="modify"){this.changes.find(i=>i.kind==="modify"&&i.objectId===t.objectId)||this.changes.push(t);return}if(t.kind==="sysvar"){this.changes.find(i=>i.kind==="sysvar"&&i.name===t.name)||this.changes.push(t);return}this.recordStructuralChange(t)}findStructuralChangeIndex(t,e,i){return this.changes.findIndex(r=>r.kind===t&&r.object.objectId===i&&e0(r.container,e))}getSysvarValue(t,e){return gt.instance().getVar(e,t)}}class ra{constructor(){this.openedObjects=new Map,this.originalStates=new Map,this.recorder=new Mh}getObject(t,e,i=!1){const r=this.openedObjects.get(t);if(r){if(e===ii.kForWrite&&!this.originalStates.has(t)){const a=r.clonePreservingIdentity();this.originalStates.set(t,a),this.recorder.recordModify(r)}return r}const s=this.lookupObject(t,i);if(this.openedObjects.set(t,s),e===ii.kForWrite){const a=s.clonePreservingIdentity();this.originalStates.set(s.objectId,a),this.recorder.recordModify(s)}return s}commit(){this.originalStates.clear(),this.openedObjects.clear()}abort(){for(const[t,e]of this.originalStates){const i=this.openedObjects.get(t);i&&i.restoreFrom(e)}this.originalStates.clear(),this.openedObjects.clear(),this.recorder.clear()}lookupObject(t,e){throw new Error(`lookupObject(${t}) not implemented`)}}class Oh extends ra{constructor(t){super(),this.database=t}lookupObject(t,e){const i=this.database.getObjectById(t,e);if(!i)throw new Error(`lookupObject(${t}) not found`);return i}}class Nh{constructor(){this.undoRecords=[],this.redoRecords=[],this.maxDepth=100}push(t){this.undoRecords.push(t),this.redoRecords.length=0,this.undoRecords.length>this.maxDepth&&this.undoRecords.shift()}popUndo(){return this.undoRecords.pop()}pushRedo(t){this.redoRecords.push(t)}popRedo(){return this.redoRecords.pop()}canUndo(){return this.undoRecords.length>0}canRedo(){return this.redoRecords.length>0}clear(){this.undoRecords.length=0,this.redoRecords.length=0}}class Rh{constructor(t){this.database=t,this.transactionStack=[],this.undoStack=new Nh,this.undoMarkStack=[],this._applyingUndoRedo=!1,this._pendingEntityModified=new Set,this._pendingLayerModified=new Map,this.strictMode=!1,this.changeApplier=new Ch(t)}startTransaction(){const t=new Oh(this.database);return this.transactionStack.push(t),t}currentTransaction(){return this.transactionStack[this.transactionStack.length-1]}hasTransaction(){return this.transactionStack.length>0}isRecording(){return this.hasTransaction()&&!this._applyingUndoRedo}isApplyingUndoRedo(){return this._applyingUndoRedo}isOpenedForWriteInTransaction(t){for(const e of this.transactionStack)if(e.recorder.hasModify(t))return!0;return!1}commitTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to commit.");if(this.transactionStack.length>0){this.transactionStack[this.transactionStack.length-1].recorder.mergeFrom(t.recorder),t.commit();return}t.recorder.finalize(this.database);const e=t.recorder.getChanges();t.commit(),e.length>0&&(this.dispatchCommitEvents(e),this.enqueueUndoChanges(e))}abortTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to abort.");const e=[...t.recorder.getChanges()];this.database.beginEventBatch(),this._applyingUndoRedo=!0;try{t.abort(),e.length>0&&this.changeApplier.applyInverse(e)}finally{this._applyingUndoRedo=!1,this.database.endEventBatch()}}startUndoMark(t){this.undoMarkStack.push({label:t,pendingChanges:[]})}endUndoMark(){const t=this.undoMarkStack.pop();if(!t)throw new Error("No active undo mark to end.");t.pendingChanges.length!==0&&this.undoStack.push({label:t.label,changes:t.pendingChanges})}cancelUndoMark(){this.undoMarkStack.length>0&&this.undoMarkStack.pop()}undo(){const t=this.undoStack.popUndo();if(!t)return!1;this.database.beginEventBatch(),this._applyingUndoRedo=!0;try{this.changeApplier.applyInverse(t.changes),this.dispatchUndoRedoEvents(t.changes,!0)}finally{this._applyingUndoRedo=!1,this.database.endEventBatch()}return this.undoStack.pushRedo(t),!0}redo(){const t=this.undoStack.popRedo();if(!t)return!1;this.database.beginEventBatch(),this._applyingUndoRedo=!0;try{this.changeApplier.applyForward(t.changes),this.dispatchUndoRedoEvents(t.changes,!1)}finally{this._applyingUndoRedo=!1,this.database.endEventBatch()}return this.undoStack.push(t),!0}canUndo(){return this.undoStack.canUndo()}canRedo(){return this.undoStack.canRedo()}clearUndoStack(){this.undoStack.clear()}recordAppend(t,e){var i;this.isRecording()&&((i=this.currentTransaction())==null||i.recorder.recordAppend(t,e))}recordRemove(t,e){var i;this.isRecording()&&((i=this.currentTransaction())==null||i.recorder.recordRemove(t,e))}recordSysvar(t,e){var i;this.isRecording()&&((i=this.currentTransaction())==null||i.recorder.recordSysvar(t,e))}resolveSymbolTableName(t){const e=this.database.tables;return t===e.appIdTable?"appIdTable":t===e.blockTable?"blockTable":t===e.dimStyleTable?"dimStyleTable":t===e.linetypeTable?"linetypeTable":t===e.textStyleTable?"textStyleTable":t===e.viewTable?"viewTable":t===e.layerTable?"layerTable":t===e.viewportTable?"viewportTable":t.objectId}runUndoable(t,e){this.startUndoMark(t),this.startTransaction();try{const i=e(this.currentTransaction());return this.commitTransaction(),this.endUndoMark(),i}catch(i){throw this.hasTransaction()&&this.abortTransaction(),this.cancelUndoMark(),i}}enqueueUndoChanges(t){const e=this.undoMarkStack[this.undoMarkStack.length-1];if(e)for(const i of t)e.pendingChanges.push(i)}dispatchCommitEvents(t){const{modified:e,appended:i,erased:r}=As(this.database,t);for(const o of e)this.dispatchEntityModified(o);i.length>0&&this.database.notifyEntityAppended(i),r.length>0&&this.database.notifyEntityErased(r);const{set:s,erased:a}=To(this.database,t);for(const{object:o,key:c}of s)this.database.notifyDictObjectSet(o,c);for(const{object:o,key:c}of a)this.database.notifyDictObjectErased(o,c);for(const o of t)o.kind==="sysvar"&&o.after!==void 0&&gt.instance().events.sysVarChanged.dispatch({database:this.database,name:o.name,oldVal:o.before,newVal:o.after});for(const o of Mo(this.database,t))this.dispatchLayerModified(o)}dispatchUndoRedoEvents(t,e){const{modified:i,appended:r,erased:s}=As(this.database,t),{set:a,erased:o}=To(this.database,t);if(e){for(const c of i)this.dispatchEntityModified(c);s.length>0&&this.database.notifyEntityAppended(s),r.length>0&&this.database.notifyEntityErased(r);for(const{object:c,key:l}of o)this.database.notifyDictObjectSet(c,l);for(const{object:c,key:l}of a)this.database.notifyDictObjectErased(c,l)}else{for(const c of i)this.dispatchEntityModified(c);r.length>0&&this.database.notifyEntityAppended(r),s.length>0&&this.database.notifyEntityErased(s);for(const{object:c,key:l}of a)this.database.notifyDictObjectSet(c,l);for(const{object:c,key:l}of o)this.database.notifyDictObjectErased(c,l)}for(const c of t)if(c.kind==="sysvar"){const l=e?c.after:c.before,h=e?c.before:c.after;h!==void 0&&gt.instance().events.sysVarChanged.dispatch({database:this.database,name:c.name,oldVal:l,newVal:h})}for(const c of Mo(this.database,t,e))this.dispatchLayerModified(c)}dispatchLayerModified(t){if(this.database.isEventBatched()){const e=this._pendingLayerModified.get(t.layer.objectId);if(e){e.changes={...e.changes,...t.changes};return}this._pendingLayerModified.set(t.layer.objectId,{database:t.database,layer:t.layer,changes:{...t.changes}});return}this.database.events.layerModified.dispatch(t)}dispatchEntityModified(t){if(this.database.isEventBatched()){this._pendingEntityModified.add(t);return}this.database.events.entityModified.dispatch({database:this.database,entity:t})}flushPendingLayerModifiedEvents(){if(this._pendingLayerModified.size===0)return;const t=[...this._pendingLayerModified.values()];this._pendingLayerModified.clear();for(const e of t)this.database.events.layerModified.dispatch(e)}flushPendingEntityModifiedEvents(){if(this._pendingEntityModified.size===0)return;const t=[...this._pendingEntityModified];this._pendingEntityModified.clear();for(const e of t)this.database.events.entityModified.dispatch({database:this.database,entity:e})}}const Si=class Si extends bt{constructor(){super({objectId:"0"}),this._classes=[],this._handleRegistry=new Map,this._drawNoPlotLayers=!0,this._eventBatchDepth=0,this._pendingEntityAppended=[],this._pendingEntityErased=[],this._pendingDictObjectSet=[],this._pendingDictObjectErased=[],this._lastOpenError=null,this.events={dictObjetSet:new at,dictObjectErased:new at,entityAppended:new at,entityModified:new at,entityErased:new at,layerAppended:new at,layerModified:new at,layerErased:new at,openProgress:new at,openFailed:new at},Si._unsavedDrawingSequence+=1,this._dwgname=`Drawing${Si._unsavedDrawingSequence}.dwg`,this._version=new pt("AC1014"),this._angbase=0,this._angdir=0,this._aunits=St.DecimalDegrees,this._auprec=0,this._lunits=rt.Decimal,this._luprec=4,this._celtscale=1,this._cecolor=new X,this._celtype=lt,this._celweight=exports.AcGiLineWeight.ByLayer,this._cetransparency=new ot,this._clayer="0",this._cmlstyle=oe,this._cmlscale=1,this._cmleaderstyle=ce,this._hpbackgroundcolor=new X(exports.AcCmColorMethod.None),this._hpcolor=this._cecolor.clone(),this._hplayer=".",this._hptransparency=new ot,this._textstyle=Z,this._dimstyle=Z,this._extents=new Y,this._insunits=J.Millimeters,this._unitmode=0,this._measurement=1,this._ltscale=1,this._lwdisplay=!1,this._tilemode=!0,this._psltscale=!0,this._pdmode=0,this._pdsize=0,this._osmode=0,this._orthomode=0,this._maxHandle=0,this._tables={appIdTable:new Lh(this),blockTable:new wh(this),dimStyleTable:new vh(this),linetypeTable:new Ah(this),textStyleTable:new Sh(this),ucsTable:new Ph(this),viewTable:new Ih(this),layerTable:new kh(this),viewportTable:new Eh(this)},this._objects={dictionary:new Nt(this),group:new Nt(this),imageDefinition:new Nt(this),layerFilter:new Nt(this),layerIndex:new Nt(this),layout:new Th(this),mleaderStyle:new Nt(this),mlineStyle:new Nt(this),sortentsTable:new Nt(this),xrecord:new Nt(this)},this._layerFilters=new le,this.transactionManager=new Rh(this),this.registerBootstrapHandles()}get tables(){return this._tables}get classes(){return this._classes}set classes(t){this._classes=t.map(e=>({...e}))}get objects(){return this._objects}get layerFilters(){return this._layerFilters}set layerFilters(t){this._layerFilters=t??new le}getObjectById(t,e=!1){return t===this.objectId?this:this._handleRegistry.get(t)}isUndoRecording(){return this.transactionManager.isRecording()}openObject(t,e){const i=this.transactionManager.currentTransaction();if(i){const r=i.getObject(t,e);if(r)return r}return this.getObjectById(t)}openObjectForRead(t){return this.openObject(t,ii.kForRead)}openObjectForWrite(t){return this.openObject(t,ii.kForWrite)}openEntityForRead(t){const e=typeof t=="string"?t:t.objectId;return this.openObjectForRead(e)}openEntityForWrite(t){const e=typeof t=="string"?t:t.objectId;return this.openObjectForWrite(e)}runDatabaseEdit(t,e){if(this.isUndoRecording()){e();return}this.transactionManager.runUndoable(t,e)}getRootDictionaries(){return[this.objects.dictionary,this.objects.group,this.objects.imageDefinition,this.objects.layerFilter,this.objects.layerIndex,this.objects.layout,this.objects.mleaderStyle,this.objects.mlineStyle,this.objects.sortentsTable,this.objects.xrecord]}beginEventBatch(){this._eventBatchDepth++}endEventBatch(){this._eventBatchDepth<=0||(this._eventBatchDepth--,this._eventBatchDepth===0&&(this.transactionManager.flushPendingEntityModifiedEvents(),this.transactionManager.flushPendingLayerModifiedEvents(),this.flushEventBatch()))}async endEventBatchChunked(t,e){if(this._eventBatchDepth<=0||(this._eventBatchDepth--,this._eventBatchDepth!==0))return;this.transactionManager.flushPendingEntityModifiedEvents(),this.transactionManager.flushPendingLayerModifiedEvents();const i=this._pendingEntityAppended;this._pendingEntityAppended=[];const r=i.length,s=Math.max(1,t);if(r===0){this.flushEventBatchRemainder();return}let a=0;try{for(let o=0;o<r;o+=s){const c=Math.min(o+s,r),l=i.slice(o,c);this.events.entityAppended.dispatch({database:this,entity:l}),a=c,e&&await e(c,r)}}finally{a<r&&this.events.entityAppended.dispatch({database:this,entity:i.slice(a)}),this.flushEventBatchRemainder()}}isEventBatched(){return this._eventBatchDepth>0}notifyEntityAppended(t){if(this.isEventBatched()){const e=Array.isArray(t)?t:[t];this._pendingEntityAppended.push(...e);return}this.events.entityAppended.dispatch({database:this,entity:t})}notifyEntityErased(t){if(this.isEventBatched()){const e=Array.isArray(t)?t:[t];this._pendingEntityErased.push(...e);return}this.events.entityErased.dispatch({database:this,entity:t})}notifyDictObjectSet(t,e){if(this.isEventBatched()){this._pendingDictObjectSet.push({object:t,key:e});return}this.events.dictObjetSet.dispatch({database:this,object:t,key:e})}notifyDictObjectErased(t,e){if(this.isEventBatched()){this._pendingDictObjectErased.push({object:t,key:e});return}this.events.dictObjectErased.dispatch({database:this,object:t,key:e})}flushEventBatch(){if(this._pendingEntityAppended.length>0){const t=this._pendingEntityAppended;this._pendingEntityAppended=[],this.events.entityAppended.dispatch({database:this,entity:t})}this.flushEventBatchRemainder()}flushEventBatchRemainder(){if(this._pendingEntityErased.length>0){const t=this._pendingEntityErased;this._pendingEntityErased=[],this.events.entityErased.dispatch({database:this,entity:t})}if(this._pendingDictObjectSet.length>0){const t=this._pendingDictObjectSet;this._pendingDictObjectSet=[];for(const{object:e,key:i}of t)this.events.dictObjetSet.dispatch({database:this,object:e,key:i})}if(this._pendingDictObjectErased.length>0){const t=this._pendingDictObjectErased;this._pendingDictObjectErased=[];for(const{object:e,key:i}of t)this.events.dictObjectErased.dispatch({database:this,object:e,key:i})}}get formatter(){return this._formatter??(this._formatter=new ph(this))}generateHandle(){return this._maxHandle++,this._maxHandle.toString(16).toUpperCase()}generateUniqueHandle(){let t=this.generateHandle();for(;this.isHandleTaken(t);)t=this.generateHandle();return t}initializeHandleSeed(t){const e=parseInt(t,16);if(!isNaN(e)&&e>0){const i=e-1;i>this._maxHandle&&(this._maxHandle=i)}}adoptExternalHandle(t,e){return this.releaseObjectHandle(t),e&&!e.startsWith(be)&&!this.isHandleTaken(e)?(t.objectId=e,this.registerObjectHandle(t),this.updateMaxHandle(e),e):this.assignGeneratedHandle(t)}registerObjectHandle(t){const e=t.objectId;!e||e.startsWith(be)||this._handleRegistry.set(e,t)}releaseObjectHandle(t){const e=t.objectId;!e||e.startsWith(be)||this._handleRegistry.get(e)===t&&this._handleRegistry.delete(e)}isHandleTaken(t,e){if(!t||t.startsWith(be))return!1;const i=this._handleRegistry.get(t);return i!==void 0&&i!==e}registerBootstrapHandles(){this._handleRegistry.clear(),this.registerObjectHandle(this);for(const t of[this._tables.blockTable,this._tables.dimStyleTable,this._tables.layerTable,this._tables.linetypeTable,this._tables.appIdTable,this._tables.textStyleTable,this._tables.ucsTable,this._tables.viewTable,this._tables.viewportTable])this.registerObjectHandle(t);for(const t of[this._objects.dictionary,this._objects.group,this._objects.imageDefinition,this._objects.layerFilter,this._objects.layerIndex,this._objects.layout,this._objects.mleaderStyle,this._objects.mlineStyle,this._objects.sortentsTable,this._objects.xrecord])this.registerObjectHandle(t)}assignGeneratedHandle(t){const e=t.objectId;this.releaseObjectHandle(t);const i=this.generateUniqueHandle();return t.objectId=i,this.registerObjectHandle(t),e&&e!==i&&this.updateMaxHandle(i),i}updateMaxHandle(t){const e=parseInt(t,16);!isNaN(e)&&e>this._maxHandle&&(this._maxHandle=e)}commitObjectHandle(t,e){const i=t.getAttrWithoutException("objectId"),r=e!=null&&i!=null&&e(i);if(!i||t.isTemp||r){this.assignGeneratedHandle(t);return}const a=this._handleRegistry.get(i);if(a&&a!==t)if(this.shouldPreserveIncomingHandle(t))this.assignGeneratedHandle(a);else{this.assignGeneratedHandle(t);return}this.registerObjectHandle(t),this.updateMaxHandle(i)}shouldPreserveIncomingHandle(t){return!t.isTemp}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(I.AUNITS,this._aunits,t??0,e=>{this._aunits=e})}get auprec(){return this._auprec}set auprec(t){this.updateSysVar(I.AUPREC,this._auprec,t??0,e=>{this._auprec=e})}get lunits(){return this._lunits}set lunits(t){this.updateSysVar(I.LUNITS,this._lunits,t??rt.Decimal,e=>{this._lunits=e})}get luprec(){return this._luprec}set luprec(t){this.updateSysVar(I.LUPREC,this._luprec,t??4,e=>{this._luprec=e})}get version(){return this._version}set version(t){this.updateSysVar(I.ACADVER,this._version,new pt(t),e=>{this._version=e})}get insunits(){return this._insunits}set insunits(t){this.updateSysVar(I.INSUNITS,this._insunits,t??4,e=>{this._insunits=e})}get unitmode(){return this._unitmode}set unitmode(t){this.updateSysVar(I.UNITMODE,this._unitmode,t??0,e=>{this._unitmode=e})}get measurement(){return this._measurement}set measurement(t){this.updateSysVar(I.MEASUREMENT,this._measurement,t??1,e=>{this._measurement=e})}get ltscale(){return this._ltscale}set ltscale(t){this.updateSysVar(I.LTSCALE,this._ltscale,t??1,e=>{this._ltscale=e})}get lwdisplay(){return this._lwdisplay}get drawNoPlotLayers(){return this._drawNoPlotLayers}get dwgname(){return this._dwgname}setDwgName(t){const e=t.trim();e&&this.updateSysVar(I.DWGNAME,this._dwgname,e,i=>{this._dwgname=i})}get thumbnailImage(){return this._thumbnailImage}set thumbnailImage(t){if(!t||t.length===0){this._thumbnailImage=void 0;return}this._thumbnailImage=t}isLayerDrawable(t){if(this._drawNoPlotLayers)return!0;const e=this.tables.layerTable.getAt(t);return e==null||e.isPlottable}set lwdisplay(t){this.updateSysVar(I.LWDISPLAY,this._lwdisplay,t??!1,e=>{this._lwdisplay=e})}get tilemode(){return this._tilemode}set tilemode(t){this._tilemode=t}get psltscale(){return this._psltscale}set psltscale(t){this._psltscale=t}get cecolor(){return this._cecolor}set cecolor(t){this.updateSysVar(I.CECOLOR,this._cecolor,t||0,e=>{this._cecolor=e.clone()})}get celtscale(){return this._celtscale}set celtscale(t){this.updateSysVar(I.CELTSCALE,this._celtscale,t??1,e=>{this._celtscale=e})}get celtype(){return this._celtype}set celtype(t){const e=this.normalizeLinetypeName(t??lt);this.updateSysVar(I.CELTYPE,this._celtype,e,i=>{this._celtype=i})}get celweight(){return this._celweight}set celweight(t){this.updateSysVar(I.CELWEIGHT,this._celweight,t??exports.AcGiLineWeight.ByLayer,e=>{this._celweight=e})}get cetransparency(){return this._cetransparency}set cetransparency(t){this.updateSysVar(I.CETRANSPARENCY,this._cetransparency,t??new ot,e=>{this._cetransparency=e.clone()})}get clayer(){return this._clayer}set clayer(t){this.updateSysVar(I.CLAYER,this._clayer,t??"0",e=>{this._clayer=e})}get cmlstyle(){return this._cmlstyle}set cmlstyle(t){this.updateSysVar(I.CMLSTYLE,this._cmlstyle,t??oe,e=>{this._cmlstyle=e})}get cmlscale(){return this._cmlscale}set cmlscale(t){this.updateSysVar(I.CMLSCALE,this._cmlscale,t??1,e=>{this._cmlscale=e})}get cmleaderstyle(){return this._cmleaderstyle}set cmleaderstyle(t){this.updateSysVar(I.CMLEADERSTYLE,this._cmleaderstyle,t??ce,e=>{this._cmleaderstyle=e})}get hpbackgroundcolor(){return this._hpbackgroundcolor}set hpbackgroundcolor(t){this.updateSysVar(I.HPBACKGROUNDCOLOR,this._hpbackgroundcolor,t??new X(exports.AcCmColorMethod.None),e=>{this._hpbackgroundcolor=e.clone()})}get hpcolor(){return this._hpcolor}set hpcolor(t){this.updateSysVar(I.HPCOLOR,this._hpcolor,t??this._cecolor,e=>{this._hpcolor=e.clone()})}get hplayer(){return this._hplayer}set hplayer(t){this.updateSysVar(I.HPLAYER,this._hplayer,t??".",e=>{this._hplayer=e})}get hptransparency(){return this._hptransparency}set hptransparency(t){this.updateSysVar(I.HPTRANSPARENCY,this._hptransparency,t??new ot,e=>{this._hptransparency=e.clone()})}get textstyle(){return this._textstyle}set textstyle(t){this.updateSysVar(I.TEXTSTYLE,this._textstyle,t??Z,e=>{this._textstyle=e})}get dimstyle(){return this._dimstyle}set dimstyle(t){this.updateSysVar(I.DIMSTYLE,this._dimstyle,t??Z,e=>{this._dimstyle=e})}get angbase(){return this._angbase}set angbase(t){this.updateSysVar(I.ANGBASE,this._angbase,t??0,e=>{this._angbase=e})}get angdir(){return this._angdir}set angdir(t){this.updateSysVar(I.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(I.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(I.EXTMIN,e,this._extents.min)}}get extents(){return this._extents}get pdmode(){return this._pdmode}set pdmode(t){this.updateSysVar(I.PDMODE,this._pdmode,t??0,e=>{this._pdmode=e})}get pdsize(){return this._pdsize}set pdsize(t){this.updateSysVar(I.PDSIZE,this._pdsize,t??0,e=>{this._pdsize=e})}get osmode(){return this._osmode}set osmode(t){this.updateSysVar(I.OSMODE,this._osmode,t??0,e=>{this._osmode=e})}get orthomode(){return this._orthomode}set orthomode(t){this.updateSysVar(I.ORTHOMODE,this._orthomode,t??0,e=>{this._orthomode=e})}get lastOpenError(){return this._lastOpenError}async read(t,e,i=wi.DXF){const r=qt.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(),this._lastOpenError=null,this._drawNoPlotLayers=(e==null?void 0:e.drawNoPlotLayers)??!0,e!=null&&e.fileName&&this.setDwgName(e.fileName),qc(this);try{await r.read(t,this,e&&e.minimumChunkSize||10,this.createConversionProgressHandler(e),e==null?void 0:e.timeout,e==null?void 0:e.sysVars)}catch(s){const a=Di.from(s);throw this._lastOpenError=a,this.events.openFailed.dispatch({database:this,error:a}),a}this._lastOpenError=null,this.ensureDatabaseDefaults()}createConversionProgressHandler(t){return async(e,i,r,s,a)=>{let o=s;if(r==="ERROR"&&a){const c=Di.fromTask(a);this._lastOpenError=c,o={code:c.code,message:c.message,stage:c.stage??i}}if(t&&t.fontLoader&&i=="FONT"&&r=="END"){const c=s||this.tables.textStyleTable.fonts;try{await this.loadFontsWithProgress(t.fontLoader,c,e)}catch(l){if(t.failOnFontLoadError)throw l;const h=l instanceof Error?l.message:String(l);this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:i,subStageStatus:"ERROR",data:{fonts:c,error:h,code:"font_load_failed"}})}this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:i,subStageStatus:"END",data:c});return}this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:i,subStageStatus:r,data:o})}}async loadFontsWithProgress(t,e,i){if(e.length<=1){await t.load(e);return}const r=Math.max(1,Math.min(5,19-i));for(let s=0;s<e.length;s++){await t.load([e[s]]);const a=Math.min(19,i+Math.round((s+1)/e.length*r));this.events.openProgress.dispatch({database:this,percentage:a,stage:"CONVERSION",subStage:"FONT",subStageStatus:"IN-PROGRESS",data:e})}}async openUri(t,e){var g;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"),s=r?parseInt(r,10):null;let a=0;const o=(g=i.body)==null?void 0:g.getReader();if(!o)throw new Error("Failed to get response reader");const c=[];for(;;){const{done:p,value:f}=await o.read();if(p)break;if(c.push(f),a+=f.length,s!==null){const m=Math.round(a/s*100);this.events.openProgress.dispatch({database:this,percentage:m,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const l=new Uint8Array(a);let h=0;for(const p of c)l.set(p,h),h+=p.length;const u=this.getFileNameFromUri(t);u&&this.setDwgName(u);const d=u.toLowerCase().split(".").pop();d==="dwg"?await this.read(l.buffer,e,wi.DWG):d==="dxf"?await this.read(l.buffer,e,wi.DXF):await this.read(l.buffer,e,d),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(),this._layerFilters.root.getNestedFilters().length>0&&!this.tables.layerTable.extensionDictionary&&(this.tables.layerTable.extensionDictionary=this.generateHandle());const s=typeof r=="boolean"?{saveThumbnailImage:r,format:"ascii"}:{saveThumbnailImage:r.saveThumbnailImage??!1,format:r.format??"ascii"},a=i instanceof pt?i:new pt(i),o=new xe({database:this,precision:e,version:a,outputFormat:s.format});return this.writeDxfHeaderSection(o),this.writeDxfClassesSection(o),this.writeDxfTablesSection(o,a),this.writeDxfBlocksSection(o),this.writeDxfEntitiesSection(o),this.writeDxfObjectsSection(o),this.writeDxfThumbnailImageSection(o,s.saveThumbnailImage),o.writeStart("EOF"),s.format==="binary"?o.toBinary():o.toString()}async regen(){await new Ml(this).read(null,this,500,this.createConversionProgressHandler())}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){const e=new fh(this);t.layer&&e.createDefaultLayer(),t.lineType&&e.createDefaultLineType(),t.textStyle&&e.createDefaultTextStyle(),t.dimStyle&&e.createDefaultDimStyle(),t.layout&&e.createDefaultLayout()}ensureEntityStyleDefaults(t){var e;if(t.dxfTypeName==="MLINE"){this.ensureMLineStyle(this._cmlstyle||oe);return}if(t.dxfTypeName==="MULTILEADER"){this.ensureMLeaderStyle(this._cmleaderstyle||ce);return}if(t.dxfTypeName==="HATCH"){const i=t;(e=i.applyPatternDefaultsFromSysVars)==null||e.call(i,this)}}ensureTextStyleDefaults(){this.hasDefaultTextStyle()||this.tables.textStyleTable.add(new xr({name:Z,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}hasDefaultTextStyle(){const t=[Z,"STANDARD"];for(const e of t)if(this.tables.textStyleTable.has(e))return!0;for(const e of this.tables.textStyleTable.newIterator())if(e.name.toUpperCase()===Z.toUpperCase())return!0;return!1}ensureDatabaseDefaults(){if(!this.tables.layerTable.has("0")){const e=new X;e.colorIndex=7,this.tables.layerTable.add(new Zi({name:"0",standardFlags:0,linetype:we,lineWeight:0,isOff:!1,color:e,isPlottable:!0}))}if(this.tables.linetypeTable.has(Qt)||this.tables.linetypeTable.add(new ve({name:Qt,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(lt)||this.tables.linetypeTable.add(new ve({name:lt,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(we)||this.tables.linetypeTable.add(new ve({name:we,standardFlag:0,description:"Solid line",totalPatternLength:0})),this.ensureTextStyleDefaults(),this.tables.dimStyleTable.has(Z)||this.tables.dimStyleTable.add(new Tt({name:Z,dimtxsty:Z})),!this.tables.viewportTable.has(ti)){const e=new ke;e.name=ti,this.tables.viewportTable.add(e)}this.ensureMLineStyle(this._cmlstyle||oe),this.ensureMLeaderStyle(this._cmleaderstyle||ce);const t=this.tables.blockTable.modelSpace;if(!this.objects.layout.getAt("Model")){const e=new qi;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(ds)||this.tables.appIdTable.add(new Cn(ds)),this.tables.appIdTable.has(us)||this.tables.appIdTable.add(new Cn(us))}ensureMLineStyle(t){const e=this.objects.mlineStyle,i=t.trim();if(!i||e.getAt(i))return;for(const[s,a]of e.entries())if(s.toUpperCase()===i.toUpperCase()||a.styleName.toUpperCase()===i.toUpperCase())return;const r=new ta;r.styleName=i,r.elements=[{offset:.5,color:new X().setByLayer(),lineType:lt},{offset:-.5,color:new X().setByLayer(),lineType:lt}],e.setAt(i,r)}ensureMLeaderStyle(t){const e=this.objects.mleaderStyle,i=t.trim();if(!i||e.getAt(i))return;for(const[o]of e.entries())if(o.toUpperCase()===i.toUpperCase())return;const r=new Pr;r.unknown1=2,r.maxLeaderSegmentsPoints=2,r.leaderLineColor=new X().setByBlock(),r.textColor=new X().setByBlock(),r.blockColor=new X().setByBlock(),r.alignSpace=4,r.breakSize=3.75,r.enableBlockRotation=!0,r.unknown2=!1;const s=this.tables.linetypeTable.getAt(Qt);r.leaderLineTypeId=s==null?void 0:s.objectId;const a=this.tables.textStyleTable.getAt(Z);r.textStyleId=a==null?void 0:a.objectId,e.setAt(i,r)}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.capabilities.supportsUtf8CodePage&&(t.writeString(9,"$DWGCODEPAGE"),t.writeString(3,"UTF-8")),t.writeString(9,"$INSUNITS"),t.writeInt16(70,this.insunits),t.writeString(9,"$LUNITS"),t.writeInt16(70,this.lunits),t.writeString(9,"$LUPREC"),t.writeInt16(70,this.luprec),t.writeString(9,"$UNITMODE"),t.writeInt16(70,this.unitmode),t.writeString(9,"$MEASUREMENT"),t.writeInt16(70,this.measurement),t.writeString(9,"$LTSCALE"),t.writeDouble(40,this.ltscale),t.capabilities.supportsLineWeight&&(t.writeString(9,"$LWDISPLAY"),t.writeInt16(70,this.lwdisplay?1:0)),t.writeString(9,"$CELTSCALE"),t.writeDouble(40,this.celtscale),t.capabilities.supportsLineWeight&&(t.writeString(9,"$CELWEIGHT"),t.writeLineWeight(370,this.celweight)),t.writeString(9,"$CECOLOR"),t.writeCmColor(this.cecolor),t.writeString(9,"$TILEMODE"),t.writeInt16(70,this.tilemode?1:0),t.writeString(9,"$PSLTSCALE"),t.writeInt16(70,this.psltscale?1:0),t.writeString(9,"$CLAYER"),t.writeString(8,this.clayer),t.writeString(9,"$CELTYPE"),t.writeString(6,this.celtype),t.capabilities.supportsTransparency&&!this.cetransparency.isInvalid&&(t.writeString(9,"$CETRANSPARENCY"),t.writeTransparency(this.cetransparency)),t.writeString(9,"$CMLSTYLE"),t.writeString(2,this.cmlstyle),t.writeString(9,"$CMLSCALE"),t.writeDouble(40,this.cmlscale),t.writeString(9,"$CMLEADERSTYLE"),t.writeString(2,this.cmleaderstyle),this.hpcolor.colorMethod!==exports.AcCmColorMethod.None&&(t.writeString(9,"$HPCOLOR"),t.writeCmColor(this.hpcolor,2)),this.hpbackgroundcolor.colorMethod!==exports.AcCmColorMethod.None&&(t.writeString(9,"$HPBACKGROUNDCOLOR"),t.writeCmColor(this.hpbackgroundcolor,2)),t.writeString(9,"$HPLAYER"),t.writeString(8,this.hplayer),t.capabilities.supportsTransparency&&!this.hptransparency.isInvalid&&(t.writeString(9,"$HPTRANSPARENCY"),t.writeTransparency(this.hptransparency)),t.writeString(9,"$TEXTSTYLE"),t.writeString(7,this.textstyle),t.writeString(9,"$DIMSTYLE"),t.writeString(2,this.dimstyle),t.writeString(9,"$ANGBASE"),t.writeAngle(50,this.angbase),t.writeString(9,"$ANGDIR"),t.writeInt16(70,this.angdir),t.writeString(9,"$AUNITS"),t.writeInt16(70,this.aunits),t.writeString(9,"$AUPREC"),t.writeInt16(70,this.auprec),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.writeString(9,"$ORTHOMODE"),t.writeInt16(70,this.orthomode),t.endSection()}writeDxfClassesSection(t){if(!(!t.capabilities.supportsClassesSection||this._classes.length===0)){t.startSection("CLASSES");for(const e of this._classes)t.writeStart("CLASS"),t.writeString(1,e.name),t.writeString(2,e.cppClassName),t.writeString(3,e.appName),t.writeInt32(90,e.proxyFlag),t.writeInt32(91,e.instanceCount),t.writeInt8(280,e.wasProxy?1:0),t.writeInt8(281,e.isEntity?1:0);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,"UCS",this.tables.ucsTable,this.tables.ucsTable.newIterator(),"UCS"),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(!0),"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.capabilities.supportsBlockRecordTable&&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){if(!t.capabilities.supportsObjectsSection)return;t.startSection("OBJECTS");const e=this.objects.dictionary;e.ownerId="0";const i=a=>{t.writeStart("DICTIONARY"),a.dxfOut(t,!0)},r=(a,o)=>{e.getAt(a)!==o&&e.setAt(a,o)},s=a=>{e.getAt(a)&&e.remove(a)};r("ACAD_LAYOUT",this.objects.layout),this.objects.group.numEntries>0?r("ACAD_GROUP",this.objects.group):s("ACAD_GROUP"),this.objects.sortentsTable.numEntries>0?r("ACAD_SORTENTS",this.objects.sortentsTable):s("ACAD_SORTENTS"),this.objects.mleaderStyle.numEntries>0?r("ACAD_MLEADERSTYLE",this.objects.mleaderStyle):s("ACAD_MLEADERSTYLE"),this.objects.mlineStyle.numEntries>0?r("ACAD_MLINESTYLE",this.objects.mlineStyle):s("ACAD_MLINESTYLE"),this.objects.imageDefinition.numEntries>0?r("ISM_RASTER_IMAGE_DICT",this.objects.imageDefinition):s("ISM_RASTER_IMAGE_DICT"),this.objects.xrecord.numEntries>0?r("MLIGHT_XRECORD",this.objects.xrecord):s("MLIGHT_XRECORD"),i(e),i(this.objects.layout),this.objects.group.numEntries>0&&i(this.objects.group),this.objects.sortentsTable.numEntries>0&&i(this.objects.sortentsTable),this.objects.mleaderStyle.numEntries>0&&i(this.objects.mleaderStyle),this.objects.mlineStyle.numEntries>0&&i(this.objects.mlineStyle),this.objects.imageDefinition.numEntries>0&&i(this.objects.imageDefinition),this.objects.xrecord.numEntries>0&&i(this.objects.xrecord);for(const[a,o]of this.objects.layout.entries())t.writeStart("LAYOUT"),o.dxfOut(t,!0);for(const[a,o]of this.objects.group.entries())o.name||(o.name=a),t.writeStart("GROUP"),o.dxfOut(t,!0);for(const[a,o]of this.objects.sortentsTable.entries())t.writeStart("SORTENTSTABLE"),o.dxfOut(t,!0);for(const[a,o]of this.objects.imageDefinition.entries())t.writeStart("IMAGEDEF"),o.dxfOut(t,!0);for(const[a,o]of this.objects.layerFilter.entries())t.writeStart("LAYER_FILTER"),o.dxfOut(t,!0);for(const[a,o]of this.objects.layerIndex.entries())t.writeStart("LAYER_INDEX"),o.dxfOut(t,!0);for(const[a,o]of this.objects.mleaderStyle.entries())t.writeStart("MLEADERSTYLE"),o.dxfOut(t,!0);for(const[a,o]of this.objects.mlineStyle.entries())t.writeStart("MLINESTYLE"),o.dxfOut(t,!0);for(const[a,o]of this.objects.xrecord.entries())t.writeStart("XRECORD"),o.dxfOut(t,!0);this.writeAcLyLayerFilterObjects(t),t.endSection()}writeAcLyLayerFilterObjects(t){const e=Wl(this._layerFilters);if(e.nodes.length===0)return;const i=[],r=[],s=this.tables.layerTable,a=s.extensionDictionary??this.generateHandle();s.extensionDictionary=a;const o=this.generateHandle(),c=this.generateHandle(),l=[],h=[],u=(p,f,m)=>{const b=this.generateHandle();let _;if(p.children.length>0){const v=this.generateHandle(),x=this.generateHandle(),S=[];for(const P of p.children)S.push({name:P.key,id:u(P,x,!1)});i.push({handle:v,ownerId:b,entries:[{name:ri,id:x}]}),i.push({handle:x,ownerId:v,entries:S}),_=v}return r.push({handle:b,ownerId:f,extensionDictionaryId:_,data:p.data}),m&&h.push({name:p.key,id:b}),b};for(const p of e.nodes)l.push({name:p.key,id:u(p,o,!0)});const d=new Map,g=this.getObjectById(a);if(g instanceof Nt)for(const[p,f]of g.entries())d.set(p,f.objectId);d.set(ri,o),d.set(Sr,c),i.unshift({handle:a,ownerId:s.objectId,entries:Array.from(d,([p,f])=>({name:p,id:f}))},{handle:o,ownerId:a,entries:l},{handle:c,ownerId:a,entries:h});for(const p of i){t.writeStart("DICTIONARY"),t.writeHandle(5,p.handle),t.writeObjectId(330,p.ownerId),t.writeSubclassMarker("AcDbDictionary"),t.writeInt16(280,1),t.writeInt16(281,1);for(const f of p.entries)t.writeString(3,f.name),t.writeObjectId(350,f.id)}for(const p of r){const f=new ea;f.objectId=p.handle,f.ownerId=p.ownerId,p.extensionDictionaryId&&(f.extensionDictionary=p.extensionDictionaryId),f.data=$l(p.data),t.writeStart("XRECORD"),f.dxfOut(t)}}writeDxfTable(t,e,i,r,s){const a=[...r];t.startTable(e),i.dxfOut(t);for(const o of a){if(s==="BLOCK_RECORD"&&o instanceof tt){o.dxfOutBlockRecord(t);continue}t.writeStart(s),o.dxfOut(t,!0)}t.endTable()}writeDxfEntity(t,e){if(e instanceof kt&&!t.capabilities.supportsLwPolyline){t.writeStart("POLYLINE"),e.dxfOutAs2dPolyline(t,!0);return}t.writeStart(e.dxfTypeName),e.dxfOut(t,!0)}writeDxfThumbnailImageSection(t,e=!1){const i=this._thumbnailImage;if(!e||!i||i.length===0||!t.capabilities.supportsObjectsSection)return;const r=127;t.startSection("THUMBNAILIMAGE"),t.writeInt32(90,i.length);for(let s=0;s<i.length;s+=r){const a=i.subarray(s,s+r);t.writeString(310,br(a))}t.endSection()}clear(){this.transactionManager.clearUndoStack(),this._classes=[],this._tables.blockTable.removeAll(),this._tables.dimStyleTable.removeAll(),this._tables.linetypeTable.removeAll(),this._tables.textStyleTable.removeAll(),this._tables.ucsTable.removeAll(),this._tables.viewTable.removeAll(),this._tables.layerTable.removeAll(),this._tables.viewportTable.removeAll(),this._tables.appIdTable.removeAll(),this._objects.layout.removeAll(),this._objects.group.removeAll(),this._objects.imageDefinition.removeAll(),this._objects.layerFilter.removeAll(),this._objects.layerIndex.removeAll(),this._objects.mleaderStyle.removeAll(),this._objects.mlineStyle.removeAll(),this._objects.sortentsTable.removeAll(),this._objects.xrecord.removeAll(),this._layerFilters=new le,this._currentSpace=void 0,this._extents.makeEmpty(),this.registerBootstrapHandles()}updateSysVar(t,e,i,r){gt.instance().applyVarMutation(t,e,i,this,()=>r(i))}normalizeLinetypeName(t){const e=t.trim();return e.toUpperCase()==="BYLAYER"?lt:e.toUpperCase()==="BYBLOCK"?Qt:e}triggerSysVarChangedEvent(t,e,i){const r=gt.instance(),s=t.toLowerCase();r.getDescriptor(s)!=null&&r.events.sysVarChanged.dispatch({database:this,name:s,oldVal:e,newVal:i})}getFileNameFromUri(t){try{const i=new URL(t).pathname.split("/");return i[i.length-1]||""}catch{return""}}};Si._unsavedDrawingSequence=0;let Ss=Si;class i0{constructor(){this.transactionStack=[]}startTransaction(){const t=new ra;return this.transactionStack.push(t),t}currentTransaction(){return this.transactionStack[this.transactionStack.length-1]}commitTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to commit.");t.commit()}abortTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to abort.");t.abort()}hasTransaction(){return this.transactionStack.length>0}}const Kr=6,pa=class pa extends H{get dxfTypeName(){return"TOLERANCE"}constructor(){super(),this._location=new y,this._text="",this._dimensionStyle="",this._normal=new w(0,0,1),this._direction=new w(1,0,0)}get location(){return this._location}set location(t){this._location.set(t.x,t.y,t.z??0)}get text(){return this._text}set text(t){this._text=t}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t}get normal(){return this._normal}set normal(t){this._normal.set(t.x,t.y,t.z??0),this._normal.lengthSq()>0&&this._normal.normalize()}get direction(){return this._direction}set direction(t){this._direction.set(t.x,t.y,t.z??0),this._direction.lengthSq()>0&&this._direction.normalize()}setOrientation(t,e){return this.normal=t,this.direction=e,this}getBoundingPoints(){return this.getBoundingPolyline().slice(0,4)}getBoundingPolyline(){const{width:t,rowHeight:e,rowCount:i}=this.resolveFrameLayout(),r=e/2,s=r-e*i;return[new y(0,r,0),new y(t,r,0),new y(t,s,0),new y(0,s,0),new y(0,r,0)].map(o=>this.toFrameWcs(o.x,o.y))}get geometricExtents(){const t=new Y;for(const e of this.getBoundingPoints())t.expandByPoint(e);return t.isEmpty()&&t.expandByPoint(this._location),t}subGetGripPoints(){return[this._location]}subMoveGripPointsAt(t,e){return te(t,e,this._location),this}subGetOsnapPoints(t,e,i,r){t===k.Insertion&&r.push(this._location)}transformBy(t){const e=this.resolveLocalBasis(),i=this._location.clone(),r=i.clone().add(e.xAxis),s=i.clone().add(e.yAxis);i.applyMatrix4(t),r.applyMatrix4(t),s.applyMatrix4(t);const a=new w(r).sub(i),o=new w(s).sub(i);let c=new w().crossVectors(a,o);c.lengthSq()===0?c=this._normal.clone().transformDirection(t):c.normalize();let l=a.clone();return l.lengthSq()===0?l=this._direction.clone().transformDirection(t):l.normalize(),this._location.copy(i),this._normal.copy(c),this._direction.copy(l),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"tolerance",properties:[{name:"text",type:"string",editable:!0,accessor:{get:()=>this.text,set:t=>{this.text=t}}},{name:"dimensionStyle",type:"string",editable:!0,accessor:{get:()=>this.dimensionStyle,set:t=>{this.dimensionStyle=t}}},{name:"textHeight",type:"float",editable:!1,accessor:{get:()=>this.textHeight}}]},{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}}}]}]}}subWorldDraw(t,e){const r=this.collectFrameLineSegments().map(([a,o])=>t.lines([a,o])),s=this.drawToleranceText(t,e);return r.length>0&&s?t.group([...r,s]):r.length===1?r[0]:r.length>1?t.group(r):s}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbFcf"),this._dimensionStyle&&t.writeString(3,this._dimensionStyle),t.writePoint3d(10,this._location),t.writeString(1,this._text),this._normal.equals(w.Z_AXIS)||t.writeVector3d(210,this._normal),this._direction.equals(w.X_AXIS)||t.writeVector3d(11,this._direction),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbFcf");let e=this.location.x,i=this.location.y,r=this.location.z,s=this.normal.x,a=this.normal.y,o=this.normal.z,c=this.direction.x,l=this.direction.y,h=this.direction.z,u=!1,d=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const g=t.readItem();if(!g)break;const p=Number(g.code),f=Number(g.value);switch(p){case 1:this.text=String(g.value);break;case 3:this.dimensionStyle=String(g.value);break;case 10:e=f;break;case 20:i=f;break;case 30:r=f;break;case 11:c=f,d=!0;break;case 21:l=f,d=!0;break;case 31:h=f,d=!0;break;case 210:s=f,u=!0;break;case 220:a=f,u=!0;break;case 230:o=f,u=!0;break}}return this.location={x:e,y:i,z:r},u&&(this.normal={x:s,y:a,z:o}),d&&(this.direction={x:c,y:l,z:h}),this}get textHeight(){const t=this.resolveDimensionStyle(),e=(t==null?void 0:t.dimtxt)??Tt.DEFAULT_DIM_VALUES.dimtxt,i=(t==null?void 0:t.dimscale)??Tt.DEFAULT_DIM_VALUES.dimscale;return e*i}drawToleranceText(t,e){const i=this.parseToleranceFrame(this._text);if(i.length===0)return;const r=this.resolveFrameLayout(i),s=this.getTextStyle(),a=[];for(let o=0;o<i.length;o++){const c=i[o];let l=r.cellPadding;const h=-r.rowHeight*o;for(let u=0;u<c.cells.length;u++){const d=c.cells[u],g=r.columnWidths[u]??this.textHeight;if(d.trim()){const p=this.toFrameWcs(l+g/2,h),f={text:d,height:this.textHeight,width:1/0,position:p,directionVector:this._direction,attachmentPoint:exports.AcGiMTextAttachmentPoint.MiddleCenter,drawingDirection:exports.AcGiMTextFlowDirection.LEFT_TO_RIGHT};a.push(t.mtext(f,s,e))}l+=g+r.columnGap}}if(a.length!==0)return a.length===1?a[0]:t.group(a)}collectFrameLineSegments(){const t=this.parseToleranceFrame(this._text),e=this.resolveFrameLayout(t),{width:i,rowHeight:r,rowCount:s,columnDivisions:a}=e;if(i<=0||r<=0||s<=0)return[];const o=r/2,c=o-r*s,l=[],h=(u,d)=>{l.push([u,d])};h(this.toFrameWcs(0,o),this.toFrameWcs(i,o)),h(this.toFrameWcs(i,o),this.toFrameWcs(i,c)),h(this.toFrameWcs(i,c),this.toFrameWcs(0,c)),h(this.toFrameWcs(0,c),this.toFrameWcs(0,o));for(const u of a)h(this.toFrameWcs(u,o),this.toFrameWcs(u,c));for(let u=1;u<t.length;u++){const d=o-r*u;h(this.toFrameWcs(0,d),this.toFrameWcs(i,d))}return l}toFrameWcs(t,e){const i=this.resolveLocalBasis();return this._location.clone().addScaledVector(i.xAxis,t).addScaledVector(i.yAxis,e)}resolveFrameLayout(t){const e=t??this.parseToleranceFrame(this._text),i=this.textHeight,r=i*2,s=i/2,a=i;if(i<=0||e.length===0)return{width:0,totalHeight:0,rowHeight:0,columnWidths:[],columnDivisions:[],rowCount:0,cellPadding:0,columnGap:0};const o=Math.max(...e.map(d=>d.cells.length),0),c=[];for(let d=0;d<o;d++){let g=i;for(const p of e){const f=p.cells[d]??"";if(!f.trim())continue;const m=Rf(f,i);g=Math.max(g,m)}c.push(g)}const l=[0];let h=s;for(let d=0;d<c.length;d++)h+=c[d],h+=a,l.push(h-s);return{width:l[l.length-1]??0,totalHeight:r*e.length,rowHeight:r,columnWidths:c,columnDivisions:l,rowCount:e.length,cellPadding:s,columnGap:a}}parseToleranceFrame(t){if(!t)return[];const e=this.splitToleranceRows(t);if(e.length===0)return[];if(!t.includes("%%v"))return e.map(s=>({cells:this.parsePipeSeparatedCells(s)}));const i=e.map(s=>{const o=this.splitToleranceTokens(s,"%%v").slice(0,Kr);for(;o.length<Kr;)o.push("");return o}),r=[0,1];i.some(s=>{var a;return(a=s[2])==null?void 0:a.trim()})&&r.push(2);for(let s=3;s<Kr;s++)i.some(a=>{var o;return(o=a[s])==null?void 0:o.trim()})&&r.push(s);return i.map(s=>({cells:r.map(a=>s[a]??"")}))}splitToleranceRows(t){return t.replace(/\^J/g,`
11
- `).split(/\r\n|\r|\n|\\P/i).map(i=>i.trim()).filter(i=>i.length>0)}splitToleranceTokens(t,e){if(!t)return[];const i=[];let r="",s=0;for(let a=0;a<t.length;){if(t.startsWith(e,a)&&s===0){i.push(r),r="",a+=e.length;continue}const o=t[a];o==="{"?s++:o==="}"&&(s=Math.max(0,s-1)),r+=o,a++}return i.push(r),i}parsePipeSeparatedCells(t){return t?this.splitToleranceTokens(t,"|").filter(i=>i.length>0):[]}resolveLocalBasis(){const t=this._normal.clone();t.lengthSq()===0?t.set(0,0,1):t.normalize();let e=this._direction.clone();e.lengthSq()===0?e.set(1,0,0):e.normalize();let i=new w().crossVectors(t,e);return i.lengthSq()===0&&(e=w.X_AXIS.clone(),i=new w().crossVectors(t,e)),i.normalize(),e=new w().crossVectors(i,t).normalize(),{xAxis:e,yAxis:i,zAxis:t}}resolveDimensionStyle(){const t=this._dimensionStyle.trim(),e=this.tryGetDatabase();if(!(!t||!e))return e.tables.dimStyleTable.getAt(t)}tryGetDatabase(){try{return this.database}catch{return}}getTextStyle(){const t=this.resolveDimensionStyle(),e=(t==null?void 0:t.dimtxsty)??Tt.DEFAULT_DIM_VALUES.dimtxsty??"Standard",i=this.database.tables.textStyleTable.resolveAt(e);if(!i)throw new Error("No valid text style found in text style table.");return i.textStyle}};pa.typeName="Fcf";let On=pa;var Bh=(n=>(n[n.MText=0]="MText",n[n.Fcf=1]="Fcf",n[n.BlockReference=2]="BlockReference",n[n.NoAnnotation=3]="NoAnnotation",n))(Bh||{});const ma=class ma extends _t{get dxfTypeName(){return"LEADER"}constructor(){super(),this._isSplined=!1,this._updated=!1,this._hasArrowHead=!1,this._vertices=[],this._dimensionStyle="",this._hasHookLine=!1,this._isHookLineSameDirection=!1,this._annoType=3,this._textHeight=0,this._textWidth=0,this._associatedAnnotation="",this._normal=new w(0,0,1),this._horizontalDirection=new w(1,0,0)}get isSplined(){return this._isSplined}set isSplined(t){this._isSplined=t}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(t){this._hasArrowHead=t}get hasHookLine(){return this._hasHookLine}set hasHookLine(t){this._hasHookLine=t}get isHookLineSameDirection(){return this._isHookLineSameDirection}set isHookLineSameDirection(t){this._isHookLineSameDirection=t}get numVertices(){return this._vertices.length}get vertices(){return this._vertices.map(t=>t.clone())}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t}get annoType(){return this._annoType}set annoType(t){this._annoType=t}get textHeight(){return this._textHeight}set textHeight(t){this._textHeight=t}get textWidth(){return this._textWidth}set textWidth(t){this._textWidth=t}get byBlockColor(){return this._byBlockColor}set byBlockColor(t){this._byBlockColor=t}get associatedAnnotation(){return this._associatedAnnotation}set associatedAnnotation(t){this._associatedAnnotation=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get horizontalDirection(){return this._horizontalDirection}set horizontalDirection(t){this._horizontalDirection.copy(t)}get offsetFromBlock(){var t;return(t=this._offsetFromBlock)==null?void 0:t.clone()}set offsetFromBlock(t){this._offsetFromBlock=t?new w(t):void 0}get offsetFromAnnotation(){var t;return(t=this._offsetFromAnnotation)==null?void 0:t.clone()}set offsetFromAnnotation(t){this._offsetFromAnnotation=t?new w(t):void 0}appendVertex(t){this._vertices.push(new y().copy(t)),this._updated=!0}setVertexAt(t,e){if(t<0||t>=this._vertices.length)throw new Error("The vertex index is out of range!");return this._vertices[t].copy(e),this._updated=!0,this}vertexAt(t){if(t<0||t>=this._vertices.length)throw new Error("The vertex index is out of range!");return this._vertices[t].clone()}subGetGripPoints(){return this._vertices.map(t=>t.clone())}subMoveGripPointsAt(t,e){return ci(t,e,this._vertices),this}subGetOsnapPoints(t,e,i,r){if(this.numVertices===0)return;if(this.isSplined&&this.splineGeo){switch(t){case k.EndPoint:r.push(this._vertices[0]),r.push(this._vertices[this.numVertices-1]);break;case k.Nearest:r.push(this.splineGeo.nearestPoint(e));break}return}const s=this._vertices;switch(t){case k.EndPoint:r.push(...s);break;case k.MidPoint:case k.Nearest:case k.Perpendicular:{const a=[];for(let o=0;o<s.length-1;o++){const c=[];li(s[o],s[o+1],t,e,c),a.push(...c)}if(t===k.MidPoint)r.push(...a);else{const o=Ft(e,a);o&&r.push(o)}break}}}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new Y().setFromPoints(this.collectDrawPoints())}get closed(){return!1}set closed(t){}get area(){return 0}transformBy(t){return this._vertices.forEach(e=>e.applyMatrix4(t)),this.transformVector(this._normal,t),this.transformVector(this._horizontalDirection,t),this._offsetFromBlock&&this.transformVector(this._offsetFromBlock,t),this._offsetFromAnnotation&&this.transformVector(this._offsetFromAnnotation,t),this._splineGeo?(this._splineGeo.transform(t),this._updated=!1):this._updated=!0,this}subWorldDraw(t){return t.lines(this.collectDrawPoints())}collectDrawPoints(){if(this.isSplined&&this.splineGeo)return this.splineGeo.getPoints(100);const t=this._vertices.map(e=>e.clone());if(t.length>0&&!this._isSplined){const e=t[t.length-1];if(this.shouldDrawHookLine(e)){const i=this.computeHookLineEndPoint(e);i&&t.push(i)}}return t}shouldDrawHookLine(t){if(this.resolveHookLineLength(t)<=0)return!1;if(this._hasHookLine)return!0;const e=this.resolveAssociatedMText();if(e&&this.resolveHookSpanFromMText(e,t)>0)return!0;if(this._annoType!==0)return!1;const i=this.resolveDimensionStyle();return((i==null?void 0:i.dimtad)??Tt.DEFAULT_DIM_VALUES.dimtad)!==Qs.Center}computeHookLineEndPoint(t){const e=this.resolveHookLineLength(t);if(e<=0)return null;const i=this.resolveHookAxis();return t.clone().addScaledVector(i,e)}resolveHookLineLength(t){const e=this.resolveDimensionStyle(),i=((e==null?void 0:e.dimgap)??Tt.DEFAULT_DIM_VALUES.dimgap)*((e==null?void 0:e.dimscale)??Tt.DEFAULT_DIM_VALUES.dimscale);let r=this._textWidth+i;const s=this.resolveAssociatedMText();if(s){const a=this.resolveHookSpanFromMText(s,t);if(a>0)r=Math.max(r,a);else{const o=this.resolveAnnotationWidth(s);o>0&&(r=Math.max(r,o))}}return r}resolveHookAxis(){const t=this._horizontalDirection.clone();t.lengthSq()===0?t.set(1,0,0):t.normalize();const e=this._isHookLineSameDirection?1:-1;return t.multiplyScalar(e),t}resolveHookSpanFromMText(t,e){const i=this.resolveHookAxis(),r=this.resolveMTextLayoutMetrics(t);let s=0;for(const a of Df(r)){const o=(a.x-e.x)*i.x+(a.y-e.y)*i.y+(a.z-e.z)*i.z;o>s&&(s=o)}return s}resolveAnnotationWidth(t){if(t.extentsWidth>0)return t.extentsWidth;const e=$s(t.contents).split(`
12
- `);return Math.max(...e.map(i=>Ki(i.trim(),t.height)),0)}resolveMTextLayoutMetrics(t){return Bf({contents:t.contents,height:t.height,width:t.width,extentsWidth:t.extentsWidth,lineSpacingFactor:t.lineSpacingFactor,attachmentPoint:t.attachmentPoint,rotation:t.rotation,direction:t.direction,location:t.location})}scoreMTextAssociation(t,e){const i=this.resolveMTextLayoutMetrics(t),r=Math.max(t.height*2,1),s=Math.max(t.height,1),a=Math.max(i.height,t.height*4,10);return Yf(e,i,{padX:r,padYAbove:s,padYBelow:a})}resolveDimensionStyle(){var i;const t=(i=this._dimensionStyle)==null?void 0:i.trim(),e=this.tryGetDatabase();if(!(!t||!e))return e.tables.dimStyleTable.getAt(t)}resolveAssociatedMText(){const t=this.tryGetDatabase();if(!t)return;if(this._associatedAnnotation){const o=t.getObjectById(this._associatedAnnotation);if(o instanceof Pe)return o}if(this._vertices.length===0)return;const e=this.getAttrWithoutException("ownerId");if(!e)return;const i=t.getObjectById(e);if(!(i instanceof tt))return;const r=this._vertices[this._vertices.length-1];let s,a=Number.POSITIVE_INFINITY;for(const o of i.newIterator()){if(!(o instanceof Pe))continue;const c=this.scoreMTextAssociation(o,r);c==null||c>=a||(a=c,s=o)}return s}tryGetDatabase(){try{return this.database}catch{return}}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new jt(this._vertices,"Uniform"),this._updated=!1)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLeader"),t.writeString(3,this.dimensionStyle),t.writeInt16(71,this.hasArrowHead?1:0),t.writeInt16(72,this.isSplined?1:0),t.writeInt16(73,this.annoType),t.writeInt16(74,this.isHookLineSameDirection?1:0),t.writeInt16(75,this.hasHookLine?1:0),t.writeInt16(76,this.numVertices),this.textHeight!==0&&t.writeDouble(40,this.textHeight),this.textWidth!==0&&t.writeDouble(41,this.textWidth),this.byBlockColor!=null&&t.writeInt16(77,this.byBlockColor),this.associatedAnnotation&&t.writeHandle(340,this.associatedAnnotation);for(const e of this.vertices)t.writePoint3d(10,e);return t.writeVector3d(210,this.normal),t.writeVector3d(211,this.horizontalDirection),this._offsetFromBlock&&t.writeVector3d(212,this._offsetFromBlock),this._offsetFromAnnotation&&t.writeVector3d(213,this._offsetFromAnnotation),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbLeader"),this._vertices.length=0;let e=null,i=this.normal.x,r=this.normal.y,s=this.normal.z,a=this.horizontalDirection.x,o=this.horizontalDirection.y,c=this.horizontalDirection.z,l=0,h=0,u=0,d=0,g=0,p=0,f=!1,m=!1;const b=()=>{e&&(this.appendVertex(e),e=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const _=t.readItem();if(!_)break;const v=Number(_.code),x=Number(_.value);switch(v){case 3:this.dimensionStyle=String(_.value);break;case 10:b(),e={x,y:0,z:0};break;case 20:e&&(e.y=x);break;case 30:e&&(e.z=x);break;case 40:this.textHeight=x;break;case 41:this.textWidth=x;break;case 71:this.hasArrowHead=x!==0;break;case 72:this.isSplined=x!==0;break;case 73:this.annoType=x;break;case 74:this.isHookLineSameDirection=x!==0;break;case 75:this.hasHookLine=x!==0;break;case 76:break;case 77:this.byBlockColor=x;break;case 210:i=x;break;case 220:r=x;break;case 230:s=x;break;case 211:a=x;break;case 221:o=x;break;case 231:c=x;break;case 212:l=x,f=!0;break;case 222:h=x,f=!0;break;case 232:u=x,f=!0;break;case 213:d=x,m=!0;break;case 223:g=x,m=!0;break;case 233:p=x,m=!0;break;case 340:this.associatedAnnotation=String(_.value);break}}return b(),this.normal={x:i,y:r,z:s},this.horizontalDirection={x:a,y:o,z:c},f&&(this.offsetFromBlock={x:l,y:h,z:u}),m&&(this.offsetFromAnnotation={x:d,y:g,z:p}),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectPath2d();return e.length<2?1:kt.from2dPoints(e,!1).getOffsetSideAtPoint(t)}createOffsetCurve(t){return Ir(this.collectPath2d(),!1,t)}collectPath2d(){return this.isSplined&&this.splineGeo?this.splineGeo.getPoints(64).map(t=>new L(t.x,t.y)):this._vertices.map(t=>new L(t.x,t.y))}transformVector(t,e){const i=new y,r=new y(t.x,t.y,t.z);i.applyMatrix4(e),r.applyMatrix4(e),t.set(r.x-i.x,r.y-i.y,r.z-i.z)}};ma.typeName="Leader";let Nn=ma;const ur=class ur extends _t{constructor(t,e){super(),this._normal=new w(0,0,1),this._thickness=0,this._geo=new ue(t,e)}get dxfTypeName(){return"LINE"}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 thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}get area(){return 0}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}subMoveGripPointsAt(t,e){return ht(t,i=>{switch(i){case 0:this.transformBy(D.makeTranslation(e));break;case 1:this.startPoint.add(e);break;case 2:this.endPoint.add(e);break}}),this}subGetOsnapPoints(t,e,i,r){const s=this.startPoint,a=this.endPoint;switch(t){case k.EndPoint:r.push(s),r.push(a);break;case k.MidPoint:r.push(this.midPoint);break;case k.Nearest:{const o=this._geo.project(e);r.push(o)}break;case k.Perpendicular:{const o=this._geo.perpPoint(e);r.push(o)}break;case k.Tangent:break}}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){const e=this.startPoint,i=this.endPoint,r=[new y(e.x,e.y,0),new y(i.x,i.y,0)];return t.lines(r)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLine"),this.thickness!==0&&t.writeDouble(39,this.thickness);const e=Lt(this.startPoint,this.normal),i=Lt(this.endPoint,this.normal);return t.writePoint3d(10,e),t.writePoint3d(11,i),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbLine");let e=this.startPoint.x,i=this.startPoint.y,r=this.startPoint.z,s=this.endPoint.x,a=this.endPoint.y,o=this.endPoint.z,c=this.thickness,l=this.normal.x,h=this.normal.y,u=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const g=t.readItem();if(!g)break;const p=Number(g.code),f=Number(g.value);switch(p){case 10:e=f;break;case 20:i=f;break;case 30:r=f;break;case 11:s=f;break;case 21:a=f;break;case 31:o=f;break;case 39:c=f;break;case 210:l=f;break;case 220:h=f;break;case 230:u=f;break}}const d=new w(l,h,u);return d.lengthSq()>0&&this.normal.copy(d.normalize()),this.thickness=c,this.startPoint=he({x:e,y:i,z:r},this.normal),this.endPoint=he({x:s,y:a,z:o},this.normal),this}getOffsetCurves(t){const e=this._geo.offset(t);return[new ur(e.startPoint,e.endPoint)]}getOffsetSideAtPoint(t){const e=this.startPoint,i=this.endPoint;return(i.x-e.x)*(t.y-e.y)-(i.y-e.y)*(t.x-e.x)>=0?1:-1}};ur.typeName="Line";let Yi=ur;var ki=(n=>(n[n.InvisibleLeader=0]="InvisibleLeader",n[n.StraightLeader=1]="StraightLeader",n[n.SplineLeader=2]="SplineLeader",n))(ki||{}),Ge=(n=>(n[n.NoneContent=0]="NoneContent",n[n.BlockContent=1]="BlockContent",n[n.MTextContent=2]="MTextContent",n[n.ToleranceContent=3]="ToleranceContent",n))(Ge||{}),Fh=(n=>(n[n.Horizontal=0]="Horizontal",n[n.Vertical=1]="Vertical",n))(Fh||{}),Dh=(n=>(n[n.Unknown=0]="Unknown",n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.Top=3]="Top",n[n.Bottom=4]="Bottom",n))(Dh||{});const n0=1,r0=2,s0=4,a0=8,o0=64,c0=128,l0=32768,ya=class ya extends H{get dxfTypeName(){return"MULTILEADER"}constructor(){super(),this._leaders=[],this._leaderLineType=1,this._contentType=0,this._doglegEnabled=!1,this._doglegLength=0,this._doglegVector=new w(1,0,0),this._normal=new w(0,0,1),this._mleaderStyleId="",this._textHeight=2.5,this._textWidth=0,this._textRotation=0,this._textDirection=new w(1,0,0),this._textStyleName="",this._textAttachmentPoint=exports.AcGiMTextAttachmentPoint.MiddleLeft,this._textDrawingDirection=exports.AcGiMTextFlowDirection.LEFT_TO_RIGHT,this._textLineSpacingFactor=1,this._textAttachmentDirection=0,this._arrowheadOverrides=[],this._blockAttributes=[]}get leaders(){return this._leaders.map(t=>this.cloneLeader(t))}get numberOfLeaders(){return this._leaders.length}get leaderLineType(){return this._leaderLineType}set leaderLineType(t){this._leaderLineType=t}get contentType(){return this._contentType}set contentType(t){this._contentType=t}get doglegEnabled(){return this._doglegEnabled}set doglegEnabled(t){this._doglegEnabled=t}get doglegLength(){return this._doglegLength}set doglegLength(t){this._doglegLength=t}get doglegVector(){return this._doglegVector}set doglegVector(t){this._doglegVector.copy(t)}get landingPoint(){return this._landingPoint}set landingPoint(t){this._landingPoint=t?this.createPoint(t):void 0}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get mleaderStyleId(){return this._mleaderStyleId}set mleaderStyleId(t){this._mleaderStyleId=t}get version(){return this._version}set version(t){this._version=t}get leaderStyleId(){return this._leaderStyleId}set leaderStyleId(t){this._leaderStyleId=t}get propertyOverrideFlag(){return this._propertyOverrideFlag}set propertyOverrideFlag(t){this._propertyOverrideFlag=t}get leaderLineColor(){return this._leaderLineColor}set leaderLineColor(t){this._leaderLineColor=t==null?void 0:t.clone()}get leaderLineTypeId(){return this._leaderLineTypeId}set leaderLineTypeId(t){this._leaderLineTypeId=t}get leaderLineWeight(){return this._leaderLineWeight}set leaderLineWeight(t){this._leaderLineWeight=t}get landingEnabled(){return this._landingEnabled}set landingEnabled(t){this._landingEnabled=t}get arrowheadId(){return this._arrowheadId}set arrowheadId(t){this._arrowheadId=t}get arrowheadSize(){return this._arrowheadSize}set arrowheadSize(t){this._arrowheadSize=t}get textStyleId(){return this._textStyleId}set textStyleId(t){this._textStyleId=t}get textLeftAttachmentType(){return this._textLeftAttachmentType}set textLeftAttachmentType(t){this._textLeftAttachmentType=t}get textRightAttachmentType(){return this._textRightAttachmentType}set textRightAttachmentType(t){this._textRightAttachmentType=t}get textAngleType(){return this._textAngleType}set textAngleType(t){this._textAngleType=t}get textAlignmentType(){return this._textAlignmentType}set textAlignmentType(t){this._textAlignmentType=t}get textColor(){return this._textColor}set textColor(t){this._textColor=t==null?void 0:t.clone()}get textFrameEnabled(){return this._textFrameEnabled}set textFrameEnabled(t){this._textFrameEnabled=t}get landingGap(){return this._landingGap}set landingGap(t){this._landingGap=t}get textAttachment(){return this._textAttachment}set textAttachment(t){this._textAttachment=t}get textFlowDirection(){return this._textFlowDirection}set textFlowDirection(t){this._textFlowDirection=t}get blockContentId(){return this._blockContentId}set blockContentId(t){this._blockContentId=t}get blockContentColor(){return this._blockContentColor}set blockContentColor(t){this._blockContentColor=t==null?void 0:t.clone()}get blockContentScale(){return this._blockContentScale}set blockContentScale(t){this._blockContentScale=t}get blockContentRotation(){return this._blockContentRotation}set blockContentRotation(t){this._blockContentRotation=t}get blockContentConnectionType(){return this._blockContentConnectionType}set blockContentConnectionType(t){this._blockContentConnectionType=t}get annotativeScaleEnabled(){return this._annotativeScaleEnabled}set annotativeScaleEnabled(t){this._annotativeScaleEnabled=t}get arrowheadOverrides(){return this._arrowheadOverrides}set arrowheadOverrides(t){this._arrowheadOverrides=t}get blockAttributes(){return this._blockAttributes}set blockAttributes(t){this._blockAttributes=t}get textDirectionNegative(){return this._textDirectionNegative}set textDirectionNegative(t){this._textDirectionNegative=t}get textAlignInIPE(){return this._textAlignInIPE}set textAlignInIPE(t){this._textAlignInIPE=t}get bottomTextAttachmentDirection(){return this._bottomTextAttachmentDirection}set bottomTextAttachmentDirection(t){this._bottomTextAttachmentDirection=t}get topTextAttachmentDirection(){return this._topTextAttachmentDirection}set topTextAttachmentDirection(t){this._topTextAttachmentDirection=t}get contentScale(){return this._contentScale}set contentScale(t){this._contentScale=t}get contentBasePosition(){return this._contentBasePosition}set contentBasePosition(t){this._contentBasePosition=t}get textAnchor(){return this._textAnchor}set textAnchor(t){this._textAnchor=t}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(t){this._textLineSpacingStyle=t}get textBackgroundColor(){return this._textBackgroundColor}set textBackgroundColor(t){this._textBackgroundColor=t==null?void 0:t.clone()}get textBackgroundScaleFactor(){return this._textBackgroundScaleFactor}set textBackgroundScaleFactor(t){this._textBackgroundScaleFactor=t}get textBackgroundTransparency(){return this._textBackgroundTransparency}set textBackgroundTransparency(t){this._textBackgroundTransparency=t}get textBackgroundColorOn(){return this._textBackgroundColorOn}set textBackgroundColorOn(t){this._textBackgroundColorOn=t}get textFillOn(){return this._textFillOn}set textFillOn(t){this._textFillOn=t}get textColumnType(){return this._textColumnType}set textColumnType(t){this._textColumnType=t}get textUseAutoHeight(){return this._textUseAutoHeight}set textUseAutoHeight(t){this._textUseAutoHeight=t}get textColumnWidth(){return this._textColumnWidth}set textColumnWidth(t){this._textColumnWidth=t}get textColumnGutterWidth(){return this._textColumnGutterWidth}set textColumnGutterWidth(t){this._textColumnGutterWidth=t}get textColumnFlowReversed(){return this._textColumnFlowReversed}set textColumnFlowReversed(t){this._textColumnFlowReversed=t}get textColumnHeight(){return this._textColumnHeight}set textColumnHeight(t){this._textColumnHeight=t}get textUseWordBreak(){return this._textUseWordBreak}set textUseWordBreak(t){this._textUseWordBreak=t}get hasMText(){return this._hasMText}set hasMText(t){this._hasMText=t}get hasBlock(){return this._hasBlock}set hasBlock(t){this._hasBlock=t}get planeOrigin(){return this._planeOrigin}set planeOrigin(t){this._planeOrigin=t}get planeXAxisDirection(){return this._planeXAxisDirection}set planeXAxisDirection(t){this._planeXAxisDirection=t}get planeYAxisDirection(){return this._planeYAxisDirection}set planeYAxisDirection(t){this._planeYAxisDirection=t}get planeNormalReversed(){return this._planeNormalReversed}set planeNormalReversed(t){this._planeNormalReversed=t}get leaderSections(){return this.leaders}get blockContentData(){return this.blockContent}get mtextContent(){return this._mtextContent?{text:this._mtextContent.text,anchorPoint:this._mtextContent.anchorPoint.clone()}:void 0}set mtextContent(t){if(!t){this._mtextContent=void 0,this._contentType===2&&(this._contentType=0);return}this._mtextContent={text:t.text,anchorPoint:this.createPoint(t.anchorPoint)},this._contentType=2}get contents(){var t;return((t=this._mtextContent)==null?void 0:t.text)??""}set contents(t){this._mtextContent?this._mtextContent.text=t:this._mtextContent={text:t,anchorPoint:new y},this._contentType=2}get textLocation(){var t;return(t=this._mtextContent)==null?void 0:t.anchorPoint}set textLocation(t){if(!t){this._mtextContent=void 0;return}this._mtextContent?this._mtextContent.anchorPoint.copy(t):this._mtextContent={text:"",anchorPoint:this.createPoint(t)},this._contentType=2}get textHeight(){return this._textHeight}set textHeight(t){this._textHeight=t}get textWidth(){return this._textWidth}set textWidth(t){this._textWidth=t}get textRotation(){return this._textRotation}set textRotation(t){this._textRotation=t}get textDirection(){return this._textDirection}set textDirection(t){this._textDirection.copy(t)}get textStyleName(){return this._textStyleName}set textStyleName(t){this._textStyleName=t}get textAttachmentPoint(){return this._textAttachmentPoint}set textAttachmentPoint(t){this._textAttachmentPoint=t}get textDrawingDirection(){return this._textDrawingDirection}set textDrawingDirection(t){this._textDrawingDirection=t}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(t){this._textLineSpacingFactor=t}get textAttachmentDirection(){return this._textAttachmentDirection}set textAttachmentDirection(t){this._textAttachmentDirection=t}get blockContent(){var t,e,i;return this._blockContent?{blockContentId:this._blockContent.blockContentId,blockHandle:this._blockContent.blockHandle,normal:(t=this._blockContent.normal)==null?void 0:t.clone(),position:(e=this._blockContent.position)==null?void 0:e.clone(),scale:this._blockContent.scale.clone(),rotation:this._blockContent.rotation,color:(i=this._blockContent.color)==null?void 0:i.clone(),transformationMatrix:[...this._blockContent.transformationMatrix]}:void 0}set blockContent(t){var e;if(!t){this._blockContent=void 0,this._contentType===1&&(this._contentType=0);return}this._blockContent={blockContentId:t.blockContentId??t.blockHandle,blockHandle:t.blockHandle,normal:t.normal?new w(t.normal):void 0,position:t.position?this.createPoint(t.position):void 0,scale:new w(t.scale??{x:1,y:1,z:1}),rotation:t.rotation??0,color:(e=t.color)==null?void 0:e.clone(),transformationMatrix:t.transformationMatrix?[...t.transformationMatrix]:[]},this.blockContentId=this._blockContent.blockContentId,this._contentType=1}addLeader(t={}){var i,r;const e={lastLeaderLinePoint:t.lastLeaderLinePoint?this.createPoint(t.lastLeaderLinePoint):void 0,lastLeaderLinePointSet:t.lastLeaderLinePointSet,landingPoint:t.landingPoint?this.createPoint(t.landingPoint):void 0,doglegVector:t.doglegVector?new w(t.doglegVector):void 0,doglegVectorSet:t.doglegVectorSet,doglegLength:t.doglegLength,breaks:((i=t.breaks)==null?void 0:i.map(s=>({index:s.index,start:this.createPoint(s.start),end:this.createPoint(s.end)})))??[],leaderBranchIndex:t.leaderBranchIndex,directionType:t.directionType,leaderLines:[]};return(r=t.leaderLines)==null||r.forEach(s=>{e.leaderLines.push(this.createLeaderLine(s))}),this._leaders.push(e),this._leaders.length-1}removeLeader(t){return this.checkLeaderIndex(t),this._leaders.splice(t,1),this}addLeaderLine(t,e=[]){return this.checkLeaderIndex(t),this._leaders[t].leaderLines.push(this.createLeaderLine({vertices:e})),this._leaders[t].leaderLines.length-1}appendVertex(t,e,i){return this.getMutableLeaderLine(t,e).vertices.push(this.createPoint(i)),this}setLeaderLineVertices(t,e,i){return this.getMutableLeaderLine(t,e).vertices=i.map(r=>this.createPoint(r)),this}getLeaderLineVertices(t,e){return this.getMutableLeaderLine(t,e).vertices.map(i=>i.clone())}addBreak(t,e,i,r){return this.getMutableLeaderLine(t,e).breaks.push({start:this.createPoint(i),end:this.createPoint(r)}),this}setLandingPoint(t,e){return this.checkLeaderIndex(t),this._leaders[t].landingPoint=e?this.createPoint(e):void 0,this}setDoglegDirection(t,e){return this.checkLeaderIndex(t),this._leaders[t].doglegVector=new w(e),this}setDoglegLength(t,e){return this.checkLeaderIndex(t),this._leaders[t].doglegLength=e,this}get geometricExtents(){const t=this.collectGeometryPoints();return t.length>0?new Y().setFromPoints(t):new Y}subGetGripPoints(){return this.collectGeometryPoints().map(t=>t.clone())}subMoveGripPointsAt(t,e){return ht(t,i=>{this.moveGeometryGripPointAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){var s;if(t===k.Insertion){this.contentBasePosition?r.push(this.contentBasePosition):this._mtextContent?r.push(this._mtextContent.anchorPoint):(s=this._blockContent)!=null&&s.position&&r.push(this._blockContent.position);return}this._leaders.forEach(a=>{a.leaderLines.forEach(o=>{const c=this.getLeaderLineDrawPoints(a,o);if(c.length!==0)switch(t){case k.EndPoint:r.push(...c);break;case k.MidPoint:case k.Nearest:case k.Perpendicular:{const l=[];for(let h=0;h<c.length-1;h++){const u=[];li(c[h],c[h+1],t,e,u),l.push(...u)}if(t===k.MidPoint)r.push(...l);else{const h=Ft(e,l);h&&r.push(h)}break}}})})}transformBy(t){var e,i,r,s,a,o,c,l;return this._leaders.forEach(h=>{var u,d;(u=h.lastLeaderLinePoint)==null||u.applyMatrix4(t),(d=h.landingPoint)==null||d.applyMatrix4(t),h.doglegVector&&this.transformVector(h.doglegVector,t),h.breaks.forEach(g=>{g.start.applyMatrix4(t),g.end.applyMatrix4(t)}),h.leaderLines.forEach(g=>{g.vertices.forEach(p=>p.applyMatrix4(t)),g.breaks.forEach(p=>{p.start.applyMatrix4(t),p.end.applyMatrix4(t)})})}),(e=this._landingPoint)==null||e.applyMatrix4(t),(i=this.contentBasePosition)==null||i.applyMatrix4(t),this.transformVector(this._doglegVector,t),this.transformVector(this._normal,t),(r=this.textAnchor)==null||r.applyMatrix4(t),(s=this._mtextContent)==null||s.anchorPoint.applyMatrix4(t),this.transformVector(this._textDirection,t),(o=(a=this._blockContent)==null?void 0:a.position)==null||o.applyMatrix4(t),(c=this._blockContent)!=null&&c.normal&&this.transformVector(this._blockContent.normal,t),this.blockContentScale&&this.transformVector(this.blockContentScale,t),(l=this.planeOrigin)==null||l.applyMatrix4(t),this.planeXAxisDirection&&this.transformVector(this.planeXAxisDirection,t),this.planeYAxisDirection&&this.transformVector(this.planeYAxisDirection,t),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"leader",properties:[{name:"contentType",type:"enum",editable:!0,options:[{label:Ge[0],value:0},{label:Ge[1],value:1},{label:Ge[2],value:2},{label:Ge[3],value:3}],accessor:{get:()=>this.contentType,set:t=>{this.contentType=t}}},{name:"leaderLineType",type:"enum",editable:!0,options:[{label:ki[0],value:0},{label:ki[1],value:1},{label:ki[2],value:2}],accessor:{get:()=>this.leaderLineType,set:t=>{this.leaderLineType=t}}},{name:"doglegEnabled",type:"boolean",editable:!0,accessor:{get:()=>this.doglegEnabled,set:t=>{this.doglegEnabled=t}}},{name:"doglegLength",type:"float",editable:!0,accessor:{get:()=>this.doglegLength,set:t=>{this.doglegLength=t}}},{name:"leaderCount",type:"int",editable:!1,accessor:{get:()=>this.numberOfLeaders}}]},{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:t=>{this.contents=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.textHeight,set:t=>{this.textHeight=t}}},{name:"textWidth",type:"float",editable:!0,accessor:{get:()=>this.textWidth,set:t=>{this.textWidth=t}}},{name:"textStyleName",type:"string",editable:!0,accessor:{get:()=>this.textStyleName,set:t=>{this.textStyleName=t}}}]}]}}resolveEffectiveProperties(){if(super.resolveEffectiveProperties(),this._mleaderStyleId)return;const t=this.getDefaultMLeaderStyle();t&&(this._mleaderStyleId=t.objectId)}subWorldDraw(t,e){const i=[],r=t.subEntityTraits,s=r.color,a=r.lineType,o=r.lineWeight,c=this.getResolvedLeaderLineColor(),l=this.getResolvedLeaderLineStyle(),h=this.getResolvedLeaderLineWeight(),u=this.getResolvedTextColor();this.getResolvedLeaderLineType()!==0&&(this.applyColorTraits(r,c,s),this.applyLineTraits(r,l,h),this._leaders.forEach(p=>{p.leaderLines.forEach(m=>{const b=this.getLeaderLineDrawPoints(p,m);if(b.length>0){const _=this.drawLeaderLine(t,b);_&&i.push(_)}});const f=this.getDoglegPoints(p);f&&i.push(t.lines(f))}));const d=this.getRenderableMTextContent();if(!!d&&(this.contentType===2||this.contentType===0||this.hasMText===!0)&&d){this.applyColorTraits(r,u,s);const p=this.getResolvedTextHeight(),f={text:d.text,height:p,width:this.getMTextRenderWidth(d.text,p),position:d.anchorPoint,rotation:this.textRotation,directionVector:this.textDirection,attachmentPoint:this.textAttachmentPoint,drawingDirection:this.textDrawingDirection,lineSpaceFactor:this.textLineSpacingFactor};i.push(t.mtext(f,this.getTextStyle(),e))}if(r.color=s,r.lineType=a,r.lineWeight=o,i.length!==0)return i.length===1?i[0]:t.group(i)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMLeader"),t.writeInt16(170,this.leaderLineType),t.writeBoolean(290,this.doglegEnabled),t.writeDouble(41,this.doglegLength),t.writeInt16(172,this.contentType),t.writeVector3d(210,this.normal),t.writeHandle(340,this.mleaderStyleId),this._landingPoint&&t.writePoint3d(10,this._landingPoint),t.writeVector3d(11,this.doglegVector),this._mtextContent&&(t.writeString(1,this._mtextContent.text),t.writePoint3d(12,this._mtextContent.anchorPoint),t.writeDouble(40,this.textHeight),t.writeDouble(42,this.textWidth),t.writeAngle(50,this.textRotation),t.writeString(7,this.textStyleName)),this._blockContent&&(t.writeHandle(341,this._blockContent.blockContentId??""),this._blockContent.position&&t.writePoint3d(15,this._blockContent.position),t.writeVector3d(16,this._blockContent.scale),t.writeAngle(52,this._blockContent.rotation)),this._leaders.forEach(e=>{e.landingPoint&&t.writePoint3d(110,e.landingPoint),e.doglegVector&&t.writeVector3d(111,e.doglegVector),t.writeDouble(140,e.doglegLength),t.writeInt16(171,e.leaderLines.length),e.leaderLines.forEach(i=>{t.writeInt16(90,i.vertices.length),i.vertices.forEach(r=>t.writePoint3d(10,r))})}),this}dxfInFields(t){var E,O,T,R,N,M,A,V,$,Q,et,W,Dt,B,Yt;super.dxfInFields(t),t.atSubclassData("AcDbMLeader"),this._leaders.length=0;let e=(E=this._mtextContent)==null?void 0:E.text,i=(T=(O=this._mtextContent)==null?void 0:O.anchorPoint)==null?void 0:T.clone(),r=!!this._mtextContent,s=(R=this._blockContent)==null?void 0:R.blockContentId,a=(M=(N=this._blockContent)==null?void 0:N.position)==null?void 0:M.clone(),o=(V=(A=this._blockContent)==null?void 0:A.scale)==null?void 0:V.clone(),c=($=this._blockContent)==null?void 0:$.rotation,l=(et=(Q=this._blockContent)==null?void 0:Q.normal)==null?void 0:et.clone(),h=(Dt=(W=this._blockContent)==null?void 0:W.color)==null?void 0:Dt.clone(),u=(B=this._blockContent)!=null&&B.transformationMatrix?[...this._blockContent.transformationMatrix]:[],d=!!this._blockContent,g=!1,p=!1,f=(Yt=this._landingPoint)==null?void 0:Yt.clone(),m=this._doglegVector.clone(),b=null,_=null,v=!1,x;const S=()=>{_&&b&&b.leaderLines.push(_),_=null},P=()=>{S(),b&&this.addLeader(b),b=null};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const st=t.readItem();if(!st)break;const du=Number(st.code),G=Number(st.value),ut=String(st.value??"");switch(du){case 100:return t.pushBackItem(st),P(),this.finishMLeaderDxfIn(e,i,r,s,a,o,c,l,h,u,d,g,f,m,x),this;case 300:if(ut==="CONTEXT_DATA{"){p=!0;const F=this.dxfInContextData(t);F.textContent!=null&&(e=F.textContent,r=!0),F.textAnchor&&(i=F.textAnchor,r=!0),F.hasMText!=null&&(this.hasMText=F.hasMText),F.hasBlock!=null&&(this.hasBlock=F.hasBlock),F.blockContentId&&(s=F.blockContentId,d=this.isValidMLeaderHandle(F.blockContentId)),F.blockPosition&&(a=F.blockPosition,d=!0),F.blockScale&&(o=F.blockScale,d=!0),F.blockRotation!=null&&(c=F.blockRotation,d=!0),F.blockNormal&&(l=F.blockNormal,d=!0),F.blockColor&&(h=F.blockColor,d=!0),F.blockMatrix.length>0&&(u=F.blockMatrix,d=!0),r&&!g&&(this.contentType=2,g=!0)}break;case 270:p=!0,this.version=G;break;case 340:this.leaderStyleId=ut,this.mleaderStyleId=ut;break;case 90:v?(S(),_={vertices:[],breakPointIndexes:[],breaks:[]}):this.propertyOverrideFlag=G;break;case 170:this.leaderLineType=G;break;case 91:this.leaderLineColor=Zt(G);break;case 341:p?this.leaderLineTypeId=ut:this.isValidMLeaderHandle(ut)?(s=ut,d=!0):this.leaderLineTypeId=ut;break;case 171:v||(this.leaderLineWeight=G);break;case 290:p?this.landingEnabled=this.readDxfBoolean(st):this.doglegEnabled=this.readDxfBoolean(st);break;case 291:this.doglegEnabled=this.readDxfBoolean(st);break;case 40:p?this.doglegLength=G:this.textHeight=G;break;case 41:this.doglegLength=G;break;case 342:this.arrowheadId=ut;break;case 42:p?this.arrowheadSize=G:this.textWidth=G;break;case 172:this.contentType=G,g=!0;break;case 343:this.textStyleId=ut;break;case 173:this.textLeftAttachmentType=G;break;case 95:this.textRightAttachmentType=G;break;case 174:this.textAngleType=G;break;case 175:this.textAlignmentType=G;break;case 92:this.textColor=Zt(G);break;case 292:this.textFrameEnabled=this.readDxfBoolean(st);break;case 344:this.isValidMLeaderHandle(ut)&&(s=ut,this.blockContentId=ut,d=!0);break;case 93:this.blockContentColor=Zt(G);break;case 10:if(v){t.pushBackItem(st);const F=t.readPoint3d(10);F&&_&&_.vertices.push(F)}else{t.pushBackItem(st);const F=t.readPoint3d(10);if(!F)break;p?(this.blockContentScale=new w(F),o=new w(F),d=!0):f=F}break;case 43:this.blockContentRotation=G,c=G,d=!0;break;case 176:this.blockContentConnectionType=G;break;case 293:this.annotativeScaleEnabled=this.readDxfBoolean(st);break;case 94:{this.arrowheadOverrides.push({index:G});break}case 345:{const F=this.arrowheadOverrides[this.arrowheadOverrides.length-1];F?F.handle=ut:this.arrowheadOverrides.push({index:0,handle:ut});break}case 330:this.blockAttributes.push({id:ut});break;case 177:{const F=this.blockAttributes[this.blockAttributes.length-1];F&&(F.index=G);break}case 44:{const F=this.blockAttributes[this.blockAttributes.length-1];F&&(F.width=G);break}case 302:{const F=this.blockAttributes[this.blockAttributes.length-1];F&&(F.text=ut);break}case 294:this.textDirectionNegative=this.readDxfBoolean(st);break;case 178:this.textAlignInIPE=G;break;case 179:G!==0&&(this.textAttachmentPoint=G);break;case 271:this.textAttachmentDirection=G;break;case 272:this.bottomTextAttachmentDirection=G;break;case 273:this.topTextAttachmentDirection=G;break;case 210:t.pushBackItem(st);{const F=t.readVector3d(210);F&&(this.normal=F)}break;case 110:P(),v=!0,t.pushBackItem(st),b={landingPoint:t.readPoint3d(110),doglegVector:new w(1,0,0),doglegLength:0,breaks:[],leaderLines:[]};break;case 111:if(b){t.pushBackItem(st);const F=t.readVector3d(111);F&&(b.doglegVector=F)}break;case 140:b?b.doglegLength=G:this.arrowheadSize=G;break;case 1:e=ut,r=!0;break;case 12:t.pushBackItem(st);{const F=t.readPoint3d(12);F&&(i=F,r=!0)}break;case 7:this.textStyleName=ut;break;case 50:x=G;break;case 15:t.pushBackItem(st);{const F=t.readPoint3d(15);F&&(a=F,d=!0)}break;case 16:t.pushBackItem(st);{const F=t.readVector3d(16);F&&(o=F,d=!0)}break;case 52:c=G*Math.PI/180,d=!0;break;case 11:if(!v&&!p){t.pushBackItem(st);const F=t.readVector3d(11);F&&(m=F)}break}}return P(),this.finishMLeaderDxfIn(e,i,r,s,a,o,c,l,h,u,d,g,f,m,x),this}finishMLeaderDxfIn(t,e,i,r,s,a,o,c,l,h,u,d,g,p,f){if(g&&(this.landingPoint=g),this.doglegVector=p,f!=null&&(this.textRotation=f*Math.PI/180),!this.textStyleName&&this.textStyleId){const b=this.database.tables.textStyleTable.getIdAt(this.textStyleId);b!=null&&b.name&&(this.textStyleName=b.name)}const m=e??this.textAnchor??this.contentBasePosition??g;(i||this.hasMText)&&t!=null&&m?(this.mtextContent={text:t,anchorPoint:m.clone()},this.textAnchor||(this.textAnchor=m.clone()),d||(this.contentType=2)):(i||this.hasMText)&&t!=null&&!m&&(d||(this.contentType=2)),u&&this.isValidMLeaderHandle(r)&&this.contentType!==2&&!this.mtextContent&&(this.blockContent={blockContentId:r,position:s,scale:a??new w(1,1,1),rotation:o??0,normal:c,color:l,transformationMatrix:h},!d&&this.contentType===0&&(this.contentType=1))}dxfInContextData(t){const e={blockMatrix:[]};for(;!t.atEof;){const i=t.readItem();if(!i)break;const r=Number(i.code),s=Number(i.value),a=String(i.value??"");if(r===301)break;if(r===0){t.pushBackItem(i);break}switch(r){case 10:t.pushBackItem(i),this.contentBasePosition=t.readPoint3d(10);break;case 11:t.pushBackItem(i);{const o=t.readVector3d(11);o&&(this.normal=o)}break;case 12:t.pushBackItem(i);{const o=t.readPoint3d(12);o&&(e.textAnchor=o,this.textAnchor=o.clone())}break;case 13:t.pushBackItem(i);{const o=t.readVector3d(13);o&&(this.textDirection=o)}break;case 14:t.pushBackItem(i),e.blockNormal=t.readVector3d(14);break;case 15:t.pushBackItem(i),e.blockPosition=t.readPoint3d(15);break;case 16:t.pushBackItem(i),e.blockScale=t.readVector3d(16);break;case 40:this.contentScale=s;break;case 41:s>0&&(this.textHeight=s);break;case 42:this.textRotation=s;break;case 43:s>0&&(this.textWidth=s);break;case 44:s>0&&(this.textHeight=s);break;case 45:this.textLineSpacingFactor=s;break;case 46:e.blockRotation=s;break;case 47:e.blockMatrix.push(s);break;case 90:this.textColor=Zt(s);break;case 91:this.textBackgroundColor=Zt(s);break;case 92:this.textBackgroundTransparency=s;break;case 93:e.blockColor=Zt(s);break;case 110:t.pushBackItem(i),this.planeOrigin=t.readPoint3d(110);break;case 111:t.pushBackItem(i),this.planeXAxisDirection=t.readVector3d(111);break;case 112:t.pushBackItem(i),this.planeYAxisDirection=t.readVector3d(112);break;case 140:this.arrowheadSize=s;break;case 141:this.textBackgroundScaleFactor=s;break;case 142:this.textColumnWidth=s;break;case 143:this.textColumnGutterWidth=s;break;case 144:this.textColumnHeight=s;break;case 145:this.landingGap=s;break;case 170:this.textLineSpacingStyle=s;break;case 171:this.textAttachment=s;break;case 172:this.textFlowDirection=s;break;case 173:this.textColumnType=s;break;case 290:e.hasMText=this.readDxfBoolean(i),this.hasMText=e.hasMText;break;case 291:this.textBackgroundColorOn=this.readDxfBoolean(i);break;case 292:this.textFillOn=this.readDxfBoolean(i);break;case 293:this.textUseAutoHeight=this.readDxfBoolean(i);break;case 294:this.textColumnFlowReversed=this.readDxfBoolean(i);break;case 295:this.textUseWordBreak=this.readDxfBoolean(i);break;case 296:e.hasBlock=this.readDxfBoolean(i),this.hasBlock=e.hasBlock;break;case 297:this.planeNormalReversed=this.readDxfBoolean(i);break;case 302:if(a==="LEADER{"){const o=this.dxfInLeaderSection(t);this.addLeader(o)}break;case 304:a!=="LEADER_LINE{"&&(e.textContent=a,this.hasMText=!0);break;case 340:this.textStyleId=a;break;case 341:e.blockContentId=a,this.isValidMLeaderHandle(a)&&(this.blockContentId=a);break}}return e}dxfInLeaderSection(t){const e={breaks:[],leaderLines:[]};let i;const r=()=>{i&&(e.breaks.push(i),i=void 0)};for(;!t.atEof;){const s=t.readItem();if(!s)break;const a=Number(s.code),o=Number(s.value),c=String(s.value??"");if(a===303){r();break}if(a===0||a===301){t.pushBackItem(s),r();break}switch(a){case 290:e.lastLeaderLinePointSet=this.readDxfBoolean(s);break;case 291:e.doglegVectorSet=this.readDxfBoolean(s);break;case 10:t.pushBackItem(s),e.lastLeaderLinePoint=t.readPoint3d(10);break;case 11:t.pushBackItem(s),e.doglegVector=t.readVector3d(11);break;case 12:t.pushBackItem(s);{const l=t.readPoint3d(12);l&&(i={start:l,end:l.clone()})}break;case 13:t.pushBackItem(s);{const l=t.readPoint3d(13);i&&l&&(i.end=l,r())}break;case 90:e.leaderBranchIndex=o;break;case 40:e.doglegLength=o;break;case 304:c==="LEADER_LINE{"&&e.leaderLines.push(this.dxfInLeaderLine(t));break}}return e}dxfInLeaderLine(t){const e={vertices:[],breakPointIndexes:[],breaks:[]};let i;const r=()=>{i&&(e.breaks.push(i),i=void 0)};for(;!t.atEof;){const s=t.readItem();if(!s)break;const a=Number(s.code),o=Number(s.value);if(a===305){r();break}if(a===0||a===303||a===301){t.pushBackItem(s),r();break}switch(a){case 10:t.pushBackItem(s);{const c=t.readPoint3d(10);c&&e.vertices.push(c)}break;case 11:t.pushBackItem(s);{const c=t.readPoint3d(11);c&&(i={index:i==null?void 0:i.index,start:c,end:c.clone()})}break;case 12:t.pushBackItem(s);{const c=t.readPoint3d(12);i&&c&&(i.end=c,r())}break;case 90:e.breakPointIndexes.push(o),i={index:o,start:(i==null?void 0:i.start)??new y,end:(i==null?void 0:i.end)??new y};break;case 91:e.leaderLineIndex=o;break}}return e}readDxfBoolean(t){if(typeof t.value=="boolean")return t.value;const e=Number(t.value);if(Number.isFinite(e))return e!==0;const i=String(t.value??"");return i!==""&&i!=="0"}isValidMLeaderHandle(t){return t!=null&&t!==""&&t!=="0"}createPoint(t){return new y().copy(t)}createLeaderLine(t){var e,i;return{vertices:((e=t.vertices)==null?void 0:e.map(r=>this.createPoint(r)))??[],breakPointIndexes:t.breakPointIndexes?[...t.breakPointIndexes]:[],leaderLineIndex:t.leaderLineIndex,breaks:((i=t.breaks)==null?void 0:i.map(r=>({index:r.index,start:this.createPoint(r.start),end:this.createPoint(r.end)})))??[]}}cloneLeader(t){var e,i,r;return{lastLeaderLinePoint:(e=t.lastLeaderLinePoint)==null?void 0:e.clone(),lastLeaderLinePointSet:t.lastLeaderLinePointSet,landingPoint:(i=t.landingPoint)==null?void 0:i.clone(),doglegVector:(r=t.doglegVector)==null?void 0:r.clone(),doglegVectorSet:t.doglegVectorSet,doglegLength:t.doglegLength,breaks:t.breaks.map(s=>({index:s.index,start:s.start.clone(),end:s.end.clone()})),leaderBranchIndex:t.leaderBranchIndex,directionType:t.directionType,leaderLines:t.leaderLines.map(s=>({vertices:s.vertices.map(a=>a.clone()),breakPointIndexes:[...s.breakPointIndexes],leaderLineIndex:s.leaderLineIndex,breaks:s.breaks.map(a=>({index:a.index,start:a.start.clone(),end:a.end.clone()}))}))}}checkLeaderIndex(t){if(t<0||t>=this._leaders.length)throw new Error("The leader index is out of range!")}getMutableLeaderLine(t,e){this.checkLeaderIndex(t);const i=this._leaders[t].leaderLines[e];if(!i)throw new Error("The leader line index is out of range!");return i}collectGeometryPoints(){var e;const t=[];return this._leaders.forEach(i=>{i.lastLeaderLinePoint&&t.push(i.lastLeaderLinePoint),i.landingPoint&&t.push(i.landingPoint),i.breaks.forEach(s=>t.push(s.start,s.end)),i.leaderLines.forEach(s=>{t.push(...s.vertices),s.breaks.forEach(a=>t.push(a.start,a.end))});const r=this.getDoglegPoints(i);r&&t.push(...r),i.leaderLines.forEach(s=>{const a=this.getArrowheadPoints(this.getLeaderLineDrawPoints(i,s));a&&t.push(...a)})}),this._landingPoint&&t.push(this._landingPoint),this.contentBasePosition&&t.push(this.contentBasePosition),this.textAnchor&&t.push(this.textAnchor),this._mtextContent&&t.push(this._mtextContent.anchorPoint),(e=this._blockContent)!=null&&e.position&&t.push(this._blockContent.position),this.planeOrigin&&t.push(this.planeOrigin),t}moveGeometryGripPointAt(t,e){var s;let i=0;const r=(a,o)=>{if(a){i===t&&a.add(e),i++;return}o&&(i===t&&o(),i++)};this._leaders.forEach(a=>{r(a.lastLeaderLinePoint),r(a.landingPoint),a.breaks.forEach(c=>{r(c.start),r(c.end)}),a.leaderLines.forEach(c=>{c.vertices.forEach(l=>r(l)),c.breaks.forEach(l=>{r(l.start),r(l.end)})});const o=this.getDoglegPoints(a);o&&(r(o[0]),r(void 0,()=>{const c=o[0],l=o[1];if(!c||!l)return;const h=c.distanceTo({x:l.x+e.x,y:l.y+e.y,z:(l.z??0)+(e.z??0)});a.doglegLength!=null||a.doglegVectorSet?a.doglegLength=h:this._doglegLength=h})),a.leaderLines.forEach(c=>{const l=this.getLeaderLineDrawPoints(a,c),h=this.getArrowheadPoints(l);h&&h.forEach((u,d)=>{d===0||d===h.length-1?r(l[0]):r(void 0)})})}),r(this._landingPoint),r(this.contentBasePosition),r(this.textAnchor),this._mtextContent&&r(this._mtextContent.anchorPoint),(s=this._blockContent)!=null&&s.position&&r(this._blockContent.position),r(this.planeOrigin)}getLeaderLineDrawPoints(t,e){if(e.vertices.length>=2)return e.vertices;if(e.vertices.length===0)return[];const i=t.lastLeaderLinePoint??t.landingPoint??this._landingPoint??this.contentBasePosition;return!i||e.vertices[0].equals(i)?e.vertices:[e.vertices[0],i]}getDoglegPoints(t){if(!this.getResolvedDoglegEnabled())return;const e=t.lastLeaderLinePoint??t.landingPoint??this._landingPoint,i=t.doglegVector??this._doglegVector,r=t.doglegLength??this.getResolvedDoglegLength();if(!e||r==null||r===0||i.lengthSq()===0)return;const s=e.clone().add(i.clone().normalize().multiplyScalar(r));return[e,s]}getArrowheadPoints(t){if(!this.isArrowheadVisible()||t.length<2)return;const e=this.getArrowheadFrame(t);if(!e)return;const i=this.getResolvedArrowheadSize(),{tip:r,unit:s}=e,a=r.clone().add(s.clone().multiplyScalar(i)),o=i/6,c=new w(-s.y,s.x,0),l=a.clone().add(c.clone().multiplyScalar(o)),h=a.clone().add(c.clone().multiplyScalar(-o));return[r,l,h,r]}isArrowheadVisible(){const t=this.getResolvedArrowheadId();return(t==null?void 0:t.toUpperCase())==="_NONE"?!1:this.getResolvedArrowheadSize()>0}drawLeaderLine(t,e){const i=[],r=this.getLeaderLinePointsForDraw(e);r.length>=2&&i.push(t.lines(r));const s=this.drawArrowhead(t,e);if(s&&i.push(s),i.length!==0)return i.length===1?i[0]:t.group(i)}getLeaderLinePointsForDraw(t){const e=this.getArrowheadLeaderLineTrimDistance();return e<=0?t:this.trimPolylineStart(t,e)}getArrowheadLeaderLineTrimDistance(){if(!this.isArrowheadVisible())return 0;const t=this.getResolvedArrowheadBlockTableRecord();if(!t)return 0;const e=this.getResolvedArrowheadSize();if(e<=0)return 0;const i=t.origin??y.ORIGIN;let r=i.x;for(const s of t.newIterator()){const a=s.geometricExtents;a.isEmpty()||a.max.x>r&&(r=a.max.x)}return Math.max(0,(r-i.x)*e)}trimPolylineStart(t,e){if(t.length<2||e<=0)return t;let i=e;for(let r=0;r<t.length-1;r++){const s=t[r],a=t[r+1],o=a.distanceTo(s);if(!(o<=0)){if(i<o){const c=new w().subVectors(a,s);return[s.clone().add(c.multiplyScalar(i/o)),...t.slice(r+1)]}i-=o}}return[t[t.length-1]]}drawArrowhead(t,e){if(!this.isArrowheadVisible())return;const i=this.drawArrowheadBlock(t,e);if(i)return i;const r=this.getArrowheadPoints(e);if(!r)return;const s=new Vt;s.add(new q(r,!0));const a=t.subEntityTraits,o=a.fillType;a.fillType={solidFill:!0,patternAngle:0,definitionLines:[]};const c=t.area(s);return a.fillType=o,c}drawArrowheadBlock(t,e){const i=this.getResolvedArrowheadBlockTableRecord();if(!i)return;const r=this.getArrowheadFrame(e);if(!r)return;const{tip:s,unit:a}=r,o=this.getResolvedArrowheadSize(),c=Math.atan2(a.y,a.x),l=i.origin??y.ORIGIN,h=new D().makeTranslation(-l.x,-l.y,-l.z),u=new D().makeScale(o,o,o),d=new D().makeRotationZ(c),g=new D().makeTranslation(s.x,s.y,s.z),p=new D().multiplyMatrices(g,d).multiply(u).multiply(h);return Se.instance.draw(t,i,this.resolvedColor,[],!0,p,new w(this.normal))}getArrowheadFrame(t){if(t.length<2)return;const e=t[0],i=t.find(s=>!s.equals(e));if(!i)return;const r=new w().subVectors(i,e);if(r.lengthSq()!==0)return{tip:e,unit:r.normalize()}}getResolvedArrowheadId(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.arrowSymbolId;return this.arrowheadId??t}getResolvedArrowheadBlockTableRecord(){const t=this.getResolvedArrowheadId();if(t)return this.database.tables.blockTable.getIdAt(t)}getResolvedArrowheadSize(){const t=this.getMLeaderStyle(),e=(t==null?void 0:t.arrowSize)??(t==null?void 0:t.scale);return this.arrowheadSize??this.contentScale??e??this.getResolvedTextHeight()}getResolvedTextHeight(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.textHeight;return this.textHeight>0?this.textHeight:t!=null&&t>0?t:2.5}getRenderableMTextContent(){var i;if(this._mtextContent)return{text:this._mtextContent.text,anchorPoint:this._mtextContent.anchorPoint};const t=(i=this.getMLeaderStyle())==null?void 0:i.defaultMTextContents,e=this.textAnchor??this.contentBasePosition??this._landingPoint;if(!(!t||!e))return{text:t,anchorPoint:e}}getMTextRenderWidth(t,e){if(this._textWidth>0)return this._textWidth;if(!t)return this._textWidth;const i=t.replace(/\\[PpNn]/g,`
13
- `).replace(/\\[A-Za-z][^;]*;/g,"").replace(/[{}]/g,""),r=Math.max(...i.split(/\r\n|\r|\n/g).map(s=>s.length),1);return Math.max(e,r*e)}transformVector(t,e){const i=new y,r=new y(t.x,t.y,t.z);i.applyMatrix4(e),r.applyMatrix4(e),t.set(r.x-i.x,r.y-i.y,r.z-i.z)}getMLeaderStyle(){var i,r;const t=this.database.objects.mleaderStyle,e=(i=this.mleaderStyleId||this.leaderStyleId)==null?void 0:i.trim();if(e){const s=t.getIdAt(e);if(s)return s;const a=e.toUpperCase();for(const[,c]of t.entries())if(((r=c.objectId)==null?void 0:r.toUpperCase())===a)return c;const o=this.database.getObjectById(e);if(o instanceof Pr)return o}return this.getDefaultMLeaderStyle()}getDefaultMLeaderStyle(){const t=this.resolveMLeaderStyleByName(this.getDefaultMLeaderStyleName());return t||this.database.objects.mleaderStyle.newIterator().toArray()[0]}resolveMLeaderStyleByName(t){const e=t==null?void 0:t.trim();if(!e)return;const i=this.database.objects.mleaderStyle,r=i.getAt(e);if(r)return r;const s=i.getIdAt(e);if(s)return s;const a=e.toUpperCase();for(const[o,c]of i.entries())if(o.toUpperCase()===a)return c}getDefaultMLeaderStyleName(){try{return this.database.cmleaderstyle||ce}catch{return ce}}getResolvedTextStyleName(){var s,a,o;const t=this.database.tables.textStyleTable,e=(s=this.getMLeaderStyle())==null?void 0:s.textStyleId,i=e?(a=t.getIdAt(e))==null?void 0:a.name:void 0,r=this.textStyleId?(o=t.getIdAt(this.textStyleId))==null?void 0:o.name:void 0;if(this.textStyleName){const c=t.getAt(this.textStyleName);if(c!=null&&c.name)return c.name;const l=t.getIdAt(this.textStyleName);if(l!=null&&l.name)return l.name}return r||i}getTextStyle(){const t=this.database.tables.textStyleTable.resolveAt(this.getResolvedTextStyleName());if(!t)throw new Error("No valid text style found in text style table.");return t.textStyle}getResolvedLeaderLineColor(){var t;return this.getResolvedComponentColor(this.leaderLineColor,(t=this.getMLeaderStyle())==null?void 0:t.leaderLineColor,r0)}getResolvedLeaderLineType(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.leaderLineType;return this.getResolvedStyleDrivenValue(this.leaderLineType,t,n0)}getResolvedLeaderLineTypeId(){var t;return this.getResolvedStyleDrivenValue(this.leaderLineTypeId,(t=this.getMLeaderStyle())==null?void 0:t.leaderLineTypeId,s0)}getResolvedLeaderLineStyle(){const t=this.getResolvedLeaderLineTypeId();if(!t)return;const e=this.database.tables.linetypeTable.getIdAt(t);if(e)return{type:"UserSpecified",...e.linetype}}getResolvedLeaderLineWeight(){var i;const t=(i=this.getMLeaderStyle())==null?void 0:i.leaderLineWeight,e=this.getResolvedStyleDrivenValue(this.leaderLineWeight,t,a0);if(e!=null)return e}getResolvedDoglegEnabled(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.doglegEnabled;return this.getResolvedStyleDrivenValue(this.doglegEnabled,t,o0)}getResolvedDoglegLength(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.doglegLength;return this.getResolvedStyleDrivenValue(this.doglegLength,t,c0)}getResolvedTextColor(){var t;return this.getResolvedComponentColor(this.textColor,(t=this.getMLeaderStyle())==null?void 0:t.textColor,l0)}getResolvedComponentColor(t,e,i){if(!t)return e;if(!t.isByBlock&&!t.isByLayer)return t;const r=this.isPropertyOverrideEnabled(i);return r===!0?t:e??t}getResolvedStyleDrivenValue(t,e,i){const r=this.isPropertyOverrideEnabled(i);return r===!0?t??e:e??t}isPropertyOverrideEnabled(t){if(this.propertyOverrideFlag!=null)return(this.propertyOverrideFlag&t)!==0}applyColorTraits(t,e,i){t.color=i,e&&(t.color=e)}applyLineTraits(t,e,i){e&&(t.lineType=e),i!=null&&(t.lineWeight=i)}};ya.typeName="MLeader";let Rn=ya;var Yh=(n=>(n[n.Top=0]="Top",n[n.Zero=1]="Zero",n[n.Bottom=2]="Bottom",n))(Yh||{}),Xh=(n=>(n[n.HasVertex=1]="HasVertex",n[n.Closed=2]="Closed",n[n.SuppressStartCaps=4]="SuppressStartCaps",n[n.SuppressEndCaps=8]="SuppressEndCaps",n))(Xh||{});const ba=class ba extends H{get dxfTypeName(){return"MLINE"}constructor(){super(),this._styleName="",this._styleObjectHandle="",this._scale=1,this._justification=1,this._flags=0,this._styleCount=0,this._startPosition=new y,this._normal=new w(0,0,1),this._segments=[]}get styleName(){return this._styleName||this.getDefaultStyleName()}set styleName(t){this._styleName=t}get styleObjectHandle(){return this._styleObjectHandle}set styleObjectHandle(t){this._styleObjectHandle=t}get scale(){return this._scale}set scale(t){this._scale=t}get justification(){return this._justification}set justification(t){this._justification=t}get flags(){return this._flags}set flags(t){this._flags=t}get styleCount(){return this._styleCount}set styleCount(t){this._styleCount=Math.max(0,t)}get startPosition(){return this._startPosition}set startPosition(t){this._startPosition.copy(t)}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get segments(){return this._segments.map(t=>this.cloneSegment(t))}set segments(t){this._segments=t.map(e=>this.createSegment(e)),this.updateHasVertexFlag()}get vertexCount(){return this._segments.length}get closed(){return(this._flags&2)!==0}set closed(t){this.setFlag(2,t)}get suppressStartCaps(){return(this._flags&4)!==0}set suppressStartCaps(t){this.setFlag(4,t)}get suppressEndCaps(){return(this._flags&8)!==0}set suppressEndCaps(t){this.setFlag(8,t)}appendSegment(t){this._segments.push(this.createSegment(t)),this.updateHasVertexFlag()}clearSegments(){this._segments=[],this.updateHasVertexFlag()}get geometricExtents(){const t=this.collectGeometryPoints();return new Y().setFromPoints(t)}transformBy(t){return this._startPosition.applyMatrix4(t),this._segments.forEach(e=>{e.position.applyMatrix4(t),this.transformVector(e.direction,t),this.transformVector(e.miterDirection,t)}),this.transformVector(this._normal,t),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"mline",properties:[{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"scale",type:"float",editable:!0,accessor:{get:()=>this.scale,set:t=>{this.scale=t}}},{name:"justification",type:"int",editable:!0,accessor:{get:()=>this.justification,set:t=>{this.justification=t}}},{name:"closed",type:"boolean",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}},{name:"vertexCount",type:"int",editable:!1,accessor:{get:()=>this.vertexCount}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this._startPosition.clone()),this._segments.forEach(e=>t.push(e.position.clone())),t}subMoveGripPointsAt(t,e){const i=[this._startPosition,...this._segments.map(r=>r.position)];return ci(t,e,i),ht(t,r=>{this.updateReferencePathDirectionsAfterGripMove(r)}),this}subGetOsnapPoints(t,e,i,r){const s=[this._startPosition,...this._segments.map(a=>a.position)];if(s.length!==0)switch(t){case k.EndPoint:r.push(...s);break;case k.MidPoint:case k.Nearest:case k.Perpendicular:{const a=[];for(let o=0;o<s.length-1;o++){const c=[];li(s[o],s[o+1],t,e,c),a.push(...c)}if(t===k.MidPoint)r.push(...a);else{const o=Ft(e,a);o&&r.push(o)}break}}}subWorldDraw(t){if(this._segments.length===0)return;const e=[],i=this.getMLineStyle(),r=this.getRenderableElementCount(i),s=t.subEntityTraits,a=s.color,o=s.lineType,c=s.fillType,l=s.drawOrder,h=this.createFillArea(i,r);if(h&&(s.color=a,this.applyFillTraits(i,s),s.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},s.drawOrder=-1,e.push(t.area(h)),s.fillType=c,s.drawOrder=l),r<=0){const u=this.getReferencePath();u.length>=2&&e.push(t.lines(u))}else{for(let u=0;u<r;u++){s.color=a,s.lineType=o,this.applyStyleElementTraits(i,u,s);const d=this.getElementPath(u,i);d.length>=2&&e.push(t.lines(d))}this.appendStyleDrivenJointAndCapEntities(t,e,i,r,a,o)}if(s.color=a,s.lineType=o,s.fillType=c,s.drawOrder=l,e.length!==0)return e.length===1?e[0]:t.group(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMline"),t.writeString(2,this.styleName),t.writeHandle(340,this._styleObjectHandle),t.writeDouble(40,this._scale),t.writeInt16(70,this._justification),t.writeInt16(71,this._flags),t.writeInt16(72,this.vertexCount),t.writeInt16(73,this._styleCount),t.writePoint3d(10,this._startPosition),t.writeVector3d(210,this._normal),this._segments.forEach(e=>{t.writePoint3d(11,e.position),t.writeVector3d(12,e.direction),t.writeVector3d(13,e.miterDirection),e.elements.forEach(i=>{t.writeInt16(74,i.parameterCount),i.parameters.forEach(r=>t.writeDouble(41,r)),t.writeInt16(75,i.fillCount),i.fillParameters.forEach(r=>t.writeDouble(42,r))})}),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbMline");let e=this._startPosition.x,i=this._startPosition.y,r=this._startPosition.z,s=this._normal.x,a=this._normal.y,o=this._normal.z;const c=[];let l=null,h=null,u=!1,d=!1,g=0,p=0;const f=()=>{h&&l&&l.elements.push(h),h=null,u=!1,d=!1,g=0,p=0},m=()=>{f(),l&&c.push(l),l=null};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const b=t.readItem();if(!b)break;const _=Number(b.code),v=Number(b.value);switch(_){case 2:this.styleName=String(b.value);break;case 340:this.styleObjectHandle=String(b.value);break;case 40:this.scale=v;break;case 70:this.justification=v;break;case 71:this.flags=v;break;case 72:break;case 73:this.styleCount=v;break;case 10:e=v;break;case 20:i=v;break;case 30:r=v;break;case 210:s=v;break;case 220:a=v;break;case 230:o=v;break;case 11:m(),l={position:new y(v,0,0),direction:new w(1,0,0),miterDirection:new w(0,1,0),elements:[]};break;case 21:l&&(l.position.y=v);break;case 31:l&&(l.position.z=v);break;case 12:l&&(l.direction.x=v);break;case 22:l&&(l.direction.y=v);break;case 32:l&&(l.direction.z=v);break;case 13:l&&(l.miterDirection.x=v);break;case 23:l&&(l.miterDirection.y=v);break;case 33:l&&(l.miterDirection.z=v);break;case 74:f(),g=v,u=!0,d=!1,h={parameterCount:v,parameters:[],fillCount:0,fillParameters:[]};break;case 41:h&&u&&(h.parameters.push(v),g>0&&h.parameters.length>=g&&(u=!1));break;case 75:h&&(p=v,h.fillCount=v,d=!0,u=!1);break;case 42:h&&d&&(h.fillParameters.push(v),p>0&&h.fillParameters.length>=p&&(d=!1));break}}return m(),this.startPosition=new y(e,i,r),this.normal=new w(s,a,o),this.segments=c,this}setFlag(t,e){e?this._flags|=t:this._flags&=~t}updateHasVertexFlag(){this.setFlag(1,this._segments.length>0)}updateReferencePathDirectionsAfterGripMove(t){const e=r=>{const s=this._segments[r];if(!s)return;const a=r===0?this._startPosition:this._segments[r-1].position,o=new w().subVectors(s.position,a);o.lengthSq()>0&&s.direction.copy(o.normalize())};if(t===0){this._segments.length>0&&e(0);return}const i=t-1;i<0||i>=this._segments.length||(e(i),i+1<this._segments.length&&e(i+1))}createSegment(t){var e;return{position:new y().copy(t.position),direction:new w().copy(t.direction),miterDirection:new w().copy(t.miterDirection),elements:((e=t.elements)==null?void 0:e.map(i=>this.createElement(i)))??[]}}createElement(t){const e=t.parameters?[...t.parameters]:[],i=t.fillParameters?[...t.fillParameters]:[];return{parameterCount:t.parameterCount??e.length,parameters:e,fillCount:t.fillCount??i.length,fillParameters:i}}cloneSegment(t){return{position:t.position.clone(),direction:t.direction.clone(),miterDirection:t.miterDirection.clone(),elements:t.elements.map(e=>({parameterCount:e.parameterCount,parameters:[...e.parameters],fillCount:e.fillCount,fillParameters:[...e.fillParameters]}))}}collectGeometryPoints(){const t=[this._startPosition];if(this._segments.length===0)return t;const e=this.getMLineStyle(),i=this.getRenderableElementCount(e);if(i<=0)return this._segments.forEach(r=>t.push(r.position)),t;for(let r=0;r<i;r++)t.push(...this.getElementPath(r,e));return t}getRenderableElementCount(t){const e=(t==null?void 0:t.elementCount)??0;return Math.max(this._styleCount,e,...this._segments.map(i=>i.elements.length),0)}getReferencePath(){const t=[this._startPosition.clone(),...this._segments.map(e=>e.position.clone())];return this.closePathIfNeeded(t)}getElementPath(t,e){const i=[],r=this._segments[0];return i.push(this.getElementBoundaryPoint("start",r,t,e)),this._segments.forEach(s=>{i.push(this.offsetPoint(s.position,s.miterDirection,this.getElementMiterOffset(s,t,e)))}),i[i.length-1]=this.getElementBoundaryPoint("end",this._segments[this._segments.length-1],t,e),this.closePathIfNeeded(i)}getElementMiterOffset(t,e,i){var s;const r=t.elements[e];return(s=r==null?void 0:r.parameters)!=null&&s.length?r.parameters[0]:this.getStyleElementOffset(e,i)}getElementBoundaryPoint(t,e,i,r){const s=this.getElementMiterOffset(e,i,r),a=t==="start"?this._startPosition:e.position,o=this.offsetPoint(a,e.miterDirection,s);if(!this.shouldApplyCapCutAtSide(t,r))return o;const c=t==="start"?r==null?void 0:r.startAngle:r==null?void 0:r.endAngle,l=this.computeCapCutDistance(s,c,t);if(l===0)return o;const h=t==="start"?this.getStartSegmentDirection():this.getEndSegmentDirection();return h.lengthSq()===0?o:o.add(h.multiplyScalar(l))}shouldApplyCapCutAtSide(t,e){return!e||this.closed?!1:t==="start"?this.suppressStartCaps?!1:(e.flags&112)!==0:this.suppressEndCaps?!1:(e.flags&1792)!==0}computeCapCutDistance(t,e,i){const r=this.normalizeCapAngle(e),s=Math.tan(r);if(Math.abs(s)<1e-6)return 0;const a=t/s;return a}normalizeCapAngle(t){if(t==null||!Number.isFinite(t))return Math.PI/2;let e=t%180;return e<0&&(e+=180),(e<1||e>179)&&(e=90),e*Math.PI/180}getStartSegmentDirection(){const t=this._segments[0],e=new w;return t&&(e.subVectors(t.position,this._startPosition),e.lengthSq()===0&&e.copy(t.direction)),e.lengthSq()>0&&e.normalize(),e}getEndSegmentDirection(){const t=this._segments[this._segments.length-1];if(!t)return new w;const e=new w,i=this._segments.length>1?this._segments[this._segments.length-2].position:this._startPosition;return e.subVectors(t.position,i),e.lengthSq()===0&&e.copy(t.direction),e.lengthSq()>0&&e.normalize(),e}createFillArea(t,e){if(!t||(t.flags&1)===0||e<2)return;const i=this.getFillBoundaryElementIndices(e,t);if(!i)return;const r=this.getElementPath(i.outerIndex,t),s=this.getElementPath(i.innerIndex,t),a=this.stripClosingPoint(r),o=this.stripClosingPoint(s);if(a.length<2||o.length<2)return;const c=new Vt;if(this.closed){if(a.length<3||o.length<3)return;c.add(new q(a.map(l=>({x:l.x,y:l.y})),!0)),c.add(new q(o.map(l=>({x:l.x,y:l.y})),!0))}else{const l=[...a,...o.slice().reverse()].map(h=>({x:h.x,y:h.y}));if(l.length<3)return;c.add(new q(l,!0))}return c}getFillBoundaryElementIndices(t,e){let i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=-1,a=-1;for(let o=0;o<t;o++){const c=this.getElementReferenceOffset(o,e);c<i&&(i=c,s=o),c>r&&(r=c,a=o)}if(!(s<0||a<0||s===a))return{outerIndex:a,innerIndex:s}}getElementReferenceOffset(t,e){var r;const i=this._segments[0];if(i){const s=i.elements[t];if((r=s==null?void 0:s.parameters)!=null&&r.length)return s.parameters[0]}return this.getStyleElementOffset(t,e)}getStyleElementOffset(t,e){const i=e==null?void 0:e.elements[t];if(!i)return 0;const r=this.getStyleJustificationShift(e);return(i.offset+r)*this._scale}getStyleJustificationShift(t){const e=(t==null?void 0:t.elements)??[];if(e.length<=0)return 0;let i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const s of e){const a=s.offset;a<i&&(i=a),a>r&&(r=a)}return this._justification===0?-r:this._justification===2?-i:0}stripClosingPoint(t){if(t.length<2)return t;const e=t[0],i=t[t.length-1],r=1e-9;return Math.abs(e.x-i.x)<=r&&Math.abs(e.y-i.y)<=r&&Math.abs(e.z-i.z)<=r?t.slice(0,-1):t}offsetPoint(t,e,i){if(i===0||e.lengthSq()===0)return t.clone();const r=e.clone().normalize().multiplyScalar(i);return t.clone().add(r)}closePathIfNeeded(t){if(!this.closed||t.length<2)return t;const e=t[0],i=t[t.length-1],r=1e-9;return Math.abs(e.x-i.x)<=r&&Math.abs(e.y-i.y)<=r&&Math.abs(e.z-i.z)<=r||t.push(e.clone()),t}appendStyleDrivenJointAndCapEntities(t,e,i,r,s,a){!i||r<2||(e.push(...this.drawMiterJointEntities(t,i,r,s,a)),e.push(...this.drawCapEntities(t,i,r,s,a)))}drawMiterJointEntities(t,e,i,r,s){if(this.closed||this._segments.length<2||(e.flags&2)===0)return[];const a=[],o=t.subEntityTraits;for(let c=0;c<this._segments.length-1;c++){const l=this._segments[c],h=Array.from({length:i},(u,d)=>{const g=this.getElementMiterOffset(l,d,e);return{elementIndex:d,offset:g,point:this.offsetPoint(l.position,l.miterDirection,g)}}).sort((u,d)=>d.offset-u.offset);for(let u=0;u<h.length-1;u++)this.applyElementDrawTraits(o,r,s,e,h[u].elementIndex),a.push(t.lines([h[u].point,h[u+1].point]))}return a}drawCapEntities(t,e,i,r,s){if(this.closed||this._segments.length<=0)return[];const a=[];return a.push(...this.drawCapEntitiesForSide(t,"start",e,i,r,s)),a.push(...this.drawCapEntitiesForSide(t,"end",e,i,r,s)),a}drawCapEntitiesForSide(t,e,i,r,s,a){if(e==="start"&&this.suppressStartCaps)return[];if(e==="end"&&this.suppressEndCaps)return[];const o=i.flags,c=e==="start",l=c?(o&16)!==0:(o&256)!==0,h=c?(o&64)!==0:(o&1024)!==0,u=c?(o&32)!==0:(o&512)!==0;if(!l&&!h&&!u)return[];const d=this.getCapElementPoints(e,r,i);if(d.length<2)return[];const g=[],p=t.subEntityTraits;if(l)for(let m=0;m<d.length-1;m++)this.applyElementDrawTraits(p,s,a,i,d[m].elementIndex),g.push(t.lines([d[m].point,d[m+1].point]));const f=c?this.getStartSegmentDirection().multiplyScalar(-1):this.getEndSegmentDirection().clone();if(h){const m=this.drawCapArcBetweenElements(t,e,d[0],d[d.length-1],f,p,s,a,i);m&&g.push(m)}if(u)for(let m=1;m<Math.floor(d.length/2);m++){const b=d[m],_=d[d.length-1-m];if(!b||!_||b===_)continue;const v=this.drawCapArcBetweenElements(t,e,b,_,f,p,s,a,i);v&&g.push(v)}return g}getCapElementPoints(t,e,i){const r=t==="start"?this._segments[0]:this._segments[this._segments.length-1];return r?Array.from({length:e},(s,a)=>({elementIndex:a,offset:this.getElementMiterOffset(r,a,i),point:this.getElementBoundaryPoint(t,r,a,i)})).sort((s,a)=>a.offset-s.offset):[]}drawCapArcBetweenElements(t,e,i,r,s,a,o,c,l){const h=e==="end"?r.point:i.point,u=e==="end"?i.point:r.point,d=h.distanceTo(u);if(d<=1e-9||s.lengthSq()===0)return;const p=h.clone().add(new w().subVectors(u,h).multiplyScalar(.5)).add(s.clone().normalize().multiplyScalar(d/2)),f=Kt.createByThreePoints(h,u,p);if(f)return this.applyElementDrawTraits(a,o,c,l,e==="end"?r.elementIndex:i.elementIndex),t.circularArc(f)}applyElementDrawTraits(t,e,i,r,s){t.color=e,t.lineType=i,this.applyStyleElementTraits(r,s,t)}transformVector(t,e){const i=new y,r=new y(t.x,t.y,t.z);i.applyMatrix4(e),r.applyMatrix4(e),t.set(r.x-i.x,r.y-i.y,r.z-i.z)}getMLineStyle(){var s;const t=this.database.objects.mlineStyle,e=this.styleObjectHandle?t.getIdAt(this.styleObjectHandle):void 0;if(e)return e;const i=this.styleName?t.getAt(this.styleName):void 0;if(i)return i;const r=(s=this.styleName)==null?void 0:s.toUpperCase();if(r)for(const[a,o]of t.entries()){const c=(o.styleName||a).toUpperCase();if(a.toUpperCase()===r||c===r)return o}}applyStyleElementTraits(t,e,i){const r=t==null?void 0:t.elements[e];if(!r)return;const s=this.resolveStyleElementLineType(r.lineType);s&&(i.lineType=s),!(r.color.isByBlock||r.color.isByLayer)&&(i.color=r.color.clone())}applyFillTraits(t,e){const i=t==null?void 0:t.fillColor;!i||i.isByBlock||i.isByLayer||(e.color=i.clone())}resolveStyleElementLineType(t){var l;const e=t==null?void 0:t.trim();if(!e)return;const i=e.toUpperCase(),r=lt.toUpperCase(),s=Qt.toUpperCase();let a="UserSpecified",o=e;if(i===r){a="ByLayer";const h=(l=this.database.tables.layerTable.getAt(this.layer))==null?void 0:l.linetype;o=h&&h.toUpperCase()!==r&&h.toUpperCase()!==s?h:we}else i===s&&(a="ByBlock",o=we);const c=this.database.tables.linetypeTable.getAt(o);return c?{type:a,...c.linetype}:{type:a,name:o,standardFlag:0,description:"",totalPatternLength:0}}resolveEffectiveProperties(){super.resolveEffectiveProperties(),this._styleName||(this._styleName=this.getDefaultStyleName())}getDefaultStyleName(){try{return this.database.cmlstyle||oe}catch{return oe}}};ba.typeName="MLine";let Bn=ba;function zh(n,t){if(t.length<3)return;const e=n.subEntityTraits,i=e.fillType,r=e.transparency;e.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},e.transparency=new ot(0);const s=new Vt;s.add(new q(t,!0));const a=n.area(s);e.fillType=i,e.transparency=r;const o=n.lines(t);return a?o?n.group([a,o]):a:o}const Oo=[208,207,17,224,161,177,26,225],No=128,Ps=8,Zr=3*Ps,fn=2;function h0(n){if(!n||n.length<No)return;for(let l=0;l<Oo.length;l++)if(n[No+l]!==Oo[l])return;const t=new DataView(n.buffer,n.byteOffset,n.byteLength),e=l=>{const h=t.getFloat64(l,!0),u=t.getFloat64(l+Ps,!0),d=t.getFloat64(l+2*Ps,!0);if([h,u,d].every(Number.isFinite))return{x:h,y:u,z:d}},i=e(fn),r=e(fn+Zr),s=e(fn+2*Zr),a=e(fn+3*Zr);if(!i||!r||!s||!a)return;const o=Math.abs(s.x-i.x),c=Math.abs(i.y-s.y);if(!(o<=0||c<=0))return{upperLeft:i,upperRight:r,lowerRight:s,lowerLeft:a}}const Is=[208,207,17,224,161,177,26,225],u0=2,d0=8,Qr=128,g0=64*1024*1024;function f0(n){if(!(n!=null&&n.length))return;const t=p0(n);return t||Qe(n)}function p0(n){const t=Xi(n,Is);if(t<0)return;const e=n.subarray(t);let i;try{i=k0(e)}catch{return}const r=["CONTENTS","Package","Ole10Native","Ole10Native"];for(const s of r){const a=i.readStream(s);if(!(a!=null&&a.length))continue;const o=Qe(a);if(o)return o}for(const s of i.entries()){if(s.type!=="stream"||!/olepres/i.test(s.name)&&!s.name.includes("OlePres"))continue;const a=i.readStream(s.name);if(!(a!=null&&a.length))continue;const o=m0(a);if(o)return o;const c=Qe(a);if(c)return c}for(const s of i.entries()){if(s.type!=="stream")continue;const a=i.readStream(s.name);if(!(a!=null&&a.length))continue;const o=Qe(a);if(o)return o}}function m0(n){if(n.length<28)return;const t=new DataView(n.buffer,n.byteOffset,n.byteLength);let e=0;const i=t.getUint32(e,!0);e+=4;let r=0;if(i===4294967295)r=t.getUint32(e,!0),e+=4;else{if(i===4294967294)return;if(i>0&&i<65535)e+=i;else return}if(e+4>n.length)return;const s=t.getUint32(e,!0);if(e+=4,s>4&&(e+=s-4),e+=24,e+4>n.length)return;const a=t.getUint32(e,!0);if(e+=4,a<=0||e+a>n.length)return;const o=n.subarray(e,e+a);return r===d0?Vh(o):Qe(o)}function Qe(n){const t=y0(n);if(t)return t;const e=b0(n);if(e)return e;const i=_0(n);if(i)return i;const r=x0(n);if(r)return r;const s=w0(n);if(s)return s}function y0(n){for(let t=0;t<n.length-14;t++){if(n[t]!==66||n[t+1]!==77)continue;const e=new DataView(n.buffer,n.byteOffset+t,n.length-t),i=e.getUint32(2,!0);if(i<14||i>n.length-t)continue;const r=e.getUint32(10,!0);if(!(r<14||r>=i))return new Blob([n.subarray(t,t+i)],{type:"image/bmp"})}}function b0(n){const e=Xi(n,[137,80,78,71,13,10,26,10]);if(!(e<0)){for(let i=e+8;i+12<=n.length;i++)if(n[i+4]===73&&n[i+5]===69&&n[i+6]===78&&n[i+7]===68){const r=i+12;return new Blob([n.subarray(e,r)],{type:"image/png"})}return new Blob([n.subarray(e)],{type:"image/png"})}}function _0(n){const t=Xi(n,[255,216,255]);if(!(t<0)){for(let e=t+3;e+1<n.length;e++)if(n[e]===255&&n[e+1]===217)return new Blob([n.subarray(t,e+2)],{type:"image/jpeg"})}}function x0(n){const t=Xi(n,[71,73,70,56,55,97]),e=Xi(n,[71,73,70,56,57,97]),i=t>=0?t:e;if(!(i<0)){for(let r=i+6;r<n.length;r++)if(n[r]===59)return new Blob([n.subarray(i,r+1)],{type:"image/gif"});return new Blob([n.subarray(i)],{type:"image/gif"})}}function w0(n){for(let t=0;t+40<=n.length;t++){const e=new DataView(n.buffer,n.byteOffset+t,n.length-t),i=e.getUint32(0,!0);if(i!==40)continue;const r=e.getInt32(4,!0),s=e.getInt32(8,!0),a=e.getUint16(12,!0),o=e.getUint16(14,!0),c=e.getUint32(16,!0),l=e.getUint32(20,!0),h=e.getUint32(32,!0);if(r<=0||r>65536||s===0||Math.abs(s)>65536||a!==1||![1,4,8,16,24,32].includes(o)||c!==0&&c!==3)continue;const u=jh(i,o,c,h),d=Math.abs(s),g=r*o+31>>5<<2,p=l>0?l:g*d,f=u+p;if(!(f<=40||t+f>n.length))return Vh(n.subarray(t,t+f))}}function jh(n,t,e,i){let r=0;return t>8&&e===3&&(r+=12),i>0?r+=i*4:t<=8&&(r+=(1<<t)*4),n+r}function Vh(n){if(n.length<40)return;const e=new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,!0);if(e!==40&&e!==12)return;const i=14+n.length,r=new Uint8Array(14),s=new DataView(r.buffer);r[0]=66,r[1]=77,s.setUint32(2,i,!0),s.setUint32(10,14+v0(n),!0);const a=new Uint8Array(i);return a.set(r,0),a.set(n,14),new Blob([a],{type:"image/bmp"})}function v0(n){const t=new DataView(n.buffer,n.byteOffset,n.byteLength),e=t.getUint32(0,!0);if(e===12){const a=t.getUint16(10,!0),o=a<=8?1<<a:0;return e+o*3}const i=t.getUint16(14,!0),r=t.getUint32(16,!0),s=t.getUint32(32,!0);return jh(e,i,r,s)}function Xi(n,t){t:for(let e=0;e<=n.length-t.length;e++){for(let i=0;i<t.length;i++)if(n[e+i]!==t[i])continue t;return e}return-1}function k0(n){if(n.length<512)throw new Error("CFB too small");for(let P=0;P<Is.length;P++)if(n[P]!==Is[P])throw new Error("Not a CFB document");const t=new DataView(n.buffer,n.byteOffset,n.byteLength),i=1<<t.getUint16(30,!0);if(i!==512&&i!==4096)throw new Error("Unsupported CFB sector size");const r=t.getUint32(44,!0),s=t.getUint32(48,!0),a=t.getUint32(56,!0),o=t.getUint32(60,!0),c=t.getUint32(64,!0),l=t.getUint32(68,!0),h=t.getUint32(72,!0),u=[];for(let P=0;P<109;P++){const E=t.getUint32(76+P*4,!0);E<=4294967290&&u.push(E)}let d=l;for(let P=0;P<h&&d<=4294967290;P++){const E=(d+1)*i;if(E+i>n.length)break;const O=i/4-1;for(let T=0;T<O;T++){const R=t.getUint32(E+T*4,!0);R<=4294967290&&u.push(R)}d=t.getUint32(E+O*4,!0)}const g=[];for(let P=0;P<Math.min(r,u.length);P++){const O=(u[P]+1)*i;if(O+i>n.length)break;const T=i/4;for(let R=0;R<T;R++)g.push(t.getUint32(O+R*4,!0))}const p=pn(g,s,4096),f=mn(n,p,i),m=[],b=Math.floor(f.length/Qr);for(let P=0;P<b;P++){const E=P*Qr,O=new DataView(f.buffer,f.byteOffset+E,Qr),T=O.getUint16(64,!0);if(T<2||T>64)continue;const R=Math.floor((T-2)/2);let N="";for(let W=0;W<R;W++)N+=String.fromCharCode(O.getUint16(W*2,!0));const M=O.getUint8(66),A=O.getUint32(116,!0),V=O.getUint32(120,!0),$=O.getUint32(124,!0),Q=$===0?V:V+$*4294967296;let et="unknown";M===5?et="root":M===1?et="storage":M===2&&(et="stream"),m.push({name:N,type:et,size:Q,startSector:A})}const _=m.find(P=>P.type==="root"),v=[];if(c>0&&o<=4294967290){const P=pn(g,o,c),E=mn(n,P,i),O=new DataView(E.buffer,E.byteOffset,E.byteLength);for(let T=0;T+4<=E.length;T+=4)v.push(O.getUint32(T,!0))}let x;if(_&&_.size>0){const P=pn(g,_.startSector,65536);x=mn(n,P,i).subarray(0,_.size)}return{entries:()=>m,readStream:P=>{const E=m.find(T=>T.type==="stream"&&(T.name===P||T.name.toLowerCase()===P.toLowerCase()));if(!E||E.size<=0||E.size>g0)return;if(E.size<a&&x&&v.length>0){const R=Gh(v,E.startSector,65536),N=new Uint8Array(E.size);let M=0;for(const A of R){if(M>=E.size)break;const V=A*64,$=Math.min(V+64,x.length);if(V>=x.length)break;const Q=x.subarray(V,$);N.set(Q.subarray(0,Math.min(Q.length,E.size-M)),M),M+=Q.length}return N.subarray(0,Math.min(M,E.size))}const O=pn(g,E.startSector,65536);return mn(n,O,i).subarray(0,E.size)}}}function pn(n,t,e){return Gh(n,t,e)}function Gh(n,t,e){const i=[];let r=t;const s=new Set;for(;r<=4294967290&&i.length<e&&!(s.has(r)||(s.add(r),i.push(r),r>=n.length));)r=n[r];return i}function mn(n,t,e){const i=new Uint8Array(t.length*e);let r=0;for(const s of t){const a=(s+1)*e,o=Math.min(a+e,n.length);if(a>=n.length)break;i.set(n.subarray(a,o),r),r+=e}return i}const _a=class _a extends H{};_a.typeName="Frame";let Fn=_a;const xa=class xa extends Fn{constructor(){super(),this._oleVersion=0}get dxfTypeName(){return"OLEFRAME"}get oleVersion(){return this._oleVersion}set oleVersion(t){this._oleVersion=t}getOleObject(){return this._oleObject?new Uint8Array(this._oleObject):void 0}setOleObject(t){t==null?this._oleObject=void 0:this._oleObject=t instanceof ArrayBuffer?new Uint8Array(t.slice(0)):new Uint8Array(t),this.onOleObjectChanged()}loadOleObjectFromDxf(t,e){e!=null&&e.length?t!=null&&t>0&&t<e.length?this._oleObject=e.subarray(0,t):this._oleObject=new Uint8Array(e):this._oleObject=void 0,this.onOleObjectChanged()}get oleObjectData(){return this._oleObject}onOleObjectChanged(){}get geometricExtents(){return new Y}subWorldDraw(t){}dxfOutFields(t){var e;if(super.dxfOutFields(t),t.writeSubclassMarker("AcDbOleFrame"),t.writeInt16(70,this._oleVersion),(e=this._oleObject)!=null&&e.length){t.writeInt32(90,this._oleObject.length);let i=0;for(;i<this._oleObject.length;){const r=this._oleObject.subarray(i,i+127);t.writeString(310,br(r)),i+=127}}return t.writeString(1,"OLE"),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbOleFrame");const e=[];let i;const r=()=>{e.length>0&&this.loadOleObjectFromDxf(i,$i(e))};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const s=t.readItem();if(!s)break;const a=Number(s.code),o=Number(s.value);switch(a){case 1:break;case 70:this.oleVersion=o;break;case 90:i=o;break;case 310:s.value instanceof Uint8Array?e.push(s.value):e.push(String(s.value));break}}return r(),this}};xa.typeName="OleFrame";let zi=xa;var Uh=(n=>(n[n.Link=1]="Link",n[n.Embedded=2]="Embedded",n[n.Static=3]="Static",n))(Uh||{}),Hh=(n=>(n[n.ModelSpace=0]="ModelSpace",n[n.PaperSpace=1]="PaperSpace",n))(Hh||{});const wa=class wa extends zi{constructor(){super(),this._upperLeft=new y,this._lowerRight=new y,this._rotation=0,this._scaleWidth=1,this._scaleHeight=1,this._lockAspect=!1,this._outputQuality=0,this._autoOutputQuality=0,this._oleObjectType=2,this._tileMode=0,this._userType="",this._linkName="",this._linkPath="",this._oleClientItem=null,this._imageResolved=!1}get dxfTypeName(){return"OLE2FRAME"}get upperLeftCorner(){return this._upperLeft}set upperLeftCorner(t){this._upperLeft.copy(t)}get lowerRightCorner(){return this._lowerRight}set lowerRightCorner(t){this._lowerRight.copy(t)}getLocation(t){return t?t.copy(this._upperLeft):this._upperLeft.clone()}setLocation(t){const e=t.x-this._upperLeft.x,i=t.y-this._upperLeft.y,r=(t.z??0)-this._upperLeft.z;this._upperLeft.copy(t),this._lowerRight.x+=e,this._lowerRight.y+=i,this._lowerRight.z+=r}position(){return{upperLeft:this._upperLeft.clone(),upperRight:this.cornerUpperRight(),lowerLeft:this.cornerLowerLeft(),lowerRight:this._lowerRight.clone()}}setPosition(t){this._upperLeft.copy(t.upperLeft),this._lowerRight.copy(t.lowerRight)}wcsWidth(){return Math.abs(this._lowerRight.x-this._upperLeft.x)}setWcsWidth(t){const e=this._lowerRight.x>=this._upperLeft.x?1:-1;this._lowerRight.x=this._upperLeft.x+e*Math.abs(t),this._lockAspect&&this.syncHeightFromAspect()}wcsHeight(){return Math.abs(this._upperLeft.y-this._lowerRight.y)}setWcsHeight(t){const e=this._upperLeft.y>=this._lowerRight.y?1:-1;this._lowerRight.y=this._upperLeft.y-e*Math.abs(t),this._lockAspect&&this.syncWidthFromAspect()}scaleWidth(){return this._scaleWidth}setScaleWidth(t){this._scaleWidth=t}scaleHeight(){return this._scaleHeight}setScaleHeight(t){this._scaleHeight=t}rotation(){return this._rotation}setRotation(t){this._rotation=t}lockAspect(){return this._lockAspect}setLockAspect(t){this._lockAspect=!!t}outputQuality(){return this._outputQuality}setOutputQuality(t){this._outputQuality=t&255}autoOutputQuality(){return this._autoOutputQuality}setAutoOutputQuality(t){this._autoOutputQuality=t&255}getType(){return this._oleObjectType}setType(t){this._oleObjectType=t}get oleObjectType(){return this._oleObjectType}set oleObjectType(t){this._oleObjectType=t}get tileMode(){return this._tileMode}set tileMode(t){this._tileMode=t}getUserType(){return this._userType}setUserType(t){this._userType=t}get userType(){return this._userType}set userType(t){this._userType=t}getLinkName(){return this._linkName}setLinkName(t){this._linkName=t}getLinkPath(){return this._linkPath}setLinkPath(t){this._linkPath=t}getOleClientItem(){return this._oleClientItem}setOleClientItem(t){this._oleClientItem=t??null}get geometricExtents(){return new Y().setFromPoints(this.boundaryPath())}subGetGripPoints(){return this.boundaryPath().slice(0,4)}subMoveGripPointsAt(t,e){const i=this.boundaryPath().slice(0,4);return ci(t,e,i),ht(t,r=>{r===0?this._upperLeft.copy(i[0]):r===2?this._lowerRight.copy(i[2]):r===1?(this._upperLeft.y=i[1].y,this._lowerRight.x=i[1].x,this._upperLeft.z=i[1].z,this._lowerRight.z=i[1].z):r===3&&(this._upperLeft.x=i[3].x,this._lowerRight.y=i[3].y,this._upperLeft.z=i[3].z,this._lowerRight.z=i[3].z)}),this}subGetOsnapPoints(t,e,i,r){if(t===k.Insertion){r.push(this._upperLeft.clone());return}const s=this.boundaryPath().slice(0,4);if(t===k.EndPoint){r.push(...s);return}_r(s,!0,t,e,r)}transformBy(t){const e=this._lowerRight.x-this._upperLeft.x,i=this._upperLeft.y-this._lowerRight.y,r=Math.cos(this._rotation),s=Math.sin(this._rotation),a=this._upperLeft.clone(),o=a.clone().add(new w(e*r,e*s,0)),c=a.clone().add(new w(i*s,-i*r,0));a.applyMatrix4(t),o.applyMatrix4(t),c.applyMatrix4(t);const l=new w().subVectors(o,a),h=new w().subVectors(c,a);return this._upperLeft.copy(a),this._rotation=Math.atan2(l.y,l.x),this._lowerRight.set(a.x+l.length(),a.y-h.length(),a.z),this}get image(){return this.resolveImage()}subWorldDraw(t){const e=this.resolveImage(),i=this.imageBoundaryPath();return e?t.image(e,{boundary:i,roation:this._rotation}):zh(t,this.boundaryPath())}onOleObjectChanged(){this._image=void 0,this._imageResolved=!1,this.applyGeometryFromOleObjectData()}applyGeometryFromOleObjectData(){const t=h0(this.oleObjectData);t&&(this._upperLeft.copy(t.upperLeft),this._lowerRight.copy(t.lowerRight))}resolveImage(){return this._imageResolved?this._image:(this._imageResolved=!0,this._image=f0(this.oleObjectData),this._image)}imageBoundaryPath(){const t=this.boundaryPath(),e=[t[3],t[2],t[1],t[0]];return e.push(e[0].clone()),e}dxfOutFields(t){H.prototype.dxfOutFields.call(this,t),t.writeSubclassMarker("AcDbOle2Frame"),t.writeInt16(70,this.oleVersion),this._userType&&t.writeString(3,this._userType),t.writePoint3d(10,this._upperLeft),t.writePoint3d(11,this._lowerRight),t.writeInt16(71,this._oleObjectType),t.writeInt16(72,this._tileMode),this._outputQuality&&t.writeInt16(73,this._outputQuality);const e=this.getOleObject();if(e!=null&&e.length){t.writeInt32(90,e.length);let i=0;for(;i<e.length;){const r=e.subarray(i,i+127);t.writeString(310,br(r)),i+=127}}return t.writeString(1,"OLE"),this}dxfInFields(t){H.prototype.dxfInFields.call(this,t),t.atSubclassData("AcDbOle2Frame");let e=this._upperLeft.x,i=this._upperLeft.y,r=this._upperLeft.z,s=this._lowerRight.x,a=this._lowerRight.y,o=this._lowerRight.z;const c=[];let l;const h=()=>{this.upperLeftCorner=new y(e,i,r),this.lowerRightCorner=new y(s,a,o),c.length>0&&this.loadOleObjectFromDxf(l,$i(c))};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const u=t.readItem();if(!u)break;const d=Number(u.code),g=Number(u.value);switch(d){case 1:break;case 3:this.userType=String(u.value);break;case 10:e=g;break;case 20:i=g;break;case 30:r=g;break;case 11:s=g;break;case 21:a=g;break;case 31:o=g;break;case 70:this.oleVersion=g;break;case 71:this.oleObjectType=g;break;case 72:this.tileMode=g;break;case 73:this.setOutputQuality(g);break;case 90:l=g;break;case 310:u.value instanceof Uint8Array?c.push(u.value):c.push(String(u.value));break}}return h(),this}cornerUpperRight(){return new y(this._lowerRight.x,this._upperLeft.y,this._upperLeft.z)}cornerLowerLeft(){return new y(this._upperLeft.x,this._lowerRight.y,this._lowerRight.z)}boundaryPath(){const t=[this._upperLeft.clone(),this.cornerUpperRight(),this._lowerRight.clone(),this.cornerLowerLeft()];if(this._rotation!==0){const e=this._upperLeft;for(let i=1;i<t.length;i++)t[i].sub(e).applyMatrix4(new D().makeRotationZ(this._rotation)),t[i].add(e)}return t.push(t[0].clone()),t}syncHeightFromAspect(){const t=this.wcsWidth();if(t===0||this._scaleWidth===0)return;const e=this._scaleHeight/this._scaleWidth,i=t*e,r=this._upperLeft.y>=this._lowerRight.y?1:-1;this._lowerRight.y=this._upperLeft.y-r*Math.abs(i)}syncWidthFromAspect(){const t=this.wcsHeight();if(t===0||this._scaleHeight===0)return;const e=this._scaleWidth/this._scaleHeight,i=t*e,r=this._lowerRight.x>=this._upperLeft.x?1:-1;this._lowerRight.x=this._upperLeft.x+r*Math.abs(i)}};wa.typeName="Ole2Frame";let Dn=wa;const va=class va extends H{constructor(){super(),this._thickness=0,this._normal=new w(0,0,1),this._ecsRotation=0,this._geo=new y}get dxfTypeName(){return"POINT"}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get ecsRotation(){return this._ecsRotation}set ecsRotation(t){this._ecsRotation=t}get geometricExtents(){return new Y().expandByPoint(this._geo)}subGetGripPoints(){return[this._geo]}subMoveGripPointsAt(t,e){return te(t,e,this._geo),this}subGetOsnapPoints(t,e,i,r){t===k.Node&&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"),this.thickness!==0&&t.writeDouble(39,this.thickness),t.writePoint3d(10,Lt(this.position,this.normal)),this.ecsRotation!==0&&t.writeAngle(50,this.ecsRotation),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbPoint");let e=this.position.x,i=this.position.y,r=this.position.z,s=this.thickness,a=this.ecsRotation*180/Math.PI,o=this.normal.x,c=this.normal.y,l=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const u=t.readItem();if(!u)break;const d=Number(u.code),g=Number(u.value);switch(d){case 10:e=g;break;case 20:i=g;break;case 30:r=g;break;case 39:s=g;break;case 50:a=g;break;case 210:o=g;break;case 220:c=g;break;case 230:l=g;break}}const h=new w(o,c,l);return h.lengthSq()>0&&this.normal.copy(h.normalize()),this.thickness=s,this.ecsRotation=a*Math.PI/180,this.position=he({x:e,y:i,z:r},this.normal),this}};va.typeName="Point";let Yn=va;const ka=class ka extends H{constructor(){super(...arguments),this._originalDxfName="",this._originalClassName="",this._applicationName="",this._proxyEntityClassId=498,this._applicationEntityClassId=0,this._objectDrawingFormat=0,this._originalDataFormat=0,this._entityOrigins=[],this._worldTransform=new D}get dxfTypeName(){return"ACAD_PROXY_ENTITY"}get originalDxfName(){return this._originalDxfName}set originalDxfName(t){this._originalDxfName=t}get originalClassName(){return this._originalClassName}set originalClassName(t){this._originalClassName=t}get applicationName(){return this._applicationName}set applicationName(t){this._applicationName=t}get proxyEntityClassId(){return this._proxyEntityClassId}set proxyEntityClassId(t){this._proxyEntityClassId=t}get applicationEntityClassId(){return this._applicationEntityClassId}set applicationEntityClassId(t){this._applicationEntityClassId=t}get objectDrawingFormat(){return this._objectDrawingFormat}set objectDrawingFormat(t){this._objectDrawingFormat=t}get graphicsMetafileType(){return this._objectDrawingFormat}set graphicsMetafileType(t){this._objectDrawingFormat=t}get originalDataFormat(){return this._originalDataFormat}set originalDataFormat(t){this._originalDataFormat=t}get proxyGraphic(){return this._proxyGraphic}setProxyGraphic(t){this._proxyGraphic=t?new Uint8Array(t):void 0}get entityOrigins(){return this._entityOrigins}setEntityOrigins(t){this._entityOrigins=t.map(e=>new y(e.x,e.y,e.z))}get geometricExtents(){const t=this._proxyGraphic;if(!(t!=null&&t.length))return new Y;const i=new xs(t,{database:this.database,defaultLayer:this.layer}).scanExtents();if(i){const r=new Y().setFromPoints(i);return this._worldTransform.equals(new D)||r.applyMatrix4(this._worldTransform),r}return new Y}subGetGripPoints(){if(this._entityOrigins.length>0)return[...this._entityOrigins];const t=this.geometricExtents;return t.isEmpty()?[]:[new y(t.min.x,t.min.y,t.min.z),new y(t.max.x,t.max.y,t.max.z)]}subMoveGripPointsAt(t,e){return this._entityOrigins.length>0?(ci(t,e,this._entityOrigins),this):this.geometricExtents.isEmpty()?this:(ht(t,r=>{r===0&&this.transformBy(D.makeTranslation(e))}),this)}transformBy(t){return this._entityOrigins.forEach(e=>e.applyMatrix4(t)),this._worldTransform.premultiply(t),this}subWorldDraw(t){const e=this._proxyGraphic;if(!(e!=null&&e.length))return;const r=new xs(e,{database:this.database,defaultLayer:this.layer}).worldDraw(t);return r&&!this._worldTransform.equals(new D)&&r.applyMatrix(this._worldTransform),r}dxfOutFields(t){var e;if(super.dxfOutFields(t),t.writeSubclassMarker("AcDbProxyEntity"),this._originalDxfName&&t.writeString(1,this._originalDxfName),this._originalClassName&&t.writeString(3,this._originalClassName),t.writeInt32(90,this._proxyEntityClassId||498),this._applicationEntityClassId&&t.writeInt32(91,this._applicationEntityClassId),this._objectDrawingFormat&&t.writeInt32(95,this._objectDrawingFormat),t.writeInt16(70,this._originalDataFormat),(e=this._proxyGraphic)!=null&&e.length){t.writeInt32(160,this._proxyGraphic.length);let i=0;for(;i<this._proxyGraphic.length;){const r=this._proxyGraphic.subarray(i,i+127);t.writeString(310,br(r)),i+=127}}return this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbProxyEntity");const e=[];let i;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const r=t.readItem();if(!r)break;const s=Number(r.code),a=Number(r.value);switch(s){case 1:this.originalDxfName=String(r.value);break;case 3:this.originalClassName=String(r.value);break;case 70:this.originalDataFormat=a;break;case 90:this.proxyEntityClassId=a;break;case 91:this.applicationEntityClassId=a;break;case 95:this.objectDrawingFormat=a;break;case 160:i=a;break;case 310:r.value instanceof Uint8Array?e.push(r.value):e.push(String(r.value));break}}return e.length>0&&this.loadProxyGraphicFromDxf(i,e),this}loadProxyGraphicFromDxf(t,e){const i=op(t,e);i&&this.setProxyGraphic(i)}};ka.typeName="ProxyEntity";let Xn=ka;var Wh=(n=>(n[n.Invalid=0]="Invalid",n[n.Rect=1]="Rect",n[n.Poly=2]="Poly",n))(Wh||{}),$h=(n=>(n[n.Show=1]="Show",n[n.ShowUnAligned=2]="ShowUnAligned",n[n.Clip=4]="Clip",n[n.Transparent=8]="Transparent",n))($h||{});const Aa=class Aa extends H{constructor(){super(),this._classVersion=0,this._clipMode=0,this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new y,this._scale=new nt(1,1),this._rotation=0,this._imageSize=new L,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isShownClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get dxfTypeName(){return"IMAGE"}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 classVersion(){return this._classVersion}set classVersion(t){this._classVersion=t}get clipMode(){return this._clipMode}set clipMode(t){this._clipMode=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 Y;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()}subMoveGripPointsAt(t,e){return ht(t,i=>{this.isClipped&&this._clipBoundary.length>3?this.moveClippedBoundaryGripAt(i,e):this.moveUnclippedGripAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){if(t===k.Insertion){r.push(this._position);return}const s=this.boundaryPath();if(s.length===0)return;let a=s;if(s.length>1){const o=s[0],c=s[s.length-1];o.x===c.x&&o.y===c.y&&(o.z||0)===(c.z||0)&&(a=s.slice(0,-1))}if(t===k.EndPoint){r.push(...a);return}_r(a,!0,t,e,r)}subWorldDraw(t){const e=this.boundaryPath();return this._image&&this.isImageShown?t.image(this._image,{boundary:e,roation:this._rotation}):zh(t,e)}transformBy(t){const e=this._width*this._scale.x,i=this._height*this._scale.y,r=new w(e*Math.cos(this._rotation),e*Math.sin(this._rotation),0),s=new w(-i*Math.sin(this._rotation),i*Math.cos(this._rotation),0),a=this._position.clone(),o=this._position.clone().add(r),c=this._position.clone().add(s);a.applyMatrix4(t),o.applyMatrix4(t),c.applyMatrix4(t);const l=new w(o).sub(a),h=new w(c).sub(a);return this._position.copy(a),this._rotation=Math.atan2(l.y,l.x),this._width=l.length(),this._height=h.length(),this._scale.set(1,1),this}moveUnclippedGripAt(t,e){const i=this._position.x,r=this._position.y,s=this._width,a=this._height;switch(t){case 0:this._position.add(e);break;case 1:{const o=i,c=r+a,l=i+s+e.x,h=r+e.y;this._position.x=o,this._position.y=h,this._width=l-o,this._height=c-h;break}case 2:{const o=i+s+e.x,c=r+a+e.y;this._width=o-i,this._height=c-r;break}case 3:{const o=i+s,c=r,l=i+e.x,h=r+a+e.y;this._position.x=l,this._position.y=c,this._width=o-l,this._height=h-c;break}}}moveClippedBoundaryGripAt(t,e){if(t<0||t>=this._clipBoundary.length)return;const i=this._width,r=this._height,s=new yt;s.setFromPoints(this._clipBoundary);const a=new L;a.setX(this._position.x-s.min.x*i),a.setY(this._position.y-s.min.y*r);const o=this._clipBoundary[t],c=o.x*i+a.x+e.x,l=o.y*r+a.y+e.y;o.x=(c-a.x)/i,o.y=(l-a.y)/r}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,i=this._height,r=new yt;r.setFromPoints(this._clipBoundary);const s=new L;s.setX(this._position.x-r.min.x*e),s.setY(this._position.y-r.min.y*i),this._clipBoundary.forEach(a=>{const o=a.x*e+s.x,c=a.y*i+s.y;t.push(new y(o,c,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){Ro.copy(t[1]);for(let e=1;e<4;e++)yn.copy(t[e]),yn.rotateAround(Ro,this._rotation),t[e].setX(yn.x),t[e].setY(yn.y)}t.push(t[0])}return t}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbRasterImage"),t.writeInt32(90,this.classVersion),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},s=r.x>0?e/r.x:e,a=r.y>0?i/r.y:i,o=Math.cos(this._rotation),c=Math.sin(this._rotation);t.writePoint3d(11,{x:s*o,y:s*c,z:0}),t.writePoint3d(12,{x:-a*c,y:a*o,z:0}),t.writePoint2d(13,r),t.writeObjectId(340,this.imageDefId);const l=(this.isImageShown?1:0)|(this.isShownClipped?4:0)|(this.isImageTransparent?8:0);if(t.writeInt16(70,l),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 h of this.clipBoundary)t.writePoint2d(14,h)}return t.writeInt16(290,this.clipMode),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbRasterImage");let e=this.position.x,i=this.position.y,r=this.position.z,s=1,a=0,o=0,c=0,l=1,h=0,u=this.imageSize.x,d=this.imageSize.y;const g=[];let p=null;const f=()=>{p&&(g.push(new L(p.x,p.y)),p=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const m=t.readItem();if(!m)break;const b=Number(m.code),_=Number(m.value);switch(b){case 10:e=_;break;case 20:i=_;break;case 30:r=_;break;case 11:s=_;break;case 21:a=_;break;case 31:o=_;break;case 12:c=_;break;case 22:l=_;break;case 32:h=_;break;case 13:u=_;break;case 23:d=_;break;case 14:f(),p={x:_,y:0};break;case 24:p&&(p.y=_);break;case 70:{this.isImageShown=(_&3)!==0,this.isShownClipped=(_&4)!==0,this.isImageTransparent=(_&8)!==0;break}case 71:this.clipBoundaryType=_;break;case 90:this.classVersion=_;break;case 91:break;case 280:this.isClipped=_!==0;break;case 281:this.brightness=_;break;case 282:this.contrast=_;break;case 283:this.fade=_;break;case 290:this.clipMode=_;break;case 340:this.imageDefId=String(m.value);break}}return f(),this.applyRasterImageDxfIn(e,i,r,s,a,o,c,l,h,u,d,g),this}applyRasterImageDxfIn(t,e,i,r,s,a,o,c,l,h,u,d){this.position.copy({x:t,y:e,z:i}),this.imageSize.copy({x:h,y:u});const g=Math.hypot(r,s,a),p=Math.hypot(o,c,l);this.width=g*(h||1),this.height=p*(u||1),this.rotation=Math.atan2(s,r),d.length>0&&(this.clipBoundary=d)}};Aa.typeName="RasterImage";let ji=Aa;const Ro=new L,yn=new L,dr=class dr extends _t{get dxfTypeName(){return"RAY"}constructor(){super(),this._basePoint=new y,this._unitDir=new w}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 area(){return 0}get geometricExtents(){const t=new Y;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}subMoveGripPointsAt(t,e){return te(t,e,this.basePoint),this}subGetOsnapPoints(t,e,i,r){const s=this.basePoint;if(t===k.EndPoint){r.push(s);return}const a=this.unitDir.clone();if(a.lengthSq()===0)return;a.normalize();const o=new ue(s,s.clone().add(a));switch(t){case k.Nearest:{const c=o.project(e),h=new w(c).sub(s).dot(a);r.push(h<0?s:c);break}case k.Perpendicular:r.push(o.perpPoint(e));break}}transformBy(t){return this._basePoint.applyMatrix4(t),this._unitDir.transformDirection(t),this}subWorldDraw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRay"),t.writePoint3d(10,this.basePoint),t.writeVector3d(11,this.unitDir),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbRay");let e=this.basePoint.x,i=this.basePoint.y,r=this.basePoint.z,s=this.unitDir.x,a=this.unitDir.y,o=this.unitDir.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const c=t.readItem();if(!c)break;const l=Number(c.code),h=Number(c.value);switch(l){case 10:e=h;break;case 20:i=h;break;case 30:r=h;break;case 11:s=h;break;case 21:a=h;break;case 31:o=h;break}}return this.basePoint=new y(e,i,r),this.unitDir=new w(s,a,o),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.basePoint,i=this.unitDir,r=Math.hypot(i.x,i.y);return r<=1e-9||(i.x*(t.y-e.y)-i.y*(t.x-e.x))/r>=0?1:-1}createOffsetCurve(t){const e=Lc(this.basePoint,this.unitDir,t);if(!e)return null;const i=new dr;return i.basePoint=e,i.unitDir=this.unitDir.clone(),i}};dr.typeName="Ray";let zn=dr;const Sa=class Sa extends H{get dxfTypeName(){return"SHAPE"}constructor(){super(),this._position=new y,this._size=1,this._name="",this._rotation=0,this._widthFactor=1,this._oblique=0,this._thickness=0,this._normal=new w(0,0,1),this._shapeNumber=0,this._styleName=""}get position(){return this._position}set position(t){this._position.copy(t)}get size(){return this._size}set size(t){this._size=t}get name(){return this._name}set name(t){this._name=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get widthFactor(){return this._widthFactor}set widthFactor(t){this._widthFactor=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get shapeNumber(){return this._shapeNumber}set shapeNumber(t){this._shapeNumber=t}get styleId(){var e,i,r;const t=(r=(i=(e=this.database)==null?void 0:e.tables)==null?void 0:i.textStyleTable)==null?void 0:r.resolveAt(this._styleName);return(t==null?void 0:t.objectId)??""}set styleId(t){var i,r,s;const e=(s=(r=(i=this.database)==null?void 0:i.tables)==null?void 0:r.textStyleTable)==null?void 0:s.getIdAt(t);e&&(this._styleName=e.name)}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get isPlanar(){return!0}get geometricExtents(){const t=Math.abs(this._size)/2,e=new Y;return e.expandByPoint(this._position),t>0&&(e.expandByPoint(new y(this._position.x-t,this._position.y-t,this._position.z)),e.expandByPoint(new y(this._position.x+t,this._position.y+t,this._position.z))),e}subGetGripPoints(){return[this._position]}subMoveGripPointsAt(t,e){return te(t,e,this._position),this}subGetOsnapPoints(t,e,i,r){t===k.Insertion&&r.push(this._position)}transformBy(t){const e=new D().setFromExtrusionDirection(this._normal),i=new D().makeRotationZ(this._rotation),r=new D().multiplyMatrices(e,i),s=this._position.clone(),a=new y(this._widthFactor,0,0).applyMatrix4(r).add(s),o=new y(0,1,0).applyMatrix4(r).add(s),c=new y(0,0,1).applyMatrix4(r).add(s);s.applyMatrix4(t),a.applyMatrix4(t),o.applyMatrix4(t),c.applyMatrix4(t);const l=new w(a).sub(s),h=new w(o).sub(s),u=new w(c).sub(s);let d=new w().crossVectors(l,h);d.lengthSq()===0?d=this._normal.clone().transformDirection(t):d.normalize();const p=new D().setFromExtrusionDirection(d).clone().invert(),f=l.clone().applyMatrix4(p),m=h.length(),b=l.length();this._position.copy(s),this._normal.copy(d),b>0&&(this._rotation=Math.atan2(f.y,f.x)),m>0&&(this._size*=m,b>0&&(this._widthFactor*=b/m));const _=u.length();return _>0&&(this._thickness*=_),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"shape",properties:[{name:"name",type:"string",editable:!0,accessor:{get:()=>this.name,set:t=>{this.name=t}}},{name:"size",type:"float",editable:!0,accessor:{get:()=>this.size,set:t=>{this.size=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}}},{name:"shapeNumber",type:"int",editable:!0,accessor:{get:()=>this.shapeNumber,set:t=>{this.shapeNumber=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}}}]}]}}subWorldDraw(t,e){const i=this.getTextStyle(),r=i?{...i,widthFactor:this.widthFactor,obliqueAngle:this.oblique*180/Math.PI}:void 0,s={...this.renderGlyphIdentity(),size:this.size,position:this._position,rotation:this._rotation,directionVector:this._normal,widthFactor:this.widthFactor};return t.shape(s,r,e)}renderGlyphIdentity(){const t=this._name.trim(),e=Number(t);return t!==""&&Number.isInteger(e)&&e!==0&&String(e)===t?{shapeNumber:e}:{name:t||void 0,shapeNumber:this._shapeNumber!==0?this._shapeNumber:void 0}}getTextStyle(){const t=this.styleName.trim();if(!t)return;const e=this.database.tables.textStyleTable.resolveAt(t);return e==null?void 0:e.textStyle}get dxfShapeIdentity(){const t=this._name.trim();return t||(this._shapeNumber!==0?String(this._shapeNumber):"")}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbShape"),t.writePoint3d(10,this.position),t.writeDouble(40,this.size);const e=this.dxfShapeIdentity;return e&&t.writeString(2,e),t.writeAngle(50,this.rotation),t.writeDouble(41,this.widthFactor),t.writeAngle(51,this.oblique),t.writeDouble(39,this.thickness),this._styleName&&t.writeString(3,this._styleName),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbShape");let e=this.position.x,i=this.position.y,r=this.position.z,s=this.normal.x,a=this.normal.y,o=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const c=t.readItem();if(!c)break;const l=Number(c.code),h=Number(c.value);switch(l){case 10:e=h;break;case 20:i=h;break;case 30:r=h;break;case 2:{const u=String(c.value).trim(),d=Number(u);u!==""&&Number.isInteger(d)&&d!==0&&String(d)===u?(this.shapeNumber=d,this.name=""):this.name=u;break}case 3:this.styleName=String(c.value);break;case 39:this.thickness=h;break;case 40:this.size=h;break;case 41:this.widthFactor=h;break;case 50:this.rotation=C.degToRad(h);break;case 51:this.oblique=C.degToRad(h);break;case 210:s=h;break;case 220:a=h;break;case 230:o=h;break}}return this.position={x:e,y:i,z:r},this.normal={x:s,y:a,z:o},this}};Sa.typeName="Shape";let jn=Sa;const $e=class $e extends _t{constructor(){super(),this._normal=new w(0,0,1),this._elevation=0,this._thickness=0,this._vertices=[new y,new y,new y,new y]}get dxfTypeName(){return"TRACE"}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return!0}get area(){return new q($e.boundaryPointsFromVertices(this._vertices),!0).area}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){return this._normal}set normal(t){this._normal.copy(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 Y().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subMoveGripPointsAt(t,e){return ci(t,e,this._vertices),this}subGetOsnapPoints(t,e,i,r){const s=[this._vertices[0],this._vertices[1],this._vertices[3],this._vertices[2]];_r(s,!0,t,e,r)}transformBy(t){return this._vertices.forEach(e=>e.applyMatrix4(t)),this._elevation=this._vertices[0].z,this}subWorldDraw(t){const e=new q($e.boundaryPointsFromVertices(this._vertices),!0),i=new Vt;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"),this.thickness!==0&&t.writeDouble(39,this.thickness),t.writePoint3d(10,Lt(this.getPointAt(0),this.normal)),t.writePoint3d(11,Lt(this.getPointAt(1),this.normal)),t.writePoint3d(12,Lt(this.getPointAt(2),this.normal)),t.writePoint3d(13,Lt(this.getPointAt(3),this.normal)),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbTrace");const e=[{x:this.getPointAt(0).x,y:this.getPointAt(0).y,z:this.getPointAt(0).z},{x:this.getPointAt(1).x,y:this.getPointAt(1).y,z:this.getPointAt(1).z},{x:this.getPointAt(2).x,y:this.getPointAt(2).y,z:this.getPointAt(2).z},{x:this.getPointAt(3).x,y:this.getPointAt(3).y,z:this.getPointAt(3).z}];let i=this.normal.x,r=this.normal.y,s=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const o=t.readItem();if(!o)break;const c=Number(o.code),l=Number(o.value);switch(c){case 10:case 11:case 12:case 13:e[c-10].x=l;break;case 20:case 21:case 22:case 23:e[c-20].y=l;break;case 30:case 31:case 32:case 33:e[c-30].z=l;break;case 39:this.thickness=l;break;case 210:i=l;break;case 220:r=l;break;case 230:s=l;break}}const a=new w(i,r,s);return a.lengthSq()>0&&this.normal.copy(a.normalize()),e.forEach((o,c)=>this.setPointAt(c,he(o,this.normal))),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectBoundary2d();return e.length<2?1:kt.from2dPoints(e,!0).getOffsetSideAtPoint(t)}createOffsetCurve(t){return Ir(this.collectBoundary2d(),!0,t)}collectBoundary2d(){return $e.boundaryPointsFromVertices(this._vertices)}static boundaryPointsFromVertices(t){const e=t[0],i=t[1],r=t[2],s=t[3];return[new L(e.x,e.y),new L(i.x,i.y),new L(s.x,s.y),new L(r.x,r.y)]}};$e.typeName="Trace";let Vi=$e;const Pa=class Pa extends Vi{get dxfTypeName(){return"SOLID"}};Pa.typeName="Solid";let Vn=Pa;function A0(n){return n&2048?"SqrtChord":n&1024?"Chord":"Uniform"}function Bo(n,t){try{return new Gi(n.controlPoints,n.knots,S0(n.weights,n.controlPoints.length),n.degree,t)}catch{return null}}function S0(n,t){if(!(!n||n.length!==t))return n}const qe=class qe extends _t{constructor(t,e,i,r,s){super(),this._knotTolerance=1e-6,this._controlTolerance=1e-6,this._fitTolerance=1e-9,this._normal=new w(0,0,1),this.rebuild(t,e,i,r,s)}get dxfTypeName(){return"SPLINE"}static fromControlPoints(t,e,i,r,s){const a=jt.fromControlPoints(t,e,i,r,s);return a?Bo(a,s):null}static fromFitPoints(t,e,i,r,s,a){const o=jt.fromFitPoints(t,e,i,r,s,a);return o?Bo(o,r):null}static fromDwgSpline(t){const e=!!(t.flag&1),i=A0(t.flag);if(t.numberOfControlPoints>0&&t.numberOfKnots>0){const r=qe.fromControlPoints(t.controlPoints,t.knots,t.weights,t.degree,e);if(r)return r}return t.numberOfFitPoints>0?qe.fromFitPoints(t.fitPoints,i,t.degree,e,t.startTangent,t.endTangent):null}rebuild(t,e,i,r,s){const a=+(t!==void 0)+ +(e!==void 0)+ +(i!==void 0)+ +(r!==void 0)+ +(s!==void 0);if(a<2||a>5)throw Pt.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new jt(t,e,i,r):this._geo=new jt(t,e,i,r,s)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}get area(){return this._geo.area}set closed(t){this._geo.closed=t}get knotTolerance(){return this._knotTolerance}set knotTolerance(t){this._knotTolerance=t}get controlTolerance(){return this._controlTolerance}set controlTolerance(t){this._controlTolerance=t}get fitTolerance(){return this._fitTolerance}set fitTolerance(t){this._fitTolerance=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}subGetGripPoints(){return this._geo.getGripPoints()}subMoveGripPointsAt(t,e){return this._geo.moveGripPointsAt(t,e),this}subGetOsnapPoints(t,e,i,r){switch(t){case k.EndPoint:r.push(this._geo.startPoint),r.push(this._geo.endPoint);break;case k.Node:{const s=new Set;for(const a of this._geo.knots)s.has(a)||(s.add(a),r.push(this._geo.evaluateAt(a)));break}case k.Nearest:r.push(this._geo.nearestPoint(e));break}}transformBy(t){return this._geo.transform(t),this}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),t.writeDouble(42,this.knotTolerance),t.writeDouble(43,this.controlTolerance),t.writeDouble(44,this.fitTolerance);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 t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSpline");let e=this.closed?1:0,i=3,r=0,s=0,a=0;const o=[],c=[],l=[],h=[];let u=null,d=null,g=this.knotTolerance,p=this.controlTolerance,f=this.fitTolerance,m=this.normal.x,b=this.normal.y,_=this.normal.z,v=null,x=null,S=null,P=null;const E=()=>{v&&(l.push(v),v=null)},O=()=>{x&&(h.push(x),x=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const R=t.readItem();if(!R)break;const N=Number(R.code),M=Number(R.value);switch(N){case 70:e=M;break;case 71:i=M;break;case 72:r=M;break;case 73:s=M;break;case 74:a=M;break;case 42:g=M;break;case 43:p=M;break;case 44:f=M;break;case 40:o.push(M);break;case 41:c.push(M);break;case 10:E(),v={x:M,y:0,z:0};break;case 20:v&&(v.y=M);break;case 30:v&&(v.z=M);break;case 11:O(),x={x:M,y:0,z:0};break;case 21:x&&(x.y=M);break;case 31:x&&(x.z=M);break;case 12:S={x:M,y:0,z:0};break;case 22:S&&(S.y=M);break;case 32:S&&(S.z=M,u=S,S=null);break;case 13:P={x:M,y:0,z:0};break;case 23:P&&(P.y=M);break;case 33:P&&(P.z=M,d=P,P=null);break;case 210:m=M;break;case 220:b=M;break;case 230:_=M;break}}E(),O(),this.knotTolerance=g,this.controlTolerance=p,this.fitTolerance=f;const T=new w(m,b,_);return T.lengthSq()>0&&this.normal.copy(T.normalize()),this.applyDxfInSpline({flag:e,degree:i,numberOfControlPoints:s||l.length,numberOfKnots:r||o.length,numberOfFitPoints:a||h.length,controlPoints:l,knots:o,weights:c.length>0?c:void 0,fitPoints:h,startTangent:u,endTangent:d}),this}applyDxfInSpline(t){const e=qe.fromDwgSpline(t);e&&(this._geo=e._geo,this.closed=e.closed)}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectPath2d(1);return e.length<2?1:kt.from2dPoints(e,this.closed).getOffsetSideAtPoint(t)}createOffsetCurve(t){const{points:e,tangents:i}=this._geo.getOffsetSamplePath2d(t),r=zd(e,this.closed,t,i);return r?kt.fromGePolyline(r):null}collectPath2d(t){return this._geo.getOffsetSamplePath2d(t).points}};qe.typeName="Spline";let Gi=qe;function P0(n){return n==null?pt.latest.capabilities:typeof n=="object"&&"supportsHandles"in n?n:n instanceof pt?n.capabilities:new pt(n).capabilities}const I0=new w,Ia=class Ia extends Jt{get dxfTypeName(){return"ACAD_TABLE"}constructor(t,e,i){super(t),this._attachmentPoint=exports.AcGiMTextAttachmentPoint.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}resizeGrid(t,e){const i=Math.max(0,t),r=Math.max(0,e);this._numRows=i,this._numColumns=r,this._rowHeight=new Array(i).fill(0),this._columnWidth=new Array(r).fill(0),this._cells=new Array(i*r)}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 s;const r=t*this._numColumns+e;return(s=this._cells[r])==null?void 0:s.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(){let t;try{t=this.blockTableRecord}catch{t=void 0}if(t&&t.newIterator().count>0){const o=new Y;for(const c of t.newIterator())o.union(c.geometricExtents);return o.applyMatrix4(this.blockTransform),o}const e=this._columnWidth.reduce((o,c)=>o+c,0),i=this._rowHeight.reduce((o,c)=>o+c,0),r=new Y;if(e===0&&i===0)return r.expandByPoint(this.position),r;const s=new Je;s.setFromAxisAngle(w.Z_AXIS,this.rotation),Fe.compose(this.position,s,this.scaleFactors);const a=[new y(0,0,0),new y(e,0,0),new y(e,-i,0),new y(0,-i,0)];for(const o of a)r.expandByPoint(o.applyMatrix4(Fe));return r}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"table",properties:[{name:"numRows",type:"string",editable:!0,accessor:{get:()=>this.numRows,set:t=>{this.numRows=t}}},{name:"numColumns",type:"float",editable:!0,accessor:{get:()=>this.numColumns,set:t=>{this.numColumns=t}}},{name:"tableWidth",type:"float",editable:!1,accessor:{get:()=>this._columnWidth.reduce((t,e)=>t+e,0)}},{name:"tableHeight",type:"float",editable:!1,accessor:{get:()=>this._rowHeight.reduce((t,e)=>t+e,0)}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}subWorldDraw(t){const e=this.blockTableRecord;if(e&&e.newIterator().count>0){const g=this.drawAnonymousTableBlock(t,e);if(g)return g}let i=0,r=0;const s=new Uint16Array(this.numColumns*this.numRows*8),a=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let o=0;for(let g=0;g<=this.numRows;g++){i-=g>0?this.rowHeight(g-1):0,r=0;for(let p=0;p<=this.numColumns;p++)r+=p>0?this.columnWidth(p-1):0,a[o++]=r,a[o++]=i,a[o++]=0}const c=[],l=new Array(this.numRows*this.numColumns).fill(!1);r=0,o=0;let h=0;for(let g=0;g<this.numColumns;g++){r+=g>0?this.columnWidth(g-1):0,i=0;for(let p=0;p<this.numRows;p++){i+=p>0?this.rowHeight(p-1):0;const f=this.cell(p*this.numColumns+g);if(h=p*this.numColumns+g,f&&!l[h]){const m=f.borderWidth??1,b=f.borderHeight??1;this.fillVisited(l,h,this.numColumns,m,b),s[o++]=g+p*(this.numColumns+1),s[o++]=g+p*(this.numColumns+1)+m;const _=a[s[o-1]*3]-r,v=g+(p+b)*(this.numColumns+1)+m;g+m==this.numColumns&&(s[o++]=g+p*(this.numColumns+1)+m,s[o++]=v);const x=-a[v*3+1]-i;if(p+b==this.numRows&&(s[o++]=g+(p+b)*(this.numColumns+1)+b,s[o++]=g+(p+b)*(this.numColumns+1)),s[o++]=g+(p+b)*(this.numColumns+1),s[o++]=g+p*(this.numColumns+1),f.text){const S=f.attachmentPoint||this.attachmentPoint||exports.AcGiMTextAttachmentPoint.MiddleCenter,P=this.getTableTextOffset(S,_,x),E={text:f.text,height:this.getCellTextHeight(f,x),width:_,position:I0.set(r,-i,0).clone().add(P),rotation:this.rotation,attachmentPoint:S},O=this.getTextStyle(f);c.push(t.mtext(E,O))}}}}c.push(t.lineSegments(a,3,s));const u=t.group(c),d=new Je;return d.setFromAxisAngle(w.Z_AXIS,this.rotation),Fe.compose(this.position,d,this.scaleFactors),u.applyMatrix(Fe),u}drawAnonymousTableBlock(t,e){const i=[],r=e.newIterator();for(const o of r){let c;if(o.color.isByBlock){Fo.copy(o.color);const l=this.resolvedColor;l.isForeground?o.color.setForeground():l.RGB!=null&&o.color.setRGBValue(l.RGB),c=o.worldDraw(t),o.color.copy(Fo)}else c=o.worldDraw(t);c&&(c.objectId=this.objectId,c.ownerId=this.ownerId,c.layerName=this.layer,c.visible=this.visibility&&o.visibility,i.push(c))}const s=t.group(i);s.applyMatrix(this.blockTransform);const a=this.normal;return a&&(a.x!==0||a.y!==0||a.z!==1)&&(Fe.setFromExtrusionDirection(a),s.applyMatrix(Fe)),s}fillVisited(t,e,i,r,s){if(s==1&&r==1)t[e]=!0;else for(let a=0;a<r;++a)for(let o=0;o<s;++o)t[e+a+o*i]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable.resolveAt(t.textStyle);if(!e)throw new Error("No valid text style found in text style table.");return e.textStyle}getTableTextOffset(t,e,i){const r=new w;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}getCellTextHeight(t,e){return t.textHeight&&t.textHeight>0?t.textHeight:Math.max(e/2,1)}dxfOutFields(t){var s,a,o,c,l,h,u;super.dxfOutFields(t),t.writeSubclassMarker("AcDbTable");const e=t.version??((s=t.database)==null?void 0:s.version)??((a=this.database)==null?void 0:a.version),i=P0(e).supportsUtf8CodePage;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 d=0;d<this.numRows;++d)t.writeDouble(141,this.rowHeight(d));for(let d=0;d<this.numColumns;++d)t.writeDouble(142,this.columnWidth(d));const r=this._cells.length>0?this._cells.length:this.numRows*this.numColumns;for(let d=0;d<r;d++){const g=this._cells[d],p=(g==null?void 0:g.cellType)??(g!=null&&g.blockTableRecordId?2:1);if(t.writeInt16(171,p),t.writeInt16(172,(g==null?void 0:g.flagValue)??0),t.writeInt16(173,(g==null?void 0:g.mergedValue)??0),t.writeBoolean(174,g==null?void 0:g.autoFit),t.writeInt16(175,g==null?void 0:g.borderWidth),t.writeInt16(176,g==null?void 0:g.borderHeight),(g==null?void 0:g.overrideFlag)!=null&&(i?t.writeInt32(91,g.overrideFlag):t.writeInt16(177,g.overrideFlag)),t.writeInt16(178,g==null?void 0:g.virtualEdgeFlag),t.writeAngle(145,g==null?void 0:g.rotation),i&&t.writeInt16(92,g==null?void 0:g.extendedCellFlags),p===1)g!=null&&g.fieldObjetId?t.writeObjectId(344,g.fieldObjetId):this.writeCellText(t,(g==null?void 0:g.text)??"",i,g==null?void 0:g.cellValueBlockBegin);else if(p===2){if(t.writeObjectId(340,g==null?void 0:g.blockTableRecordId),t.writeDouble(144,g==null?void 0:g.blockScale),t.writeInt16(179,g==null?void 0:g.blockAttrNum),(o=g==null?void 0:g.attrDefineId)!=null&&o.length)for(const f of g.attrDefineId)t.writeObjectId(331,f);if((g==null?void 0:g.attrText)!=null)if(Array.isArray(g.attrText))for(const f of g.attrText)t.writeString(300,f);else t.writeString(300,g.attrText)}g!=null&&g.textStyle&&t.writeString(7,g.textStyle),(g==null?void 0:g.textHeight)!=null&&t.writeDouble(140,g.textHeight),(g==null?void 0:g.attachmentPoint)!=null&&t.writeInt16(170,g.attachmentPoint),(g==null?void 0:g.topBorderVisibility)!=null&&t.writeInt16(289,g.topBorderVisibility?1:0),(g==null?void 0:g.rightBorderVisibility)!=null&&t.writeInt16(285,g.rightBorderVisibility?1:0),(g==null?void 0:g.bottomBorderVisibility)!=null&&t.writeInt16(286,g.bottomBorderVisibility?1:0),(g==null?void 0:g.leftBorderVisibility)!=null&&t.writeInt16(288,g.leftBorderVisibility?1:0)}if(t.writeInt16(70,this.flowDirection),t.writeDouble(40,this.horizontalCellMargin),t.writeDouble(41,this.verticalCellMargin),this.suppressTitle!=null&&t.writeInt16(280,this.suppressTitle?1:0),this.suppressHeader!=null&&t.writeInt16(281,this.suppressHeader?1:0),(c=this.cellTypeOverrides)!=null&&c.length)for(const d of this.cellTypeOverrides){t.writeString(7,d.textStyle),t.writeDouble(140,d.textHeight),t.writeInt16(170,d.alignment),t.writeInt16(63,d.backgroundColor),t.writeInt16(64,d.contentColor),d.backgroundColorEnabled!=null&&t.writeInt16(283,d.backgroundColorEnabled?1:0);const g=d.borderLineweights;g&&(t.writeInt16(274,g.top),t.writeInt16(275,g.right),t.writeInt16(276,g.bottom),t.writeInt16(277,g.left),t.writeInt16(278,g.insideHorizontal),t.writeInt16(279,g.insideVertical));const p=d.borderVisibility;p&&(t.writeInt16(284,p.top?1:0),t.writeInt16(285,p.right?1:0),t.writeInt16(286,p.bottom?1:0),t.writeInt16(287,p.left?1:0),t.writeInt16(288,p.insideHorizontal?1:0),t.writeInt16(289,p.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)),(l=this.rowDataTypes)!=null&&l.length)for(const d of this.rowDataTypes)t.writeInt16(97,d);if((h=this.rowUnitTypes)!=null&&h.length)for(const d of this.rowUnitTypes)t.writeInt16(98,d);if((u=this.rowFormats)!=null&&u.length)for(const d of this.rowFormats)t.writeString(4,d);return this}dxfInFields(t){var f,m,b;super.dxfInFields(t),t.atSubclassData("AcDbTable");let e=this._numRows,i=this._numColumns,r=!1;const s=[],a=[];let o=0,c=null,l=[],h=((f=this.horizontalDirection)==null?void 0:f.x)??1,u=((m=this.horizontalDirection)==null?void 0:m.y)??0,d=((b=this.horizontalDirection)==null?void 0:b.z)??0;const g=()=>{e>0&&i>0&&(!r||this._numRows!==e||this._numColumns!==i)&&(this.resizeGrid(e,i),r=!0)},p=()=>{c&&(l.length>0&&(c.text=l.join(""),l=[]),g(),o<this._cells.length&&this.setCell(o,c),o+=1,c=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const _=t.readItem();if(!_)break;const v=Number(_.code),x=Number(_.value);switch(v){case 280:c||(this.tableDataVersion=x);break;case 342:this.tableStyleId=String(_.value);break;case 343:this.owningBlockRecordId=String(_.value);break;case 11:h=x;break;case 21:u=x;break;case 31:d=x;break;case 90:c||(this.tableValueFlag=x);break;case 93:c||(this.tableOverrideFlag=x);break;case 94:c||(this.borderColorOverrideFlag=x);break;case 95:c||(this.borderLineweightOverrideFlag=x);break;case 96:c||(this.borderVisibilityOverrideFlag=x);break;case 71:this.attachmentPoint=x;break;case 170:c?c.attachmentPoint=x:this.attachmentPoint=x;break;case 91:c?c&&(c.overrideFlag=x):(e=x,g());break;case 92:c?c&&(c.extendedCellFlags=x):(i=x,g());break;case 141:s.push(x);break;case 142:a.push(x);break;case 171:p(),c={text:"",attachmentPoint:exports.AcGiMTextAttachmentPoint.MiddleCenter,cellType:x,textHeight:0};break;case 172:c&&(c.flagValue=x);break;case 173:c&&(c.mergedValue=x);break;case 174:c&&(c.autoFit=!!_.value||x!==0);break;case 175:c&&(c.borderWidth=x);break;case 176:c&&(c.borderHeight=x);break;case 177:c&&(c.overrideFlag=x);break;case 178:c&&(c.virtualEdgeFlag=x);break;case 145:c&&(c.rotation=x*Math.PI/180);break;case 1:case 2:case 302:case 303:l.push(String(_.value));break;case 300:if(c){const S=c.attrText;Array.isArray(S)?S.push(String(_.value)):S!=null&&S!==""?c.attrText=[String(S),String(_.value)]:c.attrText=String(_.value)}break;case 301:c&&(c.cellValueBlockBegin=String(_.value));break;case 304:break;case 7:c&&(c.textStyle=String(_.value));break;case 140:c&&(c.textHeight=x);break;case 340:c&&(c.blockTableRecordId=String(_.value));break;case 344:case 345:c&&(c.fieldObjetId=String(_.value));break;case 144:case 146:c&&(c.blockScale=x);break;case 179:c&&(c.blockAttrNum=x);break;case 70:this.flowDirection=x;break;case 40:this.horizontalCellMargin=x;break;case 41:this.verticalCellMargin=x;break;case 281:this.suppressHeader=x!==0;break}}return p(),this.horizontalDirection=new w(h,u,d),s.forEach((_,v)=>this.setRowHeight(v,_)),a.forEach((_,v)=>this.setColumnWidth(v,_)),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 c=0;c<o;c++){const l=c*250,h=l+250,u=e.slice(l,h);c===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 c=o*250,l=c+250,h=e.slice(c,l);o===a-1?t.writeString(302,h):t.writeString(303,h)}t.writeString(304,"ACVALUE_END")}};Ia.typeName="Table";let Gn=Ia;const Fe=new D,Fo=new X,Ea=class Ea extends H{constructor(){super(),this._snapBase=new y,this._snapSpacing=new y(1,1,0),this._gridSpacing=new y(1,1,0),this._perspectiveLensLength=50,this._frontClipZ=0,this._backClipZ=0,this._snapAngle=0,this._status=0,this._ucsPerViewport=0,this._circleZoomPercent=1e3,this._statusBitFlags=0,this._ucsOrigin=new y,this._ucsXAxis=new w(1,0,0),this._ucsYAxis=new w(0,1,0),this._elevation=0,this._frozenLayerIds=[],this._sheetName="",this._iconFlag=0,this._orthographicType=0,this._majorGridFrequency=0,this._ambientLightColorIndex=0,this._brightness=0,this._contrast=0,this._shadePlotMode=0,this._renderMode=0,this._defaultLightingType=0,this._isDefaultLighting=!1,this._clippingBoundaryId="",this._backgroundId="",this._shadePlotId="",this._ucsId="",this._ucsBaseId="",this._visualStyleId="",this._sunId="",this._ambientLightColorInstance=0,this._ambientLightColorName="",this._softPointers=[],this._centerPoint=new y,this._height=0,this._width=0,this._viewCenter=new y,this._viewTarget=new y,this._viewDirection=new w(0,0,1),this._viewTwistAngle=0,this._viewHeight=0,this._number=-1}get dxfTypeName(){return"VIEWPORT"}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 viewTarget(){return this._viewTarget}set viewTarget(t){this._viewTarget=t}get viewDirection(){return this._viewDirection}set viewDirection(t){this._viewDirection.copy(t)}get snapBase(){return this._snapBase}set snapBase(t){this._snapBase.copy(t)}get snapSpacing(){return this._snapSpacing}set snapSpacing(t){this._snapSpacing.copy(t)}get gridSpacing(){return this._gridSpacing}set gridSpacing(t){this._gridSpacing.copy(t)}get perspectiveLensLength(){return this._perspectiveLensLength}set perspectiveLensLength(t){this._perspectiveLensLength=t}get frontClipZ(){return this._frontClipZ}set frontClipZ(t){this._frontClipZ=t}get backClipZ(){return this._backClipZ}set backClipZ(t){this._backClipZ=t}get snapAngle(){return this._snapAngle}set snapAngle(t){this._snapAngle=t}get status(){return this._status}set status(t){this._status=t}get ucsPerViewport(){return this._ucsPerViewport}set ucsPerViewport(t){this._ucsPerViewport=t}get circleZoomPercent(){return this._circleZoomPercent}set circleZoomPercent(t){this._circleZoomPercent=t}get statusBitFlags(){return this._statusBitFlags}set statusBitFlags(t){this._statusBitFlags=t}get ucsOrigin(){return this._ucsOrigin}set ucsOrigin(t){this._ucsOrigin.copy(t)}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get frozenLayerIds(){return this._frozenLayerIds}set frozenLayerIds(t){this._frozenLayerIds=[...t]}get ucsXAxis(){return this._ucsXAxis}set ucsXAxis(t){this._ucsXAxis.copy(t)}get ucsYAxis(){return this._ucsYAxis}set ucsYAxis(t){this._ucsYAxis.copy(t)}get sheetName(){return this._sheetName}set sheetName(t){this._sheetName=t}get iconFlag(){return this._iconFlag}set iconFlag(t){this._iconFlag=t}get orthographicType(){return this._orthographicType}set orthographicType(t){this._orthographicType=t}get majorGridFrequency(){return this._majorGridFrequency}set majorGridFrequency(t){this._majorGridFrequency=t}get ambientLightColorIndex(){return this._ambientLightColorIndex}set ambientLightColorIndex(t){this._ambientLightColorIndex=t}get viewportBrightness(){return this._brightness}set viewportBrightness(t){this._brightness=t}get viewportContrast(){return this._contrast}set viewportContrast(t){this._contrast=t}get shadePlotMode(){return this._shadePlotMode}set shadePlotMode(t){this._shadePlotMode=t}get renderMode(){return this._renderMode}set renderMode(t){this._renderMode=t}get defaultLightingType(){return this._defaultLightingType}set defaultLightingType(t){this._defaultLightingType=t}get isDefaultLighting(){return this._isDefaultLighting}set isDefaultLighting(t){this._isDefaultLighting=t}get clippingBoundaryId(){return this._clippingBoundaryId}set clippingBoundaryId(t){this._clippingBoundaryId=t}get backgroundId(){return this._backgroundId}set backgroundId(t){this._backgroundId=t}get shadePlotId(){return this._shadePlotId}set shadePlotId(t){this._shadePlotId=t}get ucsId(){return this._ucsId}set ucsId(t){this._ucsId=t}get ucsBaseId(){return this._ucsBaseId}set ucsBaseId(t){this._ucsBaseId=t}get visualStyleId(){return this._visualStyleId}set visualStyleId(t){this._visualStyleId=t}get sunId(){return this._sunId}set sunId(t){this._sunId=t}get ambientLightColorInstance(){return this._ambientLightColorInstance}set ambientLightColorInstance(t){this._ambientLightColorInstance=t}get ambientLightColorName(){return this._ambientLightColorName}set ambientLightColorName(t){this._ambientLightColorName=t}get softPointers(){return this._softPointers}set softPointers(t){this._softPointers=[...t]}get viewTwistAngle(){return this._viewTwistAngle}set viewTwistAngle(t){this._viewTwistAngle=t}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get geometricExtents(){const t=this._width/2,e=this._height/2,i=new Y;return i.expandByPoint(new y(this._centerPoint.x-t,this._centerPoint.y-e,this._centerPoint.z)),i.expandByPoint(new y(this._centerPoint.x+t,this._centerPoint.y+e,this._centerPoint.z)),i}subGetGripPoints(){const t=new Array,e=this._width/2,i=this._height/2,r=this._centerPoint.z;return t.push(this._centerPoint),(e>0||i>0)&&t.push(new y(this._centerPoint.x-e,this._centerPoint.y-i,r),new y(this._centerPoint.x+e,this._centerPoint.y-i,r),new y(this._centerPoint.x+e,this._centerPoint.y+i,r),new y(this._centerPoint.x-e,this._centerPoint.y+i,r)),t}subMoveGripPointsAt(t,e){return ht(t,i=>{this.moveGripAt(i,e)}),this}transformBy(t){const e=this._centerPoint.clone(),i=this._centerPoint.clone().add(new w(this._width,0,0)),r=this._centerPoint.clone().add(new w(0,this._height,0));e.applyMatrix4(t),i.applyMatrix4(t),r.applyMatrix4(t);const s=new w(i).sub(e),a=new w(r).sub(e),o=this._height!==0?a.length()/this._height:1;return this._centerPoint.copy(e),this._width=s.length(),this._height=a.length(),this._viewHeight*=o,this}subWorldDraw(t){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const e=this.toGiViewport();return t.group(this.createViewportRect(e,t))}}toGiViewport(){const t=new Jc;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.viewTarget=this.viewTarget,t.viewTwistAngle=this.viewTwistAngle,t}createViewportRect(t,e){const i=[];return i.push(e.lines([new y(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new y(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)])),i.push(e.lines([new y(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new y(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)])),i.push(e.lines([new y(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new y(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)])),i.push(e.lines([new y(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new y(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0)])),i}dxfOutFields(t){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.writePoint3d(13,this.snapBase),t.writePoint3d(14,this.snapSpacing),t.writePoint3d(15,this.gridSpacing),t.writeVector3d(16,this.viewDirection),t.writePoint3d(17,this.viewTarget),t.writeDouble(42,this.perspectiveLensLength),t.writeDouble(43,this.frontClipZ),t.writeDouble(44,this.backClipZ),t.writeDouble(45,this.viewHeight),t.writeAngle(50,this.snapAngle),t.writeAngle(51,this.viewTwistAngle),t.writeInt16(68,this.status),t.writeInt32(69,this.number),t.writeInt16(71,this.ucsPerViewport),t.writeInt16(72,this.circleZoomPercent),t.writeInt32(90,this.statusBitFlags);for(const e of this.frozenLayerIds)t.writeObjectId(331,e);t.writePoint3d(110,this.ucsOrigin),t.writeVector3d(111,this.ucsXAxis),t.writeVector3d(112,this.ucsYAxis),t.writeDouble(146,this.elevation),this.sheetName&&t.writeString(1,this.sheetName),t.writeInt16(61,this.majorGridFrequency),t.writeInt16(63,this.ambientLightColorIndex),t.writeInt16(74,this.iconFlag),t.writeInt16(79,this.orthographicType);for(const e of this.softPointers)t.writeObjectId(91,e);return t.writeDouble(141,this.viewportBrightness),t.writeDouble(142,this.viewportContrast),t.writeInt16(170,this.shadePlotMode),t.writeInt16(281,this.renderMode),t.writeInt16(282,this.defaultLightingType),t.writeInt16(292,this.isDefaultLighting?1:0),this.clippingBoundaryId&&t.writeObjectId(340,this.clippingBoundaryId),this.backgroundId&&t.writeObjectId(332,this.backgroundId),this.shadePlotId&&t.writeObjectId(333,this.shadePlotId),this.ucsId&&t.writeObjectId(345,this.ucsId),this.ucsBaseId&&t.writeObjectId(346,this.ucsBaseId),this.visualStyleId&&t.writeObjectId(348,this.visualStyleId),this.sunId&&t.writeObjectId(361,this.sunId),this.ambientLightColorInstance&&t.writeInt32(421,this.ambientLightColorInstance),this.ambientLightColorName&&t.writeString(431,this.ambientLightColorName),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbViewport");let e=this.centerPoint.x,i=this.centerPoint.y,r=this.centerPoint.z,s=this.viewCenter.x,a=this.viewCenter.y,o=this.viewCenter.z,c=this.viewTarget.x,l=this.viewTarget.y,h=this.viewTarget.z,u=this.viewDirection.x,d=this.viewDirection.y,g=this.viewDirection.z,p=this.snapBase.x,f=this.snapBase.y,m=this.snapBase.z,b=this.snapSpacing.x,_=this.snapSpacing.y,v=this.snapSpacing.z,x=this.gridSpacing.x,S=this.gridSpacing.y,P=this.gridSpacing.z,E=this.ucsOrigin.x,O=this.ucsOrigin.y,T=this.ucsOrigin.z,R=this.ucsXAxis.x,N=this.ucsXAxis.y,M=this.ucsXAxis.z,A=this.ucsYAxis.x,V=this.ucsYAxis.y,$=this.ucsYAxis.z;const Q=[],et=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const W=t.readItem();if(!W)break;const Dt=Number(W.code),B=Number(W.value);switch(Dt){case 1:this.sheetName=String(W.value);break;case 10:e=B;break;case 20:i=B;break;case 30:r=B;break;case 12:s=B;break;case 22:a=B;break;case 32:o=B;break;case 13:p=B;break;case 23:f=B;break;case 33:m=B;break;case 14:b=B;break;case 24:_=B;break;case 34:v=B;break;case 15:x=B;break;case 25:S=B;break;case 35:P=B;break;case 16:u=B;break;case 26:d=B;break;case 36:g=B;break;case 17:c=B;break;case 27:l=B;break;case 37:h=B;break;case 40:this.height=B;break;case 41:this.width=B;break;case 42:this.perspectiveLensLength=B;break;case 43:this.frontClipZ=B;break;case 44:this.backClipZ=B;break;case 45:this.viewHeight=B;break;case 50:this.snapAngle=C.degToRad(B);break;case 51:this.viewTwistAngle=C.degToRad(B);break;case 61:this.majorGridFrequency=B;break;case 63:this.ambientLightColorIndex=B;break;case 68:this.status=B;break;case 69:this.number=B;break;case 71:this.ucsPerViewport=B;break;case 72:this.circleZoomPercent=B;break;case 74:this.iconFlag=B;break;case 79:this.orthographicType=B;break;case 90:this.statusBitFlags=B;break;case 91:case 335:case 343:case 344:et.push(String(W.value));break;case 110:E=B;break;case 120:O=B;break;case 130:T=B;break;case 111:R=B;break;case 121:N=B;break;case 131:M=B;break;case 112:A=B;break;case 122:V=B;break;case 132:$=B;break;case 141:this.viewportBrightness=B;break;case 142:this.viewportContrast=B;break;case 146:this.elevation=B;break;case 170:this.shadePlotMode=B;break;case 281:this.renderMode=B;break;case 282:this.defaultLightingType=B;break;case 292:this.isDefaultLighting=B!==0;break;case 331:Q.push(String(W.value));break;case 332:this.backgroundId=String(W.value);break;case 333:this.shadePlotId=String(W.value);break;case 340:this.clippingBoundaryId=String(W.value);break;case 345:this.ucsId=String(W.value);break;case 346:this.ucsBaseId=String(W.value);break;case 348:this.visualStyleId=String(W.value);break;case 361:this.sunId=String(W.value);break;case 421:this.ambientLightColorInstance=B;break;case 431:this.ambientLightColorName=String(W.value);break}}return this.applyViewportDxfIn(e,i,r,s,a,o,c,l,h),this._viewDirection.copy({x:u,y:d,z:g}),this._snapBase.copy({x:p,y:f,z:m}),this._snapSpacing.copy({x:b,y:_,z:v}),this._gridSpacing.copy({x,y:S,z:P}),this._ucsOrigin.copy({x:E,y:O,z:T}),this._ucsXAxis.copy({x:R,y:N,z:M}),this._ucsYAxis.copy({x:A,y:V,z:$}),this.frozenLayerIds=Q,this.softPointers=et,this}applyViewportDxfIn(t,e,i,r,s,a,o,c,l){this.centerPoint.copy({x:t,y:e,z:i}),this.viewCenter.copy({x:r,y:s,z:a}),this.viewTarget.copy({x:o,y:c,z:l});const h=1e-6,u=Math.abs(t)<h&&Math.abs(e)<h,d=Math.abs(o)<h&&Math.abs(c)<h,g=Number.isFinite(this.height)&&Number.isFinite(this.viewHeight)&&Math.abs(this.viewHeight-this.height)<h;u&&d&&g&&this.centerPoint.copy(this.viewCenter)}moveGripAt(t,e){switch(t){case 0:this._centerPoint.add(e);break;case 1:case 2:case 3:case 4:{const i=this.width/2,r=this.height/2,s=this._centerPoint.x,a=this._centerPoint.y,o={1:{x:s-i,y:a-r},2:{x:s+i,y:a-r},3:{x:s+i,y:a+r},4:{x:s-i,y:a+r}},c=t===1?3:t===2?4:t===3?1:2,l=o[t],h=o[c];l.x+=e.x,l.y+=e.y,this._centerPoint.x=(l.x+h.x)/2,this._centerPoint.y=(l.y+h.y)/2,this._centerPoint.z=(this._centerPoint.z??0)+(e.z??0),this.width=Math.abs(h.x-l.x),this.height=Math.abs(h.y-l.y);break}}}};Ea.typeName="Viewport";let Un=Ea;const La=class La extends ji{get dxfTypeName(){return"WIPEOUT"}subWorldDraw(t){const e=this.boundaryPath(),i=new Vt;return i.add(new q(e)),t.area(i)}dxfOutFields(t){return super.dxfOutFields(t),this}};La.typeName="Wipeout";let Hn=La;const gr=class gr extends _t{get dxfTypeName(){return"XLINE"}constructor(){super(),this._basePoint=new y,this._unitDir=new w}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 area(){return 0}get geometricExtents(){const t=new Y;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}subMoveGripPointsAt(t,e){return te(t,e,this.basePoint),this}subGetOsnapPoints(t,e,i,r){const s=this.basePoint;if(t===k.EndPoint){r.push(s);return}const a=this.unitDir.clone();if(a.lengthSq()===0)return;a.normalize();const o=new ue(s,s.clone().add(a));switch(t){case k.Nearest:r.push(o.project(e));break;case k.Perpendicular:r.push(o.perpPoint(e));break}}transformBy(t){return this._basePoint.applyMatrix4(t),this._unitDir.transformDirection(t),this}subWorldDraw(t){const e=[];return e.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbXline"),t.writePoint3d(10,this.basePoint),t.writeVector3d(11,this.unitDir),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbXline");let e=this.basePoint.x,i=this.basePoint.y,r=this.basePoint.z,s=this.unitDir.x,a=this.unitDir.y,o=this.unitDir.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const c=t.readItem();if(!c)break;const l=Number(c.code),h=Number(c.value);switch(l){case 10:e=h;break;case 20:i=h;break;case 30:r=h;break;case 11:s=h;break;case 21:a=h;break;case 31:o=h;break}}return this.basePoint=new y(e,i,r),this.unitDir=new w(s,a,o),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.basePoint,i=this.unitDir,r=Math.hypot(i.x,i.y);return r<=1e-9||(i.x*(t.y-e.y)-i.y*(t.x-e.x))/r>=0?1:-1}createOffsetCurve(t){const e=Lc(this.basePoint,this.unitDir,t);if(!e)return null;const i=new gr;return i.basePoint=e,i.unitDir=this.unitDir.clone(),i}};gr.typeName="Xline";let Wn=gr;var qh=(n=>(n.ClosedFilled="",n.Dot="_DOT",n.DotSmall="_DOTSMALL",n.DotBlank="_DOTBLANK",n.Origin="_ORIGIN",n.Origin2="_ORIGIN2",n.Open="_OPEN",n.Open90="_OPEN90",n.Open30="_OPEN30",n.Closed="_CLOSED",n.Small="_SMALL",n.None="_NONE",n.Oblique="_OBLIQUE",n.BoxFilled="_BOXFILLED",n.Box="_BOXBLANK",n.ClosedBlank="_CLOSEDBLANK",n.DatumBlank="_DATUMBLANK",n.DatumFilled="_DATUMFILLED",n.Integral="_INTEGRAL",n.ArchTick="_ARCHTICK",n))(qh||{});const De=48,Do=8,E0=48,Kh=80,Zh=32,Jr=80,ts=24,Es=40,L0=8,T0=4,Yo=64,C0=64,M0=new Set(["_version","_angbase","_angdir","_aunits","_auprec","_lunits","_luprec","_celtscale","_cecolor","_celtype","_celweight","_cetransparency","_clayer","_cmlstyle","_cmlscale","_cmleaderstyle","_hpbackgroundcolor","_hpcolor","_hplayer","_hptransparency","_textstyle","_dimstyle","_dimstyle","_dimstyle","_extents","_insunits","_unitmode","_measurement","_ltscale","_lwdisplay","_pdmode","_pdsize","_osmode","_orthomode","_maxHandle","_drawNoPlotLayers","_dwgname","_currentSpace","_formatter","_eventBatchDepth","_pendingEntityAppended","_pendingEntityErased","_pendingDictObjectSet","_pendingDictObjectErased","_lastOpenError"]),Qh=new Set(["constructor","prototype","__proto__","caller","callee","arguments"]);function Ut(n,t){let e=n.get(t);return e||(e={bytes:0,count:0},n.set(t,e)),e}function Ot(n,t,e,i=0){if(e<=0&&i===0)return;const r=Ut(n.byCategory,t);r.bytes+=e,r.count+=i}function O0(n){const t=Object.getPrototypeOf(n);return t===Object.prototype||t===null}function N0(n){return ArrayBuffer.isView(n)}function R0(n){return typeof n.addEventListener=="function"&&typeof n.dispatch=="function"&&"listeners"in n}function B0(n,t,e){return Qh.has(t)?!0:!n.includeEventManagers&&(t==="events"||e==="events")?t==="events":!n.includeTransactionManager&&(t==="transactionManager"||e==="transaction")?t==="transactionManager":!1}function Xo(n,t,e){return t==="_xDataMap"||n==="xdata"?"xdata":t==="_tables"||n==="tables"?e instanceof H?"entities":"tables":t==="_entities"||n==="entities"?"entities":t==="_objects"||n==="objects"?"objects":t==="_handleRegistry"||n==="handleRegistry"?"handleRegistry":t==="transactionManager"||n==="transaction"?"transaction":t==="events"||n==="events"?"events":n==="sysvars"||M0.has(t)?"sysvars":e instanceof H?"entities":n==="other"?"other":n}function F0(n){const t=new Set;let e=n;for(;e&&e!==Object.prototype;){for(const i of Object.getOwnPropertyNames(e)){if(Qh.has(i))continue;const r=Object.getOwnPropertyDescriptor(e,i);r&&typeof r.value=="function"||r&&(r.get||r.set)&&r.value===void 0||t.add(i)}if(e=Object.getPrototypeOf(e),e===Object.prototype||e===null||e===Array.prototype||e===Map.prototype||e===Set.prototype)break}return[...t]}function Jh(n){if(n==null)return 0;switch(typeof n){case"number":return L0;case"boolean":return T0;case"string":return Es+n.length*2;case"bigint":return 16;case"symbol":return Es+String(n.description??"").length*2;default:return 0}}function D0(n,t){if(n.visited.has(t))return 0;n.visited.add(t),n.objectCount+=1;let e=Kh+t.size*Zh;for(const i of t.keys())e+=Jh(i);return Ot(n,"handleRegistry",e,1),e}function Xe(n,t,e,i){if(t==null)return 0;const r=typeof t;if(r==="function")return 0;if(r!=="object"){const h=Jh(t);if(Ot(n,e,h),i){const u=Ut(n.byEntityType,i);u.bytes+=h}return h}const s=t;if(typeof s.nodeType=="number"||n.visited.has(s))return 0;if(n.visited.add(s),n.objectCount+=1,!n.includeEventManagers&&R0(s))return Ot(n,e,De,1),De;let a=i,o=e;if(s instanceof H){o="entities",a=s.type,n.entityCount+=1;const h=Ut(n.byEntityType,a);h.count+=1}if(typeof s.then=="function")return Ot(n,o,De,1),De;if(s instanceof ArrayBuffer){const h=Yo+s.byteLength;return Ot(n,o,h,1),a&&(Ut(n.byEntityType,a).bytes+=h),h}if(N0(s)){const h=Yo+s.byteLength;return s.buffer&&!n.visited.has(s.buffer)&&n.visited.add(s.buffer),Ot(n,o,h,1),a&&(Ut(n.byEntityType,a).bytes+=h),h}if(typeof Blob<"u"&&s instanceof Blob){const h=C0+s.size;return Ot(n,o,h,1),a&&(Ut(n.byEntityType,a).bytes+=h),h}if(s instanceof Date){const h=De+8;return Ot(n,o,h,1),h}if(s instanceof Map){const h=o==="handleRegistry",u=Kh+s.size*Zh;let d=u;Ot(n,o,u,1),a&&(Ut(n.byEntityType,a).bytes+=u);for(const[g,p]of s)d+=Xe(n,g,o,a),h||(d+=Xe(n,p,o,a));return d}if(s instanceof Set){let h=Jr+s.size*ts;for(const u of s)h+=Xe(n,u,o,a);return Ot(n,o,Jr+s.size*ts,1),a&&(Ut(n.byEntityType,a).bytes+=Jr+s.size*ts),h}if(Array.isArray(s)){let h=E0+s.length*Do;Ot(n,o,h,1),a&&(Ut(n.byEntityType,a).bytes+=h);for(let u=0;u<s.length;u++){const d=s[u],g=Xo(o,String(u),d);h+=Xe(n,d,g,a)}return h}let c=De;const l=O0(s)?Object.getOwnPropertyNames(s):F0(s);for(const h of l)c+=Do,c+=Math.min(Es+h.length*2,64);Ot(n,o,c,1),a&&(Ut(n.byEntityType,a).bytes+=c);for(const h of l){if(B0(n,h,o)||h==="_database"||h==="database")continue;let u;try{u=s[h]}catch{continue}if(typeof u=="function")continue;if(h==="_handleRegistry"&&u instanceof Map){c+=D0(n,u);continue}const d=Xo(o,h,u);!n.includeTransactionManager&&d==="transaction"||!n.includeEventManagers&&d==="events"||(c+=Xe(n,u,d,a))}return c}function Y0(n,t){const e={visited:new WeakSet,objectCount:0,entityCount:0,byCategory:new Map,byEntityType:new Map,includeTransactionManager:(t==null?void 0:t.includeTransactionManager)===!0,includeEventManagers:(t==null?void 0:t.includeEventManagers)===!0};Xe(e,n,"sysvars",null);let i=0;const r={};for(const[a,o]of e.byCategory)r[a]={bytes:o.bytes,count:o.count},i+=o.bytes;const s={};for(const[a,o]of e.byEntityType)s[a]={bytes:o.bytes,count:o.count};return{totalBytes:i,objectCount:e.objectCount,entityCount:e.entityCount,byCategory:r,byEntityType:s}}function es(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(2)} KiB`:`${(n/(1024*1024)).toFixed(2)} MiB`}function X0(n){const t=[`AcDbDatabase memory estimate: ${es(n.totalBytes)} (${n.totalBytes} bytes)`,`Objects: ${n.objectCount}, Entities: ${n.entityCount}`,"By category:"],e=Object.entries(n.byCategory).sort((r,s)=>s[1].bytes-r[1].bytes);for(const[r,s]of e)t.push(` ${r}: ${es(s.bytes)} (${s.bytes} bytes), count=${s.count}`);const i=Object.entries(n.byEntityType).sort((r,s)=>s[1].bytes-r[1].bytes);if(i.length>0){t.push("By entity type:");for(const[r,s]of i)t.push(` ${r}: ${es(s.bytes)} (${s.bytes} bytes), count=${s.count}`)}return t.join(`
14
- `)}class sa{parse(t){const i=this.normalizeLineEndings(t).split(`
15
- `),r=[],s=[];let a=null;return i.forEach((o,c)=>{const l=c+1,h=this.stripInlineComment(o).trim();if(!h)return;if(h.startsWith("*")){this.flushCurrentPattern(a,r,s);const d=this.parseHeader(h.slice(1));if(!d){s.push({line:l,message:"Invalid pattern header.",source:o}),a=null;return}a={pattern:{name:d.name,description:d.description,lines:[]},headerLine:l};return}if(!a){s.push({line:l,message:"Line descriptor appears before any pattern header.",source:o});return}const u=this.parseLineDescriptor(h,l);if(!u){s.push({line:l,message:"Invalid line descriptor. Expect: angle,x-origin,y-origin,delta-x,delta-y[,dash-1,...].",source:o});return}a.pattern.lines.push(u)}),this.flushCurrentPattern(a,r,s),{patterns:r,issues:s}}static parse(t){return new sa().parse(t)}normalizeLineEndings(t){return t.replace(/\r\n/g,`
5
+ `}toBinary(){if(this.assertWriteMode(),this._outputFormat!=="binary")throw new Error("Filer is not in binary output mode");const t=new Uint8Array(this._binaryLength);let e=0;for(const i of this._binaryChunks)t.set(i,e),e+=i.length;return t}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)}get atEof(){var t;return this._mode!=="read"||this._pushed.length>0?!1:((t=this._reader)==null?void 0:t.peek())===void 0}position(){return this._mode!=="read"||!this._reader?{byteOffset:0}:this._reader.position()}get atEndOfObject(){if(this._mode!=="read")return!0;const t=this.peekPair();return t===void 0||t.code===0}get atExtendedData(){if(this._mode!=="read")return!1;const t=this.peekPair();return t?t.code===1001||t.code===1e3||t.code===1002:!1}atSubclassData(t){if(this._mode!=="read")return!1;const e=this.peekPair();return!e||e.code!==100||typeof e.value!="string"||e.value!==t?!1:(this.readPair(),!0)}peekItem(){const t=this.peekPair();return t?this.pairToTypedValue(t):void 0}readItem(){const t=this.readPair();if(!t){this._status=1;return}return this._status=0,this.pairToTypedValue(t)}pushBackItem(t){if(t&&"type"in t){this._pushed.push(t);return}if(t){this._pushed.push(this.typedValueToPair(t));return}this._lastRead&&this._pushed.push(this._lastRead)}skipToEndOfObject(){for(;!this.atEndOfObject&&!this.atEof;)this.readPair()}readString(t){const e=this.readPair();if(e){if(t!=null&&e.code!==t){this.pushBackPair(e),this.setError(3,`Expected group code ${t}, got ${e.code}`);return}return e.type==="string"||e.type==="handle"?e.value:String(e.value)}}readInt16(t){return this.readNumber(t)}readInt32(t){return this.readNumber(t)}readInt64(t){const e=this.readPair();if(!e)return;if(t!=null&&e.code!==t){this.pushBackPair(e),this.setError(3,`Expected group code ${t}, got ${e.code}`);return}if(e.type==="long"||e.type==="int"||e.type==="double")return e.value;if(e.type==="bool")return e.value?1:0;const i=Number(e.value);return Number.isFinite(i)?i:0}readDouble(t){return this.readNumber(t)}readBoolean(t){const e=this.readPair();if(e){if(t!=null&&e.code!==t){this.pushBackPair(e),this.setError(3,`Expected group code ${t}, got ${e.code}`);return}return e.type==="bool"?e.value:typeof e.value=="number"?e.value!==0:typeof e.value=="string"?e.value!=="0"&&e.value!=="":!!e.value}}readHandle(t){const e=this.readPair();if(e){if(t!=null&&e.code!==t){this.pushBackPair(e),this.setError(3,`Expected group code ${t}, got ${e.code}`);return}return e.type==="handle"||e.type==="string"?e.value:String(e.value)}}readObjectId(t){return this.readHandle(t)}readPoint2d(t){const e=this.readDouble(t);if(e===void 0)return;const i=this.peekPair();let r=0;return i&&i.code===t+10&&(r=this.readNumber()??0),new L(e,r)}readPoint3d(t){const e=this.readDouble(t);if(e===void 0)return;let i=0,r=0;const s=this.peekPair();s&&s.code===t+10&&(i=this.readNumber()??0);const a=this.peekPair();return a&&a.code===t+20&&(r=this.readNumber()??0),new b(e,i,r)}readVector3d(t){const e=this.readPoint3d(t);return e?new w(e.x,e.y,e.z):void 0}readCmColorInto(t,e=62,i=420){const r=this.peekPair();if(!r)return!1;if(r.code===e){const s=this.readNumber();return s!=null&&(t.colorIndex=s),!0}if(r.code===i){const s=this.readNumber();return s!=null&&t.setRGBValue(s),!0}return!1}writeGroup(t,e){if(this.assertWriteMode(),e==null)return this;if(this._outputFormat==="binary")return this.writeBinaryGroup(t,e);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)}get capabilities(){return(this._version??pt.latest).capabilities}writeSubclassMarker(t){return this.capabilities.supportsSubclassMarkers?this.writeString(100,t):this}writeString(t,e){return!e&&e!==""?this:this.writeGroup(t,e)}writeMTextContents(t){for(const e of Qc(t??""))this.writeString(e.code,e.value);return this}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){if(!this.capabilities.supportsHandles)return this;const i=this.resolveHandle(e);return i?this.writeString(t,i):this}writeObjectId(t,e){return this.writeHandle(t,e)}writeLineWeight(t,e){return e==null||!this.capabilities.supportsLineWeight?this:this.writeInt16(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 s=t.RGB;return s!=null&&t.colorIndex==null&&(this.capabilities.supportsTrueColor?this.writeInt32(i,s):this.writeInt16(e,7)),this}writeTransparency(t,e=440){return!t||t.method===exports.AcCmTransparencyMethod.ErrorValue||!this.capabilities.supportsTransparency?this:this.writeInt32(e,t.serialize())}writeResultBuffer(t){if(!t)return this;for(const e of t){const i=Number(e.code);if(i===1e3&&typeof e.value=="string"){for(const r of Jc(e.value,Kc))this.writeGroup(1e3,r);continue}if(i===1004){const r=e.value instanceof Uint8Array?e.value:typeof e.value=="string"?Tg(e.value):void 0;if(r){for(const s of tl(r,Zc))this._outputFormat==="binary"?this.writeGroup(1004,s):this.writeGroup(1004,_o(s));continue}}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}assertWriteMode(){if(this._mode!=="write")throw new Error("AcDbDxfFiler is in read mode")}appendBinary(t){this._binaryChunks.push(t),this._binaryLength+=t.length}writeBinaryCode(t){const e=Math.trunc(t)&65535;if(!this.capabilities.supportsSubclassMarkers){e<=255?this.appendBinary(Uint8Array.of(e)):this.appendBinary(Uint8Array.of(255,e&255,e>>8&255));return}const r=new Uint8Array(2);new DataView(r.buffer).setUint16(0,e,!0),this.appendBinary(r)}writeBinaryGroup(t,e){const i=Qi(Math.trunc(t));switch(this.writeBinaryCode(Math.trunc(t)),i){case"string":case"handle":{const r=typeof e=="string"?this.sanitizeStringForDxfLine(e):this.formatValue(e),s=new TextEncoder().encode(r===""?"0":r),a=new Uint8Array(s.length+1);a.set(s),a[s.length]=0,this.appendBinary(a);break}case"int":{const r=Math.trunc(Number(e))||0;if(jc(Math.trunc(t))){const s=new Uint8Array(4);new DataView(s.buffer).setInt32(0,r,!0),this.appendBinary(s)}else{const s=new Uint8Array(2);new DataView(s.buffer).setInt16(0,r,!0),this.appendBinary(s)}break}case"long":{const r=new Uint8Array(8),s=new DataView(r.buffer);typeof e=="bigint"?s.setBigInt64(0,e,!0):s.setBigInt64(0,BigInt(Math.trunc(Number(e))||0),!0),this.appendBinary(r);break}case"double":{const r=new Uint8Array(8),s=Number(e);new DataView(r.buffer).setFloat64(0,Number.isFinite(s)?s:0,!0),this.appendBinary(r);break}case"bool":{const r=typeof e=="boolean"?e:Number(e)!==0&&e!==""&&e!=null;this.appendBinary(Uint8Array.of(r?1:0));break}case"binary":{const r=e instanceof Uint8Array?e:new Uint8Array(0),s=Math.min(255,r.length),a=new Uint8Array(1+s);a[0]=s,a.set(r.subarray(0,s),1),this.appendBinary(a);break}default:{const r=this.formatValue(e),s=new TextEncoder().encode(r===""?"0":r),a=new Uint8Array(s.length+1);a.set(s),a[s.length]=0,this.appendBinary(a);break}}return this}assertReadMode(){if(this._mode!=="read"||!this._reader)throw new Error("AcDbDxfFiler is not in read mode")}peekPair(){return this.assertReadMode(),this._pushed.length>0?this._pushed[this._pushed.length-1]:this._reader.peek()}readPair(){if(this.assertReadMode(),this._pushed.length>0){const e=this._pushed.pop();return this._lastRead=e,e}const t=this._reader.next();return this._lastRead=t,t}pushBackPair(t){this._pushed.push(t)}readNumber(t){const e=this.readPair();if(!e)return;if(t!=null&&e.code!==t){this.pushBackPair(e),this.setError(3,`Expected group code ${t}, got ${e.code}`);return}if(e.type==="double"||e.type==="int"||e.type==="long"){const r=e.value;return typeof r=="bigint"?Number(r):r}if(e.type==="bool")return e.value?1:0;const i=Number(e.value);return Number.isFinite(i)?i:0}pairToTypedValue(t){return{code:t.code,value:t.value}}typedValueToPair(t){const e=Number(t.code),i=t.value;return typeof i=="boolean"?{code:e,type:"bool",value:i}:typeof i=="number"?Number.isInteger(i)?{code:e,type:"int",value:i}:{code:e,type:"double",value:i}:typeof i=="bigint"?{code:e,type:"long",value:i}:i instanceof Uint8Array?{code:e,type:"binary",value:i}:{code:e,type:"string",value:String(i??"")}}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 t instanceof Uint8Array?_o(t):String(t)}sanitizeStringForDxfLine(t){return t.replace(/\r\n|\r|\n/g," ").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,"")}}function _o(n){let t="";for(let e=0;e<n.length;e++)t+=(n[e]??0).toString(16).padStart(2,"0").toUpperCase();return t}function Tg(n){const t=n.replace(/\s+/g,""),e=t.length>>>1,i=new Uint8Array(e);for(let r=0;r<e;r++)i[r]=Number.parseInt(t.slice(r*2,r*2+2),16)||0;return i}var Me=256,il=[],xo=256,gn;for(;Me--;)il[Me]=(Me+256).toString(16).substring(1);function Cg(n){var t=0,e=11;if(!gn||Me+e>xo*2)for(gn="",Me=0;t<xo;t++)gn+=il[Math.random()*256|0];return gn.substring(Me,Me+++e)}class Re{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 Re(this._values)}[Symbol.iterator](){return this._values[Symbol.iterator]()}}const xe="TEMP_";let Be;function nl(n){Be=n}function rl(n){Be&&(Be().workingDatabase=n)}function sl(){if(Be)return Be().workingDatabase;throw new Error("The current working database must be set before using it!")}const Wt=class Wt{constructor(t,e){t=t||{},this._attrs=new us(t,e),this._xDataMap=new Map,this._attrs.get("objectId")||(this._database?this._attrs.set("objectId",this._database.generateHandle()):this._attrs.set("objectId",this.generateTemporaryHandle()))}generateTemporaryHandle(){return xe+Cg()}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(xe)&&this._database&&this._database.updateMaxHandle(t)}get isTemp(){const t=this.getAttrWithoutException("objectId");return!!t&&t.startsWith(xe)}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(Be)return Be().workingDatabase;throw new Error("The current working database must be set before using it!")}set database(t){this.assignDatabase(t)}assignDatabase(t){this._database=t}getXData(t){return this._xDataMap.get(t)}setXData(t){for(const e of t)e.code===Xs.ExtendedDataRegAppName&&this._xDataMap.set(e.value,t)}removeXData(t){this._xDataMap.delete(t)}createExtensionDictionary(){}close(){}getOwnSnapshotKeys(){return Reflect.ownKeys(this).filter(t=>typeof t=="string"&&!Wt.SNAPSHOT_EXCLUDED_KEYS.has(t))}cloneAttrs(t){const e=this.cloneValue(t.attributes);return new us(e)}restoreAttrsFrom(t){const e=this.cloneValue(t.attributes),i=this._attrs.attributes;for(const r of Object.keys(i))r in e||this._attrs.set(r,void 0,{unset:!0,silent:!0});this._attrs.set(e,{silent:!0})}restoreXDataMapFrom(t){this._xDataMap.clear();for(const[e,i]of t.entries())this._xDataMap.set(e,this.cloneValue(i))}copySnapshotStateTo(t){t._attrs=this.cloneAttrs(this._attrs),t._xDataMap=this.cloneValue(this._xDataMap);const e=this,i=t;for(const r of this.getOwnSnapshotKeys())Wt.SNAPSHOT_INTERNAL_KEYS.has(r)||(i[r]=this.cloneValue(e[r]))}clone(){const t=Object.create(Object.getPrototypeOf(this));return this.copySnapshotStateTo(t),t.objectId=this.generateTemporaryHandle(),t}clonePreservingIdentity(){const t=this.clone(),e=this.getAttrWithoutException("objectId");e&&t._attrs.set("objectId",e);const i=this.getAttrWithoutException("ownerId");return i!==void 0&&t._attrs.set("ownerId",i),this._database&&(t._database=this._database),t}restoreFrom(t){const e=this.objectId,i=this._database;this.restoreAttrsFrom(t._attrs),this.restoreXDataMapFrom(t._xDataMap);const r=t,s=this,a=new Set(t.getOwnSnapshotKeys());for(const o of a)Wt.SNAPSHOT_INTERNAL_KEYS.has(o)||Wt.SNAPSHOT_EXCLUDED_KEYS.has(o)||(s[o]=this.cloneValue(r[o]));for(const o of this.getOwnSnapshotKeys())Wt.SNAPSHOT_INTERNAL_KEYS.has(o)||Wt.SNAPSHOT_EXCLUDED_KEYS.has(o)||a.has(o)||delete s[o];this.objectId=e,i&&(this.database=i)}cloneValue(t){if(t==null||typeof t!="object")return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp)return new RegExp(t.source,t.flags);if(Array.isArray(t))return t.map(r=>this.cloneValue(r));if(t instanceof Map){const r=new Map;for(const[s,a]of t.entries())r.set(this.cloneValue(s),this.cloneValue(a));return r}if(t instanceof Set){const r=new Set;for(const s of t.values())r.add(this.cloneValue(s));return r}if(ArrayBuffer.isView(t)){if(t instanceof DataView)return new DataView(t.buffer.slice(0));const r=t.constructor;return new r(t)}if(t instanceof ArrayBuffer)return t.slice(0);if(t&&typeof t=="object"&&"tables"in t&&"transactionManager"in t)return t;if("clone"in t&&typeof t.clone=="function")return t.clone();const e=Object.create(Object.getPrototypeOf(t)),i=t;for(const r of Object.keys(i))e[r]=this.cloneValue(i[r]);return e}dxfOut(...t){const[e,i=!1]=t;return e.writeHandle(5,this.objectId),e.writeObjectId(330,this.ownerId),e.writeObjectId(360,this.extensionDictionary),this.dxfOutFields(e),i&&this.dxfOutXData(e),this}dxfOutXData(t){for(const e of this._xDataMap.values())t.writeResultBuffer(e)}dxfOutFields(t){return this}dxfIn(t){for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===5||i===105)this.objectId=String(e.value);else if(i===330)this.ownerId=String(e.value);else if(i===360)this.extensionDictionary=String(e.value);else if(i===102)this.dxfInControlString(t,String(e.value));else if(i===100){t.pushBackItem(e);break}else{t.pushBackItem(e);break}}return this.dxfInFields(t),t.atExtendedData&&this.dxfInXData(t),this}dxfInControlString(t,e){const i=e==="{ACAD_XDICTIONARY"||e==="ACAD_XDICTIONARY";for(;!t.atEndOfObject&&!t.atEof;){const r=t.readItem();if(!r)break;const s=Number(r.code);if(s===102){const a=String(r.value);if(a==="}"||a==="")break;this.dxfInControlString(t,a);continue}i&&s===360&&!this.extensionDictionary&&(this.extensionDictionary=String(r.value))}}dxfInFields(t){return this}dxfInXData(t){let e;const i=()=>{e&&e.length>0&&this.setXData(e),e=void 0};for(;!t.atEndOfObject&&!t.atEof;){const r=t.readItem();if(!r)break;const s=Number(r.code);if(s===1001)i(),e=new Re([{code:r.code,value:r.value}]);else if(s>=1e3&&s<=1071)e||(e=new Re),e.add({code:r.code,value:r.value});else{t.pushBackItem(r);break}}i()}};Wt.SNAPSHOT_EXCLUDED_KEYS=new Set(["_database","transactionManager"]),Wt.SNAPSHOT_INTERNAL_KEYS=new Set(["_attrs","_xDataMap"]);let bt=Wt;exports.AcGiArrowType=void 0;(function(n){n.ClosedFilled="",n.Dot="_DOT",n.DotSmall="_DOTSMALL",n.DotBlank="_DOTBLANK",n.Origin="_ORIGIN",n.Origin2="_ORIGIN2",n.Open="_OPEN",n.Open90="_OPEN90",n.Open30="_OPEN30",n.Closed="_CLOSED",n.Small="_SMALL",n.None="_NONE",n.Oblique="_OBLIQUE",n.BoxFilled="_BOXFILLED",n.Box="_BOXBLANK",n.ClosedBlank="_CLOSEDBLANK",n.DatumBlank="_DATUMBLANK",n.DatumFilled="_DATUMFILLED",n.Integral="_INTEGRAL",n.ArchTick="_ARCHTICK"})(exports.AcGiArrowType||(exports.AcGiArrowType={}));exports.AcGiLineWeight=void 0;(function(n){n[n.ByBlock=-2]="ByBlock",n[n.ByDIPs=-4]="ByDIPs",n[n.ByLayer=-1]="ByLayer",n[n.ByLineWeightDefault=-3]="ByLineWeightDefault",n[n.LineWeight000=0]="LineWeight000",n[n.LineWeight005=5]="LineWeight005",n[n.LineWeight009=9]="LineWeight009",n[n.LineWeight013=13]="LineWeight013",n[n.LineWeight015=15]="LineWeight015",n[n.LineWeight018=18]="LineWeight018",n[n.LineWeight020=20]="LineWeight020",n[n.LineWeight025=25]="LineWeight025",n[n.LineWeight030=30]="LineWeight030",n[n.LineWeight035=35]="LineWeight035",n[n.LineWeight040=40]="LineWeight040",n[n.LineWeight050=50]="LineWeight050",n[n.LineWeight053=53]="LineWeight053",n[n.LineWeight060=60]="LineWeight060",n[n.LineWeight070=70]="LineWeight070",n[n.LineWeight080=80]="LineWeight080",n[n.LineWeight090=90]="LineWeight090",n[n.LineWeight100=100]="LineWeight100",n[n.LineWeight106=106]="LineWeight106",n[n.LineWeight120=120]="LineWeight120",n[n.LineWeight140=140]="LineWeight140",n[n.LineWeight158=158]="LineWeight158",n[n.LineWeight200=200]="LineWeight200",n[n.LineWeight211=211]="LineWeight211"})(exports.AcGiLineWeight||(exports.AcGiLineWeight={}));var Ar=(function(){function n(t){t===void 0&&(t={});var e,i,r,s;this.database=t.database,this.foregroundOnDark=(e=t.foregroundOnDark)!==null&&e!==void 0?e:Ci,this.foregroundOnLight=(i=t.foregroundOnLight)!==null&&i!==void 0?i:Mi,this.backgroundIsDark=(r=t.backgroundIsDark)!==null&&r!==void 0?r:!0,this.fallbackRgb=(s=t.fallbackRgb)!==null&&s!==void 0?s:16777215}return n.prototype.resolveSubEntityTraitsRgb=function(t){var e,i,r,s=t.color;return s.isForeground?this.backgroundIsDark?this.foregroundOnDark:this.foregroundOnLight:s.isByLayer||s.isByBlock?(e=this.fallbackRgb)!==null&&e!==void 0?e:16777215:(r=(i=s.RGB)!==null&&i!==void 0?i:this.fallbackRgb)!==null&&r!==void 0?r:16777215},n.fromBackgroundColor=function(t,e){return t===void 0&&(t=al),new n({database:e,foregroundOnDark:Ci,foregroundOnLight:Mi,backgroundIsDark:!ol(t),fallbackRgb:16777215})},n})(),al=0,Ci=16777215,Mi=0,Mg=16777215,Og=128,Ng=new Ar({database:void 0,foregroundOnDark:Ci,foregroundOnLight:Mi,backgroundIsDark:!0,fallbackRgb:16777215});function ol(n){var t=n>>16&255,e=n>>8&255,i=n&255;return .299*t+.587*e+.114*i>Og}function Rg(n){var t=Ar.fromBackgroundColor(n);return t.backgroundIsDark?t.foregroundOnDark:t.foregroundOnLight}function Bg(n){return n?Mi:Ci}function Fg(n,t){return Ar.fromBackgroundColor(t).resolveSubEntityTraitsRgb(n)}exports.AcGiMTextFlowDirection=void 0;(function(n){n[n.LEFT_TO_RIGHT=1]="LEFT_TO_RIGHT",n[n.RIGHT_TO_LEFT=2]="RIGHT_TO_LEFT",n[n.TOP_TO_BOTTOM=3]="TOP_TO_BOTTOM",n[n.BOTTOM_TO_TOP=4]="BOTTOM_TO_TOP",n[n.BY_STYLE=5]="BY_STYLE"})(exports.AcGiMTextFlowDirection||(exports.AcGiMTextFlowDirection={}));exports.AcGiMTextAttachmentPoint=void 0;(function(n){n[n.TopLeft=1]="TopLeft",n[n.TopCenter=2]="TopCenter",n[n.TopRight=3]="TopRight",n[n.MiddleLeft=4]="MiddleLeft",n[n.MiddleCenter=5]="MiddleCenter",n[n.MiddleRight=6]="MiddleRight",n[n.BottomLeft=7]="BottomLeft",n[n.BottomCenter=8]="BottomCenter",n[n.BottomRight=9]="BottomRight",n[n.BaselineLeft=10]="BaselineLeft",n[n.BaselineCenter=11]="BaselineCenter",n[n.BaselineRight=12]="BaselineRight"})(exports.AcGiMTextAttachmentPoint||(exports.AcGiMTextAttachmentPoint={}));exports.AcGiRenderMode=void 0;(function(n){n[n.OPTIMIZED_2D=0]="OPTIMIZED_2D",n[n.WIREFRAME=1]="WIREFRAME",n[n.HIDDEN_LINE=2]="HIDDEN_LINE",n[n.FLAT_SHADED=3]="FLAT_SHADED",n[n.GOURAUD_SHADED=4]="GOURAUD_SHADED",n[n.FLAT_SHADED_WITH_WIREFRAME=5]="FLAT_SHADED_WITH_WIREFRAME",n[n.GOURAUD_SHADED_WITH_WIREFRAME=6]="GOURAUD_SHADED_WITH_WIREFRAME"})(exports.AcGiRenderMode||(exports.AcGiRenderMode={}));exports.AcGiOrthographicType=void 0;(function(n){n[n.NON_ORTHOGRAPHIC=0]="NON_ORTHOGRAPHIC",n[n.TOP=1]="TOP",n[n.BOTTOM=2]="BOTTOM",n[n.FRONT=3]="FRONT",n[n.BACK=4]="BACK",n[n.LEFT=5]="LEFT",n[n.RIGHT=6]="RIGHT"})(exports.AcGiOrthographicType||(exports.AcGiOrthographicType={}));exports.AcGiDefaultLightingType=void 0;(function(n){n[n.ONE_DISTANT_LIGHT=0]="ONE_DISTANT_LIGHT",n[n.TWO_DISTANT_LIGHTS=1]="TWO_DISTANT_LIGHTS"})(exports.AcGiDefaultLightingType||(exports.AcGiDefaultLightingType={}));var cl=(function(){function n(){this._number=-1,this._id="",this._groupId="",this._centerPoint=new b,this._height=0,this._width=0,this._viewCenter=new b,this._viewTarget=new b,this._viewTwistAngle=0,this._viewHeight=0}return Object.defineProperty(n.prototype,"number",{get:function(){return this._number},set:function(t){this._number=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"id",{get:function(){return this._id},set:function(t){this._id=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"groupId",{get:function(){return this._groupId},set:function(t){this._groupId=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"centerPoint",{get:function(){return this._centerPoint},set:function(t){this._centerPoint.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"box",{get:function(){var t=new yt;return t.setFromCenterAndSize(this.centerPoint,{x:this.width,y:this.height}),t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"viewCenter",{get:function(){return this._viewCenter},set:function(t){this._viewCenter.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"viewTarget",{get:function(){return this._viewTarget},set:function(t){this._viewTarget.copy(t)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"viewTwistAngle",{get:function(){return this._viewTwistAngle},set:function(t){this._viewTwistAngle=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"viewHeight",{get:function(){return this._viewHeight},set:function(t){this._viewHeight=t},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"viewWidth",{get:function(){return this.viewHeight*(this.width/this.height)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"viewBox",{get:function(){var t=n.dcsCenterToWcs(this.viewCenter,this.viewTarget,this.viewTwistAngle),e=new yt;return e.setFromCenterAndSize(t,{x:this.viewWidth,y:this.viewHeight}),e},enumerable:!1,configurable:!0}),n.dcsCenterToWcs=function(t,e,i){var r=t.x,s=t.y;if(Number.isFinite(i)&&i!==0){var a=Math.cos(i),o=Math.sin(i);r=t.x*a-t.y*o,s=t.x*o+t.y*a}return e&&Number.isFinite(e.x)&&Number.isFinite(e.y)&&(r+=e.x,s+=e.y),new b(r,s,0)},n.prototype.clone=function(){var t=new n;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.viewTarget.copy(this.viewTarget),t.viewTwistAngle=this.viewTwistAngle,t.viewHeight=this.viewHeight,t},n.prototype.copy=function(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.viewTarget.copy(t.viewTarget),this.viewTwistAngle=t.viewTwistAngle,this.viewHeight=t.viewHeight,this},n})();const ke="Continuous",Z="Standard",le="Standard",he="Standard",Dg="ANSI31",ll="ANGLE",Oe="SOLID",hl="USER",ul="LINEAR",lt="ByLayer",Jt="ByBlock",ii="*Active",bs="mlightcad",_s="ACAD",Yg=Object.freeze({x:0,y:0}),Xg=Object.freeze({x:0,y:0}),zg=Object.freeze({x:1,y:1}),jg=Object.freeze({x:0,y:0,z:1}),Vg=Object.freeze({x:0,y:0,z:0}),dl=150,xs=1,ws=255,gl=12,vs=1,ks=255,Gg=0,Ug=32767,Hg=0,Wg=2,fl=5,As=1,Ss=255,fa=class fa extends bt{constructor(){super(...arguments),this._visibility=!0,this._transparency=new ot,this._transparencySet=!1,this._dxfPaperSpace=!1}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.getEntityColor()}set color(t){this.setEntityColor(t)}get resolvedColor(){return this.resolveStandardColor()}resolveStandardColor(){let t=this.color;if(t.isByLayer){const e=this.getLayerColor();e&&e.RGB!=null&&(t=e)}else t.isByBlock&&(t=new X().setForeground());return t}get lineType(){var t;return this._lineType==null&&(this._lineType=((t=this.database)==null?void 0:t.celtype)??lt),this._lineType}set lineType(t){t?t.toUpperCase()==="BYLAYER"?this._lineType=lt:t.toUpperCase()==="BYBLOCK"?this._lineType=Jt:this._lineType=t:this._lineType=lt}get lineWeight(){return this._lineWeight==null&&(this._lineWeight=this.database.celweight??exports.AcGiLineWeight.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(),this._transparencySet=!0}hasExplicitLayer(){return this._layer!=null}hasExplicitColor(){return this._color!=null}getEntityColor(){return this._color==null&&(this._color=new X,this.database.cecolor&&this._color.copy(this.database.cecolor)),this._color}setEntityColor(t){this._color==null&&(this._color=new X),this._color.copy(t)}shouldResolveColorFromCecolor(){return!0}hasExplicitTransparency(){return this._transparencySet}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.writeLineWeight(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}dxfInFields(t){if(super.dxfInFields(t),!t.atSubclassData("AcDbEntity")){const e=t.peekItem();if(e&&Number(e.code)===100)return this}for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}switch(i){case 8:this.layer=String(e.value);break;case 6:this.lineType=String(e.value);break;case 48:this.linetypeScale=Number(e.value);break;case 60:this.visibility=Number(e.value)===0;break;case 62:this.color.colorIndex=Number(e.value);break;case 420:this.color.setRGBValue(Number(e.value));break;case 370:this.lineWeight=Number(e.value);break;case 440:this.transparency=ot.deserialize(Number(e.value));break;case 67:this._dxfPaperSpace=Number(e.value)!==0;break}}return this}get dxfPaperSpace(){return this._dxfPaperSpace}resolveEffectiveProperties(){this._layer==null&&(this._layer=this.database.clayer??"0"),this._color==null&&this.shouldResolveColorFromCecolor()&&(this._color=new X,this.database.cecolor&&this._color.copy(this.database.cecolor)),this._lineType==null&&(this._lineType=this.database.celtype??lt),this._linetypeScale==null&&(this._linetypeScale=this.database.celtscale??-1),this._lineWeight==null&&(this._lineWeight=this.database.celweight??exports.AcGiLineWeight.ByLayer)}get properties(){return{type:this.type,groups:[this.getGeneralProperties()]}}subGetGripPoints(){return new Array}subMoveGripPointsAt(t,e){return this}subGetOsnapPoints(t,e,i,r,s,a){}transformBy(t){return this}erase(){return this.database.tables.blockTable.removeEntity(this.objectId)}worldDraw(t,e){if(!this.database.isLayerDrawable(this.layer))return;const i=t.subEntityTraits;i.color=this.resolvedColor,i.lineType=this.lineStyle,i.lineTypeScale=this.linetypeScale,i.lineWeight=this.lineWeight,i.transparency=this.transparency,i.layer=this.layer,i.drawOrder=0,"thickness"in this&&(i.thickness=this.thickness),t.context.database=this.database;const r=this.subWorldDraw(t,e);return this.attachEntityInfo(r),r}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=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==lt){const t=this.database.tables.layerTable.getAt(this.layer);if(t&&t.linetype)return{type:"ByLayer",name:t.linetype}}else return this.lineType==Jt?{type:"ByBlock",name:ke}:{type:"UserSpecified",name:this.lineType};return{type:"UserSpecified",name:ke}}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)}};fa.typeName="Entity";let H=fa;class ni{constructor(t){this.i=0,t instanceof Map?(this._records=t,this._array=null,this._keys=Array.from(t.keys())):(this._records=null,this._array=t,this._keys=[])}get count(){var t;return((t=this._records)==null?void 0:t.size)??this._array.length}toArray(){return this._records?Array.from(this._records.values()):[...this._array]}[Symbol.iterator](){return this}next(){if(this._array){if(this.i<this._array.length){const t=this._array[this.i];return this.i+=1,{value:t,done:!1}}return{value:null,done:!0}}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 we extends Error{constructor(t="Unexpected end of buffer."){super(t),this.name="AcDbProxyGraphicEndOfBufferError"}}function pl(n){return n instanceof ArrayBuffer?new Uint8Array(n):n}class Mt{constructor(t,e=4){this._index=0,this._buffer=pl(t),this._align=e}get index(){return this._index}get hasData(){return this._index<this._buffer.length}alignIndex(t){const e=t%this._align;return e?t+this._align-e:t}readStruct(t){if(!this.hasData)throw new we;const e=[];let i=0;for(const r of t){const s=new DataView(this._buffer.buffer,this._buffer.byteOffset+this._index+i,r);if(r===8)e.push(s.getFloat64(0,!0));else if(r===4)e.push(s.getUint32(0,!0));else throw new Error(`Unsupported struct size: ${r}`);i+=r}return this._index=this.alignIndex(this._index+i),e}readFloat(){return this.readStruct([8])[0]}readLong(){return this.readStruct([4])[0]}readSignedLong(){if(!this.hasData)throw new we;const e=new DataView(this._buffer.buffer,this._buffer.byteOffset+this._index,4).getInt32(0,!0);return this._index=this.alignIndex(this._index+4),e}readVertex(){return this.readStruct([8,8,8])}readPaddedString(t="utf-8"){const e=this._buffer;for(let i=this._index;i<e.length;i++)if(e[i]===0){const r=this._index;this._index=this.alignIndex(i+1);const s=e.subarray(r,i);return new TextDecoder(t).decode(s)}throw new we("Did not detect terminating zero byte.")}readPaddedUnicodeString(){const t=this._buffer;for(let e=this._index;e<t.length;e+=2)if(e+1<t.length&&t[e]===0&&t[e+1]===0){const i=this._index;this._index=this.alignIndex(e+2);const r=t.subarray(i,e);return new TextDecoder("utf-16le").decode(r)}throw new we("Did not detect terminating zero bytes.")}}class ml{constructor(t,e="AC1015",i="cp1252"){this._bitIndex=0,this._buffer=pl(t),this.dxfversion=e,this.encoding=i}get hasData(){return this._bitIndex>>3<this._buffer.length}readBit(){const t=this._bitIndex;this._bitIndex+=1;const e=t>>3;if(e>=this._buffer.length)throw new we;return this._buffer[e]&128>>(t&7)?1:0}readBits(t){const e=this._bitIndex,i=e+t;if(i-1>>3>=this._buffer.length)throw new we;this._bitIndex=i;let r=128>>(e&7),s=e>>3,a=0,o=this._buffer[s];for(;t>0;)a<<=1,o&r&&(a|=1),t-=1,r>>=1,!r&&t&&(r=128,s+=1,o=this._buffer[s]);return a}readUnsignedByte(){return this.readBits(8)}readSignedByte(){const t=this.readBits(8);return t&128?-((~t&255)+1):t}readAlignedBytes(t){const e=this._bitIndex>>3,i=e+t;if(i>this._buffer.length)throw new we;return this._bitIndex+=t<<3,this._buffer.subarray(e,i)}readUnsignedShort(){if(this._bitIndex&7){const e=this.readBits(8);return(this.readBits(8)<<8)+e}const t=this.readAlignedBytes(2);return t[1]<<8|t[0]}readSignedShort(){const t=this.readUnsignedShort();return t&32768?-((~t&65535)+1):t}readUnsignedLong(){if(this._bitIndex&7){const e=this.readBits(8),i=this.readBits(8),r=this.readBits(8);return(this.readBits(8)<<24)+(r<<16)+(i<<8)+e}const t=this.readAlignedBytes(4);return(t[3]<<24)+(t[2]<<16)+(t[1]<<8)+t[0]}readSignedLong(){const t=this.readUnsignedLong();return t&2147483648?-((~t&4294967295)+1):t}readFloat(){if(this._bitIndex&7){const i=new Uint8Array(8);for(let r=0;r<8;r++)i[r]=this.readBits(8);return new DataView(i.buffer).getFloat64(0,!0)}const t=this.readAlignedBytes(8),e=new Uint8Array(t);return new DataView(e.buffer).getFloat64(0,!0)}readRawDouble(t=1){return t===1?this.readFloat():Array.from({length:t},()=>this.readFloat())}readBitShort(t=1){const e=()=>{const i=this.readBits(2);return i===0?this.readSignedShort():i===1?this.readUnsignedByte():i===2?0:256};return t===1?e():Array.from({length:t},()=>e())}readBitLong(t=1){const e=()=>{const i=this.readBits(2);return i===0?this.readSignedLong():i===1?this.readUnsignedByte():i===2?0:256};return t===1?e():Array.from({length:t},()=>e())}readBitDouble(t=1){const e=()=>{const i=this.readBits(2);return i===0?this.readFloat():i===1?1:0};return t===1?e():Array.from({length:t},()=>e())}readBitDoubleDefault(t=1,e=0){const i=new Uint8Array(8);new DataView(i.buffer).setFloat64(0,e,!0);const r=()=>{const s=this.readBits(2);if(s===0)return e;if(s===1){const a=new Uint8Array(i);return a[0]=this.readUnsignedByte(),a[1]=this.readUnsignedByte(),a[2]=this.readUnsignedByte(),a[3]=this.readUnsignedByte(),new DataView(a.buffer).getFloat64(0,!0)}if(s===2){const a=new Uint8Array(i);return a[4]=this.readUnsignedByte(),a[5]=this.readUnsignedByte(),a[0]=this.readUnsignedByte(),a[1]=this.readUnsignedByte(),a[2]=this.readUnsignedByte(),a[3]=this.readUnsignedByte(),new DataView(a.buffer).getFloat64(0,!0)}return this.readFloat()};return t===1?r():Array.from({length:t},()=>r())}}function Sr(n){return Array.from(n,t=>t.toString(16).padStart(2,"0")).join("").toUpperCase()}function Js(n){const t=n.reduce((r,s)=>r+Math.floor(s.length/2),0),e=new Uint8Array(t);let i=0;for(const r of n)for(let s=0;s<r.length;s+=2)e[i++]=parseInt(r.slice(s,s+2),16);return e}function Ji(n){if(n.length===0)return new Uint8Array;const t=[];for(const s of n)s instanceof Uint8Array?t.push(s):t.push(Js([String(s)]));const e=t.reduce((s,a)=>s+a.length,0),i=new Uint8Array(e);let r=0;for(const s of t)i.set(s,r),r+=s.length;return i}class pe extends bt{constructor(t,e){t=t||{},Bt(t,{name:""}),super(t,e)}get name(){return this.getAttr("name")}set name(t){this.setAttr("name",t)}setAttr(t,e){this.assertOpenForWrite(),super.setAttr(t,e)}assertOpenForWrite(){if(this.isTemp)return;const t=this.database;if(!t)return;const e=t.transactionManager;if(!e.isApplyingUndoRedo()){if(e.strictMode&&!e.isRecording())throw new Error("Cannot modify symbol table records outside an active transaction.");if(e.isRecording()&&!e.isOpenedForWriteInTransaction(this.objectId))throw new Error(`Symbol table record "${this.name||this.objectId}" is not open for write. Use openObjectForWrite().`)}}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbSymbolTableRecord"),this}}var yl=(n=>(n[n.Any=0]="Any",n[n.Uniform=1]="Uniform",n))(yl||{}),wi=(n=>(n[n.None=0]="None",n[n.Anonymous=1]="Anonymous",n[n.HasNonConstantAttributes=2]="HasNonConstantAttributes",n[n.Xref=4]="Xref",n[n.XrefOverlay=8]="XrefOverlay",n[n.ExternallyDependent=16]="ExternallyDependent",n[n.Resolved=32]="Resolved",n[n.Referenced=64]="Referenced",n))(wi||{});const ye=class ye extends pe{static isModelSapceName(t){return t.toLowerCase()==ye.MODEL_SPACE_NAME.toLowerCase()}static isPaperSapceName(t){return t.toLowerCase().startsWith(ye.PAPER_SPACE_NAME_PREFIX.toLowerCase())}static sanitizeImportedFlags(t){return t&-97}constructor(t,e){t=t||{},Bt(t,{origin:new b,layoutId:"",flags:0,pathName:"",blockInsertUnits:0,explodability:1,blockScaling:1,previewIcon:void 0}),super(t,e),this._entities=[]}get isModelSapce(){return ye.isModelSapceName(this.name)}get isPaperSapce(){return ye.isPaperSapceName(this.name)}get origin(){return this.getAttr("origin")}set origin(t){this.getAttr("origin").copy(t)}get layoutId(){return this.getAttr("layoutId")}set layoutId(t){this.setAttr("layoutId",t)}get flags(){return this.getAttr("flags")}set flags(t){this.setAttr("flags",t)}get pathName(){return this.getAttr("pathName")}set pathName(t){this.setAttr("pathName",t)}get isXref(){return(this.flags&12)!==0}get isOverlayReference(){return(this.flags&8)!==0}get isUnresolvedXref(){return!this.isXref||(this.flags&32)!==0?!1:this._entities.length===0}get blockInsertUnits(){return this.getAttr("blockInsertUnits")}set blockInsertUnits(t){this.setAttr("blockInsertUnits",t)}get explodability(){return this.getAttr("explodability")}set explodability(t){this.setAttr("explodability",t)}get blockScaling(){return this.getAttr("blockScaling")}set blockScaling(t){this.setAttr("blockScaling",t)}get previewIcon(){return this.getAttrWithoutException("previewIcon")}set previewIcon(t){if(!t||t.length===0){this.setAttr("previewIcon",void 0);return}this.setAttr("previewIcon",t)}appendEntity(t){const e=this.database.transactionManager;if(e.strictMode&&!e.isRecording()&&!e.isApplyingUndoRedo())throw new Error("Cannot append entities outside an active transaction.");const i=s=>{s.database=this.database,s.ownerId=this.objectId,this.database.ensureEntityStyleDefaults(s),this.database.commitObjectHandle(s,a=>this.hasEntityId(a)),s.resolveEffectiveProperties(),this._entities.push(s),s.dxfTypeName==="INSERT"&&"syncAttributeDatabases"in s&&typeof s.syncAttributeDatabases=="function"&&s.syncAttributeDatabases()},r=Array.isArray(t)?t:[t];for(const s of r)i(s);if(e.isRecording())for(const s of r)e.recordAppend({type:"blockTableRecord",ownerId:this.objectId},s);(this.isModelSapce||this.isPaperSapce)&&!e.isRecording()&&!e.isApplyingUndoRedo()&&this.database.notifyEntityAppended(t)}removeEntity(t){const e=this.database.transactionManager;if(e.strictMode&&!e.isRecording()&&!e.isApplyingUndoRedo())throw new Error("Cannot remove entities outside an active transaction.");const i=Array.isArray(t)?t:[t];if(i.length===0)return!1;const r=new Set(i),s=[];let a=0;for(const o of this._entities)r.has(o.objectId)?(e.isRecording()&&e.recordRemove({type:"blockTableRecord",ownerId:this.objectId},o),s.push(o),this.database.releaseObjectHandle(o)):this._entities[a++]=o;return this._entities.length=a,s.length>0&&!e.isRecording()&&!e.isApplyingUndoRedo()&&this.database.notifyEntityErased(s),s.length>0}newIterator(){return new ni(this._entities)}getIdAt(t){const e=this.database.getObjectById(t);if(!(!(e instanceof H)||e.getAttrWithoutException("ownerId")!==this.objectId))return e}hasEntityId(t){return this.getIdAt(t)!==void 0}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,this.flags),t.writePoint3d(10,this.origin),t.writeString(3,this.name),this.pathName&&t.writeString(1,this.pathName),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}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbBlockTableRecord");const e=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const i=t.readItem();if(!i)break;const r=Number(i.code);if(r===100){t.pushBackItem(i);break}switch(r){case 2:this.name=String(i.value);break;case 70:this.blockInsertUnits=Number(i.value);break;case 280:this.explodability=Number(i.value);break;case 281:this.blockScaling=Number(i.value);break;case 340:this.layoutId=String(i.value);break;case 310:{const s=String(i.value).replace(/\s+/g,"");s&&e.push(s);break}}}return e.length>0&&(this.previewIcon=Js(e)),this}};ye.MODEL_SPACE_NAME="*Model_Space",ye.PAPER_SPACE_NAME_PREFIX="*Paper_Space";let tt=ye;var bl=(n=>(n[n.kInches=0]="kInches",n[n.kMillimeters=1]="kMillimeters",n[n.kPixels=2]="kPixels",n))(bl||{}),_l=(n=>(n[n.k0degrees=0]="k0degrees",n[n.k90degrees=1]="k90degrees",n[n.k180degrees=2]="k180degrees",n[n.k270degrees=3]="k270degrees",n))(_l||{}),xl=(n=>(n[n.kDisplay=0]="kDisplay",n[n.kExtents=1]="kExtents",n[n.kLimits=2]="kLimits",n[n.kView=3]="kView",n[n.kWindow=4]="kWindow",n[n.kLayout=5]="kLayout",n))(xl||{}),wl=(n=>(n[n.kDraft=0]="kDraft",n[n.kPreview=1]="kPreview",n[n.kNormal=2]="kNormal",n[n.kPresentation=3]="kPresentation",n[n.kMaximum=4]="kMaximum",n[n.kCustom=5]="kCustom",n))(wl||{}),vl=(n=>(n[n.kAsDisplayed=0]="kAsDisplayed",n[n.kWireframe=1]="kWireframe",n[n.kHidden=2]="kHidden",n[n.kRendered=3]="kRendered",n[n.kVisualStyle=4]="kVisualStyle",n[n.kRenderPreset=5]="kRenderPreset",n))(vl||{}),kl=(n=>(n[n.kScaleToFit=0]="kScaleToFit",n[n.k1_128in_1ft=1]="k1_128in_1ft",n[n.k1_64in_1ft=2]="k1_64in_1ft",n[n.k1_32in_1ft=3]="k1_32in_1ft",n[n.k1_16in_1ft=4]="k1_16in_1ft",n[n.k3_32in_1ft=5]="k3_32in_1ft",n[n.k1_8in_1ft=6]="k1_8in_1ft",n[n.k3_16in_1ft=7]="k3_16in_1ft",n[n.k1_4in_1ft=8]="k1_4in_1ft",n[n.k3_8in_1ft=9]="k3_8in_1ft",n[n.k1_2in_1ft=10]="k1_2in_1ft",n[n.k3_4in_1ft=11]="k3_4in_1ft",n[n.k1in_1ft=12]="k1in_1ft",n[n.k3in_1ft=13]="k3in_1ft",n[n.k6in_1ft=14]="k6in_1ft",n[n.k1ft_1ft=15]="k1ft_1ft",n[n.k1_1=16]="k1_1",n[n.k1_2=17]="k1_2",n[n.k1_4=18]="k1_4",n[n.k1_5=19]="k1_5",n[n.k1_8=20]="k1_8",n[n.k1_10=21]="k1_10",n[n.k1_16=22]="k1_16",n[n.k1_20=23]="k1_20",n[n.k1_30=24]="k1_30",n[n.k1_40=25]="k1_40",n[n.k1_50=26]="k1_50",n[n.k1_100=27]="k1_100",n[n.k2_1=28]="k2_1",n[n.k4_1=29]="k4_1",n[n.k8_1=30]="k8_1",n[n.k10_1=31]="k10_1",n[n.k100_1=32]="k100_1",n[n.k1000_1=33]="k1000_1",n[n.k1and1_2in_1ft=34]="k1and1_2in_1ft",n))(kl||{});const $g={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 Al extends bt{constructor(t=!1){super(),this._plotSettingsName="",this._plotCfgName="",this._canonicalMediaName="",this._currentStyleSheet="",this._plotOrigin=new L,this._customPrintScale={numerator:1,denominator:1},this._plotPaperSize=new L,this._plotPaperMargins={left:0,right:0,top:0,bottom:0},this._plotViewName="",this._paperImageOrigin=new L,this._plotWindowArea=new yt,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 paperImageOrigin(){return this._paperImageOrigin}set paperImageOrigin(t){this._paperImageOrigin=t}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 $g[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.writeDouble(148,this.paperImageOrigin.x),t.writeDouble(149,this.paperImageOrigin.y),t.writeObjectId(333,this.shadePlotId),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbPlotSettings");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code),r=Number(e.value);switch(i){case 1:this.plotSettingsName=String(e.value);break;case 2:this.plotCfgName=String(e.value);break;case 4:this.canonicalMediaName=String(e.value);break;case 6:this.plotViewName=String(e.value);break;case 7:this.currentStyleSheet=String(e.value);break;case 40:this.plotPaperMargins.left=r;break;case 41:this.plotPaperMargins.bottom=r;break;case 42:this.plotPaperMargins.right=r;break;case 43:this.plotPaperMargins.top=r;break;case 44:this.plotPaperSize.x=r;break;case 45:this.plotPaperSize.y=r;break;case 46:this.plotOrigin.x=r;break;case 47:this.plotOrigin.y=r;break;case 48:this.plotWindowArea.min.x=r;break;case 49:this.plotWindowArea.min.y=r;break;case 140:this.plotWindowArea.max.x=r;break;case 141:this.plotWindowArea.max.y=r;break;case 142:this.customPrintScale.numerator=r;break;case 143:this.customPrintScale.denominator=r;break;case 70:{const s=r;this.plotViewportBorders=(s&1)!==0,this.showPlotStyles=(s&2)!==0,this.plotCentered=(s&4)!==0,this.plotHidden=(s&8)!==0,this.useStandardScale=(s&16)!==0,this.plotPlotStyles=(s&32)!==0,this.scaleLineweights=(s&64)!==0,this.printLineweights=(s&128)!==0,this.drawViewportsFirst=(s&512)!==0,this.modelType=(s&1024)!==0;break}case 72:this.plotPaperUnits=r;break;case 73:this.plotRotation=r;break;case 74:this.plotType=r;break;case 75:this.stdScaleType=r;break;case 76:this.shadePlot=r;break;case 77:this.shadePlotResLevel=r;break;case 78:this.shadePlotCustomDPI=r;break;case 147:break;case 148:this.paperImageOrigin.x=r;break;case 149:this.paperImageOrigin.y=r;break;case 333:this.shadePlotId=String(e.value);break;case 100:return t.pushBackItem(e),this}}return this}}class tn extends Al{constructor(){super(),this._insertionPoint=new b,this._ucsOrigin=new b,this._ucsXAxis=new w(1,0,0),this._ucsYAxis=new w(0,1,0),this._elevation=0,this._orthographicType=0,this._tabOrder=-1,this._tabSelected=!1,this._blockTableRecordId="",this._layoutName="",this._limits=new yt,this._extents=new Y,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()}get namedUcsId(){return this._namedUcsId}set namedUcsId(t){this._namedUcsId=t}get orthographicUcsId(){return this._orthographicUcsId}set orthographicUcsId(t){this._orthographicUcsId=t}get insertionPoint(){return this._insertionPoint}set insertionPoint(t){this._insertionPoint.copy(t)}get ucsOrigin(){return this._ucsOrigin}set ucsOrigin(t){this._ucsOrigin.copy(t)}get ucsXAxis(){return this._ucsXAxis}set ucsXAxis(t){this._ucsXAxis.copy(t)}get ucsYAxis(){return this._ucsYAxis}set ucsYAxis(t){this._ucsYAxis.copy(t)}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get orthographicType(){return this._orthographicType}set orthographicType(t){this._orthographicType=t}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),t.writePoint3d(12,this.insertionPoint),t.writePoint3d(13,this.ucsOrigin),t.writeVector3d(16,this.ucsXAxis),t.writeVector3d(17,this.ucsYAxis),t.writeDouble(146,this.elevation),t.writeInt16(76,this.orthographicType),t.writeObjectId(345,this._namedUcsId),t.writeObjectId(346,this._orthographicUcsId),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbLayout");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code),r=Number(e.value);switch(i){case 1:this.layoutName=String(e.value);break;case 70:this.tabSelected=r!==0;break;case 71:this.tabOrder=r;break;case 330:this.blockTableRecordId=String(e.value);break;case 331:{const s=String(e.value);s&&s!=="0"&&(this.viewportArray=[s]);break}case 10:this.limits.min.x=r;break;case 20:this.limits.min.y=r;break;case 11:this.limits.max.x=r;break;case 21:this.limits.max.y=r;break;case 14:this.extents.min.x=r;break;case 24:this.extents.min.y=r;break;case 34:this.extents.min.z=r;break;case 15:this.extents.max.x=r;break;case 25:this.extents.max.y=r;break;case 35:this.extents.max.z=r;break;case 345:this.namedUcsId=String(e.value);break;case 346:this.orthographicUcsId=String(e.value);break;case 12:this.insertionPoint.x=r;break;case 22:this.insertionPoint.y=r;break;case 32:this.insertionPoint.z=r;break;case 13:this.ucsOrigin.x=r;break;case 23:this.ucsOrigin.y=r;break;case 33:this.ucsOrigin.z=r;break;case 16:this.ucsXAxis.x=r;break;case 26:this.ucsXAxis.y=r;break;case 36:this.ucsXAxis.z=r;break;case 17:this.ucsYAxis.x=r;break;case 27:this.ucsYAxis.y=r;break;case 37:this.ucsYAxis.z=r;break;case 76:this.orthographicType=r;break;case 146:this.elevation=r;break;case 100:return t.pushBackItem(e),this}}return this}}class Sl{constructor(){this.events={layoutCreated:new at,layoutRemoved:new at,layoutRenamed:new at,layoutSwitched:new at}}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 s=this.getWorkingDatabase(i).objects.layout.getAt(t);return s?(s.layoutName=e,this.events.layoutRenamed.dispatch({layout:s,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 s=!1;return r&&(s=i.remove(t),s&&this.events.layoutRemoved.dispatch({layout:r})),s}createLayout(t,e){const i=this.getWorkingDatabase(e),r=new tn;r.layoutName=t,r.tabOrder=i.objects.layout.maxTabOrder;const s=new tt;return s.name=`*Paper_Space${r.tabOrder}`,i.tables.blockTable.add(s),i.objects.layout.setAt(t,r),this.events.layoutCreated.dispatch({layout:r}),{layout:r,btr:s}}getActiveLayout(t){const e=this.getWorkingDatabase(t);return e.objects.layout.getBtrIdAt(e.currentSpaceId)}getWorkingDatabase(t){return t||sl()}setCurrentLayoutInternal(t,e){return t?(this.events.layoutSwitched.dispatch({layout:t}),e.currentSpaceId=t.blockTableRecordId,!0):!1}}let Sn;function qg(n){Sn=n}function Pl(){return Mn.instance}const dr=class dr{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(){return this._layoutManager||(Sn||(Sn=()=>new Sl),this._layoutManager=Sn()),this._layoutManager}};dr.instance=new dr;let Mn=dr;nl(Pl);var ri=(n=>(n.kForRead="kForRead",n.kForWrite="kForWrite",n))(ri||{});function Kg(n){let t="";for(let e=0;e<n.length;e++){const i=n.charCodeAt(e);t+=i<=32?n[e]:String.fromCharCode(159-i)}return t}function Zg(n){const t=n.trimStart();return!(!t||/^\d/.test(t)||/^ACIS/i.test(t)||/^ASM/i.test(t)||/^(body|point|plane|cone|cylinder|sphere|torus|lump|shell|face|edge|wire|transform)\b/i.test(t)||/\b(body|point|straight-curve|ellipse-curve)\s+\$/.test(t))}function Qg(n){return!n||!Zg(n)?n:Kg(n)}function Jg(n){return n.length===0?"":n.map(t=>Qg(t)).join(`
6
+ `)}function wo(n,t,e){if(t===1){n.push(e);return}if(n.length===0){n.push(e);return}n[n.length-1]+=e}const tf=["ACIS BinaryFile","ASM BinaryFile4"],Il=new Set(["End-of-ACIS-data","End-of-ASM-data","End-of-ACIS-History-data"]),z={Int:4,Double:6,Str:7,BoolTrue:10,BoolFalse:11,Pointer:12,EntityType:13,EntityTypeEx:14,SubtypeStart:15,SubtypeEnd:16,RecordEnd:17,LiteralStr:18,LocationVec:19,DirectionVec:20,Enum:21,Unknown0x17:23};class ef{constructor(t){this.data=t,this.index=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}get hasData(){return this.index<this.data.length}require(t){if(this.index+t>this.data.length)throw new RangeError(`SAB: read past end of data (need ${String(t)} at ${String(this.index)})`)}readByte(){return this.require(1),this.data[this.index++]??0}readInt(){this.require(4);const t=this.view.getInt32(this.index,!0);return this.index+=4,t}readFloat(){this.require(8);const t=this.view.getFloat64(this.index,!0);return this.index+=8,t}readStr(t){this.require(t);const e=nf.decode(this.data.subarray(this.index,this.index+t));return this.index+=t,e}}const nf=new TextDecoder("latin1");function rf(n,t){let e="";for(const g of tf)if(of(t,g)){e=g,n.index=g.length;break}if(e==="")throw new RangeError("SAB: not a SAB stream (missing signature)");const i=n.readInt(),r=n.readInt(),s=n.readInt(),a=n.readInt(),o=Wr(n),c=Wr(n),l=Wr(n),h=$r(n),u=$r(n),d=$r(n);return{signature:e,version:i,numRecords:r,numEntities:s,flags:a,productId:o,acisVersion:c,creationDate:l,unitsInMm:h,resTol:u,norTol:d}}function Wr(n){if(n.readByte()!==z.Str)throw new RangeError("SAB: expected string tag (0x07)");return n.readStr(n.readByte())}function $r(n){if(n.readByte()!==z.Double)throw new RangeError("SAB: expected double tag (0x06)");return n.readFloat()}function sf(n){const t=[],e=[];let i="",r=0;for(;;){if(!n.hasData){if(Il.has(i))return{type:i,tokens:t};throw new RangeError("SAB: premature end of data")}const s=n.readByte();switch(s){case z.Int:t.push({tag:s,value:n.readInt()});break;case z.Double:t.push({tag:s,value:n.readFloat()});break;case z.Str:t.push({tag:s,value:n.readStr(n.readByte())});break;case z.Pointer:t.push({tag:s,value:n.readInt()});break;case z.BoolTrue:t.push({tag:s,value:!0});break;case z.BoolFalse:t.push({tag:s,value:!1});break;case z.LiteralStr:t.push({tag:s,value:n.readStr(n.readInt())});break;case z.EntityTypeEx:e.push(n.readStr(n.readByte()));break;case z.EntityType:{e.push(n.readStr(n.readByte()));const a=e.join("-");e.length=0,i===""&&(i=a),t.push({tag:s,value:a});break}case z.LocationVec:t.push({tag:s,value:vo(n)});break;case z.DirectionVec:t.push({tag:s,value:vo(n)});break;case z.Enum:t.push({tag:s,value:n.readInt()});break;case z.Unknown0x17:t.push({tag:s,value:n.readFloat()});break;case z.SubtypeStart:r++,t.push({tag:s,value:r});break;case z.SubtypeEnd:t.push({tag:s,value:r}),r--;break;case z.RecordEnd:return{type:i,tokens:t};default:throw new RangeError(`SAB: unknown tag 0x${s.toString(16)} (${String(s)}) in record '${i}'`)}}}function vo(n){return[n.readFloat(),n.readFloat(),n.readFloat()]}function af(n){const t=new ef(n),e=rf(t,n),i=[];for(;t.hasData;){const r=sf(t);if(i.push(r),Il.has(r.type))break}return{header:e,records:i}}function of(n,t){if(n.length<t.length)return!1;for(let e=0;e<t.length;e++)if(n[e]!==t.charCodeAt(e))return!1;return!0}const cf=new Set(["End-of-ACIS-data","End-of-ASM-data","End-of-ACIS-History-data"]);function lf(n){const e=n.records.map((a,o)=>({index:o,type:a.type,record:a,refs:[]}));for(const a of e)for(const o of a.record.tokens){if(o.tag!==z.Pointer)continue;const c=o.value;a.refs.push(c>=0&&c<e.length?e[c]:null)}const i=e,r=new Map,s=new Map;for(const a of i){if(cf.has(a.type))continue;let o=r.get(a.type);o===void 0&&(o=[],r.set(a.type,o)),o.push(a),s.set(a.type,(s.get(a.type)??0)+1)}return{header:n.header,nodes:i,bodies:r.get("body")??[],typeCounts:s,nodesOfType:a=>r.get(a)??[],pointLocations(){const a=[];for(const o of r.get("point")??[]){const c=o.record.tokens.find(l=>l.tag===z.LocationVec);c!==void 0&&a.push(c.value)}return a}}}const hf=["ACIS BinaryFile","ASM BinaryFile","ASM BinaryFile4"];function uf(n,t){if(t.length===0||n.length<t.length)return-1;const e=t.charCodeAt(0);for(let i=0;i<=n.length-t.length;i++){if(n[i]!==e)continue;let r=!0;for(let s=1;s<t.length;s++)if(n[i+s]!==t.charCodeAt(s)){r=!1;break}if(r)return i}return-1}function df(n){for(const t of hf){const e=uf(n,t);if(e>=0)return e}return-1}function gf(n){if(n.length===0)return null;const t=df(n);if(t<0)return null;try{return lf(af(n.subarray(t)))}catch{return null}}const On={xAxis:[1,0,0],yAxis:[0,1,0],zAxis:[0,0,1],translation:[0,0,0],scale:1},ff=1e-12,pf=new Set([z.LocationVec,z.DirectionVec]),Pn=(n,t)=>Math.abs(n-t)<=ff,fn=(n,t)=>Pn(n[0],t[0])&&Pn(n[1],t[1])&&Pn(n[2],t[2]);function ta(){return On}function El(n,t){return Pn(n.scale,t.scale)&&fn(n.xAxis,t.xAxis)&&fn(n.yAxis,t.yAxis)&&fn(n.zAxis,t.zAxis)&&fn(n.translation,t.translation)}function mf(n){const t=[];let e;for(const i of n.record.tokens){if(pf.has(i.tag)){t.push(i.value);continue}i.tag===z.Double&&t.length>=4&&e===void 0&&(e=i.value)}return t.length<4?null:{xAxis:t[0],yAxis:t[1],zAxis:t[2],translation:t[3],scale:e??1}}function yf(n){const t=n.refs.find(e=>(e==null?void 0:e.type)==="transform");return t==null?On:mf(t)??On}function vi(n){return El(n,On)}function te(n,t){const e=t.scale,[i,r,s]=n,{xAxis:a,yAxis:o,zAxis:c,translation:l}=t;return[e*(a[0]*i+o[0]*r+c[0]*s)+l[0],e*(a[1]*i+o[1]*r+c[1]*s)+l[1],e*(a[2]*i+o[2]*r+c[2]*s)+l[2]]}function qt(n,t){const e=t.scale,[i,r,s]=n,{xAxis:a,yAxis:o,zAxis:c}=t;return[e*(a[0]*i+o[0]*r+c[0]*s),e*(a[1]*i+o[1]*r+c[1]*s),e*(a[2]*i+o[2]*r+c[2]*s)]}function Ll(n){const t=new Map,e=(i,r,s)=>{if(!(i==null||s.has(i.index))&&!i.type.includes("attrib")){s.add(i.index),t.has(i.index)||t.set(i.index,r);for(const a of i.refs)e(a,r,s)}};for(const i of n.bodies)e(i,yf(i),new Set);return t}function bf(n,t){if(vi(t)||n.length<3)return n;const e=new Float32Array(n.length);for(let i=0;i+2<n.length;i+=3){const[r,s,a]=te([n[i],n[i+1],n[i+2]],t);e[i]=r,e[i+1]=s,e[i+2]=a}return e}class Tl{constructor(t){this.tokens=t,this.i=0}next(...t){for(;this.i<this.tokens.length;){const e=this.tokens[this.i++];if(e!==void 0&&t.includes(e.tag))return e}}nextVec(){var t;return(t=this.next(z.LocationVec,z.DirectionVec))==null?void 0:t.value}nextDouble(){var t;return(t=this.next(z.Double))==null?void 0:t.value}}const Ue=(n,t)=>n.refs.find(e=>e!==null&&(e.type===t||e.type.endsWith(t)))??null,Cl=(n,t)=>n.refs.filter(e=>e!==null&&e.type===t);function qr(n){if(n===null)return null;const t=Ue(n,"point");if(t===null)return null;const e=t.record.tokens.find(i=>i.tag===z.LocationVec);return e?e.value:null}function _f(n){const t=new Tl(n.record.tokens);if(n.type==="straight-curve"){const e=t.nextVec(),i=t.nextVec();if(e&&i)return{kind:"straight",origin:e,direction:i}}else if(n.type==="ellipse-curve"){const e=t.nextVec(),i=t.nextVec(),r=t.nextVec(),s=t.nextDouble();if(e&&i&&r&&s!==void 0)return{kind:"ellipse",center:e,normal:i,majorAxis:r,ratio:s}}else if(n.type==="intcurve-curve")return{kind:"intcurve",controlPoints:xf(n.record.tokens)};return{kind:"unknown"}}function xf(n){var a,o,c;const t=n.findIndex(l=>l.tag===z.EntityType&&(l.value==="nubs"||l.value==="nurbs"));if(t<0)return[];let e=t+1,i=-1;for(;e<n.length;e++){const l=n[e];if(l===void 0||l.tag===z.Double)break;if(l.tag===z.Int&&(i=l.value),l.tag===z.EntityType||l.tag===z.SubtypeEnd)return[]}if(i<0)return[];for(let l=0;l<i;l++){if(((a=n[e])==null?void 0:a.tag)!==z.Double)return[];e+=1,((o=n[e])==null?void 0:o.tag)===z.Int&&(e+=1)}const r=[];for(;((c=n[e])==null?void 0:c.tag)===z.Double;){const l=n[e];if(l===void 0)break;r.push(l.value),e+=1}const s=[];for(let l=0;l+3<=r.length;l+=3){const h=r[l],u=r[l+1],d=r[l+2];if(h===void 0||u===void 0||d===void 0)break;s.push([h,u,d])}return s}function Ml(n){const t=new Tl(n.record.tokens);if(n.type==="plane-surface"){const e=t.nextVec(),i=t.nextVec(),r=t.nextVec();if(e&&i)return r?{kind:"plane",origin:e,normal:i,uDir:r}:{kind:"plane",origin:e,normal:i}}else if(n.type==="cone-surface"){const e=t.nextVec(),i=t.nextVec(),r=t.nextVec(),s=t.nextDouble(),a=t.nextDouble(),o=t.nextDouble();if(e&&i&&r&&s!==void 0&&a!==void 0&&o!==void 0)return{kind:"cone",origin:e,axis:i,majorAxis:r,ratio:s,sineAngle:a,cosineAngle:o}}else if(n.type==="torus-surface"){const e=t.nextVec(),i=t.nextVec(),r=t.nextDouble(),s=t.nextDouble();if(e&&i&&r!==void 0&&s!==void 0)return{kind:"torus",center:e,axis:i,majorRadius:r,minorRadius:s}}else if(n.type==="sphere-surface"){const e=t.nextVec(),i=t.nextDouble(),r=t.nextVec(),s=t.nextVec();if(e&&i!==void 0&&r&&s)return{kind:"sphere",center:e,radius:i,uDir:r,poleAxis:s}}return{kind:"unknown"}}function wf(n){return Ml(n)}const vf={"plane-surface":"plane","cone-surface":"cone","torus-surface":"torus","sphere-surface":"sphere","spline-surface":"spline"},kf={"straight-curve":"straight","ellipse-curve":"ellipse","intcurve-curve":"intcurve"};function Af(n){const t=Ue(n,"coedge");if(t===null)return 0;const e=new Set;let i=t;for(;i!==null&&!e.has(i.index);)e.add(i.index),i=Cl(i,"coedge")[0]??null;return e.size}function Sf(n,t){return n.kind==="straight"?{kind:"straight",origin:te(n.origin,t),direction:qt(n.direction,t)}:n.kind==="ellipse"?{kind:"ellipse",center:te(n.center,t),normal:qt(n.normal,t),majorAxis:qt(n.majorAxis,t),ratio:n.ratio}:n.kind==="intcurve"?{kind:"intcurve",controlPoints:n.controlPoints.map(e=>te(e,t))}:n}function Pf(n,t){return n.kind==="plane"?{kind:"plane",origin:te(n.origin,t),normal:qt(n.normal,t),...n.uDir?{uDir:qt(n.uDir,t)}:{}}:n.kind==="cone"?{kind:"cone",origin:te(n.origin,t),axis:qt(n.axis,t),majorAxis:qt(n.majorAxis,t),ratio:n.ratio,sineAngle:n.sineAngle,cosineAngle:n.cosineAngle}:n.kind==="torus"?{kind:"torus",center:te(n.center,t),axis:qt(n.axis,t),majorRadius:n.majorRadius*t.scale,minorRadius:n.minorRadius*t.scale}:n.kind==="sphere"?{kind:"sphere",center:te(n.center,t),radius:n.radius*t.scale,uDir:qt(n.uDir,t),poleAxis:qt(n.poleAxis,t)}:n}function If(n){const t=[],e=Ll(n),i=ta(),r=y=>e.get(y)??i,s=(y,_)=>{if(y===null)return null;const v=r(_);return vi(v)?y:te(y,v)};let a=1/0,o=1/0,c=1/0,l=-1/0,h=-1/0,u=-1/0;const d=y=>{y[0]<a&&(a=y[0]),y[0]>l&&(l=y[0]),y[1]<o&&(o=y[1]),y[1]>h&&(h=y[1]),y[2]<c&&(c=y[2]),y[2]>u&&(u=y[2])},g=n.nodesOfType("vertex").map(y=>{const _=s(qr(y),y.index);return _===null?t.push(`vertex#${String(y.index)}: no resolvable point`):d(_),{nodeIndex:y.index,point:_}}),p=n.nodesOfType("edge").map(y=>{const _=Cl(y,"vertex"),v=s(qr(_[0]??null),y.index),x=s(qr(_[1]??null),y.index),k=Ue(y,"-curve"),I=k?kf[k.type]??"unknown":"unknown";let P=k?_f(k):void 0;const C=r(y.index);return P!==void 0&&P.kind!=="unknown"&&!vi(C)&&(P=Sf(P,C)),v!==null&&x!==null&&v[0]===x[0]&&v[1]===x[1]&&v[2]===x[2]&&t.push(`edge#${String(y.index)}: degenerate (coincident endpoints)`),P===void 0||P.kind==="unknown"?{nodeIndex:y.index,start:v,end:x,curveType:I}:{nodeIndex:y.index,start:v,end:x,curveType:I,curve:P}}),f=n.nodesOfType("face").map(y=>{const _=Ue(y,"-surface"),v=_?vf[_.type]??"unknown":"unknown";let x=_?Ml(_):void 0;const k=r(y.index);x!==void 0&&x.kind!=="unknown"&&!vi(k)&&(x=Pf(x,k));const I=[],P=new Set;let C=Ue(y,"loop");for(;C!==null&&!P.has(C.index);)P.add(C.index),I.push({nodeIndex:C.index,coedgeCount:Af(C)}),C=Ue(C,"loop");return _===null&&t.push(`face#${String(y.index)}: no surface`),x===void 0||x.kind==="unknown"?{nodeIndex:y.index,surfaceType:v,loops:I}:{nodeIndex:y.index,surfaceType:v,surface:x,loops:I}});return{vertices:g,edges:p,faces:f,bbox:a===1/0?null:{min:[a,o,c],max:[l,h,u]},diagnostics:t}}const Ce=(n,t)=>[n[0]+t[0],n[1]+t[1],n[2]+t[2]],_e=(n,t)=>[n[0]*t,n[1]*t,n[2]*t],Ef=n=>Math.hypot(n[0],n[1],n[2]),In=(n,t)=>[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]],ze=n=>{const t=Math.hypot(n[0],n[1],n[2]);return t>0?[n[0]/t,n[1]/t,n[2]/t]:[0,0,0]};function Lf(n){const t=[];for(const r of n.record.tokens)if(r.tag===z.Double&&(t.push(r.value),t.length===2))break;const e=t[0],i=t[1];return e===void 0||i===void 0?null:[e,i]}function Ol(n,t,e,i){const r=_e(In(ze(n.normal),n.majorAxis),n.ratio),s=Math.max(1,i),a=[];for(let o=0;o<=s;o++){const c=t+(e-t)*o/s;a.push(Ce(n.center,Ce(_e(n.majorAxis,Math.cos(c)),_e(r,Math.sin(c)))))}return a}function Tf(n,t=16){const e=ze(n.poleAxis);let i=ze(n.uDir),r=In(e,i);Ef(r)<1e-9?(i=Math.abs(e[0])<.9?[1,0,0]:[0,1,0],r=ze(In(e,i))):r=ze(r),i=ze(In(r,e));const s=[],a=(o,c)=>{const l=[],h=Math.max(8,t);for(let u=0;u<=h;u++){const d=Math.PI*2*u/h;l.push(Ce(n.center,Ce(_e(o,n.radius*Math.cos(d)),_e(c,n.radius*Math.sin(d)))))}s.push(l)};a(i,r),a(i,e),a(r,e);for(const o of[-.5,.5]){const c=_e(e,n.radius*o),l=Ce(n.center,c),h=n.radius*Math.sqrt(Math.max(0,1-o*o));if(h>1e-6){const u=[],d=Math.max(8,t);for(let g=0;g<=d;g++){const p=Math.PI*2*g/d;u.push(Ce(l,Ce(_e(i,h*Math.cos(p)),_e(r,h*Math.sin(p)))))}s.push(u)}}return s}const Cf=16,Mf=(n,t)=>n.refs.find(e=>e!==null&&(e.type===t||e.type.endsWith(t)))??null;function Nl(n,t,e){n.push(t[0],t[1],t[2],e[0],e[1],e[2])}function Nn(n,t){for(let e=0;e+1<t.length;e++){const i=t[e],r=t[e+1];i&&r&&Nl(n,i,r)}}function Of(n){const t=[],e=Ll(n),i=ta();for(const r of n.nodesOfType("face")){const s=Mf(r,"-surface");if((s==null?void 0:s.type)!=="sphere-surface")continue;const a=wf(s);if(a.kind!=="sphere")continue;const o=e.get(r.index)??i;for(const c of Tf(a)){if(vi(o)){Nn(t,c);continue}Nn(t,c.map(l=>te(l,o)))}}return new Float32Array(t)}function Nf(n,t){var i,r;const e=[];for(const s of n.edges){const a=t==null?void 0:t.nodes[s.nodeIndex];if(((i=s.curve)==null?void 0:i.kind)==="ellipse"){const o=a!==void 0?Lf(a):null,c=(o==null?void 0:o[0])??0,l=(o==null?void 0:o[1])??Math.PI*2;Nn(e,Ol(s.curve,c,l,Cf));continue}if(((r=s.curve)==null?void 0:r.kind)==="intcurve"&&s.curve.controlPoints.length>0){Nn(e,s.curve.controlPoints);continue}s.start&&s.end&&Nl(e,s.start,s.end)}return new Float32Array(e)}function Rf(n){const t=gf(n);if(t===null)return null;const e=If(t),i=Nf(e,t);if(i.length>0)return i;const r=Of(t);return r.length>0?r:null}const Bf=16;function ea(n,t=!0){const e=n.split(/\s+/),i=[];let r=!t;for(const s of e){if(!r&&/^-?\d+$/.test(s)){r=!0;continue}if(s.startsWith("$")||s==="I"||s==="F"||s==="#")continue;const a=Number.parseFloat(s);Number.isFinite(a)&&i.push(a)}return i}function ko(n,t,e){n.push(t[0],t[1],t[2],e[0],e[1],e[2])}function Rl(n){return n.split("#").map(t=>t.trim()).filter(t=>t.length>0)}function Ff(n){const t=[];return n.forEach((e,i)=>{const r=/^-(\d+)\b/.exec(e),s=r?Number(r[1]):i;t[s]=e}),t}function Ao(n){if(!/(?:^|\s)transform\b/.test(n))return null;const t=ea(n);return t.length<13?null:{xAxis:[t[0],t[1],t[2]],yAxis:[t[3],t[4],t[5]],zAxis:[t[6],t[7],t[8]],translation:[t[9],t[10],t[11]],scale:t[12]}}function Df(n){const t=ta(),e=Ff(Rl(n)),i=[];for(const s of e){if(s==null||!/(?:^|\s)body\b/.test(s))continue;const a=[...s.matchAll(/\$(-?\d+)/g)].map(o=>Number(o[1]));for(const o of a){if(o<0)continue;const c=e[o];if(c==null)continue;const l=Ao(c);if(l!=null){i.push(l);break}}}if(i.length===0){const s=[];for(const a of e){if(a==null)continue;const o=Ao(a);o!=null&&s.push(o)}return s.length===1?s[0]:t}const r=i[0];for(let s=1;s<i.length;s++)if(!El(i[s],r))return t;return r}function Yf(n){if(!n.includes("straight-curve"))return null;const t=ea(n);if(t.length<6)return null;const e=t[0],i=t[1],r=t[2],s=t[3],a=t[4],o=t[5];return[[e,i,r],[e+s,i+a,r+o]]}function Xf(n){if(!n.includes("ellipse-curve"))return null;const t=ea(n);return t.length<10?null:{kind:"ellipse",center:[t[0],t[1],t[2]],normal:[t[3],t[4],t[5]],majorAxis:[t[6],t[7],t[8]],ratio:t[9]}}function zf(n){const t=[];if(!n||n.trim().length===0)return new Float32Array(0);for(const e of Rl(n)){const i=Yf(e);if(i!==null){ko(t,i[0],i[1]);continue}const r=Xf(e);if(r!==null){const s=Ol(r,0,Math.PI*2,Bf);for(let a=1;a<s.length;a++)ko(t,s[a-1],s[a])}}return t.length===0?new Float32Array(0):bf(new Float32Array(t),Df(n))}const jf=/\bpoint\s+(?:\$-?\d+\s+){1,4}([-\d.eE+]+)\s+([-\d.eE+]+)\s+([-\d.eE+]+)/g;function Vf(n){return n.split("#").map(t=>t.trim()).filter(t=>t.length>0)}function Gf(n,t=1){const e=n.split(/\s+/),i=[];for(let r=t;r<e.length;r++){const s=e[r];if(s.startsWith("$")||s==="I"||s==="F")continue;const a=Number.parseFloat(s);Number.isFinite(a)&&i.push(a)}return i}function Uf(n){const t=[];for(const e of n.matchAll(jf)){const i=Number.parseFloat(e[1]),r=Number.parseFloat(e[2]),s=Number.parseFloat(e[3]);Number.isFinite(i)&&Number.isFinite(r)&&Number.isFinite(s)&&t.push(new b(i,r,s))}if(t.length>0)return t;for(const e of Vf(n)){if(!e.startsWith("point "))continue;const i=Gf(e);if(i.length>=3){const r=i[i.length-3],s=i[i.length-2],a=i[i.length-1];t.push(new b(r,s,a))}}return t}function Hf(n){const t=[];for(let e=0;e<n.length;e+=3){const i=n[e],r=n[e+1],s=n[e+2];t.push(new b(i,r,s))}return t}function Wf(n,t){return typeof n=="string"?{satText:n,version:t}:{sabBytes:n.sabBytes,satText:n.satText??n.acisData??"",version:n.version??t}}const pa=class pa extends H{constructor(t,e){super(),this._points=[],this._wireframe=new Float32Array(0);const i=Wf(t,e);this._acisData=i.satText,this._sabBytes=i.sabBytes,this._version=i.version,this.rebuildGeometryCaches()}get dxfTypeName(){return"3DSOLID"}get acisData(){return this._acisData}get version(){return this._version}get historyObjectSoftId(){return this._historyObjectSoftId}set historyObjectSoftId(t){this._historyObjectSoftId=t}get guid(){return this._guid}set guid(t){this._guid=t}get satCache(){return this._satCache}set satCache(t){this._satCache=t}setAcisData(t,e){this._acisData=t??"",e!=null&&(this._version=e),this.rebuildGeometryCaches()}setSabBytes(t){this._sabBytes=t&&t.length>0?t:void 0,this.rebuildGeometryCaches()}get sabBytes(){return this._sabBytes}rebuildGeometryCaches(){let t=new Float32Array(0);this._sabBytes&&this._sabBytes.length>0&&(t=Rf(this._sabBytes)??new Float32Array(0)),t.length===0&&this._acisData&&(t=zf(this._acisData)),this._wireframe=t,this._points=t.length>0?Hf(t):Uf(this._acisData)}get hasRenderableGeometry(){return this._wireframe.length>0||this._points.length>0}get geometricExtents(){return this._points.length===0?new Y(new b(0,0,0),new b(0,0,0)):new Y().setFromPoints(this._points)}transformBy(t){if(this._points.forEach(e=>e.applyMatrix4(t)),this._wireframe.length>0){const e=new Float32Array(this._wireframe.length);for(let i=0;i<this._wireframe.length;i+=3){const r=new b(this._wireframe[i],this._wireframe[i+1],this._wireframe[i+2]);r.applyMatrix4(t),e[i]=r.x,e[i+1]=r.y,e[i+2]=r.z}this._wireframe=e}return this}subWorldDraw(t){if(this._wireframe.length>=6){const c=this._wireframe.length/3,l=new Uint16Array(c);for(let h=0;h<c;h++)l[h]=h;return t.lineSegments(this._wireframe,3,l)}if(this._points.length===0)return;const e=this.geometricExtents,i=e.min,r=e.max,s=[new b(i.x,i.y,i.z),new b(r.x,i.y,i.z),new b(r.x,r.y,i.z),new b(i.x,r.y,i.z),new b(i.x,i.y,r.z),new b(r.x,i.y,r.z),new b(r.x,r.y,r.z),new b(i.x,r.y,r.z)],a=new Float32Array(s.length*3);s.forEach((c,l)=>{a[l*3]=c.x,a[l*3+1]=c.y,a[l*3+2]=c.z});const o=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]);return t.lineSegments(a,3,o)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDb3dSolid"),this._version!=null&&t.writeInt16(70,this._version),this._guid!=null&&t.writeString(2,this._guid),this._satCache!=null&&t.writeInt16(290,this._satCache?1:0);const e=255,i=this._acisData.split(`
7
+ `);for(let r=0;r<i.length;r++){const s=r===i.length-1;let a=i[r];for(;a.length>e;)t.writeString(3,a.slice(0,e)),a=a.slice(e);t.writeString(s?1:3,a)}return this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbModelerGeometry");const e=[];let i=this._version;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const r=t.peekItem();if(!r)break;const s=Number(r.code);if(s===100){if(t.readItem(),String(r.value)==="AcDb3dSolid")continue;t.pushBackItem(r);break}t.readItem();const a=Number(r.value);switch(s){case 1:wo(e,1,String(r.value));break;case 3:wo(e,3,String(r.value));break;case 70:i=a;break;case 350:this._historyObjectSoftId=String(r.value);break;case 2:this._guid=String(r.value);break;case 290:this._satCache=a!==0;break}}return this.setAcisData(Jg(e),i),this}};pa.typeName="3dSolid";let Oi=pa;var A=(n=>(n[n.EndPoint=1]="EndPoint",n[n.MidPoint=2]="MidPoint",n[n.Center=3]="Center",n[n.Node=4]="Node",n[n.Quadrant=5]="Quadrant",n[n.Insertion=7]="Insertion",n[n.Perpendicular=8]="Perpendicular",n[n.Tangent=9]="Tangent",n[n.Nearest=10]="Nearest",n[n.Centroid=11]="Centroid",n))(A||{});function $f(n){let t=0;for(const e of n)t|=1<<e-1;return t}function qf(n){const t=[];for(const e of Object.values(A)){if(typeof e!="number")continue;const i=1<<e-1;(n&i)!==0&&t.push(e)}return t}function Kf(n,t){return n^1<<t-1}function Zf(n,t){return(n&1<<t-1)!==0}const ma=class ma extends H{getOffsetSideAtPoint(t){return 1}};ma.typeName="Curve";let _t=ma;function ht(n,t){for(const e of n)Number.isInteger(e)&&e>=0&&t(e)}function ie(n,t,e){ht(n,i=>{i===0&&e.add(t)})}function ki(n,t,e){const i=n[t];i&&(i.x+=e.x,i.y+=e.y)}function hi(n,t,e){ht(n,i=>{const r=e[i];r&&r.add(t)})}function So(n,t){const e=n.x-t.x,i=n.y-t.y,r=(n.z||0)-(t.z||0);return e*e+i*i+r*r}function Ft(n,t){if(t.length===0)return;let e=new b(t[0].x,t[0].y,t[0].z||0),i=So(n,e);for(let r=1;r<t.length;r++){const s=t[r],a=new b(s.x,s.y,s.z||0),o=So(n,a);o<i&&(e=a,i=o)}return e}function ui(n,t,e,i,r){const s=new b(n.x,n.y,n.z||0),a=new b(t.x,t.y,t.z||0),o=new ge(s,a);switch(e){case A.EndPoint:r.push(s,a);break;case A.MidPoint:r.push(o.midPoint);break;case A.Nearest:r.push(o.nearestPoint(i));break;case A.Perpendicular:r.push(o.perpPoint(i));break}}function Ni(n,t,e,i,r,s,a){if(e){const o=new vt(n,t,e);switch(r){case A.EndPoint:a.push(new b(o.startPoint.x,o.startPoint.y,i),new b(o.endPoint.x,o.endPoint.y,i));break;case A.MidPoint:a.push(new b(o.midPoint.x,o.midPoint.y,i));break;case A.Nearest:{const c=o.nearestPoint({x:s.x,y:s.y});a.push(new b(c.x,c.y,i));break}case A.Perpendicular:{o.perpendicularPoints({x:s.x,y:s.y}).forEach(l=>a.push(new b(l.x,l.y,i)));break}case A.Tangent:{o.tangentPoints({x:s.x,y:s.y}).forEach(l=>a.push(new b(l.x,l.y,i)));break}}return}ui(new b(n.x,n.y,i),new b(t.x,t.y,i),r,s,a)}function Pr(n,t,e,i,r){if(n.length!==0)switch(e){case A.EndPoint:n.forEach(s=>r.push(new b(s.x,s.y,s.z||0)));break;case A.MidPoint:case A.Nearest:case A.Perpendicular:{const s=n.length,a=[];for(let o=0;o<s;o++){const c=[];ui(n[o],n[(o+1)%n.length],e,i,c),a.push(...c)}if(e===A.MidPoint)r.push(...a);else{const o=Ft(i,a);o&&r.push(o)}break}}}const gr=class gr extends _t{constructor(t,e,i,r,s=w.Z_AXIS){super(),this._thickness=0;const a=Ti(s);this._geo=new Zt(t,e,i,r,s,a)}get dxfTypeName(){return"ARC"}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 thickness(){return this._thickness}set thickness(t){this._thickness=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 area(){return this._geo.area}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:()=>M.radToDeg(Math.abs(this._geo.deltaAngle))}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this.area}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this.center),t.push(this.startPoint),t.push(this.endPoint),t}subMoveGripPointsAt(t,e){return ht(t,i=>{this.moveGripAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){const s=this.startPoint,a=this.endPoint;switch(t){case A.EndPoint:r.push(s),r.push(a);break;case A.MidPoint:r.push(this.midPoint);break;case A.Center:case A.Centroid:r.push(this._geo.center);break;case A.Quadrant:{const o=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const c of o)M.isBetweenAngle(c,this.startAngle,this.endAngle)&&r.push(this._geo.getPointAtAngle(c));break}case A.Nearest:{const o=this._geo.nearestPoint(e);r.push(o)}break;case A.Perpendicular:{const o=this._geo.perpendicularPoints(e),c=Ft(e,o);c&&r.push(c);break}case A.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){super.dxfOutFields(t);const e=Lt(this.center,this.normal);return t.writeSubclassMarker("AcDbCircle"),this.thickness!==0&&t.writeDouble(39,this.thickness),t.writePoint3d(10,e),t.writeDouble(40,this.radius),t.writeVector3d(210,this.normal),t.writeSubclassMarker("AcDbArc"),t.writeAngle(50,ce(this.center,this.startPoint,this.normal)),t.writeAngle(51,ce(this.center,this.endPoint,this.normal)),this}dxfInFields(t){var d;super.dxfInFields(t);let e=0,i=0,r=0,s=this.radius,a=M.radToDeg(this.startAngle),o=M.radToDeg(this.endAngle),c=this.normal.x,l=this.normal.y,h=this.normal.z;const u=g=>{for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const p=t.readItem();if(!p)break;const f=Number(p.code);if(g&&f===100)return t.pushBackItem(p),!0;const m=Number(p.value);switch(f){case 10:e=m;break;case 20:i=m;break;case 30:r=m;break;case 40:s=m;break;case 39:this.thickness=m;break;case 50:a=m;break;case 51:o=m;break;case 210:c=m;break;case 220:l=m;break;case 230:h=m;break}}return!1};return t.atSubclassData("AcDbCircle")&&u(!0),(t.atSubclassData("AcDbArc")||!t.peekItem()||Number((d=t.peekItem())==null?void 0:d.code)!==100)&&u(!1),this.applyDxfInGeometry(e,i,r,s,a,o,c,l,h),this}applyDxfInGeometry(t,e,i,r,s,a,o,c,l){const h=new w(o,c,l);this.normal.copy(h),this.center=de({x:t,y:e,z:i},h),this.radius=r,this.startAngle=M.degToRad(s),this.endAngle=M.degToRad(a)}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.center,i=this.radius;return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)>=i?1:-1}moveGripAt(t,e){switch(t){case 0:this.transformBy(D.makeTranslation(e));break;case 1:{const i=this._geo.startPoint;this._geo.startAngle=ce(this._geo.center,{x:i.x+e.x,y:i.y+e.y,z:(i.z??0)+(e.z??0)},this._geo.normal);break}case 2:{const i=this._geo.endPoint;this._geo.endAngle=ce(this._geo.center,{x:i.x+e.x,y:i.y+e.y,z:(i.z??0)+(e.z??0)},this._geo.normal);break}}}createOffsetCurve(t){const e=this._geo.offset(t);return e?new gr(e.center,e.radius,e.startAngle,e.endAngle,e.normal):null}};gr.typeName="Arc";let Rn=gr;const Qf=1,Jf=/\\[fF][^\\|{}]*(?:\|[^;\\|{}]*)*;./i,tp=/\\[fF][^\\|{}]*(?:\|[^;\\|{}]*)*;./gi;function ia(n){return n.replace(/\\[PpNn]/g,`
8
+ `).replace(/\\[A-Za-z][^;]*;/g,"").replace(/[{}]/g,"")}function ep(n){return n.replace(/\\[PpNn]/g,`
9
+ `).replace(tp,"").replace(/\\[A-Za-z][^;]*;/g,"").replace(/[{}]/g,"").trim()}function ip(n,t,e=1){const i=n.trim();if(!i||t<=0)return 0;const r=ep(i),s=Jf.test(i);return r?Math.max(t,en(r,t,e)):s?t:0}function en(n,t,e=1){if(!n||t<=0)return 0;const i=ia(n),r=Math.max(...i.split(/\r\n|\r|\n/g).map(s=>s.length),0);return r===0?0:Math.max(t,r*t*Qf*e)}function Bl(n){const t=ia(n);return Math.max(t.split(/\r\n|\r|\n/g).length,1)}function Fl(n,t,e){if(t<=0||n<=0)return 0;if(n===1)return t;const i=Math.max(e,0)*(5/3);return t+(n-1)*t*i}function na(n,t,e){switch(e){case exports.AcGiMTextAttachmentPoint.TopCenter:return{minX:-n/2,minY:-t,maxX:n/2,maxY:0};case exports.AcGiMTextAttachmentPoint.TopRight:return{minX:-n,minY:-t,maxX:0,maxY:0};case exports.AcGiMTextAttachmentPoint.MiddleLeft:return{minX:0,minY:-t/2,maxX:n,maxY:t/2};case exports.AcGiMTextAttachmentPoint.MiddleCenter:return{minX:-n/2,minY:-t/2,maxX:n/2,maxY:t/2};case exports.AcGiMTextAttachmentPoint.MiddleRight:return{minX:-n,minY:-t/2,maxX:0,maxY:t/2};case exports.AcGiMTextAttachmentPoint.BottomLeft:case exports.AcGiMTextAttachmentPoint.BaselineLeft:return{minX:0,minY:0,maxX:n,maxY:t};case exports.AcGiMTextAttachmentPoint.BottomCenter:case exports.AcGiMTextAttachmentPoint.BaselineCenter:return{minX:-n/2,minY:0,maxX:n/2,maxY:t};case exports.AcGiMTextAttachmentPoint.BottomRight:case exports.AcGiMTextAttachmentPoint.BaselineRight:return{minX:-n,minY:0,maxX:0,maxY:t};case exports.AcGiMTextAttachmentPoint.TopLeft:default:return{minX:0,minY:-t,maxX:n,maxY:0}}}function ra(n,t){let e;t&&t.lengthSq()>0?e=t.clone().normalize():e=new w(Math.cos(n),Math.sin(n),0);const i=new w(-e.y,e.x,e.z);return i.lengthSq()===0?i.set(0,1,0):i.normalize(),{xAxis:e,yAxis:i}}function Dl(n,t,e,i,r,s=0,a){if(e<=0&&i<=0)return n.expandByPoint(t),n;const o=na(e,i,r),{xAxis:c,yAxis:l}=ra(s,a?new w(a.x,a.y,a.z||0):void 0),h=[[o.minX,o.minY],[o.maxX,o.minY],[o.maxX,o.maxY],[o.minX,o.maxY]];for(const[u,d]of h)n.expandByPoint(new b(t.x+c.x*u+l.x*d,t.y+c.y*u+l.y*d,t.z+c.z*u+l.z*d));return n}function np(n){const t=n.extentsWidth>0?n.extentsWidth:n.width>0?n.width:en(n.contents,n.height),e=Fl(Bl(n.contents),n.height,n.lineSpacingFactor);return{width:t,height:e,attachment:n.attachmentPoint,rotation:n.rotation,direction:n.direction.lengthSq()>0?n.direction.clone():void 0,location:new b(n.location.x,n.location.y,n.location.z??0)}}function rp(n,t){const{xAxis:e,yAxis:i}=ra(t.rotation,t.direction),r=n.x-t.location.x,s=n.y-t.location.y,a=(n.z??0)-t.location.z;return{x:r*e.x+s*e.y+a*e.z,y:r*i.x+s*i.y+a*i.z}}function sp(n){const t=na(n.width,n.height,n.attachment),{xAxis:e,yAxis:i}=ra(n.rotation,n.direction);return[[t.minX,t.minY],[t.maxX,t.minY],[t.maxX,t.maxY],[t.minX,t.maxY]].map(([s,a])=>new b(n.location.x+e.x*s+i.x*a,n.location.y+e.y*s+i.y*a,n.location.z+e.z*s+i.z*a))}function ap(n,t,e){const i=na(t.width,t.height,t.attachment),{x:r,y:s}=rp(n,t),a=i.minX-e.padX,o=i.maxX+e.padX,c=i.minY-e.padYBelow,l=i.maxY+e.padYAbove;if(r<a||r>o||s<c||s>l)return null;const h=r<i.minX?i.minX-r:r>i.maxX?i.maxX-r:0,u=s<i.minY?i.minY-s:s>i.maxY?s-i.maxY:0;return h+u}var Yl=(n=>(n[n.LEFT=0]="LEFT",n[n.CENTER=1]="CENTER",n[n.RIGHT=2]="RIGHT",n[n.ALIGNED=3]="ALIGNED",n[n.MIDDLE=4]="MIDDLE",n[n.FIT=5]="FIT",n))(Yl||{}),Xl=(n=>(n[n.BASELINE=0]="BASELINE",n[n.BOTTOM=1]="BOTTOM",n[n.MIDDLE=2]="MIDDLE",n[n.TOP=3]="TOP",n))(Xl||{});const ya=class ya extends H{constructor(){super(),this._generationFlag=0,this._normal=new w(0,0,1),this._textString="",this._height=0,this._thickness=1,this._position=new b,this._alignmentPoint=new b,this._rotation=0,this._oblique=0,this._horizontalMode=0,this._verticalModel=2,this._styleName="",this._widthFactor=1}get dxfTypeName(){return"TEXT"}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 alignmentPoint(){return this._alignmentPoint}set alignmentPoint(t){this._alignmentPoint.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 generationFlag(){return this._generationFlag}set generationFlag(t){this._generationFlag=t}get isBackward(){return(this._generationFlag&2)!==0}set isBackward(t){this._generationFlag=t?this._generationFlag|2:this._generationFlag&-3}get isUpsideDown(){return(this._generationFlag&4)!==0}set isUpsideDown(t){this._generationFlag=t?this._generationFlag|4:this._generationFlag&-5}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get geometricExtents(){const t=new Y,{anchor:e,attachmentPoint:i}=this.resolveTextAnchor(),r=en(this.textString,this.height,this.widthFactor);return Dl(t,e,r,this.height,i,this.rotation)}subGetGripPoints(){return[this._position]}subMoveGripPointsAt(t,e){return ie(t,e,this._position),this._alignmentPoint.add(e),this}subGetOsnapPoints(t,e,i,r){A.Insertion===t&&r.push(this._position)}transformBy(t){const e=this._position.clone(),i=this._position.clone().add(new w(Math.cos(this._rotation),Math.sin(this._rotation),0)),r=this._position.clone().add(new w(-Math.sin(this._rotation),Math.cos(this._rotation),0)),s=this._position.clone().add(new w(0,0,1));e.applyMatrix4(t),i.applyMatrix4(t),r.applyMatrix4(t),s.applyMatrix4(t);const a=new w(i).sub(e),o=new w(r).sub(e),c=new w(s).sub(e),l=o.length(),h=a.length(),u=c.length();this._position.copy(e),h>0&&(this._rotation=Math.atan2(a.y,a.x)),l>0&&(this._height*=l,h>0&&(this._widthFactor*=h/l)),u>0&&(this._thickness*=u);const d=this._alignmentPoint.clone();return d.applyMatrix4(t),this._alignmentPoint.copy(d),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.textString,set:t=>{this.textString=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.height,set:t=>{this.height=t}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:t=>{this.rotation=t}}},{name:"widthFactor",type:"float",editable:!0,accessor:{get:()=>this.widthFactor,set:t=>{this.widthFactor=t}}},{name:"oblique",type:"float",editable:!0,accessor:{get:()=>this.oblique,set:t=>{this.oblique=t}}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}getTextStyle(){const t=this.database.tables.textStyleTable.resolveAt(this.styleName);if(!t)throw new Error("No valid text style found in text style table.");return t.textStyle}subWorldDraw(t,e){const{anchor:i,attachmentPoint:r}=this.resolveTextAnchor(),s={text:this.textString,height:this.height,width:1/0,widthFactor:this.widthFactor,position:i,rotation:this.rotation,drawingDirection:exports.AcGiMTextFlowDirection.BOTTOM_TO_TOP,attachmentPoint:r};return t.mtext(s,this.getTextStyle(),e)}resolveTextAnchor(){const t=this.resolveAttachmentPoint();if(t===exports.AcGiMTextAttachmentPoint.BaselineLeft)return{anchor:this._position,attachmentPoint:t};const e=this._alignmentPoint;return e.x===0&&e.y===0&&e.z===0||e.x===this._position.x&&e.y===this._position.y&&e.z===this._position.z?{anchor:this._position,attachmentPoint:exports.AcGiMTextAttachmentPoint.BaselineLeft}:{anchor:e,attachmentPoint:t}}resolveAttachmentPoint(){const t=this._horizontalMode,e=this._verticalModel;if(t===4)return exports.AcGiMTextAttachmentPoint.MiddleCenter;if(t===3||t===5)return exports.AcGiMTextAttachmentPoint.BaselineLeft;switch(e){case 3:return t===1?exports.AcGiMTextAttachmentPoint.TopCenter:t===2?exports.AcGiMTextAttachmentPoint.TopRight:exports.AcGiMTextAttachmentPoint.TopLeft;case 2:return t===1?exports.AcGiMTextAttachmentPoint.MiddleCenter:t===2?exports.AcGiMTextAttachmentPoint.MiddleRight:exports.AcGiMTextAttachmentPoint.MiddleLeft;case 1:return t===1?exports.AcGiMTextAttachmentPoint.BottomCenter:t===2?exports.AcGiMTextAttachmentPoint.BottomRight:exports.AcGiMTextAttachmentPoint.BottomLeft;case 0:default:return t===1?exports.AcGiMTextAttachmentPoint.BaselineCenter:t===2?exports.AcGiMTextAttachmentPoint.BaselineRight:exports.AcGiMTextAttachmentPoint.BaselineLeft}}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),this.generationFlag!==0&&t.writeInt16(71,this.generationFlag),t.writeInt16(72,this.horizontalMode),t.writeInt16(73,this.verticalMode),t.writePoint3d(11,this.alignmentPoint),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbText");let e=this.position.x,i=this.position.y,r=this.position.z,s=this.alignmentPoint.x,a=this.alignmentPoint.y,o=this.alignmentPoint.z,c=!1,l=this.normal.x,h=this.normal.y,u=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const d=t.readItem();if(!d)break;const g=Number(d.code),p=Number(d.value);switch(g){case 10:e=p;break;case 20:i=p;break;case 30:r=p;break;case 11:s=p,c=!0;break;case 21:a=p,c=!0;break;case 31:o=p,c=!0;break;case 1:this.textString=String(d.value);break;case 7:this.styleName=String(d.value);break;case 39:this.thickness=p;break;case 40:this.height=p;break;case 41:this.widthFactor=p;break;case 50:this.rotation=M.degToRad(p);break;case 51:this.oblique=M.degToRad(p);break;case 71:this.generationFlag=p;break;case 72:this.horizontalMode=p;break;case 73:this.verticalMode=p;break;case 210:l=p;break;case 220:h=p;break;case 230:u=p;break;case 100:{if(String(d.value)==="AcDbText")break;return t.pushBackItem(d),this.finishTextDxfIn(e,i,r,s,a,o,c,l,h,u),this}}}return this.finishTextDxfIn(e,i,r,s,a,o,c,l,h,u),this}finishTextDxfIn(t,e,i,r,s,a,o,c,l,h){this.position=new b(t,e,i),o&&!(r===0&&s===0&&a===0)?this.alignmentPoint=new b(r,s,a):this.alignmentPoint=new b(t,e,i);const u=new w(c,l,h);u.lengthSq()>0&&this.normal.copy(u.normalize())}};ya.typeName="Text";let si=ya;var dt=(n=>(n[n.Invisible=1]="Invisible",n[n.Const=2]="Const",n[n.Verifiable=4]="Verifiable",n[n.Preset=8]="Preset",n))(dt||{}),Ht=(n=>(n[n.MultiLine=2]="MultiLine",n[n.ConstMultiLine=4]="ConstMultiLine",n))(Ht||{});const ba=class ba extends si{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}isLooseInDrawingSpace(){const t=this.database;if(!t||!this.ownerId)return!0;const e=t.tables.blockTable.getIdAt(this.ownerId);return e?e.isModelSapce||e.isPaperSapce:!0}resolveDisplayText(){if(!this.isInvisible)return this.isLooseInDrawingSpace()?this.tag||this.textString:this.textString}subWorldDraw(t,e){const i=this.resolveDisplayText();if(i===void 0)return;if(i===this.textString)return super.subWorldDraw(t,e);const r=this.textString;this.textString=i;try{return super.subWorldDraw(t,e)}finally{this.textString=r}}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbAttributeDefinition"),t.writeString(3,this.prompt),t.writeString(2,this.tag),t.writeInt16(70,this._flags),t.writeInt16(73,this.fieldLength),t.writeInt16(74,this.lockPositionInBlock?1:0),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbAttributeDefinition");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code),r=Number(e.value);switch(i){case 2:this.tag=String(e.value);break;case 3:this.prompt=String(e.value);break;case 70:this.isInvisible=(r&1)!==0,this.isConst=(r&2)!==0,this.isVerifiable=(r&4)!==0,this.isPreset=(r&8)!==0;break;case 71:this.isMTextAttribute=(r&2)!==0,this.isConstMTextAttribute=(r&4)!==0;break;case 73:this.fieldLength=r;break;case 74:this.verticalMode=r;break;case 280:this.lockPositionInBlock=r!==0;break}}return this}};ba.typeName="AttDef";let Bn=ba;function op(n){return n!=null&&typeof n=="object"&&"blockTableRecord"in n}const _a=class _a extends si{get dxfTypeName(){return"ATTRIB"}get resolvedColor(){var t;if(this.color.isByBlock){const e=(t=this.database)==null?void 0:t.tables.blockTable.getEntityById(this.ownerId);if(op(e))return e.resolvedColor}return this.resolveStandardColor()}constructor(){super(),this._flags=0,this._mtextFlag=0,this._tag="",this._fieldLength=0,this._lockPositionInBlock=!1,this._isReallyLocked=!1}get isInvisible(){return(this._flags&dt.Invisible)!==0}set isInvisible(t){t?this._flags|=dt.Invisible:this._flags&=~dt.Invisible}get isConst(){return(this._flags&dt.Const)!==0}set isConst(t){t?this._flags|=dt.Const:this._flags&=~dt.Const}get isVerifiable(){return(this._flags&dt.Verifiable)!==0}set isVerifiable(t){t?this._flags|=dt.Verifiable:this._flags&=~dt.Verifiable}get isPreset(){return(this._flags&dt.Preset)!==0}set isPreset(t){t?this._flags|=dt.Preset:this._flags&=~dt.Preset}get isMTextAttribute(){return(this._mtextFlag&Ht.MultiLine)!==0}set isMTextAttribute(t){t?this._mtextFlag|=Ht.MultiLine:this._mtextFlag&=~Ht.MultiLine}get isConstMTextAttribute(){return(this._mtextFlag&Ht.ConstMultiLine)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=Ht.ConstMultiLine:this._mtextFlag&=~Ht.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}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbAttribute");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code),r=Number(e.value);switch(i){case 2:this.tag=String(e.value);break;case 70:this.isInvisible=(r&dt.Invisible)!==0,this.isConst=(r&dt.Const)!==0,this.isVerifiable=(r&dt.Verifiable)!==0,this.isPreset=(r&dt.Preset)!==0;break;case 71:this.isMTextAttribute=(r&Ht.MultiLine)!==0,this.isConstMTextAttribute=(r&Ht.ConstMultiLine)!==0;break;case 73:this.fieldLength=r;break;case 74:this.verticalMode=r;break;case 280:this.lockPositionInBlock=r!==0;break}}return this}};_a.typeName="Attrib";let Ri=_a;const cp=()=>({hits:0,misses:0,hitMs:0,missBuildMs:0,missCompactMs:0,cloneMs:0,setCloneMs:0,applyMs:0}),Po=()=>({hits:0,misses:0,hitMs:0,missBuildMs:0,missCompactMs:0,cloneMs:0,setCloneMs:0,applyMs:0,topLevel:cp(),blockMisses:[]}),ct=class ct{static get profileStats(){return this._profileStats}static resetProfile(){this._profileStats=Po(),this._drawDepth=0}static get instance(){return this._instance||(this._instance=new ct),this._instance}constructor(){this._blocks=new Map}createKey(t,e){let i=e.toString();return!i&&e.isByColor&&(i=`RGB:${e.red},${e.green},${e.blue}`),`${t}_${i}`}createCacheKey(t,e,i){return i?this.createKey(t,e):t}set(t,e){if(ct.profiling){const i=performance.now();e=e.fastDeepClone();const r=performance.now()-i;ct._profileStats.setCloneMs+=r,ct._drawDepth===1&&(ct._profileStats.topLevel.setCloneMs+=r)}else e=e.fastDeepClone();return this._blocks.set(t,e),e}get(t){let e=this._blocks.get(t);if(e)if(ct.profiling){const i=performance.now();e=e.fastDeepClone();const r=performance.now()-i;ct._profileStats.cloneMs+=r,ct._drawDepth===1&&(ct._profileStats.topLevel.cloneMs+=r)}else e=e.fastDeepClone();return e}has(t){return this._blocks.has(t)}clear(){this._blocks.forEach(t=>{var e;(e=t.dispose)==null||e.call(t)}),this._blocks.clear()}async prebuildAll(t,e,i){const r=[];for(const l of e)!l||!l.name||this.shouldSkipPrebuild(l)||r.push(l);const s=r.length;let a=0;const o=new X().setForeground(),c=new vr;for(const l of r){const h=this.createCacheKey(l.name,o,!1);this.has(h)||this.draw(t,l,o,[],!0),a++,i&&await i(a,s,l.name),await c.maybeYield(ci)}}draw(t,e,i,r=[],s=!0,a,o){const c=ct.profiling;c&&ct._drawDepth++;const l=c&&ct._drawDepth===1,h=ct._profileStats,u=[];try{if(e!=null){const d=i.RGB??0,g=e.name;let p;if(g&&this.has(g))p=g;else if(g){const y=this.createKey(g,i);this.has(y)&&(p=y)}let f;if(p!==void 0){const y=c?performance.now():0;if(f=this.get(p),c){const _=performance.now()-y;h.hits++,h.hitMs+=_,l&&(h.topLevel.hits++,h.topLevel.hitMs+=_)}}else{const y=c?performance.now():0;let _=!1;const v=e.newIterator();for(const P of v)if(P.visibility)if(P.color.isByBlock){_=!0;const C=dp(P.color);try{i.isForeground?P.color.setForeground():P.color.setRGBValue(d),this.addEntity(P,u,t)}finally{P.color.copy(C),gp(C)}}else this.addEntity(P,u,t);f=t.group(u);let x=0;c&&(x=performance.now()-y,h.missBuildMs+=x,l&&(h.topLevel.missBuildMs+=x));let k=0;if(f!=null&&f.compactForInstancing&&up(f)>=hp){const P=c?performance.now():0;f.compactForInstancing(),c&&(k=performance.now()-P,h.missCompactMs+=k,l&&(h.topLevel.missCompactMs+=k))}p=this.createCacheKey(g,i,_);const I=c?h.setCloneMs:0;f&&s&&g&&!g.startsWith("*U")&&this.set(p,f),c&&(h.misses++,l&&h.topLevel.misses++,h.blockMisses.push({blockName:g||"(unnamed)",buildMs:x,compactMs:k,setCloneMs:h.setCloneMs-I}))}const m=c?performance.now():0;if(f&&a&&(pn.copy(a),f.applyMatrix(pn),o&&(o.x!=0||o.y!=0||o.z!=1)&&(Kr.setFromExtrusionDirection(o),f.applyMatrix(Kr),pn.premultiply(Kr))),f&&r&&r.length>0){const y=a!=null?lp.copy(pn).invert():void 0;r.forEach(_=>{y&&_.applyMatrix(y),f.addChild(_)})}if(c){const y=performance.now()-m;h.applyMs+=y,l&&(h.topLevel.applyMs+=y)}return f}else return t.group(u)}finally{c&&ct._drawDepth--}}shouldSkipPrebuild(t){const e=t.name;if(tt.isModelSapceName(e)||tt.isPaperSapceName(e)||e.startsWith("*U")||this.blockHasByBlockColor(t))return!0;for(const i of t.newIterator())if(i.visibility)return!1;return!0}blockHasByBlockColor(t){for(const e of t.newIterator())if(e.visibility&&e.color.isByBlock)return!0;return!1}addEntity(t,e,i){if(!t.visibility)return;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}};ct.profiling=!1,ct._profileStats=Po(),ct._drawDepth=0;let Ie=ct;const pn=new D,Kr=new D,lp=new D,hp=3,zl=[];function up(n){const t=n.childCount;return typeof t=="number"?t:Number.POSITIVE_INFINITY}function dp(n){const t=zl.pop()??new X;return t.copy(n),t}function gp(n){zl.push(n)}const $e=class $e extends H{constructor(t){super(),this._columnCount=1,this._rowCount=1,this._columnSpacing=0,this._rowSpacing=0,this._blockName=t,this._position=new b,this._rotation=0,this._normal=new w(0,0,1),this._scaleFactors=new b(1,1,1),this._attribs=new Map}get dxfTypeName(){return"INSERT"}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}set blockName(t){this._blockName=t}get columnCount(){return this._columnCount}set columnCount(t){this._columnCount=Math.max(1,Math.floor(t)||1)}get rowCount(){return this._rowCount}set rowCount(t){this._rowCount=Math.max(1,Math.floor(t)||1)}get columnSpacing(){return this._columnSpacing}set columnSpacing(t){this._columnSpacing=t}get rowSpacing(){return this._rowSpacing}set rowSpacing(t){this._rowSpacing=t}get blockTableRecord(){return this.database.tables.blockTable.getAt(this._blockName)}appendAttributes(t){this._attribs.set(t.objectId,t),t.ownerId=this.objectId,this.syncAttributeDatabases()}syncAttributeDatabases(){try{const t=this.database,e=new Map;this._attribs.forEach(i=>{i.database=t,i.ownerId=this.objectId,t.commitObjectHandle(i),e.set(i.objectId,i)}),this._attribs=e}catch{}}attributeIterator(){return new ni(this._attribs)}get blockTransform(){const t=this.blockTableRecord,e=(t==null?void 0:t.origin)??b.ORIGIN,i=new D().makeTranslation(-e.x,-e.y,-e.z),r=new D().makeScale(this._scaleFactors.x,this._scaleFactors.y,this._scaleFactors.z),s=new ei().setFromAxisAngle(w.Z_AXIS,this._rotation),a=new D().makeRotationFromQuaternion(s),o=new D().makeTranslation(this._position.x,this._position.y,this._position.z);return new D().multiplyMatrices(o,a).multiply(r).multiply(i)}subGetGripPoints(){return[this._position]}subMoveGripPointsAt(t,e){return ie(t,e,this._position),this}subGetOsnapPoints(t,e,i,r,s,a){const o=a??new D;A.Insertion===t?r.push(this.getInsertionPoint(o)):s?this.subEntityGetOsnapPoints(t,e,i,r,s,o):this.collectBlockOsnapPoints(t,e,i,r,o)}transformBy(t){const e=new D().setFromExtrusionDirection(this._normal),i=new D().makeRotationZ(this._rotation),r=new D().multiplyMatrices(e,i),s=this._position.clone(),a=new b(this._scaleFactors.x,0,0).applyMatrix4(r).add(s),o=new b(0,this._scaleFactors.y,0).applyMatrix4(r).add(s),c=new b(0,0,this._scaleFactors.z).applyMatrix4(r).add(s);s.applyMatrix4(t),a.applyMatrix4(t),o.applyMatrix4(t),c.applyMatrix4(t);const l=new w(a).sub(s),h=new w(o).sub(s),u=new w(c).sub(s);let d=new w().crossVectors(l,h);d.lengthSq()===0?d=this._normal.clone().transformDirection(t):d.normalize();const p=new D().setFromExtrusionDirection(d).clone().invert(),f=l.clone().applyMatrix4(p);return this._position.copy(s),this._normal.copy(d),this._rotation=Math.atan2(f.y,f.x),this._scaleFactors.set(l.length(),h.length(),u.length()),this._attribs.forEach(m=>m.transformBy(t)),this}get properties(){const t={type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"blockName",type:"float",editable:!1,accessor:{get:()=>this._blockName}},{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:e=>{this.position.x=e}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:e=>{this.position.y=e}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:e=>{this.position.z=e}}},{name:"rotation",type:"float",editable:!0,accessor:{get:()=>this.rotation,set:e=>{this.rotation=e}}},{name:"scaleFactorsX",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.x,set:e=>{this.scaleFactors.x=e}}},{name:"scaleFactorsY",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.y,set:e=>{this.scaleFactors.y=e}}},{name:"scaleFactorsZ",type:"float",editable:!0,accessor:{get:()=>this.scaleFactors.z,set:e=>{this.scaleFactors.z=e}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:e=>{this.normal.x=e}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:e=>{this.normal.y=e}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:e=>{this.normal.z=e}}}]}]};if(this._attribs.size>0){const e={groupName:"attribute",properties:[]};t.groups.push(e),this._attribs.forEach(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 Y,e=this.blockTableRecord;if(e!=null){const r=e.newIterator();for(const s of r)t.union(s.geometricExtents)}const i=this.blockTransform;return t.applyMatrix4(i),t}subWorldDraw(t){const e=this.blockTableRecord;if(e!=null){const i=[];this._attribs.forEach(o=>{if(!o.isInvisible){const c=o.worldDraw(t);c&&i.push(c)}});const r=Math.max(1,this.columnCount),s=Math.max(1,this.rowCount);if(r===1&&s===1)return Ie.instance.draw(t,e,this.resolvedColor,i,!0,this.blockTransform,this._normal);const a=[];for(let o=0;o<s;o++)for(let c=0;c<r;c++){const l=new D().makeTranslation(c*this.columnSpacing,o*this.rowSpacing,0),h=new D().multiplyMatrices(this.blockTransform,l),u=Ie.instance.draw(t,e,this.resolvedColor,c===0&&o===0?i:[],!0,h,this._normal);u&&a.push(u)}return t.group(a)}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,e);return i&&(t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity")),this}collectBlockOsnapPoints(t,e,i,r,s){const a=this.blockTableRecord;if(!a)return;const o=new D().multiplyMatrices(s,this.getFullInsertionTransform()),c=o.clone().invert(),l=new b(e).applyMatrix4(c),h=new b(i).applyMatrix4(c),u=[];for(const d of a.newIterator()){const g=[];if(d instanceof $e){d.subGetOsnapPoints(t,e,i,g,void 0,o),u.push(...g);continue}d.subGetOsnapPoints(t,l,h,g,void 0,o),g.forEach(p=>u.push(new b(p).applyMatrix4(o)))}if(u.length!==0)if(t===A.Nearest||t===A.Perpendicular||t===A.Tangent){const d=Ft(e,u);d&&r.push(d)}else r.push(...u)}subEntityGetOsnapPoints(t,e,i,r,s,a,o=new Set){if(s===this.objectId||o.has(this.objectId))return!1;o.add(this.objectId);try{const c=this.blockTableRecord;if(c==null)return!1;const l=new D().multiplyMatrices(a,this.getFullInsertionTransform());for(const h of c.newIterator()){if(h.objectId===s){const u=new b(e).applyMatrix4(l.clone().invert()),d=new b(i).applyMatrix4(l.clone().invert()),g=[];return h.subGetOsnapPoints(t,u,d,g,s,l),h instanceof $e?g.forEach(p=>{r.push(p.clone())}):g.forEach(p=>{r.push(new b(p).applyMatrix4(l))}),!0}if(h instanceof $e&&h.subEntityGetOsnapPoints(t,e,i,r,s,l,o))return!0}return!1}finally{o.delete(this.objectId)}}getInsertionPoint(t){var r;const e=((r=this.blockTableRecord)==null?void 0:r.origin)??b.ORIGIN,i=new D().multiplyMatrices(t,this.getFullInsertionTransform());return new b(e).applyMatrix4(i)}getFullInsertionTransform(){const t=new D().setFromExtrusionDirection(this._normal);return new D().multiplyMatrices(t,this.blockTransform)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbBlockReference"),t.writePoint3d(10,this.position),t.writeString(2,this.blockName),t.writeDouble(41,this.scaleFactors.x),t.writeDouble(42,this.scaleFactors.y),t.writeDouble(43,this.scaleFactors.z),t.writeAngle(50,this.rotation),this.columnCount>1&&t.writeInt16(70,this.columnCount),this.rowCount>1&&t.writeInt16(71,this.rowCount),this.columnSpacing!==0&&t.writeDouble(44,this.columnSpacing),this.rowSpacing!==0&&t.writeDouble(45,this.rowSpacing),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbBlockReference");let e=this.position.x,i=this.position.y,r=this.position.z,s=this.scaleFactors.x,a=this.scaleFactors.y,o=this.scaleFactors.z,c=M.radToDeg(this.rotation),l=this.normal.x,h=this.normal.y,u=this.normal.z,d=this.columnCount,g=this.rowCount,p=this.columnSpacing,f=this.rowSpacing;const m=()=>{this.position=new b(e,i,r),this.scaleFactors=new b(s,a,o),this.rotation=M.degToRad(c),this.normal.copy(new w(l,h,u)),this.columnCount=d>0?d:1,this.rowCount=g>0?g:1,this.columnSpacing=p,this.rowSpacing=f};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const y=t.readItem();if(!y)break;const _=Number(y.code),v=Number(y.value);switch(_){case 10:e=v;break;case 20:i=v;break;case 30:r=v;break;case 2:this.blockName=String(y.value);break;case 41:s=v;break;case 42:a=v;break;case 43:o=v;break;case 44:p=v;break;case 45:f=v;break;case 50:c=v;break;case 66:break;case 70:d=v;break;case 71:g=v;break;case 210:l=v;break;case 220:h=v;break;case 230:u=v;break;case 100:return t.pushBackItem(y),m(),this}}return m(),this}};$e.typeName="BlockReference";let ee=$e;const Io=[0,Math.PI/2,Math.PI,Math.PI/2*3],fr=class fr extends _t{constructor(t,e,i=w.Z_AXIS){super(),this._thickness=0;const r=Ti(i);this._geo=new Zt(t,e,0,V,i,r)}get dxfTypeName(){return"CIRCLE"}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 thickness(){return this._thickness}set thickness(t){this._thickness=t}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}get area(){return this._geo.area}subGetOsnapPoints(t,e,i,r){switch(t){case A.Center:case A.Centroid:r.push(this._geo.center);break;case A.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 A.Nearest:{const s=this._geo.nearestPoint(e);r.push(s)}break;case A.Tangent:{const s=this._geo.tangentPoints(e);r.push(...s);break}case A.Perpendicular:{const s=this._geo.perpendicularPoints(e),a=Ft(e,s);a&&r.push(a);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.area}}]}]}}subGetGripPoints(){const t=new Array;t.push(this.center);for(const e of Io)t.push(this._geo.getPointAtAngle(e));return t}subMoveGripPointsAt(t,e){return ht(t,i=>{this.moveGripAt(i,e)}),this}transformBy(t){return this._geo.transform(t),this}subWorldDraw(t){return t.circularArc(this._geo)}dxfOutFields(t){super.dxfOutFields(t);const e=Lt(this.center,this.normal);return t.writeSubclassMarker("AcDbCircle"),t.writePoint3d(10,e),t.writeDouble(40,this.radius),this.thickness!==0&&t.writeDouble(39,this.thickness),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbCircle");let e=0,i=0,r=0,s=this.radius,a=this.normal.x,o=this.normal.y,c=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const l=t.readItem();if(!l)break;const h=Number(l.code),u=Number(l.value);switch(h){case 10:e=u;break;case 20:i=u;break;case 30:r=u;break;case 40:s=u;break;case 39:this.thickness=u;break;case 210:a=u;break;case 220:o=u;break;case 230:c=u;break}}return this.applyDxfInGeometry(e,i,r,s,a,o,c),this}applyDxfInGeometry(t,e,i,r,s,a,o){const c=new w(s,a,o);this.normal.copy(c),this.center=de({x:t,y:e,z:i},c),this.radius=r}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.center,i=this.radius;return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)>=i?1:-1}createOffsetCurve(t){const e=this._geo.offset(t);return e?new fr(e.center,e.radius,e.normal):null}moveGripAt(t,e){switch(t){case 0:this.transformBy(D.makeTranslation(e));break;case 1:case 2:case 3:case 4:{const i=Io[t-1],r=this._geo.getPointAtAngle(i),a=new b(r.x+e.x,r.y+e.y,(r.z??0)+(e.z??0)).distanceTo(this.center);a>0&&(this.radius=a);break}}}};fr.typeName="Circle";let Fn=fr;const fi=[0,Math.PI/2,Math.PI,Math.PI/2*3],pr=class pr extends _t{get dxfTypeName(){return"ELLIPSE"}constructor(t,e,i,r,s,a,o){super(),this._geo=new Cn(t,e,i,r,s,a,o)}get center(){return this._geo.center}set center(t){this._geo.center=t}get majorAxis(){return this._geo.majorAxis}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||Math.abs(this._geo.deltaAngle-V)<1e-10}get area(){return this._geo.area}subGetGripPoints(){const t=new Array;if(t.push(this._geo.center),this.closed)for(const e of fi)t.push(this._geo.getPointAtAngle(e));else t.push(this._geo.startPoint),t.push(this._geo.endPoint);return t}subMoveGripPointsAt(t,e){return ht(t,i=>{this.moveGripAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){switch(t){case A.EndPoint:this.closed||(r.push(this._geo.startPoint),r.push(this._geo.endPoint));break;case A.MidPoint:this.closed||r.push(this._geo.midPoint);break;case A.Center:case A.Centroid:r.push(this._geo.center);break;case A.Quadrant:if(this.closed)for(const s of fi)r.push(this._geo.getPointAtAngle(s));break;case A.Nearest:r.push(this._geo.nearestPoint(e));break;case A.Tangent:r.push(...this._geo.tangentPoints(e));break;case A.Perpendicular:{const s=this._geo.perpendicularPoints(e),a=Ft(e,s);a&&r.push(a);break}}}transformBy(t){return this._geo.transform(t),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"centerX",type:"float",editable:!0,accessor:{get:()=>this.center.x,set:t=>{this.center.x=t}}},{name:"centerY",type:"float",editable:!0,accessor:{get:()=>this.center.y,set:t=>{this.center.y=t}}},{name:"centerZ",type:"float",editable:!0,accessor:{get:()=>this.center.z,set:t=>{this.center.z=t}}},{name:"majorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.majorAxisRadius,set:t=>{this.center.x=t}}},{name:"minorAxisRadius",type:"float",editable:!0,accessor:{get:()=>this.minorAxisRadius,set:t=>{this.minorAxisRadius=t}}},{name:"startAngle",type:"float",editable:!0,accessor:{get:()=>this.startAngle,set:t=>{this.startAngle=t}}},{name:"endAngle",type:"float",editable:!0,accessor:{get:()=>this.endAngle,set:t=>{this.endAngle=t}}},{name:"normalX",type:"float",editable:!0,accessor:{get:()=>this.normal.x,set:t=>{this.normal.x=t}}},{name:"normalY",type:"float",editable:!0,accessor:{get:()=>this.normal.y,set:t=>{this.normal.y=t}}},{name:"normalZ",type:"float",editable:!0,accessor:{get:()=>this.normal.z,set:t=>{this.normal.z=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}},{name:"area",type:"float",editable:!1,accessor:{get:()=>this.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}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbEllipse");let e=this.center.x,i=this.center.y,r=this.center.z,s=this.majorAxis.x*this.majorAxisRadius,a=this.majorAxis.y*this.majorAxisRadius,o=this.majorAxis.z*this.majorAxisRadius,c=this.normal.x,l=this.normal.y,h=this.normal.z,u=this.majorAxisRadius>0?this.minorAxisRadius/this.majorAxisRadius:1,d=this.startAngle,g=this.endAngle;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const p=t.readItem();if(!p)break;const f=Number(p.code),m=Number(p.value);switch(f){case 10:e=m;break;case 20:i=m;break;case 30:r=m;break;case 11:s=m;break;case 21:a=m;break;case 31:o=m;break;case 210:c=m;break;case 220:l=m;break;case 230:h=m;break;case 40:u=m;break;case 41:d=m;break;case 42:g=m;break}}return this.applyDxfInGeometry(e,i,r,s,a,o,c,l,h,u,d,g),this}applyDxfInGeometry(t,e,i,r,s,a,o,c,l,h,u,d){const g=Math.hypot(r,s,a)||1;this._geo=new Cn({x:t,y:e,z:i},{x:o,y:c,z:l},{x:r,y:s,z:a},g,g*h,u,d)}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.center,i=t.x-e.x,r=t.y-e.y,s=this.majorAxis,a=Math.hypot(s.x,s.y)||1,o=this.minorAxisRadius/this.majorAxisRadius*a||1,c=s.x/a,l=s.y/a,h=-l,u=c,d=i*c+r*l,g=i*h+r*u;return(d/a)**2+(g/o)**2>=1?1:-1}moveGripAt(t,e){switch(t){case 0:this.transformBy(D.makeTranslation(e));break;case 1:if(this.closed)this.moveQuadrantGripAt(fi[0],e);else{const i=this._geo.startPoint;this._geo.startAngle=ce(this._geo.center,{x:i.x+e.x,y:i.y+e.y,z:(i.z??0)+(e.z??0)},this._geo.normal)}break;case 2:if(this.closed)this.moveQuadrantGripAt(fi[1],e);else{const i=this._geo.endPoint;this._geo.endAngle=ce(this._geo.center,{x:i.x+e.x,y:i.y+e.y,z:(i.z??0)+(e.z??0)},this._geo.normal)}break;case 3:case 4:this.closed&&this.moveQuadrantGripAt(fi[t-1],e);break}}moveQuadrantGripAt(t,e){const i=this._geo.getPointAtAngle(t),r=new b(i.x+e.x,i.y+e.y,(i.z??0)+(e.z??0)),s=this._geo.center,a=r.x-s.x,o=r.y-s.y,c=(r.z??0)-(s.z??0),l=t===0||t===Math.PI?this._geo.majorAxis:this._geo.minorAxis,h=a*l.x+o*l.y+c*l.z,u=Math.abs(h);u<=0||(t===0||t===Math.PI?this.majorAxisRadius=u:this.minorAxisRadius=u)}createOffsetCurve(t){const e=this._geo.offset(t);return e?new pr(e.center,e.normal,e.majorAxis,e.majorAxisRadius,e.minorAxisRadius,e.startAngle,e.endAngle):null}};pr.typeName="Ellipse";let Dn=pr;const xa=class xa extends H{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 Y().setFromPoints(this._vertices)}get area(){const t=[this.getVertexAt(0),this.getVertexAt(1),this.getVertexAt(2)],e=this.getVertexAt(3);return(e.x!==t[2].x||e.y!==t[2].y||e.z!==t[2].z)&&t.push(e),Tc(t)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subMoveGripPointsAt(t,e){return hi(t,e,this._vertices),this}subGetOsnapPoints(t,e,i,r){Pr(this._vertices,!0,t,e,r)}transformBy(t){return this._vertices.forEach(e=>e.applyMatrix4(t)),this}subWorldDraw(t){const e=this._vertices.length,i=new Float32Array(e*3),r=new Uint16Array(e*2);for(let s=0;s<e;s++)i[s*3]=this._vertices[s].x,i[s*3+1]=this._vertices[s].y,i[s*3+2]=this._vertices[s].z,this.isEdgeVisibleAt(s)&&(r[s*2]=s,r[s*2+1]=(s+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),s=this.getVertexAt(3);t.writeSubclassMarker("AcDbFace"),t.writePoint3d(10,e),t.writePoint3d(11,i),t.writePoint3d(12,r),t.writePoint3d(13,s);let a=0;for(let o=0;o<4;++o)this.isEdgeVisibleAt(o)||(a|=1<<o);return t.writeInt16(70,a),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbFace");const e=[0,1,2,3].map(r=>{const s=this._vertices[r];return s?{x:s.x,y:s.y,z:s.z}:{x:0,y:0,z:0}});let i=this._edgeInvisibilities;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const r=t.readItem();if(!r)break;const s=Number(r.code),a=Number(r.value);switch(s){case 10:case 11:case 12:case 13:e[s-10].x=a;break;case 20:case 21:case 22:case 23:e[s-20].y=a;break;case 30:case 31:case 32:case 33:e[s-30].z=a;break;case 70:i=a;break}}return e.forEach((r,s)=>this.setVertexAt(s,r)),this._edgeInvisibilities=i,this}};xa.typeName="Face";let Yn=xa;var St=(n=>(n[n.DecimalDegrees=0]="DecimalDegrees",n[n.DegreesMinutesSeconds=1]="DegreesMinutesSeconds",n[n.Gradians=2]="Gradians",n[n.Radians=3]="Radians",n[n.SurveyorsUnits=4]="SurveyorsUnits",n))(St||{}),rt=(n=>(n[n.Scientific=1]="Scientific",n[n.Decimal=2]="Decimal",n[n.Engineering=3]="Engineering",n[n.Architectural=4]="Architectural",n[n.Fractional=5]="Fractional",n[n.WindowsDesktop=6]="WindowsDesktop",n))(rt||{}),J=(n=>(n[n.Undefined=0]="Undefined",n[n.Inches=1]="Inches",n[n.Feet=2]="Feet",n[n.Miles=3]="Miles",n[n.Millimeters=4]="Millimeters",n[n.Centimeters=5]="Centimeters",n[n.Meters=6]="Meters",n[n.Kilometers=7]="Kilometers",n[n.Microinches=8]="Microinches",n[n.Mils=9]="Mils",n[n.Yards=10]="Yards",n[n.Angstroms=11]="Angstroms",n[n.Nanometers=12]="Nanometers",n[n.Microns=13]="Microns",n[n.Decimeters=14]="Decimeters",n[n.Dekameters=15]="Dekameters",n[n.Hectometers=16]="Hectometers",n[n.Gigameters=17]="Gigameters",n[n.Astronomical=18]="Astronomical",n[n.LightYears=19]="LightYears",n[n.Parsecs=20]="Parsecs",n[n.USSurveyFeet=21]="USSurveyFeet",n[n.USSurveyInch=22]="USSurveyInch",n[n.USSurveyYard=23]="USSurveyYard",n[n.USSurveyMile=24]="USSurveyMile",n[n.Max=24]="Max",n))(J||{});function fp(n){return n==4||n==5||n==6||n==7||n==12||n==13||n==14||n==15||n==16||n==17}function pp(n){return n==1||n==2||n==3||n==8||n==9||n==10||n==21}const E={ACADVER:"ACADVER",ANGBASE:"ANGBASE",ANGDIR:"ANGDIR",AUNITS:"AUNITS",AUPREC:"AUPREC",CECOLOR:"CECOLOR",CELTSCALE:"CELTSCALE",CELTYPE:"CELTYPE",CELWEIGHT:"CELWEIGHT",CETRANSPARENCY:"CETRANSPARENCY",CLAYER:"CLAYER",CMLEADERSTYLE:"CMLEADERSTYLE",CMLSCALE:"CMLSCALE",CMLSTYLE:"CMLSTYLE",COLORTHEME:"COLORTHEME",DYNMODE:"DYNMODE",DYNPROMPT:"DYNPROMPT",DWGNAME:"DWGNAME",EXTMAX:"EXTMAX",EXTMIN:"EXTMIN",GRIPCOLOR:"GRIPCOLOR",GRIPHOT:"GRIPHOT",GRIPOBJLIMIT:"GRIPOBJLIMIT",GRIPS:"GRIPS",GRIPSIZE:"GRIPSIZE",HPANG:"HPANG",HPASSOC:"HPASSOC",HPBACKGROUNDCOLOR:"HPBACKGROUNDCOLOR",HPCOLOR:"HPCOLOR",HPDOUBLE:"HPDOUBLE",HPISLANDDETECTION:"HPISLANDDETECTION",HPLAYER:"HPLAYER",HPNAME:"HPNAME",HPSCALE:"HPSCALE",HPSEPARATE:"HPSEPARATE",HPTRANSPARENCY:"HPTRANSPARENCY",INSUNITS:"INSUNITS",LTSCALE:"LTSCALE",LUNITS:"LUNITS",LUPREC:"LUPREC",LWDISPLAY:"LWDISPLAY",MEASUREMENT:"MEASUREMENT",MEASUREMENTCOLOR:"MEASUREMENTCOLOR",MODELBKCOLOR:"MODELBKCOLOR",OSMODE:"OSMODE",ORTHOMODE:"ORTHOMODE",OPENPROF:"OPENPROF",PAPERBKCOLOR:"PAPERBKCOLOR",PDMODE:"PDMODE",PDSIZE:"PDSIZE",PICKBOX:"PICKBOX",POLARADDANG:"POLARADDANG",POLARMODE:"POLARMODE",POLARANG:"POLARANG",SHORTCUTMENU:"SHORTCUTMENU",TEXTSTYLE:"TEXTSTYLE",DIMSTYLE:"DIMSTYLE",UNITMODE:"UNITMODE"},mp=Object.freeze(Object.values(E)),mr=class mr{constructor(){this.registry=new Map,this.cache=new Map,this.events={sysVarChanged:new at},this.registerVar({name:E.ANGBASE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:E.ANGDIR,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:E.AUNITS,type:"number",isDbVar:!0,defaultValue:St.DecimalDegrees}),this.registerVar({name:E.AUPREC,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:E.CECOLOR,type:"color",isDbVar:!0,defaultValue:new X(exports.AcCmColorMethod.ByLayer)}),this.registerVar({name:E.CELTSCALE,type:"number",isDbVar:!0,defaultValue:-1}),this.registerVar({name:E.CELTYPE,type:"string",isDbVar:!0,defaultValue:lt}),this.registerVar({name:E.CELWEIGHT,type:"number",isDbVar:!0,defaultValue:exports.AcGiLineWeight.ByLayer}),this.registerVar({name:E.CETRANSPARENCY,type:"transparency",isDbVar:!0,defaultValue:new ot}),this.registerVar({name:E.CLAYER,type:"string",isDbVar:!0,defaultValue:"0"}),this.registerVar({name:E.CMLEADERSTYLE,type:"string",isDbVar:!0,defaultValue:he}),this.registerVar({name:E.CMLSCALE,type:"number",isDbVar:!0,defaultValue:1}),this.registerVar({name:E.CMLSTYLE,type:"string",isDbVar:!0,defaultValue:le}),this.registerVar({name:E.COLORTHEME,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:E.DYNMODE,type:"number",isDbVar:!1,defaultValue:3}),this.registerVar({name:E.DYNPROMPT,type:"boolean",isDbVar:!1,defaultValue:!0}),this.registerVar({name:E.DWGNAME,type:"string",isDbVar:!0,readOnly:!0,defaultValue:"Drawing1.dwg"}),this.registerVar({name:E.GRIPCOLOR,type:"number",isDbVar:!1,defaultValue:dl}),this.registerVar({name:E.GRIPHOT,type:"number",isDbVar:!1,defaultValue:gl}),this.registerVar({name:E.GRIPOBJLIMIT,type:"number",isDbVar:!1,defaultValue:100}),this.registerVar({name:E.GRIPS,type:"number",isDbVar:!1,defaultValue:2}),this.registerVar({name:E.GRIPSIZE,type:"number",isDbVar:!1,defaultValue:fl}),this.registerVar({name:E.HPANG,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:E.HPASSOC,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:E.HPBACKGROUNDCOLOR,type:"color",isDbVar:!0,defaultValue:new X(exports.AcCmColorMethod.None)}),this.registerVar({name:E.HPCOLOR,type:"color",isDbVar:!0,defaultValue:new X(exports.AcCmColorMethod.ByLayer)}),this.registerVar({name:E.HPDOUBLE,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:E.HPISLANDDETECTION,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:E.HPLAYER,type:"string",isDbVar:!0,defaultValue:"."}),this.registerVar({name:E.HPNAME,type:"string",isDbVar:!1,defaultValue:ll}),this.registerVar({name:E.HPSCALE,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:E.HPSEPARATE,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:E.HPTRANSPARENCY,type:"transparency",isDbVar:!0,defaultValue:new ot}),this.registerVar({name:E.INSUNITS,type:"number",isDbVar:!0,defaultValue:J.Millimeters}),this.registerVar({name:E.LUNITS,type:"number",isDbVar:!0,defaultValue:rt.Decimal}),this.registerVar({name:E.LUPREC,type:"number",isDbVar:!0,defaultValue:4}),this.registerVar({name:E.LWDISPLAY,type:"boolean",isDbVar:!0,defaultValue:!1}),this.registerVar({name:E.MEASUREMENT,type:"number",isDbVar:!0,defaultValue:1}),this.registerVar({name:E.MEASUREMENTCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new X(exports.AcCmColorMethod.ByColor);return t.setRGB(96,165,250),t})()}),this.registerVar({name:E.MODELBKCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new X(exports.AcCmColorMethod.ByColor);return t.setRGB(0,0,0),t})()}),this.registerVar({name:E.OSMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:E.ORTHOMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:E.OPENPROF,type:"boolean",isDbVar:!1,defaultValue:!1}),this.registerVar({name:E.PAPERBKCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new X(exports.AcCmColorMethod.ByColor);return t.setRGB(255,255,255),t})()}),this.registerVar({name:E.PICKBOX,type:"number",isDbVar:!1,defaultValue:10}),this.registerVar({name:E.POLARADDANG,type:"string",isDbVar:!1,defaultValue:""}),this.registerVar({name:E.POLARMODE,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:E.POLARANG,type:"number",isDbVar:!1,defaultValue:90}),this.registerVar({name:E.SHORTCUTMENU,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:E.TEXTSTYLE,type:"string",isDbVar:!0,defaultValue:Z}),this.registerVar({name:E.UNITMODE,type:"number",isDbVar:!0,defaultValue:0})}static instance(){return this._instance||(this._instance=new mr),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}applyVarMutation(t,e,i,r,s){const a=this.normalizeName(t);if(this.hasValueChanged(e,i)){if(r.transactionManager.isRecording())r.transactionManager.recordSysvar(a,e);else if(r.transactionManager.strictMode&&!r.transactionManager.isApplyingUndoRedo())throw new Error(`Cannot change system variable ${a} outside an active transaction.`);s(),!r.transactionManager.isApplyingUndoRedo()&&!r.transactionManager.isRecording()&&this.events.sysVarChanged.dispatch({database:r,name:a,newVal:i,oldVal:e})}}setVar(t,e,i){t=this.normalizeName(t);const r=this.getDescriptor(t);if(r){if(r.readOnly)throw new Error(`System variable ${t} is read-only!`);const s=this.getVar(t,i);if(r.type==="transparency"){const a=this.parseTransparency(e);if(a==null||a.isInvalid)throw new Error("Invalid transparency value!");e=a}else 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=this.parseColorSysVar(t,e,i);if(a==null)throw new Error("Invalid color value!");e=a}}if(t===E.GRIPCOLOR.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<xs||a>ws)throw new Error(`Invalid GRIPCOLOR value! Valid range is ${xs} to ${ws}.`);e=a}if(t===E.GRIPHOT.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<vs||a>ks)throw new Error(`Invalid GRIPHOT value! Valid range is ${vs} to ${ks}.`);e=a}if(t===E.GRIPOBJLIMIT.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<0||a>32767)throw new Error("Invalid GRIPOBJLIMIT value! Valid range is 0 to 32767.");e=a}if(t===E.GRIPS.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<0||a>2)throw new Error("Invalid GRIPS value! Valid range is 0 to 2.");e=a}if(t===E.GRIPSIZE.toLowerCase()){const a=Math.trunc(e);if(!Number.isFinite(a)||a<As||a>Ss)throw new Error(`Invalid GRIPSIZE value! Valid range is ${As} to ${Ss}.`);e=a}r.isDbVar?this.applyVarMutation(t,s,e,i,()=>{i[t.toLowerCase()]=e}):this.applyVarMutation(t,s,e,i,()=>{this.cache.set(t,e)})}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)}parseColorSysVar(t,e,i){const r=e.trim().toLowerCase();return t===E.HPCOLOR.toLowerCase()&&(r==="."||r==="use current")?i.cecolor.clone():t===E.HPBACKGROUNDCOLOR.toLowerCase()&&(r===""||r==="."||r==="none")?new X(exports.AcCmColorMethod.None):X.fromString(e)}parseTransparency(t){if(t instanceof ot)return t;if(typeof t=="number")return ot.deserialize(t);if(!(typeof t!="string"&&!(t instanceof String)))return ot.fromString(String(t))}hasValueChanged(t,e){return t instanceof X&&e instanceof X||t instanceof ot&&e instanceof ot?!t.equals(e):!Object.is(t,e)}normalizeName(t){return t.toLowerCase()}};mr._instance=null;let ft=mr;const jl="Load Database",Eo=3e4,yp=12e4,bp=1024*1024;class At extends ic{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=zs.getInstance().getEntry(jl),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 sa{constructor(t={}){this.config={useWorker:t.useWorker??!0,...t}}async read(t,e,i,r,s,a){const o={name:jl,data:{total:0},format(){let u="";return Object.keys(this.data).forEach(d=>{d!=="total"&&(u+=`- ${d}: ${this.data[d]} ms
10
+ `)}),u+=`- total: ${this.data.total} ms`,u}};zs.getInstance().collect(o),this.progress=r;const c={value:0},l=new nc;l.setCompleteCallback(()=>this.onFinished()),l.setErrorCallback(u=>this.onError(u)),l.addTask(new At({stage:"START",step:1,progress:c,task:async u=>u},r)),l.addTask(new At({stage:"PARSE",step:5,progress:c,task:async u=>await this.parse(u,s)},r)),l.addTask(new At({stage:"FONT",step:5,progress:c,task:async u=>{const d=this.getFonts(u.model);return{model:u.model,data:d}}},r)),l.addTask(new At({stage:"LTYPE",step:1,progress:c,task:async u=>(this.processLineTypes(u.model,e),u)},r)),l.addTask(new At({stage:"STYLE",step:1,progress:c,task:async u=>(this.processTextStyles(u.model,e),u)},r)),l.addTask(new At({stage:"DIMSTYLE",step:1,progress:c,task:async u=>(this.processDimStyles(u.model,e),u)},r)),l.addTask(new At({stage:"LAYER",step:1,progress:c,task:async u=>(this.processLayers(u.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),u)},r)),l.addTask(new At({stage:"VPORT",step:1,progress:c,task:async u=>(this.processViewports(u.model,e),u)},r)),l.addTask(new At({stage:"HEADER",step:1,progress:c,task:async u=>{if(this.processClasses(u.model,e),this.processHeader(u.model,e),a){const d=ft.instance();for(const[g,p]of Object.entries(a))d.setVar(g,p,e)}return u}},r)),l.addTask(new At({stage:"BLOCK_RECORD",step:5,progress:c,task:async u=>(this.processBlockTables(u.model,e),u)},r)),l.addTask(new At({stage:"OBJECT",step:5,progress:c,task:async u=>(this.processObjects(u.model,e),e.objects.layout.numEntries===0&&e.createDefaultData({layout:!0}),u)},r)),l.addTask(new At({stage:"BLOCK",step:5,progress:c,task:async u=>(await this.processBlocks(u.model,e),u)},r)),l.addTask(new At({stage:"ENTITY",step:100,progress:c,task:async u=>(await this.processEntities(u.model,e,i,c,r),u)},r)),l.addTask(new At({stage:"END",step:0,progress:c,task:async u=>u},r));const h=Date.now();await l.run(t),o.data.total=Date.now()-h}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"),Ie.instance.clear())}getParserWorkerTimeout(t,e){const i=e??this.config.timeout;if(i!=null)return i;const r=Math.ceil(t.byteLength/bp),s=Eo+r*1e3;return Math.min(yp,Math.max(Eo,s))}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!")}processClasses(t,e){}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,s){throw new Error("Not impelemented yet!")}}class Vl{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)}async scheduleTask(t){await ci(),await t()}async processChunk(t,e){if(this._count<=0){await(e==null?void 0:e());return}let i=0;const r=async()=>{const s=i,a=Math.min(i+this._chunkSize,this._count);await t(s,a),i=a,i<this._count&&await this.scheduleTask(r)};await r(),await(e==null?void 0:e())}}class Gl extends sa{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}getFonts(){return[]}async processEntities(t,e,i,r,s){let a=t.tables.blockTable.modelSpace.newIterator().toArray();const o=a.length,c=new Vl(o,100-r.value,i);this.config.convertByEntityType&&(a=this.groupAndFlattenByType(a));const l=e.tables.blockTable.modelSpace;await c.processChunk(async(h,u)=>{let d=[],g=h<u?a[h].type:"";for(let p=h;p<u;p++){const f=a[p];this.config.convertByEntityType&&f.type!==g&&(this.triggerEvents(l,d),d=[],g=f.type),d.push(f)}if(this.triggerEvents(l,d),s){let p=r.value+u/o*(100-r.value);p>100&&(p=100),await s(p,"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(){}processClasses(){}processBlockTables(){}processObjects(){const t=this._database.objects.layout.newIterator();for(const a of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.layoutName});const e=this._database.objects.imageDefinition.newIterator();for(const a of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.objectId});const i=this._database.objects.mleaderStyle.newIterator();for(const a of i)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.objectId});const r=this._database.objects.layerFilter.newIterator();for(const a of r)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.objectId});const s=this._database.objects.layerIndex.newIterator();for(const a of s)this._database.events.dictObjetSet.dispatch({database:this._database,object:a,key:a.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})}}const _p=/\\[fF](.*?)\|/g,xp=/\\[fF]([^|;]+);/g;class gt{constructor(t){this.styles=t.styles,this.styleMap=gt.buildStyleFontMap(this.styles),this.textStyleVar=t.textStyleVar??Z,this.includeAllNamedStyleFonts=t.includeAllNamedStyleFonts??!0}collect(t,e){const i=new Set;for(const r of gt.collectShapeDefinitionFonts(this.styles))i.add(r);if(this.includeAllNamedStyleFonts)for(const r of gt.collectNamedStyleTableFonts(this.styles))i.add(r);return this.collectFromEntities(t,e,i),Array.from(i)}static normalizeFontFileName(t){if(!t)return;const e=t.lastIndexOf(".");return e>=0?t.substring(0,e).toLowerCase():t.toLowerCase()}collectFromEntities(t,e,i){for(const r of gt.iterateEntities(t)){const s=e.getEntityFontInfo(r);if(s){if(s.formattedText)for(const a of gt.extractInlineMTextFonts(s.formattedText))i.add(a);if(s.resolveStyle&&this.addResolvedStyleFonts(s.styleName,i),s.blockName&&e.getBlockEntities){const a=e.getBlockEntities(s.blockName);a&&this.collectFromEntities(a,e,i)}}}}static iterateEntities(t){return t instanceof Map?t.values():t[Symbol.iterator]()}resolveStyleFontNames(t){const e=[],i=r=>{const s=r==null?void 0:r.trim();s&&!e.includes(s)&&e.push(s)};i(t),i(this.textStyleVar),i(Z),i("STANDARD");for(const r of e){const s=this.styleMap.get(r);if(s)return s;const a=r.toUpperCase();for(const[o,c]of this.styleMap)if(o.toUpperCase()===a)return c}return this.styleMap.values().next().value}addResolvedStyleFonts(t,e){const i=this.resolveStyleFontNames(t);i==null||i.forEach(r=>e.add(r))}static buildStyleFontMap(t){const e=new Map;for(const i of t)e.set(i.name,gt.collectStyleEntryFontNames(i));return e}static collectStyleEntryFontNames(t){const e=[];for(const i of[t.font,t.bigFont,t.extendedFont]){const r=gt.normalizeFontFileName(i);r&&e.push(r)}return e}static collectNamedStyleTableFonts(t){const e=[];for(const i of t)i.standardFlag&&i.standardFlag&1||e.push(...gt.collectStyleEntryFontNames(i));return e}static collectShapeDefinitionFonts(t){const e=[];for(const i of t)if(i.standardFlag&&i.standardFlag&1){const r=gt.normalizeFontFileName(i.font);r&&e.push(r)}return e}static extractInlineMTextFonts(t){const e=new Set;for(const i of t.matchAll(_p))e.add(i[1].toLowerCase());for(const i of t.matchAll(xp))e.add(i[1].toLowerCase());return Array.from(e)}static collectInlineMTextFonts(t){return gt.extractInlineMTextFonts(t)}}var Ul=(n=>(n[n.Center=0]="Center",n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.OverFirst=3]="OverFirst",n[n.OverSecond=4]="OverSecond",n))(Ul||{}),aa=(n=>(n[n.Center=0]="Center",n[n.Above=1]="Above",n[n.Outside=2]="Outside",n[n.JIS=3]="JIS",n[n.Below=4]="Below",n))(aa||{}),Hl=(n=>(n[n.Feet=0]="Feet",n[n.None=1]="None",n[n.Inch=2]="Inch",n[n.FeetAndInch=3]="FeetAndInch",n[n.Leading=4]="Leading",n[n.Trailing=8]="Trailing",n[n.LeadingAndTrailing=12]="LeadingAndTrailing",n))(Hl||{}),Wl=(n=>(n[n.None=0]="None",n[n.Leading=1]="Leading",n[n.Trailing=2]="Trailing",n[n.LeadingAndTrailing=3]="LeadingAndTrailing",n))(Wl||{}),$l=(n=>(n[n.Bottom=0]="Bottom",n[n.Middle=1]="Middle",n[n.Top=2]="Top",n))($l||{});const yr=class yr extends pe{constructor(t,e){t=t||{},Bt(t,yr.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)}dxfOut(...t){const[e,i=!1]=t;return e.writeHandle(105,this.objectId),e.writeObjectId(330,this.ownerId),e.writeObjectId(360,this.extensionDictionary),this.dxfOutFields(e),i&&this.dxfOutXData(e),this}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),s=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,s==null?void 0:s.objectId),t.writeObjectId(344,a==null?void 0:a.objectId),t.writeInt16(371,this.dimlwd),t.writeInt16(372,this.dimlwe),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbDimStyleTableRecord");const e=i=>i===0?0:1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const i=t.readItem();if(!i)break;const r=Number(i.code);if(r===100){t.pushBackItem(i);break}const s=Number(i.value);switch(r){case 2:this.name=String(i.value);break;case 70:break;case 3:this.dimpost=String(i.value);break;case 4:this.dimapost=String(i.value);break;case 5:this.dimblk=String(i.value);break;case 6:this.dimblk1=String(i.value);break;case 7:this.dimblk2=String(i.value);break;case 40:this.dimscale=s;break;case 41:this.dimasz=s;break;case 42:this.dimexo=s;break;case 43:this.dimdli=s;break;case 44:this.dimexe=s;break;case 45:this.dimrnd=s;break;case 46:this.dimdle=s;break;case 47:this.dimtp=s;break;case 48:this.dimtm=s;break;case 140:this.dimtxt=s;break;case 141:this.dimcen=s;break;case 142:this.dimtsz=s;break;case 143:this.dimaltf=s;break;case 144:this.dimlfac=s;break;case 145:this.dimtvp=s;break;case 146:this.dimtfac=s;break;case 147:this.dimgap=s;break;case 148:this.dimaltrnd=s;break;case 71:this.dimtol=e(s);break;case 72:this.dimlim=e(s);break;case 73:this.dimtih=e(s);break;case 74:this.dimtoh=e(s);break;case 75:this.dimse1=e(s);break;case 76:this.dimse2=e(s);break;case 77:this.dimtad=s;break;case 78:this.dimzin=s;break;case 79:this.dimazin=s;break;case 170:this.dimalt=e(s);break;case 171:this.dimaltd=s;break;case 172:this.dimtofl=e(s);break;case 173:this.dimsah=e(s);break;case 174:this.dimtix=e(s);break;case 175:this.dimsoxd=e(s);break;case 176:this.dimclrd=s;break;case 177:this.dimclre=s;break;case 178:this.dimclrt=s;break;case 179:this.dimadec=s;break;case 270:this.dimunit=s;break;case 271:this.dimdec=s;break;case 272:this.dimtdec=s;break;case 273:this.dimaltu=s;break;case 274:this.dimalttd=s;break;case 275:this.dimaunit=s;break;case 276:this.dimfrac=s;break;case 277:this.dimlunit=s;break;case 278:this.dimdsep=typeof i.value=="string"?i.value:String.fromCharCode(s||46);break;case 279:this.dimtmove=s;break;case 280:this.dimjust=s;break;case 281:this.dimsd1=e(s);break;case 282:this.dimsd2=e(s);break;case 283:this.dimtolj=s;break;case 284:this.dimtzin=s;break;case 285:this.dimaltz=s;break;case 286:this.dimalttz=s;break;case 287:this.dimfit=s;break;case 288:this.dimupt=e(s);break;case 289:this.dimatfit=s;break;case 340:this.dimtxsty=String(i.value);break;case 341:this.dimldrblk=String(i.value);break;case 342:this.dimblk=String(i.value);break;case 343:this.dimblk1=String(i.value);break;case 344:this.dimblk2=String(i.value);break;case 371:this.dimlwd=s;break;case 372:this.dimlwe=s;break}}return this}};yr.DEFAULT_DIM_VALUES={name:"",dimpost:"",dimapost:"",dimscale:1,dimasz:2.5,dimexo:.625,dimdli:.38,dimexe:.18,dimrnd:0,dimdle:0,dimtp:0,dimtm:0,dimtxt:2.5,dimcen:2.5,dimtsz:0,dimaltf:0,dimlfac:1,dimtvp:0,dimtfac:1,dimgap:1,dimaltrnd:0,dimtol:0,dimlim:0,dimtih:0,dimtoh:0,dimse1:0,dimse2:0,dimtad:0,dimzin:0,dimazin:0,dimalt:0,dimaltd:2,dimtofl:0,dimsah:0,dimtix:0,dimsoxd:0,dimclrd:0,dimclre:0,dimclrt:0,dimadec:0,dimunit:2,dimdec:4,dimtdec:4,dimaltu:2,dimalttd:2,dimaunit:0,dimfrac:0,dimlunit:2,dimdsep:".",dimtmove:0,dimjust:0,dimsd1:0,dimsd2:0,dimtolj:0,dimtzin:0,dimaltz:0,dimalttz:0,dimfit:0,dimupt:0,dimatfit:3,dimtxsty:Z,dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let Tt=yr;function ql(){return{color:new X,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:new ot,linetype:"",lineWeight:1,materialId:-1}}const wp=["name",...Object.keys(ql())];class nn extends pe{constructor(t,e){t=t||{},Bt(t,ql()),super(t,e)}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.writeLineWeight(370,this.lineWeight),t.writeTransparency(this.transparency),this.description&&t.writeString(4,this.description),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbLayerTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}switch(i){case 2:this.name=String(e.value);break;case 70:this.standardFlags=Number(e.value);break;case 62:{const r=Number(e.value);this.isOff=r<0,this.color.colorIndex=Math.abs(r);break}case 420:this.color.setRGBValue(Number(e.value));break;case 6:this.linetype=String(e.value);break;case 290:this.isPlottable=Number(e.value)!==0;break;case 370:this.lineWeight=Number(e.value);break;case 440:this.transparency=ot.deserialize(Number(e.value));break;case 4:this.description=String(e.value);break}}return this}}class Ae extends pe{constructor(t,e){t=t||{},Bt(t,{standardFlag:0,description:"",totalPatternLength:0}),super(t,e)}get numDashes(){const t=this.getAttrWithoutException("pattern");return t?t.length:0}get patternLength(){return this.getAttr("totalPatternLength")}get comments(){return this.getAttr("description")}get linetype(){return{name:this.name,standardFlag:this.getAttr("standardFlag"),description:this.getAttr("description"),totalPatternLength:this.getAttr("totalPatternLength"),pattern:this.getAttrWithoutException("pattern")}}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.getAttr("pattern")[t].elementLength}toPreviewSvgString(t){const e=Math.max((t==null?void 0:t.width)??220,1),i=Math.max((t==null?void 0:t.height)??36,1),r=Math.min(Math.max((t==null?void 0:t.padding)??8,0),Math.floor(e/2)),s=Math.max((t==null?void 0:t.strokeWidth)??2,.5),a=this.escapeSvgAttribute((t==null?void 0:t.stroke)??"currentColor"),o=Math.max((t==null?void 0:t.repeats)??4,1),c=i/2,l=r,h=Math.max(e-r,l+1),u=h-l,d=this.getAttrWithoutException("pattern")??[];if(d.length===0||this.patternLength<=0||!d.some(v=>v.elementLength!==0))return this.buildSvgString({width:e,height:i,stroke:a,strokeWidth:s,lineSegments:[[l,h]],dots:[],y:c});const g=[],p=[],f=u/(this.patternLength*o),m=.5,y=Math.max(s*2,2);let _=l;for(;_<h;)for(const v of d){if(_>=h)break;const x=v.elementLength;if(x===0){p.push(_),_=Math.min(_+y,h);continue}const k=Math.max(Math.abs(x)*f,m),I=Math.min(_+k,h);x>0&&I>_&&g.push([_,I]),_=I}return this.buildSvgString({width:e,height:i,stroke:a,strokeWidth:s,lineSegments:g,dots:p,y:c})}buildSvgString(t){const{width:e,height:i,stroke:r,strokeWidth:s,lineSegments:a,dots:o,y:c}=t,l=a.map(([u,d])=>`<line x1="${u.toFixed(2)}" y1="${c.toFixed(2)}" x2="${d.toFixed(2)}" y2="${c.toFixed(2)}" stroke="${r}" stroke-width="${s.toFixed(2)}" stroke-linecap="round" />`).join(""),h=o.map(u=>`<circle cx="${u.toFixed(2)}" cy="${c.toFixed(2)}" r="${(s/2).toFixed(2)}" fill="${r}" />`).join("");return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${i}" viewBox="0 0 ${e} ${i}" role="img" aria-label="${this.escapeSvgAttribute(this.name)} linetype preview">${l}${h}</svg>`}escapeSvgAttribute(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;")}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLinetypeTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.getAttr("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.getAttrWithoutException("pattern")??[])t.writeDouble(49,e.elementLength),t.writeInt16(74,e.elementTypeFlag);return this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbLinetypeTableRecord");const e=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const i=t.readItem();if(!i)break;const r=Number(i.code);if(r===100){t.pushBackItem(i);break}switch(r){case 2:this.name=String(i.value);break;case 70:this.setAttr("standardFlag",Number(i.value));break;case 3:this.setAttr("description",String(i.value));break;case 72:break;case 73:break;case 40:this.setAttr("totalPatternLength",Number(i.value));break;case 49:e.push({elementLength:Number(i.value),elementTypeFlag:0});break;case 74:e.length>0&&(e[e.length-1].elementTypeFlag=Number(i.value));break}}return this.setAttr("pattern",e),this}}class Xn extends pe{constructor(t){typeof t=="string"&&(t={name:t}),super(t)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRegAppTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbRegAppTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}switch(i){case 2:this.name=String(e.value);break}}return this}}class Ir extends pe{constructor(t,e){t=t||{},Bt(t,{standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:0,font:"",bigFont:""}),super(t,e),this.setAttr("font",this.getFileNameWithoutExtension(this.getAttr("font")||this.getAttrWithoutException("extendedFont")||this.name))}get obliquingAngle(){return this.getAttr("obliqueAngle")}set obliquingAngle(t){this.setAttr("obliqueAngle",t)}get priorSize(){return this.getAttr("lastHeight")}set priorSize(t){this.setAttr("lastHeight",t)}get textSize(){return this.getAttr("fixedTextHeight")}set textSize(t){this.setAttr("fixedTextHeight",t)}get xScale(){return this.getAttr("widthFactor")}set xScale(t){this.setAttr("widthFactor",t)}get isVertical(){return(this.getAttr("standardFlag")&4)===4}set isVertical(t){const e=this.getAttr("standardFlag");this.setAttr("standardFlag",t?e|4:e&-5)}get isShapeFile(){return(this.getAttr("standardFlag")&1)===1}set isShapeFile(t){const e=this.getAttr("standardFlag");this.setAttr("standardFlag",t?e|1:e&-2)}get fileName(){return this.getAttr("font")}set fileName(t){this.setAttr("font",t)}get bigFontFileName(){return this.getAttr("bigFont")}set bigFontFileName(t){this.setAttr("bigFont",t)}get textStyle(){return{name:this.name,standardFlag:this.getAttr("standardFlag"),fixedTextHeight:this.getAttr("fixedTextHeight"),widthFactor:this.getAttr("widthFactor"),obliqueAngle:this.getAttr("obliqueAngle"),textGenerationFlag:this.getAttr("textGenerationFlag"),lastHeight:this.getAttr("lastHeight"),font:this.getAttr("font"),bigFont:this.getAttr("bigFont"),extendedFont:this.getAttrWithoutException("extendedFont")}}getFileNameWithoutExtension(t){const e=t.split("/").pop();if(e){const i=e.lastIndexOf(".");return i===-1?e:e.substring(0,i)}return t}get dxfFontFileName(){var e;const t=((e=this.fileName)==null?void 0:e.trim())??"";return!t||!this.isShapeFile||/\.[^./\\]+$/i.test(t)?t:`${t}.shx`}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbTextStyleTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.getAttr("standardFlag")),t.writeDouble(40,this.textSize),t.writeDouble(41,this.xScale),t.writeAngle(50,this.obliquingAngle),t.writeInt16(71,this.getAttr("textGenerationFlag")),t.writeDouble(42,this.priorSize),t.writeString(3,this.dxfFontFileName),t.writeString(4,this.bigFontFileName),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbTextStyleTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}switch(i){case 2:this.name=String(e.value);break;case 70:this.setAttr("standardFlag",Number(e.value));break;case 40:this.textSize=Number(e.value);break;case 41:this.xScale=Number(e.value);break;case 50:this.obliquingAngle=Number(e.value);break;case 71:this.setAttr("textGenerationFlag",Number(e.value));break;case 42:this.priorSize=Number(e.value);break;case 3:this.fileName=this.getFileNameWithoutExtension(String(e.value));break;case 4:this.bigFontFileName=String(e.value);break}}return this}dxfInXData(t){super.dxfInXData(t),this.applyExtendedFontFromXData()}applyExtendedFontFromXData(){const t=this.getXData("ACAD");if(t){for(const i of t)if(Number(i.code)===1e3&&i.value!=null){const r=String(i.value).trim();if(r){this.setAttr("extendedFont",r);break}}}if(!(this.getAttr("font")??"").trim()){const i=this.getAttrWithoutException("extendedFont")||this.name||"";i&&(this.fileName=this.getFileNameWithoutExtension(i))}}}class Kl extends pe{constructor(t,e){t=t||{},Bt(t,{standardFlags:0,origin:new b(0,0,0),xAxis:new b(1,0,0),yAxis:new b(0,1,0),isOrthographic:!1,elevation:0}),super(t,e)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get origin(){return this.getAttr("origin")}set origin(t){this.setAttr("origin",t.clone())}get xAxis(){return this.getAttr("xAxis")}set xAxis(t){this.setAttr("xAxis",t.clone())}get yAxis(){return this.getAttr("yAxis")}set yAxis(t){this.setAttr("yAxis",t.clone())}get isOrthographic(){return this.getAttr("isOrthographic")}set isOrthographic(t){this.setAttr("isOrthographic",t)}get elevation(){return this.getAttr("elevation")}set elevation(t){this.setAttr("elevation",t)}get baseUcsId(){return this.getAttrWithoutException("baseUcsId")}set baseUcsId(t){this.setAttr("baseUcsId",t)}get orthographicType(){return this.getAttrWithoutException("orthographicType")}set orthographicType(t){this.setAttr("orthographicType",t)}get orthographicOrigin(){return this.getAttrWithoutException("orthographicOrigin")}set orthographicOrigin(t){this.setAttr("orthographicOrigin",t==null?void 0:t.clone())}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbUCSTableRecord"),t.writeString(2,this.name),t.writeInt16(70,this.standardFlags),t.writePoint3d(10,this.origin),t.writePoint3d(11,this.xAxis),t.writePoint3d(12,this.yAxis),t.writeDouble(146,this.elevation),t.writeInt16(79,this.isOrthographic?1:0),this.isOrthographic&&t.writeObjectId(346,this.baseUcsId),this.orthographicType!=null&&this.orthographicOrigin&&(t.writeInt16(71,this.orthographicType),t.writePoint3d(13,this.orthographicOrigin)),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbUCSTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}const r=Number(e.value);switch(i){case 2:this.name=String(e.value);break;case 70:this.standardFlags=r;break;case 10:this.origin.x=r;break;case 20:this.origin.y=r;break;case 30:this.origin.z=r;break;case 11:this.xAxis.x=r;break;case 21:this.xAxis.y=r;break;case 31:this.xAxis.z=r;break;case 12:this.yAxis.x=r;break;case 22:this.yAxis.y=r;break;case 32:this.yAxis.z=r;break;case 79:this.isOrthographic=r!==0;break;case 146:this.elevation=r;break;case 346:this.baseUcsId=String(e.value);break;case 71:this.orthographicType=r;break;case 13:this.orthographicOrigin=this.orthographicOrigin??new b,this.orthographicOrigin.x=r;break;case 23:this.orthographicOrigin&&(this.orthographicOrigin.y=r);break;case 33:this.orthographicOrigin&&(this.orthographicOrigin.z=r);break}}return this}}const vp=()=>({center:new L,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:exports.AcGiRenderMode.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:exports.AcGiOrthographicType.TOP,shadePlotSetting:0,shadePlotObjectId:void 0,visualStyleObjectId:void 0,isDefaultLightingOn:!1,defaultLightingType:exports.AcGiDefaultLightingType.ONE_DISTANT_LIGHT,brightness:0,contrast:0,ambientColor:void 0,aspectRatio:void 0});class oa extends pe{constructor(t,e){t=t||{},Bt(t,{gsView:vp()}),super(t,e)}get gsView(){return this.getAttr("gsView")}get centerPoint(){return this.gsView.center}set centerPoint(t){this.gsView.center.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}get aspectRatio(){return this.gsView.aspectRatio}set aspectRatio(t){this.gsView.aspectRatio=t}}const Lo=2,kp=.45,Ap=1e5;function Sp(n){var i;const t=n,e=t.aspectRatio??((i=t.gsView)==null?void 0:i.aspectRatio);return Number.isFinite(e)?e:void 0}function Pp(n,t){if(Number.isFinite(t)&&t>0)return t;const e=Sp(n);return e!=null&&e>0?e:1}function Ip(n,t){const e=Math.max(n.min.x,t.min.x),i=Math.max(n.min.y,t.min.y),r=Math.min(n.max.x,t.max.x),s=Math.min(n.max.y,t.max.y);return e>=r||i>=s?0:(r-e)*(s-i)}function To(n){return{x:(n.min.x+n.max.x)/2,y:(n.min.y+n.max.y)/2}}function Ep(n){if(!n||n.isEmpty())return!1;const t=n.max.x-n.min.x,e=n.max.y-n.min.y;return t>0&&e>0}class Se extends oa{static isActiveVportName(t){return t.toLowerCase()===ii.toLowerCase()}constructor(t,e){t=t||{},Bt(t,{circleSides:100,lowerLeftCorner:new L(0,0),upperRightCorner:new L(1,1),snapBase:new L(0,0),snapAngle:0,snapSpacing:new L(0,0),standardFlag:0,gridSpacing:new L,gridMajor:10,ucsElevation:0}),super(t,e)}get circleSides(){return this.getAttr("circleSides")}set circleSides(t){this.setAttr("circleSides",t)}get center(){return this.centerPoint}set center(t){this.centerPoint=t}get lowerLeftCorner(){return this.getAttr("lowerLeftCorner")}set lowerLeftCorner(t){this.getAttr("lowerLeftCorner").copy(t)}get upperRightCorner(){return this.getAttr("upperRightCorner")}set upperRightCorner(t){this.getAttr("upperRightCorner").copy(t)}get snapBase(){return this.getAttr("snapBase")}set snapBase(t){this.getAttr("snapBase").copy(t)}get snapAngle(){return this.getAttr("snapAngle")}set snapAngle(t){this.setAttr("snapAngle",t)}get snapIncrements(){return this.getAttr("snapSpacing")}set snapIncrements(t){this.getAttr("snapSpacing").copy(t)}get gridMajor(){return this.getAttr("gridMajor")}set gridMajor(t){this.setAttr("gridMajor",t)}get gridIncrements(){return this.getAttr("gridSpacing")}set gridIncrements(t){this.getAttr("gridSpacing").copy(t)}get standardFlag(){return this.getAttr("standardFlag")}set standardFlag(t){this.setAttr("standardFlag",t)}get snapEnabled(){return!!(this.standardFlag&256)}get backgroundObjectId(){return this.getAttrWithoutException("backgroundObjectId")}set backgroundObjectId(t){this.setAttr("backgroundObjectId",t)}get ucsElevation(){return this.getAttr("ucsElevation")}set ucsElevation(t){this.setAttr("ucsElevation",t)}modelViewBox(t){const e=this.centerPoint,i=this.viewHeight;if(!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(i)||i<=0)return;const r=this.viewTwistAngle;let s=e.x,a=e.y;if(Number.isFinite(r)&&r!==0){const d=Math.cos(r),g=Math.sin(r);s=e.x*d-e.y*g,a=e.x*g+e.y*d}const o=this.viewTarget;o&&Number.isFinite(o.x)&&Number.isFinite(o.y)&&(s+=o.x,a+=o.y);const c=Pp(this,t),l=i*c,h=i/2,u=l/2;return new yt().expandByPoint({x:s-u,y:a-h}).expandByPoint({x:s+u,y:a+h})}static isModelViewBoxUsable(t,e){if(t.isEmpty()||e.isEmpty())return!1;const i=t.max.x-t.min.x,r=t.max.y-t.min.y,s=e.max.x-e.min.x,a=e.max.y-e.min.y;if(i<=0||r<=0||s<=0||a<=0||i>s*Lo||r>a*Lo)return!1;const o=Math.max(s,a)*kp,c=To(t),l=To(e);if(Math.hypot(c.x-l.x,c.y-l.y)>o)return!1;const u=i*r,d=Ip(t,e);return!(d<=0||d/u<.25)}resolveModelViewBox(t,e){const i=this.modelViewBox(t);if(!(!i||!Se.isModelViewBoxStructurallyValid(i))){if(Ep(e)){if(!Se.isModelViewBoxUsable(i,e))return}else if(!Se.isModelViewBoxPlausibleWithoutExtents(i))return;return i}}static isModelViewBoxStructurallyValid(t){if(t.isEmpty())return!1;const e=t.max.x-t.min.x,i=t.max.y-t.min.y;return Number.isFinite(e)&&Number.isFinite(i)&&e>0&&i>0}static isModelViewBoxPlausibleWithoutExtents(t){const e=t.max.x-t.min.x,i=t.max.y-t.min.y;return Math.max(e,i)<=Ap}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbViewportTableRecord"),t.writeString(2,this.name),t.writeDouble(40,this.gsView.viewHeight),this.gsView.aspectRatio!=null&&Number.isFinite(this.gsView.aspectRatio)&&t.writeDouble(41,this.gsView.aspectRatio),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.writeDouble(146,this.ucsElevation),t.writeInt16(170,this.shadePlotSetting),t.writeInt16(282,this.defaultLightingType),t.writeInt16(292,this.isDefaultLightingOn?1:0),t.writeInt16(281,this.backgroundObjectId?1:0),t.writeObjectId(332,this.backgroundObjectId),t.writeObjectId(333,this.shadePlotObjectId),t.writeObjectId(348,this.gsView.visualStyleObjectId),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbAbstractViewTableRecord"),t.atSubclassData("AcDbViewportTableRecord");const e=[...this.gsView.frozenLayers??[]];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const i=t.readItem();if(!i)break;const r=Number(i.code);if(r===100){t.pushBackItem(i);break}const s=Number(i.value);switch(r){case 2:this.name=String(i.value);break;case 1:this.gsView.styleSheet=String(i.value);break;case 10:this.lowerLeftCorner.x=s;break;case 20:this.lowerLeftCorner.y=s;break;case 11:this.upperRightCorner.x=s;break;case 21:this.upperRightCorner.y=s;break;case 12:this.center.x=s,this.gsView.center.x=s;break;case 22:this.center.y=s,this.gsView.center.y=s;break;case 13:this.snapBase.x=s;break;case 23:this.snapBase.y=s;break;case 14:this.snapIncrements.x=s;break;case 24:this.snapIncrements.y=s;break;case 15:this.gridIncrements.x=s;break;case 25:this.gridIncrements.y=s;break;case 16:this.gsView.viewDirectionFromTarget.x=s;break;case 26:this.gsView.viewDirectionFromTarget.y=s;break;case 36:this.gsView.viewDirectionFromTarget.z=s;break;case 17:this.gsView.viewTarget.x=s;break;case 27:this.gsView.viewTarget.y=s;break;case 37:this.gsView.viewTarget.z=s;break;case 40:case 45:this.gsView.viewHeight=s;break;case 41:Number.isFinite(s)&&s>0&&(this.gsView.aspectRatio=s);break;case 42:this.gsView.lensLength=s;break;case 43:this.gsView.frontClippingPlane=s;break;case 44:this.gsView.backClippingPlane=s;break;case 50:this.snapAngle=s;break;case 51:this.gsView.viewTwistAngle=s;break;case 61:this.gridMajor=s;break;case 70:this.standardFlag=s;break;case 71:s>=1&&s<=2e4&&(this.circleSides=s),this.gsView.viewMode=s;break;case 72:this.circleSides=s;break;case 74:this.gsView.ucsIconSetting=s;break;case 110:this.gsView.ucsOrigin.x=s;break;case 120:this.gsView.ucsOrigin.y=s;break;case 130:this.gsView.ucsOrigin.z=s;break;case 111:this.gsView.ucsXAxis.x=s;break;case 121:this.gsView.ucsXAxis.y=s;break;case 131:this.gsView.ucsXAxis.z=s;break;case 112:this.gsView.ucsYAxis.x=s;break;case 122:this.gsView.ucsYAxis.y=s;break;case 132:this.gsView.ucsYAxis.z=s;break;case 79:this.gsView.orthographicType=s;break;case 281:this.gsView.renderMode=s;break;case 331:case 441:e.push(String(i.value));break;case 332:this.backgroundObjectId=String(i.value);break;case 146:this.ucsElevation=s;break;case 170:this.shadePlotSetting=s;break;case 282:this.defaultLightingType=s;break;case 292:this.isDefaultLightingOn=s!==0;break;case 333:this.shadePlotObjectId=String(i.value);break;case 348:this.gsView.visualStyleObjectId=String(i.value);break}}return this.gsView.frozenLayers=e,this}}class Zl extends oa{constructor(t,e){t=t||{};const i=t.viewWidth!==void 0;Bt(t,{standardFlags:0,ucsAssociated:!1,cameraPlottable:!1,ucsElevation:0}),super(t,e),i||(this.viewWidth=this.viewHeight)}get standardFlags(){return this.getAttr("standardFlags")}set standardFlags(t){this.setAttr("standardFlags",t)}get viewWidth(){return this.getAttr("viewWidth")}set viewWidth(t){this.setAttr("viewWidth",t)}get ucsAssociated(){return this.getAttr("ucsAssociated")}set ucsAssociated(t){this.setAttr("ucsAssociated",t)}get cameraPlottable(){return this.getAttr("cameraPlottable")}set cameraPlottable(t){this.setAttr("cameraPlottable",t)}get ucsElevation(){return this.getAttr("ucsElevation")}set ucsElevation(t){this.setAttr("ucsElevation",t)}get ucsObjectId(){return this.getAttrWithoutException("ucsObjectId")}set ucsObjectId(t){this.setAttr("ucsObjectId",t)}get ucsBaseObjectId(){return this.getAttrWithoutException("ucsBaseObjectId")}set ucsBaseObjectId(t){this.setAttr("ucsBaseObjectId",t)}get backgroundObjectId(){return this.getAttrWithoutException("backgroundObjectId")}set backgroundObjectId(t){this.setAttr("backgroundObjectId",t)}get liveSectionObjectId(){return this.getAttrWithoutException("liveSectionObjectId")}set liveSectionObjectId(t){this.setAttr("liveSectionObjectId",t)}get sunObjectId(){return this.getAttrWithoutException("sunObjectId")}set sunObjectId(t){this.setAttr("sunObjectId",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),t.writeObjectId(361,this.sunObjectId),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}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSymbolTableRecord"),t.atSubclassData("AcDbAbstractViewTableRecord"),t.atSubclassData("AcDbViewTableRecord");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}const r=Number(e.value);switch(i){case 2:this.name=String(e.value);break;case 70:this.standardFlags=r;break;case 40:this.gsView.viewHeight=r;break;case 10:this.centerPoint.x=r;break;case 20:this.centerPoint.y=r;break;case 41:this.viewWidth=r;break;case 11:this.gsView.viewDirectionFromTarget.x=r;break;case 21:this.gsView.viewDirectionFromTarget.y=r;break;case 31:this.gsView.viewDirectionFromTarget.z=r;break;case 12:this.gsView.viewTarget.x=r;break;case 22:this.gsView.viewTarget.y=r;break;case 32:this.gsView.viewTarget.z=r;break;case 42:this.gsView.lensLength=r;break;case 43:this.gsView.frontClippingPlane=r;break;case 44:this.gsView.backClippingPlane=r;break;case 50:this.gsView.viewTwistAngle=r*Math.PI/180;break;case 71:this.gsView.viewMode=r;break;case 281:this.gsView.renderMode=r;break;case 72:this.ucsAssociated=r!==0;break;case 73:this.cameraPlottable=r!==0;break;case 332:this.backgroundObjectId=String(e.value);break;case 334:this.liveSectionObjectId=String(e.value);break;case 348:this.gsView.visualStyleObjectId=String(e.value);break;case 361:this.sunObjectId=String(e.value);break;case 110:this.gsView.ucsOrigin.x=r;break;case 120:this.gsView.ucsOrigin.y=r;break;case 130:this.gsView.ucsOrigin.z=r;break;case 111:this.gsView.ucsXAxis.x=r;break;case 121:this.gsView.ucsXAxis.y=r;break;case 131:this.gsView.ucsXAxis.z=r;break;case 112:this.gsView.ucsYAxis.x=r;break;case 122:this.gsView.ucsYAxis.y=r;break;case 132:this.gsView.ucsYAxis.z=r;break;case 79:this.gsView.orthographicType=r;break;case 146:this.ucsElevation=r;break;case 345:this.ucsObjectId=String(e.value);break;case 346:this.ucsBaseObjectId=String(e.value);break}}return this}}const Er=192,Bi=193,Lr=194,Tr=195,Ql=200;function Zr(n){if(n.isByBlock)return Bi<<24>>0;if(n.isByLayer)return Er<<24>>0;const t=n.colorIndex;if(t!=null&&t>0&&t<256)return(Tr<<24|t&255)>>0;const e=n.RGB;return e!=null?(Lr<<24|e&16777215)>>0:Bi<<24>>0}function Qt(n){const t=new X(exports.AcCmColorMethod.ByBlock);switch(n>>>24&255){case Er:t.setByLayer();break;case Bi:case Ql:t.setByBlock();break;case Tr:t.colorIndex=n&255;break;case Lr:t.setRGBValue(n&16777215);break;default:n===256?t.setByLayer():n===0?t.setByBlock():n>0&&n<256&&(t.colorIndex=n);break}return t}class Cr extends bt{constructor(){super(),this._contentType=2,this._drawMLeaderOrderType=1,this._drawLeaderOrderType=0,this._bitFlags=0,this._maxLeaderSegmentsPoints=-1,this._firstSegmentAngleConstraint=0,this._secondSegmentAngleConstraint=0,this._leaderLineType=1,this._leaderLineColor=new X(exports.AcCmColorMethod.ByLayer),this._leaderLineWeight=-2,this._enableLanding=!0,this._landingGap=2,this._enableDogleg=!0,this._doglegLength=8,this._description="",this._arrowSize=4,this._defaultMTextContents="",this._textLeftAttachmentType=1,this._textAngleType=1,this._textAlignmentType=0,this._textRightAttachmentType=1,this._textColor=new X(exports.AcCmColorMethod.ByLayer),this._textHeight=4,this._enableFrameText=!1,this._textAlignAlwaysLeft=!1,this._alignSpace=0,this._blockColor=new X(exports.AcCmColorMethod.ByBlock),this._blockScale=new w(1,1,1),this._enableBlockScale=!0,this._blockRotation=0,this._enableBlockRotation=!1,this._blockConnectionType=0,this._scale=1,this._overwritePropChanged=!1,this._annotative=!1,this._breakSize=0,this._textAttachmentDirection=0,this._bottomTextAttachmentType=9,this._topTextAttachmentType=9,this._extendLeaderToText=!1}get unknown1(){return this._unknown1}set unknown1(t){this._unknown1=t}get contentType(){return this._contentType}set contentType(t){this._contentType=t}get drawMLeaderOrderType(){return this._drawMLeaderOrderType}set drawMLeaderOrderType(t){this._drawMLeaderOrderType=t}get drawLeaderOrderType(){return this._drawLeaderOrderType}set drawLeaderOrderType(t){this._drawLeaderOrderType=t}get bitFlags(){return this._bitFlags}set bitFlags(t){this._bitFlags=t}get maxLeaderSegmentsPoints(){return this._maxLeaderSegmentsPoints}set maxLeaderSegmentsPoints(t){this._maxLeaderSegmentsPoints=t}get maxLeaderSegmentPoints(){return this.maxLeaderSegmentsPoints}set maxLeaderSegmentPoints(t){this.maxLeaderSegmentsPoints=t}get firstSegmentAngleConstraint(){return this._firstSegmentAngleConstraint}set firstSegmentAngleConstraint(t){this._firstSegmentAngleConstraint=t}get secondSegmentAngleConstraint(){return this._secondSegmentAngleConstraint}set secondSegmentAngleConstraint(t){this._secondSegmentAngleConstraint=t}get leaderLineType(){return this._leaderLineType}set leaderLineType(t){this._leaderLineType=t}get leaderLineColor(){return this._leaderLineColor}set leaderLineColor(t){this._leaderLineColor.copy(t)}get leaderLineTypeId(){return this._leaderLineTypeId}set leaderLineTypeId(t){this._leaderLineTypeId=t}get leaderLineWeight(){return this._leaderLineWeight}set leaderLineWeight(t){this._leaderLineWeight=t}get enableLanding(){return this._enableLanding}set enableLanding(t){this._enableLanding=t}get landingEnabled(){return this.enableLanding}set landingEnabled(t){this.enableLanding=t}get landingGap(){return this._landingGap}set landingGap(t){this._landingGap=t}get enableDogleg(){return this._enableDogleg}set enableDogleg(t){this._enableDogleg=t}get doglegEnabled(){return this.enableDogleg}set doglegEnabled(t){this.enableDogleg=t}get doglegLength(){return this._doglegLength}set doglegLength(t){this._doglegLength=t}get description(){return this._description}set description(t){this._description=t}get arrowSymbolId(){return this._arrowSymbolId}set arrowSymbolId(t){this._arrowSymbolId=t}get arrowheadId(){return this.arrowSymbolId}set arrowheadId(t){this.arrowSymbolId=t}get arrowSize(){return this._arrowSize}set arrowSize(t){this._arrowSize=t}get arrowheadSize(){return this.arrowSize}set arrowheadSize(t){this.arrowSize=t}get defaultMTextContents(){return this._defaultMTextContents}set defaultMTextContents(t){this._defaultMTextContents=t}get defaultMText(){return this.defaultMTextContents}set defaultMText(t){this.defaultMTextContents=t}get textString(){return this.defaultMTextContents}set textString(t){this.defaultMTextContents=t}get textStyleId(){return this._textStyleId}set textStyleId(t){this._textStyleId=t}get textStyle(){return this.textStyleId}set textStyle(t){this.textStyleId=t}get textLeftAttachmentType(){return this._textLeftAttachmentType}set textLeftAttachmentType(t){this._textLeftAttachmentType=t}get textAngleType(){return this._textAngleType}set textAngleType(t){this._textAngleType=t}get textAlignmentType(){return this._textAlignmentType}set textAlignmentType(t){this._textAlignmentType=t}get textRightAttachmentType(){return this._textRightAttachmentType}set textRightAttachmentType(t){this._textRightAttachmentType=t}get textColor(){return this._textColor}set textColor(t){this._textColor.copy(t)}get textHeight(){return this._textHeight}set textHeight(t){this._textHeight=t}get enableFrameText(){return this._enableFrameText}set enableFrameText(t){this._enableFrameText=t}get textFrameEnabled(){return this.enableFrameText}set textFrameEnabled(t){this.enableFrameText=t}get textAlignAlwaysLeft(){return this._textAlignAlwaysLeft}set textAlignAlwaysLeft(t){this._textAlignAlwaysLeft=t}get alignSpace(){return this._alignSpace}set alignSpace(t){this._alignSpace=t}get blockId(){return this._blockId}set blockId(t){this._blockId=t}get blockContentId(){return this.blockId}set blockContentId(t){this.blockId=t}get blockColor(){return this._blockColor}set blockColor(t){this._blockColor.copy(t)}get blockContentColor(){return this.blockColor}set blockContentColor(t){this.blockColor=t}get blockScale(){return this._blockScale.clone()}set blockScale(t){this._blockScale.copy(t)}get blockContentScale(){return this.blockScale}set blockContentScale(t){this.blockScale=t}get enableBlockScale(){return this._enableBlockScale}set enableBlockScale(t){this._enableBlockScale=t}get blockContentScaleEnabled(){return this.enableBlockScale}set blockContentScaleEnabled(t){this.enableBlockScale=t}get blockRotation(){return this._blockRotation}set blockRotation(t){this._blockRotation=t}get blockContentRotation(){return this.blockRotation}set blockContentRotation(t){this.blockRotation=t}get enableBlockRotation(){return this._enableBlockRotation}set enableBlockRotation(t){this._enableBlockRotation=t}get blockContentRotationEnabled(){return this.enableBlockRotation}set blockContentRotationEnabled(t){this.enableBlockRotation=t}get blockConnectionType(){return this._blockConnectionType}set blockConnectionType(t){this._blockConnectionType=t}get blockContentConnectionType(){return this.blockConnectionType}set blockContentConnectionType(t){this.blockConnectionType=t}get scale(){return this._scale}set scale(t){this._scale=t}get scaleFactor(){return this.scale}set scaleFactor(t){this.scale=t}get overwritePropChanged(){return this._overwritePropChanged}set overwritePropChanged(t){this._overwritePropChanged=t}get overwritePropertyValue(){return this.overwritePropChanged}set overwritePropertyValue(t){this.overwritePropChanged=t}get annotative(){return this._annotative}set annotative(t){this._annotative=t}get breakSize(){return this._breakSize}set breakSize(t){this._breakSize=t}get breakGapSize(){return this.breakSize}set breakGapSize(t){this.breakSize=t}get textAttachmentDirection(){return this._textAttachmentDirection}set textAttachmentDirection(t){this._textAttachmentDirection=t}get bottomTextAttachmentType(){return this._bottomTextAttachmentType}set bottomTextAttachmentType(t){this._bottomTextAttachmentType=t}get bottomTextAttachmentDirection(){return this.bottomTextAttachmentType}set bottomTextAttachmentDirection(t){this.bottomTextAttachmentType=t}get topTextAttachmentType(){return this._topTextAttachmentType}set topTextAttachmentType(t){this._topTextAttachmentType=t}get topTextAttachmentDirection(){return this.topTextAttachmentType}set topTextAttachmentDirection(t){this.topTextAttachmentType=t}get extendLeaderToText(){return this._extendLeaderToText}set extendLeaderToText(t){this._extendLeaderToText=t}get unknown2(){return this._unknown2}set unknown2(t){this._unknown2=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMLeaderStyle"),t.writeInt16(179,this.unknown1),t.writeInt16(170,this.contentType),t.writeInt16(171,this.drawMLeaderOrderType),t.writeInt16(172,this.drawLeaderOrderType),t.writeInt32(90,this.maxLeaderSegmentsPoints),t.writeDouble(40,this.firstSegmentAngleConstraint),t.writeDouble(41,this.secondSegmentAngleConstraint),t.writeInt16(173,this.leaderLineType),t.writeInt32(91,Zr(this.leaderLineColor)),t.writeHandle(340,this.leaderLineTypeId),t.writeInt32(92,this.leaderLineWeight),t.writeBoolean(290,this.enableLanding),t.writeDouble(42,this.landingGap),t.writeBoolean(291,this.enableDogleg),t.writeDouble(43,this.doglegLength),t.writeString(3,this.description),t.writeHandle(341,this.arrowSymbolId),t.writeDouble(44,this.arrowSize),t.writeString(300,this.defaultMTextContents),t.writeHandle(342,this.textStyleId),t.writeInt16(174,this.textLeftAttachmentType),t.writeInt16(175,this.textAngleType),t.writeInt16(176,this.textAlignmentType),t.writeInt16(178,this.textRightAttachmentType),t.writeInt32(93,Zr(this.textColor)),t.writeDouble(45,this.textHeight),t.writeBoolean(292,this.enableFrameText),t.writeBoolean(297,this.textAlignAlwaysLeft),t.writeDouble(46,this.alignSpace),t.writeHandle(343,this.blockId),t.writeInt32(94,Zr(this.blockColor)),t.writeDouble(47,this._blockScale.x),t.writeDouble(49,this._blockScale.y),t.writeDouble(140,this._blockScale.z),t.writeBoolean(293,this.enableBlockScale),t.writeDouble(141,this.blockRotation),t.writeBoolean(294,this.enableBlockRotation),t.writeInt16(177,this.blockConnectionType),t.writeDouble(142,this.scale),t.writeBoolean(295,this.overwritePropChanged),t.writeBoolean(296,this.annotative),t.writeDouble(143,this.breakSize),t.writeInt16(271,this.textAttachmentDirection),t.writeInt16(272,this.bottomTextAttachmentType),t.writeInt16(273,this.topTextAttachmentType),t.writeBoolean(298,this.unknown2),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbMLeaderStyle");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code),r=Number(e.value);switch(i){case 179:this.unknown1=r;break;case 170:this.contentType=r;break;case 171:this.drawMLeaderOrderType=r;break;case 172:this.drawLeaderOrderType=r;break;case 90:this.maxLeaderSegmentsPoints=r;break;case 40:this.firstSegmentAngleConstraint=r;break;case 41:this.secondSegmentAngleConstraint=r;break;case 173:this.leaderLineType=r;break;case 91:this.leaderLineColor=Qt(r);break;case 340:this.leaderLineTypeId=String(e.value);break;case 92:this.leaderLineWeight=r;break;case 290:this.enableLanding=r!==0;break;case 42:this.landingGap=r;break;case 291:this.enableDogleg=r!==0;break;case 43:this.doglegLength=r;break;case 3:this.description=String(e.value);break;case 341:this.arrowSymbolId=String(e.value);break;case 44:this.arrowSize=r;break;case 300:this.defaultMTextContents=String(e.value);break;case 342:this.textStyleId=String(e.value);break;case 174:this.textLeftAttachmentType=r;break;case 175:this.textAngleType=r;break;case 176:this.textAlignmentType=r;break;case 178:this.textRightAttachmentType=r;break;case 93:this.textColor=Qt(r);break;case 45:this.textHeight=r;break;case 292:this.enableFrameText=r!==0;break;case 297:this.textAlignAlwaysLeft=r!==0;break;case 46:this.alignSpace=r;break;case 343:this.blockId=String(e.value);break;case 94:this.blockColor=Qt(r);break;case 47:this._blockScale.x=r;break;case 49:this._blockScale.y=r;break;case 140:this._blockScale.z=r;break;case 293:this.enableBlockScale=r!==0;break;case 141:this.blockRotation=r;break;case 294:this.enableBlockRotation=r!==0;break;case 177:this.blockConnectionType=r;break;case 142:this.scale=r;break;case 295:this.overwritePropChanged=r!==0;break;case 296:this.annotative=r!==0;break;case 143:this.breakSize=r;break;case 271:this.textAttachmentDirection=r;break;case 272:this.bottomTextAttachmentType=r;break;case 273:this.topTextAttachmentType=r;break;case 298:this.unknown2=r!==0;break;case 100:return t.pushBackItem(e),this}}return this}}var Ai=(n=>(n[n.InvisibleLeader=0]="InvisibleLeader",n[n.StraightLeader=1]="StraightLeader",n[n.SplineLeader=2]="SplineLeader",n))(Ai||{}),He=(n=>(n[n.NoneContent=0]="NoneContent",n[n.BlockContent=1]="BlockContent",n[n.MTextContent=2]="MTextContent",n[n.ToleranceContent=3]="ToleranceContent",n))(He||{}),Jl=(n=>(n[n.Horizontal=0]="Horizontal",n[n.Vertical=1]="Vertical",n))(Jl||{}),th=(n=>(n[n.Unknown=0]="Unknown",n[n.Left=1]="Left",n[n.Right=2]="Right",n[n.Top=3]="Top",n[n.Bottom=4]="Bottom",n))(th||{});const Lp=1,Tp=2,Cp=4,Mp=8,Op=64,Np=128,Rp=32768,wa=class wa extends H{get dxfTypeName(){return"MULTILEADER"}constructor(){super(),this._leaders=[],this._leaderLineType=1,this._contentType=0,this._doglegEnabled=!1,this._doglegLength=0,this._doglegVector=new w(1,0,0),this._normal=new w(0,0,1),this._mleaderStyleId="",this._textHeight=2.5,this._textWidth=0,this._textRotation=0,this._textDirection=new w(1,0,0),this._textStyleName="",this._textAttachmentPoint=exports.AcGiMTextAttachmentPoint.MiddleLeft,this._textDrawingDirection=exports.AcGiMTextFlowDirection.LEFT_TO_RIGHT,this._textLineSpacingFactor=1,this._textAttachmentDirection=0,this._arrowheadOverrides=[],this._blockAttributes=[]}get leaders(){return this._leaders.map(t=>this.cloneLeader(t))}get numberOfLeaders(){return this._leaders.length}get leaderLineType(){return this._leaderLineType}set leaderLineType(t){this._leaderLineType=t}get contentType(){return this._contentType}set contentType(t){this._contentType=t}get doglegEnabled(){return this._doglegEnabled}set doglegEnabled(t){this._doglegEnabled=t}get doglegLength(){return this._doglegLength}set doglegLength(t){this._doglegLength=t}get doglegVector(){return this._doglegVector}set doglegVector(t){this._doglegVector.copy(t)}get landingPoint(){return this._landingPoint}set landingPoint(t){this._landingPoint=t?this.createPoint(t):void 0}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get mleaderStyleId(){return this._mleaderStyleId}set mleaderStyleId(t){this._mleaderStyleId=t}get version(){return this._version}set version(t){this._version=t}get leaderStyleId(){return this._leaderStyleId}set leaderStyleId(t){this._leaderStyleId=t}get propertyOverrideFlag(){return this._propertyOverrideFlag}set propertyOverrideFlag(t){this._propertyOverrideFlag=t}get leaderLineColor(){return this._leaderLineColor}set leaderLineColor(t){this._leaderLineColor=t==null?void 0:t.clone()}get leaderLineTypeId(){return this._leaderLineTypeId}set leaderLineTypeId(t){this._leaderLineTypeId=t}get leaderLineWeight(){return this._leaderLineWeight}set leaderLineWeight(t){this._leaderLineWeight=t}get landingEnabled(){return this._landingEnabled}set landingEnabled(t){this._landingEnabled=t}get arrowheadId(){return this._arrowheadId}set arrowheadId(t){this._arrowheadId=t}get arrowheadSize(){return this._arrowheadSize}set arrowheadSize(t){this._arrowheadSize=t}get textStyleId(){return this._textStyleId}set textStyleId(t){this._textStyleId=t}get textLeftAttachmentType(){return this._textLeftAttachmentType}set textLeftAttachmentType(t){this._textLeftAttachmentType=t}get textRightAttachmentType(){return this._textRightAttachmentType}set textRightAttachmentType(t){this._textRightAttachmentType=t}get textAngleType(){return this._textAngleType}set textAngleType(t){this._textAngleType=t}get textAlignmentType(){return this._textAlignmentType}set textAlignmentType(t){this._textAlignmentType=t}get textColor(){return this._textColor}set textColor(t){this._textColor=t==null?void 0:t.clone()}get textFrameEnabled(){return this._textFrameEnabled}set textFrameEnabled(t){this._textFrameEnabled=t}get landingGap(){return this._landingGap}set landingGap(t){this._landingGap=t}get textAttachment(){return this._textAttachment}set textAttachment(t){this._textAttachment=t}get textFlowDirection(){return this._textFlowDirection}set textFlowDirection(t){this._textFlowDirection=t}get blockContentId(){return this._blockContentId}set blockContentId(t){this._blockContentId=t}get blockContentColor(){return this._blockContentColor}set blockContentColor(t){this._blockContentColor=t==null?void 0:t.clone()}get blockContentScale(){return this._blockContentScale}set blockContentScale(t){this._blockContentScale=t}get blockContentRotation(){return this._blockContentRotation}set blockContentRotation(t){this._blockContentRotation=t}get blockContentConnectionType(){return this._blockContentConnectionType}set blockContentConnectionType(t){this._blockContentConnectionType=t}get annotativeScaleEnabled(){return this._annotativeScaleEnabled}set annotativeScaleEnabled(t){this._annotativeScaleEnabled=t}get arrowheadOverrides(){return this._arrowheadOverrides}set arrowheadOverrides(t){this._arrowheadOverrides=t}get blockAttributes(){return this._blockAttributes}set blockAttributes(t){this._blockAttributes=t}get textDirectionNegative(){return this._textDirectionNegative}set textDirectionNegative(t){this._textDirectionNegative=t}get textAlignInIPE(){return this._textAlignInIPE}set textAlignInIPE(t){this._textAlignInIPE=t}get bottomTextAttachmentDirection(){return this._bottomTextAttachmentDirection}set bottomTextAttachmentDirection(t){this._bottomTextAttachmentDirection=t}get topTextAttachmentDirection(){return this._topTextAttachmentDirection}set topTextAttachmentDirection(t){this._topTextAttachmentDirection=t}get contentScale(){return this._contentScale}set contentScale(t){this._contentScale=t}get contentBasePosition(){return this._contentBasePosition}set contentBasePosition(t){this._contentBasePosition=t}get textAnchor(){return this._textAnchor}set textAnchor(t){this._textAnchor=t}get textLineSpacingStyle(){return this._textLineSpacingStyle}set textLineSpacingStyle(t){this._textLineSpacingStyle=t}get textBackgroundColor(){return this._textBackgroundColor}set textBackgroundColor(t){this._textBackgroundColor=t==null?void 0:t.clone()}get textBackgroundScaleFactor(){return this._textBackgroundScaleFactor}set textBackgroundScaleFactor(t){this._textBackgroundScaleFactor=t}get textBackgroundTransparency(){return this._textBackgroundTransparency}set textBackgroundTransparency(t){this._textBackgroundTransparency=t}get textBackgroundColorOn(){return this._textBackgroundColorOn}set textBackgroundColorOn(t){this._textBackgroundColorOn=t}get textFillOn(){return this._textFillOn}set textFillOn(t){this._textFillOn=t}get textColumnType(){return this._textColumnType}set textColumnType(t){this._textColumnType=t}get textUseAutoHeight(){return this._textUseAutoHeight}set textUseAutoHeight(t){this._textUseAutoHeight=t}get textColumnWidth(){return this._textColumnWidth}set textColumnWidth(t){this._textColumnWidth=t}get textColumnGutterWidth(){return this._textColumnGutterWidth}set textColumnGutterWidth(t){this._textColumnGutterWidth=t}get textColumnFlowReversed(){return this._textColumnFlowReversed}set textColumnFlowReversed(t){this._textColumnFlowReversed=t}get textColumnHeight(){return this._textColumnHeight}set textColumnHeight(t){this._textColumnHeight=t}get textUseWordBreak(){return this._textUseWordBreak}set textUseWordBreak(t){this._textUseWordBreak=t}get hasMText(){return this._hasMText}set hasMText(t){this._hasMText=t}get hasBlock(){return this._hasBlock}set hasBlock(t){this._hasBlock=t}get planeOrigin(){return this._planeOrigin}set planeOrigin(t){this._planeOrigin=t}get planeXAxisDirection(){return this._planeXAxisDirection}set planeXAxisDirection(t){this._planeXAxisDirection=t}get planeYAxisDirection(){return this._planeYAxisDirection}set planeYAxisDirection(t){this._planeYAxisDirection=t}get planeNormalReversed(){return this._planeNormalReversed}set planeNormalReversed(t){this._planeNormalReversed=t}get leaderSections(){return this.leaders}get blockContentData(){return this.blockContent}get mtextContent(){return this._mtextContent?{text:this._mtextContent.text,anchorPoint:this._mtextContent.anchorPoint.clone()}:void 0}set mtextContent(t){if(!t){this._mtextContent=void 0,this._contentType===2&&(this._contentType=0);return}this._mtextContent={text:t.text,anchorPoint:this.createPoint(t.anchorPoint)},this._contentType=2}get contents(){var t;return((t=this._mtextContent)==null?void 0:t.text)??""}set contents(t){this._mtextContent?this._mtextContent.text=t:this._mtextContent={text:t,anchorPoint:new b},this._contentType=2}get textLocation(){var t;return(t=this._mtextContent)==null?void 0:t.anchorPoint}set textLocation(t){if(!t){this._mtextContent=void 0;return}this._mtextContent?this._mtextContent.anchorPoint.copy(t):this._mtextContent={text:"",anchorPoint:this.createPoint(t)},this._contentType=2}get textHeight(){return this._textHeight}set textHeight(t){this._textHeight=t}get textWidth(){return this._textWidth}set textWidth(t){this._textWidth=t}get textRotation(){return this._textRotation}set textRotation(t){this._textRotation=t}get textDirection(){return this._textDirection}set textDirection(t){this._textDirection.copy(t)}get textStyleName(){return this._textStyleName}set textStyleName(t){this._textStyleName=t}get textAttachmentPoint(){return this._textAttachmentPoint}set textAttachmentPoint(t){this._textAttachmentPoint=t}get textDrawingDirection(){return this._textDrawingDirection}set textDrawingDirection(t){this._textDrawingDirection=t}get textLineSpacingFactor(){return this._textLineSpacingFactor}set textLineSpacingFactor(t){this._textLineSpacingFactor=t}get textAttachmentDirection(){return this._textAttachmentDirection}set textAttachmentDirection(t){this._textAttachmentDirection=t}get blockContent(){var t,e,i;return this._blockContent?{blockContentId:this._blockContent.blockContentId,blockHandle:this._blockContent.blockHandle,normal:(t=this._blockContent.normal)==null?void 0:t.clone(),position:(e=this._blockContent.position)==null?void 0:e.clone(),scale:this._blockContent.scale.clone(),rotation:this._blockContent.rotation,color:(i=this._blockContent.color)==null?void 0:i.clone(),transformationMatrix:[...this._blockContent.transformationMatrix]}:void 0}set blockContent(t){var e;if(!t){this._blockContent=void 0,this._contentType===1&&(this._contentType=0);return}this._blockContent={blockContentId:t.blockContentId??t.blockHandle,blockHandle:t.blockHandle,normal:t.normal?new w(t.normal):void 0,position:t.position?this.createPoint(t.position):void 0,scale:new w(t.scale??{x:1,y:1,z:1}),rotation:t.rotation??0,color:(e=t.color)==null?void 0:e.clone(),transformationMatrix:t.transformationMatrix?[...t.transformationMatrix]:[]},this.blockContentId=this._blockContent.blockContentId,this._contentType=1}addLeader(t={}){var i,r;const e={lastLeaderLinePoint:t.lastLeaderLinePoint?this.createPoint(t.lastLeaderLinePoint):void 0,lastLeaderLinePointSet:t.lastLeaderLinePointSet,landingPoint:t.landingPoint?this.createPoint(t.landingPoint):void 0,doglegVector:t.doglegVector?new w(t.doglegVector):void 0,doglegVectorSet:t.doglegVectorSet,doglegLength:t.doglegLength,breaks:((i=t.breaks)==null?void 0:i.map(s=>({index:s.index,start:this.createPoint(s.start),end:this.createPoint(s.end)})))??[],leaderBranchIndex:t.leaderBranchIndex,directionType:t.directionType,leaderLines:[]};return(r=t.leaderLines)==null||r.forEach(s=>{e.leaderLines.push(this.createLeaderLine(s))}),this._leaders.push(e),this._leaders.length-1}removeLeader(t){return this.checkLeaderIndex(t),this._leaders.splice(t,1),this}addLeaderLine(t,e=[]){return this.checkLeaderIndex(t),this._leaders[t].leaderLines.push(this.createLeaderLine({vertices:e})),this._leaders[t].leaderLines.length-1}appendVertex(t,e,i){return this.getMutableLeaderLine(t,e).vertices.push(this.createPoint(i)),this}setLeaderLineVertices(t,e,i){return this.getMutableLeaderLine(t,e).vertices=i.map(r=>this.createPoint(r)),this}getLeaderLineVertices(t,e){return this.getMutableLeaderLine(t,e).vertices.map(i=>i.clone())}addBreak(t,e,i,r){return this.getMutableLeaderLine(t,e).breaks.push({start:this.createPoint(i),end:this.createPoint(r)}),this}setLandingPoint(t,e){return this.checkLeaderIndex(t),this._leaders[t].landingPoint=e?this.createPoint(e):void 0,this}setDoglegDirection(t,e){return this.checkLeaderIndex(t),this._leaders[t].doglegVector=new w(e),this}setDoglegLength(t,e){return this.checkLeaderIndex(t),this._leaders[t].doglegLength=e,this}get geometricExtents(){const t=this.collectGeometryPoints();return t.length>0?new Y().setFromPoints(t):new Y}subGetGripPoints(){return this.collectGeometryPoints().map(t=>t.clone())}subMoveGripPointsAt(t,e){return ht(t,i=>{this.moveGeometryGripPointAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){var s;if(t===A.Insertion){this.contentBasePosition?r.push(this.contentBasePosition):this._mtextContent?r.push(this._mtextContent.anchorPoint):(s=this._blockContent)!=null&&s.position&&r.push(this._blockContent.position);return}this._leaders.forEach(a=>{a.leaderLines.forEach(o=>{const c=this.getLeaderLineDrawPoints(a,o);if(c.length!==0)switch(t){case A.EndPoint:r.push(...c);break;case A.MidPoint:case A.Nearest:case A.Perpendicular:{const l=[];for(let h=0;h<c.length-1;h++){const u=[];ui(c[h],c[h+1],t,e,u),l.push(...u)}if(t===A.MidPoint)r.push(...l);else{const h=Ft(e,l);h&&r.push(h)}break}}})})}transformBy(t){var e,i,r,s,a,o,c,l;return this._leaders.forEach(h=>{var u,d;(u=h.lastLeaderLinePoint)==null||u.applyMatrix4(t),(d=h.landingPoint)==null||d.applyMatrix4(t),h.doglegVector&&this.transformVector(h.doglegVector,t),h.breaks.forEach(g=>{g.start.applyMatrix4(t),g.end.applyMatrix4(t)}),h.leaderLines.forEach(g=>{g.vertices.forEach(p=>p.applyMatrix4(t)),g.breaks.forEach(p=>{p.start.applyMatrix4(t),p.end.applyMatrix4(t)})})}),(e=this._landingPoint)==null||e.applyMatrix4(t),(i=this.contentBasePosition)==null||i.applyMatrix4(t),this.transformVector(this._doglegVector,t),this.transformVector(this._normal,t),(r=this.textAnchor)==null||r.applyMatrix4(t),(s=this._mtextContent)==null||s.anchorPoint.applyMatrix4(t),this.transformVector(this._textDirection,t),(o=(a=this._blockContent)==null?void 0:a.position)==null||o.applyMatrix4(t),(c=this._blockContent)!=null&&c.normal&&this.transformVector(this._blockContent.normal,t),this.blockContentScale&&this.transformVector(this.blockContentScale,t),(l=this.planeOrigin)==null||l.applyMatrix4(t),this.planeXAxisDirection&&this.transformVector(this.planeXAxisDirection,t),this.planeYAxisDirection&&this.transformVector(this.planeYAxisDirection,t),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"leader",properties:[{name:"contentType",type:"enum",editable:!0,options:[{label:He[0],value:0},{label:He[1],value:1},{label:He[2],value:2},{label:He[3],value:3}],accessor:{get:()=>this.contentType,set:t=>{this.contentType=t}}},{name:"leaderLineType",type:"enum",editable:!0,options:[{label:Ai[0],value:0},{label:Ai[1],value:1},{label:Ai[2],value:2}],accessor:{get:()=>this.leaderLineType,set:t=>{this.leaderLineType=t}}},{name:"doglegEnabled",type:"boolean",editable:!0,accessor:{get:()=>this.doglegEnabled,set:t=>{this.doglegEnabled=t}}},{name:"doglegLength",type:"float",editable:!0,accessor:{get:()=>this.doglegLength,set:t=>{this.doglegLength=t}}},{name:"leaderCount",type:"int",editable:!1,accessor:{get:()=>this.numberOfLeaders}}]},{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:t=>{this.contents=t}}},{name:"textHeight",type:"float",editable:!0,accessor:{get:()=>this.textHeight,set:t=>{this.textHeight=t}}},{name:"textWidth",type:"float",editable:!0,accessor:{get:()=>this.textWidth,set:t=>{this.textWidth=t}}},{name:"textStyleName",type:"string",editable:!0,accessor:{get:()=>this.textStyleName,set:t=>{this.textStyleName=t}}}]}]}}resolveEffectiveProperties(){if(super.resolveEffectiveProperties(),this._mleaderStyleId)return;const t=this.getDefaultMLeaderStyle();t&&(this._mleaderStyleId=t.objectId)}subWorldDraw(t,e){const i=[],r=t.subEntityTraits,s=r.color,a=r.lineType,o=r.lineWeight,c=this.getResolvedLeaderLineColor(),l=this.getResolvedLeaderLineStyle(),h=this.getResolvedLeaderLineWeight(),u=this.getResolvedTextColor();this.getResolvedLeaderLineType()!==0&&(this.applyColorTraits(r,c,s),this.applyLineTraits(r,l,h),this._leaders.forEach(p=>{p.leaderLines.forEach(m=>{const y=this.getLeaderLineDrawPoints(p,m);if(y.length>0){const _=this.drawLeaderLine(t,y);_&&i.push(_)}});const f=this.getDoglegPoints(p);f&&i.push(t.lines(f))}));const d=this.getRenderableMTextContent();if(!!d&&(this.contentType===2||this.contentType===0||this.hasMText===!0)&&d){this.applyColorTraits(r,u,s);const p=this.getResolvedTextHeight(),f={text:d.text,height:p,width:this.getMTextRenderWidth(d.text,p),position:d.anchorPoint,rotation:this.textRotation,directionVector:this.textDirection,attachmentPoint:this.textAttachmentPoint,drawingDirection:this.textDrawingDirection,lineSpaceFactor:this.textLineSpacingFactor};i.push(t.mtext(f,this.getTextStyle(),e))}if(r.color=s,r.lineType=a,r.lineWeight=o,i.length!==0)return i.length===1?i[0]:t.group(i)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMLeader"),t.writeInt16(170,this.leaderLineType),t.writeBoolean(290,this.doglegEnabled),t.writeDouble(41,this.doglegLength),t.writeInt16(172,this.contentType),t.writeVector3d(210,this.normal),t.writeHandle(340,this.mleaderStyleId),this._landingPoint&&t.writePoint3d(10,this._landingPoint),t.writeVector3d(11,this.doglegVector),this._mtextContent&&(t.writeString(1,this._mtextContent.text),t.writePoint3d(12,this._mtextContent.anchorPoint),t.writeDouble(40,this.textHeight),t.writeDouble(42,this.textWidth),t.writeAngle(50,this.textRotation),t.writeString(7,this.textStyleName)),this._blockContent&&(t.writeHandle(341,this._blockContent.blockContentId??""),this._blockContent.position&&t.writePoint3d(15,this._blockContent.position),t.writeVector3d(16,this._blockContent.scale),t.writeAngle(52,this._blockContent.rotation)),this._leaders.forEach(e=>{e.landingPoint&&t.writePoint3d(110,e.landingPoint),e.doglegVector&&t.writeVector3d(111,e.doglegVector),t.writeDouble(140,e.doglegLength),t.writeInt16(171,e.leaderLines.length),e.leaderLines.forEach(i=>{t.writeInt16(90,i.vertices.length),i.vertices.forEach(r=>t.writePoint3d(10,r))})}),this}dxfInFields(t){var P,C,T,R,N,O,S,G,$,Q,et,W,Dt,B,Yt;super.dxfInFields(t),t.atSubclassData("AcDbMLeader"),this._leaders.length=0;let e=(P=this._mtextContent)==null?void 0:P.text,i=(T=(C=this._mtextContent)==null?void 0:C.anchorPoint)==null?void 0:T.clone(),r=!!this._mtextContent,s=(R=this._blockContent)==null?void 0:R.blockContentId,a=(O=(N=this._blockContent)==null?void 0:N.position)==null?void 0:O.clone(),o=(G=(S=this._blockContent)==null?void 0:S.scale)==null?void 0:G.clone(),c=($=this._blockContent)==null?void 0:$.rotation,l=(et=(Q=this._blockContent)==null?void 0:Q.normal)==null?void 0:et.clone(),h=(Dt=(W=this._blockContent)==null?void 0:W.color)==null?void 0:Dt.clone(),u=(B=this._blockContent)!=null&&B.transformationMatrix?[...this._blockContent.transformationMatrix]:[],d=!!this._blockContent,g=!1,p=!1,f=(Yt=this._landingPoint)==null?void 0:Yt.clone(),m=this._doglegVector.clone(),y=null,_=null,v=!1,x;const k=()=>{_&&y&&y.leaderLines.push(_),_=null},I=()=>{k(),y&&this.addLeader(y),y=null};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const st=t.readItem();if(!st)break;const Au=Number(st.code),U=Number(st.value),ut=String(st.value??"");switch(Au){case 100:return t.pushBackItem(st),I(),this.finishMLeaderDxfIn(e,i,r,s,a,o,c,l,h,u,d,g,f,m,x),this;case 300:if(ut==="CONTEXT_DATA{"){p=!0;const F=this.dxfInContextData(t);F.textContent!=null&&(e=F.textContent,r=!0),F.textAnchor&&(i=F.textAnchor,r=!0),F.hasMText!=null&&(this.hasMText=F.hasMText),F.hasBlock!=null&&(this.hasBlock=F.hasBlock),F.blockContentId&&(s=F.blockContentId,d=this.isValidMLeaderHandle(F.blockContentId)),F.blockPosition&&(a=F.blockPosition,d=!0),F.blockScale&&(o=F.blockScale,d=!0),F.blockRotation!=null&&(c=F.blockRotation,d=!0),F.blockNormal&&(l=F.blockNormal,d=!0),F.blockColor&&(h=F.blockColor,d=!0),F.blockMatrix.length>0&&(u=F.blockMatrix,d=!0),r&&!g&&(this.contentType=2,g=!0)}break;case 270:p=!0,this.version=U;break;case 340:this.leaderStyleId=ut,this.mleaderStyleId=ut;break;case 90:v?(k(),_={vertices:[],breakPointIndexes:[],breaks:[]}):this.propertyOverrideFlag=U;break;case 170:this.leaderLineType=U;break;case 91:this.leaderLineColor=Qt(U);break;case 341:p?this.leaderLineTypeId=ut:this.isValidMLeaderHandle(ut)?(s=ut,d=!0):this.leaderLineTypeId=ut;break;case 171:v||(this.leaderLineWeight=U);break;case 290:p?this.landingEnabled=this.readDxfBoolean(st):this.doglegEnabled=this.readDxfBoolean(st);break;case 291:this.doglegEnabled=this.readDxfBoolean(st);break;case 40:p?this.doglegLength=U:this.textHeight=U;break;case 41:this.doglegLength=U;break;case 342:this.arrowheadId=ut;break;case 42:p?this.arrowheadSize=U:this.textWidth=U;break;case 172:this.contentType=U,g=!0;break;case 343:this.textStyleId=ut;break;case 173:this.textLeftAttachmentType=U;break;case 95:this.textRightAttachmentType=U;break;case 174:this.textAngleType=U;break;case 175:this.textAlignmentType=U;break;case 92:this.textColor=Qt(U);break;case 292:this.textFrameEnabled=this.readDxfBoolean(st);break;case 344:this.isValidMLeaderHandle(ut)&&(s=ut,this.blockContentId=ut,d=!0);break;case 93:this.blockContentColor=Qt(U);break;case 10:if(v){t.pushBackItem(st);const F=t.readPoint3d(10);F&&_&&_.vertices.push(F)}else{t.pushBackItem(st);const F=t.readPoint3d(10);if(!F)break;p?(this.blockContentScale=new w(F),o=new w(F),d=!0):f=F}break;case 43:this.blockContentRotation=U,c=U,d=!0;break;case 176:this.blockContentConnectionType=U;break;case 293:this.annotativeScaleEnabled=this.readDxfBoolean(st);break;case 94:{this.arrowheadOverrides.push({index:U});break}case 345:{const F=this.arrowheadOverrides[this.arrowheadOverrides.length-1];F?F.handle=ut:this.arrowheadOverrides.push({index:0,handle:ut});break}case 330:this.blockAttributes.push({id:ut});break;case 177:{const F=this.blockAttributes[this.blockAttributes.length-1];F&&(F.index=U);break}case 44:{const F=this.blockAttributes[this.blockAttributes.length-1];F&&(F.width=U);break}case 302:{const F=this.blockAttributes[this.blockAttributes.length-1];F&&(F.text=ut);break}case 294:this.textDirectionNegative=this.readDxfBoolean(st);break;case 178:this.textAlignInIPE=U;break;case 179:U!==0&&(this.textAttachmentPoint=U);break;case 271:this.textAttachmentDirection=U;break;case 272:this.bottomTextAttachmentDirection=U;break;case 273:this.topTextAttachmentDirection=U;break;case 210:t.pushBackItem(st);{const F=t.readVector3d(210);F&&(this.normal=F)}break;case 110:I(),v=!0,t.pushBackItem(st),y={landingPoint:t.readPoint3d(110),doglegVector:new w(1,0,0),doglegLength:0,breaks:[],leaderLines:[]};break;case 111:if(y){t.pushBackItem(st);const F=t.readVector3d(111);F&&(y.doglegVector=F)}break;case 140:y?y.doglegLength=U:this.arrowheadSize=U;break;case 1:e=ut,r=!0;break;case 12:t.pushBackItem(st);{const F=t.readPoint3d(12);F&&(i=F,r=!0)}break;case 7:this.textStyleName=ut;break;case 50:x=U;break;case 15:t.pushBackItem(st);{const F=t.readPoint3d(15);F&&(a=F,d=!0)}break;case 16:t.pushBackItem(st);{const F=t.readVector3d(16);F&&(o=F,d=!0)}break;case 52:c=U*Math.PI/180,d=!0;break;case 11:if(!v&&!p){t.pushBackItem(st);const F=t.readVector3d(11);F&&(m=F)}break}}return I(),this.finishMLeaderDxfIn(e,i,r,s,a,o,c,l,h,u,d,g,f,m,x),this}finishMLeaderDxfIn(t,e,i,r,s,a,o,c,l,h,u,d,g,p,f){if(g&&(this.landingPoint=g),this.doglegVector=p,f!=null&&(this.textRotation=f*Math.PI/180),!this.textStyleName&&this.textStyleId){const y=this.database.tables.textStyleTable.getIdAt(this.textStyleId);y!=null&&y.name&&(this.textStyleName=y.name)}const m=e??this.textAnchor??this.contentBasePosition??g;(i||this.hasMText)&&t!=null&&m?(this.mtextContent={text:t,anchorPoint:m.clone()},this.textAnchor||(this.textAnchor=m.clone()),d||(this.contentType=2)):(i||this.hasMText)&&t!=null&&!m&&(d||(this.contentType=2)),u&&this.isValidMLeaderHandle(r)&&this.contentType!==2&&!this.mtextContent&&(this.blockContent={blockContentId:r,position:s,scale:a??new w(1,1,1),rotation:o??0,normal:c,color:l,transformationMatrix:h},!d&&this.contentType===0&&(this.contentType=1))}dxfInContextData(t){const e={blockMatrix:[]};for(;!t.atEof;){const i=t.readItem();if(!i)break;const r=Number(i.code),s=Number(i.value),a=String(i.value??"");if(r===301)break;if(r===0){t.pushBackItem(i);break}switch(r){case 10:t.pushBackItem(i),this.contentBasePosition=t.readPoint3d(10);break;case 11:t.pushBackItem(i);{const o=t.readVector3d(11);o&&(this.normal=o)}break;case 12:t.pushBackItem(i);{const o=t.readPoint3d(12);o&&(e.textAnchor=o,this.textAnchor=o.clone())}break;case 13:t.pushBackItem(i);{const o=t.readVector3d(13);o&&(this.textDirection=o)}break;case 14:t.pushBackItem(i),e.blockNormal=t.readVector3d(14);break;case 15:t.pushBackItem(i),e.blockPosition=t.readPoint3d(15);break;case 16:t.pushBackItem(i),e.blockScale=t.readVector3d(16);break;case 40:this.contentScale=s;break;case 41:s>0&&(this.textHeight=s);break;case 42:this.textRotation=s;break;case 43:s>0&&(this.textWidth=s);break;case 44:s>0&&(this.textHeight=s);break;case 45:this.textLineSpacingFactor=s;break;case 46:e.blockRotation=s;break;case 47:e.blockMatrix.push(s);break;case 90:this.textColor=Qt(s);break;case 91:this.textBackgroundColor=Qt(s);break;case 92:this.textBackgroundTransparency=s;break;case 93:e.blockColor=Qt(s);break;case 110:t.pushBackItem(i),this.planeOrigin=t.readPoint3d(110);break;case 111:t.pushBackItem(i),this.planeXAxisDirection=t.readVector3d(111);break;case 112:t.pushBackItem(i),this.planeYAxisDirection=t.readVector3d(112);break;case 140:this.arrowheadSize=s;break;case 141:this.textBackgroundScaleFactor=s;break;case 142:this.textColumnWidth=s;break;case 143:this.textColumnGutterWidth=s;break;case 144:this.textColumnHeight=s;break;case 145:this.landingGap=s;break;case 170:this.textLineSpacingStyle=s;break;case 171:this.textAttachment=s;break;case 172:this.textFlowDirection=s;break;case 173:this.textColumnType=s;break;case 290:e.hasMText=this.readDxfBoolean(i),this.hasMText=e.hasMText;break;case 291:this.textBackgroundColorOn=this.readDxfBoolean(i);break;case 292:this.textFillOn=this.readDxfBoolean(i);break;case 293:this.textUseAutoHeight=this.readDxfBoolean(i);break;case 294:this.textColumnFlowReversed=this.readDxfBoolean(i);break;case 295:this.textUseWordBreak=this.readDxfBoolean(i);break;case 296:e.hasBlock=this.readDxfBoolean(i),this.hasBlock=e.hasBlock;break;case 297:this.planeNormalReversed=this.readDxfBoolean(i);break;case 302:if(a==="LEADER{"){const o=this.dxfInLeaderSection(t);this.addLeader(o)}break;case 304:a!=="LEADER_LINE{"&&(e.textContent=a,this.hasMText=!0);break;case 340:this.textStyleId=a;break;case 341:e.blockContentId=a,this.isValidMLeaderHandle(a)&&(this.blockContentId=a);break}}return e}dxfInLeaderSection(t){const e={breaks:[],leaderLines:[]};let i;const r=()=>{i&&(e.breaks.push(i),i=void 0)};for(;!t.atEof;){const s=t.readItem();if(!s)break;const a=Number(s.code),o=Number(s.value),c=String(s.value??"");if(a===303){r();break}if(a===0||a===301){t.pushBackItem(s),r();break}switch(a){case 290:e.lastLeaderLinePointSet=this.readDxfBoolean(s);break;case 291:e.doglegVectorSet=this.readDxfBoolean(s);break;case 10:t.pushBackItem(s),e.lastLeaderLinePoint=t.readPoint3d(10);break;case 11:t.pushBackItem(s),e.doglegVector=t.readVector3d(11);break;case 12:t.pushBackItem(s);{const l=t.readPoint3d(12);l&&(i={start:l,end:l.clone()})}break;case 13:t.pushBackItem(s);{const l=t.readPoint3d(13);i&&l&&(i.end=l,r())}break;case 90:e.leaderBranchIndex=o;break;case 40:e.doglegLength=o;break;case 304:c==="LEADER_LINE{"&&e.leaderLines.push(this.dxfInLeaderLine(t));break}}return e}dxfInLeaderLine(t){const e={vertices:[],breakPointIndexes:[],breaks:[]};let i;const r=()=>{i&&(e.breaks.push(i),i=void 0)};for(;!t.atEof;){const s=t.readItem();if(!s)break;const a=Number(s.code),o=Number(s.value);if(a===305){r();break}if(a===0||a===303||a===301){t.pushBackItem(s),r();break}switch(a){case 10:t.pushBackItem(s);{const c=t.readPoint3d(10);c&&e.vertices.push(c)}break;case 11:t.pushBackItem(s);{const c=t.readPoint3d(11);c&&(i={index:i==null?void 0:i.index,start:c,end:c.clone()})}break;case 12:t.pushBackItem(s);{const c=t.readPoint3d(12);i&&c&&(i.end=c,r())}break;case 90:e.breakPointIndexes.push(o),i={index:o,start:(i==null?void 0:i.start)??new b,end:(i==null?void 0:i.end)??new b};break;case 91:e.leaderLineIndex=o;break}}return e}readDxfBoolean(t){if(typeof t.value=="boolean")return t.value;const e=Number(t.value);if(Number.isFinite(e))return e!==0;const i=String(t.value??"");return i!==""&&i!=="0"}isValidMLeaderHandle(t){return t!=null&&t!==""&&t!=="0"}createPoint(t){return new b().copy(t)}createLeaderLine(t){var e,i;return{vertices:((e=t.vertices)==null?void 0:e.map(r=>this.createPoint(r)))??[],breakPointIndexes:t.breakPointIndexes?[...t.breakPointIndexes]:[],leaderLineIndex:t.leaderLineIndex,breaks:((i=t.breaks)==null?void 0:i.map(r=>({index:r.index,start:this.createPoint(r.start),end:this.createPoint(r.end)})))??[]}}cloneLeader(t){var e,i,r;return{lastLeaderLinePoint:(e=t.lastLeaderLinePoint)==null?void 0:e.clone(),lastLeaderLinePointSet:t.lastLeaderLinePointSet,landingPoint:(i=t.landingPoint)==null?void 0:i.clone(),doglegVector:(r=t.doglegVector)==null?void 0:r.clone(),doglegVectorSet:t.doglegVectorSet,doglegLength:t.doglegLength,breaks:t.breaks.map(s=>({index:s.index,start:s.start.clone(),end:s.end.clone()})),leaderBranchIndex:t.leaderBranchIndex,directionType:t.directionType,leaderLines:t.leaderLines.map(s=>({vertices:s.vertices.map(a=>a.clone()),breakPointIndexes:[...s.breakPointIndexes],leaderLineIndex:s.leaderLineIndex,breaks:s.breaks.map(a=>({index:a.index,start:a.start.clone(),end:a.end.clone()}))}))}}checkLeaderIndex(t){if(t<0||t>=this._leaders.length)throw new Error("The leader index is out of range!")}getMutableLeaderLine(t,e){this.checkLeaderIndex(t);const i=this._leaders[t].leaderLines[e];if(!i)throw new Error("The leader line index is out of range!");return i}collectGeometryPoints(){var e;const t=[];return this._leaders.forEach(i=>{i.lastLeaderLinePoint&&t.push(i.lastLeaderLinePoint),i.landingPoint&&t.push(i.landingPoint),i.breaks.forEach(s=>t.push(s.start,s.end)),i.leaderLines.forEach(s=>{t.push(...s.vertices),s.breaks.forEach(a=>t.push(a.start,a.end))});const r=this.getDoglegPoints(i);r&&t.push(...r),i.leaderLines.forEach(s=>{const a=this.getArrowheadPoints(this.getLeaderLineDrawPoints(i,s));a&&t.push(...a)})}),this._landingPoint&&t.push(this._landingPoint),this.contentBasePosition&&t.push(this.contentBasePosition),this.textAnchor&&t.push(this.textAnchor),this._mtextContent&&t.push(this._mtextContent.anchorPoint),(e=this._blockContent)!=null&&e.position&&t.push(this._blockContent.position),this.planeOrigin&&t.push(this.planeOrigin),t}moveGeometryGripPointAt(t,e){var s;let i=0;const r=(a,o)=>{if(a){i===t&&a.add(e),i++;return}o&&(i===t&&o(),i++)};this._leaders.forEach(a=>{r(a.lastLeaderLinePoint),r(a.landingPoint),a.breaks.forEach(c=>{r(c.start),r(c.end)}),a.leaderLines.forEach(c=>{c.vertices.forEach(l=>r(l)),c.breaks.forEach(l=>{r(l.start),r(l.end)})});const o=this.getDoglegPoints(a);o&&(r(o[0]),r(void 0,()=>{const c=o[0],l=o[1];if(!c||!l)return;const h=c.distanceTo({x:l.x+e.x,y:l.y+e.y,z:(l.z??0)+(e.z??0)});a.doglegLength!=null||a.doglegVectorSet?a.doglegLength=h:this._doglegLength=h})),a.leaderLines.forEach(c=>{const l=this.getLeaderLineDrawPoints(a,c),h=this.getArrowheadPoints(l);h&&h.forEach((u,d)=>{d===0||d===h.length-1?r(l[0]):r(void 0)})})}),r(this._landingPoint),r(this.contentBasePosition),r(this.textAnchor),this._mtextContent&&r(this._mtextContent.anchorPoint),(s=this._blockContent)!=null&&s.position&&r(this._blockContent.position),r(this.planeOrigin)}getLeaderLineDrawPoints(t,e){if(e.vertices.length>=2)return e.vertices;if(e.vertices.length===0)return[];const i=t.lastLeaderLinePoint??t.landingPoint??this._landingPoint??this.contentBasePosition;return!i||e.vertices[0].equals(i)?e.vertices:[e.vertices[0],i]}getDoglegPoints(t){if(!this.getResolvedDoglegEnabled())return;const e=t.lastLeaderLinePoint??t.landingPoint??this._landingPoint,i=t.doglegVector??this._doglegVector,r=t.doglegLength??this.getResolvedDoglegLength();if(!e||r==null||r===0||i.lengthSq()===0)return;const s=e.clone().add(i.clone().normalize().multiplyScalar(r));return[e,s]}getArrowheadPoints(t){if(!this.isArrowheadVisible()||t.length<2)return;const e=this.getArrowheadFrame(t);if(!e)return;const i=this.getResolvedArrowheadSize(),{tip:r,unit:s}=e,a=r.clone().add(s.clone().multiplyScalar(i)),o=i/6,c=new w(-s.y,s.x,0),l=a.clone().add(c.clone().multiplyScalar(o)),h=a.clone().add(c.clone().multiplyScalar(-o));return[r,l,h,r]}isArrowheadVisible(){const t=this.getResolvedArrowheadId();return(t==null?void 0:t.toUpperCase())==="_NONE"?!1:this.getResolvedArrowheadSize()>0}drawLeaderLine(t,e){const i=[],r=this.getLeaderLinePointsForDraw(e);r.length>=2&&i.push(t.lines(r));const s=this.drawArrowhead(t,e);if(s&&i.push(s),i.length!==0)return i.length===1?i[0]:t.group(i)}getLeaderLinePointsForDraw(t){const e=this.getArrowheadLeaderLineTrimDistance();return e<=0?t:this.trimPolylineStart(t,e)}getArrowheadLeaderLineTrimDistance(){if(!this.isArrowheadVisible())return 0;const t=this.getResolvedArrowheadBlockTableRecord();if(!t)return 0;const e=this.getResolvedArrowheadSize();if(e<=0)return 0;const i=t.origin??b.ORIGIN;let r=i.x;for(const s of t.newIterator()){const a=s.geometricExtents;a.isEmpty()||a.max.x>r&&(r=a.max.x)}return Math.max(0,(r-i.x)*e)}trimPolylineStart(t,e){if(t.length<2||e<=0)return t;let i=e;for(let r=0;r<t.length-1;r++){const s=t[r],a=t[r+1],o=a.distanceTo(s);if(!(o<=0)){if(i<o){const c=new w().subVectors(a,s);return[s.clone().add(c.multiplyScalar(i/o)),...t.slice(r+1)]}i-=o}}return[t[t.length-1]]}drawArrowhead(t,e){if(!this.isArrowheadVisible())return;const i=this.drawArrowheadBlock(t,e);if(i)return i;const r=this.getArrowheadPoints(e);if(!r)return;const s=new Vt;s.add(new q(r,!0));const a=t.subEntityTraits,o=a.fillType;a.fillType={solidFill:!0,patternAngle:0,definitionLines:[]};const c=t.area(s);return a.fillType=o,c}drawArrowheadBlock(t,e){const i=this.getResolvedArrowheadBlockTableRecord();if(!i)return;const r=this.getArrowheadFrame(e);if(!r)return;const{tip:s,unit:a}=r,o=this.getResolvedArrowheadSize(),c=Math.atan2(a.y,a.x),l=i.origin??b.ORIGIN,h=new D().makeTranslation(-l.x,-l.y,-l.z),u=new D().makeScale(o,o,o),d=new D().makeRotationZ(c),g=new D().makeTranslation(s.x,s.y,s.z),p=new D().multiplyMatrices(g,d).multiply(u).multiply(h);return Ie.instance.draw(t,i,this.resolvedColor,[],!0,p,new w(this.normal))}getArrowheadFrame(t){if(t.length<2)return;const e=t[0],i=t.find(s=>!s.equals(e));if(!i)return;const r=new w().subVectors(i,e);if(r.lengthSq()!==0)return{tip:e,unit:r.normalize()}}getResolvedArrowheadId(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.arrowSymbolId;return this.arrowheadId??t}getResolvedArrowheadBlockTableRecord(){const t=this.getResolvedArrowheadId();if(t)return this.database.tables.blockTable.getIdAt(t)}getResolvedArrowheadSize(){const t=this.getMLeaderStyle(),e=(t==null?void 0:t.arrowSize)??(t==null?void 0:t.scale);return this.arrowheadSize??this.contentScale??e??this.getResolvedTextHeight()}getResolvedTextHeight(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.textHeight;return this.textHeight>0?this.textHeight:t!=null&&t>0?t:2.5}getRenderableMTextContent(){var i;if(this._mtextContent)return{text:this._mtextContent.text,anchorPoint:this._mtextContent.anchorPoint};const t=(i=this.getMLeaderStyle())==null?void 0:i.defaultMTextContents,e=this.textAnchor??this.contentBasePosition??this._landingPoint;if(!(!t||!e))return{text:t,anchorPoint:e}}getMTextRenderWidth(t,e){if(this._textWidth>0)return this._textWidth;if(!t)return this._textWidth;const i=t.replace(/\\[PpNn]/g,`
11
+ `).replace(/\\[A-Za-z][^;]*;/g,"").replace(/[{}]/g,""),r=Math.max(...i.split(/\r\n|\r|\n/g).map(s=>s.length),1);return Math.max(e,r*e)}transformVector(t,e){const i=new b,r=new b(t.x,t.y,t.z);i.applyMatrix4(e),r.applyMatrix4(e),t.set(r.x-i.x,r.y-i.y,r.z-i.z)}getMLeaderStyle(){var i,r;const t=this.database.objects.mleaderStyle,e=(i=this.mleaderStyleId||this.leaderStyleId)==null?void 0:i.trim();if(e){const s=t.getIdAt(e);if(s)return s;const a=e.toUpperCase();for(const[,c]of t.entries())if(((r=c.objectId)==null?void 0:r.toUpperCase())===a)return c;const o=this.database.getObjectById(e);if(o instanceof Cr)return o}return this.getDefaultMLeaderStyle()}getDefaultMLeaderStyle(){const t=this.resolveMLeaderStyleByName(this.getDefaultMLeaderStyleName());return t||this.database.objects.mleaderStyle.newIterator().toArray()[0]}resolveMLeaderStyleByName(t){const e=t==null?void 0:t.trim();if(!e)return;const i=this.database.objects.mleaderStyle,r=i.getAt(e);if(r)return r;const s=i.getIdAt(e);if(s)return s;const a=e.toUpperCase();for(const[o,c]of i.entries())if(o.toUpperCase()===a)return c}getDefaultMLeaderStyleName(){try{return this.database.cmleaderstyle||he}catch{return he}}getResolvedTextStyleName(){var s,a,o;const t=this.database.tables.textStyleTable,e=(s=this.getMLeaderStyle())==null?void 0:s.textStyleId,i=e?(a=t.getIdAt(e))==null?void 0:a.name:void 0,r=this.textStyleId?(o=t.getIdAt(this.textStyleId))==null?void 0:o.name:void 0;if(this.textStyleName){const c=t.getAt(this.textStyleName);if(c!=null&&c.name)return c.name;const l=t.getIdAt(this.textStyleName);if(l!=null&&l.name)return l.name}return r||i}getTextStyle(){const t=this.database.tables.textStyleTable.resolveAt(this.getResolvedTextStyleName());if(!t)throw new Error("No valid text style found in text style table.");return t.textStyle}getResolvedLeaderLineColor(){var t;return this.getResolvedComponentColor(this.leaderLineColor,(t=this.getMLeaderStyle())==null?void 0:t.leaderLineColor,Tp)}getResolvedLeaderLineType(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.leaderLineType;return this.getResolvedStyleDrivenValue(this.leaderLineType,t,Lp)}getResolvedLeaderLineTypeId(){var t;return this.getResolvedStyleDrivenValue(this.leaderLineTypeId,(t=this.getMLeaderStyle())==null?void 0:t.leaderLineTypeId,Cp)}getResolvedLeaderLineStyle(){const t=this.getResolvedLeaderLineTypeId();if(!t)return;const e=this.database.tables.linetypeTable.getIdAt(t);if(e)return{type:"UserSpecified",...e.linetype}}getResolvedLeaderLineWeight(){var i;const t=(i=this.getMLeaderStyle())==null?void 0:i.leaderLineWeight,e=this.getResolvedStyleDrivenValue(this.leaderLineWeight,t,Mp);if(e!=null)return e}getResolvedDoglegEnabled(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.doglegEnabled;return this.getResolvedStyleDrivenValue(this.doglegEnabled,t,Op)}getResolvedDoglegLength(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.doglegLength;return this.getResolvedStyleDrivenValue(this.doglegLength,t,Np)}getResolvedTextColor(){var t;return this.getResolvedComponentColor(this.textColor,(t=this.getMLeaderStyle())==null?void 0:t.textColor,Rp)}getResolvedComponentColor(t,e,i){if(!t)return e;if(!t.isByBlock&&!t.isByLayer)return t;const r=this.isPropertyOverrideEnabled(i);return r===!0?t:e??t}getResolvedStyleDrivenValue(t,e,i){const r=this.isPropertyOverrideEnabled(i);return r===!0?t??e:e??t}isPropertyOverrideEnabled(t){if(this.propertyOverrideFlag!=null)return(this.propertyOverrideFlag&t)!==0}applyColorTraits(t,e,i){t.color=i,e&&(t.color=e)}applyLineTraits(t,e,i){e&&(t.lineType=e),i!=null&&(t.lineWeight=i)}};wa.typeName="MLeader";let Fi=wa;const va=class va extends H{constructor(){super(),this._normal=new w(0,0,1),this._annotationHeight=0,this._columnType=0,this._columnCount=0,this._columnFlowReversed=!1,this._columnAutoHeight=!1,this._columnWidth=0,this._columnGutter=0,this._contents="",this._height=0,this._width=0,this._extentsWidth=0,this._lineSpacingFactor=1,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=exports.AcGiMTextAttachmentPoint.TopLeft,this._direction=new w(1,0,0),this._drawingDirection=exports.AcGiMTextFlowDirection.LEFT_TO_RIGHT}get dxfTypeName(){return"MTEXT"}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 extentsWidth(){return this._extentsWidth}set extentsWidth(t){this._extentsWidth=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 normal(){return this._normal}set normal(t){this._normal.copy(t)}get annotationHeight(){return this._annotationHeight}set annotationHeight(t){this._annotationHeight=t}get columnType(){return this._columnType}set columnType(t){this._columnType=t}get columnCount(){return this._columnCount}set columnCount(t){this._columnCount=t}get columnFlowReversed(){return this._columnFlowReversed}set columnFlowReversed(t){this._columnFlowReversed=t}get columnAutoHeight(){return this._columnAutoHeight}set columnAutoHeight(t){this._columnAutoHeight=t}get columnWidth(){return this._columnWidth}set columnWidth(t){this._columnWidth=t}get columnGutter(){return this._columnGutter}set columnGutter(t){this._columnGutter=t}get geometricExtents(){const t=new Y,e=this.extentsWidth>0?this.extentsWidth:this.width>0?this.width:en(this.contents,this.height),i=Bl(this.contents),r=Fl(i,this.height,this.lineSpacingFactor);return Dl(t,this._location,e,r,this.attachmentPoint,this.rotation,this.direction)}subGetGripPoints(){return[this._location]}subMoveGripPointsAt(t,e){return ie(t,e,this._location),this}subGetOsnapPoints(t,e,i,r){A.Insertion===t&&r.push(this._location)}transformBy(t){const e=this._location.clone(),i=this._direction.lengthSq()>0?this._direction.clone().normalize():new w(Math.cos(this._rotation),Math.sin(this._rotation),0),r=new w(-i.y,i.x,i.z);r.lengthSq()===0&&r.set(0,1,0),r.normalize();const s=e.clone().add(i),a=e.clone().add(r);e.applyMatrix4(t),s.applyMatrix4(t),a.applyMatrix4(t);const o=new w(s).sub(e),c=new w(a).sub(e),l=o.length(),h=c.length();return this._location.copy(e),l>0&&(this._direction.copy(o).normalize(),this._rotation=Math.atan2(this._direction.y,this._direction.x),this._width*=l,this._extentsWidth>0&&(this._extentsWidth*=l)),h>0&&(this._height*=h),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"text",properties:[{name:"contents",type:"string",editable:!0,accessor:{get:()=>this.contents,set:t=>{this.contents=t}}},{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"attachmentPoint",type:"enum",editable:!0,options:[{label:exports.AcGiMTextAttachmentPoint[1],value:1},{label:exports.AcGiMTextAttachmentPoint[2],value:2},{label:exports.AcGiMTextAttachmentPoint[3],value:3},{label:exports.AcGiMTextAttachmentPoint[4],value:4},{label:exports.AcGiMTextAttachmentPoint[5],value:5},{label:exports.AcGiMTextAttachmentPoint[6],value:6},{label:exports.AcGiMTextAttachmentPoint[7],value:7},{label:exports.AcGiMTextAttachmentPoint[8],value:8},{label:exports.AcGiMTextAttachmentPoint[9],value:9}],accessor:{get:()=>this.attachmentPoint,set:t=>{this.attachmentPoint=t}}},{name:"drawingDirection",type:"enum",editable:!0,options:[{label:exports.AcGiMTextFlowDirection[1],value:1},{label:exports.AcGiMTextFlowDirection[2],value:2},{label:exports.AcGiMTextFlowDirection[3],value:3},{label:exports.AcGiMTextFlowDirection[4],value:4},{label:exports.AcGiMTextFlowDirection[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.resolveAt(this.styleName);if(!t)throw new Error("No valid text style found in text style table.");return t.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),this.extentsWidth>0&&t.writeDouble(42,this.extentsWidth),t.writeMTextContents(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.annotationHeight!==0&&t.writeDouble(46,this.annotationHeight),this.columnType!==0&&(t.writeInt16(75,this.columnType),t.writeInt16(76,this.columnCount),t.writeInt16(78,this.columnFlowReversed?1:0),t.writeInt16(79,this.columnAutoHeight?1:0),t.writeDouble(48,this.columnWidth),t.writeDouble(49,this.columnGutter)),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbMText");let e=this.location.x,i=this.location.y,r=this.location.z,s=this.direction.x,a=this.direction.y,o=this.direction.z,c=this.normal.x,l=this.normal.y,h=this.normal.z,u=!1;const d=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const g=t.readItem();if(!g)break;const p=Number(g.code),f=Number(g.value);switch(p){case 10:e=f;break;case 20:i=f;break;case 30:r=f;break;case 11:s=f,u=!0;break;case 21:a=f,u=!0;break;case 31:o=f,u=!0;break;case 1:case 3:d.push(String(g.value));break;case 7:this.styleName=String(g.value);break;case 40:this.height=f;break;case 41:this.width=f;break;case 42:f>0&&(this.extentsWidth=f);break;case 43:break;case 44:this.lineSpacingFactor=f;break;case 45:this.backgroundScaleFactor=f;break;case 46:this.annotationHeight=f;break;case 48:this.columnWidth=f;break;case 49:this.columnGutter=f;break;case 50:this.rotation=M.degToRad(f);break;case 71:this.attachmentPoint=f;break;case 72:this.drawingDirection=f;break;case 73:this.lineSpacingStyle=f;break;case 75:this.columnType=f;break;case 76:this.columnCount=f;break;case 78:this.columnFlowReversed=f!==0;break;case 79:this.columnAutoHeight=f!==0;break;case 90:this.backgroundFill=f!==0;break;case 63:this.backgroundFillColor=f;break;case 441:this.backgroundFillTransparency=f;break;case 101:for(;!t.atEndOfObject&&!t.atEof&&t.readItem(););break;case 210:c=f;break;case 220:l=f;break;case 230:h=f;break;case 100:return t.pushBackItem(g),this.finishMTextDxfIn(d,e,i,r,s,a,o,u,c,l,h),this}}return this.finishMTextDxfIn(d,e,i,r,s,a,o,u,c,l,h),this}finishMTextDxfIn(t,e,i,r,s,a,o,c,l,h,u){t.length>0&&(this.contents=t.join("")),this.location={x:e,y:i,z:r},c&&(this.direction={x:s,y:a,z:o});const d=new w(l,h,u);d.lengthSq()>0&&this.normal.copy(d.normalize())}};va.typeName="MText";let Ee=va;const Bp=127;var eh=(n=>(n[n.Extents=1]="Extents",n[n.Circle=2]="Circle",n[n.Circle3P=3]="Circle3P",n[n.CircularArc=4]="CircularArc",n[n.CircularArc3P=5]="CircularArc3P",n[n.Polyline=6]="Polyline",n[n.Polygon=7]="Polygon",n[n.Mesh=8]="Mesh",n[n.Shell=9]="Shell",n[n.Text=10]="Text",n[n.Text2=11]="Text2",n[n.Xline=12]="Xline",n[n.Ray=13]="Ray",n[n.AttributeColor=14]="AttributeColor",n[n.AttributeLayer=16]="AttributeLayer",n[n.AttributeLinetype=18]="AttributeLinetype",n[n.AttributeMarker=19]="AttributeMarker",n[n.AttributeFill=20]="AttributeFill",n[n.AttributeTrueColor=22]="AttributeTrueColor",n[n.AttributeLineweight=23]="AttributeLineweight",n[n.AttributeLtscale=24]="AttributeLtscale",n[n.AttributeThickness=25]="AttributeThickness",n[n.PushMatrix=29]="PushMatrix",n[n.PopMatrix=31]="PopMatrix",n[n.PolylineWithNormals=32]="PolylineWithNormals",n[n.LwPolyline=33]="LwPolyline",n[n.UnicodeText=36]="UnicodeText",n[n.UnicodeText2=38]="UnicodeText2",n[n.EllipticArc=44]="EllipticArc",n))(eh||{});const Te=w.Z_AXIS,Fp=529;function Dp(n){const t=n>>24&255;return t===Lr?{rgb:n&16777215}:t===Er?{colorIndex:256}:t===Bi?{colorIndex:0}:t===Tr?{colorIndex:n&255}:{colorIndex:n&255}}function Qr(n){return new w(n.x,n.y,n.z??0)}function Jr(n){return new b(n.x,n.y,n.z??0)}function Co(n){return{x:n[0],y:n[1],z:n[2]}}class Ps{constructor(t,e={}){this._index=8,this._colorIndex=256,this._layer="0",this._linetype=lt,this._lineweight=exports.AcGiLineWeight.ByLineWeightDefault,this._ltscale=1,this._thickness=0,this._fill=!1,this._layers=[],this._linetypes=[],this._matrices=[],this._buffer=t,this._database=e.database,this._dxfversion=e.dxfversion??"AC1015",this._encoding=e.encoding??(this._dxfversion<"AC1024"?"windows-1252":"utf-8"),this._layer=e.defaultLayer??"0",this._database&&(this._database.tables.layerTable.newIterator().toArray().forEach(i=>this._layers.push(i.name)),this._database.tables.linetypeTable.newIterator().toArray().forEach(i=>this._linetypes.push(i.name)))}get extents(){return this._extents}scanExtents(){var i;const t=this._buffer;let e=this._index;for(;e<t.length;){const r=new DataView(t.buffer,t.byteOffset+e,8),s=r.getUint32(0,!0),a=r.getUint32(4,!0);if(s<8)break;if(a===1){const o=t.subarray(e+8,e+s);return this.readExtents(o),((i=this._extents)==null?void 0:i.length)===2?[this._extents[0],this._extents[1]]:void 0}e+=s}}worldDraw(t){const e=[],i=t.subEntityTraits,r={color:i.color.clone(),lineType:i.lineType,lineTypeScale:i.lineTypeScale,lineWeight:i.lineWeight,layer:i.layer,thickness:i.thickness},s=this._buffer;let a=this._index;for(;a<s.length;){const o=new DataView(s.buffer,s.byteOffset+a,8),c=o.getUint32(0,!0),l=o.getUint32(4,!0);if(c<8)break;const h=s.subarray(a+8,a+c);this.dispatchChunk(t,e,l,h),l!==20&&(this._fill=!1),a+=c}if(i.color=r.color,i.lineType=r.lineType,i.lineTypeScale=r.lineTypeScale,i.lineWeight=r.lineWeight,i.layer=r.layer,i.thickness=r.thickness,e.length!==0)return t.group(e)}dispatchChunk(t,e,i,r){switch(i){case 1:this.readExtents(r);break;case 2:this.drawCircle(t,e,r);break;case 3:this.drawCircle3P(t,e,r);break;case 4:this.drawCircularArc(t,e,r);break;case 5:this.drawCircularArc3P(t,e,r);break;case 44:this.drawEllipticArc(t,e,r);break;case 6:this.drawPolyline(t,e,r,!1);break;case 32:this.drawPolyline(t,e,r,!0);break;case 7:this.drawPolygon(t,e,r);break;case 33:this.drawLwPolyline(t,e,r);break;case 9:this.drawShell(t,e,r);break;case 10:this.drawText(t,e,r,!1);break;case 36:this.drawText(t,e,r,!0);break;case 11:this.drawText2(t,e,r,!1);break;case 38:this.drawText2(t,e,r,!0);break;case 12:this.drawXline(t,e,r,!1);break;case 13:this.drawXline(t,e,r,!0);break;case 14:this.readAttributeColor(r);break;case 16:this.readAttributeLayer(r);break;case 18:this.readAttributeLinetype(r);break;case 20:this.readAttributeFill(r);break;case 22:this.readAttributeTrueColor(r);break;case 23:this.readAttributeLineweight(r);break;case 24:this.readAttributeLtscale(r);break;case 25:this.readAttributeThickness(r);break;case 29:this.pushMatrix(r);break;case 31:this.popMatrix();break}}applyTraits(t){const e=t.subEntityTraits;e.layer=this._layer,e.lineTypeScale=this._ltscale,e.thickness=this._thickness,e.lineWeight=this._lineweight,this._rgbColor!=null?e.color=new X(exports.AcCmColorMethod.ByColor,this._rgbColor):this._colorIndex===256?e.color=new X(exports.AcCmColorMethod.ByLayer):this._colorIndex===0?e.color=new X(exports.AcCmColorMethod.ByBlock):this._colorIndex===7?e.color=new X(exports.AcCmColorMethod.ByACI,7):e.color=new X(exports.AcCmColorMethod.ByACI,this._colorIndex),e.lineType={name:this._linetype,type:this.resolveLineStyleType(),standardFlag:0,description:"",totalPatternLength:0}}resolveLineStyleType(){return this._linetype===lt?"ByLayer":this._linetype===Jt?"ByBlock":"UserSpecified"}transformPoint(t){const e=Array.isArray(t)?Co(t):t,i=Jr(e);return this._matrices.length>0&&i.applyMatrix4(this._matrices[this._matrices.length-1]),i}transformVector(t){const e=Array.isArray(t)?Co(t):t,i=Qr(e);return this._matrices.length>0&&i.transformDirection(this._matrices[this._matrices.length-1]),!Number.isFinite(i.lengthSq())||i.lengthSq()<1e-24?Te.clone():i.normalize()}pushEntity(t,e){e&&t.push(e)}readExtents(t){const e=new Mt(t),i=e.readVertex(),r=e.readVertex();this._extents=[new b(i[0],i[1],i[2]),new b(r[0],r[1],r[2])]}readAttributeColor(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);this._rgbColor=void 0,this._colorIndex=e>256||e<0?256:e}readAttributeLayer(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);e<this._layers.length&&(this._layer=this._layers[e])}readAttributeLinetype(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);e+2<this._linetypes.length?this._linetype=this._linetypes[e+2]:e===32766?this._linetype=Jt:this._linetype=lt}readAttributeFill(t){this._fill=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0)!==0}readAttributeTrueColor(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0),i=Dp(e);this._rgbColor=i.rgb,i.colorIndex!=null&&(this._colorIndex=i.colorIndex)}readAttributeLineweight(t){const e=new DataView(t.buffer,t.byteOffset,4).getUint32(0,!0);e>Fp?this._lineweight=e-4294967296:this._lineweight=e}readAttributeLtscale(t){this._ltscale=new DataView(t.buffer,t.byteOffset,8).getFloat64(0,!0)}readAttributeThickness(t){this._thickness=new DataView(t.buffer,t.byteOffset,8).getFloat64(0,!0)}pushMatrix(t){const e=new Float64Array(t.buffer,t.byteOffset,16),i=new D().fromArray(Array.from(e));i.transpose(),this._matrices.push(i)}popMatrix(){this._matrices.length>0&&this._matrices.pop()}loadVertices(t,e){const i=new Mt(t);let r=i.readLong();e&&(r+=1);const s=[];for(;r>0;){const[o,c,l]=i.readVertex();s.push(this.transformPoint({x:o,y:c,z:l})),r-=1}let a=Te;return e&&s.length>0&&(a=Qr(s.pop())),{vertices:s,normal:a}}drawCircle(t,e,i){const r=new Mt(i),s=r.readVertex(),a=r.readFloat(),o=this.transformVector(r.readVertex());let c=Jr({x:s[0],y:s[1],z:s[2]});o.equals(Te)||(c=Lt(c,o)),c=this.transformPoint(c);const l=Ti(o),h=new Zt(de(c,o),a,0,V,o,l);this.applyTraits(t),this.pushEntity(e,t.circularArc(h))}drawCircle3P(t,e,i){const r=new Mt(i),s=this.transformPoint(r.readVertex()),a=this.transformPoint(r.readVertex()),o=this.transformPoint(r.readVertex()),c=Zt.computeCenterPoint(s,a,o);if(!c)return;const l=c.distanceTo(s),h=new Zt(c,l,0,V,Te);this.applyTraits(t),this.pushEntity(e,t.circularArc(h))}drawCircularArc(t,e,i){const r=new Mt(i),s=r.readVertex(),a=r.readFloat(),o=r.readVertex(),c=r.readVertex(),l=r.readFloat(),h=this.transformVector(o),u=Jr({x:s[0],y:s[1],z:s[2]}),d=Qr({x:c[0],y:c[1],z:c[2]});this._matrices.length>0&&d.transformDirection(this._matrices[this._matrices.length-1]);const g=Number.isFinite(d.lengthSq())&&d.lengthSq()>=1e-24?d.normalize():Ti(h),p=0,f=l,m=new Zt(this.transformPoint(u),a,p,f,h,g);this.applyTraits(t),this.pushEntity(e,t.circularArc(m))}drawCircularArc3P(t,e,i){const r=new Mt(i),s=this.transformPoint(r.readVertex()),a=this.transformPoint(r.readVertex()),o=this.transformPoint(r.readVertex()),c=Zt.computeCenterPoint(s,o,a);if(!c)return;const l=c.distanceTo(s),h=ce(c,s,Te),u=ce(c,o,Te),d=new Zt(c,l,h,u,Te);this.applyTraits(t),this.pushEntity(e,t.circularArc(d))}drawEllipticArc(t,e,i){const r=new Mt(i),s=this.transformPoint(r.readVertex()),a=this.transformVector(r.readVertex()),o=r.readFloat(),c=r.readFloat(),l=r.readFloat(),h=r.readFloat(),u=r.readFloat(),d=de({x:Math.cos(u)*o,y:Math.sin(u)*o,z:0},a),g=new Cn(s,a,d,o,c,l,h);this.applyTraits(t),this.pushEntity(e,t.ellipticalArc(g))}drawPolyline(t,e,i,r){var a,o;const{vertices:s}=this.loadVertices(i,r);if(s.length!==0){if(s.length===1){this.applyTraits(t);const c=((a=this._database)==null?void 0:a.pdmode)??0,l=((o=this._database)==null?void 0:o.pdsize)??0;this.pushEntity(e,t.point(s[0],{displayMode:c,displaySize:l}));return}this.applyTraits(t),this.pushEntity(e,t.lines(s))}}drawPolygon(t,e,i){const{vertices:r}=this.loadVertices(i,!1);if(r.length<2)return;if(this._fill){const a=new q(r.map(l=>({x:l.x,y:l.y})),!0),o=new Vt;o.add(a);const c=t.subEntityTraits;c.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},c.drawOrder=-1,this.applyTraits(t),this.pushEntity(e,t.area(o));return}const s=[...r,r[0]];this.applyTraits(t),this.pushEntity(e,t.lines(s))}drawLwPolyline(t,e,i){const r=new ml(i,this._dxfversion,this._encoding);let s=0,a=!1;r.readUnsignedLong();const o=r.readBitShort();o&8&&(s=r.readBitDouble()),o&512&&(a=!0);const c=r.readBitLong();if(c<=0)return;const l=o&16?r.readBitLong():0;this._dxfversion>="AC1024"&&(o&1024&&r.readBitLong(),o&32&&r.readBitLong());const h=r.readRawDouble(2),u=[this.transformPoint({x:h[0],y:h[1],z:s})];let d=h;for(let g=1;g<c;g++){const p=r.readBitDoubleDefault(1,d[0]),f=r.readBitDoubleDefault(1,d[1]);d=[p,f],u.push(this.transformPoint({x:p,y:f,z:s}))}for(let g=0;g<l;g++)r.readBitDouble();a&&u.length>1&&u.push(u[0].clone()),this.applyTraits(t),this.pushEntity(e,t.lines(u))}drawShell(t,e,i){const r=new Mt(i),s=r.readLong(),a=[];for(let h=0;h<s;h++){const[u,d,g]=r.readVertex();a.push(this.transformPoint({x:u,y:d,z:g}))}const o=r.readLong(),c=[];let l=0;for(;l<o;){const h=Math.abs(r.readSignedLong());l+=1+h;const u=[];for(let g=0;g<h;g++)u.push(r.readLong());const d=u.map(g=>a[g]).filter(Boolean);if(d.length>=3)for(let g=0;g<d.length;g++)c.push(d[g]),c.push(d[(g+1)%d.length])}c.length!==0&&(this.applyTraits(t),this.pushEntity(e,t.lines(c)))}drawText(t,e,i,r){const s=new Mt(i),a=this.transformPoint(s.readVertex()),o=this.transformVector(s.readVertex()),c=this.transformVector(s.readVertex()),[l,h,u]=s.readStruct([8,8,8]),d=r?s.readPaddedUnicodeString():s.readPaddedString(this._encoding);this.drawTextPrimitive(t,e,{insert:a,normal:o,textDirection:c,text:d,height:l,widthFactor:h,obliqueAngle:u})}drawText2(t,e,i,r){const s=new Mt(i),a=this.transformPoint(s.readVertex()),o=this.transformVector(s.readVertex()),c=this.transformVector(s.readVertex()),l=r?s.readPaddedUnicodeString():s.readPaddedString(this._encoding);s.readSignedLong(),s.readSignedLong();const[h,u,d]=s.readStruct([8,8,8]);s.readFloat(),this.drawTextPrimitive(t,e,{insert:a,normal:o,textDirection:c,text:l,height:h,widthFactor:u,obliqueAngle:d})}drawTextPrimitive(t,e,i){const r=Math.atan2(i.textDirection.y,i.textDirection.x),s={text:i.text,height:i.height,width:1/0,widthFactor:i.widthFactor,position:i.insert,rotation:r*180/Math.PI,drawingDirection:exports.AcGiMTextFlowDirection.BOTTOM_TO_TOP,attachmentPoint:exports.AcGiMTextAttachmentPoint.BaselineLeft},a={name:Z,standardFlag:0,fixedTextHeight:0,widthFactor:i.widthFactor,obliqueAngle:i.obliqueAngle*180/Math.PI,textGenerationFlag:0,lastHeight:i.height,font:"txt",bigFont:""};this.applyTraits(t),this.pushEntity(e,t.mtext(s,a))}drawXline(t,e,i,r){const s=new Mt(i),a=this.transformPoint(s.readVertex()),o=this.transformPoint(s.readVertex()),c=new w().subVectors(o,a);if(c.lengthSq()===0)return;const l=1e6,h=r?a.clone().add(c.normalize().multiplyScalar(l)):a.clone().sub(c.normalize().multiplyScalar(l)),u=o.clone().add(c.normalize().multiplyScalar(l));this.applyTraits(t),this.pushEntity(e,t.lines([h,u]))}}function Yp(n,t){if(!(t!=null&&t.length))return;const e=Ji(t);return n!=null&&n>0&&e.length>=n?e.subarray(0,n):e}const Xp="ASM_Data";function Is(n){return String(n).trim().toUpperCase()}function zp(n){let t,e;const i={};for(;!n.atEndOfObject&&!n.atEof;){const r=n.readItem();if(!r)break;switch(Number(r.code)){case 320:t=Is(String(r.value));break;case 2:e=String(r.value),i[e]??(i[e]=[]);break;case 310:e&&(r.value instanceof Uint8Array?i[e].push(r.value):i[e].push(String(r.value)));break}}return{ownerHandle:t,hexChunks:i[Xp]??[]}}function jp(n){const t={};for(;!n.atEof;){const e=n.peekItem();if(!e)break;if(Number(e.code)!==0){n.readItem();continue}const i=String(e.value).toUpperCase();if(i==="ENDSEC"||i==="EOF"){n.readItem();break}if(n.readItem(),i==="ACDSRECORD"){const r=zp(n);if(r.ownerHandle&&r.hexChunks.length>0){const s=Ji(r.hexChunks);s.length>0&&(t[r.ownerHandle]=s)}}else n.skipToEndOfObject()}return{byOwnerHandle:t}}function ih(n,t){for(;!n.atEof;){const e=n.peekItem();if(!e)break;if(Number(e.code)===0){if(String(e.value).toUpperCase()==="ENDSEC"){n.readItem();break}break}if(n.readItem(),Number(e.code)!==9)continue;const i=String(e.value).toUpperCase();Vp(n,t,i)}}function Vp(n,t,e){switch(e){case"$ACADVER":{const i=Gt(n);i&&(t.version=i);break}case"$CECOLOR":{const i=it(n);t.cecolor.colorIndex=i??256;break}case"$ANGBASE":t.angbase=it(n)??0;break;case"$ANGDIR":t.angdir=it(n)??0;break;case"$AUNITS":{const i=it(n);i!=null&&(t.aunits=i);break}case"$AUPREC":{const i=it(n);i!=null&&(t.auprec=i);break}case"$LUNITS":{const i=it(n);i!=null&&(t.lunits=i);break}case"$LUPREC":{const i=it(n);i!=null&&(t.luprec=i);break}case"$UNITMODE":{const i=it(n);i!=null&&(t.unitmode=i);break}case"$MEASUREMENT":{const i=it(n);i!=null&&(t.measurement=i);break}case"$CELTYPE":t.celtype=Gt(n)||lt;break;case"$CETRANSPARENCY":{const i=Gt(n)||"ByLayer";ft.instance().setVar(E.CETRANSPARENCY,i,t);break}case"$CELTSCALE":t.celtscale=it(n)??1;break;case"$CELWEIGHT":{const i=it(n);i!=null&&(t.celweight=i);break}case"$LWDISPLAY":t.lwdisplay=(it(n)??0)!==0;break;case"$TILEMODE":t.tilemode=(it(n)??1)!==0;break;case"$PSLTSCALE":t.psltscale=(it(n)??1)!==0;break;case"$CMLSTYLE":case"CMLSTYLE":t.cmlstyle=Gt(n)||le;break;case"$CMLSCALE":case"CMLSCALE":{const i=it(n);i!=null&&Number.isFinite(i)&&(t.cmlscale=i);break}case"$CMLEADERSTYLE":case"CMLEADERSTYLE":t.cmleaderstyle=Gt(n)||he;break;case"$HPLAYER":case"HPLAYER":t.hplayer=Gt(n)||".";break;case"$LTSCALE":t.ltscale=it(n)??1;break;case"$EXTMAX":{const i=Mo(n);i&&(t.extmax=i);break}case"$EXTMIN":{const i=Mo(n);i&&(t.extmin=i);break}case"$INSUNITS":{const i=it(n);i!=null&&(t.insunits=i);break}case"$OSMODE":t.osmode=it(n)??0;break;case"$ORTHOMODE":t.orthomode=it(n)??0;break;case"$PDMODE":t.pdmode=it(n)??0;break;case"$PDSIZE":t.pdsize=it(n)??0;break;case"$TEXTSTYLE":t.textstyle=Gt(n)||Z;break;case"$DIMSTYLE":t.dimstyle=Gt(n)||Z;break;case"$CLAYER":t.clayer=Gt(n)||"0";break;case"$HANDSEED":{const i=Gt(n);i&&t.initializeHandleSeed(i);break}default:Gp(n);break}}function Gt(n){const t=n.readItem();if(t){if(Number(t.code)===9||Number(t.code)===0){n.pushBackItem(t);return}return String(t.value)}}function it(n){const t=n.readItem();if(!t)return;if(Number(t.code)===9||Number(t.code)===0){n.pushBackItem(t);return}const e=Number(t.value);return Number.isFinite(e)?e:void 0}function Mo(n){let t=0,e=0,i=0,r=!1;for(;!n.atEof;){const s=n.peekItem();if(!s)break;const a=Number(s.code);if(a===9||a===0)break;n.readItem();const o=Number(s.value);a===10?(t=o,r=!0):a===20?(e=o,r=!0):a===30&&(i=o,r=!0)}return r?new b(t,e,i):void 0}function Gp(n){for(;!n.atEof;){const t=n.peekItem();if(!t)break;const e=Number(t.code);if(e===9||e===0)break;n.readItem()}}class nh{constructor(t){this._expression=t}get expression(){return this._expression}}var rh=(n=>(n[n.Cancel=0]="Cancel",n[n.Ok=1]="Ok",n))(rh||{});class Mr{constructor(){this._name="",this._filterExpression="",this._nestedFilters=[],this._parent=null,this._allowDelete=!0,this._allowRename=!0,this._dynamicallyGenerated=!1,this._isProxy=!1}get name(){return this._name}setName(t){return!this.allowRename()&&this._name.length>0?!1:(this._name=t,!0)}set name(t){this.setName(t)}get filterExpression(){return this._filterExpression}setFilterExpression(t){return this.isIdFilter()?!1:(this._filterExpression=t??"",!0)}set filterExpression(t){this.setFilterExpression(t)}filterExpressionTree(){return this.isIdFilter()||!this._filterExpression?null:new nh(this._filterExpression)}getNestedFilters(){return this._nestedFilters}get nestedFilters(){return this._nestedFilters}parent(){return this._parent}isIdFilter(){return!1}allowNested(){return!0}allowDelete(){return this._allowDelete}setAllowDelete(t){this._allowDelete=t}allowRename(){return this._allowRename}setAllowRename(t){this._allowRename=t}dynamicallyGenerated(){return this._dynamicallyGenerated}setDynamicallyGenerated(t){this._dynamicallyGenerated=t}isProxy(){return this._isProxy}setIsProxy(t){this._isProxy=t}addNested(t){return!t||t===this||!this.allowNested()||!(this._parent==null)&&!this.isIdFilter()&&t.isIdFilter()||this._nestedFilters.includes(t)?!1:(t._parent&&t._parent.removeNested(t),t._parent=this,this._nestedFilters.push(t),!0)}removeNested(t){const e=this._nestedFilters.indexOf(t);return e<0?!1:(this._nestedFilters.splice(e,1),t._parent===this&&(t._parent=null),!0)}generateNested(){return!1}compareTo(t){return t?this.isIdFilter()===t.isIdFilter()&&this._name===t._name&&this._filterExpression===t._filterExpression:!1}filter(t){return t?this._filterExpression?Up(this._filterExpression,t):!0:!1}showEditor(){return 0}}function Up(n,t){const e=n.trim();return e?Oo(e,"OR").some(r=>Oo(r,"AND").every(a=>Hp(a,t))):!0}function Oo(n,t){const e=new RegExp(`\\s+${t}\\s+`,"i");return n.split(e).map(i=>i.trim()).filter(i=>i.length>0)}function Hp(n,t){var a;const e=n.trim().match(/^([A-Za-z_]+)\s*(==|=)\s*"?(.*?)"?\s*$/);if(!e)return!1;const i=e[1].toUpperCase(),r=e[3],s=$p(r);switch(i){case"NAME":return Wp(t.name,r);case"LOCKED":return s!=null?t.isLocked===s:!1;case"FROZEN":return s!=null?t.isFrozen===s:!1;case"OFF":return s!=null?t.isOff===s:!1;case"PLOT":return s!=null?t.isPlottable===s:!1;case"COLOR":{const o=(a=t.color)==null?void 0:a.colorIndex;return o!=null&&String(o)===r}case"LINETYPE":return t.linetype.localeCompare(r,void 0,{sensitivity:"accent"})===0;default:return!1}}function Wp(n,t){return/[*?]/.test(t)?new RegExp(`^${t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")}$`,"i").test(n):n.localeCompare(t,void 0,{sensitivity:"accent"})===0}function $p(n){const t=n.trim().toLowerCase();return t==="true"||t==="1"?!0:t==="false"||t==="0"?!1:null}class ue{constructor(t,e){this._root=t??ue.createDefaultRoot(),this._current=e===void 0?this._root:e}static createDefaultRoot(){const t=new Mr;return t.setName("All"),t.setAllowDelete(!1),t.setAllowRename(!1),t.setFilterExpression(""),t}get root(){return this._root}get current(){return this._current}set current(t){this._current=t}clone(){return new ue(this._root,this._current)}}class sh extends Mr{constructor(){super(),this._layerIds=[]}isIdFilter(){return!0}layerIds(){return this._layerIds}get layerIdList(){return this._layerIds}addLayerId(t){return!t||this._layerIds.includes(t)?!1:(this._layerIds.push(t),!0)}removeLayerId(t){const e=this._layerIds.indexOf(t);return e<0?!1:(this._layerIds.splice(e,1),!0)}filter(t){return t?this._layerIds.includes(t.objectId):!1}setFilterExpression(t){return!1}}const Or="ACAD_LAYERFILTERS",ai="ACLYDICTIONARY";function ah(n){const t=ue.createDefaultRoot(),e=new ue(t,t),i=No(n,ai),r=No(n,Or);if(i){for(const[s,a]of Object.entries(i.entries)){const o=Es(n,a,s);o&&t.addNested(o)}return e}if(r)for(const[s,a]of Object.entries(r.entries)){const o=Es(n,a,s);o&&t.addNested(o)}return e}function oh(n){const t=[];for(const e of n.root.getNestedFilters())t.push(hh(e));return{nodes:t}}function ch(n){const t=new Re;for(const e of n)t.add({code:e.code,value:e.value});return t}function qp(n){return n?n.toArray().map(t=>({code:Number(t.code),value:t.value})):[]}function No(n,t){let e;for(const i of n.dictionaries.values()){const r=i.entries[t];if(!r)continue;const s=n.dictionaries.get(oe(r));if(!s)continue;if(!(i.ownerObjectId?n.xrecords.has(oe(i.ownerObjectId)):!1))return s;e=s}return e}function Es(n,t,e){const i=n.xrecords.get(oe(t));if(!i)return;const r=lh(i.data,e),s=r.isIdFilter?new sh:new Mr;if(s.setAllowRename(!0),s.setName(r.name||e),!r.isIdFilter)s.setFilterExpression(r.filterExpression);else{const a=s;for(const o of r.layerIds)a.addLayerId(o)}for(const a of Kp(n,i)){const o=Es(n,a.handle,a.key);o&&s.addNested(o)}return s}function Kp(n,t){const e=[],i=new Set,r=oe(t.handle),s=t.extensionDictionaryId?oe(t.extensionDictionaryId):void 0,a=(o,c)=>{const l=oe(c);i.has(l)||(i.add(l),e.push({key:o,handle:c}))};for(const o of n.dictionaries.values()){const c=o.ownerObjectId?oe(o.ownerObjectId):void 0;if(!c||!(c===r||c===s))continue;const h=o.entries[ai];if(h){const u=n.dictionaries.get(oe(h));if(u){for(const[d,g]of Object.entries(u.entries))a(d,g);continue}}for(const[u,d]of Object.entries(o.entries))u===ai||u===Or||a(u,d)}return e}function lh(n,t=""){const e=[],i=[];let r=0,s,a,o;for(const p of n){const f=Number(p.code),m=p.value;f===1&&typeof m=="string"?e.push(m):f===300&&typeof m=="string"?a=m:f===301&&typeof m=="string"?o=m:f===70||f===90?r=Number(m)||0:f===290||f===280?s=Number(m)===1:(f===330||f===340||f===350||f===360)&&m!=null&&String(m).length>0&&i.push(oe(String(m)))}const c=e[0],h=a||(c==="AcLyLayerFilter"||c==="AcLyLayerGroup"?void 0:c)||t,u=e[1]??"";let d=o??u;!o&&d&&d!=="*"&&!/==/.test(d)&&(d=`NAME=="${d}"`);const g=o!=null&&o.length>0?!1:s===!0&&i.length>0?!0:i.length>0&&(d.length===0||d==="*");return{name:h,filterExpression:g?"":d,flags:r,layerIds:i,isIdFilter:g}}function hh(n){const t=n.isIdFilter(),e=uh(n),i=n.getNestedFilters().map(s=>hh(s));return{key:n.name||(t?"Group":"Filter"),isIdFilter:t,data:e,children:i}}function uh(n){const t=[];if(t.push({code:1,value:n.name}),n.isIdFilter()){t.push({code:1,value:""}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:70,value:0}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:290,value:1});const e=n;for(const i of e.layerIds())t.push({code:330,value:i})}else t.push({code:1,value:n.filterExpression||"*"}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:70,value:0}),t.push({code:1,value:"*"}),t.push({code:1,value:"*"}),t.push({code:290,value:0});return t}function oe(n){return n.trim().toUpperCase()}class dh extends bt{constructor(){super(...arguments),this._name="",this._unnamed=!1,this._selectable=!0,this._entityIds=[]}get name(){return this._name}set name(t){this._name=t}get unnamed(){return this._unnamed}set unnamed(t){this._unnamed=t}get selectable(){return this._selectable}set selectable(t){this._selectable=t}get entityIds(){return this._entityIds}set entityIds(t){this._entityIds=[...t]}addEntityId(t){this._entityIds.push(t)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbGroup"),this.name&&t.writeString(300,this.name),t.writeInt16(70,this.unnamed?1:0),t.writeInt16(71,this.selectable?1:0);for(const e of this._entityIds)t.writeObjectId(340,e);return this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbGroup"),this._entityIds=[];!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}switch(i){case 300:this._name=String(e.value);break;case 70:this._unnamed=Number(e.value)!==0;break;case 71:this._selectable=Number(e.value)!==0;break;case 340:this._entityIds.push(String(e.value));break}}return this}}class gh extends bt{constructor(){super(),this._boundaryVertices=[],this._clipBoundaryDisplayEnabled=!1,this._frontClippingEnabled=!1,this._backClippingEnabled=!1}get boundaryVertices(){return this._boundaryVertices}set boundaryVertices(t){this._boundaryVertices=t.map(e=>e.clone())}get clipBoundaryNormal(){return this._clipBoundaryNormal}set clipBoundaryNormal(t){this._clipBoundaryNormal=t==null?void 0:t.clone()}get clipBoundaryOrigin(){return this._clipBoundaryOrigin}set clipBoundaryOrigin(t){this._clipBoundaryOrigin=t==null?void 0:t.clone()}get clipBoundaryDisplayEnabled(){return this._clipBoundaryDisplayEnabled}set clipBoundaryDisplayEnabled(t){this._clipBoundaryDisplayEnabled=t}get frontClippingEnabled(){return this._frontClippingEnabled}set frontClippingEnabled(t){this._frontClippingEnabled=t}get frontClippingDistance(){return this._frontClippingDistance}set frontClippingDistance(t){this._frontClippingDistance=t}get backClippingEnabled(){return this._backClippingEnabled}set backClippingEnabled(t){this._backClippingEnabled=t}get backClippingDistance(){return this._backClippingDistance}set backClippingDistance(t){this._backClippingDistance=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbFilter"),this._boundaryVertices.length>0&&(t.writeInt16(70,this._boundaryVertices.length),this._boundaryVertices.forEach(e=>t.writePoint2d(10,e)),t.writeVector3d(210,this._clipBoundaryNormal),t.writePoint3d(11,this._clipBoundaryOrigin),t.writeInt16(71,this._clipBoundaryDisplayEnabled?1:0),t.writeInt16(72,this._frontClippingEnabled?1:0),this._frontClippingEnabled&&this._frontClippingDistance!=null&&t.writeDouble(40,this._frontClippingDistance),t.writeInt16(73,this._backClippingEnabled?1:0),this._backClippingEnabled&&this._backClippingDistance!=null&&t.writeDouble(41,this._backClippingDistance)),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbFilter");let e=null,i=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const r=t.readItem();if(!r)break;const s=Number(r.code);if(s===100){t.pushBackItem(r);break}const a=Number(r.value);switch(s){case 70:break;case 10:e&&this._boundaryVertices.push(new L(e.x,e.y)),e={x:a,y:0};break;case 20:e&&(e.y=a);break;case 210:this._clipBoundaryNormal=this._clipBoundaryNormal??new b,this._clipBoundaryNormal.x=a;break;case 220:this._clipBoundaryNormal&&(this._clipBoundaryNormal.y=a);break;case 230:this._clipBoundaryNormal&&(this._clipBoundaryNormal.z=a);break;case 11:this._clipBoundaryOrigin=this._clipBoundaryOrigin??new b,this._clipBoundaryOrigin.x=a;break;case 21:this._clipBoundaryOrigin&&(this._clipBoundaryOrigin.y=a);break;case 31:this._clipBoundaryOrigin&&(this._clipBoundaryOrigin.z=a);break;case 71:this._clipBoundaryDisplayEnabled=a!==0;break;case 72:this._frontClippingEnabled=a!==0;break;case 73:this._backClippingEnabled=a!==0;break;case 40:i||(this._frontClippingDistance=a,i=!0);break;case 41:this._backClippingDistance=a;break}}return e&&this._boundaryVertices.push(new L(e.x,e.y)),this}}class fh extends gh{constructor(){super(),this._layerNames=[]}get layerNames(){return this._layerNames}set layerNames(t){this._layerNames=[...t]}add(t){const e=t==null?void 0:t.trim();return!e||this._layerNames.includes(e)?!1:(this._layerNames.push(e),!0)}getAt(t){if(t<0||t>=this._layerNames.length)throw new Error("The layer index is out of range!");return this._layerNames[t]}remove(t){const e=this._layerNames.indexOf(t);return e<0?!1:(this._layerNames.splice(e,1),!0)}layerCount(){return this._layerNames.length}indexClass(){return"AcDbLayerIndex"}isValid(){return this._layerNames.some(t=>t.length>0)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayerFilter");for(const e of this._layerNames)t.writeString(8,e);return this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbLayerFilter");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;switch(Number(e.code)){case 8:this.add(String(e.value));break;case 100:return t.pushBackItem(e),this}}return this}}class ph extends bt{constructor(){super(),this._lastUpdatedAt=0,this._lastUpdatedAtU=0,this._isUptoDate=!1,this._objectBeingIndexedId=""}get lastUpdatedAt(){return this._lastUpdatedAt}set lastUpdatedAt(t){this._lastUpdatedAt=t}get lastUpdatedAtU(){return this._lastUpdatedAtU}set lastUpdatedAtU(t){this._lastUpdatedAtU=t}get isUptoDate(){return this._isUptoDate}set isUptoDate(t){this._isUptoDate=t}objectBeingIndexedId(){return this._objectBeingIndexedId}setObjectBeingIndexedId(t){this._objectBeingIndexedId=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbIndex"),t.writeDouble(40,this.lastUpdatedAt),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbIndex");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;switch(Number(e.code)){case 40:this.lastUpdatedAt=Number(e.value),this.lastUpdatedAtU=this.lastUpdatedAt;break;case 100:return t.pushBackItem(e),this}}return this}}class mh extends ph{constructor(){super(),this._layerNames=[],this._idBufferIds=[],this._idBufferEntryCounts=[]}get layerNames(){return this._layerNames}set layerNames(t){this._layerNames=[...t]}get idBufferIds(){return this._idBufferIds}set idBufferIds(t){this._idBufferIds=[...t]}get idBufferEntryCounts(){return this._idBufferEntryCounts}set idBufferEntryCounts(t){this._idBufferEntryCounts=[...t]}get entries(){const t=Math.max(this._layerNames.length,this._idBufferIds.length,this._idBufferEntryCounts.length),e=[];for(let i=0;i<t;i++)e.push({layerName:this._layerNames[i]??"",idBufferId:this._idBufferIds[i]??"",idBufferEntryCount:this._idBufferEntryCounts[i]??0});return e}set entries(t){this._layerNames=t.map(e=>e.layerName),this._idBufferIds=t.map(e=>e.idBufferId),this._idBufferEntryCounts=t.map(e=>e.idBufferEntryCount)}compute(t,e){if(e&&this.setObjectBeingIndexedId(e.objectId),t){this._layerNames=[];for(const i of t.newIterator())this._layerNames.push(i.name)}return this.lastUpdatedAt=Date.now(),this.lastUpdatedAtU=Date.now(),this.isUptoDate=!0,!0}newIterator(t){return null}rebuildFull(t){return this.lastUpdatedAt=Date.now(),this.lastUpdatedAtU=Date.now(),this.isUptoDate=!0,!0}rebuildModified(t){return this.lastUpdatedAt=Date.now(),this.lastUpdatedAtU=Date.now(),this.isUptoDate=!0,!0}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLayerIndex");const e=Math.max(this._layerNames.length,this._idBufferIds.length,this._idBufferEntryCounts.length);for(let i=0;i<e;i++)this._layerNames[i]!=null&&t.writeString(8,this._layerNames[i]),this._idBufferIds[i]&&t.writeHandle(360,this._idBufferIds[i]),this._idBufferEntryCounts[i]!=null&&t.writeInt32(90,this._idBufferEntryCounts[i]);return this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbLayerIndex");const e=[],i=[],r=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const s=t.readItem();if(!s)break;switch(Number(s.code)){case 8:e.push(String(s.value));break;case 360:i.push(String(s.value));break;case 90:r.push(Number(s.value));break;case 100:return t.pushBackItem(s),this.layerNames=e,this.idBufferIds=i,this.idBufferEntryCounts=r,this.isUptoDate=!0,this}}return this.layerNames=e,this.idBufferIds=i,this.idBufferEntryCounts=r,this.isUptoDate=!0,this}}class ca extends bt{constructor(){super(),this._styleName="STANDARD",this._flags=0,this._description="",this._fillColor=new X,this._startAngle=90,this._endAngle=90,this._elements=[]}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get flags(){return this._flags}set flags(t){this._flags=t}get description(){return this._description}set description(t){this._description=t}get fillColor(){return this._fillColor}set fillColor(t){this._fillColor.copy(t)}get startAngle(){return this._startAngle}set startAngle(t){this._startAngle=t}get endAngle(){return this._endAngle}set endAngle(t){this._endAngle=t}get elementCount(){return this._elements.length}get elements(){return this._elements.map(t=>({offset:t.offset,color:t.color.clone(),lineType:t.lineType}))}set elements(t){this._elements=t.map(e=>({offset:e.offset,color:e.color.clone(),lineType:e.lineType}))}addElement(t){this._elements.push({offset:t.offset,color:t.color.clone(),lineType:t.lineType})}removeElementAt(t){if(t<0||t>=this._elements.length)throw new Error("The element index is out of range!");this._elements.splice(t,1)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMlineStyle"),t.writeString(2,this.styleName),t.writeInt16(70,this.flags),t.writeString(3,this.description),t.writeCmColor(this.fillColor),t.writeDouble(51,this.startAngle),t.writeDouble(52,this.endAngle),t.writeInt16(71,this.elementCount),this._elements.forEach(e=>{t.writeDouble(49,e.offset),t.writeCmColor(e.color),t.writeString(6,e.lineType)}),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbMlineStyle");const e=[];let i,r=0;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const s=t.readItem();if(!s)break;const a=Number(s.code),o=Number(s.value);switch(a){case 2:this.styleName=String(s.value);break;case 70:this.flags=o;break;case 3:this.description=String(s.value);break;case 51:this.startAngle=o;break;case 52:this.endAngle=o;break;case 71:r=o;break;case 49:{i={offset:o,color:new X,lineType:"BYLAYER"},i.color.colorIndex=256,e.push(i);break}case 62:i?i.color.colorIndex=o:this.fillColor.colorIndex=o;break;case 420:i?i.color.setRGBValue(o):this.fillColor.setRGBValue(o);break;case 6:i&&(i.lineType=String(s.value));break;case 100:return t.pushBackItem(s),this.finishMlineElements(e,r),this}}return this.finishMlineElements(e,r),this}finishMlineElements(t,e){const i=Math.max(e,t.length);if(i<=0){this.elements=[];return}this.elements=Array.from({length:i},(r,s)=>{const a=t[s];if(a)return a;const o=new X;return o.colorIndex=256,{offset:0,color:o,lineType:"BYLAYER"}})}}class yh extends bt{constructor(){super(),this._isLoaded=!0,this._resolutionUnits=0,this._sourceFileName="",this._classVersion=0,this._imageSize=new L,this._pixelSize=new L(1,1)}get sourceFileName(){return this._sourceFileName}set sourceFileName(t){this._sourceFileName=t}get classVersion(){return this._classVersion}set classVersion(t){this._classVersion=t}get imageSize(){return this._imageSize}set imageSize(t){this._imageSize.copy(t)}get pixelSize(){return this._pixelSize}set pixelSize(t){this._pixelSize.copy(t)}get isLoaded(){return this._isLoaded}set isLoaded(t){this._isLoaded=t}get resolutionUnits(){return this._resolutionUnits}set resolutionUnits(t){this._resolutionUnits=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRasterImageDef"),t.writeInt32(90,this.classVersion),t.writeString(1,this.sourceFileName),t.writePoint2d(10,this.imageSize),t.writeDouble(11,this.pixelSize.x),t.writeDouble(12,this.pixelSize.y),t.writeInt16(280,this.isLoaded?1:0),t.writeInt16(281,this.resolutionUnits),this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbRasterImageDef");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code),r=Number(e.value);switch(i){case 1:this.sourceFileName=String(e.value);break;case 90:this.classVersion=r;break;case 10:this.imageSize.x=r;break;case 20:this.imageSize.y=r;break;case 11:this.pixelSize.x=r;break;case 12:this.pixelSize.y=r;break;case 280:this.isLoaded=r!==0;break;case 281:this.resolutionUnits=r;break;case 100:return t.pushBackItem(e),this}}return this}}class bh extends bt{constructor(){super(...arguments),this._entityIds=[]}get entityIds(){return this._entityIds}set entityIds(t){this._entityIds=[...t]}addEntityId(t){this._entityIds.push(t)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbSortentsTable");for(const e of this._entityIds)t.writeObjectId(331,e);return this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbSortentsTable"),this._entityIds=[];!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;const i=Number(e.code);if(i===100){t.pushBackItem(e);break}switch(i){case 331:this._entityIds.push(String(e.value));break}}return this}}var _h=(n=>(n[n.NotApplicable=0]="NotApplicable",n[n.Ignore=1]="Ignore",n[n.Replace=2]="Replace",n[n.XrefMangleName=3]="XrefMangleName",n[n.MangleName=4]="MangleName",n))(_h||{});class la extends bt{constructor(){super(...arguments),this._data=null}get data(){return this._data}set data(t){this._data=t}clear(){var t;(t=this._data)==null||t.clear()}clone(){return super.clone()}getDuplicateRecordCloning(){return this._cloningFlag??0}setDuplicateRecordCloning(t){this._cloningFlag=t}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbXrecord"),t.writeInt16(280,this._cloningFlag??1),t.writeResultBuffer(this.data),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbXrecord");const e=new Re;for(;!t.atEndOfObject&&!t.atEof;){const i=t.readItem();if(!i)break;const r=Number(i.code);if(r===1001||r>=1e3&&r<=1071){t.pushBackItem(i);break}if(r===100){t.pushBackItem(i);break}switch(r){case 280:this._cloningFlag=Number(i.value);break;default:e.add({code:i.code,value:i.value});break}}return this._data=e.length>0?e:null,this}}const Et=n=>n?n.trim().toUpperCase():"";class xh{constructor(t){this._db=t,this._dictionaries=new Map,this._xrecords=new Map,this._unknownObjectCount=0}get unknownObjectCount(){return this._unknownObjectCount}read(t){for(this._unknownObjectCount=0;!t.atEof;){const e=t.peekItem();if(!e)break;if(Number(e.code)!==0){t.readItem();continue}const i=String(e.value).toUpperCase();if(i==="ENDSEC"){t.readItem();break}t.readItem(),this.readObject(t,i)}this.finishNamedObjectDictionaries(),this.finishLayerFilterTree(),this.linkLayoutsToBlockTableRecords(),this._db.objects.layout.numEntries===0&&this._db.createDefaultData({layout:!0})}readObject(t,e){switch(e){case"LAYOUT":{const i=new tn;i.dxfIn(t),i.layoutName&&this._db.objects.layout.setAt(i.layoutName,i);break}case"IMAGEDEF":{const i=new yh;i.dxfIn(t),this._db.objects.imageDefinition.setAt(i.objectId,i);break}case"LAYER_FILTER":{const i=new fh;i.dxfIn(t),this._db.objects.layerFilter.setAt(i.objectId,i);break}case"LAYER_INDEX":{const i=new mh;i.dxfIn(t),this._db.objects.layerIndex.setAt(i.objectId,i);break}case"MLEADERSTYLE":{const i=new Cr;i.dxfIn(t),this._db.objects.mleaderStyle.setAt(i.objectId,i);break}case"MLINESTYLE":{const i=new ca;i.dxfIn(t),this._db.objects.mlineStyle.setAt(i.styleName||i.objectId,i);break}case"GROUP":{const i=new dh;i.dxfIn(t);const r=i.name||i.objectId;this._db.objects.group.setAt(r,i);break}case"SORTENTSTABLE":{const i=new bh;i.dxfIn(t),this._db.objects.sortentsTable.setAt(i.objectId,i);break}case"DICTIONARY":{const i=this.readPersistDictionary(t);i.handle&&this._dictionaries.set(Et(i.handle),i);break}case"XRECORD":{const i=new la;i.dxfIn(t);const r=Et(i.objectId);if(r){this._db.objects.xrecord.setAt(r,i);const s={handle:r,ownerObjectId:Et(i.ownerId),data:i.data?i.data.toArray().map(a=>({code:Number(a.code),value:a.value})):[]};i.extensionDictionary&&(s.extensionDictionaryId=Et(i.extensionDictionary)),this._xrecords.set(r,s)}break}default:this._unknownObjectCount+=1,t.skipToEndOfObject();break}}finishNamedObjectDictionaries(){if(this._dictionaries.size===0)return;let t;for(const s of this._dictionaries.values())if(!s.ownerObjectId||s.ownerObjectId==="0"){t=s;break}if(!(t!=null&&t.handle))return;const e=this._db.objects.dictionary;e.objectId=t.handle,e.ownerId="0";const i={ACAD_LAYOUT:this._db.objects.layout,ACAD_GROUP:this._db.objects.group,ACAD_SORTENTS:this._db.objects.sortentsTable,ACAD_MLEADERSTYLE:this._db.objects.mleaderStyle,ACAD_MLINESTYLE:this._db.objects.mlineStyle,ISM_RASTER_IMAGE_DICT:this._db.objects.imageDefinition,MLIGHT_XRECORD:this._db.objects.xrecord},r=this.collectLoadedObjectsByHandle();for(const[s,a]of Object.entries(t.entries)){const o=i[s.toUpperCase()];if(!o)continue;o.objectId=a,o.ownerId=t.handle,e.setAt(s,o);const c=this._dictionaries.get(Et(a));if(c)for(const[l,h]of Object.entries(c.entries)){const u=r.get(Et(h));u&&(o.getAt(l)||o.setAt(l,u))}}}collectLoadedObjectsByHandle(){const t=new Map,e=i=>{const r=Et(i.objectId);r&&t.set(r,i)};for(const[,i]of this._db.objects.layout.entries())e(i);for(const[,i]of this._db.objects.group.entries())e(i);for(const[,i]of this._db.objects.sortentsTable.entries())e(i);for(const[,i]of this._db.objects.imageDefinition.entries())e(i);for(const[,i]of this._db.objects.mleaderStyle.entries())e(i);for(const[,i]of this._db.objects.mlineStyle.entries())e(i);for(const[,i]of this._db.objects.layerFilter.entries())e(i);for(const[,i]of this._db.objects.layerIndex.entries())e(i);for(const[,i]of this._db.objects.xrecord.entries())e(i);return t}readPersistDictionary(t){const e={handle:"",ownerObjectId:"",entries:{}};let i;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const r=t.readItem();if(!r)break;const s=Number(r.code);switch(s){case 5:e.handle=String(r.value);break;case 330:e.ownerObjectId=String(r.value);break;case 100:case 280:case 281:break;case 3:i=String(r.value);break;case 350:case 340:case 360:{const a=Et(String(r.value));i?(e.entries[i]=a,i=void 0):s===360&&!e.extensionDictionaryId&&(e.extensionDictionaryId=a);break}}}return e.handle=Et(e.handle),e.ownerObjectId=Et(e.ownerObjectId),e.extensionDictionaryId&&(e.extensionDictionaryId=Et(e.extensionDictionaryId)),e}finishLayerFilterTree(){if(this._dictionaries.size===0&&this._xrecords.size===0)return;const t=ah({dictionaries:this._dictionaries,xrecords:this._xrecords});t.root.getNestedFilters().length>0&&(this._db.layerFilters=t),this._dictionaries.clear(),this._xrecords.clear()}linkLayoutsToBlockTableRecords(){const t=this._db.tables.blockTable,e=tt.MODEL_SPACE_NAME.toUpperCase();for(const[,i]of this._db.objects.layout.entries()){if(i.layoutName==="Model"){const a=t.modelSpace;i.blockTableRecordId=a.objectId,a.layoutId=i.objectId;continue}const r=Et(i.objectId);let s=!1;for(const a of t.newIterator())if(Et(a.layoutId)===r){i.blockTableRecordId=a.objectId,s=!0;break}if(!s&&i.blockTableRecordId){const a=t.getIdAt(i.blockTableRecordId);a&&(a.layoutId=i.objectId)}else if(!s){for(const a of t.newIterator())if(a.isPaperSapce&&a.name.toUpperCase()!==e&&!a.layoutId){i.blockTableRecordId=a.objectId,a.layoutId=i.objectId;break}}}}}class wh{constructor(t,e={}){this._db=t,this._options=e,this._unknownEntityCount=0,this._unknownObjectCount=0,this._fonts=new Set,this._attributeMap=new Map,this._yieldGate=new vr(this._options.yieldBudgetMs??Li)}get unknownEntityCount(){return this._unknownEntityCount}get unknownObjectCount(){return this._unknownObjectCount}get fonts(){return[...this._fonts]}async read(t){for(this._unknownEntityCount=0,this._unknownObjectCount=0,this._fonts.clear(),this._attributeMap.clear(),t.database=this._db;!t.atEof;){const e=t.readItem();if(!e)break;if(Number(e.code)!==0)continue;const i=String(e.value).toUpperCase();if(i==="EOF")break;if(i==="SECTION"){const r=this.readSectionName(t);await this.readSection(t,r);continue}}return this.flushRemainingAttributes(),{unknownEntityCount:this._unknownEntityCount,unknownObjectCount:this._unknownObjectCount,fonts:this.fonts}}readSectionName(t){const e=t.readItem();return e&&Number(e.code)===2?String(e.value).toUpperCase():(e&&t.pushBackItem(e),"")}async readSection(t,e){switch(e){case"HEADER":ih(t,this._db),await this.reportParseProgress(t);break;case"CLASSES":this.readClassesSection(t),await this.reportParseProgress(t);break;case"TABLES":this.readTablesSection(t),await this.reportParseProgress(t);break;case"BLOCKS":await this.readBlocksSection(t),await this.reportParseProgress(t);break;case"ENTITIES":await this.readEntitiesSection(t),await this.reportParseProgress(t);break;case"OBJECTS":{const i=new xh(this._db);i.read(t),this._unknownObjectCount+=i.unknownObjectCount}await this.reportParseProgress(t);break;case"ACDSDATA":this.applyAcdsDataToSolids(jp(t)),await this.reportParseProgress(t);break;case"THUMBNAILIMAGE":this.readThumbnailImageSection(t),await this.reportParseProgress(t);break;default:this.skipUntilEndSec(t),await this.reportParseProgress(t);break}}applyAcdsDataToSolids(t){const e=Object.keys(t.byOwnerHandle);if(e.length===0)return;const i=new Map;for(const r of this._db.tables.blockTable.newIterator())for(const s of r.newIterator())s instanceof Oi&&i.set(Is(s.objectId),s);for(const r of e){const s=t.byOwnerHandle[r];if(!s)continue;const a=i.get(Is(r));a&&a.setSabBytes(s)}}readThumbnailImageSection(t){let e=0;const i=[];for(;!t.atEof;){const s=t.readItem();if(!s)break;if(Number(s.code)===0){if(String(s.value).toUpperCase()==="ENDSEC")break;t.pushBackItem(s);break}Number(s.code)===90?e=Number(s.value)||0:Number(s.code)===310&&(s.value instanceof Uint8Array?i.push(s.value):i.push(String(s.value)))}if(i.length===0)return;const r=Ji(i);!r||r.length===0||(this._db.thumbnailImage=e>0&&r.length>e?r.subarray(0,e):r)}readClassesSection(t){const e=[];for(;!t.atEof;){const i=t.peekItem();if(!i)break;if(Number(i.code)!==0){t.readItem();continue}const r=String(i.value).toUpperCase();if(r==="ENDSEC"){t.readItem();break}if(r==="CLASS"){t.readItem();const s=this.readClassRecord(t);(s.name||s.cppClassName)&&e.push(s);continue}t.readItem(),t.skipToEndOfObject()}e.length>0&&(this._db.classes=e)}readClassRecord(t){const e={name:"",cppClassName:"",appName:"",proxyFlag:0,instanceCount:0,wasProxy:!1,isEntity:!1};for(;!t.atEndOfObject&&!t.atEof;){const i=t.readItem();if(!i)break;switch(Number(i.code)){case 1:e.name=String(i.value);break;case 2:e.cppClassName=String(i.value);break;case 3:e.appName=String(i.value);break;case 90:e.proxyFlag=Number(i.value);break;case 91:e.instanceCount=Number(i.value);break;case 280:e.wasProxy=Number(i.value)!==0;break;case 281:e.isEntity=Number(i.value)!==0;break}}return e}readTablesSection(t){for(;!t.atEof;){const e=t.peekItem();if(!e)break;if(Number(e.code)!==0){t.readItem();continue}const i=String(e.value).toUpperCase();if(i==="ENDSEC"){t.readItem();break}if(i==="TABLE"){t.readItem();const r=this.readTableName(t);this.readTable(t,r);continue}t.readItem(),t.skipToEndOfObject()}this._db.ensureTextStyleDefaults()}readTableName(t){for(;!t.atEof;){const e=t.peekItem();if(!e)return"";const i=Number(e.code);if(i===0)return"";if(t.readItem(),i===2)return String(e.value).toUpperCase()}return""}readTable(t,e){switch(e){case"LAYER":this.readNamedTable(t,"LAYER",()=>new nn,i=>{i.name&&this._db.tables.layerTable.add(i)});break;case"LTYPE":this.readNamedTable(t,"LTYPE",()=>new Ae,i=>{i.name&&this._db.tables.linetypeTable.add(i)});break;case"STYLE":this.readNamedTable(t,"STYLE",()=>new Ir,i=>{this._db.tables.textStyleTable.add(i),this.collectFontFromStyleRecord(i)});break;case"DIMSTYLE":this.readNamedTable(t,"DIMSTYLE",()=>new Tt,i=>{i.name&&this._db.tables.dimStyleTable.add(i)});break;case"VPORT":this.readNamedTable(t,"VPORT",()=>new Se,i=>{i.name&&this._db.tables.viewportTable.add(i)});break;case"APPID":this.readNamedTable(t,"APPID",()=>new Xn,i=>{i.name&&this._db.tables.appIdTable.add(i)});break;case"VIEW":this.readNamedTable(t,"VIEW",()=>new Zl,i=>{i.name&&this._db.tables.viewTable.add(i)});break;case"UCS":this.readNamedTable(t,"UCS",()=>new Kl,i=>{i.name&&this._db.tables.ucsTable.add(i)});break;case"BLOCK_RECORD":this.readBlockRecordTable(t);break;default:this.skipUntilEndTab(t);break}}readNamedTable(t,e,i,r){for(;!t.atEof;){const s=t.peekItem();if(!s)break;if(Number(s.code)!==0){t.readItem();continue}const a=String(s.value).toUpperCase();if(a==="ENDTAB"){t.readItem();break}if(a==="ENDSEC")break;if(a===e){t.readItem();const o=i();o.dxfIn(t),r(o);continue}t.readItem(),t.skipToEndOfObject()}}readBlockRecordTable(t){let e=!1;for(;!t.atEof;){const i=t.peekItem();if(!i)break;if(Number(i.code)!==0){t.readItem();continue}const r=String(i.value).toUpperCase();if(r==="ENDTAB"){t.readItem();break}if(r==="ENDSEC")break;if(r==="BLOCK_RECORD"){t.readItem(),e||(this._db.tables.blockTable.removeAll(),e=!0);const s=new tt;s.dxfIn(t),s.name&&this._db.tables.blockTable.add(s);continue}t.readItem(),t.skipToEndOfObject()}}skipUntilEndTab(t){for(;!t.atEof;){const e=t.readItem();if(!e||Number(e.code)===0&&String(e.value).toUpperCase()==="ENDTAB")break}}async readBlocksSection(t){const e=Math.max(1,this._options.entityBatchSize??200);let i=0;for(;!t.atEof;){const r=t.peekItem();if(!r)break;if(Number(r.code)!==0){t.readItem();continue}const s=String(r.value).toUpperCase();if(s==="ENDSEC"){t.readItem();break}if(s==="BLOCK"){t.readItem(),i=await this.readBlockDefinition(t,e,i);continue}t.readItem(),t.skipToEndOfObject()}}async readBlockDefinition(t,e,i){const r=this.readBlockBeginFields(t),s=this.ensureBlockTableRecord(r);for(;!t.atEof;){const a=t.peekItem();if(!a)break;if(Number(a.code)!==0){t.readItem();continue}const o=String(a.value).toUpperCase();if(o==="ENDBLK"){t.readItem(),t.skipToEndOfObject();break}if(o==="ENDSEC")break;if(t.readItem(),this.consumeSeqend(t,o)){i+=1,i>=e&&(i=0,await this.yieldAndReportProgress(t));continue}const c=Fs(t,o);c?this.shouldAcceptBlockEntity(s)&&this.acceptEntity(c,s):(this._unknownEntityCount+=1,t.skipToEndOfObject()),i+=1,i>=e&&(i=0,await this.yieldAndReportProgress(t))}return i}shouldAcceptBlockEntity(t){return!t.isModelSapce&&!t.isPaperSapce}consumeSeqend(t,e){return e!=="SEQEND"?!1:(t.skipToEndOfObject(),!0)}readBlockBeginFields(t){const e=new b;let i="",r=0,s="",a,o;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const c=t.readItem();if(!c)break;const l=Number(c.code);if(l===100)continue;const h=Number(c.value);switch(l){case 5:a=String(c.value);break;case 330:o=String(c.value);break;case 2:case 3:i||(i=String(c.value));break;case 70:r=h;break;case 10:e.x=h;break;case 20:e.y=h;break;case 30:e.z=h;break;case 1:s=String(c.value);break}}return{name:i,flags:r,origin:e,pathName:s,objectId:a,ownerId:o}}ensureBlockTableRecord(t){let e=t.name?this._db.tables.blockTable.getAt(t.name):void 0;e||(e=new tt,e.name=t.name||"*UNKNOWN",t.objectId&&(e.objectId=t.objectId),this._db.tables.blockTable.add(e)),e.origin.copy(t.origin);let i=tt.sanitizeImportedFlags(t.flags);return t.pathName&&(e.pathName=t.pathName,(i&(wi.Xref|wi.XrefOverlay))===0&&(i=i|wi.Xref)),e.flags=i,e}async readEntitiesSection(t){const e=Math.max(1,this._options.entityBatchSize??200);let i=0;const r=this._db.tables.blockTable.modelSpace;for(;!t.atEof;){const s=t.peekItem();if(!s)break;if(Number(s.code)!==0){t.readItem();continue}const a=String(s.value).toUpperCase();if(a==="ENDSEC"){t.readItem();break}if(t.readItem(),this.consumeSeqend(t,a)){i+=1,i>=e&&(i=0,await this.yieldAndReportProgress(t));continue}const o=Fs(t,a);o?this.acceptEntity(o,this.resolveEntityOwner(o,r)):(this._unknownEntityCount+=1,t.skipToEndOfObject()),i+=1,i>=e&&(i=0,await this.yieldAndReportProgress(t))}}resolveEntityOwner(t,e){const i=t.getAttrWithoutException("ownerId");if(i){const r=this._db.tables.blockTable.getIdAt(i);if(r&&(r.isModelSapce||r.isPaperSapce))return r}if(t.dxfPaperSpace){const r=this._db.tables.blockTable.getAt(tt.PAPER_SPACE_NAME_PREFIX);if(r)return r}return e}acceptEntity(t,e){if(t instanceof Ri){this.collectInlineFontsFromEntity(t),this.linkOrDeferAttribute(t,e);return}if(e.appendEntity(t),this.collectInlineFontsFromEntity(t),t instanceof ee){const i=this._attributeMap.get(t.objectId);if(i&&i.length>0){for(const r of i)t.appendAttributes(r);this._attributeMap.delete(t.objectId)}}}linkOrDeferAttribute(t,e){const i=t.getAttrWithoutException("ownerId");if(!i||i==="0")return;const r=e.getIdAt(i)??this._db.tables.blockTable.getEntityById(i);if(r instanceof ee){r.appendAttributes(t);return}let s=this._attributeMap.get(i);s||(s=[],this._attributeMap.set(i,s)),s.push(t)}flushRemainingAttributes(){for(const[t,e]of this._attributeMap){const i=this._db.tables.blockTable.getEntityById(t);if(i instanceof ee)for(const r of e)i.appendAttributes(r)}this._attributeMap.clear()}collectFontFromStyleRecord(t){if(t.fileName){const r=gt.normalizeFontFileName(t.fileName);r?this._fonts.add(r):this._fonts.add(t.fileName)}const e=t.textStyle.extendedFont;if(e){const r=gt.normalizeFontFileName(e);r&&this._fonts.add(r)}const i=t.bigFontFileName;if(i){const r=gt.normalizeFontFileName(i);r&&this._fonts.add(r)}}collectInlineFontsFromEntity(t){const e=this.getEntityFormattedTextForFonts(t);if(e)for(const i of gt.collectInlineMTextFonts(e))this._fonts.add(i)}getEntityFormattedTextForFonts(t){if(t instanceof Ee||t instanceof Fi)return t.contents||void 0;if(t instanceof Vi)return t.text||void 0}skipUntilEndSec(t){for(;!t.atEof;){const e=t.readItem();if(!e||Number(e.code)===0&&String(e.value).toUpperCase()==="ENDSEC")break}}async reportParseProgress(t){const{onProgress:e,totalBytes:i}=this._options;if(!e||!i||i<=0)return;const r=Math.min(1,Math.max(0,t.position().byteOffset/i));await e(r)}async yieldAndReportProgress(t){await this.reportParseProgress(t),await this._yieldGate.maybeYield(ci)}}const mn=1,ts=12,Zp=13,Qp=18,yn=20,bn=98;class vh extends sa{constructor(t={}){super({useWorker:!1,...t})}async read(t,e,i,r,s,a){this.progress=r;const o=async(l,h,u,d)=>{r&&await r(l,h,u,d)};await o(0,"START","START"),await o(mn,"PARSE","START"),await ec(),e.beginEventBatch();let c=!0;try{const l=ve.fromBuffer(t,{database:e}),h=t.byteLength;let u=mn;const g=await new wh(e,{entityBatchSize:Math.max(1,i||200),yieldBudgetMs:Li,totalBytes:h,onProgress:async y=>{const _=Math.min(ts-1,mn+Math.floor(y*(ts-mn)));_<=u||(u=_,await o(_,"PARSE","IN-PROGRESS"))}}).read(l);await o(ts,"PARSE","END",{unknownEntityCount:g.unknownEntityCount}),await o(Zp,"FONT","START"),await o(Qp,"FONT","END",g.fonts),await o(yn,"ENTITY","START");const p=Math.max(1,i||200);let f=yn;const m=new vr(Li);await e.endEventBatchChunked(p,async(y,_)=>{const v=_<=0?bn:Math.min(bn,yn+Math.floor(y/_*(bn-yn)));v>f&&(f=v,await o(v,"ENTITY","IN-PROGRESS")),await m.maybeYield()}),c=!1,await o(bn,"ENTITY","END"),await o(100,"END","END")}catch(l){throw c&&e.endEventBatch(),l}}async parse(t){return{model:null,data:{unknownEntityCount:0}}}getFonts(t){return[]}}var Si=(n=>(n.DXF="dxf",n.DWG="dwg",n))(Si||{});class Kt{constructor(){this.events={registered:new at,unregistered:new at},this._converters=new Map,this.register("dxf",new vh)}static createInstance(){return Kt._instance==null&&(Kt._instance=new Kt),this._instance}static get instance(){return Kt._instance||(Kt._instance=new Kt),Kt._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}))}}const qe=class qe extends _t{constructor(){super(),this._thickness=0,this._normal=new w(0,0,1),this._elevation=0,this._geo=new q}get dxfTypeName(){return"LWPOLYLINE"}get numberOfVertices(){return this._geo.numberOfVertices}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get closed(){return this._geo.closed}get area(){return this._geo.area}set closed(t){this._geo.closed=t}addVertexAt(t,e,i=0,r=-1,s=-1){const a=r<0?void 0:r,o=s<0?void 0:s,c={x:e.x,y:e.y,bulge:i,startWidth:a,endWidth:o};this._geo.addVertexAt(t,c)}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 Y({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 this.shouldIncludeSegmentMidpointGrips()&&this.appendSegmentMidpointGrips(t),t}subMoveGripPointsAt(t,e){const i=this.numberOfVertices,r=this.shouldIncludeSegmentMidpointGrips(),s=r?this.getSegmentCount():0;return ht(t,a=>{if(a<i){ki(this._geo.vertices,a,e);return}if(!r||a>=i+s)return;const o=a-i;ki(this._geo.vertices,o,e),ki(this._geo.vertices,(o+1)%i,e)}),this}shouldIncludeSegmentMidpointGrips(){return this.getGripsMode()>=2}getGripsMode(){try{const t=ft.instance().getVar(E.GRIPS,this.database);return typeof t=="number"?t:2}catch{return 2}}getSegmentCount(){const t=this.numberOfVertices;return t<2?0:this.closed?t:t-1}appendSegmentMidpointGrips(t){var a;const e=this._geo,i=this._elevation,r=this.getSegmentCount(),s=e.numberOfVertices;for(let o=0;o<r;o++){const c=[];Ni(e.getPointAt(o),e.getPointAt((o+1)%s),(a=e.vertices[o])==null?void 0:a.bulge,i,A.MidPoint,{x:0,y:0,z:0},c),t.push(...c)}}subGetOsnapPoints(t,e,i,r){var c;const s=this._geo,a=this._elevation,o=s.numberOfVertices;if(o!==0)switch(t){case A.EndPoint:for(let l=0;l<o;l++){const h=s.getPointAt(l);r.push(new b(h.x,h.y,a))}break;case A.MidPoint:case A.Nearest:case A.Perpendicular:case A.Tangent:{const l=this.closed?o:o-1,h=[];for(let u=0;u<l;u++){const d=[];Ni(s.getPointAt(u),s.getPointAt((u+1)%o),(c=s.vertices[u])==null?void 0:c.bulge,a,t,e,d),h.push(...d)}if(t===A.MidPoint)r.push(...h);else{const u=Ft(e,h);u&&r.push(u)}break}}}transformBy(t){const e=t.determinant()<0;let i=this._elevation;return this._geo.vertices.forEach(r=>{const s=new b(r.x,r.y,this._elevation).applyMatrix4(t);r.x=s.x,r.y=s.y,i=s.z,e&&r.bulge!=null&&(r.bulge=-r.bulge)}),this._elevation=i,this._geo._boundingBoxNeedsUpdate=!0,this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set:t=>{this.elevation=t}}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=this._geo.getPoints(100),i=this.createWidthProfile();if(i!=null){const s=t0(i,this.closed);if(s!=null){const a=t.subEntityTraits;return a.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},t.area(s)}}const r=[];return e.forEach(s=>r.push(new b().set(s.x,s.y,this.elevation))),t.lines(r)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPolyline"),t.writeInt32(90,this.numberOfVertices),t.writeInt16(70,this.closed?1:0);const e=this.resolveConstantWidth();e!=null&&t.writeDouble(43,e),t.writeDouble(38,this.elevation),this.thickness!==0&&t.writeDouble(39,this.thickness);const i=this._geo.vertices;for(let r=0;r<i.length;++r){const s=i[r];t.writePoint2d(10,this.getPoint2dAt(r)),e==null&&(s.startWidth!=null&&t.writeDouble(40,s.startWidth),s.endWidth!=null&&t.writeDouble(41,s.endWidth));const a=s.bulge??0;a!==0&&t.writeDouble(42,a),s.identifier!=null&&t.writeInt32(91,s.identifier)}return t.writeVector3d(210,this.normal),this}dxfOutAs2dPolyline(t,e=!1){var r,s,a;t.writeHandle(5,this.objectId),t.writeObjectId(330,this.ownerId),t.writeObjectId(360,this.extensionDictionary),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.writeLineWeight(370,this.lineWeight),t.writeTransparency(this.transparency);const i=(r=this.database)==null?void 0:r.tables.blockTable.getIdAt(this.ownerId);i!=null&&i.isPaperSapce&&t.writeInt16(67,1),t.writeSubclassMarker("AcDb2dPolyline"),t.writeInt16(66,this.numberOfVertices>0?1:0),t.writeInt16(70,this.closed?1:0),t.writeDouble(10,0),t.writeDouble(20,0),t.writeDouble(30,this.elevation);for(let o=0;o<this.numberOfVertices;++o){const c=this._geo.vertices[o];t.writeStart("VERTEX"),t.writeHandle(5,(s=this.database)==null?void 0:s.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),t.writeSubclassMarker("AcDbVertex"),t.writeSubclassMarker("AcDb2dVertex"),t.writePoint3d(10,{x:this.getPoint2dAt(o).x,y:this.getPoint2dAt(o).y,z:this.elevation});const l=(c==null?void 0:c.bulge)??0;l!==0&&t.writeDouble(42,l),t.writeInt16(70,0)}return t.writeStart("SEQEND"),t.writeHandle(5,(a=this.database)==null?void 0:a.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbPolyline"),this.reset(!1);let e=!1,i=this.elevation,r=this.thickness,s=this.normal.x,a=this.normal.y,o=this.normal.z,c=-1,l=0,h=0,u=!1,d=0,g=-1,p=-1,f,m=0;const y=()=>{if(!u)return;const v=g<0?c:g,x=p<0?c:p;if(this.addVertexAt(m++,new L(l,h),d,v,x),f!=null){const k=this._geo.vertices[m-1];k&&(k.identifier=f)}u=!1,d=0,g=-1,p=-1,f=void 0};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const v=t.readItem();if(!v)break;const x=Number(v.code),k=Number(v.value);switch(x){case 90:break;case 70:e=(k&1)!==0;break;case 43:c=k;break;case 38:i=k;break;case 39:r=k;break;case 10:y(),l=k,h=0,u=!0;break;case 20:h=k;break;case 40:g=k;break;case 41:p=k;break;case 42:d=k;break;case 91:f=k;break;case 210:s=k;break;case 220:a=k;break;case 230:o=k;break}}y(),this.closed=e,this.elevation=i,this.thickness=r;const _=new w(s,a,o);return _.lengthSq()>0&&this.normal.copy(_.normalize()),this}resolveConstantWidth(){const t=this._geo.vertices;if(t.length===0)return;let e;for(const i of t){const r=i.startWidth,s=i.endWidth;if(r==null&&s==null){if(e!=null&&e!==0)return;e=e??0;continue}const a=r??0;if(a!==(s??0))return;if(e==null)e=a;else if(e!==a)return}return e!=null&&e!==0?e:void 0}createWidthProfile(){const t=this._geo.vertices,e=t.length;if(e<2)return null;const i=this.closed?e:e-1,r=[];let s=!1;for(let a=0;a<i;a++){const o=t[a],c=t[(a+1)%e],l=Math.max(0,o.startWidth??0),h=Math.max(0,o.endWidth??0);(l>mt||h>mt)&&(s=!0);const u=this.sampleSegment(o,c),d=u.length-1;for(let g=0;g<=d;g++){if(g===0&&r.length>0||this.closed&&a===i-1&&g===d)continue;const p=d>0?g/d:0;r.push({x:u[g].x,y:u[g].y,width:l0(l,h,p)})}}return s&&r.length>=2?r:null}sampleSegment(t,e){if(t.bulge&&Math.abs(t.bulge)>mt){const r=new vt(t,e,t.bulge).getPoints(32);if(r.length>1)return r.map(s=>new L(s.x,s.y))}return[new L(t.x,t.y),new L(e.x,e.y)]}static from2dPoints(t,e){const i=new qe;return t.forEach((r,s)=>i.addVertexAt(s,r)),i.closed=e,i}static fromGePolyline(t){const e=new qe;return t.vertices.forEach((i,r)=>{e.addVertexAt(r,new L(i.x,i.y),i.bulge??0)}),e.closed=t.closed,e}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.numberOfVertices;let i=1/0,r=1;const s=this.closed?e:e-1;for(let a=0;a<s;a++){const o=this.getPoint2dAt(a),c=this.getPoint2dAt((a+1)%e),l=c.x-o.x,h=c.y-o.y,u=l*l+h*h;if(u===0)continue;const d=Math.max(0,Math.min(1,((t.x-o.x)*l+(t.y-o.y)*h)/u)),g=(t.x-o.x-d*l)**2+(t.y-o.y-d*h)**2;g<i&&(i=g,r=l*(t.y-o.y)-h*(t.x-o.x)>=0?1:-1)}return r}createOffsetCurve(t){const e=this._geo.offset(t);return e.length===0?null:qe.fromGePolyline(e[0])}};qe.typeName="Polyline";let kt=qe;function Nr(n,t,e){const i=Qd(n,t,e);return i?kt.fromGePolyline(i):null}const mt=1e-6,Ro=4,Jp=.75;function t0(n,t){if(n.length<2)return null;if(t)return es(n,!0);const e=e0(n);if(e.length===1)return es(e[0],!1);const i=new Vt;let r=!1;for(const s of e){const a=es(s,!1);if(a!=null){for(const o of a.loops)i.add(o);r=!0}}return r?i:null}function es(n,t){const e=o0(n,t);if(e.length<2)return null;const{left:i,right:r}=kh(e,t);if(Fo(i)<2||Fo(r)<2)return null;const s=new Vt;if(t){const a=zn(i),o=zn(r);if(!Yi(a)||!Yi(o))return null;const c=Math.abs(Di(a)),l=Math.abs(Di(o)),[h,u]=c>=l?[a,o]:[o,a];return s.add(new q(h,!0)),s.add(new q(u,!0)),s}return n0(e)&&r0(s,e)||a0(s,i,r)?s:null}function e0(n){if(n.length<2)return[n];const t=[];let e=0;const i=new Map;for(let s=0;s<n.length;s++){const a=Bo(n[s]),o=i.get(a);if(o!=null&&s-o>1){const c=n.slice(e,s+1);c.length>=2&&t.push(c),e=o,i.clear();for(let l=e;l<=s;l++)i.set(Bo(n[l]),l);continue}i.set(a,s)}const r=n.slice(e);return r.length>=2&&t.push(r),t.length>0?t:[n]}function Bo(n){return`${n.x.toFixed(4)}:${n.y.toFixed(4)}`}function i0(n,t){const e=Math.max(n,t),i=Math.min(n,t);return e<=mt||e-i<=mt?!1:i/e<=Jp}function n0(n){const t=n[0],e=n[n.length-1],i=Math.hypot(e.x-t.x,e.y-t.y);if(i<=mt)return!0;const r=Math.max(...n.map(s=>s.width));return r<=mt?!1:i<=r*4}function r0(n,t){const{left:e,right:i}=kh(t,!0),r=zn(e),s=zn(i);if(!Yi(r)||!Yi(s))return!1;const a=Math.abs(Di(r)),o=Math.abs(Di(s));if(!i0(a,o))return!1;const[c,l]=a>=o?[r,s]:[s,r];return n.add(new q(c,!0)),n.add(new q(l,!0)),!0}function kh(n,t){const e=new Array(n.length),i=new Array(n.length);for(let r=0;r<n.length;r++){const s=n[r],a=Math.max(0,s.width)/2;if(a<=mt){e[r]=null,i[r]=null;continue}const o=c0(n,r,t);if(o==null){e[r]=null,i[r]=null;continue}e[r]={x:s.x+o.x*a,y:s.y+o.y*a},i[r]={x:s.x-o.x*a,y:s.y-o.y*a}}return{left:e,right:i}}function s0(n,t,e,i,r){const s=[t,e,i,r];return Yi(s)?(n.add(new q(s,!0)),!0):!1}function a0(n,t,e){let i=!1;for(let r=0;r<t.length-1;r++){const s=t[r],a=t[r+1],o=e[r],c=e[r+1];s==null||a==null||o==null||c==null||s0(n,s,a,c,o)&&(i=!0)}return i}function Fo(n){return n.reduce((t,e)=>e==null?t:t+1,0)}function zn(n){return n.filter(t=>t!=null)}function o0(n,t){const e=[];if(n.forEach(i=>{const r=e[e.length-1];(!r||Math.abs(r.x-i.x)>mt||Math.abs(r.y-i.y)>mt||Math.abs(r.width-i.width)>mt)&&e.push(i)}),t&&e.length>1){const i=e[0],r=e[e.length-1];Math.abs(i.x-r.x)<=mt&&Math.abs(i.y-r.y)<=mt&&e.pop()}return e}function c0(n,t,e){const i=n.length,r=n[t],s=n[(t-1+i)%i],a=n[(t+1)%i];let o=Do(r.x-s.x,r.y-s.y),c=Do(a.x-r.x,a.y-r.y);if(e||(t===0&&(o=c),t===i-1&&(c=o)),o==null&&c==null)return null;if(o==null)return _n(c);if(c==null)return _n(o);const l=_n(o),h=_n(c),u=l.x+h.x,d=l.y+h.y,g=Math.hypot(u,d);if(g<=mt)return h;const p={x:u/g,y:d/g},f=Math.abs(p.x*h.x+p.y*h.y),m=f<=mt?Ro:Math.min(1/f,Ro);return{x:p.x*m,y:p.y*m}}function Do(n,t){const e=Math.hypot(n,t);return e<=mt?null:{x:n/e,y:t/e}}function _n(n){return{x:-n.y,y:n.x}}function Di(n){let t=0;const e=n.length;for(let i=0;i<e;i++){const r=n[i],s=n[(i+1)%e];t+=r.x*s.y-s.x*r.y}return t/2}function Yi(n){return n.length>=3&&Math.abs(Di(n))>mt}function l0(n,t,e){return n+(t-n)*e}const h0={patterns:[{name:"SOLID",description:"",lines:[]},{name:"ANGLE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.275,dashes:[.2,-.075],sourceLine:23},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.275,dashes:[.2,-.075],sourceLine:24}]},{name:"ANSI31",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:26}]},{name:"ANSI32",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.375,dashes:[],sourceLine:28},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.375,dashes:[],sourceLine:29}]},{name:"ANSI33",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:31},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.25,dashes:[.125,-.0625],sourceLine:32}]},{name:"ANSI34",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:34},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:35},{angle:45,originX:.353553391,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:36},{angle:45,originX:.530330086,originY:0,deltaX:0,deltaY:.75,dashes:[],sourceLine:37}]},{name:"ANSI35",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:39},{angle:45,originX:.176776695,originY:0,deltaX:0,deltaY:.25,dashes:[.3125,-.0625,0,-.0625],sourceLine:40}]},{name:"ANSI36",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:.21875,deltaY:.125,dashes:[.3125,-.0625,0,-.0625],sourceLine:42}]},{name:"ANSI37",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:44},{angle:135,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:45}]},{name:"ANSI38",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:47},{angle:135,originX:0,originY:0,deltaX:.25,deltaY:.125,dashes:[.3125,-.1875],sourceLine:48}]},{name:"AR-B816",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:8,dashes:[],sourceLine:54},{angle:90,originX:0,originY:0,deltaX:8,deltaY:8,dashes:[8,-8],sourceLine:55}]},{name:"AR-B816C",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:8,deltaY:8,dashes:[15.625,-.375],sourceLine:57},{angle:0,originX:-8,originY:.375,deltaX:8,deltaY:8,dashes:[15.625,-.375],sourceLine:58},{angle:90,originX:0,originY:0,deltaX:8,deltaY:8,dashes:[-8.375,7.625],sourceLine:59},{angle:90,originX:-.375,originY:0,deltaX:8,deltaY:8,dashes:[-8.375,7.625],sourceLine:60}]},{name:"AR-B88",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:8,dashes:[],sourceLine:62},{angle:90,originX:0,originY:0,deltaX:8,deltaY:4,dashes:[8,-8],sourceLine:63}]},{name:"AR-BRELM",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5.334,dashes:[7.625,-.375],sourceLine:65},{angle:0,originX:0,originY:2.25,deltaX:0,deltaY:5.334,dashes:[7.625,-.375],sourceLine:66},{angle:0,originX:2,originY:2.667,deltaX:0,deltaY:5.334,dashes:[3.625,-.375],sourceLine:67},{angle:0,originX:2,originY:4.917,deltaX:0,deltaY:5.334,dashes:[3.625,-.375],sourceLine:68},{angle:90,originX:0,originY:0,deltaX:0,deltaY:8,dashes:[2.25,-3.084],sourceLine:69},{angle:90,originX:-.375,originY:0,deltaX:0,deltaY:8,dashes:[2.25,-3.084],sourceLine:70},{angle:90,originX:2,originY:2.667,deltaX:0,deltaY:4,dashes:[2.25,-3.084],sourceLine:71},{angle:90,originX:1.625,originY:2.667,deltaX:0,deltaY:4,dashes:[2.25,-3.084],sourceLine:72}]},{name:"AR-BRSTD",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:2.667,dashes:[],sourceLine:74},{angle:90,originX:0,originY:0,deltaX:2.667,deltaY:4,dashes:[2.667,-2.667],sourceLine:75}]},{name:"AR-CONC",description:"",lines:[{angle:50,originX:0,originY:0,deltaX:4.12975034,deltaY:-5.89789472,dashes:[.75,-8.25],sourceLine:77},{angle:355,originX:0,originY:0,deltaX:-2.03781207,deltaY:7.3723684,dashes:[.6,-6.6],sourceLine:78},{angle:100.45144446,originX:.59771681,originY:-.05229344,deltaX:5.7305871,deltaY:-6.9397673,dashes:[.63740192,-7.01142112],sourceLine:79},{angle:46.1842,originX:0,originY:2,deltaX:6.19462554,deltaY:-8.84684596,dashes:[1.125,-12.375],sourceLine:80},{angle:96.63563549,originX:.88936745,originY:1.86206693,deltaX:8.59588239,deltaY:-10.40964966,dashes:[.95610342,-10.5171376],sourceLine:81},{angle:351.18416399,originX:0,originY:2,deltaX:7.74327494,deltaY:11.05855746,dashes:[.9,-9.90000001],sourceLine:82},{angle:21,originX:1,originY:1.5,deltaX:4.12975034,deltaY:-5.89789472,dashes:[.75,-8.25],sourceLine:83},{angle:326,originX:1,originY:1.5,deltaX:-2.03781207,deltaY:7.3723684,dashes:[.6,-6.6],sourceLine:84},{angle:71.45144474,originX:1.49742254,originY:1.16448426,deltaX:5.7305871,deltaY:-6.9397673,dashes:[.6374019,-7.01142112],sourceLine:85},{angle:37.5,originX:0,originY:0,deltaX:2.123,deltaY:2.567,dashes:[0,-6.52,0,-6.7,0,-6.625],sourceLine:86},{angle:7.5,originX:0,originY:0,deltaX:3.123,deltaY:3.567,dashes:[0,-3.82,0,-6.37,0,-2.525],sourceLine:87},{angle:-32.5,originX:-2.23,originY:0,deltaX:4.6234,deltaY:2.678,dashes:[0,-2.5,0,-7.8,0,-10.35],sourceLine:88},{angle:-42.5,originX:-3.23,originY:0,deltaX:3.6234,deltaY:4.678,dashes:[0,-3.25,0,-5.18,0,-7.35],sourceLine:89}]},{name:"AR-HBONE",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:4,deltaY:4,dashes:[12,-4],sourceLine:91},{angle:135,originX:2.828427125,originY:2.828427125,deltaX:4,deltaY:-4,dashes:[12,-4],sourceLine:92}]},{name:"AR-PARQ1",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:94},{angle:90,originX:2,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:95},{angle:90,originX:4,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:96},{angle:90,originX:6,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:97},{angle:90,originX:8,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:98},{angle:90,originX:10,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:99},{angle:90,originX:12,originY:0,deltaX:12,deltaY:12,dashes:[12,-12],sourceLine:100},{angle:0,originX:0,originY:12,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:101},{angle:0,originX:0,originY:14,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:102},{angle:0,originX:0,originY:16,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:103},{angle:0,originX:0,originY:18,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:104},{angle:0,originX:0,originY:20,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:105},{angle:0,originX:0,originY:22,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:106},{angle:0,originX:0,originY:24,deltaX:12,deltaY:-12,dashes:[12,-12],sourceLine:107}]},{name:"AR-RROOF",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:2.2,deltaY:1,dashes:[15,-2,5,-1],sourceLine:109},{angle:0,originX:1.33,originY:.5,deltaX:-1,deltaY:1.33,dashes:[3,-.33,6,-.75],sourceLine:110},{angle:0,originX:.5,originY:.85,deltaX:5.2,deltaY:.67,dashes:[8,-1.4,4,-1],sourceLine:111}]},{name:"AR-RSHKE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:25.5,deltaY:12,dashes:[6,-5,7,-3,9,-4],sourceLine:113},{angle:0,originX:6,originY:.5,deltaX:25.5,deltaY:12,dashes:[5,-19,4,-6],sourceLine:114},{angle:0,originX:18,originY:-.75,deltaX:25.5,deltaY:12,dashes:[3,-31],sourceLine:115},{angle:90,originX:0,originY:0,deltaX:12,deltaY:8.5,dashes:[11.5,-36.5],sourceLine:116},{angle:90,originX:6,originY:0,deltaX:12,deltaY:8.5,dashes:[11.25,-36.75],sourceLine:117},{angle:90,originX:11,originY:0,deltaX:12,deltaY:8.5,dashes:[10.5,-37.5],sourceLine:118},{angle:90,originX:18,originY:-.75,deltaX:12,deltaY:8.5,dashes:[11.5,-36.5],sourceLine:119},{angle:90,originX:21,originY:-.75,deltaX:12,deltaY:8.5,dashes:[11.5,-36.5],sourceLine:120},{angle:90,originX:30,originY:0,deltaX:12,deltaY:8.5,dashes:[11,-37],sourceLine:121}]},{name:"AR-SAND",description:"",lines:[{angle:37.5,originX:0,originY:0,deltaX:1.123,deltaY:1.567,dashes:[0,-1.52,0,-1.7,0,-1.625],sourceLine:123},{angle:7.5,originX:0,originY:0,deltaX:2.123,deltaY:2.567,dashes:[0,-.82,0,-1.37,0,-.525],sourceLine:124},{angle:-32.5,originX:-1.23,originY:0,deltaX:2.6234,deltaY:1.678,dashes:[0,-.5,0,-1.8,0,-2.35],sourceLine:125},{angle:-42.5,originX:-1.23,originY:0,deltaX:1.6234,deltaY:2.678,dashes:[0,-.25,0,-1.18,0,-1.35],sourceLine:126}]},{name:"BOX",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[],sourceLine:128},{angle:90,originX:.25,originY:0,deltaX:0,deltaY:1,dashes:[],sourceLine:129},{angle:0,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[-.25,.25],sourceLine:130},{angle:0,originX:0,originY:.25,deltaX:0,deltaY:1,dashes:[-.25,.25],sourceLine:131},{angle:0,originX:0,originY:.5,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:132},{angle:0,originX:0,originY:.75,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:133},{angle:90,originX:.5,originY:0,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:134},{angle:90,originX:.75,originY:0,deltaX:0,deltaY:1,dashes:[.25,-.25],sourceLine:135}]},{name:"BRASS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:137},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.25,dashes:[.125,-.0625],sourceLine:138}]},{name:"BRICK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:140},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.5,dashes:[.25,-.25],sourceLine:141},{angle:90,originX:.25,originY:0,deltaX:0,deltaY:.5,dashes:[-.25,.25],sourceLine:142}]},{name:"BRSTONE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.33,dashes:[],sourceLine:144},{angle:90,originX:.9,originY:0,deltaX:.33,deltaY:.5,dashes:[.33,-.33],sourceLine:145},{angle:90,originX:.8,originY:0,deltaX:.33,deltaY:.5,dashes:[.33,-.33],sourceLine:146},{angle:0,originX:.9,originY:.055,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:147},{angle:0,originX:.9,originY:.11,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:148},{angle:0,originX:.9,originY:.165,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:149},{angle:0,originX:.9,originY:.22,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:150},{angle:0,originX:.9,originY:.275,deltaX:.5,deltaY:.33,dashes:[-.9,.1],sourceLine:151}]},{name:"CLAY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.1875,dashes:[],sourceLine:153},{angle:0,originX:0,originY:.03125,deltaX:0,deltaY:.1875,dashes:[],sourceLine:154},{angle:0,originX:0,originY:.0625,deltaX:0,deltaY:.1875,dashes:[],sourceLine:155},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.1875,dashes:[.1875,-.125],sourceLine:156}]},{name:"CORK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:158},{angle:135,originX:.0625,originY:-.0625,deltaX:0,deltaY:.35355339,dashes:[.176776696,-.176776696],sourceLine:159},{angle:135,originX:.09375,originY:-.0625,deltaX:0,deltaY:.35355339,dashes:[.176776696,-.176776696],sourceLine:160},{angle:135,originX:.125,originY:-.0625,deltaX:0,deltaY:.35355339,dashes:[.176776696,-.176776696],sourceLine:161}]},{name:"CROSS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.25,deltaY:.25,dashes:[.125,-.375],sourceLine:163},{angle:90,originX:.0625,originY:-.0625,deltaX:.25,deltaY:.25,dashes:[.125,-.375],sourceLine:164}]},{name:"DASH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.125,deltaY:.125,dashes:[.125,-.125],sourceLine:166}]},{name:"DOLMIT",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:168},{angle:45,originX:0,originY:0,deltaX:0,deltaY:.70710678,dashes:[.3535533905932738,-.7071067811865476],sourceLine:169}]},{name:"DOTS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.03125,deltaY:.0625,dashes:[0,-.0625],sourceLine:171}]},{name:"EARTH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:173},{angle:0,originX:0,originY:.09375,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:174},{angle:0,originX:0,originY:.1875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:175},{angle:90,originX:.03125,originY:.21875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:176},{angle:90,originX:.125,originY:.21875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:177},{angle:90,originX:.21875,originY:.21875,deltaX:.25,deltaY:.25,dashes:[.25,-.25],sourceLine:178}]},{name:"ESCHER",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[1.1,-.1],sourceLine:180},{angle:180,originX:0,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[1.1,-.1],sourceLine:181},{angle:300,originX:0,originY:0,deltaX:.6,deltaY:1.039230484,dashes:[1.1,-.1],sourceLine:182},{angle:60,originX:.1,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:183},{angle:300,originX:.1,originY:0,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:184},{angle:60,originX:-.05,originY:.08660254,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:185},{angle:180,originX:-.05,originY:.08660254,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:186},{angle:300,originX:-.05,originY:-.08660254,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:187},{angle:180,originX:-.05,originY:-.08660254,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:188},{angle:60,originX:-.4,originY:0,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:189},{angle:300,originX:-.4,originY:0,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:190},{angle:60,originX:.2,originY:-.346410161,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:191},{angle:180,originX:.2,originY:-.346410161,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:192},{angle:300,originX:.2,originY:.346410161,deltaX:.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:193},{angle:180,originX:.2,originY:.346410161,deltaX:-.6,deltaY:1.039230484,dashes:[.2,-1],sourceLine:194},{angle:0,originX:.2,originY:.173205081,deltaX:-.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:195},{angle:0,originX:.2,originY:-.173205081,deltaX:-.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:196},{angle:120,originX:.05,originY:.259807621,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:197},{angle:120,originX:-.25,originY:.08660254,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:198},{angle:240,originX:-.25,originY:-.08660254,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:199},{angle:240,originX:.05,originY:-.259807621,deltaX:.6,deltaY:1.039230484,dashes:[.7,-.5],sourceLine:200}]},{name:"FLEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[.25,-.25],sourceLine:202},{angle:45,originX:.25,originY:0,deltaX:.176776695296,deltaY:.176776695296,dashes:[.0625,-.2285533906,.0625,-.353553390593],sourceLine:203}]},{name:"GOST_GLASS",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:6,deltaY:-6,dashes:[5,-7],sourceLine:205},{angle:45,originX:2.12132,originY:0,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:206},{angle:45,originX:0,originY:2.12132,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:207}]},{name:"GOST_WOOD",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:209},{angle:90,originX:2,originY:-2,deltaX:0,deltaY:-6,dashes:[6,-1.5,3,-1.5],sourceLine:210},{angle:90,originX:4,originY:-5,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:211}]},{name:"GOST_GROUND",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:213},{angle:45,originX:3,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:214},{angle:45,originX:6,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:215}]},{name:"GRASS",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:.707106781,deltaY:.707106781,dashes:[.1875,-1.226713563],sourceLine:217},{angle:45,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[.1875,-.8125],sourceLine:218},{angle:135,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[.1875,-.8125],sourceLine:219}]},{name:"GRATE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.03125,dashes:[],sourceLine:221},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:222}]},{name:"GRAVEL",description:"",lines:[{angle:228.012787504,originX:.72,originY:1,deltaX:12.0413651692039,deltaY:.0743294146632,dashes:[.134536,-13.3190880470737],sourceLine:224},{angle:184.969740728,originX:.63,originY:.9,deltaX:-12.0415166747131,deltaY:.0433148081592,dashes:[.230868,-22.85592476123],sourceLine:225},{angle:132.510447078,originX:.4,originY:.88,deltaX:-14.8659418273816,deltaY:.061429511683,dashes:[.162788,-16.1160325960997],sourceLine:226},{angle:267.273689006,originX:.01,originY:.63,deltaX:-20.0249279039043,deltaY:.0475651493827,dashes:[.210238,-20.813558041629],sourceLine:227},{angle:292.833654178,originX:0,originY:.42,deltaX:-12.9999095019474,deltaY:.048507125026,dashes:[.206155,-20.4093731280883],sourceLine:228},{angle:357.273689006,originX:.08,originY:.23,deltaX:-20.0249279039043,deltaY:.0475651493827,dashes:[.210238,-20.813558041629],sourceLine:229},{angle:37.6942404667,originX:.29,originY:.22,deltaX:-16.4011800288558,deltaY:.0359675000664,dashes:[.278029,-27.524848548916],sourceLine:230},{angle:72.2553283749,originX:.51,originY:.39,deltaX:23.0867613281116,deltaY:.0380969659053,dashes:[.262488,-25.9863214968134],sourceLine:231},{angle:121.429565615,originX:.59,originY:.64,deltaX:15.2642639131074,deltaY:.047404546271,dashes:[.21095,-20.884073109729],sourceLine:232},{angle:175.236358309,originX:.48,originY:.82,deltaX:-11.0450488205478,deltaY:.083045479801,dashes:[.240832,-11.8007625787923],sourceLine:233},{angle:222.397437798,originX:.24,originY:.84,deltaX:16.2787889313724,deltaY:.0321080648114,dashes:[.311448,-30.8333750047949],sourceLine:234},{angle:138.814074834,originX:1,originY:.62,deltaX:9.2190645101588,deltaY:.0940720868851,dashes:[.106301,-10.5238448127347],sourceLine:235},{angle:171.46923439,originX:.92,originY:.69,deltaX:-13.1528534931484,deltaY:.0494468176315,dashes:[.202237,-20.021511416157],sourceLine:236},{angle:225,originX:.72,originY:.72,deltaX:.7071067811865,deltaY:.7071067811865,dashes:[.141421,-1.2727925623731],sourceLine:237},{angle:203.198590514,originX:.65,originY:.84,deltaX:-5.3835637472478,deltaY:.1313064328928,dashes:[.076158,-7.5396151058639],sourceLine:238},{angle:291.801409486,originX:.58,originY:.81,deltaX:-3.156820749011,deltaY:.185695338158,dashes:[.107703,-5.2774618071345],sourceLine:239},{angle:30.9637565321,originX:.62,originY:.71,deltaX:3.6014702879928,deltaY:.1714985851408,dashes:[.174929,-5.6560228948453],sourceLine:240},{angle:161.565051177,originX:.77,originY:.8,deltaX:-2.2135943621183,deltaY:.3162277660138,dashes:[.126491,-3.0357866601684],sourceLine:241},{angle:16.389540334,originX:0,originY:.81,deltaX:10.4401539876873,deltaY:.0564332648047,dashes:[.1772,-17.5428451466694],sourceLine:242},{angle:70.3461759419,originX:.17,originY:.86,deltaX:-11.7045066155395,deltaY:.0672672793901,dashes:[.148661,-14.717407747319],sourceLine:243},{angle:293.198590514,originX:.77,originY:1,deltaX:-5.3835637472478,deltaY:.1313064328928,dashes:[.152315,-7.4634581058639],sourceLine:244},{angle:343.610459666,originX:.83,originY:.86,deltaX:-10.4401539876873,deltaY:.0564332648047,dashes:[.1772,-17.542845146669],sourceLine:245},{angle:339.44395478,originX:0,originY:.19,deltaX:-5.3838927710229,deltaY:.117041147157,dashes:[.17088,-8.3731237453175],sourceLine:246},{angle:294.775140569,originX:.16,originY:.13,deltaX:-12.0828441168135,deltaY:.0698430296124,dashes:[.143178,-14.174643063276],sourceLine:247},{angle:66.8014094864,originX:.78,originY:0,deltaX:5.3835637472487,deltaY:.1313064328552,dashes:[.152315,-7.4634581058639],sourceLine:248},{angle:17.3540246363,originX:.84,originY:.14,deltaX:-13.6013396869991,deltaY:.0596549986364,dashes:[.167631,-16.59542361424],sourceLine:249},{angle:69.4439547804,originX:.29,originY:0,deltaX:-5.383892771022,deltaY:.1170411471946,dashes:[.08544,-8.4585637453175],sourceLine:250},{angle:101.309932474,originX:.72,originY:0,deltaX:4.1184388379018,deltaY:.1961161351396,dashes:[.05099,-5.0480295135928],sourceLine:251},{angle:165.963756532,originX:.71,originY:.05,deltaX:-3.1529631254726,deltaY:.2425356250323,dashes:[.206155,-3.9169506256177],sourceLine:252},{angle:186.009005957,originX:.51,originY:.1,deltaX:-10.0497393137326,deltaY:.0523423921723,dashes:[.19105,-18.9139231745428],sourceLine:253},{angle:303.690067526,originX:.62,originY:.62,deltaX:-2.2188007849008,deltaY:.2773500981134,dashes:[.144222,-3.461329275464],sourceLine:254},{angle:353.157226587,originX:.7,originY:.5,deltaX:17.1171966955143,deltaY:.0397150736497,dashes:[.251794,-24.9275626240283],sourceLine:255},{angle:60.9453959009,originX:.95,originY:.47,deltaX:-8.0616726575653,deltaY:.0971285862325,dashes:[.102956,-10.192674140987],sourceLine:256},{angle:90,originX:1,originY:.56,deltaX:1,deltaY:1,dashes:[.06,-.94],sourceLine:257},{angle:120.256437164,originX:.49,originY:.13,deltaX:-8.0619364083848,deltaY:.0719815751411,dashes:[.138924,-13.7535199894498],sourceLine:258},{angle:48.0127875042,originX:.42,originY:.25,deltaX:12.0413651692041,deltaY:.0743294146212,dashes:[.269072,-13.1845520470737],sourceLine:259},{angle:0,originX:.6,originY:.45,deltaX:1,deltaY:1,dashes:[.26,-.74],sourceLine:260},{angle:325.304846469,originX:.86,originY:.45,deltaX:12.2063917682497,deltaY:-.063245553253,dashes:[.158114,-15.653274300842],sourceLine:261},{angle:254.054604099,originX:.99,originY:.36,deltaX:4.1208169184605,deltaY:.1373605639542,dashes:[.145602,-7.1345078892805],sourceLine:262},{angle:207.645975364,originX:.95,originY:.22,deltaX:21.4708691170287,deltaY:.0421824539631,dashes:[.237065,-23.4694741822594],sourceLine:263},{angle:175.42607874,originX:.74,originY:.11,deltaX:13.0383438432524,deltaY:.039872611164,dashes:[.250799,-24.8290734079689],sourceLine:264}]},{name:"HEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.21650635094610965,dashes:[.125,-.25],sourceLine:266},{angle:120,originX:0,originY:0,deltaX:0,deltaY:.21650635094610965,dashes:[.125,-.25],sourceLine:267},{angle:60,originX:.125,originY:0,deltaX:0,deltaY:.21650635094610965,dashes:[.125,-.25],sourceLine:268}]},{name:"HONEY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.1875,deltaY:.10825317547305482,dashes:[.125,-.25],sourceLine:270},{angle:120,originX:0,originY:0,deltaX:.1875,deltaY:.10825317547305482,dashes:[.125,-.25],sourceLine:271},{angle:60,originX:0,originY:0,deltaX:.1875,deltaY:.10825317547305482,dashes:[-.25,.125],sourceLine:272}]},{name:"HOUND",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.25,deltaY:.0625,dashes:[1,-.5],sourceLine:274},{angle:90,originX:0,originY:0,deltaX:-.25,deltaY:.0625,dashes:[1,-.5],sourceLine:275}]},{name:"INSUL",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.375,dashes:[],sourceLine:277},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.375,dashes:[.125,-.125],sourceLine:278},{angle:0,originX:0,originY:.25,deltaX:0,deltaY:.375,dashes:[.125,-.125],sourceLine:279}]},{name:"ACAD_ISO02W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3],sourceLine:292}]},{name:"ACAD_ISO03W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-18],sourceLine:294}]},{name:"ACAD_ISO04W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3],sourceLine:296}]},{name:"ACAD_ISO05W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-3],sourceLine:298}]},{name:"ACAD_ISO06W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-6.5],sourceLine:300},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-34,.5,-3],sourceLine:301}]},{name:"ACAD_ISO07W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[.5,-3],sourceLine:303}]},{name:"ACAD_ISO08W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3],sourceLine:305}]},{name:"ACAD_ISO09W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3,6,-3],sourceLine:307}]},{name:"ACAD_ISO10W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3],sourceLine:309}]},{name:"ACAD_ISO11W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-3],sourceLine:311}]},{name:"ACAD_ISO12W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-3],sourceLine:313}]},{name:"ACAD_ISO13W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-6.5],sourceLine:315},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3],sourceLine:316}]},{name:"ACAD_ISO14W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-6.5],sourceLine:318},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-22,.5,-3],sourceLine:319}]},{name:"ACAD_ISO15W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-10],sourceLine:321},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3,.5,-3],sourceLine:322}]},{name:"LINE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:327}]},{name:"MUDST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.5,deltaY:.25,dashes:[.25,-.25,0,-.25,0,-.25],sourceLine:329}]},{name:"NET",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:331},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:332}]},{name:"NET3",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:334},{angle:60,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:335},{angle:120,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:336}]},{name:"PLAST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:338},{angle:0,originX:0,originY:.03125,deltaX:0,deltaY:.25,dashes:[],sourceLine:339},{angle:0,originX:0,originY:.0625,deltaX:0,deltaY:.25,dashes:[],sourceLine:340}]},{name:"PLASTI",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:342},{angle:0,originX:0,originY:.03125,deltaX:0,deltaY:.25,dashes:[],sourceLine:343},{angle:0,originX:0,originY:.0625,deltaX:0,deltaY:.25,dashes:[],sourceLine:344},{angle:0,originX:0,originY:.15625,deltaX:0,deltaY:.25,dashes:[],sourceLine:345}]},{name:"SACNCR",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.09375,dashes:[],sourceLine:347},{angle:45,originX:.066291261,originY:0,deltaX:0,deltaY:.09375,dashes:[0,-.09375],sourceLine:348}]},{name:"SQUARE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[.125,-.125],sourceLine:350},{angle:90,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[.125,-.125],sourceLine:351}]},{name:"STARS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.216506351,dashes:[.125,-.125],sourceLine:353},{angle:60,originX:0,originY:0,deltaX:0,deltaY:.216506351,dashes:[.125,-.125],sourceLine:354},{angle:120,originX:.0625,originY:.108253176,deltaX:0,deltaY:.216506351,dashes:[.125,-.125],sourceLine:355}]},{name:"STEEL",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.125,dashes:[],sourceLine:357},{angle:45,originX:0,originY:.0625,deltaX:0,deltaY:.125,dashes:[],sourceLine:358}]},{name:"SWAMP",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.5,deltaY:.866025403,dashes:[.125,-.875],sourceLine:360},{angle:90,originX:.0625,originY:0,deltaX:.866025403,deltaY:.5,dashes:[.0625,-1.669550806],sourceLine:361},{angle:90,originX:.078125,originY:0,deltaX:.866025403,deltaY:.5,dashes:[.05,-1.682050806],sourceLine:362},{angle:90,originX:.046875,originY:0,deltaX:.866025403,deltaY:.5,dashes:[.05,-1.682050806],sourceLine:363},{angle:60,originX:.09375,originY:0,deltaX:.5,deltaY:.866025403,dashes:[.04,-.96],sourceLine:364},{angle:120,originX:.03125,originY:0,deltaX:.5,deltaY:.866025403,dashes:[.04,-.96],sourceLine:365}]},{name:"TRANS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.25,dashes:[],sourceLine:367},{angle:0,originX:0,originY:.125,deltaX:0,deltaY:.25,dashes:[.125,-.125],sourceLine:368}]},{name:"TRIANG",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:.1875,deltaY:.324759526,dashes:[.1875,-.1875],sourceLine:370},{angle:120,originX:0,originY:0,deltaX:.1875,deltaY:.324759526,dashes:[.1875,-.1875],sourceLine:371},{angle:0,originX:-.09375,originY:.162379763,deltaX:.1875,deltaY:.324759526,dashes:[.1875,-.1875],sourceLine:372}]},{name:"ZIGZAG",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.125,deltaY:.125,dashes:[.125,-.125],sourceLine:374},{angle:90,originX:.125,originY:0,deltaX:.125,deltaY:.125,dashes:[.125,-.125],sourceLine:375}]}],issues:[]},Ah={patterns:[{name:"SOLID",description:"",lines:[]},{name:"ANGLE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.985,dashes:[5.08,-1.905],sourceLine:20},{angle:90,originX:0,originY:0,deltaX:0,deltaY:6.985,dashes:[5.08,-1.905],sourceLine:21}]},{name:"ANSI31",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:23}]},{name:"ANSI32",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:9.525,dashes:[],sourceLine:25},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:9.525,dashes:[],sourceLine:26}]},{name:"ANSI33",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:28},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:6.35,dashes:[3.175,-1.5875],sourceLine:29}]},{name:"ANSI34",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:31},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:32},{angle:45,originX:8.98026,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:33},{angle:45,originX:13.4704,originY:0,deltaX:0,deltaY:19.05,dashes:[],sourceLine:34}]},{name:"ANSI35",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:36},{angle:45,originX:4.49013,originY:0,deltaX:0,deltaY:6.35,dashes:[7.9375,-1.5875,0,-1.5875],sourceLine:37}]},{name:"ANSI36",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:5.55625,deltaY:3.175,dashes:[7.9375,-1.5875,0,-1.5875],sourceLine:39}]},{name:"ANSI37",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:41},{angle:135,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:42}]},{name:"ANSI38",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:44},{angle:135,originX:0,originY:0,deltaX:6.35,deltaY:3.175,dashes:[7.9375,-4.7625],sourceLine:45}]},{name:"AR-B816",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:203.2,dashes:[],sourceLine:47},{angle:90,originX:0,originY:0,deltaX:203.2,deltaY:203.2,dashes:[203.2,-203.2],sourceLine:48}]},{name:"AR-B816C",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:203.2,deltaY:203.2,dashes:[396.875,-9.525],sourceLine:50},{angle:0,originX:-203.2,originY:9.525,deltaX:203.2,deltaY:203.2,dashes:[396.875,-9.525],sourceLine:51},{angle:90,originX:0,originY:0,deltaX:203.2,deltaY:203.2,dashes:[-212.725,193.675],sourceLine:52},{angle:90,originX:-9.525,originY:0,deltaX:203.2,deltaY:203.2,dashes:[-212.725,193.675],sourceLine:53}]},{name:"AR-B88",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:203.2,dashes:[],sourceLine:55},{angle:90,originX:0,originY:0,deltaX:203.2,deltaY:101.6,dashes:[203.2,-203.2],sourceLine:56}]},{name:"AR-BRELM",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:135.484,dashes:[193.675,-9.525],sourceLine:58},{angle:0,originX:0,originY:57.15,deltaX:0,deltaY:135.484,dashes:[193.675,-9.525],sourceLine:59},{angle:0,originX:50.8,originY:67.7418,deltaX:0,deltaY:135.484,dashes:[92.075,-9.525],sourceLine:60},{angle:0,originX:50.8,originY:124.892,deltaX:0,deltaY:135.484,dashes:[92.075,-9.525],sourceLine:61},{angle:90,originX:0,originY:0,deltaX:0,deltaY:203.2,dashes:[57.15,-78.334],sourceLine:62},{angle:90,originX:-9.525,originY:0,deltaX:0,deltaY:203.2,dashes:[57.15,-78.334],sourceLine:63},{angle:90,originX:50.8,originY:67.7418,deltaX:0,deltaY:101.6,dashes:[57.15,-78.334],sourceLine:64},{angle:90,originX:41.275,originY:67.7418,deltaX:0,deltaY:101.6,dashes:[57.15,-78.334],sourceLine:65}]},{name:"AR-BRSTD",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:67.7418,dashes:[],sourceLine:67},{angle:90,originX:0,originY:0,deltaX:67.7418,deltaY:101.6,dashes:[67.7418,-67.7418],sourceLine:68}]},{name:"AR-CONC",description:"",lines:[{angle:50,originX:0,originY:0,deltaX:104.896,deltaY:-149.807,dashes:[19.05,-209.55],sourceLine:70},{angle:355,originX:0,originY:0,deltaX:-51.76101082,deltaY:187.25814969,dashes:[15.24,-167.64058417],sourceLine:71},{angle:100.4514447,originX:15.182007,originY:-1.3282535,deltaX:145.5569059,deltaY:-176.270089,dashes:[16.1900088,-178.0902446],sourceLine:72},{angle:46.1842,originX:0,originY:50.8,deltaX:157.343,deltaY:-224.71,dashes:[28.575,-314.325],sourceLine:73},{angle:96.63555761,originX:22.5899,originY:47.2965,deltaX:218.33577212,deltaY:-264.40480444,dashes:[24.28502314,-267.13560816],sourceLine:74},{angle:351.18415117,originX:0,originY:50.8,deltaX:196.67912063,deltaY:280.88740361,dashes:[22.85996707,-251.45973192],sourceLine:75},{angle:21,originX:25.4,originY:38.1,deltaX:104.89565868,deltaY:-149.80652586,dashes:[19.05,-209.55],sourceLine:76},{angle:326,originX:25.4,originY:38.1,deltaX:-51.7604,deltaY:187.258,dashes:[15.24,-167.64],sourceLine:77},{angle:71.451445,originX:38.0345326,originY:29.5779001,deltaX:145.5567546,deltaY:-176.2700748,dashes:[16.1900088,-178.0899376],sourceLine:78},{angle:37.5,originX:0,originY:0,deltaX:53.9242,deltaY:65.2018,dashes:[0,-165.608,0,-170.18,0,-168.275],sourceLine:79},{angle:7.5,originX:0,originY:0,deltaX:79.3242,deltaY:90.6018,dashes:[0,-97.028,0,-161.798,0,-64.135],sourceLine:80},{angle:-32.5,originX:-56.642,originY:0,deltaX:117.434,deltaY:68.0212,dashes:[0,-63.5,0,-198.12,0,-262.89],sourceLine:81},{angle:-42.5,originX:-82.042,originY:0,deltaX:92.0344,deltaY:118.821,dashes:[0,-82.55,0,-131.572,0,-186.69],sourceLine:82}]},{name:"AR-HBONE",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:101.6,deltaY:101.6,dashes:[304.8,-101.6],sourceLine:84},{angle:135,originX:71.842,originY:71.842,deltaX:101.6,deltaY:-101.6,dashes:[304.8,-101.6],sourceLine:85}]},{name:"AR-PARQ1",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:87},{angle:90,originX:50.8,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:88},{angle:90,originX:101.6,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:89},{angle:90,originX:152.4,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:90},{angle:90,originX:203.2,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:91},{angle:90,originX:254,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:92},{angle:90,originX:304.8,originY:0,deltaX:304.8,deltaY:304.8,dashes:[304.8,-304.8],sourceLine:93},{angle:0,originX:0,originY:304.8,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:94},{angle:0,originX:0,originY:355.6,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:95},{angle:0,originX:0,originY:406.4,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:96},{angle:0,originX:0,originY:457.2,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:97},{angle:0,originX:0,originY:508,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:98},{angle:0,originX:0,originY:558.8,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:99},{angle:0,originX:0,originY:609.6,deltaX:304.8,deltaY:-304.8,dashes:[304.8,-304.8],sourceLine:100}]},{name:"AR-RROOF",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:55.88,deltaY:25.4,dashes:[381,-50.8,127,-25.4],sourceLine:102},{angle:0,originX:33.782,originY:12.7,deltaX:-25.4,deltaY:33.782,dashes:[76.2,-8.382,152.4,-19.05],sourceLine:103},{angle:0,originX:12.7,originY:21.59,deltaX:132.08,deltaY:17.018,dashes:[203.2,-35.56,101.6,-25.4],sourceLine:104}]},{name:"AR-RSHKE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:647.7,deltaY:304.8,dashes:[152.4,-127,177.8,-76.2,228.6,-101.6],sourceLine:106},{angle:0,originX:152.4,originY:12.7,deltaX:647.7,deltaY:304.8,dashes:[127,-482.6,101.6,-152.4],sourceLine:107},{angle:0,originX:457.2,originY:-19.05,deltaX:647.7,deltaY:304.8,dashes:[76.2,-787.4],sourceLine:108},{angle:90,originX:0,originY:0,deltaX:304.8,deltaY:215.9,dashes:[292.1,-927.1],sourceLine:109},{angle:90,originX:152.4,originY:0,deltaX:304.8,deltaY:215.9,dashes:[285.75,-933.45],sourceLine:110},{angle:90,originX:279.4,originY:0,deltaX:304.8,deltaY:215.9,dashes:[266.7,-952.5],sourceLine:111},{angle:90,originX:457.2,originY:-19.05,deltaX:304.8,deltaY:215.9,dashes:[292.1,-927.1],sourceLine:112},{angle:90,originX:533.4,originY:-19.05,deltaX:304.8,deltaY:215.9,dashes:[292.1,-927.1],sourceLine:113},{angle:90,originX:762,originY:0,deltaX:304.8,deltaY:215.9,dashes:[279.4,-939.8],sourceLine:114}]},{name:"AR-SAND",description:"",lines:[{angle:37.5,originX:0,originY:0,deltaX:28.5242,deltaY:39.8018,dashes:[0,-38.608,0,-43.18,0,-41.275],sourceLine:116},{angle:7.5,originX:0,originY:0,deltaX:53.9242,deltaY:65.2018,dashes:[0,-20.828,0,-34.798,0,-13.335],sourceLine:117},{angle:-32.5,originX:-31.242,originY:0,deltaX:66.6344,deltaY:42.6212,dashes:[0,-12.7,0,-45.72,0,-59.69],sourceLine:118},{angle:-42.5,originX:-31.242,originY:0,deltaX:41.2344,deltaY:68.0212,dashes:[0,-6.35,0,-29.972,0,-34.29],sourceLine:119}]},{name:"BOX",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[],sourceLine:121},{angle:90,originX:6.35,originY:0,deltaX:0,deltaY:25.4,dashes:[],sourceLine:122},{angle:0,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[-6.35,6.35],sourceLine:123},{angle:0,originX:0,originY:6.35,deltaX:0,deltaY:25.4,dashes:[-6.35,6.35],sourceLine:124},{angle:0,originX:0,originY:12.7,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:125},{angle:0,originX:0,originY:19.05,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:126},{angle:90,originX:12.7,originY:0,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:127},{angle:90,originX:19.05,originY:0,deltaX:0,deltaY:25.4,dashes:[6.35,-6.35],sourceLine:128}]},{name:"BRASS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:130},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:6.35,dashes:[3.175,-1.5875],sourceLine:131}]},{name:"BRICK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:133},{angle:90,originX:0,originY:0,deltaX:0,deltaY:12.7,dashes:[6.35,-6.35],sourceLine:134},{angle:90,originX:6.35,originY:0,deltaX:0,deltaY:12.7,dashes:[-6.35,6.35],sourceLine:135}]},{name:"BRSTONE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:8.382,dashes:[],sourceLine:137},{angle:90,originX:22.86,originY:0,deltaX:8.382,deltaY:12.7,dashes:[8.382,-8.382],sourceLine:138},{angle:90,originX:20.32,originY:0,deltaX:8.382,deltaY:12.7,dashes:[8.382,-8.382],sourceLine:139},{angle:0,originX:22.86,originY:1.397,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:140},{angle:0,originX:22.86,originY:2.794,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:141},{angle:0,originX:22.86,originY:4.191,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:142},{angle:0,originX:22.86,originY:5.588,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:143},{angle:0,originX:22.86,originY:6.985,deltaX:12.7,deltaY:8.382,dashes:[-22.86,2.54],sourceLine:144}]},{name:"CLAY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:4.7625,dashes:[],sourceLine:146},{angle:0,originX:0,originY:.79375,deltaX:0,deltaY:4.7625,dashes:[],sourceLine:147},{angle:0,originX:0,originY:1.5875,deltaX:0,deltaY:4.7625,dashes:[],sourceLine:148},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:4.7625,dashes:[4.7625,-3.175],sourceLine:149}]},{name:"CORK",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:151},{angle:135,originX:1.5875,originY:-1.5875,deltaX:0,deltaY:8.98026,dashes:[4.49013,-4.49013],sourceLine:152},{angle:135,originX:2.38125,originY:-1.5875,deltaX:0,deltaY:8.98026,dashes:[4.49013,-4.49013],sourceLine:153},{angle:135,originX:3.175,originY:-1.5875,deltaX:0,deltaY:8.98026,dashes:[4.49013,-4.49013],sourceLine:154}]},{name:"CROSS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:6.35,deltaY:6.35,dashes:[3.175,-9.525],sourceLine:156},{angle:90,originX:1.5875,originY:-1.5875,deltaX:6.35,deltaY:6.35,dashes:[3.175,-9.525],sourceLine:157}]},{name:"DASH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:3.175,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:159}]},{name:"DOLMIT",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:161},{angle:45,originX:0,originY:0,deltaX:0,deltaY:17.9605,dashes:[8.980256121069154,-17.960512242138307],sourceLine:162}]},{name:"DOTS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:.79375,deltaY:1.5875,dashes:[0,-1.5875],sourceLine:164}]},{name:"EARTH",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:166},{angle:0,originX:0,originY:2.38125,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:167},{angle:0,originX:0,originY:4.7625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:168},{angle:90,originX:.79375,originY:5.55625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:169},{angle:90,originX:3.175,originY:5.55625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:170},{angle:90,originX:5.55625,originY:5.55625,deltaX:6.35,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:171}]},{name:"ESCHER",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[27.94,-2.54],sourceLine:173},{angle:180,originX:0,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[27.94,-2.54],sourceLine:174},{angle:300,originX:0,originY:0,deltaX:15.24,deltaY:26.3964542936,dashes:[27.94,-2.54],sourceLine:175},{angle:60,originX:2.54,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:176},{angle:300,originX:2.54,originY:0,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:177},{angle:60,originX:-1.27,originY:2.199704516,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:178},{angle:180,originX:-1.27,originY:2.199704516,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:179},{angle:300,originX:-1.27,originY:-2.199704516,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:180},{angle:180,originX:-1.27,originY:-2.199704516,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:181},{angle:60,originX:-10.16,originY:0,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:182},{angle:300,originX:-10.16,originY:0,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:183},{angle:60,originX:5.08,originY:-8.7988180894,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:184},{angle:180,originX:5.08,originY:-8.7988180894,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:185},{angle:300,originX:5.08,originY:8.7988180894,deltaX:15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:186},{angle:180,originX:5.08,originY:8.7988180894,deltaX:-15.24,deltaY:26.3964542936,dashes:[5.08,-25.4],sourceLine:187},{angle:0,originX:5.08,originY:4.3994090574,deltaX:-15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:188},{angle:0,originX:5.08,originY:-4.3994090574,deltaX:-15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:189},{angle:120,originX:1.27,originY:6.5991135734,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:190},{angle:120,originX:-6.35,originY:2.199704516,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:191},{angle:240,originX:-6.35,originY:-2.199704516,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:192},{angle:240,originX:1.27,originY:-6.5991135734,deltaX:15.24,deltaY:26.3964542936,dashes:[17.78,-12.7],sourceLine:193}]},{name:"FLEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[6.35,-6.35],sourceLine:195},{angle:45,originX:6.35,originY:0,deltaX:4.490128053,deltaY:4.490128053,dashes:[1.5875,-5.8052561314,1.5875,-8.9802561314],sourceLine:196}]},{name:"GOST_GLASS",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:6,deltaY:-6,dashes:[5,-7],sourceLine:198},{angle:45,originX:2.12132,originY:0,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:199},{angle:45,originX:0,originY:2.12132,deltaX:6,deltaY:-6,dashes:[2,-10],sourceLine:200}]},{name:"GOST_WOOD",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:202},{angle:90,originX:2,originY:-2,deltaX:0,deltaY:-6,dashes:[6,-1.5,3,-1.5],sourceLine:203},{angle:90,originX:4,originY:-5,deltaX:0,deltaY:-6,dashes:[10,-2],sourceLine:204}]},{name:"GOST_GROUND",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:206},{angle:45,originX:3,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:207},{angle:45,originX:6,originY:0,deltaX:10,deltaY:-10,dashes:[20],sourceLine:208}]},{name:"GRASS",description:"",lines:[{angle:90,originX:0,originY:0,deltaX:17.96051224,deltaY:17.96051224,dashes:[4.7625,-31.15852448],sourceLine:210},{angle:45,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[4.7625,-20.6375],sourceLine:211},{angle:135,originX:0,originY:0,deltaX:0,deltaY:25.4,dashes:[4.7625,-20.6375],sourceLine:212}]},{name:"GRATE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:.79375,dashes:[],sourceLine:214},{angle:90,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:215}]},{name:"GRAVEL",description:"",lines:[{angle:228.0127875,originX:18.288,originY:25.4,deltaX:305.85067529778,deltaY:1.88796713245,dashes:[3.4172144,-338.30483639565],sourceLine:217},{angle:184.969741,originX:16.002,originY:22.86,deltaX:-305.8545235377,deltaY:1.10019612724,dashes:[5.8640472,-580.54048893524],sourceLine:218},{angle:132.5104471,originX:10.16,originY:22.352,deltaX:-377.59492241548,deltaY:1.56030959675,dashes:[4.1348152,-409.347227941],sourceLine:219},{angle:267.273689,originX:.254,originY:16.002,deltaX:-508.63316875916,deltaY:1.20815479432,dashes:[5.3400452,-528.66437425738],sourceLine:220},{angle:292.83365418,originX:0,originY:10.668,deltaX:-330.19770134945,deltaY:1.23208097566,dashes:[5.236337,-518.39807745344],sourceLine:221},{angle:357.273689,originX:2.032,originY:5.842,deltaX:-508.63316875916,deltaY:1.20815479432,dashes:[5.3400452,-528.66437425738],sourceLine:222},{angle:37.69424047,originX:7.366,originY:5.588,deltaX:-416.58997273292,deltaY:.91357450169,dashes:[7.0619366,-699.13115314247],sourceLine:223},{angle:72.25532837,originX:12.954,originY:9.906,deltaX:586.40373773403,deltaY:.96766293399,dashes:[6.6671952,-660.05256601905],sourceLine:224},{angle:121.42956562,originX:14.986,originY:16.256,deltaX:387.71230339293,deltaY:1.2040754753,dashes:[5.35813,-530.45545698712],sourceLine:225},{angle:175.2363583,originX:12.192,originY:20.828,deltaX:-280.5442400419,deltaY:2.10935518695,dashes:[6.1171328,-299.7393695],sourceLine:226},{angle:222.3974378,originX:6.096,originY:21.336,deltaX:413.48123885686,deltaY:.81554484621,dashes:[7.9107792,-783.16772512177],sourceLine:227},{angle:138.81407483,originX:25.4,originY:15.748,deltaX:234.164238558,deltaY:2.38943100688,dashes:[2.7000454,-267.30565824344],sourceLine:228},{angle:171.4692344,originX:23.368,originY:17.526,deltaX:-334.082478726,deltaY:1.25594916784,dashes:[5.1368198,-508.5463899704],sourceLine:229},{angle:225,originX:18.288,originY:18.288,deltaX:17.96051224214,deltaY:17.96051224214,dashes:[3.5920934,-32.32893108428],sourceLine:230},{angle:203.19859051,originX:16.51,originY:21.336,deltaX:-136.74251918,deltaY:3.33518339548,dashes:[1.9344132,-191.50622368894],sourceLine:231},{angle:291.80140949,originX:14.732,originY:20.574,deltaX:-80.18324702488,deltaY:4.71666158921,dashes:[2.7356562,-134.0475299],sourceLine:232},{angle:30.96375653,originX:15.748,originY:18.034,deltaX:91.47734531502,deltaY:4.35606406258,dashes:[4.4431966,-143.6629815291],sourceLine:233},{angle:161.56505118,originX:19.558,originY:20.32,deltaX:-56.2252967978,deltaY:8.03218525675,dashes:[3.2128714,-77.10898116828],sourceLine:234},{angle:16.389540334,originX:0,originY:20.574,deltaX:265.17991128726,deltaY:1.43340492604,dashes:[4.50088,-445.58826672539],sourceLine:235},{angle:70.34617594,originX:4.318,originY:21.844,deltaX:-297.29446803469,deltaY:1.70858889651,dashes:[3.7759894,-373.822156782],sourceLine:236},{angle:293.19859051,originX:19.558,originY:25.4,deltaX:-136.7425191801,deltaY:3.33518339548,dashes:[3.868801,-189.57183588894],sourceLine:237},{angle:343.61045967,originX:21.082,originY:21.844,deltaX:-265.17991128725,deltaY:1.433404926,dashes:[4.50088,-445.5882667254],sourceLine:238},{angle:339.44395478,originX:0,originY:4.826,deltaX:-136.75087638398,deltaY:2.97284513779,dashes:[4.340352,-212.67734313106],sourceLine:239},{angle:294.7751406,originX:4.064,originY:3.302,deltaX:-306.90424056705,deltaY:1.77401295215,dashes:[3.6367212,-360.0359338072],sourceLine:240},{angle:66.80140949,originX:19.812,originY:0,deltaX:136.74251918012,deltaY:3.33518339452,dashes:[3.868801,-189.57183588894],sourceLine:241},{angle:17.35402464,originX:21.336,originY:3.556,deltaX:-345.47402804977,deltaY:1.51523696536,dashes:[4.2578274,-421.523759802],sourceLine:242},{angle:69.44395478,originX:7.366,originY:0,deltaX:-136.75087638396,deltaY:2.97284513874,dashes:[2.170176,-214.84751913106],sourceLine:243},{angle:101.309932474,originX:18.288,originY:0,deltaX:104.60834648271,deltaY:4.98134983255,dashes:[1.295146,-128.21994964526],sourceLine:244},{angle:165.963756532,originX:18.034,originY:1.27,deltaX:-80.085263387,deltaY:6.16040487582,dashes:[5.236337,-99.49054589069],sourceLine:245},{angle:186.00900596,originX:12.954,originY:2.54,deltaX:-255.26337856879,deltaY:1.32949676118,dashes:[4.85267,-480.41364863337],sourceLine:246},{angle:303.69006753,originX:15.748,originY:15.748,deltaX:-56.35753993648,deltaY:7.0446924921,dashes:[3.6632388,-87.9177635968],sourceLine:247},{angle:353.15722659,originX:17.78,originY:12.7,deltaX:434.77679606606,deltaY:1.0087628707,dashes:[6.3955676,-633.16009065031],sourceLine:248},{angle:60.9453959,originX:24.13,originY:11.938,deltaX:-204.76648550216,deltaY:2.46706609031,dashes:[2.6150824,-258.8939231811],sourceLine:249},{angle:90,originX:25.4,originY:14.224,deltaX:25.4,deltaY:25.4,dashes:[1.524,-23.876],sourceLine:250},{angle:120.25643716,originX:12.446,originY:3.302,deltaX:-204.77318477297,deltaY:1.8283320086,dashes:[3.5286696,-349.339407732],sourceLine:251},{angle:48.0127875,originX:10.668,originY:6.35,deltaX:305.85067529778,deltaY:1.88796713138,dashes:[6.8344288,-334.88762199565],sourceLine:252},{angle:0,originX:15.24,originY:11.43,deltaX:25.4,deltaY:25.4,dashes:[6.604,-18.796],sourceLine:253},{angle:325.3048465,originX:21.844,originY:11.43,deltaX:310.04235091354,deltaY:-1.6064370526,dashes:[4.0160956,-397.5931672414],sourceLine:254},{angle:254.0546041,originX:25.146,originY:9.144,deltaX:104.6687497289,deltaY:3.48895832444,dashes:[3.6982908,-181.21650038772],sourceLine:255},{angle:207.64597536,originX:24.13,originY:5.588,deltaX:545.36007557253,deltaY:1.07143433066,dashes:[6.021451,-596.12464422938],sourceLine:256},{angle:175.42607874,originX:18.796,originY:2.794,deltaX:331.1739336186,deltaY:1.01276432357,dashes:[6.3702946,-630.6584645624],sourceLine:257}]},{name:"HEX",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-6.35],sourceLine:259},{angle:120,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-6.35],sourceLine:260},{angle:60,originX:3.175,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-6.35],sourceLine:261}]},{name:"HONEY",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:4.7625,deltaY:2.749630645,dashes:[3.175,-6.35],sourceLine:263},{angle:120,originX:0,originY:0,deltaX:4.7625,deltaY:2.749630645,dashes:[3.175,-6.35],sourceLine:264},{angle:60,originX:0,originY:0,deltaX:4.7625,deltaY:2.749630645,dashes:[-6.35,3.175],sourceLine:265}]},{name:"HOUND",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:6.35,deltaY:1.5875,dashes:[25.4,-12.7],sourceLine:267},{angle:90,originX:0,originY:0,deltaX:-6.35,deltaY:1.5875,dashes:[25.4,-12.7],sourceLine:268}]},{name:"INSUL",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:9.525,dashes:[],sourceLine:270},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:9.525,dashes:[3.175,-3.175],sourceLine:271},{angle:0,originX:0,originY:6.35,deltaX:0,deltaY:9.525,dashes:[3.175,-3.175],sourceLine:272}]},{name:"ACAD_ISO02W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3],sourceLine:285}]},{name:"ACAD_ISO03W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-18],sourceLine:287}]},{name:"ACAD_ISO04W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3],sourceLine:289}]},{name:"ACAD_ISO05W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-3],sourceLine:291}]},{name:"ACAD_ISO06W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,.5,-3,.5,-6.5],sourceLine:293},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-34,.5,-3],sourceLine:294}]},{name:"ACAD_ISO07W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[.5,-3],sourceLine:296}]},{name:"ACAD_ISO08W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3],sourceLine:298}]},{name:"ACAD_ISO09W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[24,-3,6,-3,6,-3],sourceLine:300}]},{name:"ACAD_ISO10W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3],sourceLine:302}]},{name:"ACAD_ISO11W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-3],sourceLine:304}]},{name:"ACAD_ISO12W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-3],sourceLine:306}]},{name:"ACAD_ISO13W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-6.5],sourceLine:308},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3],sourceLine:309}]},{name:"ACAD_ISO14W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,.5,-3,.5,-6.5],sourceLine:311},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-22,.5,-3],sourceLine:312}]},{name:"ACAD_ISO15W100",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[12,-3,12,-3,.5,-10],sourceLine:314},{angle:0,originX:0,originY:0,deltaX:0,deltaY:5,dashes:[-33.5,.5,-3,.5,-3],sourceLine:315}]},{name:"JIS_LC_20",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:322},{angle:45,originX:.4,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:323}]},{name:"JIS_LC_20A",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:325},{angle:45,originX:1,originY:0,deltaX:0,deltaY:20,dashes:[],sourceLine:326}]},{name:"JIS_LC_8",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:328},{angle:45,originX:.4,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:329}]},{name:"JIS_LC_8A",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:331},{angle:45,originX:1,originY:0,deltaX:0,deltaY:7.8,dashes:[],sourceLine:332}]},{name:"JIS_RC_10",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:10,dashes:[],sourceLine:334},{angle:45,originX:.725,originY:0,deltaX:0,deltaY:10,dashes:[],sourceLine:335},{angle:45,originX:1.45,originY:0,deltaX:0,deltaY:10,dashes:[],sourceLine:336}]},{name:"JIS_RC_15",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:15,dashes:[],sourceLine:338},{angle:45,originX:.725,originY:0,deltaX:0,deltaY:15,dashes:[],sourceLine:339},{angle:45,originX:1.45,originY:0,deltaX:0,deltaY:15,dashes:[],sourceLine:340}]},{name:"JIS_RC_18",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:18,dashes:[],sourceLine:342},{angle:45,originX:1,originY:0,deltaX:0,deltaY:18,dashes:[],sourceLine:343},{angle:45,originX:2,originY:0,deltaX:0,deltaY:18,dashes:[],sourceLine:344}]},{name:"JIS_RC_30",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:30,dashes:[],sourceLine:346},{angle:45,originX:1,originY:0,deltaX:0,deltaY:30,dashes:[],sourceLine:347},{angle:45,originX:2,originY:0,deltaX:0,deltaY:30,dashes:[],sourceLine:348}]},{name:"JIS_STN_1E",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:1,dashes:[],sourceLine:350},{angle:45,originX:.705,originY:0,deltaX:0,deltaY:1,dashes:[1,-.5],sourceLine:351}]},{name:"JIS_STN_2.5",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:2.5,dashes:[],sourceLine:353},{angle:45,originX:1.765,originY:0,deltaX:0,deltaY:2.5,dashes:[1.2,-.5],sourceLine:354}]},{name:"JIS_WOOD",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:.70710678,dashes:[],sourceLine:356}]},{name:"LINE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:359}]},{name:"MUDST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:12.7,deltaY:6.35,dashes:[6.35,-6.35,0,-6.35,0,-6.35],sourceLine:361}]},{name:"NET",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:363},{angle:90,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:364}]},{name:"NET3",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:366},{angle:60,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:367},{angle:120,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:368}]},{name:"PLAST",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:370},{angle:0,originX:0,originY:.79375,deltaX:0,deltaY:6.35,dashes:[],sourceLine:371},{angle:0,originX:0,originY:1.5875,deltaX:0,deltaY:6.35,dashes:[],sourceLine:372}]},{name:"PLASTI",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:374},{angle:0,originX:0,originY:.79375,deltaX:0,deltaY:6.35,dashes:[],sourceLine:375},{angle:0,originX:0,originY:1.5875,deltaX:0,deltaY:6.35,dashes:[],sourceLine:376},{angle:0,originX:0,originY:3.96875,deltaX:0,deltaY:6.35,dashes:[],sourceLine:377}]},{name:"SACNCR",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:2.38125,dashes:[],sourceLine:379},{angle:45,originX:1.6838,originY:0,deltaX:0,deltaY:2.38125,dashes:[0,-2.38125],sourceLine:380}]},{name:"SQUARE",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:382},{angle:90,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:383}]},{name:"STARS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-3.175],sourceLine:385},{angle:60,originX:0,originY:0,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-3.175],sourceLine:386},{angle:120,originX:1.5875,originY:2.7496306704,deltaX:0,deltaY:5.4992613154,dashes:[3.175,-3.175],sourceLine:387}]},{name:"STEEL",description:"",lines:[{angle:45,originX:0,originY:0,deltaX:0,deltaY:3.175,dashes:[],sourceLine:389},{angle:45,originX:0,originY:1.5875,deltaX:0,deltaY:3.175,dashes:[],sourceLine:390}]},{name:"SWAMP",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:12.7,deltaY:21.9970452362,dashes:[3.175,-22.225],sourceLine:392},{angle:90,originX:1.5875,originY:0,deltaX:21.9970452362,deltaY:12.7,dashes:[1.5875,-42.4065904724],sourceLine:393},{angle:90,originX:1.984375,originY:0,deltaX:21.9970452362,deltaY:12.7,dashes:[1.27,-42.7240904724],sourceLine:394},{angle:90,originX:1.190625,originY:0,deltaX:21.9970452362,deltaY:12.7,dashes:[1.27,-42.7240904724],sourceLine:395},{angle:60,originX:2.38125,originY:0,deltaX:12.7,deltaY:21.9970452362,dashes:[1.016,-24.384],sourceLine:396},{angle:120,originX:.79375,originY:0,deltaX:12.7,deltaY:21.9970452362,dashes:[1.016,-24.384],sourceLine:397}]},{name:"TRANS",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:0,deltaY:6.35,dashes:[],sourceLine:399},{angle:0,originX:0,originY:3.175,deltaX:0,deltaY:6.35,dashes:[3.175,-3.175],sourceLine:400}]},{name:"TRIANG",description:"",lines:[{angle:60,originX:0,originY:0,deltaX:4.7625,deltaY:8.2488919604,dashes:[4.7625,-4.7625],sourceLine:402},{angle:120,originX:0,originY:0,deltaX:4.7625,deltaY:8.2488919604,dashes:[4.7625,-4.7625],sourceLine:403},{angle:0,originX:-2.38125,originY:4.1244459802,deltaX:4.7625,deltaY:8.2488919604,dashes:[4.7625,-4.7625],sourceLine:404}]},{name:"ZIGZAG",description:"",lines:[{angle:0,originX:0,originY:0,deltaX:3.175,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:406},{angle:90,originX:3.175,originY:0,deltaX:3.175,deltaY:3.175,dashes:[3.175,-3.175],sourceLine:407}]}],issues:[]};var Pi=(n=>(n[n.UserDefined=0]="UserDefined",n[n.Predefined=1]="Predefined",n[n.Custom=2]="Custom",n))(Pi||{}),Sh=(n=>(n[n.Normal=0]="Normal",n[n.Outer=1]="Outer",n[n.Ignore=2]="Ignore",n))(Sh||{}),Ph=(n=>(n[n.HatchObject=0]="HatchObject",n[n.GradientObject=1]="GradientObject",n))(Ph||{}),Ih=(n=>(n[n.PreDefinedGradient=0]="PreDefinedGradient",n[n.UserDefinedGradient=1]="UserDefinedGradient",n))(Ih||{});const ka=class ka extends H{constructor(){super(),this._gradientAngle=0,this._elevation=0,this._geo=new Vt,this._isSolidFill=!1,this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1,this._patternName="",this._patternNameSet=!1,this._patternType=1,this._patternAngle=0,this._patternAngleSet=!1,this._patternScale=1,this._patternScaleSet=!1,this._associative=!1,this._associativeSet=!1,this._backgroundColor=void 0,this._backgroundColorSet=!1,this._patternDouble=!1,this._patternDoubleSet=!1,this._hatchStyle=0,this._hatchStyleSet=!1,this._hatchObjectType=0,this._gradientAngle=0,this._gradientShift=0,this._shadeTintValue=0,this._gradientStartColor=void 0,this._gradientEndColor=void 0,this._pixelSize=void 0,this._gradientType=0,this._gradientName="",this._gradientOneColorMode=!1}get dxfTypeName(){return"HATCH"}get isGradient(){return this._hatchObjectType===1}get isHatch(){return this._hatchObjectType===0}get isSolidFill(){return this._isSolidFill||this.getEffectivePatternName().trim().toUpperCase()===Oe}set isSolidFill(t){this._isSolidFill=t}get color(){if(this.hasExplicitColor())return this.getEntityColor();const t=this.database,e=ft.instance().getVar(E.HPCOLOR,t);return e instanceof X&&e.colorMethod!==exports.AcCmColorMethod.None?e.clone():t.cecolor.clone()}set color(t){this.setEntityColor(t)}get definitionLines(){return this._definitionLines}get patternName(){return this._patternName}set patternName(t){this._patternName=t??"",this._isSolidFill=this._patternName.trim().toUpperCase()===Oe,this._patternNameSet=!0,this.updatePredefinedPatternDefinitionLines()}get patternType(){return this._patternType}set patternType(t){this._patternType=t,t!==1&&this._definitionLinesAutoGenerated&&(this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1),this.updatePredefinedPatternDefinitionLines()}get patternAngle(){return this._patternAngle}set patternAngle(t){this._patternAngle=t,this._patternAngleSet=!0}get patternScale(){return this._patternScale}set patternScale(t){this._patternScale=t,this._patternScaleSet=!0,this.updatePredefinedPatternDefinitionLines()}get associative(){return this._associative}set associative(t){this._associative=!!t,this._associativeSet=!0}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){this._backgroundColor=t==null?void 0:t.clone(),this._backgroundColorSet=!0}get patternDouble(){return this._patternDouble}set patternDouble(t){this._patternDouble=!!t,this._patternDoubleSet=!0}get hatchStyle(){return this._hatchStyle}set hatchStyle(t){this._hatchStyle=t,this._hatchStyleSet=!0}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get hatchObjectType(){return this._hatchObjectType}set hatchObjectType(t){this._hatchObjectType=t}get gradientAngle(){return this._gradientAngle}set gradientAngle(t){this._gradientAngle=t}get gradientShift(){return this._gradientShift}set gradientShift(t){this._gradientShift=t}get gradientType(){return this._gradientType}set gradientType(t){this._gradientType=t}get gradientName(){return this.isGradient&&this._gradientName.trim()===""?ul:this._gradientName}set gradientName(t){this._gradientName=t??""}get gradientOneColorMode(){return this._gradientOneColorMode}set gradientOneColorMode(t){this._gradientOneColorMode=t}get shadeTintValue(){return this._shadeTintValue}set shadeTintValue(t){this._shadeTintValue=t}get gradientStartColor(){return this._gradientStartColor}set gradientStartColor(t){this._gradientStartColor=t==null||!Number.isFinite(t)?void 0:t&16777215}get gradientEndColor(){return this._gradientEndColor}set gradientEndColor(t){this._gradientEndColor=t==null||!Number.isFinite(t)?void 0:t&16777215}get pixelSize(){return this._pixelSize}set pixelSize(t){this._pixelSize=t}applyPatternDefaultsFromSysVars(t){const e=ft.instance();if(!this.hasExplicitLayer()){const i=e.getVar(E.HPLAYER,t);this.shouldUseSysVarOverride(i)&&(this.layer=i)}if(!this.hasExplicitTransparency()){const i=this.parseHpTransparency(e.getVar(E.HPTRANSPARENCY,t));i&&(this.transparency=i)}if(this._backgroundColorSet||(this._backgroundColor=this.parseHpBackgroundColor(e.getVar(E.HPBACKGROUNDCOLOR,t)),this._backgroundColorSet=!0),!this._patternNameSet){const i=e.getVar(E.HPNAME,t);this._patternName=typeof i=="string"?i:"",this._patternNameSet=!0}if(!this._patternAngleSet){const i=e.getVar(E.HPANG,t);this._patternAngle=typeof i=="number"&&Number.isFinite(i)?i:0,this._patternAngleSet=!0}if(this._patternScaleSet||(this._patternScale=this.normalizePatternScale(e.getVar(E.HPSCALE,t)),this._patternScaleSet=!0),!this._associativeSet){const i=e.getVar(E.HPASSOC,t);this._associative=typeof i=="number"?i!==0:!1,this._associativeSet=!0}if(this._hatchStyleSet||(this._hatchStyle=this.normalizeHatchStyle(e.getVar(E.HPISLANDDETECTION,t)),this._hatchStyleSet=!0),!this._patternDoubleSet){const i=e.getVar(E.HPDOUBLE,t);this._patternDouble=typeof i=="number"?i!==0:!1,this._patternDoubleSet=!0}this.updatePredefinedPatternDefinitionLines()}getEffectivePatternName(){if(this._patternNameSet)return this._patternName;const t=this.database,e=ft.instance().getVar(E.HPNAME,t);return typeof e=="string"?e:this._patternName}shouldResolveColorFromCecolor(){return!1}getEffectivePatternAngle(){if(this._patternAngleSet)return this._patternAngle;const t=this.database,e=ft.instance().getVar(E.HPANG,t);return typeof e=="number"&&Number.isFinite(e)?e:this._patternAngle}getRenderablePatternAngle(){return!this._definitionLinesAutoGenerated&&this._definitionLines.length>0?0:this.getEffectivePatternAngle()}getEffectivePatternScale(){if(this._patternScaleSet)return this._patternScale;const t=this.database;return this.normalizePatternScale(ft.instance().getVar(E.HPSCALE,t))}getEffectiveAssociative(){if(this._associativeSet)return this._associative;const t=this.database,e=ft.instance().getVar(E.HPASSOC,t);return typeof e=="number"?e!==0:this._associative}normalizePatternScale(t){return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1}normalizeHatchStyle(t){return typeof t!="number"||!Number.isFinite(t)?1:t===0?0:t===2?2:1}shouldUseSysVarOverride(t){if(typeof t!="string")return!1;const e=t.trim().toLowerCase();return e!==""&&e!=="."&&e!=="use current"}parseHpBackgroundColor(t){if(t instanceof X)return t.colorMethod===exports.AcCmColorMethod.None?void 0:t.clone();if(typeof t!="string")return;const e=t.trim().toLowerCase();if(!(!e||e==="."||e==="none"))return X.fromString(t)}parseHpTransparency(t){if(t instanceof ot)return t.clone();if(!this.shouldUseSysVarOverride(t))return;const e=t.trim();if(/^bylayer$/i.test(e)||/^byblock$/i.test(e))return ot.fromString(e);const i=Number(e);if(Number.isInteger(i)&&i>=0&&i<=90){const r=new ot;return r.percentage=i,r}}updatePredefinedPatternDefinitionLines(t=this.getEffectivePatternName(),e=this.getEffectivePatternScale()){if(this.patternType!==1||!(this._definitionLinesAutoGenerated||this._definitionLines.length===0))return;const r=t.trim().toUpperCase();if(!r||r===Oe){this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1;return}const s=this.normalizePatternScale(e);if(this._definitionLinesAutoGenerated&&this._definitionLinesPatternName===r&&this._definitionLinesPatternScale===s)return;const a=Ah.patterns.find(o=>o.name.trim().toUpperCase()===r);if(!a){this._definitionLinesAutoGenerated&&(this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1);return}this._definitionLines=a.lines.map(o=>({angle:o.angle*Math.PI/180,base:{x:o.originX*s,y:o.originY*s},offset:{x:o.deltaX*s,y:o.deltaY*s},dashLengths:o.dashes.map(c=>c*s)})),this._definitionLinesAutoGenerated=!0,this._definitionLinesPatternName=r,this._definitionLinesPatternScale=s}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=(s,a)=>{if(s.index>=0&&a%2===0){const o=new Vt;o.add(t[s.index]),s.children.forEach(c=>{c.index>=0&&o.add(t[c.index])}),i.push(o)}s.children.forEach(o=>r(o,a+1))};return e.children.forEach(s=>r(s,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 area(){return this.getCalculatedAreaValue()}get geometricExtents(){const t=this.buildAreasFromLoops();if(t.length===0)return new Y;const e=new Y;return t.forEach(i=>{const r=i.box;e.union(new Y({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:Pi[0],value:0},{label:Pi[1],value:1},{label:Pi[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}}},{name:"associative",type:"boolean",editable:!0,accessor:{get:()=>this.associative,set:t=>{this.associative=t}}},{name:"backgroundColor",type:"color",editable:!0,accessor:{get:()=>this.backgroundColor,set:t=>{this.backgroundColor=t}}},{name:"patternDouble",type:"boolean",editable:!0,accessor:{get:()=>this.patternDouble,set:t=>{this.patternDouble=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.area}}]}]}}subGetGripPoints(){return this.associative?[]:this.collectBoundaryGripPoints()}subMoveGripPointsAt(t,e){return this.associative?this:(ht(t,i=>{this.moveBoundaryGripPointAt(i,e)}),this)}collectBoundaryGripPoints(){const t=new Array,e=this._elevation,i=new Set,r=s=>{const a=`${s.x},${s.y},${s.z??0}`;i.has(a)||(i.add(a),t.push(new b(s.x,s.y,s.z??e)))};return this._geo.loops.forEach(s=>{if(s instanceof q){const a=s.numberOfVertices;for(let o=0;o<a;o++){const c=s.getPointAt(o);r({x:c.x,y:c.y,z:e})}return}s.curves.forEach(a=>{if(a instanceof zt)r({x:a.startPoint.x,y:a.startPoint.y,z:e}),r({x:a.endPoint.x,y:a.endPoint.y,z:e});else if(a instanceof vt)r({x:a.startPoint.x,y:a.startPoint.y,z:e}),r({x:a.endPoint.x,y:a.endPoint.y,z:e}),r({x:a.midPoint.x,y:a.midPoint.y,z:e});else if(a instanceof be){r({x:a.startPoint.x,y:a.startPoint.y,z:e}),r({x:a.endPoint.x,y:a.endPoint.y,z:e});const o=a.getPoint(.5);r({x:o.x,y:o.y,z:e})}})}),t}moveBoundaryGripPointAt(t,e){let i=0;const r=this._elevation,s=new Set,a=(o,c)=>{const l=`${o.x},${o.y},${o.z??0}`;s.has(l)||(s.add(l),i===t&&c(),i++)};this._geo.loops.forEach(o=>{if(o instanceof q){const c=o.numberOfVertices;for(let l=0;l<c;l++){const h=o.vertices[l];h&&a({x:h.x,y:h.y,z:r},()=>{ki(o.vertices,l,e)})}return}o.curves.forEach(c=>{if(c instanceof zt)a({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>{c.startPoint.x+=e.x,c.startPoint.y+=e.y}),a({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>{c.endPoint.x+=e.x,c.endPoint.y+=e.y});else if(c instanceof vt)a({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"start",e)),a({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"end",e)),a({x:c.midPoint.x,y:c.midPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"mid",e));else if(c instanceof be){a({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"start",e)),a({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"end",e));const l=c.getPoint(.5);a({x:l.x,y:l.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"mid",e))}})})}moveCircArc2dGripPoint(t,e,i){const r=t.center;switch(e){case"start":{const s=t.startPoint;t.startAngle=Math.atan2(s.y+i.y-r.y,s.x+i.x-r.x);break}case"end":{const s=t.endPoint;t.endAngle=Math.atan2(s.y+i.y-r.y,s.x+i.x-r.x);break}case"mid":{const s=t.midPoint,a=new vt(t.startPoint,{x:s.x+i.x,y:s.y+i.y},t.endPoint);t.center=a.center,t.radius=a.radius,t.startAngle=a.startAngle,t.endAngle=a.endAngle,t.clockwise=a.clockwise;break}}}moveEllipseArc2dGripPoint(t,e,i){const r=t.center;switch(e){case"start":{const s=t.startPoint;t.startAngle=Math.atan2(s.y+i.y-r.y,s.x+i.x-r.x);break}case"end":{const s=t.endPoint;t.endAngle=Math.atan2(s.y+i.y-r.y,s.x+i.x-r.x);break}case"mid":{const s=t.getPoint(.5),a=s.x+i.x-t.center.x,o=s.y+i.y-t.center.y,c=Math.hypot(s.x-t.center.x,s.y-t.center.y),l=Math.hypot(a,o);if(c>0&&l>0){const h=l/c;t.majorAxisRadius*=h,t.minorAxisRadius*=h}break}}}subGetOsnapPoints(t,e,i,r){const s=this._elevation,a=[];if(this._geo.loops.forEach(o=>{var c;if(o instanceof q){const l=o,h=l.numberOfVertices;if(h===0)return;switch(t){case A.EndPoint:for(let u=0;u<h;u++){const d=l.getPointAt(u);r.push(new b(d.x,d.y,s))}break;case A.MidPoint:case A.Nearest:case A.Perpendicular:case A.Tangent:{const u=o.closed?h:h-1;for(let d=0;d<u;d++){const g=[];Ni(l.getPointAt(d),l.getPointAt((d+1)%h),(c=l.vertices[d])==null?void 0:c.bulge,s,t,e,g),t===A.MidPoint?r.push(...g):a.push(...g)}break}}return}o.curves.forEach(l=>{if(l instanceof zt){const h=[];Ni(l.startPoint,l.endPoint,void 0,s,t,e,h),t===A.MidPoint?r.push(...h):t===A.Nearest||t===A.Perpendicular||t===A.Tangent?a.push(...h):r.push(...h)}else if(l instanceof vt)switch(t){case A.EndPoint:r.push(new b(l.startPoint.x,l.startPoint.y,s),new b(l.endPoint.x,l.endPoint.y,s));break;case A.MidPoint:r.push(new b(l.midPoint.x,l.midPoint.y,s));break;case A.Nearest:{const h=l.nearestPoint({x:e.x,y:e.y});a.push(new b(h.x,h.y,s));break}case A.Perpendicular:{l.perpendicularPoints({x:e.x,y:e.y}).forEach(u=>a.push(new b(u.x,u.y,s)));break}case A.Tangent:{l.tangentPoints({x:e.x,y:e.y}).forEach(u=>a.push(new b(u.x,u.y,s)));break}}else if(l instanceof be)switch(t){case A.EndPoint:r.push(new b(l.startPoint.x,l.startPoint.y,s),new b(l.endPoint.x,l.endPoint.y,s));break;case A.MidPoint:{const h=l.getPoint(.5);r.push(new b(h.x,h.y,s));break}case A.Nearest:{const h=l.nearestPoint({x:e.x,y:e.y});a.push(new b(h.x,h.y,s));break}case A.Perpendicular:{l.perpendicularPoints({x:e.x,y:e.y}).forEach(u=>a.push(new b(u.x,u.y,s)));break}case A.Tangent:{l.tangentPoints({x:e.x,y:e.y}).forEach(u=>a.push(new b(u.x,u.y,s)));break}}})}),(t===A.Nearest||t===A.Perpendicular||t===A.Tangent)&&a.length>0){const o=Ft(e,a);r.length=0,o&&r.push(o)}}subWorldDraw(t){var s;this.updatePredefinedPatternDefinitionLines();const e=t.subEntityTraits;e.fillType={solidFill:this.isSolidFill,patternAngle:this.getRenderablePatternAngle(),definitionLines:this.definitionLines,backgroundColor:(s=this.backgroundColor)==null?void 0:s.clone(),gradient:this.isGradient?{name:this.gradientName,angle:this.gradientAngle,shift:this.gradientShift,oneColorMode:this.gradientOneColorMode,shadeTintValue:this.shadeTintValue,startColor:this.gradientStartColor,endColor:this.gradientEndColor}:void 0},e.drawOrder=-1;const 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(a=>t.area(a));return t.group(r)}transformBy(t){const e=t.elements,i=new Ki(e[0],e[4],e[12],e[1],e[5],e[13],0,0,1);this._geo.transform(i),this._elevation=new b(0,0,this._elevation).applyMatrix4(t).z;const r=new b(1,0,0).applyMatrix4(t),s=new b().applyMatrix4(t),a=new b(r).sub(s);if(a.length()>0){const o=Math.atan2(a.y,a.x);this._patternAngle=this.getEffectivePatternAngle()+o,this._gradientAngle+=o,this._patternScale=this.getEffectivePatternScale()*a.length(),this._patternAngleSet=!0,this._patternScaleSet=!0,this.updatePredefinedPatternDefinitionLines()}return this}dxfOutFields(t){super.dxfOutFields(t);const e=this._geo.loops,i=this.getEffectivePatternName(),r=this.getEffectivePatternAngle(),s=this.getEffectivePatternScale();if(this.updatePredefinedPatternDefinitionLines(i,s),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,i||(this.isSolidFill?Oe:hl)),t.writeInt16(70,this.isSolidFill?1:0),t.writeInt16(71,this.getEffectiveAssociative()?1:0),t.writeInt16(91,e.length),e.forEach((a,o)=>{const c=o===0;if(a instanceof q){const l=a.vertices,h=l.some(d=>(d.bulge??0)!==0);t.writeInt16(92,2),t.writeInt16(72,h?1:0),t.writeInt16(73,a.closed?1:0),t.writeInt16(93,l.length);for(const d of l)t.writePoint2d(10,d),h&&t.writeDouble(42,d.bulge??0);t.writeInt16(97,0);return}if(a instanceof xi){const l=c?1:0;t.writeInt16(92,l),t.writeInt16(93,a.numberOfEdges);for(const h of a.curves){if(h instanceof zt){t.writeInt16(72,1),t.writePoint2d(10,h.startPoint),t.writePoint2d(11,h.endPoint);continue}if(h instanceof vt){t.writeInt16(72,2),t.writePoint2d(10,h.center),t.writeDouble(40,h.radius),t.writeAngle(50,h.startAngle),t.writeAngle(51,h.endAngle),t.writeInt16(73,h.clockwise?0:1);continue}if(h instanceof be){t.writeInt16(72,3),t.writePoint2d(10,h.center);const u=new L(h.majorAxisRadius*Math.cos(h.rotation),h.majorAxisRadius*Math.sin(h.rotation));t.writePoint2d(11,u);const d=h.majorAxisRadius===0?0:h.minorAxisRadius/h.majorAxisRadius;t.writeDouble(40,d),t.writeAngle(50,h.startAngle),t.writeAngle(51,h.endAngle),t.writeInt16(73,h.clockwise?0:1);continue}if(h instanceof jt){const u=h.knots,d=h.controlPoints,g=h.weights,p=h.fitPoints,f=g.some(m=>m!==1);t.writeInt16(72,4),t.writeInt16(94,h.degree),t.writeInt16(73,f?1:0),t.writeInt16(74,h.closed?1:0),t.writeInt16(95,u.length),t.writeInt16(96,d.length),u.forEach(m=>t.writeDouble(40,m)),d.forEach((m,y)=>{t.writePoint2d(10,m),f&&t.writeDouble(42,g[y]??1)}),t.writeInt16(97,(p==null?void 0:p.length)??0),p==null||p.forEach(m=>t.writePoint2d(11,m))}}t.writeInt16(97,0)}}),t.writeInt16(75,this.hatchStyle),t.writeInt16(76,this.patternType),t.writeAngle(52,r),t.writeDouble(41,s),t.writeInt16(77,0),t.writeInt16(78,this.definitionLines.length),this.definitionLines.forEach(a=>{t.writeAngle(53,a.angle),t.writeDouble(43,a.base.x),t.writeDouble(44,a.base.y),t.writeDouble(45,a.offset.x),t.writeDouble(46,a.offset.y),t.writeInt16(79,a.dashLengths.length),a.dashLengths.forEach(o=>t.writeDouble(49,o))}),this._pixelSize!=null&&t.writeDouble(47,this._pixelSize),this.isGradient){t.writeInt16(450,this._hatchObjectType),t.writeInt16(451,0),t.writeDouble(460,this._gradientAngle),t.writeDouble(461,this._gradientShift),t.writeInt16(452,this._gradientOneColorMode?1:0),t.writeDouble(462,this._shadeTintValue);const a=this._gradientStartColor,o=this._gradientEndColor,c=a!=null&&o!=null?2:a!=null||o!=null?1:0;t.writeInt16(453,c);const l=(h,u)=>{t.writeDouble(463,h);const d=$t.getIndexByColor(u);d!=null&&t.writeInt16(63,d),t.writeInt32(421,u)};a!=null&&l(0,a),o!=null&&l(1,o),t.writeString(470,this.gradientName)}return t.writeInt16(98,0),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbHatch"),this.definitionLines.length=0;let e=this.elevation,i=this.patternAngle*180/Math.PI,r=0,s=!1,a=!1,o=!1,c=[],l=null,h=[],u=null,d="type",g=0,p=!1,f=null,m=!1,y=0,_;const v=N=>{y===0?this.gradientStartColor=N:this.gradientEndColor=N,y++,_=void 0},x=()=>{if(_==null)return;const N=$t.getColorByIndex(_);N!=null?v(N):_=void 0},k=()=>{l&&(c.push(l),l=null)},I=()=>{if(k(),c.length===0)return;const N=new q;N.closed=o,c.forEach((O,S)=>{N.addVertexAt(S,{x:O.x,y:O.y,bulge:O.bulge??0})}),this.add(N),c=[]},P=()=>{if(h.length===0)return;const N=[];for(const S of h)if(S.kind==="line")N.push(new zt({x:S.sx,y:S.sy},{x:S.ex,y:S.ey}));else if(S.kind==="arc")N.push(new vt({x:S.cx,y:S.cy},S.radius,S.startDeg*Math.PI/180,S.endDeg*Math.PI/180,!S.isCcw));else if(S.kind==="ellipse"){const G=Math.hypot(S.mx,S.my),$=G*S.ratio;let Q=S.startDeg*Math.PI/180,et=S.endDeg*Math.PI/180;const W=Math.atan2(S.my,S.mx);S.isCcw||(Q=Math.PI*2-Q,et=Math.PI*2-et),N.push(new be({x:S.cx,y:S.cy,z:0},G,$,Q,et,!S.isCcw,W))}else{const G=jt.fromDwgSplineEdge({degree:S.degree,numberOfControlPoints:S.controlPoints.length,numberOfKnots:S.knots.length,numberOfFitData:S.fitPoints.length,knots:S.knots,controlPoints:S.controlPoints.map($=>({x:$.x,y:$.y,z:0,weight:S.rational?$.weight??1:void 0})),fitDatum:S.fitPoints.map($=>({x:$.x,y:$.y,z:0})),startTangent:null,endTangent:null});G&&N.push(G)}const O=xi.buildFromEdges(N);O.length===0&&N.length>0?this.add(new xi(N)):O.forEach(S=>this.add(S)),h=[],u=null},C=()=>{s?I():P()},T=()=>{u&&(h.push(u),u=null)},R=()=>{T(),C(),g=Math.max(0,g-1),g===0&&(m=!0)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const N=t.readItem();if(!N)break;const O=Number(N.code),S=Number(N.value);if(p||m){switch(O){case 75:this.hatchStyle=S,m=!0;break;case 76:this.patternType=S;break;case 52:i=S;break;case 41:this.patternScale=S;break;case 77:break;case 78:p=!0;break;case 53:f&&this.definitionLines.push(f),f={angle:S*Math.PI/180,base:{x:0,y:0},offset:{x:0,y:0},dashLengths:[]};break;case 43:f&&(f.base.x=S);break;case 44:f&&(f.base.y=S);break;case 45:f&&(f.offset.x=S);break;case 46:f&&(f.offset.y=S);break;case 79:break;case 49:f&&f.dashLengths.push(S);break;case 47:this.pixelSize=S;break;case 99:break;case 450:this.hatchObjectType=S,this.gradientStartColor=void 0,this.gradientEndColor=void 0,y=0,_=void 0;break;case 451:break;case 452:this.gradientOneColorMode=S!==0;break;case 453:break;case 460:this.gradientAngle=S;break;case 461:this.gradientShift=S;break;case 462:this.shadeTintValue=S;break;case 463:x();break;case 63:_=S;break;case 421:v(S);break;case 470:x(),this.gradientName=String(N.value);break}continue}switch(O){case 10:s||u&&u.kind!=="line"&&u.kind!=="arc"&&u.kind!=="ellipse"&&u.kind,g>0&&s?(k(),l={x:S,y:0}):(u==null?void 0:u.kind)==="line"&&d==="type"?u.sx=S:(u==null?void 0:u.kind)==="arc"||(u==null?void 0:u.kind)==="ellipse"?u.cx=S:(u==null?void 0:u.kind)==="spline"&&u.controlPoints.push({x:S,y:0});break;case 20:g>0&&s&&l?l.y=S:(u==null?void 0:u.kind)==="line"&&d==="type"?u.sy=S:(u==null?void 0:u.kind)==="arc"||(u==null?void 0:u.kind)==="ellipse"?u.cy=S:(u==null?void 0:u.kind)==="spline"&&u.controlPoints.length>0&&(u.controlPoints[u.controlPoints.length-1].y=S);break;case 30:g<=0&&!m&&(e=S);break;case 2:this.patternName=String(N.value);break;case 70:this.isSolidFill=S!==0;break;case 71:this.associative=S!==0;break;case 91:g=S;break;case 92:g>0&&(c.length>0||h.length>0||u)&&(T(),C()),r=S,s=(r&2)!==0,a=!1,o=!1,c=[],h=[],u=null,d="type";break;case 72:s?a=S!==0:(T(),S===1?(u={kind:"line",sx:0,sy:0,ex:0,ey:0},d="type"):S===2?u={kind:"arc",cx:0,cy:0,radius:0,startDeg:0,endDeg:0,isCcw:!0}:S===3?u={kind:"ellipse",cx:0,cy:0,mx:0,my:0,ratio:1,startDeg:0,endDeg:0,isCcw:!0}:S===4?u={kind:"spline",degree:3,rational:!1,closed:!1,knots:[],controlPoints:[],fitPoints:[],expectedKnots:0,expectedControls:0,expectedFits:0,fitCountSeen:!1}:u=null);break;case 73:s?o=S!==0:(u==null?void 0:u.kind)==="arc"||(u==null?void 0:u.kind)==="ellipse"?u.isCcw=S!==0:(u==null?void 0:u.kind)==="spline"&&(u.rational=S!==0);break;case 74:(u==null?void 0:u.kind)==="spline"&&(u.closed=S!==0);break;case 93:break;case 42:s&&a&&l?l.bulge=S:(u==null?void 0:u.kind)==="spline"&&u.rational&&u.controlPoints.length>0&&(u.controlPoints[u.controlPoints.length-1].weight=S);break;case 11:(u==null?void 0:u.kind)==="line"?(u.ex=S,d="line-end"):(u==null?void 0:u.kind)==="ellipse"?u.mx=S:(u==null?void 0:u.kind)==="spline"&&u.fitPoints.push({x:S,y:0});break;case 21:(u==null?void 0:u.kind)==="line"?u.ey=S:(u==null?void 0:u.kind)==="ellipse"?u.my=S:(u==null?void 0:u.kind)==="spline"&&u.fitPoints.length>0&&(u.fitPoints[u.fitPoints.length-1].y=S);break;case 40:(u==null?void 0:u.kind)==="arc"?u.radius=S:(u==null?void 0:u.kind)==="ellipse"?u.ratio=S:(u==null?void 0:u.kind)==="spline"&&u.knots.push(S);break;case 50:((u==null?void 0:u.kind)==="arc"||(u==null?void 0:u.kind)==="ellipse")&&(u.startDeg=S);break;case 51:((u==null?void 0:u.kind)==="arc"||(u==null?void 0:u.kind)==="ellipse")&&(u.endDeg=S);break;case 94:(u==null?void 0:u.kind)==="spline"&&(u.degree=S);break;case 95:(u==null?void 0:u.kind)==="spline"&&(u.expectedKnots=S);break;case 96:(u==null?void 0:u.kind)==="spline"&&(u.expectedControls=S);break;case 97:if((u==null?void 0:u.kind)==="spline"&&!u.fitCountSeen&&(u.controlPoints.length>0||u.knots.length>0)){u.expectedFits=S,u.fitCountSeen=!0;break}R();break;case 75:T(),C(),g=0,m=!0,this.hatchStyle=S;break}}return u&&(h.push(u),u=null),C(),f&&this.definitionLines.push(f),x(),this.elevation=e,this.patternAngle=i*Math.PI/180,this}};ka.typeName="Hatch";let Xi=ka;class Eh{constructor(t){this.db=t}createDefaultLayer(){const t=new X;return t.colorIndex=7,this.db.tables.layerTable.add(new nn({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new Ae({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new Ae({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new Ae({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new Ir({name:Z,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new Tt({name:Z,dimtxsty:Z}))}createDefaultLayout(){const t=new tn;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 Xi;e.patternName=Oe;const i=new xi;i.add(new zt({x:0,y:0},{x:-1,y:.125})),i.add(new zt({x:-1,y:.125},{x:-1,y:-.125})),i.add(new zt({x:-1,y:-.125},{x:0,y:0})),e.add(i);const r=new tt;r.name="_CAXARROW",r.appendEntity(e),this.db.tables.blockTable.add(r)}}}const Ls=Math.PI/200;class Lh{constructor(t){this.database=t}formatLength(t,e){const i=this.createContext(e);return De(t,i)}formatPoint2d(t,e){const i=this.createContext(e);return`${De(t.x,i)}, ${De(t.y,i)}`}formatPoint3d(t,e){const i=this.createContext(e);return`${De(t.x,i)}, ${De(t.y,i)}, ${De(t.z,i)}`}formatAngle(t,e){const i=this.createContext(e),s=(e==null?void 0:e.applyAngbaseAngdir)??!0?d0(t,this.database.angbase,this.database.angdir):M.normalizeAngle(t);return u0(s,i)}createContext(t){return{lunits:this.database.lunits,luprec:zi(this.database.luprec),insunits:this.database.insunits,unitmode:this.database.unitmode,measurement:this.database.measurement,aunits:this.database.aunits,auprec:zi(this.database.auprec),showUnits:(t==null?void 0:t.showUnits)??!1,showApproximate:(t==null?void 0:t.showApproximate)??!1}}}function De(n,t){let e;switch(t.lunits){case rt.Scientific:e=is(w0(n,t.luprec),t);break;case rt.Engineering:e=v0(n,t);break;case rt.Architectural:e=k0(n,t);break;case rt.Fractional:e=is(A0(n,t),t);break;case rt.WindowsDesktop:case rt.Decimal:default:e=is(gi(n,t.luprec),t)}return Th(e,g0(n,t),t)}function u0(n,t){let e;switch(t.aunits){case St.DegreesMinutesSeconds:e=Oh(n,t);break;case St.Gradians:e=I0(n,t);break;case St.Radians:e=P0(n,t);break;case St.SurveyorsUnits:e=E0(n,t);break;case St.DecimalDegrees:default:e=S0(n,t)}return Th(e,f0(n,t),t)}function d0(n,t,e){let i=n-t;return e===1&&(i=-i),M.normalizeAngle(i)}function ha(n){const t=n.showUnits?'"':"";return n.unitmode===1?{feetInchSeparator:"",fractionSeparator:"-",inchSuffix:t}:{feetInchSeparator:"-",fractionSeparator:" ",inchSuffix:t}}function zi(n,t=0,e=8){return Number.isFinite(n)?Math.max(t,Math.min(e,Math.round(n))):t}function di(n){return Object.is(n,-0)?0:n}function Th(n,t,e){return!e.showApproximate||!t?n:`~ ${n}`}function g0(n,t){if(!Number.isFinite(n))return!1;const e=m0(n,t);return ua(n,e)}function f0(n,t){if(!Number.isFinite(n))return!1;if(t.aunits===St.SurveyorsUnits)return p0(n,t.auprec);const e=y0(n,t);return ua(n,e)}function p0(n,t){const i=((90-M.radToDeg(n))%360+360)%360,r=Nh(i),s=Math.min(Math.abs(i-r.base),Math.abs(r.base+90-i)),a=M.degToRad(s),o=Ch(a,t);return ua(a,o)}function m0(n,t){const e=di(n);switch(t.lunits){case rt.Scientific:return b0(e,t.luprec);case rt.Engineering:case rt.Architectural:case rt.Fractional:return _0(e,t);case rt.WindowsDesktop:case rt.Decimal:default:return Je(e,t.luprec)}}function y0(n,t){const e=di(n);switch(t.aunits){case St.DegreesMinutesSeconds:return Ch(e,t.auprec);case St.Gradians:return Je(e/Ls,t.auprec)*Ls;case St.Radians:return Je(e,t.auprec);case St.DecimalDegrees:default:return M.degToRad(Je(M.radToDeg(e),t.auprec))}}function Je(n,t){if(!Number.isFinite(n))return 0;const e=10**t;return Math.round(di(n)*e)/e}function b0(n,t){if(!Number.isFinite(n))return 0;const e=di(n);if(e===0)return 0;const i=e.toExponential(t);return Number(i)}function _0(n,t){if(!Number.isFinite(n))return 0;const e=n<0?-1:1,i=Math.abs(n),r=Math.floor(i/12),s=i-r*12;if(t.lunits===rt.Architectural||t.lunits===rt.Fractional){const a=1<<zi(t.luprec,0,8),o=x0(s,a);return e*(r*12+o)}return e*(r*12+Je(s,t.luprec))}function x0(n,t){const e=Math.floor(n),i=n-e,r=Math.round(i*t);return r>=t?e+1:e+r/t}function Ch(n,t){const e=M.radToDeg(n),i=e<0?-1:1,r=Math.abs(e),s=Math.floor(r),a=(r-s)*60,o=Math.floor(a),c=Je((a-o)*60,t),l=s+o/60+c/3600;return M.degToRad(i*l)}function ua(n,t){if(n===t)return!1;const e=Math.max(Math.abs(n),Math.abs(t),1);return Math.abs(n-t)>e*Number.EPSILON*8}function gi(n,t){if(!Number.isFinite(n))return"0";const e=di(n);if(Number.isInteger(e)&&t===0)return String(e);const r=e.toFixed(t).replace(/\.?0+$/,"");return r===""||r==="-"?"0":r}function w0(n,t){if(!Number.isFinite(n))return"0";const e=di(n);if(e===0)return"0";const i=e.toExponential(t).match(/^(.+)e([+-])(\d+)$/i);if(!i)return"0";const[,r,s,a]=i,o=a.length<2?a.padStart(2,"0"):a;return`${r}E${s}${o}`.toUpperCase()}function v0(n,t){if(!Number.isFinite(n))return"0";const e=ha(t),i=n<0?"-":"",r=Math.abs(n),s=Math.floor(r/12),a=r-s*12,o=gi(a,t.luprec);return s===0?`${i}${o}${e.inchSuffix}`:`${i}${s}'${e.feetInchSeparator}${o}${e.inchSuffix}`}function k0(n,t){if(!Number.isFinite(n))return"0";const e=ha(t),i=n<0?"-":"",r=Math.abs(n),s=Math.floor(r/12),a=r-s*12,o=1<<zi(t.luprec,0,8),c=Mh(a,o,e.fractionSeparator);return s===0?`${i}${c}${e.inchSuffix}`:`${i}${s}'${e.feetInchSeparator}${c}${e.inchSuffix}`}function A0(n,t){if(!Number.isFinite(n))return"0";const e=ha(t),i=n<0?"-":"",r=Math.abs(n),s=1<<zi(t.luprec,0,8);return`${i}${Mh(r,s,e.fractionSeparator)}`}function Mh(n,t,e){const i=Math.floor(n),r=n-i;let s=Math.round(r*t);if(s>=t)return String(i+1);if(s===0)return String(i);const a=M0(s,t);s/=a;const o=t/a,c=`${s}/${o}`;return i===0?c:`${i}${e}${c}`}function S0(n,t){const e=M.radToDeg(n);return`${gi(e,t.auprec)}${t.showUnits?"°":""}`}function P0(n,t){return`${gi(n,t.auprec)}${t.showUnits?" rad":""}`}function I0(n,t){const e=n/Ls;return`${gi(e,t.auprec)}${t.showUnits?"g":""}`}function Oh(n,t){const e=M.radToDeg(n),i=e<0?"-":"",r=Math.abs(e),s=Math.floor(r),a=(r-s)*60,o=Math.floor(a),c=(a-o)*60,l=gi(c,t.auprec),h=t.showUnits?'"':"";return`${i}${s}d${o}'${l}${h}`}function E0(n,t){const i=((90-M.radToDeg(n))%360+360)%360,r=Nh(i),s=Math.min(Math.abs(i-r.base),Math.abs(r.base+90-i)),o=Oh(M.degToRad(s),t).replace(/^-/,"");return`${r.prefix} ${o} ${r.suffix}`.trim()}function Nh(n){return n<90?{prefix:"N",suffix:"E",base:0}:n<180?{prefix:"S",suffix:"E",base:90}:n<270?{prefix:"S",suffix:"W",base:180}:{prefix:"N",suffix:"W",base:270}}function is(n,t){if(!t.showUnits||t.lunits===rt.Engineering||t.lunits===rt.Architectural)return n;const e=L0(t.insunits,t.measurement);return e?`${n}${e}`:n}function L0(n,t){return n===J.Undefined?t===0?'"':" mm":fp(n)?T0(n):pp(n)?C0(n):""}function T0(n){switch(n){case J.Millimeters:return" mm";case J.Centimeters:return" cm";case J.Meters:return" m";case J.Kilometers:return" km";case J.Decimeters:return" dm";case J.Microns:return" µm";case J.Nanometers:return" nm";default:return""}}function C0(n){switch(n){case J.Inches:case J.Microinches:case J.Mils:case J.USSurveyInch:return'"';case J.Feet:case J.USSurveyFeet:return"'";case J.Miles:case J.USSurveyMile:return" mi";case J.Yards:case J.USSurveyYard:return" yd";default:return""}}function M0(n,t){let e=Math.abs(n),i=Math.abs(t);for(;i!==0;){const r=i;i=e%i,e=r}return e||1}class Nt extends bt{constructor(t){super(),this.database=t,this.objectId=t.generateHandle(),this._recordsByName=new Map}get numEntries(){return this._recordsByName.size}setAt(t,e){const i=this.database.transactionManager;if(i.strictMode&&!i.isRecording()&&!i.isApplyingUndoRedo())throw new Error("Cannot modify dictionary entries outside an active transaction.");const r=this.getAt(t);r&&(i.isRecording()&&i.recordRemove({type:"dictionary",dictionaryId:this.objectId,key:t},r),this.database.releaseObjectHandle(r)),e.database=this.database,e.ownerId=this.objectId,this.database.commitObjectHandle(e,s=>this.hasId(s)),this._recordsByName.set(t,e),i.isRecording()&&i.recordAppend({type:"dictionary",dictionaryId:this.objectId,key:t},e),!i.isRecording()&&!i.isApplyingUndoRedo()&&this.database.notifyDictObjectSet(e,t)}remove(t){const e=this.getAt(t);return e?(this.removeStoredObject(e,t),!0):!1}removeId(t){const e=this.getIdAt(t);if(e){let i="";return this._recordsByName.forEach((r,s)=>{r===e&&(i=s)}),this.removeStoredObject(e,i),!0}return!1}removeStoredObject(t,e){const i=this.database.transactionManager;if(i.strictMode&&!i.isRecording()&&!i.isApplyingUndoRedo())throw new Error("Cannot remove dictionary entries outside an active transaction.");i.isRecording()&&i.recordRemove({type:"dictionary",dictionaryId:this.objectId,key:e},t),this._recordsByName.forEach((r,s)=>{r===t&&this._recordsByName.delete(s)}),this.database.releaseObjectHandle(t),e&&!i.isRecording()&&!i.isApplyingUndoRedo()&&this.database.notifyDictObjectErased(t,e)}removeAll(){this._recordsByName.forEach((t,e)=>{this.database.releaseObjectHandle(t),this.database.events.dictObjectErased.dispatch({database:this.database,object:t,key:e})}),this._recordsByName.clear()}has(t){return this._recordsByName.has(t.toUpperCase())}hasId(t){return this.getIdAt(t)!==void 0}getAt(t){return this._recordsByName.get(t)}getIdAt(t){const e=this.database.getObjectById(t);if(!(!e||e.getAttrWithoutException("ownerId")!==this.objectId))return e}newIterator(){return new ni(this._recordsByName)}entries(){return this._recordsByName.entries()}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbDictionary"),t.writeInt16(280,1),t.writeInt16(281,1);for(const[e,i]of this._recordsByName)t.writeString(3,e),t.writeObjectId(350,i.objectId);return this}dxfInFields(t){for(super.dxfInFields(t),t.atSubclassData("AcDbDictionary");!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const e=t.readItem();if(!e)break;if(Number(e.code)===100){t.pushBackItem(e);break}}return this}}class ne extends bt{constructor(t){super(),this.database=t,this.objectId=t.generateHandle(),this.ownerId=t.objectId,this._recordsByName=new Map,this._unnamedRecords=[]}get numEntries(){return this._recordsByName.size}get totalRecordCount(){return this._recordsByName.size+this._unnamedRecords.length}add(t){const e=this.database.transactionManager;if(e.strictMode&&!e.isRecording()&&!e.isApplyingUndoRedo())throw new Error("Cannot add symbol table records outside an active transaction.");const i=e.resolveSymbolTableName(this);t.database=this.database,t.ownerId=this.objectId,this.database.commitObjectHandle(t,s=>this.hasId(s));const r=this.normalizeName(t.name);r?this._recordsByName.set(r,t):this._unnamedRecords.push(t),e.isRecording()&&e.recordAppend({type:"symbolTable",tableName:i},t)}remove(t){const e=this.normalizeName(t),i=this._recordsByName.get(e);return i?(this.removeRecord(i),!0):!1}removeId(t){const e=this.getIdAt(t);return e?(this.removeRecord(e),!0):!1}removeRecord(t){const e=this.database.transactionManager;if(e.strictMode&&!e.isRecording()&&!e.isApplyingUndoRedo())throw new Error("Cannot remove symbol table records outside an active transaction.");if(e.isRecording()){const i=e.resolveSymbolTableName(this);e.recordRemove({type:"symbolTable",tableName:i},t)}this.removeFromMembership(t),this.database.releaseObjectHandle(t)}removeAll(){for(const t of this._recordsByName.values())this.database.releaseObjectHandle(t);for(const t of this._unnamedRecords)this.database.releaseObjectHandle(t);this._recordsByName.clear(),this._unnamedRecords.length=0}has(t){const e=this.normalizeName(t);return this._recordsByName.has(e)}hasId(t){return this.getIdAt(t)!==void 0}getAt(t){const e=this.normalizeName(t);return this._recordsByName.get(e)}getIdAt(t){const e=this.database.getObjectById(t);if(!(!e||e.getAttrWithoutException("ownerId")!==this.objectId))return e}getOwnerIdAt(t){return this.getIdAt(t)}newIterator(t=!1){return t?new ni([...this._recordsByName.values(),...this._unnamedRecords]):new ni(this._recordsByName)}normalizeName(t){return t.trim().toUpperCase()}get dxfEntryCount(){return this.numEntries}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbSymbolTable"),t.writeInt16(70,this.dxfEntryCount),this}removeFromMembership(t){const e=this.normalizeName(t.name);if(e){this._recordsByName.delete(e);return}const i=this._unnamedRecords.indexOf(t);i>=0&&this._unnamedRecords.splice(i,1)}}class Rh extends ne{constructor(t){super(t)}get modelSpace(){let t=this.getAt(tt.MODEL_SPACE_NAME);return t||(t=new tt,t.name=tt.MODEL_SPACE_NAME,this.add(t)),t}getEntityById(t){const e=this.database.getObjectById(t);if(e instanceof H)return e}removeEntity(t){let e=!1;for(const i of this.database.tables.blockTable.newIterator())if(i.removeEntity(t)){e=!0;break}return e}getXrefs(){const t=[];for(const e of this.newIterator())e.isXref&&t.push(e);return t}getUnresolvedXrefs(){return this.getXrefs().filter(t=>t.isUnresolvedXref)}normalizeName(t){const e=t.trim();if(tt.isModelSapceName(e))return tt.MODEL_SPACE_NAME;if(tt.isPaperSapceName(e)){const i=tt.PAPER_SPACE_NAME_PREFIX,r=e.substring(i.length);return i+r}return super.normalizeName(e)}}const Rt=class Rt extends Error{constructor(t,e,i){super(t),this.name="AcDbOpenDatabaseError",this.code=e,this.stage=i==null?void 0:i.stage}static isWorkerOutOfMemoryMessage(t){const e=t.toLowerCase();return Rt.WORKER_OOM_PATTERNS.some(i=>e.includes(i))}static classifyWorkerErrorMessage(t){return Rt.isWorkerOutOfMemoryMessage(t)?"worker_oom":t.toLowerCase().includes("timed out")?"worker_timeout":"worker_error"}static from(t,e){if(t instanceof Rt)return t;const i=t instanceof Error?t.message:String(t),r=Rt.classifyWorkerErrorMessage(i);return new Rt(i,r,{stage:e,cause:t})}static fromTask(t){const e=t.task.name;return Rt.from(t.error,e)}static throwOnWorkerParseFailure(t,e="PARSE"){if(t.success)return;const i=t.error!=null?`Failed to parse drawing due to error: '${t.error}'`:"Failed to parse drawing due to an unknown worker error",r=Rt.mapWorkerResultCode(t.errorCode,t.error);throw new Rt(i,r,{stage:e})}static mapWorkerResultCode(t,e){switch(t){case"worker_oom":return"worker_oom";case"worker_timeout":return"worker_timeout";case"worker_error":return"worker_error";default:return Rt.classifyWorkerErrorMessage(e??"")}}};Rt.WORKER_OOM_PATTERNS=["out of memory","data cannot be cloned","allocation failed","memory access out of bounds"];let ji=Rt;class Bh extends ne{constructor(t){super(t)}}class Fh extends ne{constructor(t){super(t)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class Dh extends ne{constructor(t){super(t)}}class Yh extends ne{constructor(t){super(t)}get dxfEntryCount(){return this.totalRecordCount}resolveAt(t){this.database.ensureTextStyleDefaults();const e=[],i=r=>{const s=r==null?void 0:r.trim();s&&!e.includes(s)&&e.push(s)};i(t),i(this.database.textstyle),i(Z),i("STANDARD");for(const r of e){const s=this.getAt(r);if(s)return s;const a=r.toUpperCase();for(const o of this.newIterator())if(o.name.toUpperCase()===a)return o}return this.newIterator().next().value??void 0}get shapeFiles(){return this.newIterator(!0).toArray().filter(t=>t.isShapeFile)}get fonts(){const t=new Set;for(const e of this.newIterator()){const i=gt.normalizeFontFileName(e.fileName);i&&t.add(i);const r=gt.normalizeFontFileName(e.bigFontFileName);r&&t.add(r)}return Array.from(t)}}class Xh extends ne{constructor(t){super(t)}}class zh extends ne{constructor(t){super(t)}}class jh extends ne{constructor(t){super(t)}normalizeName(t){const e=t.trim();return Se.isActiveVportName(e)?ii:super.normalizeName(e)}getActiveVport(){return this.getAt(ii)}getActiveVportBox(t,e){const i=this.getActiveVport();return i==null?void 0:i.resolveModelViewBox(t,e)}}class Vh extends ne{constructor(t){super(t)}}class Gh extends Nt{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 Uh{constructor(t){this.database=t}applyForward(t){for(const e of t)this.applyChange(e,!0)}applyInverse(t){for(let e=t.length-1;e>=0;e--)this.applyChange(t[e],!1)}applyChange(t,e){switch(t.kind){case"modify":this.applyModify(t,e);break;case"append":e?this.applyAppend(t.container,t.object):this.applyRemove(t.container,t.object);break;case"remove":e?this.applyRemove(t.container,t.object):this.applyAppend(t.container,t.object);break;case"sysvar":this.applySysvar(t,e);break}}applyModify(t,e){const i=this.database.getObjectById(t.objectId);if(!i)return;const r=e?t.after:t.before;r&&i.restoreFrom(r)}applySysvar(t,e){const i=e?t.after:t.before;i!==void 0&&ft.instance().setVar(t.name,i,this.database)}applyAppend(t,e){switch(t.type){case"blockTableRecord":{const i=this.database.tables.blockTable.getIdAt(t.ownerId);i&&i.appendEntity(e);break}case"symbolTable":{const i=this.getSymbolTable(t.tableName);i&&i.add(e);break}case"dictionary":{const i=this.database.getObjectById(t.dictionaryId);i&&i.setAt(t.key,e);break}}}applyRemove(t,e){switch(t.type){case"blockTableRecord":{const i=this.database.tables.blockTable.getIdAt(t.ownerId);i&&i.removeEntity(e.objectId);break}case"symbolTable":{const i=this.getSymbolTable(t.tableName);i&&i.removeId(e.objectId);break}case"dictionary":{const i=this.database.getObjectById(t.dictionaryId);i&&i.removeId(e.objectId);break}}}getSymbolTable(t){const e=this.database.tables;switch(t){case"appIdTable":return e.appIdTable;case"blockTable":return e.blockTable;case"dimStyleTable":return e.dimStyleTable;case"linetypeTable":return e.linetypeTable;case"textStyleTable":return e.textStyleTable;case"viewTable":return e.viewTable;case"layerTable":return e.layerTable;case"viewportTable":return e.viewportTable;default:return}}}function Ts(n,t){const e=[],i=[],r=[];for(const s of t)if(s.kind==="modify"){const a=n.getObjectById(s.objectId);a instanceof H&&e.push(a)}else if(s.kind==="append"){if(s.container.type==="blockTableRecord"){const a=n.tables.blockTable.getEntityById(s.object.objectId)??(s.object instanceof H?s.object:void 0);a&&i.push(a)}}else s.kind==="remove"&&s.container.type==="blockTableRecord"&&s.object instanceof H&&r.push(s.object);return{modified:e,appended:i,erased:r}}function Yo(n,t){const e=[],i=[];for(const r of t){if(r.kind!=="append"&&r.kind!=="remove"||r.container.type!=="dictionary")continue;const s=r.container.key;if(r.kind==="append"){const a=n.getObjectById(r.object.objectId)??r.object;e.push({object:a,key:s})}else r.kind==="remove"&&i.push({object:r.object,key:s})}return{set:e,erased:i}}function Xo(n,t){const e={};for(const i of wp){const r=n.getAttrWithoutException(i),s=t.getAttrWithoutException(i);Ne(r,s)||(e[i]=s)}return e}function zo(n,t,e=!1){const i=[];for(const r of t){if(r.kind!=="modify")continue;const s=n.getObjectById(r.objectId);if(!(s instanceof nn))continue;const a=r.before,o=r.after;if(!a||!o)continue;const c=e?Xo(o,a):Xo(a,o);Object.keys(c).length!==0&&i.push({database:n,layer:s,changes:c})}return i}function O0(n,t){if(n.type!==t.type)return!1;switch(n.type){case"blockTableRecord":return t.type==="blockTableRecord"&&n.ownerId===t.ownerId;case"symbolTable":return t.type==="symbolTable"&&n.tableName===t.tableName;case"dictionary":return t.type==="dictionary"&&n.dictionaryId===t.dictionaryId&&n.key===t.key}}class Hh{constructor(){this.changes=[]}getChanges(){return this.changes}clear(){this.changes.length=0}mergeFrom(t){for(const e of t.getChanges())this.mergeChange(e)}recordModify(t){const e=t.objectId;this.changes.find(r=>r.kind==="modify"&&r.objectId===e)||this.changes.push({kind:"modify",objectId:e,before:t.clonePreservingIdentity()})}hasModify(t){return this.changes.some(e=>e.kind==="modify"&&e.objectId===t)}recordAppend(t,e){this.recordStructuralChange({kind:"append",container:t,object:e.clonePreservingIdentity()})}recordRemove(t,e){this.recordStructuralChange({kind:"remove",container:t,object:e.clonePreservingIdentity()})}recordSysvar(t,e){const i=t.toLowerCase();this.changes.find(s=>s.kind==="sysvar"&&s.name===i)||this.changes.push({kind:"sysvar",name:i,before:e})}finalize(t){for(const e of this.changes)if(e.kind==="modify"){const i=t.getObjectById(e.objectId);i&&(e.after=i.clonePreservingIdentity())}else e.kind==="sysvar"&&(e.after=this.getSysvarValue(t,e.name))}recordStructuralChange(t){const e=t.kind==="append"?"remove":"append",i=this.findStructuralChangeIndex(e,t.container,t.object.objectId);if(i>=0){this.changes.splice(i,1);return}this.changes.push(t)}mergeChange(t){if(t.kind==="modify"){this.changes.find(i=>i.kind==="modify"&&i.objectId===t.objectId)||this.changes.push(t);return}if(t.kind==="sysvar"){this.changes.find(i=>i.kind==="sysvar"&&i.name===t.name)||this.changes.push(t);return}this.recordStructuralChange(t)}findStructuralChangeIndex(t,e,i){return this.changes.findIndex(r=>r.kind===t&&r.object.objectId===i&&O0(r.container,e))}getSysvarValue(t,e){return ft.instance().getVar(e,t)}}class da{constructor(){this.openedObjects=new Map,this.originalStates=new Map,this.recorder=new Hh}getObject(t,e,i=!1){const r=this.openedObjects.get(t);if(r){if(e===ri.kForWrite&&!this.originalStates.has(t)){const a=r.clonePreservingIdentity();this.originalStates.set(t,a),this.recorder.recordModify(r)}return r}const s=this.lookupObject(t,i);if(this.openedObjects.set(t,s),e===ri.kForWrite){const a=s.clonePreservingIdentity();this.originalStates.set(s.objectId,a),this.recorder.recordModify(s)}return s}commit(){this.originalStates.clear(),this.openedObjects.clear()}abort(){for(const[t,e]of this.originalStates){const i=this.openedObjects.get(t);i&&i.restoreFrom(e)}this.originalStates.clear(),this.openedObjects.clear(),this.recorder.clear()}lookupObject(t,e){throw new Error(`lookupObject(${t}) not implemented`)}}class Wh extends da{constructor(t){super(),this.database=t}lookupObject(t,e){const i=this.database.getObjectById(t,e);if(!i)throw new Error(`lookupObject(${t}) not found`);return i}}class $h{constructor(){this.undoRecords=[],this.redoRecords=[],this.maxDepth=100}push(t){this.undoRecords.push(t),this.redoRecords.length=0,this.undoRecords.length>this.maxDepth&&this.undoRecords.shift()}popUndo(){return this.undoRecords.pop()}pushRedo(t){this.redoRecords.push(t)}popRedo(){return this.redoRecords.pop()}canUndo(){return this.undoRecords.length>0}canRedo(){return this.redoRecords.length>0}clear(){this.undoRecords.length=0,this.redoRecords.length=0}}class qh{constructor(t){this.database=t,this.transactionStack=[],this.undoStack=new $h,this.undoMarkStack=[],this._applyingUndoRedo=!1,this._pendingEntityModified=new Set,this._pendingLayerModified=new Map,this.strictMode=!1,this.changeApplier=new Uh(t)}startTransaction(){const t=new Wh(this.database);return this.transactionStack.push(t),t}currentTransaction(){return this.transactionStack[this.transactionStack.length-1]}hasTransaction(){return this.transactionStack.length>0}isRecording(){return this.hasTransaction()&&!this._applyingUndoRedo}isApplyingUndoRedo(){return this._applyingUndoRedo}isOpenedForWriteInTransaction(t){for(const e of this.transactionStack)if(e.recorder.hasModify(t))return!0;return!1}commitTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to commit.");if(this.transactionStack.length>0){this.transactionStack[this.transactionStack.length-1].recorder.mergeFrom(t.recorder),t.commit();return}t.recorder.finalize(this.database);const e=t.recorder.getChanges();t.commit(),e.length>0&&(this.dispatchCommitEvents(e),this.enqueueUndoChanges(e))}abortTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to abort.");const e=[...t.recorder.getChanges()];this.database.beginEventBatch(),this._applyingUndoRedo=!0;try{t.abort(),e.length>0&&this.changeApplier.applyInverse(e)}finally{this._applyingUndoRedo=!1,this.database.endEventBatch()}}startUndoMark(t){this.undoMarkStack.push({label:t,pendingChanges:[]})}endUndoMark(){const t=this.undoMarkStack.pop();if(!t)throw new Error("No active undo mark to end.");t.pendingChanges.length!==0&&this.undoStack.push({label:t.label,changes:t.pendingChanges})}cancelUndoMark(){this.undoMarkStack.length>0&&this.undoMarkStack.pop()}undo(){const t=this.undoStack.popUndo();if(!t)return!1;this.database.beginEventBatch(),this._applyingUndoRedo=!0;try{this.changeApplier.applyInverse(t.changes),this.dispatchUndoRedoEvents(t.changes,!0)}finally{this._applyingUndoRedo=!1,this.database.endEventBatch()}return this.undoStack.pushRedo(t),!0}redo(){const t=this.undoStack.popRedo();if(!t)return!1;this.database.beginEventBatch(),this._applyingUndoRedo=!0;try{this.changeApplier.applyForward(t.changes),this.dispatchUndoRedoEvents(t.changes,!1)}finally{this._applyingUndoRedo=!1,this.database.endEventBatch()}return this.undoStack.push(t),!0}canUndo(){return this.undoStack.canUndo()}canRedo(){return this.undoStack.canRedo()}clearUndoStack(){this.undoStack.clear()}recordAppend(t,e){var i;this.isRecording()&&((i=this.currentTransaction())==null||i.recorder.recordAppend(t,e))}recordRemove(t,e){var i;this.isRecording()&&((i=this.currentTransaction())==null||i.recorder.recordRemove(t,e))}recordSysvar(t,e){var i;this.isRecording()&&((i=this.currentTransaction())==null||i.recorder.recordSysvar(t,e))}resolveSymbolTableName(t){const e=this.database.tables;return t===e.appIdTable?"appIdTable":t===e.blockTable?"blockTable":t===e.dimStyleTable?"dimStyleTable":t===e.linetypeTable?"linetypeTable":t===e.textStyleTable?"textStyleTable":t===e.viewTable?"viewTable":t===e.layerTable?"layerTable":t===e.viewportTable?"viewportTable":t.objectId}runUndoable(t,e){this.startUndoMark(t),this.startTransaction();try{const i=e(this.currentTransaction());return this.commitTransaction(),this.endUndoMark(),i}catch(i){throw this.hasTransaction()&&this.abortTransaction(),this.cancelUndoMark(),i}}enqueueUndoChanges(t){const e=this.undoMarkStack[this.undoMarkStack.length-1];if(e)for(const i of t)e.pendingChanges.push(i)}dispatchCommitEvents(t){const{modified:e,appended:i,erased:r}=Ts(this.database,t);for(const o of e)this.dispatchEntityModified(o);i.length>0&&this.database.notifyEntityAppended(i),r.length>0&&this.database.notifyEntityErased(r);const{set:s,erased:a}=Yo(this.database,t);for(const{object:o,key:c}of s)this.database.notifyDictObjectSet(o,c);for(const{object:o,key:c}of a)this.database.notifyDictObjectErased(o,c);for(const o of t)o.kind==="sysvar"&&o.after!==void 0&&ft.instance().events.sysVarChanged.dispatch({database:this.database,name:o.name,oldVal:o.before,newVal:o.after});for(const o of zo(this.database,t))this.dispatchLayerModified(o)}dispatchUndoRedoEvents(t,e){const{modified:i,appended:r,erased:s}=Ts(this.database,t),{set:a,erased:o}=Yo(this.database,t);if(e){for(const c of i)this.dispatchEntityModified(c);s.length>0&&this.database.notifyEntityAppended(s),r.length>0&&this.database.notifyEntityErased(r);for(const{object:c,key:l}of o)this.database.notifyDictObjectSet(c,l);for(const{object:c,key:l}of a)this.database.notifyDictObjectErased(c,l)}else{for(const c of i)this.dispatchEntityModified(c);r.length>0&&this.database.notifyEntityAppended(r),s.length>0&&this.database.notifyEntityErased(s);for(const{object:c,key:l}of a)this.database.notifyDictObjectSet(c,l);for(const{object:c,key:l}of o)this.database.notifyDictObjectErased(c,l)}for(const c of t)if(c.kind==="sysvar"){const l=e?c.after:c.before,h=e?c.before:c.after;h!==void 0&&ft.instance().events.sysVarChanged.dispatch({database:this.database,name:c.name,oldVal:l,newVal:h})}for(const c of zo(this.database,t,e))this.dispatchLayerModified(c)}dispatchLayerModified(t){if(this.database.isEventBatched()){const e=this._pendingLayerModified.get(t.layer.objectId);if(e){e.changes={...e.changes,...t.changes};return}this._pendingLayerModified.set(t.layer.objectId,{database:t.database,layer:t.layer,changes:{...t.changes}});return}this.database.events.layerModified.dispatch(t)}dispatchEntityModified(t){if(this.database.isEventBatched()){this._pendingEntityModified.add(t);return}this.database.events.entityModified.dispatch({database:this.database,entity:t})}flushPendingLayerModifiedEvents(){if(this._pendingLayerModified.size===0)return;const t=[...this._pendingLayerModified.values()];this._pendingLayerModified.clear();for(const e of t)this.database.events.layerModified.dispatch(e)}flushPendingEntityModifiedEvents(){if(this._pendingEntityModified.size===0)return;const t=[...this._pendingEntityModified];this._pendingEntityModified.clear();for(const e of t)this.database.events.entityModified.dispatch({database:this.database,entity:e})}}const Ei=class Ei extends bt{constructor(){super({objectId:"0"}),this._classes=[],this._handleRegistry=new Map,this._drawNoPlotLayers=!0,this._eventBatchDepth=0,this._pendingEntityAppended=[],this._pendingEntityErased=[],this._pendingDictObjectSet=[],this._pendingDictObjectErased=[],this._lastOpenError=null,this.events={dictObjetSet:new at,dictObjectErased:new at,entityAppended:new at,entityModified:new at,entityErased:new at,layerAppended:new at,layerModified:new at,layerErased:new at,openProgress:new at,openFailed:new at},Ei._unsavedDrawingSequence+=1,this._dwgname=`Drawing${Ei._unsavedDrawingSequence}.dwg`,this._version=new pt("AC1014"),this._angbase=0,this._angdir=0,this._aunits=St.DecimalDegrees,this._auprec=0,this._lunits=rt.Decimal,this._luprec=4,this._celtscale=1,this._cecolor=new X,this._celtype=lt,this._celweight=exports.AcGiLineWeight.ByLayer,this._cetransparency=new ot,this._clayer="0",this._cmlstyle=le,this._cmlscale=1,this._cmleaderstyle=he,this._hpbackgroundcolor=new X(exports.AcCmColorMethod.None),this._hpcolor=this._cecolor.clone(),this._hplayer=".",this._hptransparency=new ot,this._textstyle=Z,this._dimstyle=Z,this._extents=new Y,this._insunits=J.Millimeters,this._unitmode=0,this._measurement=1,this._ltscale=1,this._lwdisplay=!1,this._tilemode=!0,this._psltscale=!0,this._pdmode=0,this._pdsize=0,this._osmode=0,this._orthomode=0,this._maxHandle=0,this._tables={appIdTable:new Vh(this),blockTable:new Rh(this),dimStyleTable:new Bh(this),linetypeTable:new Dh(this),textStyleTable:new Yh(this),ucsTable:new Xh(this),viewTable:new zh(this),layerTable:new Fh(this),viewportTable:new jh(this)},this._objects={dictionary:new Nt(this),group:new Nt(this),imageDefinition:new Nt(this),layerFilter:new Nt(this),layerIndex:new Nt(this),layout:new Gh(this),mleaderStyle:new Nt(this),mlineStyle:new Nt(this),sortentsTable:new Nt(this),xrecord:new Nt(this)},this._layerFilters=new ue,this.transactionManager=new qh(this),this.registerBootstrapHandles()}get tables(){return this._tables}get classes(){return this._classes}set classes(t){this._classes=t.map(e=>({...e}))}get objects(){return this._objects}get layerFilters(){return this._layerFilters}set layerFilters(t){this._layerFilters=t??new ue}getObjectById(t,e=!1){return t===this.objectId?this:this._handleRegistry.get(t)}isUndoRecording(){return this.transactionManager.isRecording()}openObject(t,e){const i=this.transactionManager.currentTransaction();if(i){const r=i.getObject(t,e);if(r)return r}return this.getObjectById(t)}openObjectForRead(t){return this.openObject(t,ri.kForRead)}openObjectForWrite(t){return this.openObject(t,ri.kForWrite)}openEntityForRead(t){const e=typeof t=="string"?t:t.objectId;return this.openObjectForRead(e)}openEntityForWrite(t){const e=typeof t=="string"?t:t.objectId;return this.openObjectForWrite(e)}runDatabaseEdit(t,e){if(this.isUndoRecording()){e();return}this.transactionManager.runUndoable(t,e)}getRootDictionaries(){return[this.objects.dictionary,this.objects.group,this.objects.imageDefinition,this.objects.layerFilter,this.objects.layerIndex,this.objects.layout,this.objects.mleaderStyle,this.objects.mlineStyle,this.objects.sortentsTable,this.objects.xrecord]}beginEventBatch(){this._eventBatchDepth++}endEventBatch(){this._eventBatchDepth<=0||(this._eventBatchDepth--,this._eventBatchDepth===0&&(this.transactionManager.flushPendingEntityModifiedEvents(),this.transactionManager.flushPendingLayerModifiedEvents(),this.flushEventBatch()))}async endEventBatchChunked(t,e){if(this._eventBatchDepth<=0||(this._eventBatchDepth--,this._eventBatchDepth!==0))return;this.transactionManager.flushPendingEntityModifiedEvents(),this.transactionManager.flushPendingLayerModifiedEvents();const i=this._pendingEntityAppended;this._pendingEntityAppended=[];const r=i.length,s=Math.max(1,t);if(r===0){this.flushEventBatchRemainder();return}let a=0;try{for(let o=0;o<r;o+=s){const c=Math.min(o+s,r),l=i.slice(o,c);this.events.entityAppended.dispatch({database:this,entity:l}),a=c,e&&await e(c,r)}}finally{a<r&&this.events.entityAppended.dispatch({database:this,entity:i.slice(a)}),this.flushEventBatchRemainder()}}isEventBatched(){return this._eventBatchDepth>0}notifyEntityAppended(t){if(this.isEventBatched()){const e=Array.isArray(t)?t:[t];this._pendingEntityAppended.push(...e);return}this.events.entityAppended.dispatch({database:this,entity:t})}notifyEntityErased(t){if(this.isEventBatched()){const e=Array.isArray(t)?t:[t];this._pendingEntityErased.push(...e);return}this.events.entityErased.dispatch({database:this,entity:t})}notifyDictObjectSet(t,e){if(this.isEventBatched()){this._pendingDictObjectSet.push({object:t,key:e});return}this.events.dictObjetSet.dispatch({database:this,object:t,key:e})}notifyDictObjectErased(t,e){if(this.isEventBatched()){this._pendingDictObjectErased.push({object:t,key:e});return}this.events.dictObjectErased.dispatch({database:this,object:t,key:e})}flushEventBatch(){if(this._pendingEntityAppended.length>0){const t=this._pendingEntityAppended;this._pendingEntityAppended=[],this.events.entityAppended.dispatch({database:this,entity:t})}this.flushEventBatchRemainder()}flushEventBatchRemainder(){if(this._pendingEntityErased.length>0){const t=this._pendingEntityErased;this._pendingEntityErased=[],this.events.entityErased.dispatch({database:this,entity:t})}if(this._pendingDictObjectSet.length>0){const t=this._pendingDictObjectSet;this._pendingDictObjectSet=[];for(const{object:e,key:i}of t)this.events.dictObjetSet.dispatch({database:this,object:e,key:i})}if(this._pendingDictObjectErased.length>0){const t=this._pendingDictObjectErased;this._pendingDictObjectErased=[];for(const{object:e,key:i}of t)this.events.dictObjectErased.dispatch({database:this,object:e,key:i})}}get formatter(){return this._formatter??(this._formatter=new Lh(this))}generateHandle(){return this._maxHandle++,this._maxHandle.toString(16).toUpperCase()}generateUniqueHandle(){let t=this.generateHandle();for(;this.isHandleTaken(t);)t=this.generateHandle();return t}initializeHandleSeed(t){const e=parseInt(t,16);if(!isNaN(e)&&e>0){const i=e-1;i>this._maxHandle&&(this._maxHandle=i)}}adoptExternalHandle(t,e){return this.releaseObjectHandle(t),e&&!e.startsWith(xe)&&!this.isHandleTaken(e)?(t.objectId=e,this.registerObjectHandle(t),this.updateMaxHandle(e),e):this.assignGeneratedHandle(t)}registerObjectHandle(t){const e=t.objectId;!e||e.startsWith(xe)||this._handleRegistry.set(e,t)}releaseObjectHandle(t){const e=t.objectId;!e||e.startsWith(xe)||this._handleRegistry.get(e)===t&&this._handleRegistry.delete(e)}isHandleTaken(t,e){if(!t||t.startsWith(xe))return!1;const i=this._handleRegistry.get(t);return i!==void 0&&i!==e}registerBootstrapHandles(){this._handleRegistry.clear(),this.registerObjectHandle(this);for(const t of[this._tables.blockTable,this._tables.dimStyleTable,this._tables.layerTable,this._tables.linetypeTable,this._tables.appIdTable,this._tables.textStyleTable,this._tables.ucsTable,this._tables.viewTable,this._tables.viewportTable])this.registerObjectHandle(t);for(const t of[this._objects.dictionary,this._objects.group,this._objects.imageDefinition,this._objects.layerFilter,this._objects.layerIndex,this._objects.layout,this._objects.mleaderStyle,this._objects.mlineStyle,this._objects.sortentsTable,this._objects.xrecord])this.registerObjectHandle(t)}assignGeneratedHandle(t){const e=t.objectId;this.releaseObjectHandle(t);const i=this.generateUniqueHandle();return t.objectId=i,this.registerObjectHandle(t),e&&e!==i&&this.updateMaxHandle(i),i}updateMaxHandle(t){const e=parseInt(t,16);!isNaN(e)&&e>this._maxHandle&&(this._maxHandle=e)}commitObjectHandle(t,e){const i=t.getAttrWithoutException("objectId"),r=e!=null&&i!=null&&e(i);if(!i||t.isTemp||r){this.assignGeneratedHandle(t);return}const a=this._handleRegistry.get(i);if(a&&a!==t)if(this.shouldPreserveIncomingHandle(t))this.assignGeneratedHandle(a);else{this.assignGeneratedHandle(t);return}this.registerObjectHandle(t),this.updateMaxHandle(i)}shouldPreserveIncomingHandle(t){return!t.isTemp}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(E.AUNITS,this._aunits,t??0,e=>{this._aunits=e})}get auprec(){return this._auprec}set auprec(t){this.updateSysVar(E.AUPREC,this._auprec,t??0,e=>{this._auprec=e})}get lunits(){return this._lunits}set lunits(t){this.updateSysVar(E.LUNITS,this._lunits,t??rt.Decimal,e=>{this._lunits=e})}get luprec(){return this._luprec}set luprec(t){this.updateSysVar(E.LUPREC,this._luprec,t??4,e=>{this._luprec=e})}get version(){return this._version}set version(t){this.updateSysVar(E.ACADVER,this._version,new pt(t),e=>{this._version=e})}get insunits(){return this._insunits}set insunits(t){this.updateSysVar(E.INSUNITS,this._insunits,t??4,e=>{this._insunits=e})}get unitmode(){return this._unitmode}set unitmode(t){this.updateSysVar(E.UNITMODE,this._unitmode,t??0,e=>{this._unitmode=e})}get measurement(){return this._measurement}set measurement(t){this.updateSysVar(E.MEASUREMENT,this._measurement,t??1,e=>{this._measurement=e})}get ltscale(){return this._ltscale}set ltscale(t){this.updateSysVar(E.LTSCALE,this._ltscale,t??1,e=>{this._ltscale=e})}get lwdisplay(){return this._lwdisplay}get drawNoPlotLayers(){return this._drawNoPlotLayers}get dwgname(){return this._dwgname}setDwgName(t){const e=t.trim();e&&this.updateSysVar(E.DWGNAME,this._dwgname,e,i=>{this._dwgname=i})}get thumbnailImage(){return this._thumbnailImage}set thumbnailImage(t){if(!t||t.length===0){this._thumbnailImage=void 0;return}this._thumbnailImage=t}isLayerDrawable(t){if(this._drawNoPlotLayers)return!0;const e=this.tables.layerTable.getAt(t);return e==null||e.isPlottable}set lwdisplay(t){this.updateSysVar(E.LWDISPLAY,this._lwdisplay,t??!1,e=>{this._lwdisplay=e})}get tilemode(){return this._tilemode}set tilemode(t){this._tilemode=t}get psltscale(){return this._psltscale}set psltscale(t){this._psltscale=t}get cecolor(){return this._cecolor}set cecolor(t){this.updateSysVar(E.CECOLOR,this._cecolor,t||0,e=>{this._cecolor=e.clone()})}get celtscale(){return this._celtscale}set celtscale(t){this.updateSysVar(E.CELTSCALE,this._celtscale,t??1,e=>{this._celtscale=e})}get celtype(){return this._celtype}set celtype(t){const e=this.normalizeLinetypeName(t??lt);this.updateSysVar(E.CELTYPE,this._celtype,e,i=>{this._celtype=i})}get celweight(){return this._celweight}set celweight(t){this.updateSysVar(E.CELWEIGHT,this._celweight,t??exports.AcGiLineWeight.ByLayer,e=>{this._celweight=e})}get cetransparency(){return this._cetransparency}set cetransparency(t){this.updateSysVar(E.CETRANSPARENCY,this._cetransparency,t??new ot,e=>{this._cetransparency=e.clone()})}get clayer(){return this._clayer}set clayer(t){this.updateSysVar(E.CLAYER,this._clayer,t??"0",e=>{this._clayer=e})}get cmlstyle(){return this._cmlstyle}set cmlstyle(t){this.updateSysVar(E.CMLSTYLE,this._cmlstyle,t??le,e=>{this._cmlstyle=e})}get cmlscale(){return this._cmlscale}set cmlscale(t){this.updateSysVar(E.CMLSCALE,this._cmlscale,t??1,e=>{this._cmlscale=e})}get cmleaderstyle(){return this._cmleaderstyle}set cmleaderstyle(t){this.updateSysVar(E.CMLEADERSTYLE,this._cmleaderstyle,t??he,e=>{this._cmleaderstyle=e})}get hpbackgroundcolor(){return this._hpbackgroundcolor}set hpbackgroundcolor(t){this.updateSysVar(E.HPBACKGROUNDCOLOR,this._hpbackgroundcolor,t??new X(exports.AcCmColorMethod.None),e=>{this._hpbackgroundcolor=e.clone()})}get hpcolor(){return this._hpcolor}set hpcolor(t){this.updateSysVar(E.HPCOLOR,this._hpcolor,t??this._cecolor,e=>{this._hpcolor=e.clone()})}get hplayer(){return this._hplayer}set hplayer(t){this.updateSysVar(E.HPLAYER,this._hplayer,t??".",e=>{this._hplayer=e})}get hptransparency(){return this._hptransparency}set hptransparency(t){this.updateSysVar(E.HPTRANSPARENCY,this._hptransparency,t??new ot,e=>{this._hptransparency=e.clone()})}get textstyle(){return this._textstyle}set textstyle(t){this.updateSysVar(E.TEXTSTYLE,this._textstyle,t??Z,e=>{this._textstyle=e})}get dimstyle(){return this._dimstyle}set dimstyle(t){this.updateSysVar(E.DIMSTYLE,this._dimstyle,t??Z,e=>{this._dimstyle=e})}get angbase(){return this._angbase}set angbase(t){this.updateSysVar(E.ANGBASE,this._angbase,t??0,e=>{this._angbase=e})}get angdir(){return this._angdir}set angdir(t){this.updateSysVar(E.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(E.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(E.EXTMIN,e,this._extents.min)}}get extents(){return this._extents}get pdmode(){return this._pdmode}set pdmode(t){this.updateSysVar(E.PDMODE,this._pdmode,t??0,e=>{this._pdmode=e})}get pdsize(){return this._pdsize}set pdsize(t){this.updateSysVar(E.PDSIZE,this._pdsize,t??0,e=>{this._pdsize=e})}get osmode(){return this._osmode}set osmode(t){this.updateSysVar(E.OSMODE,this._osmode,t??0,e=>{this._osmode=e})}get orthomode(){return this._orthomode}set orthomode(t){this.updateSysVar(E.ORTHOMODE,this._orthomode,t??0,e=>{this._orthomode=e})}get lastOpenError(){return this._lastOpenError}async read(t,e,i=Si.DXF){const r=Kt.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(),this._lastOpenError=null,this._drawNoPlotLayers=(e==null?void 0:e.drawNoPlotLayers)??!0,e!=null&&e.fileName&&this.setDwgName(e.fileName),rl(this);try{await r.read(t,this,e&&e.minimumChunkSize||10,this.createConversionProgressHandler(e),e==null?void 0:e.timeout,e==null?void 0:e.sysVars)}catch(s){const a=ji.from(s);throw this._lastOpenError=a,this.events.openFailed.dispatch({database:this,error:a}),a}this._lastOpenError=null,this.ensureDatabaseDefaults()}createConversionProgressHandler(t){return async(e,i,r,s,a)=>{let o=s;if(r==="ERROR"&&a){const c=ji.fromTask(a);this._lastOpenError=c,o={code:c.code,message:c.message,stage:c.stage??i}}if(t&&t.fontLoader&&i=="FONT"&&r=="END"){const c=s||this.tables.textStyleTable.fonts;try{await this.loadFontsWithProgress(t.fontLoader,c,e)}catch(l){if(t.failOnFontLoadError)throw l;const h=l instanceof Error?l.message:String(l);this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:i,subStageStatus:"ERROR",data:{fonts:c,error:h,code:"font_load_failed"}})}this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:i,subStageStatus:"END",data:c});return}this.events.openProgress.dispatch({database:this,percentage:e,stage:"CONVERSION",subStage:i,subStageStatus:r,data:o})}}async loadFontsWithProgress(t,e,i){if(e.length<=1){await t.load(e);return}const r=Math.max(1,Math.min(5,19-i));for(let s=0;s<e.length;s++){await t.load([e[s]]);const a=Math.min(19,i+Math.round((s+1)/e.length*r));this.events.openProgress.dispatch({database:this,percentage:a,stage:"CONVERSION",subStage:"FONT",subStageStatus:"IN-PROGRESS",data:e})}}async openUri(t,e){var g;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"),s=r?parseInt(r,10):null;let a=0;const o=(g=i.body)==null?void 0:g.getReader();if(!o)throw new Error("Failed to get response reader");const c=[];for(;;){const{done:p,value:f}=await o.read();if(p)break;if(c.push(f),a+=f.length,s!==null){const m=Math.round(a/s*100);this.events.openProgress.dispatch({database:this,percentage:m,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const l=new Uint8Array(a);let h=0;for(const p of c)l.set(p,h),h+=p.length;const u=this.getFileNameFromUri(t);u&&this.setDwgName(u);const d=u.toLowerCase().split(".").pop();d==="dwg"?await this.read(l.buffer,e,Si.DWG):d==="dxf"?await this.read(l.buffer,e,Si.DXF):await this.read(l.buffer,e,d),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(),this._layerFilters.root.getNestedFilters().length>0&&!this.tables.layerTable.extensionDictionary&&(this.tables.layerTable.extensionDictionary=this.generateHandle());const s=typeof r=="boolean"?{saveThumbnailImage:r,format:"ascii"}:{saveThumbnailImage:r.saveThumbnailImage??!1,format:r.format??"ascii"},a=i instanceof pt?i:new pt(i),o=new ve({database:this,precision:e,version:a,outputFormat:s.format});return this.writeDxfHeaderSection(o),this.writeDxfClassesSection(o),this.writeDxfTablesSection(o,a),this.writeDxfBlocksSection(o),this.writeDxfEntitiesSection(o),this.writeDxfObjectsSection(o),this.writeDxfThumbnailImageSection(o,s.saveThumbnailImage),o.writeStart("EOF"),s.format==="binary"?o.toBinary():o.toString()}async regen(){await new Gl(this).read(null,this,500,this.createConversionProgressHandler())}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){const e=new Eh(this);t.layer&&e.createDefaultLayer(),t.lineType&&e.createDefaultLineType(),t.textStyle&&e.createDefaultTextStyle(),t.dimStyle&&e.createDefaultDimStyle(),t.layout&&e.createDefaultLayout()}ensureEntityStyleDefaults(t){var e;if(t.dxfTypeName==="MLINE"){this.ensureMLineStyle(this._cmlstyle||le);return}if(t.dxfTypeName==="MULTILEADER"){this.ensureMLeaderStyle(this._cmleaderstyle||he);return}if(t.dxfTypeName==="HATCH"){const i=t;(e=i.applyPatternDefaultsFromSysVars)==null||e.call(i,this)}}ensureTextStyleDefaults(){this.hasDefaultTextStyle()||this.tables.textStyleTable.add(new Ir({name:Z,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}hasDefaultTextStyle(){const t=[Z,"STANDARD"];for(const e of t)if(this.tables.textStyleTable.has(e))return!0;for(const e of this.tables.textStyleTable.newIterator())if(e.name.toUpperCase()===Z.toUpperCase())return!0;return!1}ensureDatabaseDefaults(){if(!this.tables.layerTable.has("0")){const e=new X;e.colorIndex=7,this.tables.layerTable.add(new nn({name:"0",standardFlags:0,linetype:ke,lineWeight:0,isOff:!1,color:e,isPlottable:!0}))}if(this.tables.linetypeTable.has(Jt)||this.tables.linetypeTable.add(new Ae({name:Jt,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(lt)||this.tables.linetypeTable.add(new Ae({name:lt,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(ke)||this.tables.linetypeTable.add(new Ae({name:ke,standardFlag:0,description:"Solid line",totalPatternLength:0})),this.ensureTextStyleDefaults(),this.tables.dimStyleTable.has(Z)||this.tables.dimStyleTable.add(new Tt({name:Z,dimtxsty:Z})),!this.tables.viewportTable.has(ii)){const e=new Se;e.name=ii,this.tables.viewportTable.add(e)}this.ensureMLineStyle(this._cmlstyle||le),this.ensureMLeaderStyle(this._cmleaderstyle||he);const t=this.tables.blockTable.modelSpace;if(!this.objects.layout.getAt("Model")){const e=new tn;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(_s)||this.tables.appIdTable.add(new Xn(_s)),this.tables.appIdTable.has(bs)||this.tables.appIdTable.add(new Xn(bs))}ensureMLineStyle(t){const e=this.objects.mlineStyle,i=t.trim();if(!i||e.getAt(i))return;for(const[s,a]of e.entries())if(s.toUpperCase()===i.toUpperCase()||a.styleName.toUpperCase()===i.toUpperCase())return;const r=new ca;r.styleName=i,r.elements=[{offset:.5,color:new X().setByLayer(),lineType:lt},{offset:-.5,color:new X().setByLayer(),lineType:lt}],e.setAt(i,r)}ensureMLeaderStyle(t){const e=this.objects.mleaderStyle,i=t.trim();if(!i||e.getAt(i))return;for(const[o]of e.entries())if(o.toUpperCase()===i.toUpperCase())return;const r=new Cr;r.unknown1=2,r.maxLeaderSegmentsPoints=2,r.leaderLineColor=new X().setByBlock(),r.textColor=new X().setByBlock(),r.blockColor=new X().setByBlock(),r.alignSpace=4,r.breakSize=3.75,r.enableBlockRotation=!0,r.unknown2=!1;const s=this.tables.linetypeTable.getAt(Jt);r.leaderLineTypeId=s==null?void 0:s.objectId;const a=this.tables.textStyleTable.getAt(Z);r.textStyleId=a==null?void 0:a.objectId,e.setAt(i,r)}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.capabilities.supportsUtf8CodePage&&(t.writeString(9,"$DWGCODEPAGE"),t.writeString(3,"UTF-8")),t.writeString(9,"$INSUNITS"),t.writeInt16(70,this.insunits),t.writeString(9,"$LUNITS"),t.writeInt16(70,this.lunits),t.writeString(9,"$LUPREC"),t.writeInt16(70,this.luprec),t.writeString(9,"$UNITMODE"),t.writeInt16(70,this.unitmode),t.writeString(9,"$MEASUREMENT"),t.writeInt16(70,this.measurement),t.writeString(9,"$LTSCALE"),t.writeDouble(40,this.ltscale),t.capabilities.supportsLineWeight&&(t.writeString(9,"$LWDISPLAY"),t.writeInt16(70,this.lwdisplay?1:0)),t.writeString(9,"$CELTSCALE"),t.writeDouble(40,this.celtscale),t.capabilities.supportsLineWeight&&(t.writeString(9,"$CELWEIGHT"),t.writeLineWeight(370,this.celweight)),t.writeString(9,"$CECOLOR"),t.writeCmColor(this.cecolor),t.writeString(9,"$TILEMODE"),t.writeInt16(70,this.tilemode?1:0),t.writeString(9,"$PSLTSCALE"),t.writeInt16(70,this.psltscale?1:0),t.writeString(9,"$CLAYER"),t.writeString(8,this.clayer),t.writeString(9,"$CELTYPE"),t.writeString(6,this.celtype),t.capabilities.supportsTransparency&&!this.cetransparency.isInvalid&&(t.writeString(9,"$CETRANSPARENCY"),t.writeTransparency(this.cetransparency)),t.writeString(9,"$CMLSTYLE"),t.writeString(2,this.cmlstyle),t.writeString(9,"$CMLSCALE"),t.writeDouble(40,this.cmlscale),t.writeString(9,"$CMLEADERSTYLE"),t.writeString(2,this.cmleaderstyle),this.hpcolor.colorMethod!==exports.AcCmColorMethod.None&&(t.writeString(9,"$HPCOLOR"),t.writeCmColor(this.hpcolor,2)),this.hpbackgroundcolor.colorMethod!==exports.AcCmColorMethod.None&&(t.writeString(9,"$HPBACKGROUNDCOLOR"),t.writeCmColor(this.hpbackgroundcolor,2)),t.writeString(9,"$HPLAYER"),t.writeString(8,this.hplayer),t.capabilities.supportsTransparency&&!this.hptransparency.isInvalid&&(t.writeString(9,"$HPTRANSPARENCY"),t.writeTransparency(this.hptransparency)),t.writeString(9,"$TEXTSTYLE"),t.writeString(7,this.textstyle),t.writeString(9,"$DIMSTYLE"),t.writeString(2,this.dimstyle),t.writeString(9,"$ANGBASE"),t.writeAngle(50,this.angbase),t.writeString(9,"$ANGDIR"),t.writeInt16(70,this.angdir),t.writeString(9,"$AUNITS"),t.writeInt16(70,this.aunits),t.writeString(9,"$AUPREC"),t.writeInt16(70,this.auprec),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.writeString(9,"$ORTHOMODE"),t.writeInt16(70,this.orthomode),t.endSection()}writeDxfClassesSection(t){if(!(!t.capabilities.supportsClassesSection||this._classes.length===0)){t.startSection("CLASSES");for(const e of this._classes)t.writeStart("CLASS"),t.writeString(1,e.name),t.writeString(2,e.cppClassName),t.writeString(3,e.appName),t.writeInt32(90,e.proxyFlag),t.writeInt32(91,e.instanceCount),t.writeInt8(280,e.wasProxy?1:0),t.writeInt8(281,e.isEntity?1:0);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,"UCS",this.tables.ucsTable,this.tables.ucsTable.newIterator(),"UCS"),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(!0),"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.capabilities.supportsBlockRecordTable&&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){if(!t.capabilities.supportsObjectsSection)return;t.startSection("OBJECTS");const e=this.objects.dictionary;e.ownerId="0";const i=a=>{t.writeStart("DICTIONARY"),a.dxfOut(t,!0)},r=(a,o)=>{e.getAt(a)!==o&&e.setAt(a,o)},s=a=>{e.getAt(a)&&e.remove(a)};r("ACAD_LAYOUT",this.objects.layout),this.objects.group.numEntries>0?r("ACAD_GROUP",this.objects.group):s("ACAD_GROUP"),this.objects.sortentsTable.numEntries>0?r("ACAD_SORTENTS",this.objects.sortentsTable):s("ACAD_SORTENTS"),this.objects.mleaderStyle.numEntries>0?r("ACAD_MLEADERSTYLE",this.objects.mleaderStyle):s("ACAD_MLEADERSTYLE"),this.objects.mlineStyle.numEntries>0?r("ACAD_MLINESTYLE",this.objects.mlineStyle):s("ACAD_MLINESTYLE"),this.objects.imageDefinition.numEntries>0?r("ISM_RASTER_IMAGE_DICT",this.objects.imageDefinition):s("ISM_RASTER_IMAGE_DICT"),this.objects.xrecord.numEntries>0?r("MLIGHT_XRECORD",this.objects.xrecord):s("MLIGHT_XRECORD"),i(e),i(this.objects.layout),this.objects.group.numEntries>0&&i(this.objects.group),this.objects.sortentsTable.numEntries>0&&i(this.objects.sortentsTable),this.objects.mleaderStyle.numEntries>0&&i(this.objects.mleaderStyle),this.objects.mlineStyle.numEntries>0&&i(this.objects.mlineStyle),this.objects.imageDefinition.numEntries>0&&i(this.objects.imageDefinition),this.objects.xrecord.numEntries>0&&i(this.objects.xrecord);for(const[a,o]of this.objects.layout.entries())t.writeStart("LAYOUT"),o.dxfOut(t,!0);for(const[a,o]of this.objects.group.entries())o.name||(o.name=a),t.writeStart("GROUP"),o.dxfOut(t,!0);for(const[a,o]of this.objects.sortentsTable.entries())t.writeStart("SORTENTSTABLE"),o.dxfOut(t,!0);for(const[a,o]of this.objects.imageDefinition.entries())t.writeStart("IMAGEDEF"),o.dxfOut(t,!0);for(const[a,o]of this.objects.layerFilter.entries())t.writeStart("LAYER_FILTER"),o.dxfOut(t,!0);for(const[a,o]of this.objects.layerIndex.entries())t.writeStart("LAYER_INDEX"),o.dxfOut(t,!0);for(const[a,o]of this.objects.mleaderStyle.entries())t.writeStart("MLEADERSTYLE"),o.dxfOut(t,!0);for(const[a,o]of this.objects.mlineStyle.entries())t.writeStart("MLINESTYLE"),o.dxfOut(t,!0);for(const[a,o]of this.objects.xrecord.entries())t.writeStart("XRECORD"),o.dxfOut(t,!0);this.writeAcLyLayerFilterObjects(t),t.endSection()}writeAcLyLayerFilterObjects(t){const e=oh(this._layerFilters);if(e.nodes.length===0)return;const i=[],r=[],s=this.tables.layerTable,a=s.extensionDictionary??this.generateHandle();s.extensionDictionary=a;const o=this.generateHandle(),c=this.generateHandle(),l=[],h=[],u=(p,f,m)=>{const y=this.generateHandle();let _;if(p.children.length>0){const v=this.generateHandle(),x=this.generateHandle(),k=[];for(const I of p.children)k.push({name:I.key,id:u(I,x,!1)});i.push({handle:v,ownerId:y,entries:[{name:ai,id:x}]}),i.push({handle:x,ownerId:v,entries:k}),_=v}return r.push({handle:y,ownerId:f,extensionDictionaryId:_,data:p.data}),m&&h.push({name:p.key,id:y}),y};for(const p of e.nodes)l.push({name:p.key,id:u(p,o,!0)});const d=new Map,g=this.getObjectById(a);if(g instanceof Nt)for(const[p,f]of g.entries())d.set(p,f.objectId);d.set(ai,o),d.set(Or,c),i.unshift({handle:a,ownerId:s.objectId,entries:Array.from(d,([p,f])=>({name:p,id:f}))},{handle:o,ownerId:a,entries:l},{handle:c,ownerId:a,entries:h});for(const p of i){t.writeStart("DICTIONARY"),t.writeHandle(5,p.handle),t.writeObjectId(330,p.ownerId),t.writeSubclassMarker("AcDbDictionary"),t.writeInt16(280,1),t.writeInt16(281,1);for(const f of p.entries)t.writeString(3,f.name),t.writeObjectId(350,f.id)}for(const p of r){const f=new la;f.objectId=p.handle,f.ownerId=p.ownerId,p.extensionDictionaryId&&(f.extensionDictionary=p.extensionDictionaryId),f.data=ch(p.data),t.writeStart("XRECORD"),f.dxfOut(t)}}writeDxfTable(t,e,i,r,s){const a=[...r];t.startTable(e),i.dxfOut(t);for(const o of a){if(s==="BLOCK_RECORD"&&o instanceof tt){o.dxfOutBlockRecord(t);continue}t.writeStart(s),o.dxfOut(t,!0)}t.endTable()}writeDxfEntity(t,e){if(e instanceof kt&&!t.capabilities.supportsLwPolyline){t.writeStart("POLYLINE"),e.dxfOutAs2dPolyline(t,!0);return}t.writeStart(e.dxfTypeName),e.dxfOut(t,!0)}writeDxfThumbnailImageSection(t,e=!1){const i=this._thumbnailImage;if(!e||!i||i.length===0||!t.capabilities.supportsObjectsSection)return;const r=127;t.startSection("THUMBNAILIMAGE"),t.writeInt32(90,i.length);for(let s=0;s<i.length;s+=r){const a=i.subarray(s,s+r);t.writeString(310,Sr(a))}t.endSection()}clear(){this.transactionManager.clearUndoStack(),this._classes=[],this._tables.blockTable.removeAll(),this._tables.dimStyleTable.removeAll(),this._tables.linetypeTable.removeAll(),this._tables.textStyleTable.removeAll(),this._tables.ucsTable.removeAll(),this._tables.viewTable.removeAll(),this._tables.layerTable.removeAll(),this._tables.viewportTable.removeAll(),this._tables.appIdTable.removeAll(),this._objects.layout.removeAll(),this._objects.group.removeAll(),this._objects.imageDefinition.removeAll(),this._objects.layerFilter.removeAll(),this._objects.layerIndex.removeAll(),this._objects.mleaderStyle.removeAll(),this._objects.mlineStyle.removeAll(),this._objects.sortentsTable.removeAll(),this._objects.xrecord.removeAll(),this._layerFilters=new ue,this._currentSpace=void 0,this._extents.makeEmpty(),this.registerBootstrapHandles()}updateSysVar(t,e,i,r){ft.instance().applyVarMutation(t,e,i,this,()=>r(i))}normalizeLinetypeName(t){const e=t.trim();return e.toUpperCase()==="BYLAYER"?lt:e.toUpperCase()==="BYBLOCK"?Jt:e}triggerSysVarChangedEvent(t,e,i){const r=ft.instance(),s=t.toLowerCase();r.getDescriptor(s)!=null&&r.events.sysVarChanged.dispatch({database:this,name:s,oldVal:e,newVal:i})}getFileNameFromUri(t){try{const i=new URL(t).pathname.split("/");return i[i.length-1]||""}catch{return""}}};Ei._unsavedDrawingSequence=0;let Cs=Ei;class N0{constructor(){this.transactionStack=[]}startTransaction(){const t=new da;return this.transactionStack.push(t),t}currentTransaction(){return this.transactionStack[this.transactionStack.length-1]}commitTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to commit.");t.commit()}abortTransaction(){const t=this.transactionStack.pop();if(!t)throw new Error("No active transaction to abort.");t.abort()}hasTransaction(){return this.transactionStack.length>0}}const ns=6,Aa=class Aa extends H{get dxfTypeName(){return"TOLERANCE"}constructor(){super(),this._location=new b,this._text="",this._dimensionStyle="",this._normal=new w(0,0,1),this._direction=new w(1,0,0)}get location(){return this._location}set location(t){this._location.set(t.x,t.y,t.z??0)}get text(){return this._text}set text(t){this._text=t}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t}get normal(){return this._normal}set normal(t){this._normal.set(t.x,t.y,t.z??0),this._normal.lengthSq()>0&&this._normal.normalize()}get direction(){return this._direction}set direction(t){this._direction.set(t.x,t.y,t.z??0),this._direction.lengthSq()>0&&this._direction.normalize()}setOrientation(t,e){return this.normal=t,this.direction=e,this}getBoundingPoints(){return this.getBoundingPolyline().slice(0,4)}getBoundingPolyline(){const{width:t,rowHeight:e,rowCount:i}=this.resolveFrameLayout(),r=e/2,s=r-e*i;return[new b(0,r,0),new b(t,r,0),new b(t,s,0),new b(0,s,0),new b(0,r,0)].map(o=>this.toFrameWcs(o.x,o.y))}get geometricExtents(){const t=new Y;for(const e of this.getBoundingPoints())t.expandByPoint(e);return t.isEmpty()&&t.expandByPoint(this._location),t}subGetGripPoints(){return[this._location]}subMoveGripPointsAt(t,e){return ie(t,e,this._location),this}subGetOsnapPoints(t,e,i,r){t===A.Insertion&&r.push(this._location)}transformBy(t){const e=this.resolveLocalBasis(),i=this._location.clone(),r=i.clone().add(e.xAxis),s=i.clone().add(e.yAxis);i.applyMatrix4(t),r.applyMatrix4(t),s.applyMatrix4(t);const a=new w(r).sub(i),o=new w(s).sub(i);let c=new w().crossVectors(a,o);c.lengthSq()===0?c=this._normal.clone().transformDirection(t):c.normalize();let l=a.clone();return l.lengthSq()===0?l=this._direction.clone().transformDirection(t):l.normalize(),this._location.copy(i),this._normal.copy(c),this._direction.copy(l),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"tolerance",properties:[{name:"text",type:"string",editable:!0,accessor:{get:()=>this.text,set:t=>{this.text=t}}},{name:"dimensionStyle",type:"string",editable:!0,accessor:{get:()=>this.dimensionStyle,set:t=>{this.dimensionStyle=t}}},{name:"textHeight",type:"float",editable:!1,accessor:{get:()=>this.textHeight}}]},{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}}}]}]}}subWorldDraw(t,e){const r=this.collectFrameLineSegments().map(([a,o])=>t.lines([a,o])),s=this.drawToleranceText(t,e);return r.length>0&&s?t.group([...r,s]):r.length===1?r[0]:r.length>1?t.group(r):s}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbFcf"),this._dimensionStyle&&t.writeString(3,this._dimensionStyle),t.writePoint3d(10,this._location),t.writeString(1,this._text),this._normal.equals(w.Z_AXIS)||t.writeVector3d(210,this._normal),this._direction.equals(w.X_AXIS)||t.writeVector3d(11,this._direction),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbFcf");let e=this.location.x,i=this.location.y,r=this.location.z,s=this.normal.x,a=this.normal.y,o=this.normal.z,c=this.direction.x,l=this.direction.y,h=this.direction.z,u=!1,d=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const g=t.readItem();if(!g)break;const p=Number(g.code),f=Number(g.value);switch(p){case 1:this.text=String(g.value);break;case 3:this.dimensionStyle=String(g.value);break;case 10:e=f;break;case 20:i=f;break;case 30:r=f;break;case 11:c=f,d=!0;break;case 21:l=f,d=!0;break;case 31:h=f,d=!0;break;case 210:s=f,u=!0;break;case 220:a=f,u=!0;break;case 230:o=f,u=!0;break}}return this.location={x:e,y:i,z:r},u&&(this.normal={x:s,y:a,z:o}),d&&(this.direction={x:c,y:l,z:h}),this}get textHeight(){const t=this.resolveDimensionStyle(),e=(t==null?void 0:t.dimtxt)??Tt.DEFAULT_DIM_VALUES.dimtxt,i=(t==null?void 0:t.dimscale)??Tt.DEFAULT_DIM_VALUES.dimscale;return e*i}drawToleranceText(t,e){const i=this.parseToleranceFrame(this._text);if(i.length===0)return;const r=this.resolveFrameLayout(i),s=this.getTextStyle(),a=[];for(let o=0;o<i.length;o++){const c=i[o];let l=r.cellPadding;const h=-r.rowHeight*o;for(let u=0;u<c.cells.length;u++){const d=c.cells[u],g=r.columnWidths[u]??this.textHeight;if(d.trim()){const p=this.toFrameWcs(l+g/2,h),f={text:d,height:this.textHeight,width:1/0,position:p,directionVector:this._direction,attachmentPoint:exports.AcGiMTextAttachmentPoint.MiddleCenter,drawingDirection:exports.AcGiMTextFlowDirection.LEFT_TO_RIGHT};a.push(t.mtext(f,s,e))}l+=g+r.columnGap}}if(a.length!==0)return a.length===1?a[0]:t.group(a)}collectFrameLineSegments(){const t=this.parseToleranceFrame(this._text),e=this.resolveFrameLayout(t),{width:i,rowHeight:r,rowCount:s,columnDivisions:a}=e;if(i<=0||r<=0||s<=0)return[];const o=r/2,c=o-r*s,l=[],h=(u,d)=>{l.push([u,d])};h(this.toFrameWcs(0,o),this.toFrameWcs(i,o)),h(this.toFrameWcs(i,o),this.toFrameWcs(i,c)),h(this.toFrameWcs(i,c),this.toFrameWcs(0,c)),h(this.toFrameWcs(0,c),this.toFrameWcs(0,o));for(const u of a)h(this.toFrameWcs(u,o),this.toFrameWcs(u,c));for(let u=1;u<t.length;u++){const d=o-r*u;h(this.toFrameWcs(0,d),this.toFrameWcs(i,d))}return l}toFrameWcs(t,e){const i=this.resolveLocalBasis();return this._location.clone().addScaledVector(i.xAxis,t).addScaledVector(i.yAxis,e)}resolveFrameLayout(t){const e=t??this.parseToleranceFrame(this._text),i=this.textHeight,r=i*2,s=i/2,a=i;if(i<=0||e.length===0)return{width:0,totalHeight:0,rowHeight:0,columnWidths:[],columnDivisions:[],rowCount:0,cellPadding:0,columnGap:0};const o=Math.max(...e.map(d=>d.cells.length),0),c=[];for(let d=0;d<o;d++){let g=i;for(const p of e){const f=p.cells[d]??"";if(!f.trim())continue;const m=ip(f,i);g=Math.max(g,m)}c.push(g)}const l=[0];let h=s;for(let d=0;d<c.length;d++)h+=c[d],h+=a,l.push(h-s);return{width:l[l.length-1]??0,totalHeight:r*e.length,rowHeight:r,columnWidths:c,columnDivisions:l,rowCount:e.length,cellPadding:s,columnGap:a}}parseToleranceFrame(t){if(!t)return[];const e=this.splitToleranceRows(t);if(e.length===0)return[];if(!t.includes("%%v"))return e.map(s=>({cells:this.parsePipeSeparatedCells(s)}));const i=e.map(s=>{const o=this.splitToleranceTokens(s,"%%v").slice(0,ns);for(;o.length<ns;)o.push("");return o}),r=[0,1];i.some(s=>{var a;return(a=s[2])==null?void 0:a.trim()})&&r.push(2);for(let s=3;s<ns;s++)i.some(a=>{var o;return(o=a[s])==null?void 0:o.trim()})&&r.push(s);return i.map(s=>({cells:r.map(a=>s[a]??"")}))}splitToleranceRows(t){return t.replace(/\^J/g,`
12
+ `).split(/\r\n|\r|\n|\\P/i).map(i=>i.trim()).filter(i=>i.length>0)}splitToleranceTokens(t,e){if(!t)return[];const i=[];let r="",s=0;for(let a=0;a<t.length;){if(t.startsWith(e,a)&&s===0){i.push(r),r="",a+=e.length;continue}const o=t[a];o==="{"?s++:o==="}"&&(s=Math.max(0,s-1)),r+=o,a++}return i.push(r),i}parsePipeSeparatedCells(t){return t?this.splitToleranceTokens(t,"|").filter(i=>i.length>0):[]}resolveLocalBasis(){const t=this._normal.clone();t.lengthSq()===0?t.set(0,0,1):t.normalize();let e=this._direction.clone();e.lengthSq()===0?e.set(1,0,0):e.normalize();let i=new w().crossVectors(t,e);return i.lengthSq()===0&&(e=w.X_AXIS.clone(),i=new w().crossVectors(t,e)),i.normalize(),e=new w().crossVectors(i,t).normalize(),{xAxis:e,yAxis:i,zAxis:t}}resolveDimensionStyle(){const t=this._dimensionStyle.trim(),e=this.tryGetDatabase();if(!(!t||!e))return e.tables.dimStyleTable.getAt(t)}tryGetDatabase(){try{return this.database}catch{return}}getTextStyle(){const t=this.resolveDimensionStyle(),e=(t==null?void 0:t.dimtxsty)??Tt.DEFAULT_DIM_VALUES.dimtxsty??"Standard",i=this.database.tables.textStyleTable.resolveAt(e);if(!i)throw new Error("No valid text style found in text style table.");return i.textStyle}};Aa.typeName="Fcf";let Vi=Aa;var Kh=(n=>(n[n.MText=0]="MText",n[n.Fcf=1]="Fcf",n[n.BlockReference=2]="BlockReference",n[n.NoAnnotation=3]="NoAnnotation",n))(Kh||{});const Sa=class Sa extends _t{get dxfTypeName(){return"LEADER"}constructor(){super(),this._isSplined=!1,this._updated=!1,this._hasArrowHead=!1,this._vertices=[],this._dimensionStyle="",this._hasHookLine=!1,this._isHookLineSameDirection=!1,this._annoType=3,this._textHeight=0,this._textWidth=0,this._associatedAnnotation="",this._normal=new w(0,0,1),this._horizontalDirection=new w(1,0,0)}get isSplined(){return this._isSplined}set isSplined(t){this._isSplined=t}get hasArrowHead(){return this._hasArrowHead}set hasArrowHead(t){this._hasArrowHead=t}get hasHookLine(){return this._hasHookLine}set hasHookLine(t){this._hasHookLine=t}get isHookLineSameDirection(){return this._isHookLineSameDirection}set isHookLineSameDirection(t){this._isHookLineSameDirection=t}get numVertices(){return this._vertices.length}get vertices(){return this._vertices.map(t=>t.clone())}get dimensionStyle(){return this._dimensionStyle}set dimensionStyle(t){this._dimensionStyle=t}get annoType(){return this._annoType}set annoType(t){this._annoType=t}get textHeight(){return this._textHeight}set textHeight(t){this._textHeight=t}get textWidth(){return this._textWidth}set textWidth(t){this._textWidth=t}get byBlockColor(){return this._byBlockColor}set byBlockColor(t){this._byBlockColor=t}get associatedAnnotation(){return this._associatedAnnotation}set associatedAnnotation(t){this._associatedAnnotation=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get horizontalDirection(){return this._horizontalDirection}set horizontalDirection(t){this._horizontalDirection.copy(t)}get offsetFromBlock(){var t;return(t=this._offsetFromBlock)==null?void 0:t.clone()}set offsetFromBlock(t){this._offsetFromBlock=t?new w(t):void 0}get offsetFromAnnotation(){var t;return(t=this._offsetFromAnnotation)==null?void 0:t.clone()}set offsetFromAnnotation(t){this._offsetFromAnnotation=t?new w(t):void 0}appendVertex(t){this._vertices.push(new b().copy(t)),this._updated=!0}setVertexAt(t,e){if(t<0||t>=this._vertices.length)throw new Error("The vertex index is out of range!");return this._vertices[t].copy(e),this._updated=!0,this}vertexAt(t){if(t<0||t>=this._vertices.length)throw new Error("The vertex index is out of range!");return this._vertices[t].clone()}subGetGripPoints(){return this._vertices.map(t=>t.clone())}subMoveGripPointsAt(t,e){return hi(t,e,this._vertices),this}subGetOsnapPoints(t,e,i,r){if(this.numVertices===0)return;if(this.isSplined&&this.splineGeo){switch(t){case A.EndPoint:r.push(this._vertices[0]),r.push(this._vertices[this.numVertices-1]);break;case A.Nearest:r.push(this.splineGeo.nearestPoint(e));break}return}const s=this._vertices;switch(t){case A.EndPoint:r.push(...s);break;case A.MidPoint:case A.Nearest:case A.Perpendicular:{const a=[];for(let o=0;o<s.length-1;o++){const c=[];ui(s[o],s[o+1],t,e,c),a.push(...c)}if(t===A.MidPoint)r.push(...a);else{const o=Ft(e,a);o&&r.push(o)}break}}}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new Y().setFromPoints(this.collectDrawPoints())}get closed(){return!1}set closed(t){}get area(){return 0}transformBy(t){return this._vertices.forEach(e=>e.applyMatrix4(t)),this.transformVector(this._normal,t),this.transformVector(this._horizontalDirection,t),this._offsetFromBlock&&this.transformVector(this._offsetFromBlock,t),this._offsetFromAnnotation&&this.transformVector(this._offsetFromAnnotation,t),this._splineGeo?(this._splineGeo.transform(t),this._updated=!1):this._updated=!0,this}subWorldDraw(t){return t.lines(this.collectDrawPoints())}collectDrawPoints(){if(this.isSplined&&this.splineGeo)return this.splineGeo.getPoints(100);const t=this._vertices.map(e=>e.clone());if(t.length>0&&!this._isSplined){const e=t[t.length-1];if(this.shouldDrawHookLine(e)){const i=this.computeHookLineEndPoint(e);i&&t.push(i)}}return t}shouldDrawHookLine(t){if(this.resolveHookLineLength(t)<=0)return!1;if(this._hasHookLine)return!0;const e=this.resolveAssociatedMText();if(e&&this.resolveHookSpanFromMText(e,t)>0)return!0;if(this._annoType!==0)return!1;const i=this.resolveDimensionStyle();return((i==null?void 0:i.dimtad)??Tt.DEFAULT_DIM_VALUES.dimtad)!==aa.Center}computeHookLineEndPoint(t){const e=this.resolveHookLineLength(t);if(e<=0)return null;const i=this.resolveHookAxis();return t.clone().addScaledVector(i,e)}resolveHookLineLength(t){const e=this.resolveDimensionStyle(),i=((e==null?void 0:e.dimgap)??Tt.DEFAULT_DIM_VALUES.dimgap)*((e==null?void 0:e.dimscale)??Tt.DEFAULT_DIM_VALUES.dimscale);let r=this._textWidth+i;const s=this.resolveAssociatedMText();if(s){const a=this.resolveHookSpanFromMText(s,t);if(a>0)r=Math.max(r,a);else{const o=this.resolveAnnotationWidth(s);o>0&&(r=Math.max(r,o))}}return r}resolveHookAxis(){const t=this._horizontalDirection.clone();t.lengthSq()===0?t.set(1,0,0):t.normalize();const e=this._isHookLineSameDirection?1:-1;return t.multiplyScalar(e),t}resolveHookSpanFromMText(t,e){const i=this.resolveHookAxis(),r=this.resolveMTextLayoutMetrics(t);let s=0;for(const a of sp(r)){const o=(a.x-e.x)*i.x+(a.y-e.y)*i.y+(a.z-e.z)*i.z;o>s&&(s=o)}return s}resolveAnnotationWidth(t){if(t.extentsWidth>0)return t.extentsWidth;const e=ia(t.contents).split(`
13
+ `);return Math.max(...e.map(i=>en(i.trim(),t.height)),0)}resolveMTextLayoutMetrics(t){return np({contents:t.contents,height:t.height,width:t.width,extentsWidth:t.extentsWidth,lineSpacingFactor:t.lineSpacingFactor,attachmentPoint:t.attachmentPoint,rotation:t.rotation,direction:t.direction,location:t.location})}scoreMTextAssociation(t,e){const i=this.resolveMTextLayoutMetrics(t),r=Math.max(t.height*2,1),s=Math.max(t.height,1),a=Math.max(i.height,t.height*4,10);return ap(e,i,{padX:r,padYAbove:s,padYBelow:a})}resolveDimensionStyle(){var i;const t=(i=this._dimensionStyle)==null?void 0:i.trim(),e=this.tryGetDatabase();if(!(!t||!e))return e.tables.dimStyleTable.getAt(t)}resolveAssociatedMText(){const t=this.tryGetDatabase();if(!t)return;if(this._associatedAnnotation){const o=t.getObjectById(this._associatedAnnotation);if(o instanceof Ee)return o}if(this._vertices.length===0)return;const e=this.getAttrWithoutException("ownerId");if(!e)return;const i=t.getObjectById(e);if(!(i instanceof tt))return;const r=this._vertices[this._vertices.length-1];let s,a=Number.POSITIVE_INFINITY;for(const o of i.newIterator()){if(!(o instanceof Ee))continue;const c=this.scoreMTextAssociation(o,r);c==null||c>=a||(a=c,s=o)}return s}tryGetDatabase(){try{return this.database}catch{return}}get splineGeo(){return this.createSplineIfNeeded(),this._splineGeo}createSplineIfNeeded(){this.isSplined&&this.numVertices>=2&&(this._splineGeo==null||this._updated)&&(this._splineGeo=new jt(this._vertices,"Uniform"),this._updated=!1)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLeader"),t.writeString(3,this.dimensionStyle),t.writeInt16(71,this.hasArrowHead?1:0),t.writeInt16(72,this.isSplined?1:0),t.writeInt16(73,this.annoType),t.writeInt16(74,this.isHookLineSameDirection?1:0),t.writeInt16(75,this.hasHookLine?1:0),t.writeInt16(76,this.numVertices),this.textHeight!==0&&t.writeDouble(40,this.textHeight),this.textWidth!==0&&t.writeDouble(41,this.textWidth),this.byBlockColor!=null&&t.writeInt16(77,this.byBlockColor),this.associatedAnnotation&&t.writeHandle(340,this.associatedAnnotation);for(const e of this.vertices)t.writePoint3d(10,e);return t.writeVector3d(210,this.normal),t.writeVector3d(211,this.horizontalDirection),this._offsetFromBlock&&t.writeVector3d(212,this._offsetFromBlock),this._offsetFromAnnotation&&t.writeVector3d(213,this._offsetFromAnnotation),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbLeader"),this._vertices.length=0;let e=null,i=this.normal.x,r=this.normal.y,s=this.normal.z,a=this.horizontalDirection.x,o=this.horizontalDirection.y,c=this.horizontalDirection.z,l=0,h=0,u=0,d=0,g=0,p=0,f=!1,m=!1;const y=()=>{e&&(this.appendVertex(e),e=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const _=t.readItem();if(!_)break;const v=Number(_.code),x=Number(_.value);switch(v){case 3:this.dimensionStyle=String(_.value);break;case 10:y(),e={x,y:0,z:0};break;case 20:e&&(e.y=x);break;case 30:e&&(e.z=x);break;case 40:this.textHeight=x;break;case 41:this.textWidth=x;break;case 71:this.hasArrowHead=x!==0;break;case 72:this.isSplined=x!==0;break;case 73:this.annoType=x;break;case 74:this.isHookLineSameDirection=x!==0;break;case 75:this.hasHookLine=x!==0;break;case 76:break;case 77:this.byBlockColor=x;break;case 210:i=x;break;case 220:r=x;break;case 230:s=x;break;case 211:a=x;break;case 221:o=x;break;case 231:c=x;break;case 212:l=x,f=!0;break;case 222:h=x,f=!0;break;case 232:u=x,f=!0;break;case 213:d=x,m=!0;break;case 223:g=x,m=!0;break;case 233:p=x,m=!0;break;case 340:this.associatedAnnotation=String(_.value);break}}return y(),this.normal={x:i,y:r,z:s},this.horizontalDirection={x:a,y:o,z:c},f&&(this.offsetFromBlock={x:l,y:h,z:u}),m&&(this.offsetFromAnnotation={x:d,y:g,z:p}),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectPath2d();return e.length<2?1:kt.from2dPoints(e,!1).getOffsetSideAtPoint(t)}createOffsetCurve(t){return Nr(this.collectPath2d(),!1,t)}collectPath2d(){return this.isSplined&&this.splineGeo?this.splineGeo.getPoints(64).map(t=>new L(t.x,t.y)):this._vertices.map(t=>new L(t.x,t.y))}transformVector(t,e){const i=new b,r=new b(t.x,t.y,t.z);i.applyMatrix4(e),r.applyMatrix4(e),t.set(r.x-i.x,r.y-i.y,r.z-i.z)}};Sa.typeName="Leader";let jn=Sa;const br=class br extends _t{constructor(t,e){super(),this._normal=new w(0,0,1),this._thickness=0,this._geo=new ge(t,e)}get dxfTypeName(){return"LINE"}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 thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}get midPoint(){return this._geo.midPoint}get geometricExtents(){return this._geo.box}get closed(){return!1}get area(){return 0}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}subMoveGripPointsAt(t,e){return ht(t,i=>{switch(i){case 0:this.transformBy(D.makeTranslation(e));break;case 1:this.startPoint.add(e);break;case 2:this.endPoint.add(e);break}}),this}subGetOsnapPoints(t,e,i,r){const s=this.startPoint,a=this.endPoint;switch(t){case A.EndPoint:r.push(s),r.push(a);break;case A.MidPoint:r.push(this.midPoint);break;case A.Nearest:{const o=this._geo.project(e);r.push(o)}break;case A.Perpendicular:{const o=this._geo.perpPoint(e);r.push(o)}break;case A.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){super.dxfOutFields(t),t.writeSubclassMarker("AcDbLine"),this.thickness!==0&&t.writeDouble(39,this.thickness);const e=Lt(this.startPoint,this.normal),i=Lt(this.endPoint,this.normal);return t.writePoint3d(10,e),t.writePoint3d(11,i),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbLine");let e=this.startPoint.x,i=this.startPoint.y,r=this.startPoint.z,s=this.endPoint.x,a=this.endPoint.y,o=this.endPoint.z,c=this.thickness,l=this.normal.x,h=this.normal.y,u=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const g=t.readItem();if(!g)break;const p=Number(g.code),f=Number(g.value);switch(p){case 10:e=f;break;case 20:i=f;break;case 30:r=f;break;case 11:s=f;break;case 21:a=f;break;case 31:o=f;break;case 39:c=f;break;case 210:l=f;break;case 220:h=f;break;case 230:u=f;break}}const d=new w(l,h,u);return d.lengthSq()>0&&this.normal.copy(d.normalize()),this.thickness=c,this.startPoint=de({x:e,y:i,z:r},this.normal),this.endPoint=de({x:s,y:a,z:o},this.normal),this}getOffsetCurves(t){const e=this._geo.offset(t);return[new br(e.startPoint,e.endPoint)]}getOffsetSideAtPoint(t){const e=this.startPoint,i=this.endPoint;return(i.x-e.x)*(t.y-e.y)-(i.y-e.y)*(t.x-e.x)>=0?1:-1}};br.typeName="Line";let Gi=br;var Zh=(n=>(n[n.Top=0]="Top",n[n.Zero=1]="Zero",n[n.Bottom=2]="Bottom",n))(Zh||{}),Qh=(n=>(n[n.HasVertex=1]="HasVertex",n[n.Closed=2]="Closed",n[n.SuppressStartCaps=4]="SuppressStartCaps",n[n.SuppressEndCaps=8]="SuppressEndCaps",n))(Qh||{});const Pa=class Pa extends H{get dxfTypeName(){return"MLINE"}constructor(){super(),this._styleName="",this._styleObjectHandle="",this._scale=1,this._justification=1,this._flags=0,this._styleCount=0,this._startPosition=new b,this._normal=new w(0,0,1),this._segments=[]}get styleName(){return this._styleName||this.getDefaultStyleName()}set styleName(t){this._styleName=t}get styleObjectHandle(){return this._styleObjectHandle}set styleObjectHandle(t){this._styleObjectHandle=t}get scale(){return this._scale}set scale(t){this._scale=t}get justification(){return this._justification}set justification(t){this._justification=t}get flags(){return this._flags}set flags(t){this._flags=t}get styleCount(){return this._styleCount}set styleCount(t){this._styleCount=Math.max(0,t)}get startPosition(){return this._startPosition}set startPosition(t){this._startPosition.copy(t)}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get segments(){return this._segments.map(t=>this.cloneSegment(t))}set segments(t){this._segments=t.map(e=>this.createSegment(e)),this.updateHasVertexFlag()}get vertexCount(){return this._segments.length}get closed(){return(this._flags&2)!==0}set closed(t){this.setFlag(2,t)}get suppressStartCaps(){return(this._flags&4)!==0}set suppressStartCaps(t){this.setFlag(4,t)}get suppressEndCaps(){return(this._flags&8)!==0}set suppressEndCaps(t){this.setFlag(8,t)}appendSegment(t){this._segments.push(this.createSegment(t)),this.updateHasVertexFlag()}clearSegments(){this._segments=[],this.updateHasVertexFlag()}get geometricExtents(){const t=this.collectGeometryPoints();return new Y().setFromPoints(t)}transformBy(t){return this._startPosition.applyMatrix4(t),this._segments.forEach(e=>{e.position.applyMatrix4(t),this.transformVector(e.direction,t),this.transformVector(e.miterDirection,t)}),this.transformVector(this._normal,t),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"mline",properties:[{name:"styleName",type:"string",editable:!0,accessor:{get:()=>this.styleName,set:t=>{this.styleName=t}}},{name:"scale",type:"float",editable:!0,accessor:{get:()=>this.scale,set:t=>{this.scale=t}}},{name:"justification",type:"int",editable:!0,accessor:{get:()=>this.justification,set:t=>{this.justification=t}}},{name:"closed",type:"boolean",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}},{name:"vertexCount",type:"int",editable:!1,accessor:{get:()=>this.vertexCount}}]}]}}subGetGripPoints(){const t=new Array;return t.push(this._startPosition.clone()),this._segments.forEach(e=>t.push(e.position.clone())),t}subMoveGripPointsAt(t,e){const i=[this._startPosition,...this._segments.map(r=>r.position)];return hi(t,e,i),ht(t,r=>{this.updateReferencePathDirectionsAfterGripMove(r)}),this}subGetOsnapPoints(t,e,i,r){const s=[this._startPosition,...this._segments.map(a=>a.position)];if(s.length!==0)switch(t){case A.EndPoint:r.push(...s);break;case A.MidPoint:case A.Nearest:case A.Perpendicular:{const a=[];for(let o=0;o<s.length-1;o++){const c=[];ui(s[o],s[o+1],t,e,c),a.push(...c)}if(t===A.MidPoint)r.push(...a);else{const o=Ft(e,a);o&&r.push(o)}break}}}subWorldDraw(t){if(this._segments.length===0)return;const e=[],i=this.getMLineStyle(),r=this.getRenderableElementCount(i),s=t.subEntityTraits,a=s.color,o=s.lineType,c=s.fillType,l=s.drawOrder,h=this.createFillArea(i,r);if(h&&(s.color=a,this.applyFillTraits(i,s),s.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},s.drawOrder=-1,e.push(t.area(h)),s.fillType=c,s.drawOrder=l),r<=0){const u=this.getReferencePath();u.length>=2&&e.push(t.lines(u))}else{for(let u=0;u<r;u++){s.color=a,s.lineType=o,this.applyStyleElementTraits(i,u,s);const d=this.getElementPath(u,i);d.length>=2&&e.push(t.lines(d))}this.appendStyleDrivenJointAndCapEntities(t,e,i,r,a,o)}if(s.color=a,s.lineType=o,s.fillType=c,s.drawOrder=l,e.length!==0)return e.length===1?e[0]:t.group(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbMline"),t.writeString(2,this.styleName),t.writeHandle(340,this._styleObjectHandle),t.writeDouble(40,this._scale),t.writeInt16(70,this._justification),t.writeInt16(71,this._flags),t.writeInt16(72,this.vertexCount),t.writeInt16(73,this._styleCount),t.writePoint3d(10,this._startPosition),t.writeVector3d(210,this._normal),this._segments.forEach(e=>{t.writePoint3d(11,e.position),t.writeVector3d(12,e.direction),t.writeVector3d(13,e.miterDirection),e.elements.forEach(i=>{t.writeInt16(74,i.parameterCount),i.parameters.forEach(r=>t.writeDouble(41,r)),t.writeInt16(75,i.fillCount),i.fillParameters.forEach(r=>t.writeDouble(42,r))})}),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbMline");let e=this._startPosition.x,i=this._startPosition.y,r=this._startPosition.z,s=this._normal.x,a=this._normal.y,o=this._normal.z;const c=[];let l=null,h=null,u=!1,d=!1,g=0,p=0;const f=()=>{h&&l&&l.elements.push(h),h=null,u=!1,d=!1,g=0,p=0},m=()=>{f(),l&&c.push(l),l=null};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const y=t.readItem();if(!y)break;const _=Number(y.code),v=Number(y.value);switch(_){case 2:this.styleName=String(y.value);break;case 340:this.styleObjectHandle=String(y.value);break;case 40:this.scale=v;break;case 70:this.justification=v;break;case 71:this.flags=v;break;case 72:break;case 73:this.styleCount=v;break;case 10:e=v;break;case 20:i=v;break;case 30:r=v;break;case 210:s=v;break;case 220:a=v;break;case 230:o=v;break;case 11:m(),l={position:new b(v,0,0),direction:new w(1,0,0),miterDirection:new w(0,1,0),elements:[]};break;case 21:l&&(l.position.y=v);break;case 31:l&&(l.position.z=v);break;case 12:l&&(l.direction.x=v);break;case 22:l&&(l.direction.y=v);break;case 32:l&&(l.direction.z=v);break;case 13:l&&(l.miterDirection.x=v);break;case 23:l&&(l.miterDirection.y=v);break;case 33:l&&(l.miterDirection.z=v);break;case 74:f(),g=v,u=!0,d=!1,h={parameterCount:v,parameters:[],fillCount:0,fillParameters:[]};break;case 41:h&&u&&(h.parameters.push(v),g>0&&h.parameters.length>=g&&(u=!1));break;case 75:h&&(p=v,h.fillCount=v,d=!0,u=!1);break;case 42:h&&d&&(h.fillParameters.push(v),p>0&&h.fillParameters.length>=p&&(d=!1));break}}return m(),this.startPosition=new b(e,i,r),this.normal=new w(s,a,o),this.segments=c,this}setFlag(t,e){e?this._flags|=t:this._flags&=~t}updateHasVertexFlag(){this.setFlag(1,this._segments.length>0)}updateReferencePathDirectionsAfterGripMove(t){const e=r=>{const s=this._segments[r];if(!s)return;const a=r===0?this._startPosition:this._segments[r-1].position,o=new w().subVectors(s.position,a);o.lengthSq()>0&&s.direction.copy(o.normalize())};if(t===0){this._segments.length>0&&e(0);return}const i=t-1;i<0||i>=this._segments.length||(e(i),i+1<this._segments.length&&e(i+1))}createSegment(t){var e;return{position:new b().copy(t.position),direction:new w().copy(t.direction),miterDirection:new w().copy(t.miterDirection),elements:((e=t.elements)==null?void 0:e.map(i=>this.createElement(i)))??[]}}createElement(t){const e=t.parameters?[...t.parameters]:[],i=t.fillParameters?[...t.fillParameters]:[];return{parameterCount:t.parameterCount??e.length,parameters:e,fillCount:t.fillCount??i.length,fillParameters:i}}cloneSegment(t){return{position:t.position.clone(),direction:t.direction.clone(),miterDirection:t.miterDirection.clone(),elements:t.elements.map(e=>({parameterCount:e.parameterCount,parameters:[...e.parameters],fillCount:e.fillCount,fillParameters:[...e.fillParameters]}))}}collectGeometryPoints(){const t=[this._startPosition];if(this._segments.length===0)return t;const e=this.getMLineStyle(),i=this.getRenderableElementCount(e);if(i<=0)return this._segments.forEach(r=>t.push(r.position)),t;for(let r=0;r<i;r++)t.push(...this.getElementPath(r,e));return t}getRenderableElementCount(t){const e=(t==null?void 0:t.elementCount)??0;return Math.max(this._styleCount,e,...this._segments.map(i=>i.elements.length),0)}getReferencePath(){const t=[this._startPosition.clone(),...this._segments.map(e=>e.position.clone())];return this.closePathIfNeeded(t)}getElementPath(t,e){const i=[],r=this._segments[0];return i.push(this.getElementBoundaryPoint("start",r,t,e)),this._segments.forEach(s=>{i.push(this.offsetPoint(s.position,s.miterDirection,this.getElementMiterOffset(s,t,e)))}),i[i.length-1]=this.getElementBoundaryPoint("end",this._segments[this._segments.length-1],t,e),this.closePathIfNeeded(i)}getElementMiterOffset(t,e,i){var s;const r=t.elements[e];return(s=r==null?void 0:r.parameters)!=null&&s.length?r.parameters[0]:this.getStyleElementOffset(e,i)}getElementBoundaryPoint(t,e,i,r){const s=this.getElementMiterOffset(e,i,r),a=t==="start"?this._startPosition:e.position,o=this.offsetPoint(a,e.miterDirection,s);if(!this.shouldApplyCapCutAtSide(t,r))return o;const c=t==="start"?r==null?void 0:r.startAngle:r==null?void 0:r.endAngle,l=this.computeCapCutDistance(s,c,t);if(l===0)return o;const h=t==="start"?this.getStartSegmentDirection():this.getEndSegmentDirection();return h.lengthSq()===0?o:o.add(h.multiplyScalar(l))}shouldApplyCapCutAtSide(t,e){return!e||this.closed?!1:t==="start"?this.suppressStartCaps?!1:(e.flags&112)!==0:this.suppressEndCaps?!1:(e.flags&1792)!==0}computeCapCutDistance(t,e,i){const r=this.normalizeCapAngle(e),s=Math.tan(r);if(Math.abs(s)<1e-6)return 0;const a=t/s;return a}normalizeCapAngle(t){if(t==null||!Number.isFinite(t))return Math.PI/2;let e=t%180;return e<0&&(e+=180),(e<1||e>179)&&(e=90),e*Math.PI/180}getStartSegmentDirection(){const t=this._segments[0],e=new w;return t&&(e.subVectors(t.position,this._startPosition),e.lengthSq()===0&&e.copy(t.direction)),e.lengthSq()>0&&e.normalize(),e}getEndSegmentDirection(){const t=this._segments[this._segments.length-1];if(!t)return new w;const e=new w,i=this._segments.length>1?this._segments[this._segments.length-2].position:this._startPosition;return e.subVectors(t.position,i),e.lengthSq()===0&&e.copy(t.direction),e.lengthSq()>0&&e.normalize(),e}createFillArea(t,e){if(!t||(t.flags&1)===0||e<2)return;const i=this.getFillBoundaryElementIndices(e,t);if(!i)return;const r=this.getElementPath(i.outerIndex,t),s=this.getElementPath(i.innerIndex,t),a=this.stripClosingPoint(r),o=this.stripClosingPoint(s);if(a.length<2||o.length<2)return;const c=new Vt;if(this.closed){if(a.length<3||o.length<3)return;c.add(new q(a.map(l=>({x:l.x,y:l.y})),!0)),c.add(new q(o.map(l=>({x:l.x,y:l.y})),!0))}else{const l=[...a,...o.slice().reverse()].map(h=>({x:h.x,y:h.y}));if(l.length<3)return;c.add(new q(l,!0))}return c}getFillBoundaryElementIndices(t,e){let i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=-1,a=-1;for(let o=0;o<t;o++){const c=this.getElementReferenceOffset(o,e);c<i&&(i=c,s=o),c>r&&(r=c,a=o)}if(!(s<0||a<0||s===a))return{outerIndex:a,innerIndex:s}}getElementReferenceOffset(t,e){var r;const i=this._segments[0];if(i){const s=i.elements[t];if((r=s==null?void 0:s.parameters)!=null&&r.length)return s.parameters[0]}return this.getStyleElementOffset(t,e)}getStyleElementOffset(t,e){const i=e==null?void 0:e.elements[t];if(!i)return 0;const r=this.getStyleJustificationShift(e);return(i.offset+r)*this._scale}getStyleJustificationShift(t){const e=(t==null?void 0:t.elements)??[];if(e.length<=0)return 0;let i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;for(const s of e){const a=s.offset;a<i&&(i=a),a>r&&(r=a)}return this._justification===0?-r:this._justification===2?-i:0}stripClosingPoint(t){if(t.length<2)return t;const e=t[0],i=t[t.length-1],r=1e-9;return Math.abs(e.x-i.x)<=r&&Math.abs(e.y-i.y)<=r&&Math.abs(e.z-i.z)<=r?t.slice(0,-1):t}offsetPoint(t,e,i){if(i===0||e.lengthSq()===0)return t.clone();const r=e.clone().normalize().multiplyScalar(i);return t.clone().add(r)}closePathIfNeeded(t){if(!this.closed||t.length<2)return t;const e=t[0],i=t[t.length-1],r=1e-9;return Math.abs(e.x-i.x)<=r&&Math.abs(e.y-i.y)<=r&&Math.abs(e.z-i.z)<=r||t.push(e.clone()),t}appendStyleDrivenJointAndCapEntities(t,e,i,r,s,a){!i||r<2||(e.push(...this.drawMiterJointEntities(t,i,r,s,a)),e.push(...this.drawCapEntities(t,i,r,s,a)))}drawMiterJointEntities(t,e,i,r,s){if(this.closed||this._segments.length<2||(e.flags&2)===0)return[];const a=[],o=t.subEntityTraits;for(let c=0;c<this._segments.length-1;c++){const l=this._segments[c],h=Array.from({length:i},(u,d)=>{const g=this.getElementMiterOffset(l,d,e);return{elementIndex:d,offset:g,point:this.offsetPoint(l.position,l.miterDirection,g)}}).sort((u,d)=>d.offset-u.offset);for(let u=0;u<h.length-1;u++)this.applyElementDrawTraits(o,r,s,e,h[u].elementIndex),a.push(t.lines([h[u].point,h[u+1].point]))}return a}drawCapEntities(t,e,i,r,s){if(this.closed||this._segments.length<=0)return[];const a=[];return a.push(...this.drawCapEntitiesForSide(t,"start",e,i,r,s)),a.push(...this.drawCapEntitiesForSide(t,"end",e,i,r,s)),a}drawCapEntitiesForSide(t,e,i,r,s,a){if(e==="start"&&this.suppressStartCaps)return[];if(e==="end"&&this.suppressEndCaps)return[];const o=i.flags,c=e==="start",l=c?(o&16)!==0:(o&256)!==0,h=c?(o&64)!==0:(o&1024)!==0,u=c?(o&32)!==0:(o&512)!==0;if(!l&&!h&&!u)return[];const d=this.getCapElementPoints(e,r,i);if(d.length<2)return[];const g=[],p=t.subEntityTraits;if(l)for(let m=0;m<d.length-1;m++)this.applyElementDrawTraits(p,s,a,i,d[m].elementIndex),g.push(t.lines([d[m].point,d[m+1].point]));const f=c?this.getStartSegmentDirection().multiplyScalar(-1):this.getEndSegmentDirection().clone();if(h){const m=this.drawCapArcBetweenElements(t,e,d[0],d[d.length-1],f,p,s,a,i);m&&g.push(m)}if(u)for(let m=1;m<Math.floor(d.length/2);m++){const y=d[m],_=d[d.length-1-m];if(!y||!_||y===_)continue;const v=this.drawCapArcBetweenElements(t,e,y,_,f,p,s,a,i);v&&g.push(v)}return g}getCapElementPoints(t,e,i){const r=t==="start"?this._segments[0]:this._segments[this._segments.length-1];return r?Array.from({length:e},(s,a)=>({elementIndex:a,offset:this.getElementMiterOffset(r,a,i),point:this.getElementBoundaryPoint(t,r,a,i)})).sort((s,a)=>a.offset-s.offset):[]}drawCapArcBetweenElements(t,e,i,r,s,a,o,c,l){const h=e==="end"?r.point:i.point,u=e==="end"?i.point:r.point,d=h.distanceTo(u);if(d<=1e-9||s.lengthSq()===0)return;const p=h.clone().add(new w().subVectors(u,h).multiplyScalar(.5)).add(s.clone().normalize().multiplyScalar(d/2)),f=Zt.createByThreePoints(h,u,p);if(f)return this.applyElementDrawTraits(a,o,c,l,e==="end"?r.elementIndex:i.elementIndex),t.circularArc(f)}applyElementDrawTraits(t,e,i,r,s){t.color=e,t.lineType=i,this.applyStyleElementTraits(r,s,t)}transformVector(t,e){const i=new b,r=new b(t.x,t.y,t.z);i.applyMatrix4(e),r.applyMatrix4(e),t.set(r.x-i.x,r.y-i.y,r.z-i.z)}getMLineStyle(){var s;const t=this.database.objects.mlineStyle,e=this.styleObjectHandle?t.getIdAt(this.styleObjectHandle):void 0;if(e)return e;const i=this.styleName?t.getAt(this.styleName):void 0;if(i)return i;const r=(s=this.styleName)==null?void 0:s.toUpperCase();if(r)for(const[a,o]of t.entries()){const c=(o.styleName||a).toUpperCase();if(a.toUpperCase()===r||c===r)return o}}applyStyleElementTraits(t,e,i){const r=t==null?void 0:t.elements[e];if(!r)return;const s=this.resolveStyleElementLineType(r.lineType);s&&(i.lineType=s),!(r.color.isByBlock||r.color.isByLayer)&&(i.color=r.color.clone())}applyFillTraits(t,e){const i=t==null?void 0:t.fillColor;!i||i.isByBlock||i.isByLayer||(e.color=i.clone())}resolveStyleElementLineType(t){var l;const e=t==null?void 0:t.trim();if(!e)return;const i=e.toUpperCase(),r=lt.toUpperCase(),s=Jt.toUpperCase();let a="UserSpecified",o=e;if(i===r){a="ByLayer";const h=(l=this.database.tables.layerTable.getAt(this.layer))==null?void 0:l.linetype;o=h&&h.toUpperCase()!==r&&h.toUpperCase()!==s?h:ke}else i===s&&(a="ByBlock",o=ke);const c=this.database.tables.linetypeTable.getAt(o);return c?{type:a,...c.linetype}:{type:a,name:o,standardFlag:0,description:"",totalPatternLength:0}}resolveEffectiveProperties(){super.resolveEffectiveProperties(),this._styleName||(this._styleName=this.getDefaultStyleName())}getDefaultStyleName(){try{return this.database.cmlstyle||le}catch{return le}}};Pa.typeName="MLine";let Vn=Pa;function Jh(n,t){if(t.length<3)return;const e=n.subEntityTraits,i=e.fillType,r=e.transparency;e.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},e.transparency=new ot(0);const s=new Vt;s.add(new q(t,!0));const a=n.area(s);e.fillType=i,e.transparency=r;const o=n.lines(t);return a?o?n.group([a,o]):a:o}const jo=[208,207,17,224,161,177,26,225],Vo=128,Ms=8,rs=3*Ms,xn=2;function R0(n){if(!n||n.length<Vo)return;for(let l=0;l<jo.length;l++)if(n[Vo+l]!==jo[l])return;const t=new DataView(n.buffer,n.byteOffset,n.byteLength),e=l=>{const h=t.getFloat64(l,!0),u=t.getFloat64(l+Ms,!0),d=t.getFloat64(l+2*Ms,!0);if([h,u,d].every(Number.isFinite))return{x:h,y:u,z:d}},i=e(xn),r=e(xn+rs),s=e(xn+2*rs),a=e(xn+3*rs);if(!i||!r||!s||!a)return;const o=Math.abs(s.x-i.x),c=Math.abs(i.y-s.y);if(!(o<=0||c<=0))return{upperLeft:i,upperRight:r,lowerRight:s,lowerLeft:a}}const Os=[208,207,17,224,161,177,26,225],B0=2,F0=8,ss=128,D0=64*1024*1024;function Y0(n){if(!(n!=null&&n.length))return;const t=X0(n);return t||ti(n)}function X0(n){const t=Ui(n,Os);if(t<0)return;const e=n.subarray(t);let i;try{i=$0(e)}catch{return}const r=["CONTENTS","Package","Ole10Native","Ole10Native"];for(const s of r){const a=i.readStream(s);if(!(a!=null&&a.length))continue;const o=ti(a);if(o)return o}for(const s of i.entries()){if(s.type!=="stream"||!/olepres/i.test(s.name)&&!s.name.includes("OlePres"))continue;const a=i.readStream(s.name);if(!(a!=null&&a.length))continue;const o=z0(a);if(o)return o;const c=ti(a);if(c)return c}for(const s of i.entries()){if(s.type!=="stream")continue;const a=i.readStream(s.name);if(!(a!=null&&a.length))continue;const o=ti(a);if(o)return o}}function z0(n){if(n.length<28)return;const t=new DataView(n.buffer,n.byteOffset,n.byteLength);let e=0;const i=t.getUint32(e,!0);e+=4;let r=0;if(i===4294967295)r=t.getUint32(e,!0),e+=4;else{if(i===4294967294)return;if(i>0&&i<65535)e+=i;else return}if(e+4>n.length)return;const s=t.getUint32(e,!0);if(e+=4,s>4&&(e+=s-4),e+=24,e+4>n.length)return;const a=t.getUint32(e,!0);if(e+=4,a<=0||e+a>n.length)return;const o=n.subarray(e,e+a);return r===F0?eu(o):ti(o)}function ti(n){const t=j0(n);if(t)return t;const e=V0(n);if(e)return e;const i=G0(n);if(i)return i;const r=U0(n);if(r)return r;const s=H0(n);if(s)return s}function j0(n){for(let t=0;t<n.length-14;t++){if(n[t]!==66||n[t+1]!==77)continue;const e=new DataView(n.buffer,n.byteOffset+t,n.length-t),i=e.getUint32(2,!0);if(i<14||i>n.length-t)continue;const r=e.getUint32(10,!0);if(!(r<14||r>=i))return new Blob([n.subarray(t,t+i)],{type:"image/bmp"})}}function V0(n){const e=Ui(n,[137,80,78,71,13,10,26,10]);if(!(e<0)){for(let i=e+8;i+12<=n.length;i++)if(n[i+4]===73&&n[i+5]===69&&n[i+6]===78&&n[i+7]===68){const r=i+12;return new Blob([n.subarray(e,r)],{type:"image/png"})}return new Blob([n.subarray(e)],{type:"image/png"})}}function G0(n){const t=Ui(n,[255,216,255]);if(!(t<0)){for(let e=t+3;e+1<n.length;e++)if(n[e]===255&&n[e+1]===217)return new Blob([n.subarray(t,e+2)],{type:"image/jpeg"})}}function U0(n){const t=Ui(n,[71,73,70,56,55,97]),e=Ui(n,[71,73,70,56,57,97]),i=t>=0?t:e;if(!(i<0)){for(let r=i+6;r<n.length;r++)if(n[r]===59)return new Blob([n.subarray(i,r+1)],{type:"image/gif"});return new Blob([n.subarray(i)],{type:"image/gif"})}}function H0(n){for(let t=0;t+40<=n.length;t++){const e=new DataView(n.buffer,n.byteOffset+t,n.length-t),i=e.getUint32(0,!0);if(i!==40)continue;const r=e.getInt32(4,!0),s=e.getInt32(8,!0),a=e.getUint16(12,!0),o=e.getUint16(14,!0),c=e.getUint32(16,!0),l=e.getUint32(20,!0),h=e.getUint32(32,!0);if(r<=0||r>65536||s===0||Math.abs(s)>65536||a!==1||![1,4,8,16,24,32].includes(o)||c!==0&&c!==3)continue;const u=tu(i,o,c,h),d=Math.abs(s),g=r*o+31>>5<<2,p=l>0?l:g*d,f=u+p;if(!(f<=40||t+f>n.length))return eu(n.subarray(t,t+f))}}function tu(n,t,e,i){let r=0;return t>8&&e===3&&(r+=12),i>0?r+=i*4:t<=8&&(r+=(1<<t)*4),n+r}function eu(n){if(n.length<40)return;const e=new DataView(n.buffer,n.byteOffset,n.byteLength).getUint32(0,!0);if(e!==40&&e!==12)return;const i=14+n.length,r=new Uint8Array(14),s=new DataView(r.buffer);r[0]=66,r[1]=77,s.setUint32(2,i,!0),s.setUint32(10,14+W0(n),!0);const a=new Uint8Array(i);return a.set(r,0),a.set(n,14),new Blob([a],{type:"image/bmp"})}function W0(n){const t=new DataView(n.buffer,n.byteOffset,n.byteLength),e=t.getUint32(0,!0);if(e===12){const a=t.getUint16(10,!0),o=a<=8?1<<a:0;return e+o*3}const i=t.getUint16(14,!0),r=t.getUint32(16,!0),s=t.getUint32(32,!0);return tu(e,i,r,s)}function Ui(n,t){t:for(let e=0;e<=n.length-t.length;e++){for(let i=0;i<t.length;i++)if(n[e+i]!==t[i])continue t;return e}return-1}function $0(n){if(n.length<512)throw new Error("CFB too small");for(let I=0;I<Os.length;I++)if(n[I]!==Os[I])throw new Error("Not a CFB document");const t=new DataView(n.buffer,n.byteOffset,n.byteLength),i=1<<t.getUint16(30,!0);if(i!==512&&i!==4096)throw new Error("Unsupported CFB sector size");const r=t.getUint32(44,!0),s=t.getUint32(48,!0),a=t.getUint32(56,!0),o=t.getUint32(60,!0),c=t.getUint32(64,!0),l=t.getUint32(68,!0),h=t.getUint32(72,!0),u=[];for(let I=0;I<109;I++){const P=t.getUint32(76+I*4,!0);P<=4294967290&&u.push(P)}let d=l;for(let I=0;I<h&&d<=4294967290;I++){const P=(d+1)*i;if(P+i>n.length)break;const C=i/4-1;for(let T=0;T<C;T++){const R=t.getUint32(P+T*4,!0);R<=4294967290&&u.push(R)}d=t.getUint32(P+C*4,!0)}const g=[];for(let I=0;I<Math.min(r,u.length);I++){const C=(u[I]+1)*i;if(C+i>n.length)break;const T=i/4;for(let R=0;R<T;R++)g.push(t.getUint32(C+R*4,!0))}const p=wn(g,s,4096),f=vn(n,p,i),m=[],y=Math.floor(f.length/ss);for(let I=0;I<y;I++){const P=I*ss,C=new DataView(f.buffer,f.byteOffset+P,ss),T=C.getUint16(64,!0);if(T<2||T>64)continue;const R=Math.floor((T-2)/2);let N="";for(let W=0;W<R;W++)N+=String.fromCharCode(C.getUint16(W*2,!0));const O=C.getUint8(66),S=C.getUint32(116,!0),G=C.getUint32(120,!0),$=C.getUint32(124,!0),Q=$===0?G:G+$*4294967296;let et="unknown";O===5?et="root":O===1?et="storage":O===2&&(et="stream"),m.push({name:N,type:et,size:Q,startSector:S})}const _=m.find(I=>I.type==="root"),v=[];if(c>0&&o<=4294967290){const I=wn(g,o,c),P=vn(n,I,i),C=new DataView(P.buffer,P.byteOffset,P.byteLength);for(let T=0;T+4<=P.length;T+=4)v.push(C.getUint32(T,!0))}let x;if(_&&_.size>0){const I=wn(g,_.startSector,65536);x=vn(n,I,i).subarray(0,_.size)}return{entries:()=>m,readStream:I=>{const P=m.find(T=>T.type==="stream"&&(T.name===I||T.name.toLowerCase()===I.toLowerCase()));if(!P||P.size<=0||P.size>D0)return;if(P.size<a&&x&&v.length>0){const R=iu(v,P.startSector,65536),N=new Uint8Array(P.size);let O=0;for(const S of R){if(O>=P.size)break;const G=S*64,$=Math.min(G+64,x.length);if(G>=x.length)break;const Q=x.subarray(G,$);N.set(Q.subarray(0,Math.min(Q.length,P.size-O)),O),O+=Q.length}return N.subarray(0,Math.min(O,P.size))}const C=wn(g,P.startSector,65536);return vn(n,C,i).subarray(0,P.size)}}}function wn(n,t,e){return iu(n,t,e)}function iu(n,t,e){const i=[];let r=t;const s=new Set;for(;r<=4294967290&&i.length<e&&!(s.has(r)||(s.add(r),i.push(r),r>=n.length));)r=n[r];return i}function vn(n,t,e){const i=new Uint8Array(t.length*e);let r=0;for(const s of t){const a=(s+1)*e,o=Math.min(a+e,n.length);if(a>=n.length)break;i.set(n.subarray(a,o),r),r+=e}return i}const Ia=class Ia extends H{};Ia.typeName="Frame";let Gn=Ia;const Ea=class Ea extends Gn{constructor(){super(),this._oleVersion=0}get dxfTypeName(){return"OLEFRAME"}get oleVersion(){return this._oleVersion}set oleVersion(t){this._oleVersion=t}getOleObject(){return this._oleObject?new Uint8Array(this._oleObject):void 0}setOleObject(t){t==null?this._oleObject=void 0:this._oleObject=t instanceof ArrayBuffer?new Uint8Array(t.slice(0)):new Uint8Array(t),this.onOleObjectChanged()}loadOleObjectFromDxf(t,e){e!=null&&e.length?t!=null&&t>0&&t<e.length?this._oleObject=e.subarray(0,t):this._oleObject=new Uint8Array(e):this._oleObject=void 0,this.onOleObjectChanged()}get oleObjectData(){return this._oleObject}onOleObjectChanged(){}get geometricExtents(){return new Y}subWorldDraw(t){}dxfOutFields(t){var e;if(super.dxfOutFields(t),t.writeSubclassMarker("AcDbOleFrame"),t.writeInt16(70,this._oleVersion),(e=this._oleObject)!=null&&e.length){t.writeInt32(90,this._oleObject.length);let i=0;for(;i<this._oleObject.length;){const r=this._oleObject.subarray(i,i+127);t.writeString(310,Sr(r)),i+=127}}return t.writeString(1,"OLE"),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbOleFrame");const e=[];let i;const r=()=>{e.length>0&&this.loadOleObjectFromDxf(i,Ji(e))};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const s=t.readItem();if(!s)break;const a=Number(s.code),o=Number(s.value);switch(a){case 1:break;case 70:this.oleVersion=o;break;case 90:i=o;break;case 310:s.value instanceof Uint8Array?e.push(s.value):e.push(String(s.value));break}}return r(),this}};Ea.typeName="OleFrame";let Hi=Ea;var nu=(n=>(n[n.Link=1]="Link",n[n.Embedded=2]="Embedded",n[n.Static=3]="Static",n))(nu||{}),ru=(n=>(n[n.ModelSpace=0]="ModelSpace",n[n.PaperSpace=1]="PaperSpace",n))(ru||{});const La=class La extends Hi{constructor(){super(),this._upperLeft=new b,this._lowerRight=new b,this._rotation=0,this._scaleWidth=1,this._scaleHeight=1,this._lockAspect=!1,this._outputQuality=0,this._autoOutputQuality=0,this._oleObjectType=2,this._tileMode=0,this._userType="",this._linkName="",this._linkPath="",this._oleClientItem=null,this._imageResolved=!1}get dxfTypeName(){return"OLE2FRAME"}get upperLeftCorner(){return this._upperLeft}set upperLeftCorner(t){this._upperLeft.copy(t)}get lowerRightCorner(){return this._lowerRight}set lowerRightCorner(t){this._lowerRight.copy(t)}getLocation(t){return t?t.copy(this._upperLeft):this._upperLeft.clone()}setLocation(t){const e=t.x-this._upperLeft.x,i=t.y-this._upperLeft.y,r=(t.z??0)-this._upperLeft.z;this._upperLeft.copy(t),this._lowerRight.x+=e,this._lowerRight.y+=i,this._lowerRight.z+=r}position(){return{upperLeft:this._upperLeft.clone(),upperRight:this.cornerUpperRight(),lowerLeft:this.cornerLowerLeft(),lowerRight:this._lowerRight.clone()}}setPosition(t){this._upperLeft.copy(t.upperLeft),this._lowerRight.copy(t.lowerRight)}wcsWidth(){return Math.abs(this._lowerRight.x-this._upperLeft.x)}setWcsWidth(t){const e=this._lowerRight.x>=this._upperLeft.x?1:-1;this._lowerRight.x=this._upperLeft.x+e*Math.abs(t),this._lockAspect&&this.syncHeightFromAspect()}wcsHeight(){return Math.abs(this._upperLeft.y-this._lowerRight.y)}setWcsHeight(t){const e=this._upperLeft.y>=this._lowerRight.y?1:-1;this._lowerRight.y=this._upperLeft.y-e*Math.abs(t),this._lockAspect&&this.syncWidthFromAspect()}scaleWidth(){return this._scaleWidth}setScaleWidth(t){this._scaleWidth=t}scaleHeight(){return this._scaleHeight}setScaleHeight(t){this._scaleHeight=t}rotation(){return this._rotation}setRotation(t){this._rotation=t}lockAspect(){return this._lockAspect}setLockAspect(t){this._lockAspect=!!t}outputQuality(){return this._outputQuality}setOutputQuality(t){this._outputQuality=t&255}autoOutputQuality(){return this._autoOutputQuality}setAutoOutputQuality(t){this._autoOutputQuality=t&255}getType(){return this._oleObjectType}setType(t){this._oleObjectType=t}get oleObjectType(){return this._oleObjectType}set oleObjectType(t){this._oleObjectType=t}get tileMode(){return this._tileMode}set tileMode(t){this._tileMode=t}getUserType(){return this._userType}setUserType(t){this._userType=t}get userType(){return this._userType}set userType(t){this._userType=t}getLinkName(){return this._linkName}setLinkName(t){this._linkName=t}getLinkPath(){return this._linkPath}setLinkPath(t){this._linkPath=t}getOleClientItem(){return this._oleClientItem}setOleClientItem(t){this._oleClientItem=t??null}get geometricExtents(){return new Y().setFromPoints(this.boundaryPath())}subGetGripPoints(){return this.boundaryPath().slice(0,4)}subMoveGripPointsAt(t,e){const i=this.boundaryPath().slice(0,4);return hi(t,e,i),ht(t,r=>{r===0?this._upperLeft.copy(i[0]):r===2?this._lowerRight.copy(i[2]):r===1?(this._upperLeft.y=i[1].y,this._lowerRight.x=i[1].x,this._upperLeft.z=i[1].z,this._lowerRight.z=i[1].z):r===3&&(this._upperLeft.x=i[3].x,this._lowerRight.y=i[3].y,this._upperLeft.z=i[3].z,this._lowerRight.z=i[3].z)}),this}subGetOsnapPoints(t,e,i,r){if(t===A.Insertion){r.push(this._upperLeft.clone());return}const s=this.boundaryPath().slice(0,4);if(t===A.EndPoint){r.push(...s);return}Pr(s,!0,t,e,r)}transformBy(t){const e=this._lowerRight.x-this._upperLeft.x,i=this._upperLeft.y-this._lowerRight.y,r=Math.cos(this._rotation),s=Math.sin(this._rotation),a=this._upperLeft.clone(),o=a.clone().add(new w(e*r,e*s,0)),c=a.clone().add(new w(i*s,-i*r,0));a.applyMatrix4(t),o.applyMatrix4(t),c.applyMatrix4(t);const l=new w().subVectors(o,a),h=new w().subVectors(c,a);return this._upperLeft.copy(a),this._rotation=Math.atan2(l.y,l.x),this._lowerRight.set(a.x+l.length(),a.y-h.length(),a.z),this}get image(){return this.resolveImage()}subWorldDraw(t){const e=this.resolveImage(),i=this.imageBoundaryPath();return e?t.image(e,{boundary:i,roation:this._rotation}):Jh(t,this.boundaryPath())}onOleObjectChanged(){this._image=void 0,this._imageResolved=!1,this.applyGeometryFromOleObjectData()}applyGeometryFromOleObjectData(){const t=R0(this.oleObjectData);t&&(this._upperLeft.copy(t.upperLeft),this._lowerRight.copy(t.lowerRight))}resolveImage(){return this._imageResolved?this._image:(this._imageResolved=!0,this._image=Y0(this.oleObjectData),this._image)}imageBoundaryPath(){const t=this.boundaryPath(),e=[t[3],t[2],t[1],t[0]];return e.push(e[0].clone()),e}dxfOutFields(t){H.prototype.dxfOutFields.call(this,t),t.writeSubclassMarker("AcDbOle2Frame"),t.writeInt16(70,this.oleVersion),this._userType&&t.writeString(3,this._userType),t.writePoint3d(10,this._upperLeft),t.writePoint3d(11,this._lowerRight),t.writeInt16(71,this._oleObjectType),t.writeInt16(72,this._tileMode),this._outputQuality&&t.writeInt16(73,this._outputQuality);const e=this.getOleObject();if(e!=null&&e.length){t.writeInt32(90,e.length);let i=0;for(;i<e.length;){const r=e.subarray(i,i+127);t.writeString(310,Sr(r)),i+=127}}return t.writeString(1,"OLE"),this}dxfInFields(t){H.prototype.dxfInFields.call(this,t),t.atSubclassData("AcDbOle2Frame");let e=this._upperLeft.x,i=this._upperLeft.y,r=this._upperLeft.z,s=this._lowerRight.x,a=this._lowerRight.y,o=this._lowerRight.z;const c=[];let l;const h=()=>{this.upperLeftCorner=new b(e,i,r),this.lowerRightCorner=new b(s,a,o),c.length>0&&this.loadOleObjectFromDxf(l,Ji(c))};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const u=t.readItem();if(!u)break;const d=Number(u.code),g=Number(u.value);switch(d){case 1:break;case 3:this.userType=String(u.value);break;case 10:e=g;break;case 20:i=g;break;case 30:r=g;break;case 11:s=g;break;case 21:a=g;break;case 31:o=g;break;case 70:this.oleVersion=g;break;case 71:this.oleObjectType=g;break;case 72:this.tileMode=g;break;case 73:this.setOutputQuality(g);break;case 90:l=g;break;case 310:u.value instanceof Uint8Array?c.push(u.value):c.push(String(u.value));break}}return h(),this}cornerUpperRight(){return new b(this._lowerRight.x,this._upperLeft.y,this._upperLeft.z)}cornerLowerLeft(){return new b(this._upperLeft.x,this._lowerRight.y,this._lowerRight.z)}boundaryPath(){const t=[this._upperLeft.clone(),this.cornerUpperRight(),this._lowerRight.clone(),this.cornerLowerLeft()];if(this._rotation!==0){const e=this._upperLeft;for(let i=1;i<t.length;i++)t[i].sub(e).applyMatrix4(new D().makeRotationZ(this._rotation)),t[i].add(e)}return t.push(t[0].clone()),t}syncHeightFromAspect(){const t=this.wcsWidth();if(t===0||this._scaleWidth===0)return;const e=this._scaleHeight/this._scaleWidth,i=t*e,r=this._upperLeft.y>=this._lowerRight.y?1:-1;this._lowerRight.y=this._upperLeft.y-r*Math.abs(i)}syncWidthFromAspect(){const t=this.wcsHeight();if(t===0||this._scaleHeight===0)return;const e=this._scaleWidth/this._scaleHeight,i=t*e,r=this._lowerRight.x>=this._upperLeft.x?1:-1;this._lowerRight.x=this._upperLeft.x+r*Math.abs(i)}};La.typeName="Ole2Frame";let Un=La;const Ta=class Ta extends H{constructor(){super(),this._thickness=0,this._normal=new w(0,0,1),this._ecsRotation=0,this._geo=new b}get dxfTypeName(){return"POINT"}get position(){return this._geo}set position(t){this._geo.set(t.x,t.y,t.z||0)}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get ecsRotation(){return this._ecsRotation}set ecsRotation(t){this._ecsRotation=t}get geometricExtents(){return new Y().expandByPoint(this._geo)}subGetGripPoints(){return[this._geo]}subMoveGripPointsAt(t,e){return ie(t,e,this._geo),this}subGetOsnapPoints(t,e,i,r){t===A.Node&&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"),this.thickness!==0&&t.writeDouble(39,this.thickness),t.writePoint3d(10,Lt(this.position,this.normal)),this.ecsRotation!==0&&t.writeAngle(50,this.ecsRotation),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbPoint");let e=this.position.x,i=this.position.y,r=this.position.z,s=this.thickness,a=this.ecsRotation*180/Math.PI,o=this.normal.x,c=this.normal.y,l=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const u=t.readItem();if(!u)break;const d=Number(u.code),g=Number(u.value);switch(d){case 10:e=g;break;case 20:i=g;break;case 30:r=g;break;case 39:s=g;break;case 50:a=g;break;case 210:o=g;break;case 220:c=g;break;case 230:l=g;break}}const h=new w(o,c,l);return h.lengthSq()>0&&this.normal.copy(h.normalize()),this.thickness=s,this.ecsRotation=a*Math.PI/180,this.position=de({x:e,y:i,z:r},this.normal),this}};Ta.typeName="Point";let Hn=Ta;const Ca=class Ca extends H{constructor(){super(...arguments),this._originalDxfName="",this._originalClassName="",this._applicationName="",this._proxyEntityClassId=498,this._applicationEntityClassId=0,this._objectDrawingFormat=0,this._originalDataFormat=0,this._entityOrigins=[],this._worldTransform=new D}get dxfTypeName(){return"ACAD_PROXY_ENTITY"}get originalDxfName(){return this._originalDxfName}set originalDxfName(t){this._originalDxfName=t}get originalClassName(){return this._originalClassName}set originalClassName(t){this._originalClassName=t}get applicationName(){return this._applicationName}set applicationName(t){this._applicationName=t}get proxyEntityClassId(){return this._proxyEntityClassId}set proxyEntityClassId(t){this._proxyEntityClassId=t}get applicationEntityClassId(){return this._applicationEntityClassId}set applicationEntityClassId(t){this._applicationEntityClassId=t}get objectDrawingFormat(){return this._objectDrawingFormat}set objectDrawingFormat(t){this._objectDrawingFormat=t}get graphicsMetafileType(){return this._objectDrawingFormat}set graphicsMetafileType(t){this._objectDrawingFormat=t}get originalDataFormat(){return this._originalDataFormat}set originalDataFormat(t){this._originalDataFormat=t}get proxyGraphic(){return this._proxyGraphic}setProxyGraphic(t){this._proxyGraphic=t?new Uint8Array(t):void 0}get entityOrigins(){return this._entityOrigins}setEntityOrigins(t){this._entityOrigins=t.map(e=>new b(e.x,e.y,e.z))}get geometricExtents(){const t=this._proxyGraphic;if(!(t!=null&&t.length))return new Y;const i=new Ps(t,{database:this.database,defaultLayer:this.layer}).scanExtents();if(i){const r=new Y().setFromPoints(i);return this._worldTransform.equals(new D)||r.applyMatrix4(this._worldTransform),r}return new Y}subGetGripPoints(){if(this._entityOrigins.length>0)return[...this._entityOrigins];const t=this.geometricExtents;return t.isEmpty()?[]:[new b(t.min.x,t.min.y,t.min.z),new b(t.max.x,t.max.y,t.max.z)]}subMoveGripPointsAt(t,e){return this._entityOrigins.length>0?(hi(t,e,this._entityOrigins),this):this.geometricExtents.isEmpty()?this:(ht(t,r=>{r===0&&this.transformBy(D.makeTranslation(e))}),this)}transformBy(t){return this._entityOrigins.forEach(e=>e.applyMatrix4(t)),this._worldTransform.premultiply(t),this}subWorldDraw(t){const e=this._proxyGraphic;if(!(e!=null&&e.length))return;const r=new Ps(e,{database:this.database,defaultLayer:this.layer}).worldDraw(t);return r&&!this._worldTransform.equals(new D)&&r.applyMatrix(this._worldTransform),r}dxfOutFields(t){var e;if(super.dxfOutFields(t),t.writeSubclassMarker("AcDbProxyEntity"),this._originalDxfName&&t.writeString(1,this._originalDxfName),this._originalClassName&&t.writeString(3,this._originalClassName),t.writeInt32(90,this._proxyEntityClassId||498),this._applicationEntityClassId&&t.writeInt32(91,this._applicationEntityClassId),this._objectDrawingFormat&&t.writeInt32(95,this._objectDrawingFormat),t.writeInt16(70,this._originalDataFormat),(e=this._proxyGraphic)!=null&&e.length){t.writeInt32(160,this._proxyGraphic.length);let i=0;for(;i<this._proxyGraphic.length;){const r=this._proxyGraphic.subarray(i,i+127);t.writeString(310,Sr(r)),i+=127}}return this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbProxyEntity");const e=[];let i;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const r=t.readItem();if(!r)break;const s=Number(r.code),a=Number(r.value);switch(s){case 1:this.originalDxfName=String(r.value);break;case 3:this.originalClassName=String(r.value);break;case 70:this.originalDataFormat=a;break;case 90:this.proxyEntityClassId=a;break;case 91:this.applicationEntityClassId=a;break;case 95:this.objectDrawingFormat=a;break;case 160:i=a;break;case 310:r.value instanceof Uint8Array?e.push(r.value):e.push(String(r.value));break}}return e.length>0&&this.loadProxyGraphicFromDxf(i,e),this}loadProxyGraphicFromDxf(t,e){const i=Yp(t,e);i&&this.setProxyGraphic(i)}};Ca.typeName="ProxyEntity";let Wn=Ca;var su=(n=>(n[n.Invalid=0]="Invalid",n[n.Rect=1]="Rect",n[n.Poly=2]="Poly",n))(su||{}),au=(n=>(n[n.Show=1]="Show",n[n.ShowUnAligned=2]="ShowUnAligned",n[n.Clip=4]="Clip",n[n.Transparent=8]="Transparent",n))(au||{});const Ma=class Ma extends H{constructor(){super(),this._classVersion=0,this._clipMode=0,this._brightness=50,this._contrast=50,this._fade=0,this._width=0,this._height=0,this._position=new b,this._scale=new nt(1,1),this._rotation=0,this._imageSize=new L,this._clipBoundaryType=1,this._clipBoundary=[],this._isClipped=!1,this._isShownClipped=!1,this._isImageShown=!0,this._isImageTransparent=!1,this._imageDefId=""}get dxfTypeName(){return"IMAGE"}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 classVersion(){return this._classVersion}set classVersion(t){this._classVersion=t}get clipMode(){return this._clipMode}set clipMode(t){this._clipMode=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 Y;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()}subMoveGripPointsAt(t,e){return ht(t,i=>{this.isClipped&&this._clipBoundary.length>3?this.moveClippedBoundaryGripAt(i,e):this.moveUnclippedGripAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){if(t===A.Insertion){r.push(this._position);return}const s=this.boundaryPath();if(s.length===0)return;let a=s;if(s.length>1){const o=s[0],c=s[s.length-1];o.x===c.x&&o.y===c.y&&(o.z||0)===(c.z||0)&&(a=s.slice(0,-1))}if(t===A.EndPoint){r.push(...a);return}Pr(a,!0,t,e,r)}subWorldDraw(t){const e=this.boundaryPath();return this._image&&this.isImageShown?t.image(this._image,{boundary:e,roation:this._rotation}):Jh(t,e)}transformBy(t){const e=this._width*this._scale.x,i=this._height*this._scale.y,r=new w(e*Math.cos(this._rotation),e*Math.sin(this._rotation),0),s=new w(-i*Math.sin(this._rotation),i*Math.cos(this._rotation),0),a=this._position.clone(),o=this._position.clone().add(r),c=this._position.clone().add(s);a.applyMatrix4(t),o.applyMatrix4(t),c.applyMatrix4(t);const l=new w(o).sub(a),h=new w(c).sub(a);return this._position.copy(a),this._rotation=Math.atan2(l.y,l.x),this._width=l.length(),this._height=h.length(),this._scale.set(1,1),this}moveUnclippedGripAt(t,e){const i=this._position.x,r=this._position.y,s=this._width,a=this._height;switch(t){case 0:this._position.add(e);break;case 1:{const o=i,c=r+a,l=i+s+e.x,h=r+e.y;this._position.x=o,this._position.y=h,this._width=l-o,this._height=c-h;break}case 2:{const o=i+s+e.x,c=r+a+e.y;this._width=o-i,this._height=c-r;break}case 3:{const o=i+s,c=r,l=i+e.x,h=r+a+e.y;this._position.x=l,this._position.y=c,this._width=o-l,this._height=h-c;break}}}moveClippedBoundaryGripAt(t,e){if(t<0||t>=this._clipBoundary.length)return;const i=this._width,r=this._height,s=new yt;s.setFromPoints(this._clipBoundary);const a=new L;a.setX(this._position.x-s.min.x*i),a.setY(this._position.y-s.min.y*r);const o=this._clipBoundary[t],c=o.x*i+a.x+e.x,l=o.y*r+a.y+e.y;o.x=(c-a.x)/i,o.y=(l-a.y)/r}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,i=this._height,r=new yt;r.setFromPoints(this._clipBoundary);const s=new L;s.setX(this._position.x-r.min.x*e),s.setY(this._position.y-r.min.y*i),this._clipBoundary.forEach(a=>{const o=a.x*e+s.x,c=a.y*i+s.y;t.push(new b(o,c,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){Go.copy(t[1]);for(let e=1;e<4;e++)kn.copy(t[e]),kn.rotateAround(Go,this._rotation),t[e].setX(kn.x),t[e].setY(kn.y)}t.push(t[0])}return t}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbRasterImage"),t.writeInt32(90,this.classVersion),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},s=r.x>0?e/r.x:e,a=r.y>0?i/r.y:i,o=Math.cos(this._rotation),c=Math.sin(this._rotation);t.writePoint3d(11,{x:s*o,y:s*c,z:0}),t.writePoint3d(12,{x:-a*c,y:a*o,z:0}),t.writePoint2d(13,r),t.writeObjectId(340,this.imageDefId);const l=(this.isImageShown?1:0)|(this.isShownClipped?4:0)|(this.isImageTransparent?8:0);if(t.writeInt16(70,l),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 h of this.clipBoundary)t.writePoint2d(14,h)}return t.writeInt16(290,this.clipMode),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbRasterImage");let e=this.position.x,i=this.position.y,r=this.position.z,s=1,a=0,o=0,c=0,l=1,h=0,u=this.imageSize.x,d=this.imageSize.y;const g=[];let p=null;const f=()=>{p&&(g.push(new L(p.x,p.y)),p=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const m=t.readItem();if(!m)break;const y=Number(m.code),_=Number(m.value);switch(y){case 10:e=_;break;case 20:i=_;break;case 30:r=_;break;case 11:s=_;break;case 21:a=_;break;case 31:o=_;break;case 12:c=_;break;case 22:l=_;break;case 32:h=_;break;case 13:u=_;break;case 23:d=_;break;case 14:f(),p={x:_,y:0};break;case 24:p&&(p.y=_);break;case 70:{this.isImageShown=(_&3)!==0,this.isShownClipped=(_&4)!==0,this.isImageTransparent=(_&8)!==0;break}case 71:this.clipBoundaryType=_;break;case 90:this.classVersion=_;break;case 91:break;case 280:this.isClipped=_!==0;break;case 281:this.brightness=_;break;case 282:this.contrast=_;break;case 283:this.fade=_;break;case 290:this.clipMode=_;break;case 340:this.imageDefId=String(m.value);break}}return f(),this.applyRasterImageDxfIn(e,i,r,s,a,o,c,l,h,u,d,g),this}applyRasterImageDxfIn(t,e,i,r,s,a,o,c,l,h,u,d){this.position.copy({x:t,y:e,z:i}),this.imageSize.copy({x:h,y:u});const g=Math.hypot(r,s,a),p=Math.hypot(o,c,l);this.width=g*(h||1),this.height=p*(u||1),this.rotation=Math.atan2(s,r),d.length>0&&(this.clipBoundary=d)}};Ma.typeName="RasterImage";let Wi=Ma;const Go=new L,kn=new L,_r=class _r extends _t{get dxfTypeName(){return"RAY"}constructor(){super(),this._basePoint=new b,this._unitDir=new w}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 area(){return 0}get geometricExtents(){const t=new Y;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}subMoveGripPointsAt(t,e){return ie(t,e,this.basePoint),this}subGetOsnapPoints(t,e,i,r){const s=this.basePoint;if(t===A.EndPoint){r.push(s);return}const a=this.unitDir.clone();if(a.lengthSq()===0)return;a.normalize();const o=new ge(s,s.clone().add(a));switch(t){case A.Nearest:{const c=o.project(e),h=new w(c).sub(s).dot(a);r.push(h<0?s:c);break}case A.Perpendicular:r.push(o.perpPoint(e));break}}transformBy(t){return this._basePoint.applyMatrix4(t),this._unitDir.transformDirection(t),this}subWorldDraw(t){const e=[];return e.push(this.basePoint),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbRay"),t.writePoint3d(10,this.basePoint),t.writeVector3d(11,this.unitDir),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbRay");let e=this.basePoint.x,i=this.basePoint.y,r=this.basePoint.z,s=this.unitDir.x,a=this.unitDir.y,o=this.unitDir.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const c=t.readItem();if(!c)break;const l=Number(c.code),h=Number(c.value);switch(l){case 10:e=h;break;case 20:i=h;break;case 30:r=h;break;case 11:s=h;break;case 21:a=h;break;case 31:o=h;break}}return this.basePoint=new b(e,i,r),this.unitDir=new w(s,a,o),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.basePoint,i=this.unitDir,r=Math.hypot(i.x,i.y);return r<=1e-9||(i.x*(t.y-e.y)-i.y*(t.x-e.x))/r>=0?1:-1}createOffsetCurve(t){const e=Dc(this.basePoint,this.unitDir,t);if(!e)return null;const i=new _r;return i.basePoint=e,i.unitDir=this.unitDir.clone(),i}};_r.typeName="Ray";let $n=_r;const Oa=class Oa extends H{get dxfTypeName(){return"SHAPE"}constructor(){super(),this._position=new b,this._size=1,this._name="",this._rotation=0,this._widthFactor=1,this._oblique=0,this._thickness=0,this._normal=new w(0,0,1),this._shapeNumber=0,this._styleName=""}get position(){return this._position}set position(t){this._position.copy(t)}get size(){return this._size}set size(t){this._size=t}get name(){return this._name}set name(t){this._name=t}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get widthFactor(){return this._widthFactor}set widthFactor(t){this._widthFactor=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}get shapeNumber(){return this._shapeNumber}set shapeNumber(t){this._shapeNumber=t}get styleId(){var e,i,r;const t=(r=(i=(e=this.database)==null?void 0:e.tables)==null?void 0:i.textStyleTable)==null?void 0:r.resolveAt(this._styleName);return(t==null?void 0:t.objectId)??""}set styleId(t){var i,r,s;const e=(s=(r=(i=this.database)==null?void 0:i.tables)==null?void 0:r.textStyleTable)==null?void 0:s.getIdAt(t);e&&(this._styleName=e.name)}get styleName(){return this._styleName}set styleName(t){this._styleName=t}get isPlanar(){return!0}get geometricExtents(){const t=Math.abs(this._size)/2,e=new Y;return e.expandByPoint(this._position),t>0&&(e.expandByPoint(new b(this._position.x-t,this._position.y-t,this._position.z)),e.expandByPoint(new b(this._position.x+t,this._position.y+t,this._position.z))),e}subGetGripPoints(){return[this._position]}subMoveGripPointsAt(t,e){return ie(t,e,this._position),this}subGetOsnapPoints(t,e,i,r){t===A.Insertion&&r.push(this._position)}transformBy(t){const e=new D().setFromExtrusionDirection(this._normal),i=new D().makeRotationZ(this._rotation),r=new D().multiplyMatrices(e,i),s=this._position.clone(),a=new b(this._widthFactor,0,0).applyMatrix4(r).add(s),o=new b(0,1,0).applyMatrix4(r).add(s),c=new b(0,0,1).applyMatrix4(r).add(s);s.applyMatrix4(t),a.applyMatrix4(t),o.applyMatrix4(t),c.applyMatrix4(t);const l=new w(a).sub(s),h=new w(o).sub(s),u=new w(c).sub(s);let d=new w().crossVectors(l,h);d.lengthSq()===0?d=this._normal.clone().transformDirection(t):d.normalize();const p=new D().setFromExtrusionDirection(d).clone().invert(),f=l.clone().applyMatrix4(p),m=h.length(),y=l.length();this._position.copy(s),this._normal.copy(d),y>0&&(this._rotation=Math.atan2(f.y,f.x)),m>0&&(this._size*=m,y>0&&(this._widthFactor*=y/m));const _=u.length();return _>0&&(this._thickness*=_),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"shape",properties:[{name:"name",type:"string",editable:!0,accessor:{get:()=>this.name,set:t=>{this.name=t}}},{name:"size",type:"float",editable:!0,accessor:{get:()=>this.size,set:t=>{this.size=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}}},{name:"shapeNumber",type:"int",editable:!0,accessor:{get:()=>this.shapeNumber,set:t=>{this.shapeNumber=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}}}]}]}}subWorldDraw(t,e){const i=this.getTextStyle(),r=i?{...i,widthFactor:this.widthFactor,obliqueAngle:this.oblique*180/Math.PI}:void 0,s={...this.renderGlyphIdentity(),size:this.size,position:this._position,rotation:this._rotation,directionVector:this._normal,widthFactor:this.widthFactor};return t.shape(s,r,e)}renderGlyphIdentity(){const t=this._name.trim(),e=Number(t);return t!==""&&Number.isInteger(e)&&e!==0&&String(e)===t?{shapeNumber:e}:{name:t||void 0,shapeNumber:this._shapeNumber!==0?this._shapeNumber:void 0}}getTextStyle(){const t=this.styleName.trim();if(!t)return;const e=this.database.tables.textStyleTable.resolveAt(t);return e==null?void 0:e.textStyle}get dxfShapeIdentity(){const t=this._name.trim();return t||(this._shapeNumber!==0?String(this._shapeNumber):"")}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbShape"),t.writePoint3d(10,this.position),t.writeDouble(40,this.size);const e=this.dxfShapeIdentity;return e&&t.writeString(2,e),t.writeAngle(50,this.rotation),t.writeDouble(41,this.widthFactor),t.writeAngle(51,this.oblique),t.writeDouble(39,this.thickness),this._styleName&&t.writeString(3,this._styleName),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbShape");let e=this.position.x,i=this.position.y,r=this.position.z,s=this.normal.x,a=this.normal.y,o=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const c=t.readItem();if(!c)break;const l=Number(c.code),h=Number(c.value);switch(l){case 10:e=h;break;case 20:i=h;break;case 30:r=h;break;case 2:{const u=String(c.value).trim(),d=Number(u);u!==""&&Number.isInteger(d)&&d!==0&&String(d)===u?(this.shapeNumber=d,this.name=""):this.name=u;break}case 3:this.styleName=String(c.value);break;case 39:this.thickness=h;break;case 40:this.size=h;break;case 41:this.widthFactor=h;break;case 50:this.rotation=M.degToRad(h);break;case 51:this.oblique=M.degToRad(h);break;case 210:s=h;break;case 220:a=h;break;case 230:o=h;break}}return this.position={x:e,y:i,z:r},this.normal={x:s,y:a,z:o},this}};Oa.typeName="Shape";let qn=Oa;const Ke=class Ke extends _t{constructor(){super(),this._normal=new w(0,0,1),this._elevation=0,this._thickness=0,this._vertices=[new b,new b,new b,new b]}get dxfTypeName(){return"TRACE"}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return!0}get area(){return new q(Ke.boundaryPointsFromVertices(this._vertices),!0).area}get thickness(){return this._thickness}set thickness(t){this._thickness=t}get normal(){return this._normal}set normal(t){this._normal.copy(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 Y().setFromPoints(this._vertices)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subMoveGripPointsAt(t,e){return hi(t,e,this._vertices),this}subGetOsnapPoints(t,e,i,r){const s=[this._vertices[0],this._vertices[1],this._vertices[3],this._vertices[2]];Pr(s,!0,t,e,r)}transformBy(t){return this._vertices.forEach(e=>e.applyMatrix4(t)),this._elevation=this._vertices[0].z,this}subWorldDraw(t){const e=new q(Ke.boundaryPointsFromVertices(this._vertices),!0),i=new Vt;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"),this.thickness!==0&&t.writeDouble(39,this.thickness),t.writePoint3d(10,Lt(this.getPointAt(0),this.normal)),t.writePoint3d(11,Lt(this.getPointAt(1),this.normal)),t.writePoint3d(12,Lt(this.getPointAt(2),this.normal)),t.writePoint3d(13,Lt(this.getPointAt(3),this.normal)),t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbTrace");const e=[{x:this.getPointAt(0).x,y:this.getPointAt(0).y,z:this.getPointAt(0).z},{x:this.getPointAt(1).x,y:this.getPointAt(1).y,z:this.getPointAt(1).z},{x:this.getPointAt(2).x,y:this.getPointAt(2).y,z:this.getPointAt(2).z},{x:this.getPointAt(3).x,y:this.getPointAt(3).y,z:this.getPointAt(3).z}];let i=this.normal.x,r=this.normal.y,s=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const o=t.readItem();if(!o)break;const c=Number(o.code),l=Number(o.value);switch(c){case 10:case 11:case 12:case 13:e[c-10].x=l;break;case 20:case 21:case 22:case 23:e[c-20].y=l;break;case 30:case 31:case 32:case 33:e[c-30].z=l;break;case 39:this.thickness=l;break;case 210:i=l;break;case 220:r=l;break;case 230:s=l;break}}const a=new w(i,r,s);return a.lengthSq()>0&&this.normal.copy(a.normalize()),e.forEach((o,c)=>this.setPointAt(c,de(o,this.normal))),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectBoundary2d();return e.length<2?1:kt.from2dPoints(e,!0).getOffsetSideAtPoint(t)}createOffsetCurve(t){return Nr(this.collectBoundary2d(),!0,t)}collectBoundary2d(){return Ke.boundaryPointsFromVertices(this._vertices)}static boundaryPointsFromVertices(t){const e=t[0],i=t[1],r=t[2],s=t[3];return[new L(e.x,e.y),new L(i.x,i.y),new L(s.x,s.y),new L(r.x,r.y)]}};Ke.typeName="Trace";let $i=Ke;const Na=class Na extends $i{get dxfTypeName(){return"SOLID"}};Na.typeName="Solid";let Kn=Na;function q0(n){return n&2048?"SqrtChord":n&1024?"Chord":"Uniform"}function Uo(n,t){try{return new qi(n.controlPoints,n.knots,K0(n.weights,n.controlPoints.length),n.degree,t)}catch{return null}}function K0(n,t){if(!(!n||n.length!==t))return n}const Ze=class Ze extends _t{constructor(t,e,i,r,s){super(),this._knotTolerance=1e-6,this._controlTolerance=1e-6,this._fitTolerance=1e-9,this._normal=new w(0,0,1),this.rebuild(t,e,i,r,s)}get dxfTypeName(){return"SPLINE"}static fromControlPoints(t,e,i,r,s){const a=jt.fromControlPoints(t,e,i,r,s);return a?Uo(a,s):null}static fromFitPoints(t,e,i,r,s,a){const o=jt.fromFitPoints(t,e,i,r,s,a);return o?Uo(o,r):null}static fromDwgSpline(t){const e=!!(t.flag&1),i=q0(t.flag);if(t.numberOfControlPoints>0&&t.numberOfKnots>0){const r=Ze.fromControlPoints(t.controlPoints,t.knots,t.weights,t.degree,e);if(r)return r}return t.numberOfFitPoints>0?Ze.fromFitPoints(t.fitPoints,i,t.degree,e,t.startTangent,t.endTangent):null}rebuild(t,e,i,r,s){const a=+(t!==void 0)+ +(e!==void 0)+ +(i!==void 0)+ +(r!==void 0)+ +(s!==void 0);if(a<2||a>5)throw Pt.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new jt(t,e,i,r):this._geo=new jt(t,e,i,r,s)}get geometricExtents(){return this._geo.box}get closed(){return this._geo.closed}get area(){return this._geo.area}set closed(t){this._geo.closed=t}get knotTolerance(){return this._knotTolerance}set knotTolerance(t){this._knotTolerance=t}get controlTolerance(){return this._controlTolerance}set controlTolerance(t){this._controlTolerance=t}get fitTolerance(){return this._fitTolerance}set fitTolerance(t){this._fitTolerance=t}get normal(){return this._normal}set normal(t){this._normal.copy(t)}subGetGripPoints(){return this._geo.getGripPoints()}subMoveGripPointsAt(t,e){return this._geo.moveGripPointsAt(t,e),this}subGetOsnapPoints(t,e,i,r){switch(t){case A.EndPoint:r.push(this._geo.startPoint),r.push(this._geo.endPoint);break;case A.Node:{const s=new Set;for(const a of this._geo.knots)s.has(a)||(s.add(a),r.push(this._geo.evaluateAt(a)));break}case A.Nearest:r.push(this._geo.nearestPoint(e));break}}transformBy(t){return this._geo.transform(t),this}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),t.writeDouble(42,this.knotTolerance),t.writeDouble(43,this.controlTolerance),t.writeDouble(44,this.fitTolerance);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 t.writeVector3d(210,this.normal),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbSpline");let e=this.closed?1:0,i=3,r=0,s=0,a=0;const o=[],c=[],l=[],h=[];let u=null,d=null,g=this.knotTolerance,p=this.controlTolerance,f=this.fitTolerance,m=this.normal.x,y=this.normal.y,_=this.normal.z,v=null,x=null,k=null,I=null;const P=()=>{v&&(l.push(v),v=null)},C=()=>{x&&(h.push(x),x=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const R=t.readItem();if(!R)break;const N=Number(R.code),O=Number(R.value);switch(N){case 70:e=O;break;case 71:i=O;break;case 72:r=O;break;case 73:s=O;break;case 74:a=O;break;case 42:g=O;break;case 43:p=O;break;case 44:f=O;break;case 40:o.push(O);break;case 41:c.push(O);break;case 10:P(),v={x:O,y:0,z:0};break;case 20:v&&(v.y=O);break;case 30:v&&(v.z=O);break;case 11:C(),x={x:O,y:0,z:0};break;case 21:x&&(x.y=O);break;case 31:x&&(x.z=O);break;case 12:k={x:O,y:0,z:0};break;case 22:k&&(k.y=O);break;case 32:k&&(k.z=O,u=k,k=null);break;case 13:I={x:O,y:0,z:0};break;case 23:I&&(I.y=O);break;case 33:I&&(I.z=O,d=I,I=null);break;case 210:m=O;break;case 220:y=O;break;case 230:_=O;break}}P(),C(),this.knotTolerance=g,this.controlTolerance=p,this.fitTolerance=f;const T=new w(m,y,_);return T.lengthSq()>0&&this.normal.copy(T.normalize()),this.applyDxfInSpline({flag:e,degree:i,numberOfControlPoints:s||l.length,numberOfKnots:r||o.length,numberOfFitPoints:a||h.length,controlPoints:l,knots:o,weights:c.length>0?c:void 0,fitPoints:h,startTangent:u,endTangent:d}),this}applyDxfInSpline(t){const e=Ze.fromDwgSpline(t);e&&(this._geo=e._geo,this.closed=e.closed)}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectPath2d(1);return e.length<2?1:kt.from2dPoints(e,this.closed).getOffsetSideAtPoint(t)}createOffsetCurve(t){const{points:e,tangents:i}=this._geo.getOffsetSamplePath2d(t),r=Jd(e,this.closed,t,i);return r?kt.fromGePolyline(r):null}collectPath2d(t){return this._geo.getOffsetSamplePath2d(t).points}};Ze.typeName="Spline";let qi=Ze;function Z0(n){return n==null?pt.latest.capabilities:typeof n=="object"&&"supportsHandles"in n?n:n instanceof pt?n.capabilities:new pt(n).capabilities}const Q0=new w,Ra=class Ra extends ee{get dxfTypeName(){return"ACAD_TABLE"}constructor(t,e,i){super(t),this._attachmentPoint=exports.AcGiMTextAttachmentPoint.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}resizeGrid(t,e){const i=Math.max(0,t),r=Math.max(0,e);this._numRows=i,this._numColumns=r,this._rowHeight=new Array(i).fill(0),this._columnWidth=new Array(r).fill(0),this._cells=new Array(i*r)}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 s;const r=t*this._numColumns+e;return(s=this._cells[r])==null?void 0:s.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(){let t;try{t=this.blockTableRecord}catch{t=void 0}if(t&&t.newIterator().count>0){const o=new Y;for(const c of t.newIterator())o.union(c.geometricExtents);return o.applyMatrix4(this.blockTransform),o}const e=this._columnWidth.reduce((o,c)=>o+c,0),i=this._rowHeight.reduce((o,c)=>o+c,0),r=new Y;if(e===0&&i===0)return r.expandByPoint(this.position),r;const s=new ei;s.setFromAxisAngle(w.Z_AXIS,this.rotation),Ye.compose(this.position,s,this.scaleFactors);const a=[new b(0,0,0),new b(e,0,0),new b(e,-i,0),new b(0,-i,0)];for(const o of a)r.expandByPoint(o.applyMatrix4(Ye));return r}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"table",properties:[{name:"numRows",type:"string",editable:!0,accessor:{get:()=>this.numRows,set:t=>{this.numRows=t}}},{name:"numColumns",type:"float",editable:!0,accessor:{get:()=>this.numColumns,set:t=>{this.numColumns=t}}},{name:"tableWidth",type:"float",editable:!1,accessor:{get:()=>this._columnWidth.reduce((t,e)=>t+e,0)}},{name:"tableHeight",type:"float",editable:!1,accessor:{get:()=>this._rowHeight.reduce((t,e)=>t+e,0)}}]},{groupName:"geometry",properties:[{name:"positionX",type:"float",editable:!0,accessor:{get:()=>this.position.x,set:t=>{this.position.x=t}}},{name:"positionY",type:"float",editable:!0,accessor:{get:()=>this.position.y,set:t=>{this.position.y=t}}},{name:"positionZ",type:"float",editable:!0,accessor:{get:()=>this.position.z,set:t=>{this.position.z=t}}}]}]}}subWorldDraw(t){const e=this.blockTableRecord;if(e&&e.newIterator().count>0){const g=this.drawAnonymousTableBlock(t,e);if(g)return g}let i=0,r=0;const s=new Uint16Array(this.numColumns*this.numRows*8),a=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let o=0;for(let g=0;g<=this.numRows;g++){i-=g>0?this.rowHeight(g-1):0,r=0;for(let p=0;p<=this.numColumns;p++)r+=p>0?this.columnWidth(p-1):0,a[o++]=r,a[o++]=i,a[o++]=0}const c=[],l=new Array(this.numRows*this.numColumns).fill(!1);r=0,o=0;let h=0;for(let g=0;g<this.numColumns;g++){r+=g>0?this.columnWidth(g-1):0,i=0;for(let p=0;p<this.numRows;p++){i+=p>0?this.rowHeight(p-1):0;const f=this.cell(p*this.numColumns+g);if(h=p*this.numColumns+g,f&&!l[h]){const m=f.borderWidth??1,y=f.borderHeight??1;this.fillVisited(l,h,this.numColumns,m,y),s[o++]=g+p*(this.numColumns+1),s[o++]=g+p*(this.numColumns+1)+m;const _=a[s[o-1]*3]-r,v=g+(p+y)*(this.numColumns+1)+m;g+m==this.numColumns&&(s[o++]=g+p*(this.numColumns+1)+m,s[o++]=v);const x=-a[v*3+1]-i;if(p+y==this.numRows&&(s[o++]=g+(p+y)*(this.numColumns+1)+y,s[o++]=g+(p+y)*(this.numColumns+1)),s[o++]=g+(p+y)*(this.numColumns+1),s[o++]=g+p*(this.numColumns+1),f.text){const k=f.attachmentPoint||this.attachmentPoint||exports.AcGiMTextAttachmentPoint.MiddleCenter,I=this.getTableTextOffset(k,_,x),P={text:f.text,height:this.getCellTextHeight(f,x),width:_,position:Q0.set(r,-i,0).clone().add(I),rotation:this.rotation,attachmentPoint:k},C=this.getTextStyle(f);c.push(t.mtext(P,C))}}}}c.push(t.lineSegments(a,3,s));const u=t.group(c),d=new ei;return d.setFromAxisAngle(w.Z_AXIS,this.rotation),Ye.compose(this.position,d,this.scaleFactors),u.applyMatrix(Ye),u}drawAnonymousTableBlock(t,e){const i=[],r=e.newIterator();for(const o of r){let c;if(o.color.isByBlock){Ho.copy(o.color);const l=this.resolvedColor;l.isForeground?o.color.setForeground():l.RGB!=null&&o.color.setRGBValue(l.RGB),c=o.worldDraw(t),o.color.copy(Ho)}else c=o.worldDraw(t);c&&(c.objectId=this.objectId,c.ownerId=this.ownerId,c.layerName=this.layer,c.visible=this.visibility&&o.visibility,i.push(c))}const s=t.group(i);s.applyMatrix(this.blockTransform);const a=this.normal;return a&&(a.x!==0||a.y!==0||a.z!==1)&&(Ye.setFromExtrusionDirection(a),s.applyMatrix(Ye)),s}fillVisited(t,e,i,r,s){if(s==1&&r==1)t[e]=!0;else for(let a=0;a<r;++a)for(let o=0;o<s;++o)t[e+a+o*i]=!0}getTextStyle(t){const e=this.database.tables.textStyleTable.resolveAt(t.textStyle);if(!e)throw new Error("No valid text style found in text style table.");return e.textStyle}getTableTextOffset(t,e,i){const r=new w;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}getCellTextHeight(t,e){return t.textHeight&&t.textHeight>0?t.textHeight:Math.max(e/2,1)}dxfOutFields(t){var s,a,o,c,l,h,u;super.dxfOutFields(t),t.writeSubclassMarker("AcDbTable");const e=t.version??((s=t.database)==null?void 0:s.version)??((a=this.database)==null?void 0:a.version),i=Z0(e).supportsUtf8CodePage;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 d=0;d<this.numRows;++d)t.writeDouble(141,this.rowHeight(d));for(let d=0;d<this.numColumns;++d)t.writeDouble(142,this.columnWidth(d));const r=this._cells.length>0?this._cells.length:this.numRows*this.numColumns;for(let d=0;d<r;d++){const g=this._cells[d],p=(g==null?void 0:g.cellType)??(g!=null&&g.blockTableRecordId?2:1);if(t.writeInt16(171,p),t.writeInt16(172,(g==null?void 0:g.flagValue)??0),t.writeInt16(173,(g==null?void 0:g.mergedValue)??0),t.writeBoolean(174,g==null?void 0:g.autoFit),t.writeInt16(175,g==null?void 0:g.borderWidth),t.writeInt16(176,g==null?void 0:g.borderHeight),(g==null?void 0:g.overrideFlag)!=null&&(i?t.writeInt32(91,g.overrideFlag):t.writeInt16(177,g.overrideFlag)),t.writeInt16(178,g==null?void 0:g.virtualEdgeFlag),t.writeAngle(145,g==null?void 0:g.rotation),i&&t.writeInt16(92,g==null?void 0:g.extendedCellFlags),p===1)g!=null&&g.fieldObjetId?t.writeObjectId(344,g.fieldObjetId):this.writeCellText(t,(g==null?void 0:g.text)??"",i,g==null?void 0:g.cellValueBlockBegin);else if(p===2){if(t.writeObjectId(340,g==null?void 0:g.blockTableRecordId),t.writeDouble(144,g==null?void 0:g.blockScale),t.writeInt16(179,g==null?void 0:g.blockAttrNum),(o=g==null?void 0:g.attrDefineId)!=null&&o.length)for(const f of g.attrDefineId)t.writeObjectId(331,f);if((g==null?void 0:g.attrText)!=null)if(Array.isArray(g.attrText))for(const f of g.attrText)t.writeString(300,f);else t.writeString(300,g.attrText)}g!=null&&g.textStyle&&t.writeString(7,g.textStyle),(g==null?void 0:g.textHeight)!=null&&t.writeDouble(140,g.textHeight),(g==null?void 0:g.attachmentPoint)!=null&&t.writeInt16(170,g.attachmentPoint),(g==null?void 0:g.topBorderVisibility)!=null&&t.writeInt16(289,g.topBorderVisibility?1:0),(g==null?void 0:g.rightBorderVisibility)!=null&&t.writeInt16(285,g.rightBorderVisibility?1:0),(g==null?void 0:g.bottomBorderVisibility)!=null&&t.writeInt16(286,g.bottomBorderVisibility?1:0),(g==null?void 0:g.leftBorderVisibility)!=null&&t.writeInt16(288,g.leftBorderVisibility?1:0)}if(t.writeInt16(70,this.flowDirection),t.writeDouble(40,this.horizontalCellMargin),t.writeDouble(41,this.verticalCellMargin),this.suppressTitle!=null&&t.writeInt16(280,this.suppressTitle?1:0),this.suppressHeader!=null&&t.writeInt16(281,this.suppressHeader?1:0),(c=this.cellTypeOverrides)!=null&&c.length)for(const d of this.cellTypeOverrides){t.writeString(7,d.textStyle),t.writeDouble(140,d.textHeight),t.writeInt16(170,d.alignment),t.writeInt16(63,d.backgroundColor),t.writeInt16(64,d.contentColor),d.backgroundColorEnabled!=null&&t.writeInt16(283,d.backgroundColorEnabled?1:0);const g=d.borderLineweights;g&&(t.writeInt16(274,g.top),t.writeInt16(275,g.right),t.writeInt16(276,g.bottom),t.writeInt16(277,g.left),t.writeInt16(278,g.insideHorizontal),t.writeInt16(279,g.insideVertical));const p=d.borderVisibility;p&&(t.writeInt16(284,p.top?1:0),t.writeInt16(285,p.right?1:0),t.writeInt16(286,p.bottom?1:0),t.writeInt16(287,p.left?1:0),t.writeInt16(288,p.insideHorizontal?1:0),t.writeInt16(289,p.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)),(l=this.rowDataTypes)!=null&&l.length)for(const d of this.rowDataTypes)t.writeInt16(97,d);if((h=this.rowUnitTypes)!=null&&h.length)for(const d of this.rowUnitTypes)t.writeInt16(98,d);if((u=this.rowFormats)!=null&&u.length)for(const d of this.rowFormats)t.writeString(4,d);return this}dxfInFields(t){var f,m,y;super.dxfInFields(t),t.atSubclassData("AcDbTable");let e=this._numRows,i=this._numColumns,r=!1;const s=[],a=[];let o=0,c=null,l=[],h=((f=this.horizontalDirection)==null?void 0:f.x)??1,u=((m=this.horizontalDirection)==null?void 0:m.y)??0,d=((y=this.horizontalDirection)==null?void 0:y.z)??0;const g=()=>{e>0&&i>0&&(!r||this._numRows!==e||this._numColumns!==i)&&(this.resizeGrid(e,i),r=!0)},p=()=>{c&&(l.length>0&&(c.text=l.join(""),l=[]),g(),o<this._cells.length&&this.setCell(o,c),o+=1,c=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const _=t.readItem();if(!_)break;const v=Number(_.code),x=Number(_.value);switch(v){case 280:c||(this.tableDataVersion=x);break;case 342:this.tableStyleId=String(_.value);break;case 343:this.owningBlockRecordId=String(_.value);break;case 11:h=x;break;case 21:u=x;break;case 31:d=x;break;case 90:c||(this.tableValueFlag=x);break;case 93:c||(this.tableOverrideFlag=x);break;case 94:c||(this.borderColorOverrideFlag=x);break;case 95:c||(this.borderLineweightOverrideFlag=x);break;case 96:c||(this.borderVisibilityOverrideFlag=x);break;case 71:this.attachmentPoint=x;break;case 170:c?c.attachmentPoint=x:this.attachmentPoint=x;break;case 91:c?c&&(c.overrideFlag=x):(e=x,g());break;case 92:c?c&&(c.extendedCellFlags=x):(i=x,g());break;case 141:s.push(x);break;case 142:a.push(x);break;case 171:p(),c={text:"",attachmentPoint:exports.AcGiMTextAttachmentPoint.MiddleCenter,cellType:x,textHeight:0};break;case 172:c&&(c.flagValue=x);break;case 173:c&&(c.mergedValue=x);break;case 174:c&&(c.autoFit=!!_.value||x!==0);break;case 175:c&&(c.borderWidth=x);break;case 176:c&&(c.borderHeight=x);break;case 177:c&&(c.overrideFlag=x);break;case 178:c&&(c.virtualEdgeFlag=x);break;case 145:c&&(c.rotation=x*Math.PI/180);break;case 1:case 2:case 302:case 303:l.push(String(_.value));break;case 300:if(c){const k=c.attrText;Array.isArray(k)?k.push(String(_.value)):k!=null&&k!==""?c.attrText=[String(k),String(_.value)]:c.attrText=String(_.value)}break;case 301:c&&(c.cellValueBlockBegin=String(_.value));break;case 304:break;case 7:c&&(c.textStyle=String(_.value));break;case 140:c&&(c.textHeight=x);break;case 340:c&&(c.blockTableRecordId=String(_.value));break;case 344:case 345:c&&(c.fieldObjetId=String(_.value));break;case 144:case 146:c&&(c.blockScale=x);break;case 179:c&&(c.blockAttrNum=x);break;case 70:this.flowDirection=x;break;case 40:this.horizontalCellMargin=x;break;case 41:this.verticalCellMargin=x;break;case 281:this.suppressHeader=x!==0;break}}return p(),this.horizontalDirection=new w(h,u,d),s.forEach((_,v)=>this.setRowHeight(v,_)),a.forEach((_,v)=>this.setColumnWidth(v,_)),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 c=0;c<o;c++){const l=c*250,h=l+250,u=e.slice(l,h);c===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 c=o*250,l=c+250,h=e.slice(c,l);o===a-1?t.writeString(302,h):t.writeString(303,h)}t.writeString(304,"ACVALUE_END")}};Ra.typeName="Table";let Zn=Ra;const Ye=new D,Ho=new X,Ba=class Ba extends H{constructor(){super(),this._snapBase=new b,this._snapSpacing=new b(1,1,0),this._gridSpacing=new b(1,1,0),this._perspectiveLensLength=50,this._frontClipZ=0,this._backClipZ=0,this._snapAngle=0,this._status=0,this._ucsPerViewport=0,this._circleZoomPercent=1e3,this._statusBitFlags=0,this._ucsOrigin=new b,this._ucsXAxis=new w(1,0,0),this._ucsYAxis=new w(0,1,0),this._elevation=0,this._frozenLayerIds=[],this._sheetName="",this._iconFlag=0,this._orthographicType=0,this._majorGridFrequency=0,this._ambientLightColorIndex=0,this._brightness=0,this._contrast=0,this._shadePlotMode=0,this._renderMode=0,this._defaultLightingType=0,this._isDefaultLighting=!1,this._clippingBoundaryId="",this._backgroundId="",this._shadePlotId="",this._ucsId="",this._ucsBaseId="",this._visualStyleId="",this._sunId="",this._ambientLightColorInstance=0,this._ambientLightColorName="",this._softPointers=[],this._centerPoint=new b,this._height=0,this._width=0,this._viewCenter=new b,this._viewTarget=new b,this._viewDirection=new w(0,0,1),this._viewTwistAngle=0,this._viewHeight=0,this._number=-1}get dxfTypeName(){return"VIEWPORT"}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 viewTarget(){return this._viewTarget}set viewTarget(t){this._viewTarget=t}get viewDirection(){return this._viewDirection}set viewDirection(t){this._viewDirection.copy(t)}get snapBase(){return this._snapBase}set snapBase(t){this._snapBase.copy(t)}get snapSpacing(){return this._snapSpacing}set snapSpacing(t){this._snapSpacing.copy(t)}get gridSpacing(){return this._gridSpacing}set gridSpacing(t){this._gridSpacing.copy(t)}get perspectiveLensLength(){return this._perspectiveLensLength}set perspectiveLensLength(t){this._perspectiveLensLength=t}get frontClipZ(){return this._frontClipZ}set frontClipZ(t){this._frontClipZ=t}get backClipZ(){return this._backClipZ}set backClipZ(t){this._backClipZ=t}get snapAngle(){return this._snapAngle}set snapAngle(t){this._snapAngle=t}get status(){return this._status}set status(t){this._status=t}get ucsPerViewport(){return this._ucsPerViewport}set ucsPerViewport(t){this._ucsPerViewport=t}get circleZoomPercent(){return this._circleZoomPercent}set circleZoomPercent(t){this._circleZoomPercent=t}get statusBitFlags(){return this._statusBitFlags}set statusBitFlags(t){this._statusBitFlags=t}get ucsOrigin(){return this._ucsOrigin}set ucsOrigin(t){this._ucsOrigin.copy(t)}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get frozenLayerIds(){return this._frozenLayerIds}set frozenLayerIds(t){this._frozenLayerIds=[...t]}get ucsXAxis(){return this._ucsXAxis}set ucsXAxis(t){this._ucsXAxis.copy(t)}get ucsYAxis(){return this._ucsYAxis}set ucsYAxis(t){this._ucsYAxis.copy(t)}get sheetName(){return this._sheetName}set sheetName(t){this._sheetName=t}get iconFlag(){return this._iconFlag}set iconFlag(t){this._iconFlag=t}get orthographicType(){return this._orthographicType}set orthographicType(t){this._orthographicType=t}get majorGridFrequency(){return this._majorGridFrequency}set majorGridFrequency(t){this._majorGridFrequency=t}get ambientLightColorIndex(){return this._ambientLightColorIndex}set ambientLightColorIndex(t){this._ambientLightColorIndex=t}get viewportBrightness(){return this._brightness}set viewportBrightness(t){this._brightness=t}get viewportContrast(){return this._contrast}set viewportContrast(t){this._contrast=t}get shadePlotMode(){return this._shadePlotMode}set shadePlotMode(t){this._shadePlotMode=t}get renderMode(){return this._renderMode}set renderMode(t){this._renderMode=t}get defaultLightingType(){return this._defaultLightingType}set defaultLightingType(t){this._defaultLightingType=t}get isDefaultLighting(){return this._isDefaultLighting}set isDefaultLighting(t){this._isDefaultLighting=t}get clippingBoundaryId(){return this._clippingBoundaryId}set clippingBoundaryId(t){this._clippingBoundaryId=t}get backgroundId(){return this._backgroundId}set backgroundId(t){this._backgroundId=t}get shadePlotId(){return this._shadePlotId}set shadePlotId(t){this._shadePlotId=t}get ucsId(){return this._ucsId}set ucsId(t){this._ucsId=t}get ucsBaseId(){return this._ucsBaseId}set ucsBaseId(t){this._ucsBaseId=t}get visualStyleId(){return this._visualStyleId}set visualStyleId(t){this._visualStyleId=t}get sunId(){return this._sunId}set sunId(t){this._sunId=t}get ambientLightColorInstance(){return this._ambientLightColorInstance}set ambientLightColorInstance(t){this._ambientLightColorInstance=t}get ambientLightColorName(){return this._ambientLightColorName}set ambientLightColorName(t){this._ambientLightColorName=t}get softPointers(){return this._softPointers}set softPointers(t){this._softPointers=[...t]}get viewTwistAngle(){return this._viewTwistAngle}set viewTwistAngle(t){this._viewTwistAngle=t}get viewHeight(){return this._viewHeight}set viewHeight(t){this._viewHeight=t}get geometricExtents(){const t=this._width/2,e=this._height/2,i=new Y;return i.expandByPoint(new b(this._centerPoint.x-t,this._centerPoint.y-e,this._centerPoint.z)),i.expandByPoint(new b(this._centerPoint.x+t,this._centerPoint.y+e,this._centerPoint.z)),i}subGetGripPoints(){const t=new Array,e=this._width/2,i=this._height/2,r=this._centerPoint.z;return t.push(this._centerPoint),(e>0||i>0)&&t.push(new b(this._centerPoint.x-e,this._centerPoint.y-i,r),new b(this._centerPoint.x+e,this._centerPoint.y-i,r),new b(this._centerPoint.x+e,this._centerPoint.y+i,r),new b(this._centerPoint.x-e,this._centerPoint.y+i,r)),t}subMoveGripPointsAt(t,e){return ht(t,i=>{this.moveGripAt(i,e)}),this}transformBy(t){const e=this._centerPoint.clone(),i=this._centerPoint.clone().add(new w(this._width,0,0)),r=this._centerPoint.clone().add(new w(0,this._height,0));e.applyMatrix4(t),i.applyMatrix4(t),r.applyMatrix4(t);const s=new w(i).sub(e),a=new w(r).sub(e),o=this._height!==0?a.length()/this._height:1;return this._centerPoint.copy(e),this._width=s.length(),this._height=a.length(),this._viewHeight*=o,this}subWorldDraw(t){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const e=this.toGiViewport();return t.group(this.createViewportRect(e,t))}}toGiViewport(){const t=new cl;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.viewTarget=this.viewTarget,t.viewTwistAngle=this.viewTwistAngle,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){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.writePoint3d(13,this.snapBase),t.writePoint3d(14,this.snapSpacing),t.writePoint3d(15,this.gridSpacing),t.writeVector3d(16,this.viewDirection),t.writePoint3d(17,this.viewTarget),t.writeDouble(42,this.perspectiveLensLength),t.writeDouble(43,this.frontClipZ),t.writeDouble(44,this.backClipZ),t.writeDouble(45,this.viewHeight),t.writeAngle(50,this.snapAngle),t.writeAngle(51,this.viewTwistAngle),t.writeInt16(68,this.status),t.writeInt32(69,this.number),t.writeInt16(71,this.ucsPerViewport),t.writeInt16(72,this.circleZoomPercent),t.writeInt32(90,this.statusBitFlags);for(const e of this.frozenLayerIds)t.writeObjectId(331,e);t.writePoint3d(110,this.ucsOrigin),t.writeVector3d(111,this.ucsXAxis),t.writeVector3d(112,this.ucsYAxis),t.writeDouble(146,this.elevation),this.sheetName&&t.writeString(1,this.sheetName),t.writeInt16(61,this.majorGridFrequency),t.writeInt16(63,this.ambientLightColorIndex),t.writeInt16(74,this.iconFlag),t.writeInt16(79,this.orthographicType);for(const e of this.softPointers)t.writeObjectId(91,e);return t.writeDouble(141,this.viewportBrightness),t.writeDouble(142,this.viewportContrast),t.writeInt16(170,this.shadePlotMode),t.writeInt16(281,this.renderMode),t.writeInt16(282,this.defaultLightingType),t.writeInt16(292,this.isDefaultLighting?1:0),this.clippingBoundaryId&&t.writeObjectId(340,this.clippingBoundaryId),this.backgroundId&&t.writeObjectId(332,this.backgroundId),this.shadePlotId&&t.writeObjectId(333,this.shadePlotId),this.ucsId&&t.writeObjectId(345,this.ucsId),this.ucsBaseId&&t.writeObjectId(346,this.ucsBaseId),this.visualStyleId&&t.writeObjectId(348,this.visualStyleId),this.sunId&&t.writeObjectId(361,this.sunId),this.ambientLightColorInstance&&t.writeInt32(421,this.ambientLightColorInstance),this.ambientLightColorName&&t.writeString(431,this.ambientLightColorName),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbViewport");let e=this.centerPoint.x,i=this.centerPoint.y,r=this.centerPoint.z,s=this.viewCenter.x,a=this.viewCenter.y,o=this.viewCenter.z,c=this.viewTarget.x,l=this.viewTarget.y,h=this.viewTarget.z,u=this.viewDirection.x,d=this.viewDirection.y,g=this.viewDirection.z,p=this.snapBase.x,f=this.snapBase.y,m=this.snapBase.z,y=this.snapSpacing.x,_=this.snapSpacing.y,v=this.snapSpacing.z,x=this.gridSpacing.x,k=this.gridSpacing.y,I=this.gridSpacing.z,P=this.ucsOrigin.x,C=this.ucsOrigin.y,T=this.ucsOrigin.z,R=this.ucsXAxis.x,N=this.ucsXAxis.y,O=this.ucsXAxis.z,S=this.ucsYAxis.x,G=this.ucsYAxis.y,$=this.ucsYAxis.z;const Q=[],et=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const W=t.readItem();if(!W)break;const Dt=Number(W.code),B=Number(W.value);switch(Dt){case 1:this.sheetName=String(W.value);break;case 10:e=B;break;case 20:i=B;break;case 30:r=B;break;case 12:s=B;break;case 22:a=B;break;case 32:o=B;break;case 13:p=B;break;case 23:f=B;break;case 33:m=B;break;case 14:y=B;break;case 24:_=B;break;case 34:v=B;break;case 15:x=B;break;case 25:k=B;break;case 35:I=B;break;case 16:u=B;break;case 26:d=B;break;case 36:g=B;break;case 17:c=B;break;case 27:l=B;break;case 37:h=B;break;case 40:this.height=B;break;case 41:this.width=B;break;case 42:this.perspectiveLensLength=B;break;case 43:this.frontClipZ=B;break;case 44:this.backClipZ=B;break;case 45:this.viewHeight=B;break;case 50:this.snapAngle=M.degToRad(B);break;case 51:this.viewTwistAngle=M.degToRad(B);break;case 61:this.majorGridFrequency=B;break;case 63:this.ambientLightColorIndex=B;break;case 68:this.status=B;break;case 69:this.number=B;break;case 71:this.ucsPerViewport=B;break;case 72:this.circleZoomPercent=B;break;case 74:this.iconFlag=B;break;case 79:this.orthographicType=B;break;case 90:this.statusBitFlags=B;break;case 91:case 335:case 343:case 344:et.push(String(W.value));break;case 110:P=B;break;case 120:C=B;break;case 130:T=B;break;case 111:R=B;break;case 121:N=B;break;case 131:O=B;break;case 112:S=B;break;case 122:G=B;break;case 132:$=B;break;case 141:this.viewportBrightness=B;break;case 142:this.viewportContrast=B;break;case 146:this.elevation=B;break;case 170:this.shadePlotMode=B;break;case 281:this.renderMode=B;break;case 282:this.defaultLightingType=B;break;case 292:this.isDefaultLighting=B!==0;break;case 331:Q.push(String(W.value));break;case 332:this.backgroundId=String(W.value);break;case 333:this.shadePlotId=String(W.value);break;case 340:this.clippingBoundaryId=String(W.value);break;case 345:this.ucsId=String(W.value);break;case 346:this.ucsBaseId=String(W.value);break;case 348:this.visualStyleId=String(W.value);break;case 361:this.sunId=String(W.value);break;case 421:this.ambientLightColorInstance=B;break;case 431:this.ambientLightColorName=String(W.value);break}}return this.applyViewportDxfIn(e,i,r,s,a,o,c,l,h),this._viewDirection.copy({x:u,y:d,z:g}),this._snapBase.copy({x:p,y:f,z:m}),this._snapSpacing.copy({x:y,y:_,z:v}),this._gridSpacing.copy({x,y:k,z:I}),this._ucsOrigin.copy({x:P,y:C,z:T}),this._ucsXAxis.copy({x:R,y:N,z:O}),this._ucsYAxis.copy({x:S,y:G,z:$}),this.frozenLayerIds=Q,this.softPointers=et,this}applyViewportDxfIn(t,e,i,r,s,a,o,c,l){this.centerPoint.copy({x:t,y:e,z:i}),this.viewCenter.copy({x:r,y:s,z:a}),this.viewTarget.copy({x:o,y:c,z:l});const h=1e-6,u=Math.abs(t)<h&&Math.abs(e)<h,d=Math.abs(o)<h&&Math.abs(c)<h,g=Number.isFinite(this.height)&&Number.isFinite(this.viewHeight)&&Math.abs(this.viewHeight-this.height)<h;u&&d&&g&&this.centerPoint.copy(this.viewCenter)}moveGripAt(t,e){switch(t){case 0:this._centerPoint.add(e);break;case 1:case 2:case 3:case 4:{const i=this.width/2,r=this.height/2,s=this._centerPoint.x,a=this._centerPoint.y,o={1:{x:s-i,y:a-r},2:{x:s+i,y:a-r},3:{x:s+i,y:a+r},4:{x:s-i,y:a+r}},c=t===1?3:t===2?4:t===3?1:2,l=o[t],h=o[c];l.x+=e.x,l.y+=e.y,this._centerPoint.x=(l.x+h.x)/2,this._centerPoint.y=(l.y+h.y)/2,this._centerPoint.z=(this._centerPoint.z??0)+(e.z??0),this.width=Math.abs(h.x-l.x),this.height=Math.abs(h.y-l.y);break}}}};Ba.typeName="Viewport";let Qn=Ba;const Fa=class Fa extends Wi{get dxfTypeName(){return"WIPEOUT"}subWorldDraw(t){const e=this.boundaryPath(),i=new Vt;return i.add(new q(e)),t.area(i)}dxfOutFields(t){return super.dxfOutFields(t),this}};Fa.typeName="Wipeout";let Jn=Fa;const xr=class xr extends _t{get dxfTypeName(){return"XLINE"}constructor(){super(),this._basePoint=new b,this._unitDir=new w}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 area(){return 0}get geometricExtents(){const t=new Y;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}subMoveGripPointsAt(t,e){return ie(t,e,this.basePoint),this}subGetOsnapPoints(t,e,i,r){const s=this.basePoint;if(t===A.EndPoint){r.push(s);return}const a=this.unitDir.clone();if(a.lengthSq()===0)return;a.normalize();const o=new ge(s,s.clone().add(a));switch(t){case A.Nearest:r.push(o.project(e));break;case A.Perpendicular:r.push(o.perpPoint(e));break}}transformBy(t){return this._basePoint.applyMatrix4(t),this._unitDir.transformDirection(t),this}subWorldDraw(t){const e=[];return e.push(this._unitDir.clone().multiplyScalar(-1e6).add(this._basePoint)),e.push(this._unitDir.clone().multiplyScalar(1e6).add(this._basePoint)),t.lines(e)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbXline"),t.writePoint3d(10,this.basePoint),t.writeVector3d(11,this.unitDir),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbXline");let e=this.basePoint.x,i=this.basePoint.y,r=this.basePoint.z,s=this.unitDir.x,a=this.unitDir.y,o=this.unitDir.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const c=t.readItem();if(!c)break;const l=Number(c.code),h=Number(c.value);switch(l){case 10:e=h;break;case 20:i=h;break;case 30:r=h;break;case 11:s=h;break;case 21:a=h;break;case 31:o=h;break}}return this.basePoint=new b(e,i,r),this.unitDir=new w(s,a,o),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.basePoint,i=this.unitDir,r=Math.hypot(i.x,i.y);return r<=1e-9||(i.x*(t.y-e.y)-i.y*(t.x-e.x))/r>=0?1:-1}createOffsetCurve(t){const e=Dc(this.basePoint,this.unitDir,t);if(!e)return null;const i=new xr;return i.basePoint=e,i.unitDir=this.unitDir.clone(),i}};xr.typeName="Xline";let tr=xr;var ou=(n=>(n.ClosedFilled="",n.Dot="_DOT",n.DotSmall="_DOTSMALL",n.DotBlank="_DOTBLANK",n.Origin="_ORIGIN",n.Origin2="_ORIGIN2",n.Open="_OPEN",n.Open90="_OPEN90",n.Open30="_OPEN30",n.Closed="_CLOSED",n.Small="_SMALL",n.None="_NONE",n.Oblique="_OBLIQUE",n.BoxFilled="_BOXFILLED",n.Box="_BOXBLANK",n.ClosedBlank="_CLOSEDBLANK",n.DatumBlank="_DATUMBLANK",n.DatumFilled="_DATUMFILLED",n.Integral="_INTEGRAL",n.ArchTick="_ARCHTICK",n))(ou||{});const Xe=48,Wo=8,J0=48,cu=80,lu=32,as=80,os=24,Ns=40,tm=8,em=4,$o=64,im=64,nm=new Set(["_version","_angbase","_angdir","_aunits","_auprec","_lunits","_luprec","_celtscale","_cecolor","_celtype","_celweight","_cetransparency","_clayer","_cmlstyle","_cmlscale","_cmleaderstyle","_hpbackgroundcolor","_hpcolor","_hplayer","_hptransparency","_textstyle","_dimstyle","_dimstyle","_dimstyle","_extents","_insunits","_unitmode","_measurement","_ltscale","_lwdisplay","_pdmode","_pdsize","_osmode","_orthomode","_maxHandle","_drawNoPlotLayers","_dwgname","_currentSpace","_formatter","_eventBatchDepth","_pendingEntityAppended","_pendingEntityErased","_pendingDictObjectSet","_pendingDictObjectErased","_lastOpenError"]),hu=new Set(["constructor","prototype","__proto__","caller","callee","arguments"]);function Ut(n,t){let e=n.get(t);return e||(e={bytes:0,count:0},n.set(t,e)),e}function Ot(n,t,e,i=0){if(e<=0&&i===0)return;const r=Ut(n.byCategory,t);r.bytes+=e,r.count+=i}function rm(n){const t=Object.getPrototypeOf(n);return t===Object.prototype||t===null}function sm(n){return ArrayBuffer.isView(n)}function am(n){return typeof n.addEventListener=="function"&&typeof n.dispatch=="function"&&"listeners"in n}function om(n,t,e){return hu.has(t)?!0:!n.includeEventManagers&&(t==="events"||e==="events")?t==="events":!n.includeTransactionManager&&(t==="transactionManager"||e==="transaction")?t==="transactionManager":!1}function qo(n,t,e){return t==="_xDataMap"||n==="xdata"?"xdata":t==="_tables"||n==="tables"?e instanceof H?"entities":"tables":t==="_entities"||n==="entities"?"entities":t==="_objects"||n==="objects"?"objects":t==="_handleRegistry"||n==="handleRegistry"?"handleRegistry":t==="transactionManager"||n==="transaction"?"transaction":t==="events"||n==="events"?"events":n==="sysvars"||nm.has(t)?"sysvars":e instanceof H?"entities":n==="other"?"other":n}function cm(n){const t=new Set;let e=n;for(;e&&e!==Object.prototype;){for(const i of Object.getOwnPropertyNames(e)){if(hu.has(i))continue;const r=Object.getOwnPropertyDescriptor(e,i);r&&typeof r.value=="function"||r&&(r.get||r.set)&&r.value===void 0||t.add(i)}if(e=Object.getPrototypeOf(e),e===Object.prototype||e===null||e===Array.prototype||e===Map.prototype||e===Set.prototype)break}return[...t]}function uu(n){if(n==null)return 0;switch(typeof n){case"number":return tm;case"boolean":return em;case"string":return Ns+n.length*2;case"bigint":return 16;case"symbol":return Ns+String(n.description??"").length*2;default:return 0}}function lm(n,t){if(n.visited.has(t))return 0;n.visited.add(t),n.objectCount+=1;let e=cu+t.size*lu;for(const i of t.keys())e+=uu(i);return Ot(n,"handleRegistry",e,1),e}function je(n,t,e,i){if(t==null)return 0;const r=typeof t;if(r==="function")return 0;if(r!=="object"){const h=uu(t);if(Ot(n,e,h),i){const u=Ut(n.byEntityType,i);u.bytes+=h}return h}const s=t;if(typeof s.nodeType=="number"||n.visited.has(s))return 0;if(n.visited.add(s),n.objectCount+=1,!n.includeEventManagers&&am(s))return Ot(n,e,Xe,1),Xe;let a=i,o=e;if(s instanceof H){o="entities",a=s.type,n.entityCount+=1;const h=Ut(n.byEntityType,a);h.count+=1}if(typeof s.then=="function")return Ot(n,o,Xe,1),Xe;if(s instanceof ArrayBuffer){const h=$o+s.byteLength;return Ot(n,o,h,1),a&&(Ut(n.byEntityType,a).bytes+=h),h}if(sm(s)){const h=$o+s.byteLength;return s.buffer&&!n.visited.has(s.buffer)&&n.visited.add(s.buffer),Ot(n,o,h,1),a&&(Ut(n.byEntityType,a).bytes+=h),h}if(typeof Blob<"u"&&s instanceof Blob){const h=im+s.size;return Ot(n,o,h,1),a&&(Ut(n.byEntityType,a).bytes+=h),h}if(s instanceof Date){const h=Xe+8;return Ot(n,o,h,1),h}if(s instanceof Map){const h=o==="handleRegistry",u=cu+s.size*lu;let d=u;Ot(n,o,u,1),a&&(Ut(n.byEntityType,a).bytes+=u);for(const[g,p]of s)d+=je(n,g,o,a),h||(d+=je(n,p,o,a));return d}if(s instanceof Set){let h=as+s.size*os;for(const u of s)h+=je(n,u,o,a);return Ot(n,o,as+s.size*os,1),a&&(Ut(n.byEntityType,a).bytes+=as+s.size*os),h}if(Array.isArray(s)){let h=J0+s.length*Wo;Ot(n,o,h,1),a&&(Ut(n.byEntityType,a).bytes+=h);for(let u=0;u<s.length;u++){const d=s[u],g=qo(o,String(u),d);h+=je(n,d,g,a)}return h}let c=Xe;const l=rm(s)?Object.getOwnPropertyNames(s):cm(s);for(const h of l)c+=Wo,c+=Math.min(Ns+h.length*2,64);Ot(n,o,c,1),a&&(Ut(n.byEntityType,a).bytes+=c);for(const h of l){if(om(n,h,o)||h==="_database"||h==="database")continue;let u;try{u=s[h]}catch{continue}if(typeof u=="function")continue;if(h==="_handleRegistry"&&u instanceof Map){c+=lm(n,u);continue}const d=qo(o,h,u);!n.includeTransactionManager&&d==="transaction"||!n.includeEventManagers&&d==="events"||(c+=je(n,u,d,a))}return c}function hm(n,t){const e={visited:new WeakSet,objectCount:0,entityCount:0,byCategory:new Map,byEntityType:new Map,includeTransactionManager:(t==null?void 0:t.includeTransactionManager)===!0,includeEventManagers:(t==null?void 0:t.includeEventManagers)===!0};je(e,n,"sysvars",null);let i=0;const r={};for(const[a,o]of e.byCategory)r[a]={bytes:o.bytes,count:o.count},i+=o.bytes;const s={};for(const[a,o]of e.byEntityType)s[a]={bytes:o.bytes,count:o.count};return{totalBytes:i,objectCount:e.objectCount,entityCount:e.entityCount,byCategory:r,byEntityType:s}}function cs(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(2)} KiB`:`${(n/(1024*1024)).toFixed(2)} MiB`}function um(n){const t=[`AcDbDatabase memory estimate: ${cs(n.totalBytes)} (${n.totalBytes} bytes)`,`Objects: ${n.objectCount}, Entities: ${n.entityCount}`,"By category:"],e=Object.entries(n.byCategory).sort((r,s)=>s[1].bytes-r[1].bytes);for(const[r,s]of e)t.push(` ${r}: ${cs(s.bytes)} (${s.bytes} bytes), count=${s.count}`);const i=Object.entries(n.byEntityType).sort((r,s)=>s[1].bytes-r[1].bytes);if(i.length>0){t.push("By entity type:");for(const[r,s]of i)t.push(` ${r}: ${cs(s.bytes)} (${s.bytes} bytes), count=${s.count}`)}return t.join(`
14
+ `)}class ga{parse(t){const i=this.normalizeLineEndings(t).split(`
15
+ `),r=[],s=[];let a=null;return i.forEach((o,c)=>{const l=c+1,h=this.stripInlineComment(o).trim();if(!h)return;if(h.startsWith("*")){this.flushCurrentPattern(a,r,s);const d=this.parseHeader(h.slice(1));if(!d){s.push({line:l,message:"Invalid pattern header.",source:o}),a=null;return}a={pattern:{name:d.name,description:d.description,lines:[]},headerLine:l};return}if(!a){s.push({line:l,message:"Line descriptor appears before any pattern header.",source:o});return}const u=this.parseLineDescriptor(h,l);if(!u){s.push({line:l,message:"Invalid line descriptor. Expect: angle,x-origin,y-origin,delta-x,delta-y[,dash-1,...].",source:o});return}a.pattern.lines.push(u)}),this.flushCurrentPattern(a,r,s),{patterns:r,issues:s}}static parse(t){return new ga().parse(t)}normalizeLineEndings(t){return t.replace(/\r\n/g,`
16
16
  `).replace(/\r/g,`
17
- `)}stripInlineComment(t){const e=t.indexOf(";");return e<0?t:t.slice(0,e)}parseHeader(t){const e=t.indexOf(",");if(e<0){const s=t.trim();return s?{name:s,description:""}:null}const i=t.slice(0,e).trim(),r=t.slice(e+1).trim();return i?{name:i,description:r}:null}parseNumber(t){const e=Number(t.trim());return Number.isFinite(e)?e:null}parseLineDescriptor(t,e){const i=t.split(",").map(u=>u.trim()).filter(u=>u.length>0);if(i.length<5)return null;const r=this.parseNumber(i[0]),s=this.parseNumber(i[1]),a=this.parseNumber(i[2]),o=this.parseNumber(i[3]),c=this.parseNumber(i[4]);if(r==null||s==null||a==null||o==null||c==null)return null;const l=i.slice(5),h=[];for(const u of l){const d=this.parseNumber(u);if(d==null)return null;h.push(d)}return{angle:r,originX:s,originY:a,deltaX:o,deltaY:c,dashes:h,sourceLine:e}}flushCurrentPattern(t,e,i){t&&(t.pattern.lines.length===0&&i.push({line:t.headerLine,message:`Pattern "${t.pattern.name}" has no line descriptor.`,source:""}),e.push(t.pattern))}}const z=class z{static nextGradientId(t){return z.gradientIdCounter+=1,`acdb-pat-gradient-${t.toLowerCase()}-${z.gradientIdCounter}`}static packedRgbToCss(t){return`#${(t&16777215).toString(16).padStart(6,"0")}`}static gradientColorToCss(t,e){return typeof t=="number"?z.packedRgbToCss(t):t??e}static applyShadeTint(t,e){const i=C.clamp(e,0,1),r=i<.5?0:16777215,s=i<.5?1-i*2:i*2-1,a=t>>16&255,o=t>>8&255,c=t&255,l=r>>16&255,h=r>>8&255,u=r&255;return Math.round(a+(l-a)*s)*65536+Math.round(o+(h-o)*s)*256+Math.round(c+(u-c)*s)}static resolveGradientColors(t){const e="#2563eb",i="#f8fafc",r=z.gradientColorToCss(t.startColor,e);if(t.oneColorMode&&t.endColor==null){if(typeof t.startColor=="number"){const s=z.applyShadeTint(t.startColor,t.shadeTintValue??.5);return{start:r,end:z.packedRgbToCss(s)}}return{start:r,end:(t.shadeTintValue??.5)<.5?"#000000":"#ffffff"}}return{start:r,end:z.gradientColorToCss(t.endColor,i)}}static renderGradientStops(t){return t.map(e=>`<stop offset="${(C.clamp(e.offset,0,1)*100).toFixed(2)}%" stop-color="${e.color}" />`).join("")}static getGradientVector(t){return{x:Math.cos(t),y:-Math.sin(t)}}static isSolidPattern(t){return t.name.trim().toUpperCase()===Ce}static renderBackground(t,e,i){return`<rect x="${-t/2}" y="${-e/2}" width="${t}" height="${e}" fill="${i}" />`}static estimateUnitScale(t){const e=[];for(const s of t.lines){e.push(Math.abs(s.deltaX),Math.abs(s.deltaY));for(const a of s.dashes)e.push(Math.abs(a))}const i=e.filter(s=>s>z.EPSILON);if(i.length===0)return 1;const r=i.sort((s,a)=>s-a);return r[Math.floor(r.length/2)]||1}static segmentToSvgPath(t){return`M ${t.x1.toFixed(2)} ${(-t.y1).toFixed(2)} L ${t.x2.toFixed(2)} ${(-t.y2).toFixed(2)}`}static buildDashSegments(t,e,i,r,s,a,o){const c=t.dashes;if(c.length===0)return[{x1:r+a*e,y1:s+o*e,x2:r+a*i,y2:s+o*i}];const l=c.reduce((g,p)=>g+Math.abs(p),0);if(l<=z.EPSILON)return[{x1:r+a*e,y1:s+o*e,x2:r+a*i,y2:s+o*i}];const h=[],u=Math.ceil((i-e)/l)+2;let d=e-l;for(let g=0;g<u;g++){let p=d;for(const f of c){const m=Math.abs(f),b=p+m;if(f>0||f===0){const _=C.clamp(p,e,i),v=C.clamp(b,e,i);v>_?h.push({x1:r+a*_,y1:s+o*_,x2:r+a*v,y2:s+o*v}):f===0&&_>=e&&_<=i&&h.push({x1:r+a*(_-.35),y1:s+o*(_-.35),x2:r+a*(_+.35),y2:s+o*(_+.35)})}p=b}d+=l}return h}static renderFamily(t,e){const i=C.degToRad(t.angle),r=Math.cos(i),s=Math.sin(i),a=-s,o=r,c=r*t.deltaX+a*t.deltaY,l=s*t.deltaX+o*t.deltaY,h=Math.hypot(c,l),u=h<=z.EPSILON?1:Math.max(1,Math.ceil(e*2/h)+1),d=Math.floor(u/2),g=-e*1.5,p=e*1.5,f=[];for(let m=-d;m<=d;m++){const b=t.originX+c*m,_=t.originY+l*m,v=z.buildDashSegments(t,g,p,b,_,r,s);for(const x of v)f.push(z.segmentToSvgPath(x))}return`<path d="${f.join(" ")}" fill="none" />`}static renderLinearGradientDef(t,e,i,r,s){const a=z.getGradientVector(e),o=C.clamp(i,-1,1)*r*.5,c=a.x*o,l=a.y*o;return[`<linearGradient id="${t}" gradientUnits="userSpaceOnUse"`,` x1="${(-a.x*r+c).toFixed(2)}"`,` y1="${(-a.y*r+l).toFixed(2)}"`,` x2="${(a.x*r+c).toFixed(2)}"`,` y2="${(a.y*r+l).toFixed(2)}">`,z.renderGradientStops(s),"</linearGradient>"].join("")}static renderRadialGradientDef(t,e,i,r,s){return[`<radialGradient id="${t}" gradientUnits="userSpaceOnUse"`,` cx="${e.toFixed(2)}" cy="${i.toFixed(2)}" r="${r.toFixed(2)}"`,` fx="${e.toFixed(2)}" fy="${i.toFixed(2)}">`,z.renderGradientStops(s),"</radialGradient>"].join("")}static renderGradientDef(t,e,i,r,s,a,o){const c=e.toUpperCase(),l=c.startsWith("INV"),h=c.replace(/^INV/,""),u=l?i.end:i.start,d=l?i.start:i.end,g=Math.hypot(a,o)/2,p=z.getGradientVector(r),f=C.clamp(s,-1,1),m=p.x*f*a*.25,b=p.y*f*o*.25;switch(h){case"CYLINDER":{const _=C.clamp(.5+f*.45,.05,.95);return z.renderLinearGradientDef(t,r,0,g,[{offset:0,color:u},{offset:_,color:d},{offset:1,color:u}])}case"SPHERICAL":return z.renderRadialGradientDef(t,m,b,g,[{offset:0,color:d},{offset:1,color:u}]);case"HEMISPHERICAL":return z.renderRadialGradientDef(t,m+p.x*a*.18,b+p.y*o*.18,g*.92,[{offset:0,color:d},{offset:.72,color:u},{offset:1,color:u}]);case"CURVED":return z.renderRadialGradientDef(t,-p.x*a*.95+m,-p.y*o*.95+b,g*1.65,[{offset:0,color:u},{offset:.55,color:u},{offset:1,color:d}]);case"LINEAR":default:return z.renderLinearGradientDef(t,r,s,g,[{offset:0,color:u},{offset:1,color:d}])}}renderPattern(t,e={}){const i=e.width??260,r=e.height??160,s=e.stroke??"#1f2937",a=e.strokeWidth??1.3,o=e.background??"#ffffff",c=`${-i/2} ${-r/2} ${i} ${r}`;if(z.isSolidPattern(t))return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${c}" width="${i}" height="${r}">`,z.renderBackground(i,r,o),`<rect x="${-i/2}" y="${-r/2}" width="${i}" height="${r}" fill="${s}" />`,"</svg>"].join("");const l=z.estimateUnitScale(t),u=Math.min(i,r)*.18/Math.max(l,z.EPSILON),d={...t,lines:t.lines.map(f=>({...f,originX:f.originX*u,originY:f.originY*u,deltaX:f.deltaX*u,deltaY:f.deltaY*u,dashes:f.dashes.map(m=>m*u)}))},g=Math.hypot(i,r)*.75,p=d.lines.map(f=>z.renderFamily(f,g)).join("");return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${c}" width="${i}" height="${r}">`,z.renderBackground(i,r,o),`<g stroke="${s}" stroke-width="${a.toFixed(2)}" stroke-linecap="round">`,p,"</g>","</svg>"].join("")}renderGradient(t,e={}){const i=e.width??260,r=e.height??160,s=e.background??"#ffffff",a=e.angle??0,o=e.shift??0,c=`${-i/2} ${-r/2} ${i} ${r}`,l=z.nextGradientId(t),h=z.resolveGradientColors(e),u=z.renderGradientDef(l,t,h,a,o,i,r);return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${c}" width="${i}" height="${r}">`,z.renderBackground(i,r,s),"<defs>",u,"</defs>",`<rect x="${-i/2}" y="${-r/2}" width="${i}" height="${r}" fill="url(#${l})" />`,"</svg>"].join("")}};z.EPSILON=1e-9,z.gradientIdCounter=0;let Ls=z;function tu(n){if(!n||n.length===0)return;const t=j0(n);if(t)return Ts(t,"image/bmp")}function z0(n){if(!(!n||n.length===0))return n.length>=8&&n[0]===137&&n[1]===80&&n[2]===78&&n[3]===71?Ts(n,"image/png"):n.length>=3&&n[0]===255&&n[1]===216&&n[2]===255?Ts(n,"image/jpeg"):tu(n)}function Ts(n,t){let e="";for(let i=0;i<n.length;i++)e+=String.fromCharCode(n[i]);return`data:${t};base64,${btoa(e)}`}function j0(n){if(n.length>=14&&n[0]===66&&n[1]===77)return n;if(n.length<40)return;const t=new DataView(n.buffer,n.byteOffset,n.byteLength),e=t.getUint32(0,!0);if(e<12||e>n.length)return;const i=t.getUint16(14,!0),r=t.getUint32(32,!0),s=i<=8?r>0?r:1<<i:r>0?r:0,a=e===12?s*3:s*4,o=14+e+a;if(o>14+n.length)return;const c=14+n.length,l=new Uint8Array(14),h=new DataView(l.buffer);l[0]=66,l[1]=77,h.setUint32(2,c,!0),h.setUint32(6,0,!0),h.setUint32(10,o,!0);const u=new Uint8Array(c);return u.set(l,0),u.set(n,14),u}var $n=(n=>(n[n.AtLeast=1]="AtLeast",n[n.Exactly=2]="Exactly",n))($n||{});const Ta=class Ta extends H{get dxfTypeName(){return"DIMENSION"}constructor(){super(),this._dimBlockId=null,this._dimBlockPosition=new y,this._dxfDefinitionPoint=new y,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new y,this._textRotation=0,this._horizontalRotation=0,this._dimensionType=0,this._attachmentPoint=exports.AcGiMTextAttachmentPoint.MiddleCenter,this._dxfVersion=0,this._normal=new w(0,0,1),this._dimBlockRotation=0}get dimBlockId(){return this._dimBlockId}set dimBlockId(t){this._dimBlockId=t}get dimBlockPosition(){return this._dimBlockPosition}set dimBlockPosition(t){this._dimBlockPosition.copy(t)}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(t){this._dimensionStyleName=t,this._dimStyle=void 0}get dimensionStyle(){if(this._dimStyle==null){let t;this.dimensionStyleName&&(t=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),t==null&&(t=new Tt),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 horizontalRotation(){return this._horizontalRotation}set horizontalRotation(t){this._horizontalRotation=t}get dimensionType(){return this._dimensionType}set dimensionType(t){this._dimensionType=t}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get dxfVersion(){return this._dxfVersion}set dxfVersion(t){this._dxfVersion=t}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}get properties(){return this.getBaseProperties()}getBaseProperties(){return{type:this.type,groups:[this.getGeneralProperties(),this.getDimensionProperties()]}}transformBy(t){const e=this._textPosition.clone(),i=this._textPosition.clone().add(new w(Math.cos(this._textRotation),Math.sin(this._textRotation),0));this._dimBlockPosition.applyMatrix4(t),this._textPosition.applyMatrix4(t),this._normal.transformDirection(t);const r=new w(1,0,0).transformDirection(t);r.lengthSq()>0&&(this._dimBlockRotation+=Math.atan2(r.y,r.x)),e.applyMatrix4(t),i.applyMatrix4(t);const s=new w(i).sub(e);return s.lengthSq()>0&&(this._textRotation=Math.atan2(s.y,s.x)),this.subTransformBy(t),this}subGetOsnapPoints(t,e,i,r,s){const a=this.getDimBlockTableRecord();if(!a)return;const o=this.getFullDimBlockTransform(),c=new y(e).applyMatrix4(o.clone().invert()),l=new y(i).applyMatrix4(o.clone().invert()),h=(u,d)=>{const g=[];u.subGetOsnapPoints(t,c,l,g,d,o),u instanceof Jt?g.forEach(p=>r.push(p.clone())):g.forEach(p=>r.push(new y(p).applyMatrix4(o)))};if(s){const u=a.getIdAt(s);if(u&&(h(u,s),r.length>0))return}for(const u of a.newIterator())h(u)}subWorldDraw(t){const e=this.getDimBlockTableRecord();if(e){const r=this.computeDimBlockTransform();return Se.instance.draw(t,e,this.resolvedColor,[],!1,r,this._normal)}return t.group([])}getDimBlockGeometricExtents(){const t=new Y,e=this.getDimBlockTableRecord();if(!e)return t;for(const i of e.newIterator())t.union(i.geometricExtents);return t.applyMatrix4(this.getFullDimBlockTransform()),t}getGeometricExtentsFromDimBlockOrPoints(t){const e=this.getDimBlockGeometricExtents();if(!e.isEmpty())return e;const i=new Y;for(const r of t)i.expandByPoint(r);return this.hasExplicitTextPosition()&&i.expandByPoint(this.textPosition),i}hasExplicitTextPosition(){const{x:t,y:e,z:i}=this.textPosition;return t!==0||e!==0||i!==0}collectDimensionDefinitionGripPoints(){return[]}subGetGripPoints(){return this.collectDimensionDefinitionGripPoints().concat([this.textPosition])}subMoveGripPointsAt(t,e){const i=this.collectDimensionDefinitionGripPoints();return ht(t,r=>{r>=0&&r<i.length?i[r].add(e):r===i.length&&this.textPosition.add(e)}),this}getDimBlockTableRecord(){return this.dimBlockId?this.database.tables.blockTable.getAt(this.dimBlockId):void 0}getDimensionProperties(){return{groupName:"dimension",properties:[this.createProperty("dimensionStyleName","string",()=>this.dimensionStyleName??"",t=>{this.dimensionStyleName=t.trim()===""?null:t}),this.createProperty("dimensionText","string",()=>this.dimensionText??"",t=>{this.dimensionText=t}),this.createProperty("measurement","float",()=>this.getMeasurementPropertyValue()),this.createProperty("dimBlockId","string",()=>this.dimBlockId??""),...this.createPoint3dProperties("dimBlockPosition",()=>this.dimBlockPosition),...this.createPoint3dProperties("textPosition",()=>this.textPosition),this.createProperty("textRotation","float",()=>this.textRotation,t=>{this.textRotation=t}),this.createProperty("textLineSpacingFactor","float",()=>this.textLineSpacingFactor,t=>{this.textLineSpacingFactor=t}),this.createProperty("textLineSpacingStyle","enum",()=>this.textLineSpacingStyle,t=>{this.textLineSpacingStyle=t},[{label:$n[1],value:1},{label:$n[2],value:2}]),...this.createPoint3dProperties("normal",()=>this.normal)]}}createProperty(t,e,i,r,s){return{name:t,type:e,editable:r!=null,options:s,accessor:r?{get:i,set:r}:{get:i}}}createPoint3dProperties(t,e){return[this.createProperty(`${t}X`,"float",()=>e().x,i=>{e().x=i}),this.createProperty(`${t}Y`,"float",()=>e().y,i=>{e().y=i}),this.createProperty(`${t}Z`,"float",()=>e().z,i=>{e().z=i})]}getMeasurementPropertyValue(){return this.measurement}getFullDimBlockTransform(){const t=this.computeDimBlockTransform();if(this._normal.x===0&&this._normal.y===0&&this._normal.z===1)return t;const e=new D().setFromExtrusionDirection(this._normal);return new D().multiplyMatrices(e,t)}get arrowScaleFactor(){return this.dimensionStyle.dimasz}get firstArrowStyle(){return{type:this.firstArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse1==0}}get secondArrowStyle(){return{type:this.secondArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse2==0}}get isAppendArrow(){return!0}get firstArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk1}get firstArrowType(){const t=this.firstArrowTypeBtrId;return this.getArrowName(t)}get secondArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk2}get secondArrowType(){const t=this.secondArrowTypeBtrId;return this.getArrowName(t)}get arrowLineCount(){return 1}findPointOnLine1(t,e,i){const r=new y().subVectors(e,t).normalize();return new y(e).addScaledVector(r,i)}findPointOnLine2(t,e,i){const r=t.x+i*Math.cos(e),s=t.y+i*Math.sin(e);return{x:r,y:s}}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():exports.AcGiArrowType.Closed}computeDimBlockTransform(){const t=this.dimBlockId?this.database.tables.blockTable.getAt(this.dimBlockId):void 0,e=(t==null?void 0:t.origin)??y.ORIGIN,i=new D().makeTranslation(-e.x,-e.y,-e.z),r=new D().makeTranslation(this._dimBlockPosition.x,this._dimBlockPosition.y,this._dimBlockPosition.z),s=new D().makeRotationZ(this._dimBlockRotation);return new D().multiplyMatrices(r,new D().multiplyMatrices(s,i))}subTransformBy(t){}dxfOutFields(t){super.dxfOutFields(t);const e=this.dimensionStyleName!=null?this.database.tables.dimStyleTable.getAt(this.dimensionStyleName):void 0;return t.writeSubclassMarker("AcDbDimension"),t.writeInt16(280,this.dxfVersion),t.writeString(2,this.dimBlockId??void 0),t.writeString(3,this.dimensionStyleName??this.dimensionStyle.name),t.writePoint3d(10,this._dxfDefinitionPoint),t.writeString(1,this.dimensionText??""),t.writeAngle(53,this.textRotation),this.horizontalRotation!==0&&t.writeAngle(51,this.horizontalRotation),t.writePoint3d(11,this.textPosition),t.writeInt16(70,this.dimensionType),t.writeInt16(71,this.attachmentPoint),t.writeInt16(72,this.textLineSpacingStyle),t.writeDouble(41,this.textLineSpacingFactor),t.writeDouble(42,this.measurement),t.writeVector3d(210,this.normal),t.writeObjectId(340,e==null?void 0:e.objectId),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbDimension");let e=this._dxfDefinitionPoint.x,i=this._dxfDefinitionPoint.y,r=this._dxfDefinitionPoint.z,s=this.textPosition.x,a=this.textPosition.y,o=this.textPosition.z,c=this.textRotation*180/Math.PI,l=this.normal.x,h=this.normal.y,u=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const d=t.readItem();if(!d)break;const g=Number(d.code),p=Number(d.value);if(g===100){t.pushBackItem(d);break}switch(g){case 1:this.dimensionText=String(d.value);break;case 2:this.dimBlockId=String(d.value);break;case 3:this.dimensionStyleName=String(d.value);break;case 10:e=p;break;case 20:i=p;break;case 30:r=p;break;case 11:s=p;break;case 21:a=p;break;case 31:o=p;break;case 41:this.textLineSpacingFactor=p;break;case 42:this.measurement=p;break;case 53:c=p;break;case 51:this.horizontalRotation=C.degToRad(p);break;case 70:this.dimensionType=p;break;case 71:this.attachmentPoint=p;break;case 72:this.textLineSpacingStyle=p;break;case 210:l=p;break;case 220:h=p;break;case 230:u=p;break;case 280:this.dxfVersion=p;break}}return this._dxfDefinitionPoint.set(e,i,r),this.textPosition.copy(new y(s,a,o)),this.textRotation=c*Math.PI/180,this.normal.copy(new w(l,h,u)),this}};Ta.typeName="Dimension";let de=Ta;const Ca=class Ca extends de{constructor(t,e,i,r,s=null,a=null){super(),this._centerPoint=new y().copy(t),this._xLine1Point=new y().copy(e),this._xLine2Point=new y().copy(i),this._arcPoint=new y().copy(r),this.dimensionText=s,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 properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("centerPoint",()=>this.centerPoint),...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("arcPoint",()=>this.arcPoint)]}]}}collectDimensionDefinitionGripPoints(){return[this.centerPoint,this.xLine1Point,this.xLine2Point,this.arcPoint]}subTransformBy(t){this._arcPoint.applyMatrix4(t),this._centerPoint.applyMatrix4(t),this._xLine1Point.applyMatrix4(t),this._xLine2Point.applyMatrix4(t)}get geometricExtents(){return this.getGeometricExtentsFromDimBlockOrPoints([this.xLine1Point,this.xLine2Point,this.centerPoint,this.arcPoint])}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}dxfInFields(t){super.dxfInFields(t);const e=t.peekItem();let i=!1;if(e&&Number(e.code)===100){const O=String(e.value);O==="AcDb2LineAngularDimension"?(i=!0,t.atSubclassData("AcDb2LineAngularDimension")):O==="AcDb3PointAngularDimension"&&t.atSubclassData("AcDb3PointAngularDimension")}let r=this.xLine1Point.x,s=this.xLine1Point.y,a=this.xLine1Point.z,o=this.xLine2Point.x,c=this.xLine2Point.y,l=this.xLine2Point.z,h=this.centerPoint.x,u=this.centerPoint.y,d=this.centerPoint.z,g=this.arcPoint.x,p=this.arcPoint.y,f=this.arcPoint.z,m=!1,b=r,_=s,v=a,x=o,S=c,P=l;const E=()=>{if(i){this.xLine1Point=new y(r,s,a),this.xLine2Point=new y(h,u,d);const O=V0({x:r,y:s},{x:b,y:_},{x:h,y:u},{x,y:S});O?this.centerPoint=new y(O.x,O.y,(a+P)/2):this.centerPoint=new y(b,_,v),this.arcPoint=new y(this._dxfDefinitionPoint.x,this._dxfDefinitionPoint.y,this._dxfDefinitionPoint.z);return}this.xLine1Point=new y(r,s,a),this.xLine2Point=new y(o,c,l),this.centerPoint=new y(h,u,d),m?this.arcPoint=new y(g,p,f):this.arcPoint=new y(this._dxfDefinitionPoint.x,this._dxfDefinitionPoint.y,this._dxfDefinitionPoint.z)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const O=t.readItem();if(!O)break;const T=Number(O.code),R=Number(O.value);switch(T){case 13:r=R;break;case 23:s=R;break;case 33:a=R;break;case 14:i?b=R:o=R;break;case 24:i?_=R:c=R;break;case 34:i?v=R:l=R;break;case 15:h=R;break;case 25:u=R;break;case 35:d=R;break;case 16:i?x=R:(g=R,m=!0);break;case 26:i?S=R:(p=R,m=!0);break;case 36:i?P=R:(f=R,m=!0);break}}return E(),this}};Ca.typeName="3PointAngularDimension";let qn=Ca;function V0(n,t,e,i){const r=t.x-n.x,s=t.y-n.y,a=i.x-e.x,o=i.y-e.y,c=r*o-s*a;if(Math.abs(c)<1e-12)return null;const l=((e.x-n.x)*o-(e.y-n.y)*a)/c;return{x:n.x+l*r,y:n.y+l*s}}const Ma=class Ma extends de{constructor(t,e,i,r=null,s=null){super(),this._dimLinePoint=new y().copy(i),this._xLine1Point=new y().copy(t),this._xLine2Point=new y().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=s}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(t){this._dimLinePoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("dimLinePoint",()=>this.dimLinePoint),this.createProperty("rotation","float",()=>this.rotation,e=>{this.rotation=e}),this.createProperty("oblique","float",()=>this.oblique,e=>{this.oblique=e})]}]}}collectDimensionDefinitionGripPoints(){return[this.xLine1Point,this.xLine2Point,this.dimLinePoint]}subMoveGripPointsAt(t,e){return super.subMoveGripPointsAt(t,e),this.calculateRotation(),this}subTransformBy(t){this._dimLinePoint.applyMatrix4(t),this._xLine1Point.applyMatrix4(t),this._xLine2Point.applyMatrix4(t),this.calculateRotation()}get geometricExtents(){return this.getGeometricExtentsFromDimBlockOrPoints([this.xLine1Point,this.xLine2Point,this.dimLinePoint])}get isAppendArrow(){return!1}createDimBlock(t){const e=new tt;e.name=t;const i=this.createLines();i.forEach(o=>e.appendEntity(new Yi(o.startPoint,o.endPoint))),this.createArrows(i[0]).forEach(o=>e.appendEntity(o));const s=i[0].midPoint,a=this.createMText(s,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 Pe;return r.attachmentPoint=this.attachmentPoint,r.layer="0",r.color=new X(exports.AcCmColorMethod.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",s=new Jt(r);return s.position=t,s.rotation=e,s.scaleFactors={x:i,y:i,z:i},s}createLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),i=this.createExtensionLine(this._xLine2Point),r=this.findIntersectionPoint(e,this._dimLinePoint),s=this.findIntersectionPoint(i,this._dimLinePoint),a=new ue(r,s);return t.push(a),e.endPoint=r,this.adjustExtensionLine(e),t.push(e),i.endPoint=s,this.adjustExtensionLine(i),t.push(i),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,i=this.findPointOnLine2(t,e,100);return new ue(t,{...i,z:t.z})}findIntersectionPoint(t,e){const i=t.startPoint,r=t.endPoint,s=new w().subVectors(r,i).normalize(),o=new w().subVectors(e,i).dot(s),c=new w().copy(s).multiplyScalar(o);return new w().addVectors(i,c)}calculateRotation(){const t=this._xLine1Point,e=this._xLine2Point,i=e.x-t.x,r=e.y-t.y;this._rotation=Math.atan2(r,i)}get dxfSubclassMarker(){return"AcDbAlignedDimension"}getMeasurementPropertyValue(){return this.measurement??this.xLine1Point.distanceTo(this.xLine2Point)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker(this.dxfSubclassMarker),t.writePoint3d(13,this.xLine1Point),t.writePoint3d(14,this.xLine2Point),t.writePoint3d(15,this.dimLinePoint),t.writeAngle(50,this.rotation),t.writeAngle(52,this.oblique),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData(this.dxfSubclassMarker);let e=this.xLine1Point.x,i=this.xLine1Point.y,r=this.xLine1Point.z,s=this.xLine2Point.x,a=this.xLine2Point.y,o=this.xLine2Point.z,c=this.dimLinePoint.x,l=this.dimLinePoint.y,h=this.dimLinePoint.z,u=this.rotation*180/Math.PI,d=this.oblique*180/Math.PI,g=this.dimBlockPosition.x,p=this.dimBlockPosition.y,f=this.dimBlockPosition.z,m=!1,b=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const _=t.readItem();if(!_)break;const v=Number(_.code),x=Number(_.value);switch(v){case 12:g=x,m=!0;break;case 22:p=x,m=!0;break;case 32:f=x,m=!0;break;case 13:e=x;break;case 23:i=x;break;case 33:r=x;break;case 14:s=x;break;case 24:a=x;break;case 34:o=x;break;case 15:c=x,b=!0;break;case 25:l=x,b=!0;break;case 35:h=x,b=!0;break;case 50:u=x;break;case 52:d=x;break;case 100:return t.pushBackItem(_),this.finishAlignedDxfIn(e,i,r,s,a,o,c,l,h,u,d,g,p,f,m,b),this}}return this.finishAlignedDxfIn(e,i,r,s,a,o,c,l,h,u,d,g,p,f,m,b),this}finishAlignedDxfIn(t,e,i,r,s,a,o,c,l,h,u,d,g,p,f,m){this.xLine1Point={x:t,y:e,z:i},this.xLine2Point={x:r,y:s,z:a},m?this.dimLinePoint={x:o,y:c,z:l}:this.dimLinePoint={x:this._dxfDefinitionPoint.x,y:this._dxfDefinitionPoint.y,z:this._dxfDefinitionPoint.z},this.rotation=h*Math.PI/180,this.oblique=u*Math.PI/180,f&&(this.dimBlockPosition={x:d,y:g,z:p})}};Ma.typeName="AlignedDimension";let si=Ma;const Oa=class Oa extends de{constructor(t,e,i,r,s=null,a=null){super(),this._arcPoint=new y().copy(r),this._xLine1Point=new y().copy(e),this._xLine2Point=new y().copy(i),this._centerPoint=new y().copy(t),this.dimensionText=s,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 properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("centerPoint",()=>this.centerPoint),...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("arcPoint",()=>this.arcPoint)]}]}}collectDimensionDefinitionGripPoints(){return[this.centerPoint,this.xLine1Point,this.xLine2Point,this.arcPoint]}subTransformBy(t){this._arcPoint.applyMatrix4(t),this._centerPoint.applyMatrix4(t),this._xLine1Point.applyMatrix4(t),this._xLine2Point.applyMatrix4(t)}get geometricExtents(){return this.getGeometricExtentsFromDimBlockOrPoints([this.xLine1Point,this.xLine2Point,this.centerPoint,this.arcPoint])}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}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbArcDimension");let e=this.xLine1Point.x,i=this.xLine1Point.y,r=this.xLine1Point.z,s=this.xLine2Point.x,a=this.xLine2Point.y,o=this.xLine2Point.z,c=this.centerPoint.x,l=this.centerPoint.y,h=this.centerPoint.z,u=this.arcPoint.x,d=this.arcPoint.y,g=this.arcPoint.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const p=t.readItem();if(!p)break;const f=Number(p.code),m=Number(p.value);switch(f){case 13:e=m;break;case 23:i=m;break;case 33:r=m;break;case 14:s=m;break;case 24:a=m;break;case 34:o=m;break;case 15:c=m;break;case 25:l=m;break;case 35:h=m;break;case 16:u=m;break;case 26:d=m;break;case 36:g=m;break}}return this.xLine1Point=new y(e,i,r),this.xLine2Point=new y(s,a,o),this.centerPoint=new y(c,l,h),this.arcPoint=new y(u,d,g),this}};Oa.typeName="ArcDimension";let Kn=Oa;const Na=class Na extends de{constructor(t,e,i=0,r=null,s=null){super(),this._chordPoint=new y().copy(t),this._farChordPoint=new y().copy(e),this._extArcStartAngle=0,this._extArcEndAngle=0,this._leaderLength=i,this.dimensionText=r,this.dimensionStyleName=s}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get farChordPoint(){return this._farChordPoint}set farChordPoint(t){this._farChordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}set leaderLength(t){this._leaderLength=t}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("chordPoint",()=>this.chordPoint),...this.createPoint3dProperties("farChordPoint",()=>this.farChordPoint),this.createProperty("leaderLength","float",()=>this.leaderLength,e=>{this.leaderLength=e}),this.createProperty("extArcStartAngle","float",()=>this.extArcStartAngle,e=>{this.extArcStartAngle=e}),this.createProperty("extArcEndAngle","float",()=>this.extArcEndAngle,e=>{this.extArcEndAngle=e})]}]}}collectDimensionDefinitionGripPoints(){return[this.chordPoint,this.farChordPoint]}subTransformBy(t){this._chordPoint.applyMatrix4(t),this._farChordPoint.applyMatrix4(t)}getMeasurementPropertyValue(){return this.measurement??this.chordPoint.distanceTo(this.farChordPoint)}get geometricExtents(){const t=[this.chordPoint,this.farChordPoint];if(this.leaderLength>0){const e=this.farChordPoint.clone().sub(this.chordPoint);e.lengthSq()>0&&(e.normalize().multiplyScalar(this.leaderLength),t.push(this.farChordPoint.clone().add(e)))}return this.getGeometricExtentsFromDimBlockOrPoints(t)}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}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbDiametricDimension");let e=this._dxfDefinitionPoint.x,i=this._dxfDefinitionPoint.y,r=this._dxfDefinitionPoint.z,s=this.farChordPoint.x,a=this.farChordPoint.y,o=this.farChordPoint.z,c=!1,l=!1,h=this.extArcStartAngle*180/Math.PI,u=this.extArcEndAngle*180/Math.PI;const d=()=>{l?(this.chordPoint=new y(e,i,r),this.farChordPoint=new y(s,a,o)):c&&(this.chordPoint=new y(this._dxfDefinitionPoint.x,this._dxfDefinitionPoint.y,this._dxfDefinitionPoint.z),this.farChordPoint=new y(e,i,r)),this.extArcStartAngle=h*Math.PI/180,this.extArcEndAngle=u*Math.PI/180};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const g=t.readItem();if(!g)break;const p=Number(g.code),f=Number(g.value);switch(p){case 15:e=f,c=!0;break;case 25:i=f,c=!0;break;case 35:r=f,c=!0;break;case 16:s=f,l=!0;break;case 26:a=f,l=!0;break;case 36:o=f,l=!0;break;case 40:this.leaderLength=f;break;case 52:h=f;break;case 53:u=f;break}}return d(),this}};Na.typeName="DiametricDimension";let Zn=Na;const Ra=class Ra extends de{constructor(t,e,i=null,r=null){super(),this._definingPoint=new y().copy(t),this._leaderEndPoint=new y().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 properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("definingPoint",()=>this.definingPoint),...this.createPoint3dProperties("leaderEndPoint",()=>this.leaderEndPoint)]}]}}collectDimensionDefinitionGripPoints(){return[this.definingPoint,this.leaderEndPoint]}subTransformBy(t){this._definingPoint.applyMatrix4(t),this._leaderEndPoint.applyMatrix4(t)}get geometricExtents(){return this.getGeometricExtentsFromDimBlockOrPoints([this.definingPoint,this.leaderEndPoint])}get arrowLineCount(){return 0}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbOrdinateDimension"),t.writePoint3d(13,this.definingPoint),t.writePoint3d(14,this.leaderEndPoint),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbOrdinateDimension");let e=this.definingPoint.x,i=this.definingPoint.y,r=this.definingPoint.z,s=this.leaderEndPoint.x,a=this.leaderEndPoint.y,o=this.leaderEndPoint.z;const c=()=>{this.definingPoint=new y(e,i,r),this.leaderEndPoint=new y(s,a,o)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const l=t.readItem();if(!l)break;const h=Number(l.code),u=Number(l.value);switch(h){case 13:e=u;break;case 23:i=u;break;case 33:r=u;break;case 14:s=u;break;case 24:a=u;break;case 34:o=u;break}}return c(),this}};Ra.typeName="OrdinateDimension";let Qn=Ra;const Ba=class Ba extends de{constructor(t,e,i,r=null,s=null){super(),this._center=new y().copy(t),this._chordPoint=new y().copy(e),this._leaderLength=i,this._extArcStartAngle=0,this._extArcEndAngle=0,this.dimensionText=r,this.dimensionStyleName=s}get center(){return this._center}set center(t){this._center.copy(t)}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}set leaderLength(t){this._leaderLength=t}set leaderLenght(t){this._leaderLength=t}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("center",()=>this.center),...this.createPoint3dProperties("chordPoint",()=>this.chordPoint),this.createProperty("leaderLength","float",()=>this.leaderLength,e=>{this.leaderLength=e}),this.createProperty("extArcStartAngle","float",()=>this.extArcStartAngle,e=>{this.extArcStartAngle=e}),this.createProperty("extArcEndAngle","float",()=>this.extArcEndAngle,e=>{this.extArcEndAngle=e})]}]}}collectDimensionDefinitionGripPoints(){return[this.center,this.chordPoint]}subTransformBy(t){this._center.applyMatrix4(t),this._chordPoint.applyMatrix4(t)}getMeasurementPropertyValue(){return this.measurement??this.center.distanceTo(this.chordPoint)}get geometricExtents(){const t=[this.center,this.chordPoint];if(this.leaderLength>0){const e=this.chordPoint.clone().sub(this.center);e.lengthSq()>0&&(e.normalize().multiplyScalar(this.leaderLength),t.push(this.chordPoint.clone().add(e)))}return this.getGeometricExtentsFromDimBlockOrPoints(t)}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}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbRadialDimension");const e=this._dxfDefinitionPoint.x,i=this._dxfDefinitionPoint.y,r=this._dxfDefinitionPoint.z;let s=this.chordPoint.x,a=this.chordPoint.y,o=this.chordPoint.z,c=!1,l=this.extArcStartAngle*180/Math.PI,h=this.extArcEndAngle*180/Math.PI;const u=()=>{this.center=new y(e,i,r),this.chordPoint=new y(s,a,o),this.extArcStartAngle=l*Math.PI/180,this.extArcEndAngle=h*Math.PI/180};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const d=t.readItem();if(!d)break;const g=Number(d.code),p=Number(d.value);switch(g){case 15:s=p,c=!0;break;case 25:a=p,c=!0;break;case 35:o=p,c=!0;break;case 13:c||(s=p);break;case 23:c||(a=p);break;case 33:c||(o=p);break;case 40:this.leaderLength=p;break;case 52:l=p;break;case 53:h=p;break}}return u(),this}};Ba.typeName="RadialDimension";let Jn=Ba;const Fa=class Fa extends si{get dxfSubclassMarker(){return"AcDbRotatedDimension"}};Fa.typeName="RotatedDimension";let tr=Fa;class G0{constructor(t){this._pairs=t,this.kind="ascii",this._index=0}next(){if(!(this._index>=this._pairs.length))return this._pairs[this._index++]}peek(){if(!(this._index>=this._pairs.length))return this._pairs[this._index]}position(){return{byteOffset:this._index}}}function eu(n){const t=Number(n.code),e=n.value,i=Wi(t);return i==="comment"?{code:t,type:"string",value:String(e??"")}:i==="bool"?{code:t,type:"bool",value:!!e}:i==="binary"?e instanceof Uint8Array?{code:t,type:"binary",value:e}:{code:t,type:"string",value:String(e??"")}:i==="handle"?{code:t,type:"handle",value:String(e??"")}:i==="int"||i==="long"?{code:t,type:i==="long"?"long":"int",value:Number(e)}:i==="double"?{code:t,type:"double",value:Number(e)}:{code:t,type:"string",value:String(e??"")}}function U0(n){const t=[];for(;!n.atEndOfObject&&!n.atEof&&!n.atExtendedData;){const e=n.readItem();if(!e)break;t.push(eu(e))}return t}const H0=new Set(["AcDbAlignedDimension","AcDbRotatedDimension","AcDb3PointAngularDimension","AcDb2LineAngularDimension","AcDbOrdinateDimension","AcDbRadialDimension","AcDbDiametricDimension","AcDbArcDimension"]);function W0(n){const t=$0(n),e=q0(t),i=K0(e);if(!i)return null;const r=xe.forReading(new G0(t),{database:n.database});return i.dxfIn(r),i}function $0(n){const t=U0(n);for(;!n.atEndOfObject&&!n.atEof;){const e=n.readItem();if(!e)break;if(Number(e.code)===0){n.pushBackItem(e);break}t.push(eu(e))}return t}function q0(n){let t="";for(const e of n)e.code===100&&typeof e.value=="string"&&H0.has(e.value)&&(t=e.value);if(t)return t;for(const e of n)if(e.code===70&&typeof e.value=="number")switch(e.value&15){case 0:return"AcDbRotatedDimension";case 1:return"AcDbAlignedDimension";case 2:return"AcDb2LineAngularDimension";case 3:return"AcDbDiametricDimension";case 4:return"AcDbRadialDimension";case 5:return"AcDb3PointAngularDimension";case 6:return"AcDbOrdinateDimension";case 8:return"AcDbArcDimension"}return"AcDbAlignedDimension"}function K0(n,t){const e=new y;switch(n){case"AcDbRotatedDimension":return new tr(e,e,e);case"AcDbAlignedDimension":return new si(e,e,e);case"AcDb3PointAngularDimension":case"AcDb2LineAngularDimension":return new qn(e,e,e,e);case"AcDbOrdinateDimension":return new Qn(e,e);case"AcDbRadialDimension":return new Jn(e,e,0);case"AcDbDiametricDimension":return new Zn(e,e,0);case"AcDbArcDimension":return new Kn(e,e,e,e);default:return new si(e,e,e)}}var Ue=(n=>(n[n.SimplePoly=0]="SimplePoly",n[n.FitCurvePoly=1]="FitCurvePoly",n[n.QuadSplinePoly=2]="QuadSplinePoly",n[n.CubicSplinePoly=3]="CubicSplinePoly",n))(Ue||{});const Da=class Da extends _t{get dxfTypeName(){return"POLYLINE"}constructor(t,e,i=0,r=!1,s=0,a=0,o=null){super(),this._polyType=t,this._elevation=i;const c=o&&(o==null?void 0:o.length)===e.length,l=e.map((h,u)=>({x:h.x,y:h.y,bulge:c?o[u]:void 0}));this._geo=new q(l,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}get area(){return this._geo.area}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 Y({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 y(i.x,i.y,this._elevation))}return t}subMoveGripPointsAt(t,e){return ht(t,i=>{xi(this._geo.vertices,i,e)}),this}subGetOsnapPoints(t,e,i,r){var c;const s=this._geo,a=this._elevation,o=s.numberOfVertices;if(o!==0)switch(t){case k.EndPoint:for(let l=0;l<o;l++){const h=s.getPointAt(l);r.push(new y(h.x,h.y,a))}break;case k.MidPoint:case k.Nearest:case k.Perpendicular:case k.Tangent:{const l=this.closed?o:o-1,h=[];for(let u=0;u<l;u++){const d=[];Ci(s.getPointAt(u),s.getPointAt((u+1)%o),(c=s.vertices[u])==null?void 0:c.bulge,a,t,e,d),h.push(...d)}if(t===k.MidPoint)r.push(...h);else{const u=Ft(e,h);u&&r.push(u)}break}}}transformBy(t){const e=t.determinant()<0;let i=this._elevation;return this._geo.vertices.forEach(r=>{const s=new y(r.x,r.y,this._elevation).applyMatrix4(t);r.x=s.x,r.y=s.y,i=s.z,e&&r.bulge!=null&&(r.bulge=-r.bulge)}),this._elevation=i,this._geo._boundingBoxNeedsUpdate=!0,this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set: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 y().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}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectPath2d();return e.length<2?1:kt.from2dPoints(e,this.closed).getOffsetSideAtPoint(t)}createOffsetCurve(t){const e=this._geo.offset(t);return e.length===0?null:kt.fromGePolyline(e[0])}collectPath2d(){const t=Math.max(32,this.numberOfVertices*4);return this._geo.getPoints(t)}};Da.typeName="2dPolyline";let er=Da;var Ai=(n=>(n[n.SimplePoly=0]="SimplePoly",n[n.QuadSplinePoly=1]="QuadSplinePoly",n[n.CubicSplinePoly=2]="CubicSplinePoly",n))(Ai||{});const fr=class fr extends _t{get dxfTypeName(){return"POLYLINE"}constructor(t,e,i=!1){super(),this._polyType=t,this._geo=new q(e,i)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get closed(){return this._geo.closed}get area(){return 0}set closed(t){this._geo.closed=t}get numberOfVertices(){return this._geo.numberOfVertices}getPointAt(t){const e=this._geo.vertices[t];return new y(e.x,e.y,e.z||0)}get geometricExtents(){const t=this._geo.vertices.map(e=>new y(e.x,e.y,e.z||0));return new Y().setFromPoints(t)}subGetGripPoints(){const t=new Array;for(let e=0;e<this._geo.numberOfVertices;++e)t.push(this.getPointAt(e));return t}subMoveGripPointsAt(t,e){return ht(t,i=>{this.moveVertexAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){const s=Array.from({length:this._geo.numberOfVertices},(a,o)=>this.getPointAt(o));if(s.length!==0)switch(t){case k.EndPoint:r.push(...s);break;case k.MidPoint:case k.Nearest:case k.Perpendicular:{const a=[];for(let o=0;o<s.length-1;o++){const c=[];li(s[o],s[o+1],t,e,c),a.push(...c)}if(t===k.MidPoint)r.push(...a);else{const o=Ft(e,a);o&&r.push(o)}break}}}transformBy(t){return this._geo.vertices.forEach(e=>{const i=new y(e.x,e.y,e.z||0).applyMatrix4(t);e.x=i.x,e.y=i.y,e.z=i.z}),this._geo._boundingBoxNeedsUpdate=!0,this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=this._geo.vertices.map(i=>new y(i.x,i.y,i.z||0));return 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:r.z}),t.writeInt16(70,32)}return t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDb3dPolyline");let e=this.closed?1:0;return e|=8,this.polyType===1&&(e|=16),this.polyType===2&&(e|=32),t.writeInt16(66,this.numberOfVertices>0?1:0),t.writeInt16(70,e),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectPath2d();return e.length<2?1:kt.from2dPoints(e,this.closed).getOffsetSideAtPoint(t)}createOffsetCurve(t){const e=this._geo.offset(t);if(e.length===0)return null;const i=e[0],r=[];for(let s=0;s<i.numberOfVertices;s++){const a=i.getPointAt(s);r.push(new y(a.x,a.y,this.interpolateZ(a.x,a.y)))}return new fr(this.polyType,r,this.closed)}collectPath2d(){const t=Math.max(32,this.numberOfVertices*4);return this._geo.getPoints(t)}interpolateZ(t,e){const i=this.numberOfVertices;if(i<=0)return 0;let r=1/0,s=this.getPointAt(0).z;const a=this.closed?i:i-1;for(let o=0;o<a;o++){const c=this.getPointAt(o),l=this.getPointAt((o+1)%i),h=l.x-c.x,u=l.y-c.y,d=h*h+u*u;if(d===0)continue;const g=Math.max(0,Math.min(1,((t-c.x)*h+(e-c.y)*u)/d)),p=c.x+h*g,f=c.y+u*g,m=(t-p)**2+(e-f)**2;m<r&&(r=m,s=c.z+(l.z-c.z)*g)}return s}moveVertexAt(t,e){const i=this._geo.vertices[t];if(!i)return;i.x+=e.x,i.y+=e.y;const r=i;r.z=(r.z??0)+(e.z??0)}};fr.typeName="3dPolyline";let ir=fr;class iu{constructor(t){this.position=new y(t.x,t.y,t.z||0)}}class nu{constructor(t){this.vertexIndices=t}}const Ya=class Ya extends _t{get dxfTypeName(){return"POLYLINE"}constructor(t,e){super(),this._vertices=t.map(i=>new iu(i)),this._faces=e.map(i=>new nu(i))}get numberOfVertices(){return this._vertices.length}get numberOfFaces(){return this._faces.length}get closed(){return!1}get area(){return 0}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 Y(new y(0,0,0),new y(0,0,0));let t=Number.MAX_VALUE,e=Number.MAX_VALUE,i=Number.MAX_VALUE,r=-Number.MAX_VALUE,s=-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),s=Math.max(s,o.position.y),a=Math.max(a,o.position.z)}),new Y(new y(t,e,i),new y(r,s,a))}subGetGripPoints(){const t=new Array;return this._vertices.forEach(e=>{t.push(e.position)}),t}subMoveGripPointsAt(t,e){return ht(t,i=>{const r=this._vertices[i];r&&r.position.add(e)}),this}subGetOsnapPoints(t,e,i,r){switch(t){case k.EndPoint:this._vertices.forEach(s=>{r.push(s.position)});break}}transformBy(t){return this._vertices.forEach(e=>{e.position.applyMatrix4(t)}),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._vertices.map(t=>({x:t.position.x,y:t.position.y,z:t.position.z}))}},{name:"faces",type:"array",editable:!1,itemSchema:{properties:[{name:"vertexIndices",type:"array",editable:!1,itemSchema:{properties:[{name:"index",type:"int",editable:!1}]}}]},accessor:{get:()=>this._faces.map(t=>({vertexIndices:t.vertexIndices}))}}]}]}}subWorldDraw(t){const e=[];return this._faces.forEach(i=>{const r=[];if(i.vertexIndices.forEach(s=>{const a=Math.abs(s)-1;a>=0&&a<this._vertices.length&&r.push(this._vertices[a].position)}),r.length>=3)for(let s=0;s<r.length;s++){const a=r[s],o=r[(s+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((s,a)=>{t.writeInt32(10+a,s)})}return t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectLargestFaceBoundary2d();return e.length<2?1:kt.from2dPoints(e,!0).getOffsetSideAtPoint(t)}createOffsetCurve(t){return Ir(this.collectLargestFaceBoundary2d(),!0,t)}collectLargestFaceBoundary2d(){let t=[];for(const e of this._faces){const i=e.vertexIndices.filter(r=>r>=0);i.length>t.length&&(t=i)}return t.length<2?this._vertices.map(e=>new L(e.position.x,e.position.y)):t.map(e=>{const i=this.getVertexAt(e).position;return new L(i.x,i.y)})}};Ya.typeName="PolyFaceMesh";let nr=Ya;class ru{constructor(t){this.position=new y(t.x,t.y,t.z||0)}}const Xa=class Xa extends _t{get dxfTypeName(){return"POLYLINE"}constructor(t,e,i,r=!1,s=!1){super(),this._mCount=t,this._nCount=e,this._closedM=r,this._closedN=s,this._vertices=i.map(a=>new ru(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}get area(){return 0}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 Y(new y(0,0,0),new y(0,0,0));let t=Number.MAX_VALUE,e=Number.MAX_VALUE,i=Number.MAX_VALUE,r=-Number.MAX_VALUE,s=-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),s=Math.max(s,o.position.y),a=Math.max(a,o.position.z)}),new Y(new y(t,e,i),new y(r,s,a))}subGetGripPoints(){const t=new Array;return this._vertices.forEach(e=>{t.push(e.position)}),t}subMoveGripPointsAt(t,e){return ht(t,i=>{const r=this._vertices[i];r&&r.position.add(e)}),this}subGetOsnapPoints(t,e,i,r){switch(t){case k.EndPoint:this._vertices.forEach(s=>{r.push(s.position)});break}}transformBy(t){return this._vertices.forEach(e=>{e.position.applyMatrix4(t)}),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"mCount",type:"float",editable:!1,accessor:{get:()=>this._mCount}},{name:"nCount",type:"float",editable:!1,accessor:{get:()=>this._nCount}},{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._vertices.map(t=>({x:t.position.x,y:t.position.y,z:t.position.z}))}}]},{groupName:"others",properties:[{name:"closedM",type:"boolean",editable:!0,accessor:{get:()=>this._closedM,set:t=>{this._closedM=t}}},{name:"closedN",type:"boolean",editable:!0,accessor:{get:()=>this._closedN,set:t=>{this._closedN=t}}}]}]}}subWorldDraw(t){const e=[];for(let i=0;i<this._mCount;i++)for(let r=0;r<this._nCount;r++){const s=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(s.position),e.push(o.position)}for(let i=0;i<this._nCount;i++)for(let r=0;r<this._mCount;r++){const s=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(s.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}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectBoundary2d();return e.length<2?1:kt.from2dPoints(e,this.isBoundaryClosed()).getOffsetSideAtPoint(t)}createOffsetCurve(t){return Ir(this.collectBoundary2d(),this.isBoundaryClosed(),t)}isBoundaryClosed(){return this._closedM&&this._closedN&&this._mCount>1&&this._nCount>1}collectBoundary2d(){const t=this._mCount,e=this._nCount;if(t<1||e<1)return[];const i=[],r=(s,a)=>{const o=this.getVertexAtMN(s,a).position;i.push(new L(o.x,o.y))};if(t===1){for(let s=0;s<e;s++)r(0,s);return i}if(e===1){for(let s=0;s<t;s++)r(s,0);return i}for(let s=0;s<e;s++)r(0,s);for(let s=1;s<t;s++)r(s,e-1);for(let s=e-2;s>=0;s--)r(t-1,s);for(let s=t-2;s>=1;s--)r(s,0);return i}};Xa.typeName="PolygonMesh";let rr=Xa;const Z0=16,su=128,au=64,zo=5,jo=6;function Q0(n){const t=J0(n),e=tm(n);return im(t,e)}function J0(n){const t={layer:"0",lineType:"ByLayer",flag:0,elevation:0,startWidth:0,endWidth:0,meshM:0,meshN:0,smoothType:0};for(;!n.atEndOfObject&&!n.atEof&&!n.atExtendedData;){const e=n.readItem();if(!e)break;const i=Number(e.code),r=Number(e.value);switch(i){case 5:t.objectId=String(e.value);break;case 330:t.ownerId=String(e.value);break;case 8:t.layer=String(e.value);break;case 6:t.lineType=String(e.value);break;case 62:t.colorIndex=r;break;case 420:t.trueColor=r;break;case 70:t.flag=r;break;case 10:case 20:break;case 30:t.elevation=r;break;case 40:t.startWidth=r;break;case 41:t.endWidth=r;break;case 71:t.meshM=r;break;case 72:t.meshN=r;break;case 75:t.smoothType=r;break}}return t}function tm(n){const t=[];for(;!n.atEof;){const e=n.peekItem();if(!e)break;if(Number(e.code)!==0){n.readItem();continue}const i=String(e.value).toUpperCase();if(i==="SEQEND"){n.readItem(),n.skipToEndOfObject();break}if(i==="ENDSEC"||i==="ENDBLK"||i==="EOF"||i!=="VERTEX")break;n.readItem(),t.push(em(n))}return t}function em(n){const t={x:0,y:0,z:0,bulge:0,flag:0,faces:[]},e=[],i=[];for(;!n.atEndOfObject&&!n.atEof&&!n.atExtendedData;){const s=n.readItem();if(!s)break;const a=Number(s.code),o=Number(s.value);switch(a){case 10:t.x=o,i[0]=Math.trunc(o);break;case 20:t.y=o;break;case 30:t.z=o;break;case 11:i[1]=Math.trunc(o);break;case 12:i[2]=Math.trunc(o);break;case 13:i[3]=Math.trunc(o);break;case 42:t.bulge=o;break;case 70:t.flag=o;break;case 71:e[0]=Math.trunc(o);break;case 72:e[1]=Math.trunc(o);break;case 73:e[2]=Math.trunc(o);break;case 74:e[3]=Math.trunc(o);break}}if(!!(t.flag&su)&&!(t.flag&au)){const s=e.length>0?e:i;t.faces=s.filter(a=>a!==0&&a!=null)}return t}function im(n,t){const e=!!(n.flag&1),i=!!(n.flag&8),r=!!(n.flag&16),s=!!(n.flag&64),a=!!(n.flag&32),o=[],c=[],l=[];for(const u of t)u.flag&Z0||(s&&u.flag&su?u.flag&au?(o.push({x:u.x,y:u.y,z:u.z}),c.push(u.bulge)):u.faces.length>=3&&l.push([...u.faces]):(o.push({x:u.x,y:u.y,z:u.z}),c.push(u.bulge)));let h;if(r)h=new rr(n.meshM,n.meshN,o,e,a);else if(s)h=new nr(o,l);else if(i){let u=Ai.SimplePoly;n.flag&4&&(n.smoothType===jo?u=Ai.CubicSplinePoly:n.smoothType===zo&&(u=Ai.QuadSplinePoly)),h=new ir(u,o,e)}else{let u=Ue.SimplePoly;n.flag&2?u=Ue.FitCurvePoly:n.flag&4&&(n.smoothType===jo?u=Ue.CubicSplinePoly:n.smoothType===zo&&(u=Ue.QuadSplinePoly)),h=new er(u,o,n.elevation,e,n.startWidth,n.endWidth,c)}return nm(h,n),h}function nm(n,t){t.objectId&&(n.objectId=t.objectId),t.ownerId&&(n.ownerId=t.ownerId),n.layer=t.layer,n.lineType=t.lineType,t.colorIndex!=null&&(n.color.colorIndex=t.colorIndex),t.trueColor!=null&&n.color.setRGBValue(t.trueColor)}function ou(n){switch(n.toUpperCase()){case"LINE":return new Yi(new y,new y);case"CIRCLE":return new En(new y,1);case"ARC":return new Pn(new y,1,0,Math.PI/2);case"POINT":return new Yn;case"RAY":return new zn;case"XLINE":return new Wn;case"ELLIPSE":return new Ln(new y,w.Z_AXIS,w.X_AXIS,1,1,0,Math.PI*2);case"SOLID":return new Vn;case"TRACE":return new Vi;case"3DFACE":return new Tn;case"LWPOLYLINE":return new kt;case"INSERT":return new Jt("");case"TEXT":return new ni;case"MTEXT":return new Pe;case"SPLINE":return Gi.fromControlPoints([{x:0,y:0,z:0},{x:1,y:0,z:0},{x:2,y:0,z:0},{x:3,y:0,z:0}],[0,0,0,0,1,1,1,1],void 0,3,!1);case"ATTDEF":return new In;case"ATTRIB":return new Mi;case"SHAPE":return new jn;case"TOLERANCE":return new On;case"LEADER":return new Nn;case"VIEWPORT":return new Un;case"IMAGE":return new ji;case"WIPEOUT":return new Hn;case"ACAD_PROXY_ENTITY":return new Xn;case"OLEFRAME":return new zi;case"OLE2FRAME":return new Dn;case"HATCH":return new Bi;case"MLINE":return new Bn;case"MULTILEADER":case"MLEADER":return new Rn;case"ACAD_TABLE":return new Gn("",1,1);case"3DSOLID":return new Ti("");default:return null}}function Cs(n,t){let e=t;if(e==null){const s=n.readItem();if(!s||Number(s.code)!==0)return s&&n.pushBackItem(s),null;e=String(s.value)}const i=e.toUpperCase();if(i==="POLYLINE")return Q0(n);if(i==="DIMENSION")return W0(n);const r=ou(e);return r?(r.dxfIn(n),r):null}class cu{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(s){const a=Date.now()-i,o=s instanceof Error?s.message:String(s);return{success:!1,error:o,errorCode:o.toLowerCase().includes("timed out")?"worker_timeout":void 0,duration:a}}}async executeInWorker(t,e,i){const r=Date.now();return new Promise((s,a)=>{const o=this.getAvailableWorker(i),c=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(c),this.releaseWorker(o),s(u)},reject:u=>{clearTimeout(c),this.releaseWorker(o),a(u)},timeout:c});const l=u=>{const{id:d,success:g,data:p,error:f,errorCode:m}=u.data;if(d!==t)return;this.cleanupTask(t);const b=Date.now()-r;s(g?{success:!0,data:p,duration:b}:{success:!1,error:f,errorCode:m,duration:b})},h=u=>{this.cleanupTask(t),a(new Error(`Worker error: ${u.message}`))};o.addEventListener("message",l),o.addEventListener("error",h),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(),s={worker:i,isBusy:!0,id:r,createdAt:new Date};return this.workers.set(r,s),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 lu{constructor(t){this.framework=new cu(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function rm(n){return new lu(n)}class sm{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,s){const a={id:t,success:e,data:i,error:r,errorCode:s};try{self.postMessage(a)}catch(o){const c=o instanceof Error?o.message:String(o);self.postMessage({id:t,success:!1,error:c,errorCode:this.classifyPostMessageError(c)})}}classifyPostMessageError(t){const e=t.toLowerCase();return e.includes("out of memory")||e.includes("data cannot be cloned")?"worker_oom":"worker_error"}}var hu=(n=>(n[n.Vertex=0]="Vertex",n[n.CurveFitVertex=1]="CurveFitVertex",n[n.SplineFitVertex=8]="SplineFitVertex",n[n.SplineCtlVertex=9]="SplineCtlVertex",n))(hu||{});const za=class za extends H{get dxfTypeName(){return"VERTEX"}constructor(){super(),this._position=new y,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 Y().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subMoveGripPointsAt(t,e){return te(t,e,this._position),this}subGetOsnapPoints(t,e,i,r){(t===k.EndPoint||t===k.Node)&&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}};za.typeName="2dVertex";let Ms=za;var uu=(n=>(n[n.SimpleVertex=0]="SimpleVertex",n[n.ControlVertex=1]="ControlVertex",n[n.FitVertex=2]="FitVertex",n))(uu||{});const ja=class ja extends H{get dxfTypeName(){return"VERTEX"}constructor(){super(),this._position=new y,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 Y().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subMoveGripPointsAt(t,e){return te(t,e,this._position),this}subGetOsnapPoints(t,e,i,r){(t===k.EndPoint||t===k.Node)&&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}};ja.typeName="3dVertex";let Os=ja;exports.ACAD_APPID=ds;exports.ACAD_LAYERFILTERS_NAME=Sr;exports.ACCM_DEFAULT_UI_YIELD_BUDGET_MS=Pi;exports.ACDB_DXF_MTEXT_CHUNK_CHARS=fi;exports.ACDB_DXF_XDATA_BINARY_MAX_BYTES=jc;exports.ACDB_DXF_XDATA_STRING_MAX_BYTES=zc;exports.ACDB_GRIPCOLOR_DEFAULT=nl;exports.ACDB_GRIPCOLOR_MAX=fs;exports.ACDB_GRIPCOLOR_MIN=gs;exports.ACDB_GRIPHOT_DEFAULT=rl;exports.ACDB_GRIPHOT_MAX=ms;exports.ACDB_GRIPHOT_MIN=ps;exports.ACDB_GRIPOBJLIMIT_MAX=Mg;exports.ACDB_GRIPOBJLIMIT_MIN=Cg;exports.ACDB_GRIPSIZE_DEFAULT=sl;exports.ACDB_GRIPSIZE_MAX=bs;exports.ACDB_GRIPSIZE_MIN=ys;exports.ACDB_GRIPS_MAX=Ng;exports.ACDB_GRIPS_MIN=Og;exports.ACDB_PROXY_GRAPHIC_CHUNK_SIZE=rp;exports.ACGI_DARK_THEME_FOREGROUND=Ei;exports.ACGI_LIGHT_THEME_FOREGROUND=Li;exports.ACGI_MODEL_SPACE_BACKGROUND=Zc;exports.ACGI_PAPER_SPACE_BACKGROUND=_g;exports.ACLY_DICTIONARY_NAME=ri;exports.ACTIVE_VPORT_NAME=ti;exports.AC_DB_SYSTEM_VARIABLE_NAMES=Uf;exports.AcCmColor=X;exports.AcCmColorUtil=$t;exports.AcCmEntityColor=mu;exports.AcCmErrors=Pt;exports.AcCmEventDispatcher=yu;exports.AcCmEventManager=at;exports.AcCmLoader=Ru;exports.AcCmLoadingManager=qo;exports.AcCmObject=rs;exports.AcCmPerformanceCollector=Rs;exports.AcCmTask=Wo;exports.AcCmTaskScheduler=$o;exports.AcCmTransparency=ot;exports.AcCmUiYieldGate=pr;exports.AcDb2dPolyline=er;exports.AcDb2dVertex=Ms;exports.AcDb2dVertexType=hu;exports.AcDb3PointAngularDimension=qn;exports.AcDb3dPolyline=ir;exports.AcDb3dSolid=Ti;exports.AcDb3dVertex=Os;exports.AcDb3dVertexType=uu;exports.AcDbAbstractViewTableRecord=Js;exports.AcDbAlignedDimension=si;exports.AcDbAngleUnits=St;exports.AcDbArc=Pn;exports.AcDbArcDimension=Kn;exports.AcDbAttribute=Mi;exports.AcDbAttributeDefinition=In;exports.AcDbAttributeFlags=dt;exports.AcDbAttributeMTextFlag=Ht;exports.AcDbBaseWorker=sm;exports.AcDbBatchProcessing=Cl;exports.AcDbBlockReference=Jt;exports.AcDbBlockScaling=cl;exports.AcDbBlockTable=wh;exports.AcDbBlockTableRecord=tt;exports.AcDbBlockTableRecordFlag=_i;exports.AcDbChangeApplier=Ch;exports.AcDbChangeRecorder=Mh;exports.AcDbCircle=En;exports.AcDbCodePage=Us;exports.AcDbCurve=_t;exports.AcDbDataGenerator=fh;exports.AcDbDatabase=Ss;exports.AcDbDatabaseConverter=Zs;exports.AcDbDatabaseConverterManager=qt;exports.AcDbDatabaseTransaction=Oh;exports.AcDbDatabaseTransactionManager=Rh;exports.AcDbDiametricDimension=Zn;exports.AcDbDictionary=Nt;exports.AcDbDimArrowType=qh;exports.AcDbDimStyleTable=vh;exports.AcDbDimStyleTableRecord=Tt;exports.AcDbDimTextHorizontal=Ol;exports.AcDbDimTextVertical=Qs;exports.AcDbDimVerticalJustification=Bl;exports.AcDbDimZeroSuppression=Nl;exports.AcDbDimZeroSuppressionAngular=Rl;exports.AcDbDimension=de;exports.AcDbDuplicateRecordCloning=sh;exports.AcDbDwgVersion=pt;exports.AcDbDxfCode=Ns;exports.AcDbDxfDocumentReader=oh;exports.AcDbDxfFiler=xe;exports.AcDbDxfFilerStatus=Hc;exports.AcDbDxfObjectsReader=ah;exports.AcDbEllipse=Ln;exports.AcDbEntity=H;exports.AcDbFace=Tn;exports.AcDbFcf=On;exports.AcDbFileType=wi;exports.AcDbFilter=Jl;exports.AcDbFontNameCollector=ft;exports.AcDbFormatter=ph;exports.AcDbFrame=Fn;exports.AcDbGradientPatternType=gh;exports.AcDbGroup=Ql;exports.AcDbHatch=Bi;exports.AcDbHatchObjectType=dh;exports.AcDbHatchPatternType=vi;exports.AcDbHatchStyle=uh;exports.AcDbHostApplicationServices=Sn;exports.AcDbIndex=eh;exports.AcDbLayerFilter=th;exports.AcDbLayerIndex=ih;exports.AcDbLayerTable=kh;exports.AcDbLayerTableRecord=Zi;exports.AcDbLayout=qi;exports.AcDbLayoutDictionary=Th;exports.AcDbLayoutManager=ml;exports.AcDbLeader=Nn;exports.AcDbLeaderAnnotationType=Bh;exports.AcDbLine=Yi;exports.AcDbLineSpacingStyle=$n;exports.AcDbLinearUnits=rt;exports.AcDbLinetypeTable=Ah;exports.AcDbLinetypeTableRecord=ve;exports.AcDbMLeader=Rn;exports.AcDbMLeaderContentType=Ge;exports.AcDbMLeaderDirectionType=Dh;exports.AcDbMLeaderLineType=ki;exports.AcDbMLeaderStyle=Pr;exports.AcDbMLeaderTextAttachmentDirection=Fh;exports.AcDbMLine=Bn;exports.AcDbMLineFlags=Xh;exports.AcDbMLineJustification=Yh;exports.AcDbMText=Pe;exports.AcDbMlineStyle=ta;exports.AcDbNativeDxfConverter=ch;exports.AcDbObject=bt;exports.AcDbObjectIterator=ei;exports.AcDbOle2Frame=Dn;exports.AcDbOleFrame=zi;exports.AcDbOleObjectType=Uh;exports.AcDbOleTileMode=Hh;exports.AcDbOpenDatabaseError=Di;exports.AcDbOpenMode=ii;exports.AcDbOrdinateDimension=Qn;exports.AcDbOsnapMode=k;exports.AcDbPatParser=sa;exports.AcDbPatSvgRenderer=Ls;exports.AcDbPlotPaperUnits=ll;exports.AcDbPlotRotation=hl;exports.AcDbPlotSettings=pl;exports.AcDbPlotShadePlotResLevel=dl;exports.AcDbPlotShadePlotType=gl;exports.AcDbPlotStdScaleType=fl;exports.AcDbPlotType=ul;exports.AcDbPoint=Yn;exports.AcDbPoly2dType=Ue;exports.AcDbPoly3dType=Ai;exports.AcDbPolyFaceMesh=nr;exports.AcDbPolyFaceMeshFace=nu;exports.AcDbPolyFaceMeshVertex=iu;exports.AcDbPolygonMesh=rr;exports.AcDbPolygonMeshVertex=ru;exports.AcDbPolyline=kt;exports.AcDbPredefinedAcadIsoPat=hh;exports.AcDbPredefinedAcadPat=Mp;exports.AcDbProxyEntity=Xn;exports.AcDbProxyGraphic=xs;exports.AcDbProxyGraphicBitStream=ol;exports.AcDbProxyGraphicByteStream=Mt;exports.AcDbProxyGraphicEndOfBufferError=_e;exports.AcDbProxyGraphicType=zl;exports.AcDbRadialDimension=Jn;exports.AcDbRasterImage=ji;exports.AcDbRasterImageClipBoundaryType=Wh;exports.AcDbRasterImageDef=nh;exports.AcDbRasterImageImageDisplayOpt=$h;exports.AcDbRay=zn;exports.AcDbRegAppTable=Lh;exports.AcDbRegAppTableRecord=Cn;exports.AcDbRegenerator=Ml;exports.AcDbRenderingCache=Se;exports.AcDbResultBuffer=Oe;exports.AcDbRotatedDimension=tr;exports.AcDbShape=jn;exports.AcDbSolid=Vn;exports.AcDbSortentsTable=rh;exports.AcDbSpline=Gi;exports.AcDbSymbolTable=ee;exports.AcDbSymbolTableRecord=ge;exports.AcDbSysVarManager=gt;exports.AcDbSystemVariables=I;exports.AcDbTable=Gn;exports.AcDbText=ni;exports.AcDbTextHorizontalMode=El;exports.AcDbTextStyleTable=Sh;exports.AcDbTextStyleTableRecord=xr;exports.AcDbTextVerticalMode=Ll;exports.AcDbTrace=Vi;exports.AcDbTransaction=ra;exports.AcDbTransactionManager=i0;exports.AcDbUcsTable=Ph;exports.AcDbUcsTableRecord=Dl;exports.AcDbUndoStack=Nh;exports.AcDbUnitsValue=J;exports.AcDbViewTable=Ih;exports.AcDbViewTableRecord=Yl;exports.AcDbViewport=Un;exports.AcDbViewportTable=Eh;exports.AcDbViewportTableRecord=ke;exports.AcDbWipeout=Hn;exports.AcDbWorkerApi=lu;exports.AcDbWorkerManager=cu;exports.AcDbXline=Wn;exports.AcDbXrecord=ea;exports.AcGeArea2d=Vt;exports.AcGeBox2d=yt;exports.AcGeBox3d=Y;exports.AcGeCatmullRomCurve3d=Mc;exports.AcGeCircArc2d=vt;exports.AcGeCircArc3d=Kt;exports.AcGeCurve2d=oi;exports.AcGeEllipseArc2d=me;exports.AcGeEllipseArc3d=An;exports.AcGeEuler=Wu;exports.AcGeGeometryUtil=wt;exports.AcGeLine2d=zt;exports.AcGeLine3d=ue;exports.AcGeLoop2d=bi;exports.AcGeMathUtil=C;exports.AcGeMatrix2d=Ui;exports.AcGeMatrix3d=D;exports.AcGeNurbsCurve=Ct;exports.AcGePlane=js;exports.AcGePoint2d=L;exports.AcGePoint3d=y;exports.AcGePolyline2d=q;exports.AcGeQuaternion=Je;exports.AcGeShape2d=Gs;exports.AcGeSpline3d=jt;exports.AcGeTol=K;exports.AcGeVector2d=nt;exports.AcGeVector3d=w;exports.AcGiContext=yr;exports.AcGiViewport=Jc;exports.AcLyBoolExpr=Vl;exports.AcLyLayerFilter=Ar;exports.AcLyLayerFilterDialogResult=Gl;exports.AcLyLayerFilterTree=le;exports.AcLyLayerGroup=Ul;exports.AcTrStringUtil=Mu;exports.ByBlock=Qt;exports.ByLayer=lt;exports.DEBUG_MODE=Eu;exports.DEFAULT_ACGI_CONTEXT=wg;exports.DEFAULT_GRADIENT_HATCH_NAME=il;exports.DEFAULT_HATCH_PATTERN_IMPERIAL=Sg;exports.DEFAULT_HATCH_PATTERN_METRIC=tl;exports.DEFAULT_LINE_TYPE=we;exports.DEFAULT_MLEADER_STYLE=ce;exports.DEFAULT_MLINE_STYLE=oe;exports.DEFAULT_TEXT_STYLE=Z;exports.DEFAULT_TOL=mr;exports.DEG2RAD=Bs;exports.DefaultLoadingManager=Ko;exports.FLOAT_TOL=ne;exports.HATCH_PATTERN_SOLID=Ce;exports.HATCH_PATTERN_USER=el;exports.MLIGHTCAD_APPID=us;exports.ORIGIN_POINT_2D=Fu;exports.ORIGIN_POINT_3D=zs;exports.RAD2DEG=Fs;exports.RAW_COLOR_TYPE_ACI=kr;exports.RAW_COLOR_TYPE_BY_BLOCK=Oi;exports.RAW_COLOR_TYPE_BY_LAYER=wr;exports.RAW_COLOR_TYPE_RGB=vr;exports.RAW_COLOR_TYPE_WINDOW_BG=Xl;exports.TAU=j;exports.TEMP_OBJECT_ID_PREFIX=be;exports.VPORT_FALLBACK_CENTER_2D=Pg;exports.VPORT_FALLBACK_LLC=Ig;exports.VPORT_FALLBACK_URC=Eg;exports.VPORT_FALLBACK_VIEW_DIR=Lg;exports.VPORT_FALLBACK_VIEW_TARGET=Tg;exports.accmYieldForPaint=Ho;exports.accmYieldToUi=ai;exports.acdbAssignWorkingDatabase=qc;exports.acdbChunkBinaryByMaxBytes=Uc;exports.acdbChunkDxfMTextContents=Vc;exports.acdbChunkUtf8ByMaxBytes=Gc;exports.acdbCollectChangeEntities=As;exports.acdbCreateDxfPairReader=Xc;exports.acdbCreateEntityForDxfIn=ou;exports.acdbCreateWorkerApi=rm;exports.acdbDecodeMLeaderStyleRawColor=Zt;exports.acdbDwgCodePageToEncoding=Nc;exports.acdbDxfInEntity=Cs;exports.acdbDxfInHeader=jl;exports.acdbDxfValueType=Wi;exports.acdbEstimateDatabaseMemory=Y0;exports.acdbFormatMemoryEstimate=X0;exports.acdbGetWorkingDatabase=Kc;exports.acdbHasOsnapMode=Tf;exports.acdbHexStringsToBytes=Ws;exports.acdbHostApplicationServices=yl;exports.acdbIsBinaryDxf=Rc;exports.acdbLayerGroupsToResultBuffer=$l;exports.acdbMakeAsciiDxfPairReader=Hs;exports.acdbMakeBinaryDxfPairReader=Yc;exports.acdbMakeUtf8AsciiDxfPairReader=Dc;exports.acdbMaskToOsnapModes=Ef;exports.acdbOsnapModesToMask=If;exports.acdbParseFilterXRecordData=ql;exports.acdbPeekDxfHeaderInfo=Bc;exports.acdbPreviewIconToDataUrl=tu;exports.acdbReadLayerFilterTree=Hl;exports.acdbResultBufferToLayerGroups=yp;exports.acdbSerializeLayerFilterTree=Wl;exports.acdbSetHostApplicationServicesProvider=$c;exports.acdbSetLayoutManagerFactory=Bg;exports.acdbThumbnailImageToDataUrl=z0;exports.acdbToggleOsnapMode=Lf;exports.acdbWriteFilterXRecordData=Zl;exports.acgeBasisFunction=Ae;exports.acgeCalculateCurveLength=bc;exports.acgeCeilPowerOfTwo=uc;exports.acgeClamp=re;exports.acgeComputeParameterValues=mc;exports.acgeDamp=tc;exports.acgeDegToRad=cc;exports.acgeEuclideanModulo=Ds;exports.acgeEvaluateNurbsPoint=yi;exports.acgeFloorPowerOfTwo=dc;exports.acgeGenerateAveragedKnots=yc;exports.acgeGenerateChordKnots=Ju;exports.acgeGenerateSqrtChordKnots=td;exports.acgeGenerateUUID=Zo;exports.acgeGenerateUniformKnots=Qu;exports.acgeGetOcsAngle=ae;exports.acgeGetOcsReferenceVector=Ii;exports.acgeIntPartLength=Xs;exports.acgeInterpolateControlPoints=rd;exports.acgeInterpolateNurbsCurve=Vs;exports.acgeInverseLerp=Jo;exports.acgeIsBetween=gc;exports.acgeIsBetweenAngle=fc;exports.acgeIsPowerOfTwo=hc;exports.acgeLerp=Ys;exports.acgeMapLinear=Qo;exports.acgeNormalizeAngle=mi;exports.acgePingpong=ec;exports.acgeRadToDeg=lc;exports.acgeRandFloat=sc;exports.acgeRandFloatSpread=ac;exports.acgeRandInt=rc;exports.acgeRelativeEps=pc;exports.acgeSeededRandom=oc;exports.acgeSmootherstep=nc;exports.acgeSmoothstep=ic;exports.acgeTransformOcsPointToWcs=he;exports.acgeTransformWcsPointToOcs=Lt;exports.acgiContrastingForegroundColor=kg;exports.acgiForegroundColorForBackground=vg;exports.acgiIsLightBackground=Qc;exports.acgiResolveSubEntityTraitsRgbFromBackground=Ag;exports.clone=gi;exports.deepClone=ns;exports.defaults=Bt;exports.has=Go;exports.isEmpty=Uo;exports.isEqual=Me;exports.log=pi;exports.setLogLevel=Lu;
17
+ `)}stripInlineComment(t){const e=t.indexOf(";");return e<0?t:t.slice(0,e)}parseHeader(t){const e=t.indexOf(",");if(e<0){const s=t.trim();return s?{name:s,description:""}:null}const i=t.slice(0,e).trim(),r=t.slice(e+1).trim();return i?{name:i,description:r}:null}parseNumber(t){const e=Number(t.trim());return Number.isFinite(e)?e:null}parseLineDescriptor(t,e){const i=t.split(",").map(u=>u.trim()).filter(u=>u.length>0);if(i.length<5)return null;const r=this.parseNumber(i[0]),s=this.parseNumber(i[1]),a=this.parseNumber(i[2]),o=this.parseNumber(i[3]),c=this.parseNumber(i[4]);if(r==null||s==null||a==null||o==null||c==null)return null;const l=i.slice(5),h=[];for(const u of l){const d=this.parseNumber(u);if(d==null)return null;h.push(d)}return{angle:r,originX:s,originY:a,deltaX:o,deltaY:c,dashes:h,sourceLine:e}}flushCurrentPattern(t,e,i){t&&(t.pattern.lines.length===0&&i.push({line:t.headerLine,message:`Pattern "${t.pattern.name}" has no line descriptor.`,source:""}),e.push(t.pattern))}}const j=class j{static nextGradientId(t){return j.gradientIdCounter+=1,`acdb-pat-gradient-${t.toLowerCase()}-${j.gradientIdCounter}`}static packedRgbToCss(t){return`#${(t&16777215).toString(16).padStart(6,"0")}`}static gradientColorToCss(t,e){return typeof t=="number"?j.packedRgbToCss(t):t??e}static applyShadeTint(t,e){const i=M.clamp(e,0,1),r=i<.5?0:16777215,s=i<.5?1-i*2:i*2-1,a=t>>16&255,o=t>>8&255,c=t&255,l=r>>16&255,h=r>>8&255,u=r&255;return Math.round(a+(l-a)*s)*65536+Math.round(o+(h-o)*s)*256+Math.round(c+(u-c)*s)}static resolveGradientColors(t){const e="#2563eb",i="#f8fafc",r=j.gradientColorToCss(t.startColor,e);if(t.oneColorMode&&t.endColor==null){if(typeof t.startColor=="number"){const s=j.applyShadeTint(t.startColor,t.shadeTintValue??.5);return{start:r,end:j.packedRgbToCss(s)}}return{start:r,end:(t.shadeTintValue??.5)<.5?"#000000":"#ffffff"}}return{start:r,end:j.gradientColorToCss(t.endColor,i)}}static renderGradientStops(t){return t.map(e=>`<stop offset="${(M.clamp(e.offset,0,1)*100).toFixed(2)}%" stop-color="${e.color}" />`).join("")}static getGradientVector(t){return{x:Math.cos(t),y:-Math.sin(t)}}static isSolidPattern(t){return t.name.trim().toUpperCase()===Oe}static renderBackground(t,e,i){return`<rect x="${-t/2}" y="${-e/2}" width="${t}" height="${e}" fill="${i}" />`}static estimateUnitScale(t){const e=[];for(const s of t.lines){e.push(Math.abs(s.deltaX),Math.abs(s.deltaY));for(const a of s.dashes)e.push(Math.abs(a))}const i=e.filter(s=>s>j.EPSILON);if(i.length===0)return 1;const r=i.sort((s,a)=>s-a);return r[Math.floor(r.length/2)]||1}static segmentToSvgPath(t){return`M ${t.x1.toFixed(2)} ${(-t.y1).toFixed(2)} L ${t.x2.toFixed(2)} ${(-t.y2).toFixed(2)}`}static buildDashSegments(t,e,i,r,s,a,o){const c=t.dashes;if(c.length===0)return[{x1:r+a*e,y1:s+o*e,x2:r+a*i,y2:s+o*i}];const l=c.reduce((g,p)=>g+Math.abs(p),0);if(l<=j.EPSILON)return[{x1:r+a*e,y1:s+o*e,x2:r+a*i,y2:s+o*i}];const h=[],u=Math.ceil((i-e)/l)+2;let d=e-l;for(let g=0;g<u;g++){let p=d;for(const f of c){const m=Math.abs(f),y=p+m;if(f>0||f===0){const _=M.clamp(p,e,i),v=M.clamp(y,e,i);v>_?h.push({x1:r+a*_,y1:s+o*_,x2:r+a*v,y2:s+o*v}):f===0&&_>=e&&_<=i&&h.push({x1:r+a*(_-.35),y1:s+o*(_-.35),x2:r+a*(_+.35),y2:s+o*(_+.35)})}p=y}d+=l}return h}static renderFamily(t,e){const i=M.degToRad(t.angle),r=Math.cos(i),s=Math.sin(i),a=-s,o=r,c=r*t.deltaX+a*t.deltaY,l=s*t.deltaX+o*t.deltaY,h=Math.hypot(c,l),u=h<=j.EPSILON?1:Math.max(1,Math.ceil(e*2/h)+1),d=Math.floor(u/2),g=-e*1.5,p=e*1.5,f=[];for(let m=-d;m<=d;m++){const y=t.originX+c*m,_=t.originY+l*m,v=j.buildDashSegments(t,g,p,y,_,r,s);for(const x of v)f.push(j.segmentToSvgPath(x))}return`<path d="${f.join(" ")}" fill="none" />`}static renderLinearGradientDef(t,e,i,r,s){const a=j.getGradientVector(e),o=M.clamp(i,-1,1)*r*.5,c=a.x*o,l=a.y*o;return[`<linearGradient id="${t}" gradientUnits="userSpaceOnUse"`,` x1="${(-a.x*r+c).toFixed(2)}"`,` y1="${(-a.y*r+l).toFixed(2)}"`,` x2="${(a.x*r+c).toFixed(2)}"`,` y2="${(a.y*r+l).toFixed(2)}">`,j.renderGradientStops(s),"</linearGradient>"].join("")}static renderRadialGradientDef(t,e,i,r,s){return[`<radialGradient id="${t}" gradientUnits="userSpaceOnUse"`,` cx="${e.toFixed(2)}" cy="${i.toFixed(2)}" r="${r.toFixed(2)}"`,` fx="${e.toFixed(2)}" fy="${i.toFixed(2)}">`,j.renderGradientStops(s),"</radialGradient>"].join("")}static renderGradientDef(t,e,i,r,s,a,o){const c=e.toUpperCase(),l=c.startsWith("INV"),h=c.replace(/^INV/,""),u=l?i.end:i.start,d=l?i.start:i.end,g=Math.hypot(a,o)/2,p=j.getGradientVector(r),f=M.clamp(s,-1,1),m=p.x*f*a*.25,y=p.y*f*o*.25;switch(h){case"CYLINDER":{const _=M.clamp(.5+f*.45,.05,.95);return j.renderLinearGradientDef(t,r,0,g,[{offset:0,color:u},{offset:_,color:d},{offset:1,color:u}])}case"SPHERICAL":return j.renderRadialGradientDef(t,m,y,g,[{offset:0,color:d},{offset:1,color:u}]);case"HEMISPHERICAL":return j.renderRadialGradientDef(t,m+p.x*a*.18,y+p.y*o*.18,g*.92,[{offset:0,color:d},{offset:.72,color:u},{offset:1,color:u}]);case"CURVED":return j.renderRadialGradientDef(t,-p.x*a*.95+m,-p.y*o*.95+y,g*1.65,[{offset:0,color:u},{offset:.55,color:u},{offset:1,color:d}]);case"LINEAR":default:return j.renderLinearGradientDef(t,r,s,g,[{offset:0,color:u},{offset:1,color:d}])}}renderPattern(t,e={}){const i=e.width??260,r=e.height??160,s=e.stroke??"#1f2937",a=e.strokeWidth??1.3,o=e.background??"#ffffff",c=`${-i/2} ${-r/2} ${i} ${r}`;if(j.isSolidPattern(t))return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${c}" width="${i}" height="${r}">`,j.renderBackground(i,r,o),`<rect x="${-i/2}" y="${-r/2}" width="${i}" height="${r}" fill="${s}" />`,"</svg>"].join("");const l=j.estimateUnitScale(t),u=Math.min(i,r)*.18/Math.max(l,j.EPSILON),d={...t,lines:t.lines.map(f=>({...f,originX:f.originX*u,originY:f.originY*u,deltaX:f.deltaX*u,deltaY:f.deltaY*u,dashes:f.dashes.map(m=>m*u)}))},g=Math.hypot(i,r)*.75,p=d.lines.map(f=>j.renderFamily(f,g)).join("");return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${c}" width="${i}" height="${r}">`,j.renderBackground(i,r,o),`<g stroke="${s}" stroke-width="${a.toFixed(2)}" stroke-linecap="round">`,p,"</g>","</svg>"].join("")}renderGradient(t,e={}){const i=e.width??260,r=e.height??160,s=e.background??"#ffffff",a=e.angle??0,o=e.shift??0,c=`${-i/2} ${-r/2} ${i} ${r}`,l=j.nextGradientId(t),h=j.resolveGradientColors(e),u=j.renderGradientDef(l,t,h,a,o,i,r);return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${c}" width="${i}" height="${r}">`,j.renderBackground(i,r,s),"<defs>",u,"</defs>",`<rect x="${-i/2}" y="${-r/2}" width="${i}" height="${r}" fill="url(#${l})" />`,"</svg>"].join("")}};j.EPSILON=1e-9,j.gradientIdCounter=0;let Rs=j;function du(n){if(!n||n.length===0)return;const t=gm(n);if(t)return Bs(t,"image/bmp")}function dm(n){if(!(!n||n.length===0))return n.length>=8&&n[0]===137&&n[1]===80&&n[2]===78&&n[3]===71?Bs(n,"image/png"):n.length>=3&&n[0]===255&&n[1]===216&&n[2]===255?Bs(n,"image/jpeg"):du(n)}function Bs(n,t){let e="";for(let i=0;i<n.length;i++)e+=String.fromCharCode(n[i]);return`data:${t};base64,${btoa(e)}`}function gm(n){if(n.length>=14&&n[0]===66&&n[1]===77)return n;if(n.length<40)return;const t=new DataView(n.buffer,n.byteOffset,n.byteLength),e=t.getUint32(0,!0);if(e<12||e>n.length)return;const i=t.getUint16(14,!0),r=t.getUint32(32,!0),s=i<=8?r>0?r:1<<i:r>0?r:0,a=e===12?s*3:s*4,o=14+e+a;if(o>14+n.length)return;const c=14+n.length,l=new Uint8Array(14),h=new DataView(l.buffer);l[0]=66,l[1]=77,h.setUint32(2,c,!0),h.setUint32(6,0,!0),h.setUint32(10,o,!0);const u=new Uint8Array(c);return u.set(l,0),u.set(n,14),u}var er=(n=>(n[n.AtLeast=1]="AtLeast",n[n.Exactly=2]="Exactly",n))(er||{});const Da=class Da extends H{get dxfTypeName(){return"DIMENSION"}constructor(){super(),this._dimBlockId=null,this._dimBlockPosition=new b,this._dxfDefinitionPoint=new b,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new b,this._textRotation=0,this._horizontalRotation=0,this._dimensionType=0,this._attachmentPoint=exports.AcGiMTextAttachmentPoint.MiddleCenter,this._dxfVersion=0,this._normal=new w(0,0,1),this._dimBlockRotation=0}get dimBlockId(){return this._dimBlockId}set dimBlockId(t){this._dimBlockId=t}get dimBlockPosition(){return this._dimBlockPosition}set dimBlockPosition(t){this._dimBlockPosition.copy(t)}get dimensionStyleName(){return this._dimensionStyleName}set dimensionStyleName(t){this._dimensionStyleName=t,this._dimStyle=void 0}get dimensionStyle(){if(this._dimStyle==null){let t;this.dimensionStyleName&&(t=this.database.tables.dimStyleTable.getAt(this.dimensionStyleName)),t==null&&(t=new Tt),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 horizontalRotation(){return this._horizontalRotation}set horizontalRotation(t){this._horizontalRotation=t}get dimensionType(){return this._dimensionType}set dimensionType(t){this._dimensionType=t}get attachmentPoint(){return this._attachmentPoint}set attachmentPoint(t){this._attachmentPoint=t}get dxfVersion(){return this._dxfVersion}set dxfVersion(t){this._dxfVersion=t}get normal(){return this._normal}set normal(t){this._normal.copy(t).normalize()}get properties(){return this.getBaseProperties()}getBaseProperties(){return{type:this.type,groups:[this.getGeneralProperties(),this.getDimensionProperties()]}}transformBy(t){const e=this._textPosition.clone(),i=this._textPosition.clone().add(new w(Math.cos(this._textRotation),Math.sin(this._textRotation),0));this._dimBlockPosition.applyMatrix4(t),this._textPosition.applyMatrix4(t),this._normal.transformDirection(t);const r=new w(1,0,0).transformDirection(t);r.lengthSq()>0&&(this._dimBlockRotation+=Math.atan2(r.y,r.x)),e.applyMatrix4(t),i.applyMatrix4(t);const s=new w(i).sub(e);return s.lengthSq()>0&&(this._textRotation=Math.atan2(s.y,s.x)),this.subTransformBy(t),this}subGetOsnapPoints(t,e,i,r,s){const a=this.getDimBlockTableRecord();if(!a)return;const o=this.getFullDimBlockTransform(),c=new b(e).applyMatrix4(o.clone().invert()),l=new b(i).applyMatrix4(o.clone().invert()),h=(u,d)=>{const g=[];u.subGetOsnapPoints(t,c,l,g,d,o),u instanceof ee?g.forEach(p=>r.push(p.clone())):g.forEach(p=>r.push(new b(p).applyMatrix4(o)))};if(s){const u=a.getIdAt(s);if(u&&(h(u,s),r.length>0))return}for(const u of a.newIterator())h(u)}subWorldDraw(t){const e=this.getDimBlockTableRecord();if(e){const r=this.computeDimBlockTransform();return Ie.instance.draw(t,e,this.resolvedColor,[],!1,r,this._normal)}return t.group([])}getDimBlockGeometricExtents(){const t=new Y,e=this.getDimBlockTableRecord();if(!e)return t;for(const i of e.newIterator())t.union(i.geometricExtents);return t.applyMatrix4(this.getFullDimBlockTransform()),t}getGeometricExtentsFromDimBlockOrPoints(t){const e=this.getDimBlockGeometricExtents();if(!e.isEmpty())return e;const i=new Y;for(const r of t)i.expandByPoint(r);return this.hasExplicitTextPosition()&&i.expandByPoint(this.textPosition),i}hasExplicitTextPosition(){const{x:t,y:e,z:i}=this.textPosition;return t!==0||e!==0||i!==0}collectDimensionDefinitionGripPoints(){return[]}subGetGripPoints(){return this.collectDimensionDefinitionGripPoints().concat([this.textPosition])}subMoveGripPointsAt(t,e){const i=this.collectDimensionDefinitionGripPoints();return ht(t,r=>{r>=0&&r<i.length?i[r].add(e):r===i.length&&this.textPosition.add(e)}),this}getDimBlockTableRecord(){return this.dimBlockId?this.database.tables.blockTable.getAt(this.dimBlockId):void 0}getDimensionProperties(){return{groupName:"dimension",properties:[this.createProperty("dimensionStyleName","string",()=>this.dimensionStyleName??"",t=>{this.dimensionStyleName=t.trim()===""?null:t}),this.createProperty("dimensionText","string",()=>this.dimensionText??"",t=>{this.dimensionText=t}),this.createProperty("measurement","float",()=>this.getMeasurementPropertyValue()),this.createProperty("dimBlockId","string",()=>this.dimBlockId??""),...this.createPoint3dProperties("dimBlockPosition",()=>this.dimBlockPosition),...this.createPoint3dProperties("textPosition",()=>this.textPosition),this.createProperty("textRotation","float",()=>this.textRotation,t=>{this.textRotation=t}),this.createProperty("textLineSpacingFactor","float",()=>this.textLineSpacingFactor,t=>{this.textLineSpacingFactor=t}),this.createProperty("textLineSpacingStyle","enum",()=>this.textLineSpacingStyle,t=>{this.textLineSpacingStyle=t},[{label:er[1],value:1},{label:er[2],value:2}]),...this.createPoint3dProperties("normal",()=>this.normal)]}}createProperty(t,e,i,r,s){return{name:t,type:e,editable:r!=null,options:s,accessor:r?{get:i,set:r}:{get:i}}}createPoint3dProperties(t,e){return[this.createProperty(`${t}X`,"float",()=>e().x,i=>{e().x=i}),this.createProperty(`${t}Y`,"float",()=>e().y,i=>{e().y=i}),this.createProperty(`${t}Z`,"float",()=>e().z,i=>{e().z=i})]}getMeasurementPropertyValue(){return this.measurement}getFullDimBlockTransform(){const t=this.computeDimBlockTransform();if(this._normal.x===0&&this._normal.y===0&&this._normal.z===1)return t;const e=new D().setFromExtrusionDirection(this._normal);return new D().multiplyMatrices(e,t)}get arrowScaleFactor(){return this.dimensionStyle.dimasz}get firstArrowStyle(){return{type:this.firstArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse1==0}}get secondArrowStyle(){return{type:this.secondArrowType,scale:this.arrowScaleFactor,appended:this.isAppendArrow,visible:this.dimensionStyle.dimse2==0}}get isAppendArrow(){return!0}get firstArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk1}get firstArrowType(){const t=this.firstArrowTypeBtrId;return this.getArrowName(t)}get secondArrowTypeBtrId(){const t=this.dimensionStyle;return t.dimsah==0?t.dimblk:t.dimblk2}get secondArrowType(){const t=this.secondArrowTypeBtrId;return this.getArrowName(t)}get arrowLineCount(){return 1}findPointOnLine1(t,e,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),s=t.y+i*Math.sin(e);return{x:r,y:s}}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():exports.AcGiArrowType.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 D().makeTranslation(-e.x,-e.y,-e.z),r=new D().makeTranslation(this._dimBlockPosition.x,this._dimBlockPosition.y,this._dimBlockPosition.z),s=new D().makeRotationZ(this._dimBlockRotation);return new D().multiplyMatrices(r,new D().multiplyMatrices(s,i))}subTransformBy(t){}dxfOutFields(t){super.dxfOutFields(t);const e=this.dimensionStyleName!=null?this.database.tables.dimStyleTable.getAt(this.dimensionStyleName):void 0;return t.writeSubclassMarker("AcDbDimension"),t.writeInt16(280,this.dxfVersion),t.writeString(2,this.dimBlockId??void 0),t.writeString(3,this.dimensionStyleName??this.dimensionStyle.name),t.writePoint3d(10,this._dxfDefinitionPoint),t.writeString(1,this.dimensionText??""),t.writeAngle(53,this.textRotation),this.horizontalRotation!==0&&t.writeAngle(51,this.horizontalRotation),t.writePoint3d(11,this.textPosition),t.writeInt16(70,this.dimensionType),t.writeInt16(71,this.attachmentPoint),t.writeInt16(72,this.textLineSpacingStyle),t.writeDouble(41,this.textLineSpacingFactor),t.writeDouble(42,this.measurement),t.writeVector3d(210,this.normal),t.writeObjectId(340,e==null?void 0:e.objectId),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbDimension");let e=this._dxfDefinitionPoint.x,i=this._dxfDefinitionPoint.y,r=this._dxfDefinitionPoint.z,s=this.textPosition.x,a=this.textPosition.y,o=this.textPosition.z,c=this.textRotation*180/Math.PI,l=this.normal.x,h=this.normal.y,u=this.normal.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const d=t.readItem();if(!d)break;const g=Number(d.code),p=Number(d.value);if(g===100){t.pushBackItem(d);break}switch(g){case 1:this.dimensionText=String(d.value);break;case 2:this.dimBlockId=String(d.value);break;case 3:this.dimensionStyleName=String(d.value);break;case 10:e=p;break;case 20:i=p;break;case 30:r=p;break;case 11:s=p;break;case 21:a=p;break;case 31:o=p;break;case 41:this.textLineSpacingFactor=p;break;case 42:this.measurement=p;break;case 53:c=p;break;case 51:this.horizontalRotation=M.degToRad(p);break;case 70:this.dimensionType=p;break;case 71:this.attachmentPoint=p;break;case 72:this.textLineSpacingStyle=p;break;case 210:l=p;break;case 220:h=p;break;case 230:u=p;break;case 280:this.dxfVersion=p;break}}return this._dxfDefinitionPoint.set(e,i,r),this.textPosition.copy(new b(s,a,o)),this.textRotation=c*Math.PI/180,this.normal.copy(new w(l,h,u)),this}};Da.typeName="Dimension";let fe=Da;const Ya=class Ya extends fe{constructor(t,e,i,r,s=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=s,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 properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("centerPoint",()=>this.centerPoint),...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("arcPoint",()=>this.arcPoint)]}]}}collectDimensionDefinitionGripPoints(){return[this.centerPoint,this.xLine1Point,this.xLine2Point,this.arcPoint]}subTransformBy(t){this._arcPoint.applyMatrix4(t),this._centerPoint.applyMatrix4(t),this._xLine1Point.applyMatrix4(t),this._xLine2Point.applyMatrix4(t)}get geometricExtents(){return this.getGeometricExtentsFromDimBlockOrPoints([this.xLine1Point,this.xLine2Point,this.centerPoint,this.arcPoint])}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}dxfInFields(t){super.dxfInFields(t);const e=t.peekItem();let i=!1;if(e&&Number(e.code)===100){const C=String(e.value);C==="AcDb2LineAngularDimension"?(i=!0,t.atSubclassData("AcDb2LineAngularDimension")):C==="AcDb3PointAngularDimension"&&t.atSubclassData("AcDb3PointAngularDimension")}let r=this.xLine1Point.x,s=this.xLine1Point.y,a=this.xLine1Point.z,o=this.xLine2Point.x,c=this.xLine2Point.y,l=this.xLine2Point.z,h=this.centerPoint.x,u=this.centerPoint.y,d=this.centerPoint.z,g=this.arcPoint.x,p=this.arcPoint.y,f=this.arcPoint.z,m=!1,y=r,_=s,v=a,x=o,k=c,I=l;const P=()=>{if(i){this.xLine1Point=new b(r,s,a),this.xLine2Point=new b(h,u,d);const C=fm({x:r,y:s},{x:y,y:_},{x:h,y:u},{x,y:k});C?this.centerPoint=new b(C.x,C.y,(a+I)/2):this.centerPoint=new b(y,_,v),this.arcPoint=new b(this._dxfDefinitionPoint.x,this._dxfDefinitionPoint.y,this._dxfDefinitionPoint.z);return}this.xLine1Point=new b(r,s,a),this.xLine2Point=new b(o,c,l),this.centerPoint=new b(h,u,d),m?this.arcPoint=new b(g,p,f):this.arcPoint=new b(this._dxfDefinitionPoint.x,this._dxfDefinitionPoint.y,this._dxfDefinitionPoint.z)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const C=t.readItem();if(!C)break;const T=Number(C.code),R=Number(C.value);switch(T){case 13:r=R;break;case 23:s=R;break;case 33:a=R;break;case 14:i?y=R:o=R;break;case 24:i?_=R:c=R;break;case 34:i?v=R:l=R;break;case 15:h=R;break;case 25:u=R;break;case 35:d=R;break;case 16:i?x=R:(g=R,m=!0);break;case 26:i?k=R:(p=R,m=!0);break;case 36:i?I=R:(f=R,m=!0);break}}return P(),this}};Ya.typeName="3PointAngularDimension";let ir=Ya;function fm(n,t,e,i){const r=t.x-n.x,s=t.y-n.y,a=i.x-e.x,o=i.y-e.y,c=r*o-s*a;if(Math.abs(c)<1e-12)return null;const l=((e.x-n.x)*o-(e.y-n.y)*a)/c;return{x:n.x+l*r,y:n.y+l*s}}const Xa=class Xa extends fe{constructor(t,e,i,r=null,s=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=s}get dimLinePoint(){return this._dimLinePoint}set dimLinePoint(t){this._dimLinePoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get rotation(){return this._rotation}set rotation(t){this._rotation=t}get oblique(){return this._oblique}set oblique(t){this._oblique=t}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("dimLinePoint",()=>this.dimLinePoint),this.createProperty("rotation","float",()=>this.rotation,e=>{this.rotation=e}),this.createProperty("oblique","float",()=>this.oblique,e=>{this.oblique=e})]}]}}collectDimensionDefinitionGripPoints(){return[this.xLine1Point,this.xLine2Point,this.dimLinePoint]}subMoveGripPointsAt(t,e){return super.subMoveGripPointsAt(t,e),this.calculateRotation(),this}subTransformBy(t){this._dimLinePoint.applyMatrix4(t),this._xLine1Point.applyMatrix4(t),this._xLine2Point.applyMatrix4(t),this.calculateRotation()}get geometricExtents(){return this.getGeometricExtentsFromDimBlockOrPoints([this.xLine1Point,this.xLine2Point,this.dimLinePoint])}get isAppendArrow(){return!1}createDimBlock(t){const e=new tt;e.name=t;const i=this.createLines();i.forEach(o=>e.appendEntity(new Gi(o.startPoint,o.endPoint))),this.createArrows(i[0]).forEach(o=>e.appendEntity(o));const s=i[0].midPoint,a=this.createMText(s,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 Ee;return r.attachmentPoint=this.attachmentPoint,r.layer="0",r.color=new X(exports.AcCmColorMethod.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",s=new ee(r);return s.position=t,s.rotation=e,s.scaleFactors={x:i,y:i,z:i},s}createLines(){const t=[],e=this.createExtensionLine(this._xLine1Point),i=this.createExtensionLine(this._xLine2Point),r=this.findIntersectionPoint(e,this._dimLinePoint),s=this.findIntersectionPoint(i,this._dimLinePoint),a=new ge(r,s);return t.push(a),e.endPoint=r,this.adjustExtensionLine(e),t.push(e),i.endPoint=s,this.adjustExtensionLine(i),t.push(i),t}createExtensionLine(t){const e=this.rotation+Math.PI/2,i=this.findPointOnLine2(t,e,100);return new ge(t,{...i,z:t.z})}findIntersectionPoint(t,e){const i=t.startPoint,r=t.endPoint,s=new w().subVectors(r,i).normalize(),o=new w().subVectors(e,i).dot(s),c=new w().copy(s).multiplyScalar(o);return new w().addVectors(i,c)}calculateRotation(){const t=this._xLine1Point,e=this._xLine2Point,i=e.x-t.x,r=e.y-t.y;this._rotation=Math.atan2(r,i)}get dxfSubclassMarker(){return"AcDbAlignedDimension"}getMeasurementPropertyValue(){return this.measurement??this.xLine1Point.distanceTo(this.xLine2Point)}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker(this.dxfSubclassMarker),t.writePoint3d(13,this.xLine1Point),t.writePoint3d(14,this.xLine2Point),t.writePoint3d(15,this.dimLinePoint),t.writeAngle(50,this.rotation),t.writeAngle(52,this.oblique),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData(this.dxfSubclassMarker);let e=this.xLine1Point.x,i=this.xLine1Point.y,r=this.xLine1Point.z,s=this.xLine2Point.x,a=this.xLine2Point.y,o=this.xLine2Point.z,c=this.dimLinePoint.x,l=this.dimLinePoint.y,h=this.dimLinePoint.z,u=this.rotation*180/Math.PI,d=this.oblique*180/Math.PI,g=this.dimBlockPosition.x,p=this.dimBlockPosition.y,f=this.dimBlockPosition.z,m=!1,y=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const _=t.readItem();if(!_)break;const v=Number(_.code),x=Number(_.value);switch(v){case 12:g=x,m=!0;break;case 22:p=x,m=!0;break;case 32:f=x,m=!0;break;case 13:e=x;break;case 23:i=x;break;case 33:r=x;break;case 14:s=x;break;case 24:a=x;break;case 34:o=x;break;case 15:c=x,y=!0;break;case 25:l=x,y=!0;break;case 35:h=x,y=!0;break;case 50:u=x;break;case 52:d=x;break;case 100:return t.pushBackItem(_),this.finishAlignedDxfIn(e,i,r,s,a,o,c,l,h,u,d,g,p,f,m,y),this}}return this.finishAlignedDxfIn(e,i,r,s,a,o,c,l,h,u,d,g,p,f,m,y),this}finishAlignedDxfIn(t,e,i,r,s,a,o,c,l,h,u,d,g,p,f,m){this.xLine1Point={x:t,y:e,z:i},this.xLine2Point={x:r,y:s,z:a},m?this.dimLinePoint={x:o,y:c,z:l}:this.dimLinePoint={x:this._dxfDefinitionPoint.x,y:this._dxfDefinitionPoint.y,z:this._dxfDefinitionPoint.z},this.rotation=h*Math.PI/180,this.oblique=u*Math.PI/180,f&&(this.dimBlockPosition={x:d,y:g,z:p})}};Xa.typeName="AlignedDimension";let oi=Xa;const za=class za extends fe{constructor(t,e,i,r,s=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=s,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 properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("centerPoint",()=>this.centerPoint),...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("arcPoint",()=>this.arcPoint)]}]}}collectDimensionDefinitionGripPoints(){return[this.centerPoint,this.xLine1Point,this.xLine2Point,this.arcPoint]}subTransformBy(t){this._arcPoint.applyMatrix4(t),this._centerPoint.applyMatrix4(t),this._xLine1Point.applyMatrix4(t),this._xLine2Point.applyMatrix4(t)}get geometricExtents(){return this.getGeometricExtentsFromDimBlockOrPoints([this.xLine1Point,this.xLine2Point,this.centerPoint,this.arcPoint])}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}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbArcDimension");let e=this.xLine1Point.x,i=this.xLine1Point.y,r=this.xLine1Point.z,s=this.xLine2Point.x,a=this.xLine2Point.y,o=this.xLine2Point.z,c=this.centerPoint.x,l=this.centerPoint.y,h=this.centerPoint.z,u=this.arcPoint.x,d=this.arcPoint.y,g=this.arcPoint.z;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const p=t.readItem();if(!p)break;const f=Number(p.code),m=Number(p.value);switch(f){case 13:e=m;break;case 23:i=m;break;case 33:r=m;break;case 14:s=m;break;case 24:a=m;break;case 34:o=m;break;case 15:c=m;break;case 25:l=m;break;case 35:h=m;break;case 16:u=m;break;case 26:d=m;break;case 36:g=m;break}}return this.xLine1Point=new b(e,i,r),this.xLine2Point=new b(s,a,o),this.centerPoint=new b(c,l,h),this.arcPoint=new b(u,d,g),this}};za.typeName="ArcDimension";let nr=za;const ja=class ja extends fe{constructor(t,e,i=0,r=null,s=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=s}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get farChordPoint(){return this._farChordPoint}set farChordPoint(t){this._farChordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}set leaderLength(t){this._leaderLength=t}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("chordPoint",()=>this.chordPoint),...this.createPoint3dProperties("farChordPoint",()=>this.farChordPoint),this.createProperty("leaderLength","float",()=>this.leaderLength,e=>{this.leaderLength=e}),this.createProperty("extArcStartAngle","float",()=>this.extArcStartAngle,e=>{this.extArcStartAngle=e}),this.createProperty("extArcEndAngle","float",()=>this.extArcEndAngle,e=>{this.extArcEndAngle=e})]}]}}collectDimensionDefinitionGripPoints(){return[this.chordPoint,this.farChordPoint]}subTransformBy(t){this._chordPoint.applyMatrix4(t),this._farChordPoint.applyMatrix4(t)}getMeasurementPropertyValue(){return this.measurement??this.chordPoint.distanceTo(this.farChordPoint)}get geometricExtents(){const t=[this.chordPoint,this.farChordPoint];if(this.leaderLength>0){const e=this.farChordPoint.clone().sub(this.chordPoint);e.lengthSq()>0&&(e.normalize().multiplyScalar(this.leaderLength),t.push(this.farChordPoint.clone().add(e)))}return this.getGeometricExtentsFromDimBlockOrPoints(t)}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}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbDiametricDimension");let e=this._dxfDefinitionPoint.x,i=this._dxfDefinitionPoint.y,r=this._dxfDefinitionPoint.z,s=this.farChordPoint.x,a=this.farChordPoint.y,o=this.farChordPoint.z,c=!1,l=!1,h=this.extArcStartAngle*180/Math.PI,u=this.extArcEndAngle*180/Math.PI;const d=()=>{l?(this.chordPoint=new b(e,i,r),this.farChordPoint=new b(s,a,o)):c&&(this.chordPoint=new b(this._dxfDefinitionPoint.x,this._dxfDefinitionPoint.y,this._dxfDefinitionPoint.z),this.farChordPoint=new b(e,i,r)),this.extArcStartAngle=h*Math.PI/180,this.extArcEndAngle=u*Math.PI/180};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const g=t.readItem();if(!g)break;const p=Number(g.code),f=Number(g.value);switch(p){case 15:e=f,c=!0;break;case 25:i=f,c=!0;break;case 35:r=f,c=!0;break;case 16:s=f,l=!0;break;case 26:a=f,l=!0;break;case 36:o=f,l=!0;break;case 40:this.leaderLength=f;break;case 52:h=f;break;case 53:u=f;break}}return d(),this}};ja.typeName="DiametricDimension";let rr=ja;const Va=class Va extends fe{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 properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("definingPoint",()=>this.definingPoint),...this.createPoint3dProperties("leaderEndPoint",()=>this.leaderEndPoint)]}]}}collectDimensionDefinitionGripPoints(){return[this.definingPoint,this.leaderEndPoint]}subTransformBy(t){this._definingPoint.applyMatrix4(t),this._leaderEndPoint.applyMatrix4(t)}get geometricExtents(){return this.getGeometricExtentsFromDimBlockOrPoints([this.definingPoint,this.leaderEndPoint])}get arrowLineCount(){return 0}dxfOutFields(t){return super.dxfOutFields(t),t.writeSubclassMarker("AcDbOrdinateDimension"),t.writePoint3d(13,this.definingPoint),t.writePoint3d(14,this.leaderEndPoint),this}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbOrdinateDimension");let e=this.definingPoint.x,i=this.definingPoint.y,r=this.definingPoint.z,s=this.leaderEndPoint.x,a=this.leaderEndPoint.y,o=this.leaderEndPoint.z;const c=()=>{this.definingPoint=new b(e,i,r),this.leaderEndPoint=new b(s,a,o)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const l=t.readItem();if(!l)break;const h=Number(l.code),u=Number(l.value);switch(h){case 13:e=u;break;case 23:i=u;break;case 33:r=u;break;case 14:s=u;break;case 24:a=u;break;case 34:o=u;break}}return c(),this}};Va.typeName="OrdinateDimension";let sr=Va;const Ga=class Ga extends fe{constructor(t,e,i,r=null,s=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=s}get center(){return this._center}set center(t){this._center.copy(t)}get chordPoint(){return this._chordPoint}set chordPoint(t){this._chordPoint.copy(t)}get extArcStartAngle(){return this._extArcStartAngle}set extArcStartAngle(t){this._extArcStartAngle=t}get extArcEndAngle(){return this._extArcEndAngle}set extArcEndAngle(t){this._extArcEndAngle=t}get leaderLength(){return this._leaderLength}set leaderLength(t){this._leaderLength=t}set leaderLenght(t){this._leaderLength=t}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("center",()=>this.center),...this.createPoint3dProperties("chordPoint",()=>this.chordPoint),this.createProperty("leaderLength","float",()=>this.leaderLength,e=>{this.leaderLength=e}),this.createProperty("extArcStartAngle","float",()=>this.extArcStartAngle,e=>{this.extArcStartAngle=e}),this.createProperty("extArcEndAngle","float",()=>this.extArcEndAngle,e=>{this.extArcEndAngle=e})]}]}}collectDimensionDefinitionGripPoints(){return[this.center,this.chordPoint]}subTransformBy(t){this._center.applyMatrix4(t),this._chordPoint.applyMatrix4(t)}getMeasurementPropertyValue(){return this.measurement??this.center.distanceTo(this.chordPoint)}get geometricExtents(){const t=[this.center,this.chordPoint];if(this.leaderLength>0){const e=this.chordPoint.clone().sub(this.center);e.lengthSq()>0&&(e.normalize().multiplyScalar(this.leaderLength),t.push(this.chordPoint.clone().add(e)))}return this.getGeometricExtentsFromDimBlockOrPoints(t)}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}dxfInFields(t){super.dxfInFields(t),t.atSubclassData("AcDbRadialDimension");const e=this._dxfDefinitionPoint.x,i=this._dxfDefinitionPoint.y,r=this._dxfDefinitionPoint.z;let s=this.chordPoint.x,a=this.chordPoint.y,o=this.chordPoint.z,c=!1,l=this.extArcStartAngle*180/Math.PI,h=this.extArcEndAngle*180/Math.PI;const u=()=>{this.center=new b(e,i,r),this.chordPoint=new b(s,a,o),this.extArcStartAngle=l*Math.PI/180,this.extArcEndAngle=h*Math.PI/180};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const d=t.readItem();if(!d)break;const g=Number(d.code),p=Number(d.value);switch(g){case 15:s=p,c=!0;break;case 25:a=p,c=!0;break;case 35:o=p,c=!0;break;case 13:c||(s=p);break;case 23:c||(a=p);break;case 33:c||(o=p);break;case 40:this.leaderLength=p;break;case 52:l=p;break;case 53:h=p;break}}return u(),this}};Ga.typeName="RadialDimension";let ar=Ga;const Ua=class Ua extends oi{get dxfSubclassMarker(){return"AcDbRotatedDimension"}};Ua.typeName="RotatedDimension";let or=Ua;class pm{constructor(t){this._pairs=t,this.kind="ascii",this._index=0}next(){if(!(this._index>=this._pairs.length))return this._pairs[this._index++]}peek(){if(!(this._index>=this._pairs.length))return this._pairs[this._index]}position(){return{byteOffset:this._index}}}function gu(n){const t=Number(n.code),e=n.value,i=Qi(t);return i==="comment"?{code:t,type:"string",value:String(e??"")}:i==="bool"?{code:t,type:"bool",value:!!e}:i==="binary"?e instanceof Uint8Array?{code:t,type:"binary",value:e}:{code:t,type:"string",value:String(e??"")}:i==="handle"?{code:t,type:"handle",value:String(e??"")}:i==="int"||i==="long"?{code:t,type:i==="long"?"long":"int",value:Number(e)}:i==="double"?{code:t,type:"double",value:Number(e)}:{code:t,type:"string",value:String(e??"")}}function mm(n){const t=[];for(;!n.atEndOfObject&&!n.atEof&&!n.atExtendedData;){const e=n.readItem();if(!e)break;t.push(gu(e))}return t}const ym=new Set(["AcDbAlignedDimension","AcDbRotatedDimension","AcDb3PointAngularDimension","AcDb2LineAngularDimension","AcDbOrdinateDimension","AcDbRadialDimension","AcDbDiametricDimension","AcDbArcDimension"]);function bm(n){const t=_m(n),e=xm(t),i=wm(e);if(!i)return null;const r=ve.forReading(new pm(t),{database:n.database});return i.dxfIn(r),i}function _m(n){const t=mm(n);for(;!n.atEndOfObject&&!n.atEof;){const e=n.readItem();if(!e)break;if(Number(e.code)===0){n.pushBackItem(e);break}t.push(gu(e))}return t}function xm(n){let t="";for(const e of n)e.code===100&&typeof e.value=="string"&&ym.has(e.value)&&(t=e.value);if(t)return t;for(const e of n)if(e.code===70&&typeof e.value=="number")switch(e.value&15){case 0:return"AcDbRotatedDimension";case 1:return"AcDbAlignedDimension";case 2:return"AcDb2LineAngularDimension";case 3:return"AcDbDiametricDimension";case 4:return"AcDbRadialDimension";case 5:return"AcDb3PointAngularDimension";case 6:return"AcDbOrdinateDimension";case 8:return"AcDbArcDimension"}return"AcDbAlignedDimension"}function wm(n,t){const e=new b;switch(n){case"AcDbRotatedDimension":return new or(e,e,e);case"AcDbAlignedDimension":return new oi(e,e,e);case"AcDb3PointAngularDimension":case"AcDb2LineAngularDimension":return new ir(e,e,e,e);case"AcDbOrdinateDimension":return new sr(e,e);case"AcDbRadialDimension":return new ar(e,e,0);case"AcDbDiametricDimension":return new rr(e,e,0);case"AcDbArcDimension":return new nr(e,e,e,e);default:return new oi(e,e,e)}}var We=(n=>(n[n.SimplePoly=0]="SimplePoly",n[n.FitCurvePoly=1]="FitCurvePoly",n[n.QuadSplinePoly=2]="QuadSplinePoly",n[n.CubicSplinePoly=3]="CubicSplinePoly",n))(We||{});const Ha=class Ha extends _t{get dxfTypeName(){return"POLYLINE"}constructor(t,e,i=0,r=!1,s=0,a=0,o=null){super(),this._polyType=t,this._elevation=i;const c=o&&(o==null?void 0:o.length)===e.length,l=e.map((h,u)=>({x:h.x,y:h.y,bulge:c?o[u]:void 0}));this._geo=new q(l,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}get area(){return this._geo.area}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 Y({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,this._elevation))}return t}subMoveGripPointsAt(t,e){return ht(t,i=>{ki(this._geo.vertices,i,e)}),this}subGetOsnapPoints(t,e,i,r){var c;const s=this._geo,a=this._elevation,o=s.numberOfVertices;if(o!==0)switch(t){case A.EndPoint:for(let l=0;l<o;l++){const h=s.getPointAt(l);r.push(new b(h.x,h.y,a))}break;case A.MidPoint:case A.Nearest:case A.Perpendicular:case A.Tangent:{const l=this.closed?o:o-1,h=[];for(let u=0;u<l;u++){const d=[];Ni(s.getPointAt(u),s.getPointAt((u+1)%o),(c=s.vertices[u])==null?void 0:c.bulge,a,t,e,d),h.push(...d)}if(t===A.MidPoint)r.push(...h);else{const u=Ft(e,h);u&&r.push(u)}break}}}transformBy(t){const e=t.determinant()<0;let i=this._elevation;return this._geo.vertices.forEach(r=>{const s=new b(r.x,r.y,this._elevation).applyMatrix4(t);r.x=s.x,r.y=s.y,i=s.z,e&&r.bulge!=null&&(r.bulge=-r.bulge)}),this._elevation=i,this._geo._boundingBoxNeedsUpdate=!0,this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"elevation",type:"float",editable:!0,accessor:{get:()=>this.elevation,set: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}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectPath2d();return e.length<2?1:kt.from2dPoints(e,this.closed).getOffsetSideAtPoint(t)}createOffsetCurve(t){const e=this._geo.offset(t);return e.length===0?null:kt.fromGePolyline(e[0])}collectPath2d(){const t=Math.max(32,this.numberOfVertices*4);return this._geo.getPoints(t)}};Ha.typeName="2dPolyline";let cr=Ha;var Ii=(n=>(n[n.SimplePoly=0]="SimplePoly",n[n.QuadSplinePoly=1]="QuadSplinePoly",n[n.CubicSplinePoly=2]="CubicSplinePoly",n))(Ii||{});const wr=class wr extends _t{get dxfTypeName(){return"POLYLINE"}constructor(t,e,i=!1){super(),this._polyType=t,this._geo=new q(e,i)}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get closed(){return this._geo.closed}get area(){return 0}set closed(t){this._geo.closed=t}get numberOfVertices(){return this._geo.numberOfVertices}getPointAt(t){const e=this._geo.vertices[t];return new b(e.x,e.y,e.z||0)}get geometricExtents(){const t=this._geo.vertices.map(e=>new b(e.x,e.y,e.z||0));return new Y().setFromPoints(t)}subGetGripPoints(){const t=new Array;for(let e=0;e<this._geo.numberOfVertices;++e)t.push(this.getPointAt(e));return t}subMoveGripPointsAt(t,e){return ht(t,i=>{this.moveVertexAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){const s=Array.from({length:this._geo.numberOfVertices},(a,o)=>this.getPointAt(o));if(s.length!==0)switch(t){case A.EndPoint:r.push(...s);break;case A.MidPoint:case A.Nearest:case A.Perpendicular:{const a=[];for(let o=0;o<s.length-1;o++){const c=[];ui(s[o],s[o+1],t,e,c),a.push(...c)}if(t===A.MidPoint)r.push(...a);else{const o=Ft(e,a);o&&r.push(o)}break}}}transformBy(t){return this._geo.vertices.forEach(e=>{const i=new b(e.x,e.y,e.z||0).applyMatrix4(t);e.x=i.x,e.y=i.y,e.z=i.z}),this._geo._boundingBoxNeedsUpdate=!0,this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._geo.vertices}},{name:"length",type:"float",editable:!1,accessor:{get:()=>this._geo.length}}]},{groupName:"others",properties:[{name:"closed",type:"float",editable:!0,accessor:{get:()=>this.closed,set:t=>{this.closed=t}}}]}]}}subWorldDraw(t){const e=this._geo.vertices.map(i=>new b(i.x,i.y,i.z||0));return 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:r.z}),t.writeInt16(70,32)}return t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDb3dPolyline");let e=this.closed?1:0;return e|=8,this.polyType===1&&(e|=16),this.polyType===2&&(e|=32),t.writeInt16(66,this.numberOfVertices>0?1:0),t.writeInt16(70,e),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectPath2d();return e.length<2?1:kt.from2dPoints(e,this.closed).getOffsetSideAtPoint(t)}createOffsetCurve(t){const e=this._geo.offset(t);if(e.length===0)return null;const i=e[0],r=[];for(let s=0;s<i.numberOfVertices;s++){const a=i.getPointAt(s);r.push(new b(a.x,a.y,this.interpolateZ(a.x,a.y)))}return new wr(this.polyType,r,this.closed)}collectPath2d(){const t=Math.max(32,this.numberOfVertices*4);return this._geo.getPoints(t)}interpolateZ(t,e){const i=this.numberOfVertices;if(i<=0)return 0;let r=1/0,s=this.getPointAt(0).z;const a=this.closed?i:i-1;for(let o=0;o<a;o++){const c=this.getPointAt(o),l=this.getPointAt((o+1)%i),h=l.x-c.x,u=l.y-c.y,d=h*h+u*u;if(d===0)continue;const g=Math.max(0,Math.min(1,((t-c.x)*h+(e-c.y)*u)/d)),p=c.x+h*g,f=c.y+u*g,m=(t-p)**2+(e-f)**2;m<r&&(r=m,s=c.z+(l.z-c.z)*g)}return s}moveVertexAt(t,e){const i=this._geo.vertices[t];if(!i)return;i.x+=e.x,i.y+=e.y;const r=i;r.z=(r.z??0)+(e.z??0)}};wr.typeName="3dPolyline";let lr=wr;class fu{constructor(t){this.position=new b(t.x,t.y,t.z||0)}}class pu{constructor(t){this.vertexIndices=t}}const Wa=class Wa extends _t{get dxfTypeName(){return"POLYLINE"}constructor(t,e){super(),this._vertices=t.map(i=>new fu(i)),this._faces=e.map(i=>new pu(i))}get numberOfVertices(){return this._vertices.length}get numberOfFaces(){return this._faces.length}get closed(){return!1}get area(){return 0}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 Y(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,s=-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),s=Math.max(s,o.position.y),a=Math.max(a,o.position.z)}),new Y(new b(t,e,i),new b(r,s,a))}subGetGripPoints(){const t=new Array;return this._vertices.forEach(e=>{t.push(e.position)}),t}subMoveGripPointsAt(t,e){return ht(t,i=>{const r=this._vertices[i];r&&r.position.add(e)}),this}subGetOsnapPoints(t,e,i,r){switch(t){case A.EndPoint:this._vertices.forEach(s=>{r.push(s.position)});break}}transformBy(t){return this._vertices.forEach(e=>{e.position.applyMatrix4(t)}),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._vertices.map(t=>({x:t.position.x,y:t.position.y,z:t.position.z}))}},{name:"faces",type:"array",editable:!1,itemSchema:{properties:[{name:"vertexIndices",type:"array",editable:!1,itemSchema:{properties:[{name:"index",type:"int",editable:!1}]}}]},accessor:{get:()=>this._faces.map(t=>({vertexIndices:t.vertexIndices}))}}]}]}}subWorldDraw(t){const e=[];return this._faces.forEach(i=>{const r=[];if(i.vertexIndices.forEach(s=>{const a=Math.abs(s)-1;a>=0&&a<this._vertices.length&&r.push(this._vertices[a].position)}),r.length>=3)for(let s=0;s<r.length;s++){const a=r[s],o=r[(s+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((s,a)=>{t.writeInt32(10+a,s)})}return t.writeStart("SEQEND"),t.writeHandle(5,this.database.generateHandle()),t.writeObjectId(330,this.objectId),t.writeSubclassMarker("AcDbEntity"),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectLargestFaceBoundary2d();return e.length<2?1:kt.from2dPoints(e,!0).getOffsetSideAtPoint(t)}createOffsetCurve(t){return Nr(this.collectLargestFaceBoundary2d(),!0,t)}collectLargestFaceBoundary2d(){let t=[];for(const e of this._faces){const i=e.vertexIndices.filter(r=>r>=0);i.length>t.length&&(t=i)}return t.length<2?this._vertices.map(e=>new L(e.position.x,e.position.y)):t.map(e=>{const i=this.getVertexAt(e).position;return new L(i.x,i.y)})}};Wa.typeName="PolyFaceMesh";let hr=Wa;class mu{constructor(t){this.position=new b(t.x,t.y,t.z||0)}}const $a=class $a extends _t{get dxfTypeName(){return"POLYLINE"}constructor(t,e,i,r=!1,s=!1){super(),this._mCount=t,this._nCount=e,this._closedM=r,this._closedN=s,this._vertices=i.map(a=>new mu(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}get area(){return 0}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 Y(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,s=-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),s=Math.max(s,o.position.y),a=Math.max(a,o.position.z)}),new Y(new b(t,e,i),new b(r,s,a))}subGetGripPoints(){const t=new Array;return this._vertices.forEach(e=>{t.push(e.position)}),t}subMoveGripPointsAt(t,e){return ht(t,i=>{const r=this._vertices[i];r&&r.position.add(e)}),this}subGetOsnapPoints(t,e,i,r){switch(t){case A.EndPoint:this._vertices.forEach(s=>{r.push(s.position)});break}}transformBy(t){return this._vertices.forEach(e=>{e.position.applyMatrix4(t)}),this}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"geometry",properties:[{name:"mCount",type:"float",editable:!1,accessor:{get:()=>this._mCount}},{name:"nCount",type:"float",editable:!1,accessor:{get:()=>this._nCount}},{name:"vertices",type:"array",editable:!1,itemSchema:{properties:[{name:"x",type:"float",editable:!0},{name:"y",type:"float",editable:!0},{name:"z",type:"float",editable:!0}]},accessor:{get:()=>this._vertices.map(t=>({x:t.position.x,y:t.position.y,z:t.position.z}))}}]},{groupName:"others",properties:[{name:"closedM",type:"boolean",editable:!0,accessor:{get:()=>this._closedM,set:t=>{this._closedM=t}}},{name:"closedN",type:"boolean",editable:!0,accessor:{get:()=>this._closedN,set:t=>{this._closedN=t}}}]}]}}subWorldDraw(t){const e=[];for(let i=0;i<this._mCount;i++)for(let r=0;r<this._nCount;r++){const s=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(s.position),e.push(o.position)}for(let i=0;i<this._nCount;i++)for(let r=0;r<this._mCount;r++){const s=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(s.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}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectBoundary2d();return e.length<2?1:kt.from2dPoints(e,this.isBoundaryClosed()).getOffsetSideAtPoint(t)}createOffsetCurve(t){return Nr(this.collectBoundary2d(),this.isBoundaryClosed(),t)}isBoundaryClosed(){return this._closedM&&this._closedN&&this._mCount>1&&this._nCount>1}collectBoundary2d(){const t=this._mCount,e=this._nCount;if(t<1||e<1)return[];const i=[],r=(s,a)=>{const o=this.getVertexAtMN(s,a).position;i.push(new L(o.x,o.y))};if(t===1){for(let s=0;s<e;s++)r(0,s);return i}if(e===1){for(let s=0;s<t;s++)r(s,0);return i}for(let s=0;s<e;s++)r(0,s);for(let s=1;s<t;s++)r(s,e-1);for(let s=e-2;s>=0;s--)r(t-1,s);for(let s=t-2;s>=1;s--)r(s,0);return i}};$a.typeName="PolygonMesh";let ur=$a;const vm=16,yu=128,bu=64,Ko=5,Zo=6;function km(n){const t=Am(n),e=Sm(n);return Im(t,e)}function Am(n){const t={layer:"0",lineType:"ByLayer",flag:0,elevation:0,startWidth:0,endWidth:0,meshM:0,meshN:0,smoothType:0};for(;!n.atEndOfObject&&!n.atEof&&!n.atExtendedData;){const e=n.readItem();if(!e)break;const i=Number(e.code),r=Number(e.value);switch(i){case 5:t.objectId=String(e.value);break;case 330:t.ownerId=String(e.value);break;case 8:t.layer=String(e.value);break;case 6:t.lineType=String(e.value);break;case 62:t.colorIndex=r;break;case 420:t.trueColor=r;break;case 70:t.flag=r;break;case 10:case 20:break;case 30:t.elevation=r;break;case 40:t.startWidth=r;break;case 41:t.endWidth=r;break;case 71:t.meshM=r;break;case 72:t.meshN=r;break;case 75:t.smoothType=r;break}}return t}function Sm(n){const t=[];for(;!n.atEof;){const e=n.peekItem();if(!e)break;if(Number(e.code)!==0){n.readItem();continue}const i=String(e.value).toUpperCase();if(i==="SEQEND"){n.readItem(),n.skipToEndOfObject();break}if(i==="ENDSEC"||i==="ENDBLK"||i==="EOF"||i!=="VERTEX")break;n.readItem(),t.push(Pm(n))}return t}function Pm(n){const t={x:0,y:0,z:0,bulge:0,flag:0,faces:[]},e=[],i=[];for(;!n.atEndOfObject&&!n.atEof&&!n.atExtendedData;){const s=n.readItem();if(!s)break;const a=Number(s.code),o=Number(s.value);switch(a){case 10:t.x=o,i[0]=Math.trunc(o);break;case 20:t.y=o;break;case 30:t.z=o;break;case 11:i[1]=Math.trunc(o);break;case 12:i[2]=Math.trunc(o);break;case 13:i[3]=Math.trunc(o);break;case 42:t.bulge=o;break;case 70:t.flag=o;break;case 71:e[0]=Math.trunc(o);break;case 72:e[1]=Math.trunc(o);break;case 73:e[2]=Math.trunc(o);break;case 74:e[3]=Math.trunc(o);break}}if(!!(t.flag&yu)&&!(t.flag&bu)){const s=e.length>0?e:i;t.faces=s.filter(a=>a!==0&&a!=null)}return t}function Im(n,t){const e=!!(n.flag&1),i=!!(n.flag&8),r=!!(n.flag&16),s=!!(n.flag&64),a=!!(n.flag&32),o=[],c=[],l=[];for(const u of t)u.flag&vm||(s&&u.flag&yu?u.flag&bu?(o.push({x:u.x,y:u.y,z:u.z}),c.push(u.bulge)):u.faces.length>=3&&l.push([...u.faces]):(o.push({x:u.x,y:u.y,z:u.z}),c.push(u.bulge)));let h;if(r)h=new ur(n.meshM,n.meshN,o,e,a);else if(s)h=new hr(o,l);else if(i){let u=Ii.SimplePoly;n.flag&4&&(n.smoothType===Zo?u=Ii.CubicSplinePoly:n.smoothType===Ko&&(u=Ii.QuadSplinePoly)),h=new lr(u,o,e)}else{let u=We.SimplePoly;n.flag&2?u=We.FitCurvePoly:n.flag&4&&(n.smoothType===Zo?u=We.CubicSplinePoly:n.smoothType===Ko&&(u=We.QuadSplinePoly)),h=new cr(u,o,n.elevation,e,n.startWidth,n.endWidth,c)}return Em(h,n),h}function Em(n,t){t.objectId&&(n.objectId=t.objectId),t.ownerId&&(n.ownerId=t.ownerId),n.layer=t.layer,n.lineType=t.lineType,t.colorIndex!=null&&(n.color.colorIndex=t.colorIndex),t.trueColor!=null&&n.color.setRGBValue(t.trueColor)}function _u(n){switch(n.toUpperCase()){case"LINE":return new Gi(new b,new b);case"CIRCLE":return new Fn(new b,1);case"ARC":return new Rn(new b,1,0,Math.PI/2);case"POINT":return new Hn;case"RAY":return new $n;case"XLINE":return new tr;case"ELLIPSE":return new Dn(new b,w.Z_AXIS,w.X_AXIS,1,1,0,Math.PI*2);case"SOLID":return new Kn;case"TRACE":return new $i;case"3DFACE":return new Yn;case"LWPOLYLINE":return new kt;case"INSERT":return new ee("");case"TEXT":return new si;case"MTEXT":return new Ee;case"SPLINE":return qi.fromControlPoints([{x:0,y:0,z:0},{x:1,y:0,z:0},{x:2,y:0,z:0},{x:3,y:0,z:0}],[0,0,0,0,1,1,1,1],void 0,3,!1);case"ATTDEF":return new Bn;case"ATTRIB":return new Ri;case"SHAPE":return new qn;case"TOLERANCE":return new Vi;case"LEADER":return new jn;case"VIEWPORT":return new Qn;case"IMAGE":return new Wi;case"WIPEOUT":return new Jn;case"ACAD_PROXY_ENTITY":return new Wn;case"OLEFRAME":return new Hi;case"OLE2FRAME":return new Un;case"HATCH":return new Xi;case"MLINE":return new Vn;case"MULTILEADER":case"MLEADER":return new Fi;case"ACAD_TABLE":return new Zn("",1,1);case"3DSOLID":return new Oi("");default:return null}}function Fs(n,t){let e=t;if(e==null){const s=n.readItem();if(!s||Number(s.code)!==0)return s&&n.pushBackItem(s),null;e=String(s.value)}const i=e.toUpperCase();if(i==="POLYLINE")return km(n);if(i==="DIMENSION")return bm(n);const r=_u(e);return r?(r.dxfIn(n),r):null}class xu{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(s){const a=Date.now()-i,o=s instanceof Error?s.message:String(s);return{success:!1,error:o,errorCode:o.toLowerCase().includes("timed out")?"worker_timeout":void 0,duration:a}}}async executeInWorker(t,e,i){const r=Date.now();return new Promise((s,a)=>{const o=this.getAvailableWorker(i),c=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:d=>{clearTimeout(c),this.releaseWorker(o),s(d)},reject:d=>{clearTimeout(c),this.releaseWorker(o),a(d)},timeout:c});const l=d=>{const{id:g,success:p,data:f,error:m,errorCode:y}=d.data;if(g!==t)return;this.cleanupTask(t);const _=Date.now()-r;s(p?{success:!0,data:f,duration:_}:{success:!1,error:m,errorCode:y,duration:_})},h=d=>{this.cleanupTask(t),a(new Error(`Worker error: ${d.message}`))};o.addEventListener("message",l),o.addEventListener("error",h);const u={id:t,input:e};e instanceof ArrayBuffer?o.postMessage(u,[e]):o.postMessage(u)})}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(),s={worker:i,isBusy:!0,id:r,createdAt:new Date};return this.workers.set(r,s),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 wu{constructor(t){this.framework=new xu(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function Lm(n){return new wu(n)}class Tm{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,s){const a={id:t,success:e,data:i,error:r,errorCode:s};try{self.postMessage(a)}catch(o){const c=o instanceof Error?o.message:String(o);self.postMessage({id:t,success:!1,error:c,errorCode:this.classifyPostMessageError(c)})}}classifyPostMessageError(t){const e=t.toLowerCase();return e.includes("out of memory")||e.includes("data cannot be cloned")?"worker_oom":"worker_error"}}var vu=(n=>(n[n.Vertex=0]="Vertex",n[n.CurveFitVertex=1]="CurveFitVertex",n[n.SplineFitVertex=8]="SplineFitVertex",n[n.SplineCtlVertex=9]="SplineCtlVertex",n))(vu||{});const qa=class qa extends H{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 Y().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subMoveGripPointsAt(t,e){return ie(t,e,this._position),this}subGetOsnapPoints(t,e,i,r){(t===A.EndPoint||t===A.Node)&&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}};qa.typeName="2dVertex";let Ds=qa;var ku=(n=>(n[n.SimpleVertex=0]="SimpleVertex",n[n.ControlVertex=1]="ControlVertex",n[n.FitVertex=2]="FitVertex",n))(ku||{});const Ka=class Ka extends H{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 Y().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subMoveGripPointsAt(t,e){return ie(t,e,this._position),this}subGetOsnapPoints(t,e,i,r){(t===A.EndPoint||t===A.Node)&&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}};Ka.typeName="3dVertex";let Ys=Ka;exports.ACAD_APPID=_s;exports.ACAD_LAYERFILTERS_NAME=Or;exports.ACCM_DEFAULT_UI_YIELD_BUDGET_MS=Li;exports.ACDB_DXF_MTEXT_CHUNK_CHARS=mi;exports.ACDB_DXF_XDATA_BINARY_MAX_BYTES=Zc;exports.ACDB_DXF_XDATA_STRING_MAX_BYTES=Kc;exports.ACDB_GRIPCOLOR_DEFAULT=dl;exports.ACDB_GRIPCOLOR_MAX=ws;exports.ACDB_GRIPCOLOR_MIN=xs;exports.ACDB_GRIPHOT_DEFAULT=gl;exports.ACDB_GRIPHOT_MAX=ks;exports.ACDB_GRIPHOT_MIN=vs;exports.ACDB_GRIPOBJLIMIT_MAX=Ug;exports.ACDB_GRIPOBJLIMIT_MIN=Gg;exports.ACDB_GRIPSIZE_DEFAULT=fl;exports.ACDB_GRIPSIZE_MAX=Ss;exports.ACDB_GRIPSIZE_MIN=As;exports.ACDB_GRIPS_MAX=Wg;exports.ACDB_GRIPS_MIN=Hg;exports.ACDB_PROXY_GRAPHIC_CHUNK_SIZE=Bp;exports.ACGI_DARK_THEME_FOREGROUND=Ci;exports.ACGI_LIGHT_THEME_FOREGROUND=Mi;exports.ACGI_MODEL_SPACE_BACKGROUND=al;exports.ACGI_PAPER_SPACE_BACKGROUND=Mg;exports.ACLY_DICTIONARY_NAME=ai;exports.ACTIVE_VPORT_NAME=ii;exports.AC_DB_SYSTEM_VARIABLE_NAMES=mp;exports.AcCmColor=X;exports.AcCmColorUtil=$t;exports.AcCmEntityColor=Eu;exports.AcCmErrors=Pt;exports.AcCmEventDispatcher=Lu;exports.AcCmEventManager=at;exports.AcCmLoader=Wu;exports.AcCmLoadingManager=rc;exports.AcCmObject=us;exports.AcCmPerformanceCollector=zs;exports.AcCmTask=ic;exports.AcCmTaskScheduler=nc;exports.AcCmTransparency=ot;exports.AcCmUiYieldGate=vr;exports.AcDb2dPolyline=cr;exports.AcDb2dVertex=Ds;exports.AcDb2dVertexType=vu;exports.AcDb3PointAngularDimension=ir;exports.AcDb3dPolyline=lr;exports.AcDb3dSolid=Oi;exports.AcDb3dVertex=Ys;exports.AcDb3dVertexType=ku;exports.AcDbAbstractViewTableRecord=oa;exports.AcDbAlignedDimension=oi;exports.AcDbAngleUnits=St;exports.AcDbArc=Rn;exports.AcDbArcDimension=nr;exports.AcDbAttribute=Ri;exports.AcDbAttributeDefinition=Bn;exports.AcDbAttributeFlags=dt;exports.AcDbAttributeMTextFlag=Ht;exports.AcDbBaseWorker=Tm;exports.AcDbBatchProcessing=Vl;exports.AcDbBlockReference=ee;exports.AcDbBlockScaling=yl;exports.AcDbBlockTable=Rh;exports.AcDbBlockTableRecord=tt;exports.AcDbBlockTableRecordFlag=wi;exports.AcDbChangeApplier=Uh;exports.AcDbChangeRecorder=Hh;exports.AcDbCircle=Fn;exports.AcDbCodePage=Zs;exports.AcDbCurve=_t;exports.AcDbDataGenerator=Eh;exports.AcDbDatabase=Cs;exports.AcDbDatabaseConverter=sa;exports.AcDbDatabaseConverterManager=Kt;exports.AcDbDatabaseTransaction=Wh;exports.AcDbDatabaseTransactionManager=qh;exports.AcDbDiametricDimension=rr;exports.AcDbDictionary=Nt;exports.AcDbDimArrowType=ou;exports.AcDbDimStyleTable=Bh;exports.AcDbDimStyleTableRecord=Tt;exports.AcDbDimTextHorizontal=Ul;exports.AcDbDimTextVertical=aa;exports.AcDbDimVerticalJustification=$l;exports.AcDbDimZeroSuppression=Hl;exports.AcDbDimZeroSuppressionAngular=Wl;exports.AcDbDimension=fe;exports.AcDbDuplicateRecordCloning=_h;exports.AcDbDwgVersion=pt;exports.AcDbDxfCode=Xs;exports.AcDbDxfDocumentReader=wh;exports.AcDbDxfFiler=ve;exports.AcDbDxfFilerStatus=el;exports.AcDbDxfObjectsReader=xh;exports.AcDbEllipse=Dn;exports.AcDbEntity=H;exports.AcDbFace=Yn;exports.AcDbFcf=Vi;exports.AcDbFileType=Si;exports.AcDbFilter=gh;exports.AcDbFontNameCollector=gt;exports.AcDbFormatter=Lh;exports.AcDbFrame=Gn;exports.AcDbGradientPatternType=Ih;exports.AcDbGroup=dh;exports.AcDbHatch=Xi;exports.AcDbHatchObjectType=Ph;exports.AcDbHatchPatternType=Pi;exports.AcDbHatchStyle=Sh;exports.AcDbHostApplicationServices=Mn;exports.AcDbIndex=ph;exports.AcDbLayerFilter=fh;exports.AcDbLayerIndex=mh;exports.AcDbLayerTable=Fh;exports.AcDbLayerTableRecord=nn;exports.AcDbLayout=tn;exports.AcDbLayoutDictionary=Gh;exports.AcDbLayoutManager=Sl;exports.AcDbLeader=jn;exports.AcDbLeaderAnnotationType=Kh;exports.AcDbLine=Gi;exports.AcDbLineSpacingStyle=er;exports.AcDbLinearUnits=rt;exports.AcDbLinetypeTable=Dh;exports.AcDbLinetypeTableRecord=Ae;exports.AcDbMLeader=Fi;exports.AcDbMLeaderContentType=He;exports.AcDbMLeaderDirectionType=th;exports.AcDbMLeaderLineType=Ai;exports.AcDbMLeaderStyle=Cr;exports.AcDbMLeaderTextAttachmentDirection=Jl;exports.AcDbMLine=Vn;exports.AcDbMLineFlags=Qh;exports.AcDbMLineJustification=Zh;exports.AcDbMText=Ee;exports.AcDbMlineStyle=ca;exports.AcDbNativeDxfConverter=vh;exports.AcDbObject=bt;exports.AcDbObjectIterator=ni;exports.AcDbOle2Frame=Un;exports.AcDbOleFrame=Hi;exports.AcDbOleObjectType=nu;exports.AcDbOleTileMode=ru;exports.AcDbOpenDatabaseError=ji;exports.AcDbOpenMode=ri;exports.AcDbOrdinateDimension=sr;exports.AcDbOsnapMode=A;exports.AcDbPatParser=ga;exports.AcDbPatSvgRenderer=Rs;exports.AcDbPlotPaperUnits=bl;exports.AcDbPlotRotation=_l;exports.AcDbPlotSettings=Al;exports.AcDbPlotShadePlotResLevel=wl;exports.AcDbPlotShadePlotType=vl;exports.AcDbPlotStdScaleType=kl;exports.AcDbPlotType=xl;exports.AcDbPoint=Hn;exports.AcDbPoly2dType=We;exports.AcDbPoly3dType=Ii;exports.AcDbPolyFaceMesh=hr;exports.AcDbPolyFaceMeshFace=pu;exports.AcDbPolyFaceMeshVertex=fu;exports.AcDbPolygonMesh=ur;exports.AcDbPolygonMeshVertex=mu;exports.AcDbPolyline=kt;exports.AcDbPredefinedAcadIsoPat=Ah;exports.AcDbPredefinedAcadPat=h0;exports.AcDbProxyEntity=Wn;exports.AcDbProxyGraphic=Ps;exports.AcDbProxyGraphicBitStream=ml;exports.AcDbProxyGraphicByteStream=Mt;exports.AcDbProxyGraphicEndOfBufferError=we;exports.AcDbProxyGraphicType=eh;exports.AcDbRadialDimension=ar;exports.AcDbRasterImage=Wi;exports.AcDbRasterImageClipBoundaryType=su;exports.AcDbRasterImageDef=yh;exports.AcDbRasterImageImageDisplayOpt=au;exports.AcDbRay=$n;exports.AcDbRegAppTable=Vh;exports.AcDbRegAppTableRecord=Xn;exports.AcDbRegenerator=Gl;exports.AcDbRenderingCache=Ie;exports.AcDbResultBuffer=Re;exports.AcDbRotatedDimension=or;exports.AcDbShape=qn;exports.AcDbSolid=Kn;exports.AcDbSortentsTable=bh;exports.AcDbSpline=qi;exports.AcDbSymbolTable=ne;exports.AcDbSymbolTableRecord=pe;exports.AcDbSysVarManager=ft;exports.AcDbSystemVariables=E;exports.AcDbTable=Zn;exports.AcDbText=si;exports.AcDbTextHorizontalMode=Yl;exports.AcDbTextStyleTable=Yh;exports.AcDbTextStyleTableRecord=Ir;exports.AcDbTextVerticalMode=Xl;exports.AcDbTrace=$i;exports.AcDbTransaction=da;exports.AcDbTransactionManager=N0;exports.AcDbUcsTable=Xh;exports.AcDbUcsTableRecord=Kl;exports.AcDbUndoStack=$h;exports.AcDbUnitsValue=J;exports.AcDbViewTable=zh;exports.AcDbViewTableRecord=Zl;exports.AcDbViewport=Qn;exports.AcDbViewportTable=jh;exports.AcDbViewportTableRecord=Se;exports.AcDbWipeout=Jn;exports.AcDbWorkerApi=wu;exports.AcDbWorkerManager=xu;exports.AcDbXline=tr;exports.AcDbXrecord=la;exports.AcGeArea2d=Vt;exports.AcGeBox2d=yt;exports.AcGeBox3d=Y;exports.AcGeCatmullRomCurve3d=zc;exports.AcGeCircArc2d=vt;exports.AcGeCircArc3d=Zt;exports.AcGeCurve2d=li;exports.AcGeEllipseArc2d=be;exports.AcGeEllipseArc3d=Cn;exports.AcGeEuler=sd;exports.AcGeGeometryUtil=wt;exports.AcGeLine2d=zt;exports.AcGeLine3d=ge;exports.AcGeLoop2d=xi;exports.AcGeMathUtil=M;exports.AcGeMatrix2d=Ki;exports.AcGeMatrix3d=D;exports.AcGeNurbsCurve=Ct;exports.AcGePlane=$s;exports.AcGePoint2d=L;exports.AcGePoint3d=b;exports.AcGePolyline2d=q;exports.AcGeQuaternion=ei;exports.AcGeShape2d=Ks;exports.AcGeSpline3d=jt;exports.AcGeTol=K;exports.AcGeVector2d=nt;exports.AcGeVector3d=w;exports.AcGiContext=Ar;exports.AcGiViewport=cl;exports.AcLyBoolExpr=nh;exports.AcLyLayerFilter=Mr;exports.AcLyLayerFilterDialogResult=rh;exports.AcLyLayerFilterTree=ue;exports.AcLyLayerGroup=sh;exports.AcTrStringUtil=Gu;exports.ByBlock=Jt;exports.ByLayer=lt;exports.DEBUG_MODE=Xu;exports.DEFAULT_ACGI_CONTEXT=Ng;exports.DEFAULT_GRADIENT_HATCH_NAME=ul;exports.DEFAULT_HATCH_PATTERN_IMPERIAL=Dg;exports.DEFAULT_HATCH_PATTERN_METRIC=ll;exports.DEFAULT_LINE_TYPE=ke;exports.DEFAULT_MLEADER_STYLE=he;exports.DEFAULT_MLINE_STYLE=le;exports.DEFAULT_TEXT_STYLE=Z;exports.DEFAULT_TOL=kr;exports.DEG2RAD=js;exports.DefaultLoadingManager=sc;exports.FLOAT_TOL=se;exports.HATCH_PATTERN_SOLID=Oe;exports.HATCH_PATTERN_USER=hl;exports.MLIGHTCAD_APPID=bs;exports.ORIGIN_POINT_2D=qu;exports.ORIGIN_POINT_3D=Ws;exports.RAD2DEG=Vs;exports.RAW_COLOR_TYPE_ACI=Tr;exports.RAW_COLOR_TYPE_BY_BLOCK=Bi;exports.RAW_COLOR_TYPE_BY_LAYER=Er;exports.RAW_COLOR_TYPE_RGB=Lr;exports.RAW_COLOR_TYPE_WINDOW_BG=Ql;exports.TAU=V;exports.TEMP_OBJECT_ID_PREFIX=xe;exports.VPORT_FALLBACK_CENTER_2D=Yg;exports.VPORT_FALLBACK_LLC=Xg;exports.VPORT_FALLBACK_URC=zg;exports.VPORT_FALLBACK_VIEW_DIR=jg;exports.VPORT_FALLBACK_VIEW_TARGET=Vg;exports.accmYieldForPaint=ec;exports.accmYieldToUi=ci;exports.acdbAssignWorkingDatabase=rl;exports.acdbChunkBinaryByMaxBytes=tl;exports.acdbChunkDxfMTextContents=Qc;exports.acdbChunkUtf8ByMaxBytes=Jc;exports.acdbCollectChangeEntities=Ts;exports.acdbCreateDxfPairReader=qc;exports.acdbCreateEntityForDxfIn=_u;exports.acdbCreateWorkerApi=Lm;exports.acdbDecodeMLeaderStyleRawColor=Qt;exports.acdbDwgCodePageToEncoding=Vc;exports.acdbDxfInEntity=Fs;exports.acdbDxfInHeader=ih;exports.acdbDxfValueType=Qi;exports.acdbEstimateDatabaseMemory=hm;exports.acdbFormatMemoryEstimate=um;exports.acdbGetWorkingDatabase=sl;exports.acdbHasOsnapMode=Zf;exports.acdbHexStringsToBytes=Js;exports.acdbHostApplicationServices=Pl;exports.acdbIsBinaryDxf=Gc;exports.acdbLayerGroupsToResultBuffer=ch;exports.acdbMakeAsciiDxfPairReader=Qs;exports.acdbMakeBinaryDxfPairReader=$c;exports.acdbMakeUtf8AsciiDxfPairReader=Wc;exports.acdbMaskToOsnapModes=qf;exports.acdbOsnapModesToMask=$f;exports.acdbParseFilterXRecordData=lh;exports.acdbPeekDxfHeaderInfo=Uc;exports.acdbPreviewIconToDataUrl=du;exports.acdbReadLayerFilterTree=ah;exports.acdbResultBufferToLayerGroups=qp;exports.acdbSerializeLayerFilterTree=oh;exports.acdbSetHostApplicationServicesProvider=nl;exports.acdbSetLayoutManagerFactory=qg;exports.acdbThumbnailImageToDataUrl=dm;exports.acdbToggleOsnapMode=Kf;exports.acdbWriteFilterXRecordData=uh;exports.acgeBasisFunction=Pe;exports.acgeCalculateCurveLength=Ic;exports.acgeCeilPowerOfTwo=xc;exports.acgeClamp=ae;exports.acgeComputeParameterValues=Sc;exports.acgeDamp=lc;exports.acgeDegToRad=yc;exports.acgeEuclideanModulo=Gs;exports.acgeEvaluateNurbsPoint=_i;exports.acgeFloorPowerOfTwo=wc;exports.acgeGenerateAveragedKnots=Pc;exports.acgeGenerateChordKnots=ud;exports.acgeGenerateSqrtChordKnots=dd;exports.acgeGenerateUUID=ac;exports.acgeGenerateUniformKnots=hd;exports.acgeGetOcsAngle=ce;exports.acgeGetOcsReferenceVector=Ti;exports.acgeIntPartLength=Hs;exports.acgeInterpolateControlPoints=md;exports.acgeInterpolateNurbsCurve=qs;exports.acgeInverseLerp=cc;exports.acgeIsBetween=vc;exports.acgeIsBetweenAngle=kc;exports.acgeIsPowerOfTwo=_c;exports.acgeLerp=Us;exports.acgeMapLinear=oc;exports.acgeNormalizeAngle=bi;exports.acgePingpong=hc;exports.acgeRadToDeg=bc;exports.acgeRandFloat=fc;exports.acgeRandFloatSpread=pc;exports.acgeRandInt=gc;exports.acgeRelativeEps=Ac;exports.acgeSeededRandom=mc;exports.acgeSmootherstep=dc;exports.acgeSmoothstep=uc;exports.acgeTransformOcsPointToWcs=de;exports.acgeTransformWcsPointToOcs=Lt;exports.acgiContrastingForegroundColor=Bg;exports.acgiForegroundColorForBackground=Rg;exports.acgiIsLightBackground=ol;exports.acgiResolveSubEntityTraitsRgbFromBackground=Fg;exports.clone=pi;exports.deepClone=hs;exports.defaults=Bt;exports.has=Jo;exports.isEmpty=tc;exports.isEqual=Ne;exports.log=yi;exports.setLogLevel=zu;