@mlightcad/data-model 1.14.4 → 1.14.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Ra=(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))(Ra||{});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 fp=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.")},pp=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},ol={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},ao=[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],ue=(function(){function n(){}return n.getColorByIndex=function(t){return ao[t]},n.getIndexByColor=function(t){for(var e=ao.length-1,i=1;i<e;++i)if(ao[i]===t)return i},n.getColorByName=function(t){return ol[t.toLowerCase()]},n.getNameByColor=function(t){var e,i;try{for(var r=fp(Object.entries(ol)),s=r.next();!s.done;s=r.next()){var o=pp(s.value,2),a=o[0],c=o[1];if(c===t)return a}}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})(),mp=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},U=(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?ue.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))),o=Math.max(0,Math.min(255,Math.round(i)));return this._value=r<<16|s<<8|o,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 o=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(o){var i=parseInt(o[1],10),r=parseInt(o[2],10),s=parseInt(o[3],10);return this.setRGB(i,r,s)}var a=ue.getColorByName(t);return a!==void 0?this.setRGBValue(a):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?ue.getNameByColor(this._value):"";case exports.AcCmColorMethod.ByACI:return this._value?ue.getNameByIndex(this._value):"";default:return}},set:function(t){if(t){var e=ue.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]),o=Number(i[3]),a=new n(exports.AcCmColorMethod.ByColor);return a.setRGB(r,s,o),a}if(/^\d{1,3},\d{1,3},\d{1,3}$/.test(e)){var c=mp(e.split(",").map(Number),3),r=c[0],s=c[1],o=c[2],a=new n(exports.AcCmColorMethod.ByColor);return a.setRGB(r,s,o),a}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=ue.getColorByName(h);return u!=null?new n(exports.AcCmColorMethod.ByColor,u):void 0}var d=ue.getColorByName(e);if(d!=null)return new n(exports.AcCmColorMethod.ByColor,d)}},n})(),yp=(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})(),Ot={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")}},bp=(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,o=r.length;s<o;s++)r[s].call(this,t)}}},n})(),_p=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.")},xp=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},wp=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))},gt=(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 o=_p(this.listeners),a=o.next();!a.done;a=o.next()){var c=a.value,l=c;l.call.apply(l,wp([null,t],xp(r),!1))}}catch(h){e={error:h}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}},n})(),Yo=function(){return Yo=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},Yo.apply(this,arguments)},vp=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Ap=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))},Ph=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 ri(n){return n===null||typeof n!="object"?n:Array.isArray(n)?Ap([],vp(n),!1):Yo({},n)}function zo(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(zo);var t={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=zo(n[e]));return t}function ne(n){for(var t,e,i=[],r=1;r<arguments.length;r++)i[r-1]=arguments[r];try{for(var s=Ph(i),o=s.next();!o.done;o=s.next()){var a=o.value;if(a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&n[c]===void 0&&(n[c]=a[c])}}catch(l){t={error:l}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return n}function Sh(n,t){return n!=null&&Object.prototype.hasOwnProperty.call(n,t)}function kh(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 ln(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(!ln(n[r],t[r]))return!1;return!0}var s=Object.keys(n),o=Object.keys(t);if(s.length!==o.length)return!1;try{for(var a=Ph(s),c=a.next();!c.done;c=a.next()){var l=c.value;if(!Object.prototype.hasOwnProperty.call(t,l)||!ln(n[l],t[l]))return!1}}catch(h){e={error:h}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(e)throw e.error}}return!0}function Pp(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var vr={exports:{}},Sp=vr.exports,al;function kp(){return al||(al=1,(function(n){(function(t,e){n.exports?n.exports=e():t.log=e()})(Sp,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={},o=null;function a(p,m){var y=p[m];if(typeof y.bind=="function")return y.bind(p);try{return Function.prototype.bind.call(y,p)}catch{return function(){return Function.prototype.apply.apply(y,[p,arguments])}}}function c(){console.log&&(console.log.apply||Function.prototype.apply.apply(console.log,[console,arguments]))}function l(p){return p==="debug"&&(p="log"),typeof console===e?!1:p==="trace"&&i?c:console[p]!==void 0?a(console,p):console.log!==void 0?a(console,"log"):t}function h(){for(var p=this.getLevel(),m=0;m<r.length;m++){var y=r[m];this[y]=m<p?t:this.methodFactory(y,p,this.name)}if(this.log=this.debug,typeof console===e&&p<this.levels.SILENT)return"No console available for logging"}function u(p){return function(){typeof console!==e&&(h.call(this),this[p].apply(this,arguments))}}function d(p,m,y){return l(p)||u.apply(this,arguments)}function g(p,m){var y=this,b,w,x,S="loglevel";typeof p=="string"?S+=":"+p:typeof p=="symbol"&&(S=void 0);function P(N){var R=(r[N]||"silent").toUpperCase();if(!(typeof window===e||!S)){try{window.localStorage[S]=R;return}catch{}try{window.document.cookie=encodeURIComponent(S)+"="+R+";"}catch{}}}function v(){var N;if(!(typeof window===e||!S)){try{N=window.localStorage[S]}catch{}if(typeof N===e)try{var R=window.document.cookie,nt=encodeURIComponent(S),et=R.indexOf(nt+"=");et!==-1&&(N=/^([^;]+)/.exec(R.slice(et+nt.length+1))[1])}catch{}return y.levels[N]===void 0&&(N=void 0),N}}function k(){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 E(N){var R=N;if(typeof R=="string"&&y.levels[R.toUpperCase()]!==void 0&&(R=y.levels[R.toUpperCase()]),typeof R=="number"&&R>=0&&R<=y.levels.SILENT)return R;throw new TypeError("log.setLevel() called with invalid level: "+N)}y.name=p,y.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},y.methodFactory=m||d,y.getLevel=function(){return x??w??b},y.setLevel=function(N,R){return x=E(N),R!==!1&&P(x),h.call(y)},y.setDefaultLevel=function(N){w=E(N),v()||y.setLevel(N,!1)},y.resetLevel=function(){x=null,k(),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(o!==y&&(b=E(o.getLevel())),h.call(y),o===y)for(var N in s)s[N].rebuild()},b=E(o?o.getLevel():"WARN");var O=v();O!=null&&(x=E(O)),h.call(y)}o=new g,o.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,o.methodFactory)),y};var f=typeof window!==e?window.log:void 0;return o.noConflict=function(){return typeof window!==e&&window.log===o&&(window.log=f),o},o.getLoggers=function(){return s},o.default=o,o})})(vr)),vr.exports}var Ep=kp();const Ip=Pp(Ep);var Tp=!0,ai=Ip;ai.setLevel("debug");var Lp=function(n){try{ai.setLevel(n)}catch(t){ai.setLevel("error"),ai.error(t)}},Vo=(function(){function n(t,e){this.events={attrChanged:new gt,modelChanged:new gt},this._changing=!1,this._previousAttributes={},this._pending=!1;var i=t||{};e&&ne(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,o=i.silent,a=[],c=this._changing;this._changing=!0,c||(this._previousAttributes=ri(this.attributes),this.changed={});var l=this.attributes,h=this.changed,u=this._previousAttributes;for(var d in r)e=r[d],ln(l[d],e)||a.push(d),ln(u[d],e)?delete h[d]:h[d]=e,s?delete l[d]:l[d]=e;if(!o){a.length&&(this._pending=i);for(var g=0;g<a.length;g++)this.events.attrChanged.dispatch({object:this,attrName:a[g],attrValue:l[a[g]],options:i})}if(c)return this;if(!o)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?!kh(this.changed):Sh(this.changed,t)},n.prototype.changedAttributes=function(t){if(!t)return this.hasChanged()?ri(this.changed):{};var e=this._changing?this._previousAttributes:this.attributes,i={};for(var r in t){var s=t[r];ln(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 ri(this._previousAttributes)},n.prototype.clone=function(){var t=ri(this.attributes);return new n(t)},n})(),Mp=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.")},Cp=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Na=(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=Mp(this.entries),r=i.next();!r.done;r=i.next())var s=Cp(r.value,2),o=s[0],a=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})(),Op=(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"],o=Math.floor(Math.log(t)/Math.log(i)),a=t/Math.pow(i,o);return"".concat(parseFloat(a.toFixed(r))," ").concat(s[o])},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 pt=(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 o=Number(e);if(Number.isInteger(o)&&o>=0&&o<=255){var a=new n;return o<=90?a.percentage=o:a.alpha=o,a}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})(),Rp=function(n,t,e,i){function r(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(h){try{l(i.next(h))}catch(u){o(u)}}function c(h){try{l(i.throw(h))}catch(u){o(u)}}function l(h){h.done?s(h.value):r(h.value).then(a,c)}l((i=i.apply(n,t||[])).next())})},Np=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=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}}},bi=50;function qn(){return new Promise(function(n){typeof globalThis<"u"&&typeof globalThis.requestAnimationFrame=="function"?globalThis.requestAnimationFrame(function(){return n()}):setTimeout(n,0)})}function Eh(){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 Fs=(function(){function n(t){t===void 0&&(t=bi),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 Rp(this,arguments,void 0,function(t){var e;return t===void 0&&(t=qn),Np(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})(),co=function(n,t,e,i){function r(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(h){try{l(i.next(h))}catch(u){o(u)}}function c(h){try{l(i.throw(h))}catch(u){o(u)}}function l(h){h.done?s(h.value):r(h.value).then(a,c)}l((i=i.apply(n,t||[])).next())})},Ki=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=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}}},Ih=(function(){function n(t){this.name=t}return n.prototype.run=function(t){throw new Error("run() must be implemented by subclass")},n})(),Th=(function(){function n(){this.tasks=[],this.onProgress=function(){},this.onComplete=function(){},this.onError=function(){return!1}}return n.prototype.scheduleTask=function(t){return co(this,void 0,void 0,function(){return Ki(this,function(e){switch(e.label){case 0:return[4,qn()];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 co(this,void 0,void 0,function(){var e,i,r,s,o,a,c=this;return Ki(this,function(l){switch(l.label){case 0:e=this.tasks.length,i=t,r=function(h){var u,d,g;return Ki(this,function(f){switch(f.label){case 0:u=s.tasks[h],f.label=1;case 1:return f.trys.push([1,3,,4]),[4,s.scheduleTask(function(){return co(c,void 0,void 0,function(){var p;return Ki(this,function(m){switch(m.label){case 0:return[4,u.run(i)];case 1:return p=m.sent(),this.onProgress((h+1)/e,u),[2,p]}})})})];case 2:return i=f.sent(),[3,4];case 3:return d=f.sent(),g=s.onError({error:d,taskIndex:h,task:u}),g?[2,{value:Promise.reject(d)}]:[3,4];case 4:return[2]}})},s=this,o=0,l.label=1;case 1:return o<e?[5,r(o)]:[3,4];case 2:if(a=l.sent(),typeof a=="object")return[2,a.value];l.label=3;case 3:return o++,[3,1];case 4:return this.onComplete(i),[2]}})})},n})(),Lh=(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})(),Mh=new Lh,Bp=(function(){function n(t){this.manager=t!==void 0?t:Mh,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})(),Tt=["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"],cl=1234567,Ba=Math.PI/180,Fa=180/Math.PI;function Ch(){var n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0,r=Tt[n&255]+Tt[n>>8&255]+Tt[n>>16&255]+Tt[n>>24&255]+"-"+Tt[t&255]+Tt[t>>8&255]+"-"+Tt[t>>16&15|64]+Tt[t>>24&255]+"-"+Tt[e&63|128]+Tt[e>>8&255]+"-"+Tt[e>>16&255]+Tt[e>>24&255]+Tt[i&255]+Tt[i>>8&255]+Tt[i>>16&255]+Tt[i>>24&255];return r.toLowerCase()}function Jt(n,t,e){return Math.max(t,Math.min(e,n))}function Da(n,t){return(n%t+t)%t}function Oh(n,t,e,i,r){return i+(n-t)*(r-i)/(e-t)}function Rh(n,t,e){return n!==t?(e-n)/(t-n):0}function Xa(n,t,e){return(1-e)*n+e*t}function Nh(n,t,e,i){return Xa(n,t,1-Math.exp(-e*i))}function Bh(n,t){return t===void 0&&(t=1),t-Math.abs(Da(n,t*2)-t)}function Fh(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))}function Dh(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))}function Xh(n,t){return n+Math.floor(Math.random()*(t-n+1))}function Yh(n,t){return n+Math.random()*(t-n)}function zh(n){return n*(.5-Math.random())}function Vh(n){n!==void 0&&(cl=n);var t=cl+=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 jh(n){return n*Ba}function Uh(n){return n*Fa}function Gh(n){return(n&n-1)===0&&n!==0}function Hh(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Wh(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function hn(n){var t=Math.PI*2;return(n%t+t)%t}function $h(n,t,e){return n>t&&n<e||n>e&&n<t}function qh(n,t,e,i){return i===void 0&&(i=!1),n=hn(n),t=hn(t),e=hn(e),i?t>e?n<=t&&n>=e:n<=t||n>=e:t<e?n>=t&&n<=e:n>=t||n<=e}function Kh(n,t,e){var i=hn(e-n),r=hn(t-n);return r<=i+1e-7}function Ya(n){return n=Math.abs(n),n<1?0:Math.ceil(Math.log10(Math.abs(n)+1))}function Zh(n,t){t===void 0&&(t=1e-7);var e=Ya(n);return Math.max(Math.pow(10,e)*t,t)}var C={DEG2RAD:Ba,RAD2DEG:Fa,generateUUID:Ch,clamp:Jt,euclideanModulo:Da,mapLinear:Oh,inverseLerp:Rh,lerp:Xa,damp:Nh,pingpong:Bh,smoothstep:Fh,smootherstep:Dh,randInt:Xh,randFloat:Yh,randFloatSpread:zh,seededRandom:Vh,degToRad:jh,radToDeg:Uh,isPowerOfTwo:Gh,ceilPowerOfTwo:Hh,floorPowerOfTwo:Wh,normalizeAngle:hn,isBetween:$h,isBetweenAngle:qh,isAngleOnCcwSweep:Kh,intPartLength:Ya,relativeEps:Zh},Fp=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=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}}},ht=(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,o=r.y;this.x=s,this.y=o;return}if(i===2){this.x=t,this.y=e;return}throw Ot.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,o=this.y-t.y;return this.x=s*i-o*r+t.x,this.y=s*r+o*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 Fp(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})(),zi=(function(){function n(t,e,i,r,s,o,a,c,l){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&i!=null&&r!=null&&s!=null&&o!=null&&a!=null&&c!=null&&l!=null&&this.set(t,e,i,r,s,o,a,c,l)}return n.prototype.set=function(t,e,i,r,s,o,a,c,l){var h=this.elements;return h[0]=t,h[1]=r,h[2]=a,h[3]=e,h[4]=s,h[5]=c,h[6]=i,h[7]=o,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,o=i[0],a=i[3],c=i[6],l=i[1],h=i[4],u=i[7],d=i[2],g=i[5],f=i[8],p=r[0],m=r[3],y=r[6],b=r[1],w=r[4],x=r[7],S=r[2],P=r[5],v=r[8];return s[0]=o*p+a*b+c*S,s[3]=o*m+a*w+c*P,s[6]=o*y+a*x+c*v,s[1]=l*p+h*b+u*S,s[4]=l*m+h*w+u*P,s[7]=l*y+h*x+u*v,s[2]=d*p+g*b+f*S,s[5]=d*m+g*w+f*P,s[8]=d*y+g*x+f*v,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],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8];return e*o*h-e*a*l-i*s*h+i*a*c+r*s*l-r*o*c},n.prototype.invert=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8],u=h*o-a*l,d=a*c-h*s,g=l*s-o*c,f=e*u+i*d+r*g;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);var p=1/f;return t[0]=u*p,t[1]=(r*l-h*i)*p,t[2]=(a*i-r*o)*p,t[3]=d*p,t[4]=(h*e-r*c)*p,t[5]=(r*s-a*e)*p,t[6]=g*p,t[7]=(i*c-l*e)*p,t[8]=(o*e-i*s)*p,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,o,a){var c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*o+l*a)+o+t,-r*l,r*c,-r*(-l*o+c*a)+a+e,0,0,1),this},n.prototype.scale=function(t,e){return this.premultiply(lo.makeScale(t,e)),this},n.prototype.rotate=function(t){return this.premultiply(lo.makeRotation(-t)),this},n.prototype.translate=function(t,e){return this.premultiply(lo.makeTranslation(t,e)),this},n.prototype.makeTranslation=function(t,e){return t instanceof ht?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})(),lo=new zi,W=1e-6,Y=2*Math.PI,Dp={x:0,y:0},za={x:0,y:0,z:0},V=(function(){function n(){this.equalPointTol=W,this.equalVectorTol=W}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 ht(t).sub(e).length()<this.equalPointTol},n.prototype.equalPoint3d=function(t,e){return new A(t).sub(e).length()<this.equalPointTol},n.equalToZero=function(t,e){return e===void 0&&(e=W),t<e&&t>-e},n.equal=function(t,e,i){return i===void 0&&(i=W),Math.abs(t-e)<i},n.great=function(t,e,i){return i===void 0&&(i=W),t-e>i},n.less=function(t,e,i){return i===void 0&&(i=W),t-e<i},n.isPositive=function(t,e){return e===void 0&&(e=W),t>e},n.isNonPositive=function(t,e){return e===void 0&&(e=W),t<=e},n})(),Vi=new V,Xp=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=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}}},Dn=(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,o,a){var c=i[r+0],l=i[r+1],h=i[r+2],u=i[r+3],d=s[o+0],g=s[o+1],f=s[o+2],p=s[o+3];if(a===0){t[e+0]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u;return}if(a===1){t[e+0]=d,t[e+1]=g,t[e+2]=f,t[e+3]=p;return}if(u!==p||c!==d||l!==g||h!==f){var m=1-a,y=c*d+l*g+h*f+u*p,b=y>=0?1:-1,w=1-y*y;if(w>Number.EPSILON){var x=Math.sqrt(w),S=Math.atan2(x,y*b);m=Math.sin(m*S)/x,a=Math.sin(a*S)/x}var P=a*b;if(c=c*m+d*P,l=l*m+g*P,h=h*m+f*P,u=u*m+p*P,m===1-a){var v=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=v,l*=v,h*=v,u*=v}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u},n.multiplyQuaternionsFlat=function(t,e,i,r,s,o){var a=i[r],c=i[r+1],l=i[r+2],h=i[r+3],u=s[o],d=s[o+1],g=s[o+2],f=s[o+3];return t[e]=a*f+h*u+c*g-l*d,t[e+1]=c*f+h*d+l*u-a*g,t[e+2]=l*f+h*g+a*d-c*u,t[e+3]=h*f-a*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,o=t.order,a=Math.cos,c=Math.sin,l=a(i/2),h=a(r/2),u=a(s/2),d=c(i/2),g=c(r/2),f=c(s/2);switch(o){case"XYZ":this._x=d*h*u+l*g*f,this._y=l*g*u-d*h*f,this._z=l*h*f+d*g*u,this._w=l*h*u-d*g*f;break;case"YXZ":this._x=d*h*u+l*g*f,this._y=l*g*u-d*h*f,this._z=l*h*f-d*g*u,this._w=l*h*u+d*g*f;break;case"ZXY":this._x=d*h*u-l*g*f,this._y=l*g*u+d*h*f,this._z=l*h*f+d*g*u,this._w=l*h*u-d*g*f;break;case"ZYX":this._x=d*h*u-l*g*f,this._y=l*g*u+d*h*f,this._z=l*h*f-d*g*u,this._w=l*h*u+d*g*f;break;case"YZX":this._x=d*h*u+l*g*f,this._y=l*g*u+d*h*f,this._z=l*h*f-d*g*u,this._w=l*h*u-d*g*f;break;case"XZY":this._x=d*h*u-l*g*f,this._y=l*g*u-d*h*f,this._z=l*h*f+d*g*u,this._w=l*h*u+d*g*f;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],o=e[1],a=e[5],c=e[9],l=e[2],h=e[6],u=e[10],d=i+a+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=(o-r)*g}else if(i>a&&i>u){var g=2*Math.sqrt(1+i-a-u);this._w=(h-c)/g,this._x=.25*g,this._y=(r+o)/g,this._z=(s+l)/g}else if(a>u){var g=2*Math.sqrt(1+a-i-u);this._w=(s-l)/g,this._x=(r+o)/g,this._y=.25*g,this._z=(c+h)/g}else{var g=2*Math.sqrt(1+u-i-a);this._w=(o-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(Jt(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,o=t._w,a=e._x,c=e._y,l=e._z,h=e._w;return this._x=i*h+o*a+r*l-s*c,this._y=r*h+o*c+s*a-i*l,this._z=s*h+o*l+i*c-r*a,this._w=o*h-i*a-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,o=this._w,a=o*t._w+i*t._x+r*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;var c=1-a*a;if(c<=Number.EPSILON){var l=1-e;return this._w=l*o+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,a),d=Math.sin((1-e)*u)/h,g=Math.sin(e*u)/h;return this._w=o*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 Xp(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})(),Yp=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=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}}},A=(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,o=s.x,a=s.y,c=s.z;this.x=o,this.y=a,this.z=c||0;return}if(r===3){this.x=t,this.y=e,this.z=i;return}throw Ot.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(ll.setFromEuler(t))},n.prototype.applyAxisAngle=function(t,e){return this.applyQuaternion(ll.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,o=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])*o,this.y=(s[1]*e+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*e+s[6]*i+s[10]*r+s[14])*o,this},n.prototype.applyQuaternion=function(t){var e=this.x,i=this.y,r=this.z,s=t.x,o=t.y,a=t.z,c=t.w,l=2*(o*r-a*i),h=2*(a*e-s*r),u=2*(s*i-o*e);return this.x=e+c*l+o*u-a*h,this.y=i+c*h+a*l-s*u,this.z=r+c*u+s*h-o*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,o=e.x,a=e.y,c=e.z;return this.x=r*c-s*a,this.y=s*o-i*c,this.z=i*a-r*o,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 ho.copy(this).projectOnVector(t),this.sub(ho)},n.prototype.reflect=function(t){return this.sub(ho.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 Yp(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})(),ho=new A,ll=new Dn,D=(function(){function n(t,e,i,r,s,o,a,c,l,h,u,d,g,f,p,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&&o!=null&&a!=null&&c!=null&&l!=null&&h!=null&&u!=null&&d!=null&&g!=null&&f!=null&&p!=null&&m!=null&&this.set(t,e,i,r,s,o,a,c,l,h,u,d,g,f,p,m)}return n.makeTranslation=function(t,e,i){return new n().makeTranslation(t,e,i)},n.prototype.set=function(t,e,i,r,s,o,a,c,l,h,u,d,g,f,p,m){var y=this.elements;return y[0]=t,y[4]=e,y[8]=i,y[12]=r,y[1]=s,y[5]=o,y[9]=a,y[13]=c,y[2]=l,y[6]=h,y[10]=u,y[14]=d,y[3]=g,y[7]=f,y[11]=p,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(Vi.equalPoint3d(i,A.Z_AXIS))this.identity();else{var r=new A(1,0,0);Math.abs(i.x)<1/64&&Math.abs(i.y)<1/64?r.crossVectors(A.Y_AXIS,i).normalize():r.crossVectors(A.Z_AXIS,i).normalize();var s=i.clone().cross(r).normalize();this.makeBasis(r,s,i)}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/yn.setFromMatrixColumn(t,0).length(),s=1/yn.setFromMatrixColumn(t,1).length(),o=1/yn.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]*o,e[9]=i[9]*o,e[10]=i[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},n.prototype.makeRotationFromQuaternion=function(t){return this.compose(zp,t,Vp)},n.prototype.lookAt=function(t,e,i){var r=this.elements;return Xt.subVectors(t,e),Xt.lengthSq()===0&&(Xt.z=1),Xt.normalize(),Xe.crossVectors(i,Xt),Xe.lengthSq()===0&&(Math.abs(i.z)===1?Xt.x+=1e-4:Xt.z+=1e-4,Xt.normalize(),Xe.crossVectors(i,Xt)),Xe.normalize(),Zi.crossVectors(Xt,Xe),r[0]=Xe.x,r[4]=Zi.x,r[8]=Xt.x,r[1]=Xe.y,r[5]=Zi.y,r[9]=Xt.y,r[2]=Xe.z,r[6]=Zi.z,r[10]=Xt.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,o=i[0],a=i[4],c=i[8],l=i[12],h=i[1],u=i[5],d=i[9],g=i[13],f=i[2],p=i[6],m=i[10],y=i[14],b=i[3],w=i[7],x=i[11],S=i[15],P=r[0],v=r[4],k=r[8],E=r[12],O=r[1],N=r[5],R=r[9],nt=r[13],et=r[2],G=r[6],rt=r[10],L=r[14],q=r[3],dt=r[7],B=r[11],Ct=r[15];return s[0]=o*P+a*O+c*et+l*q,s[4]=o*v+a*N+c*G+l*dt,s[8]=o*k+a*R+c*rt+l*B,s[12]=o*E+a*nt+c*L+l*Ct,s[1]=h*P+u*O+d*et+g*q,s[5]=h*v+u*N+d*G+g*dt,s[9]=h*k+u*R+d*rt+g*B,s[13]=h*E+u*nt+d*L+g*Ct,s[2]=f*P+p*O+m*et+y*q,s[6]=f*v+p*N+m*G+y*dt,s[10]=f*k+p*R+m*rt+y*B,s[14]=f*E+p*nt+m*L+y*Ct,s[3]=b*P+w*O+x*et+S*q,s[7]=b*v+w*N+x*G+S*dt,s[11]=b*k+w*R+x*rt+S*B,s[15]=b*E+w*nt+x*L+S*Ct,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],o=t[1],a=t[5],c=t[9],l=t[13],h=t[2],u=t[6],d=t[10],g=t[14],f=t[3],p=t[7],m=t[11],y=t[15];return f*(+s*c*u-r*l*u-s*a*d+i*l*d+r*a*g-i*c*g)+p*(+e*c*g-e*l*d+s*o*d-r*o*g+r*l*h-s*c*h)+m*(+e*l*u-e*a*g-s*o*u+i*o*g+s*a*h-i*l*h)+y*(-r*a*h-e*c*u+e*a*d+r*o*u-i*o*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 A?(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],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8],u=t[9],d=t[10],g=t[11],f=t[12],p=t[13],m=t[14],y=t[15],b=u*m*l-p*d*l+p*c*g-a*m*g-u*c*y+a*d*y,w=f*d*l-h*m*l-f*c*g+o*m*g+h*c*y-o*d*y,x=h*p*l-f*u*l+f*a*g-o*p*g-h*a*y+o*u*y,S=f*u*c-h*p*c-f*a*d+o*p*d+h*a*m-o*u*m,P=e*b+i*w+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 v=1/P;return t[0]=b*v,t[1]=(p*d*s-u*m*s-p*r*g+i*m*g+u*r*y-i*d*y)*v,t[2]=(a*m*s-p*c*s+p*r*l-i*m*l-a*r*y+i*c*y)*v,t[3]=(u*c*s-a*d*s-u*r*l+i*d*l+a*r*g-i*c*g)*v,t[4]=w*v,t[5]=(h*m*s-f*d*s+f*r*g-e*m*g-h*r*y+e*d*y)*v,t[6]=(f*c*s-o*m*s-f*r*l+e*m*l+o*r*y-e*c*y)*v,t[7]=(o*d*s-h*c*s+h*r*l-e*d*l-o*r*g+e*c*g)*v,t[8]=x*v,t[9]=(f*u*s-h*p*s-f*i*g+e*p*g+h*i*y-e*u*y)*v,t[10]=(o*p*s-f*a*s+f*i*l-e*p*l-o*i*y+e*a*y)*v,t[11]=(h*a*s-o*u*s-h*i*l+e*u*l+o*i*g-e*a*g)*v,t[12]=S*v,t[13]=(h*p*r-f*u*r+f*i*d-e*p*d-h*i*m+e*u*m)*v,t[14]=(f*a*r-o*p*r-f*i*c+e*p*c+o*i*m-e*a*m)*v,t[15]=(o*u*r-h*a*r+h*i*c-e*u*c-o*i*d+e*a*d)*v,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,o=t.x,a=t.y,c=t.z,l=s*o,h=s*a;return this.set(l*o+i,l*a-r*c,l*c+r*a,0,l*a+r*c,h*a+i,h*c-r*o,0,l*c-r*a,h*c+r*o,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,o){return this.set(1,i,s,0,t,1,o,0,e,r,1,0,0,0,0,1),this},n.prototype.compose=function(t,e,i){var r=this.elements,s=e.x,o=e.y,a=e.z,c=e.w,l=s+s,h=o+o,u=a+a,d=s*l,g=s*h,f=s*u,p=o*h,m=o*u,y=a*u,b=c*l,w=c*h,x=c*u,S=i.x,P=i.y,v=i.z;return r[0]=(1-(p+y))*S,r[1]=(g+x)*S,r[2]=(f-w)*S,r[3]=0,r[4]=(g-x)*P,r[5]=(1-(d+y))*P,r[6]=(m+b)*P,r[7]=0,r[8]=(f+w)*v,r[9]=(m-b)*v,r[10]=(1-(d+p))*v,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=yn.set(r[0],r[1],r[2]).length(),o=yn.set(r[4],r[5],r[6]).length(),a=yn.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],re.copy(this);var l=1/s,h=1/o,u=1/a;return re.elements[0]*=l,re.elements[1]*=l,re.elements[2]*=l,re.elements[4]*=h,re.elements[5]*=h,re.elements[6]*=h,re.elements[8]*=u,re.elements[9]*=u,re.elements[10]*=u,e.setFromRotationMatrix(re),i.x=s,i.y=o,i.z=a,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})(),yn=new A,re=new D,zp=new A(0,0,0),Vp=new A(1,1,1),Xe=new A,Zi=new A,Xt=new A,j=(function(){function n(t,e){t===void 0&&(t=void 0),e===void 0&&(e=void 0),this.min=t==null?new A(1/0,1/0,1/0):new A(t.x,t.y,t.z),this.max=e==null?new A(-1/0,-1/0,-1/0):new A(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(uo.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=uo.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 A(0,0,0):new A(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 A(0,0,0):new A(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,uo).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:(Ee[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ee[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ee[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ee[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ee[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ee[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ee[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ee[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ee),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})(),Ee=[new A,new A,new A,new A,new A,new A,new A,new A],uo=new A,hl=new ht,kt=(function(){function n(t,e){t===void 0&&(t=void 0),e===void 0&&(e=void 0),this.min=t==null?new ht(1/0,1/0):new ht(t.x,t.y),this.max=e==null?new ht(-1/0,-1/0):new ht(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=hl.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 ht(0,0):new ht(0,0).addVectors(this.min,this.max).multiplyScalar(.5)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return this.isEmpty()?new ht(0,0):new ht(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,hl).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})(),ul=new A,jp=new A,Up=new zi,Ds=(function(){function n(t,e){t===void 0&&(t=new A(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=ul.subVectors(i,e).cross(jp.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||Up.getNormalMatrix(t),r=this.coplanarPoint(ul).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})(),Gp=(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)}})(),M=(function(n){Gp(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})(ht),Hp=(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)}})(),_=(function(n){Hp(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(o,a){o.toArray(s,a*r)}),s},t})(A),Wp=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=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}}},dl=new D,gl=new Dn,$p=(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],o=r[4],a=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(Jt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,g),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Jt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,g),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(Jt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,g),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Jt(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(-o,l));break;case"YZX":this._z=Math.asin(Jt(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(a,g));break;case"XZY":this._z=Math.asin(-Jt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,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),dl.makeRotationFromQuaternion(t),this.setFromRotationMatrix(dl,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 gl.setFromEuler(this),this.setFromQuaternion(gl,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 Wp(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 qp(n){var t,e=n;return{x:n.x,y:n.y,z:(t=e.z)!==null&&t!==void 0?t:0}}function Kp(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 Zp(n,t,e){e===void 0&&(e=!1);for(var i=n.x,r=n.y,s=!1,o=t.length,a=0,c=o-1;a<o;c=a++){var l=t[a].x,h=t[a].y,u=t[c].x,d=t[c].y,g=h>r!=d>r;e&&(g=h>=r!=d>=r);var f=g&&i<(u-l)*(r-h)/(d-h)+l;f&&(s=!s)}return s}function Qp(n,t){if(n.length===0||t.length===0)return!1;var e=new kt().setFromPoints(n),i=new kt().setFromPoints(t);if(!e.intersectsBox(i))return!1;for(var r=0;r<n.length;){if(Lt.isPointInPolygon(n[r],t,!0))return!0;r<n.length-1&&Vi.equalPoint2d(n[r+1],n[r])&&++r,++r}return!1}var Lt={applyOffsetToPoint3d:Kp,isPointInPolygon:Zp,isPolygonIntersect:Qp,point2dToPoint3d:qp},Qi=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Ji=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 Jp(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 t0(n,t){for(var e=t.length-1,i=n,r=[0],s=0,o=1;o<=e;o++){var a=t[o][0]-t[o-1][0],c=t[o][1]-t[o-1][1],l=t[o][2]-t[o-1][2],h=Math.sqrt(a*a+c*c+l*l);s+=h,r.push(s)}for(var u=[],o=0;o<=i;o++)u.push(0);for(var o=1;o<=e-i;o++){var d=r[o]/s;u.push(d*(e-i+1))}for(var o=0;o<=i;o++)u.push(e-i+1);return u}function Qh(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,o=1;o<=i;o++){var a=n[o][0]-n[o-1][0],c=n[o][1]-n[o-1][1],l=n[o][2]-n[o-1][2],h=Math.sqrt(a*a+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 Jh(n,t){for(var e=t.length-1,i=n,r=e+i+1,s=new Array(r+1).fill(0),o=t[t.length-1],a=r-i;a<=r;a++)s[a]=o;for(var c=1;c<=e-i;c++){for(var l=0,a=c;a<c+i;a++)l+=t[a];s[c+i]=l/i}return s}function e0(n,t){for(var e=t.length-1,i=n,r=[0],s=0,o=1;o<=e;o++){var a=t[o][0]-t[o-1][0],c=t[o][1]-t[o-1][1],l=t[o][2]-t[o-1][2],h=Math.sqrt(a*a+c*c+l*l),u=Math.sqrt(h);s+=u,r.push(s)}for(var d=[],o=0;o<=i;o++)d.push(0);for(var o=1;o<=e-i;o++){var g=r[o]/s;d.push(g*(e-i+1))}for(var o=0;o<=i;o++)d.push(e-i+1);return d}function go(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 o=s,a=Math.abs(i[s][s]),c=s+1;c<e;c++){var l=Math.abs(i[c][s]);l>a&&(a=l,o=c)}if(a<1e-12)throw new Error("Interpolation matrix is singular.");if(o!==s){var h=i[s];i[s]=i[o],i[o]=h;var u=r[s];r[s]=r[o],r[o]=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 f=new Array(e).fill(0),c=e-1;c>=0;c--){for(var p=r[c],g=c+1;g<e;g++)p-=i[c][g]*f[g];f[c]=p/i[c][c]}return f}function Va(n,t,e,i,r){var s,o,a,c,l,h;if(e===void 0&&(e="Uniform"),n.length===0)return{controlPoints:[],knots:[],weights:[]};var u=n.map(function(B){var Ct;return[B[0],B[1],(Ct=B[2])!==null&&Ct!==void 0?Ct:0]}),d=!!i,g=!!r,f=(d?1:0)+(g?1:0),p=u.length-1,m=p+f;if(m<t)throw new Error("Not enough points to interpolate a curve of this degree.");var y=Qh(u,e),b=y.slice();d&&b.unshift(y[0]),g&&b.push(y[y.length-1]);var w=Jh(t,b),x=m+1,S=new Array(x),P=new Array(x),v=new Array(x),k=new Array(x),E=0;S[E]=new Array(x).fill(0),S[E][0]=1,P[E]=u[0][0],v[E]=u[0][1],k[E]=u[0][2],E++;for(var O=1;O<=p-1;O++){var N=y[O];S[E]=new Array(x).fill(0);for(var R=0;R<=m;R++)S[E][R]=Ze(R,t,N,w);P[E]=u[O][0],v[E]=u[O][1],k[E]=u[O][2],E++}if(S[E]=new Array(x).fill(0),S[E][m]=1,P[E]=u[p][0],v[E]=u[p][1],k[E]=u[p][2],E++,d){var nt=w[t+1]-w[0],et=nt!==0?t/nt:0;S[E]=new Array(x).fill(0),S[E][0]=-et,S[E][1]=et,P[E]=(s=i==null?void 0:i[0])!==null&&s!==void 0?s:0,v[E]=(o=i==null?void 0:i[1])!==null&&o!==void 0?o:0,k[E]=(a=i==null?void 0:i[2])!==null&&a!==void 0?a:0,E++}if(g){var nt=w[m+t+1]-w[m],et=nt!==0?t/nt:0;S[E]=new Array(x).fill(0),S[E][m-1]=-et,S[E][m]=et,P[E]=(c=r==null?void 0:r[0])!==null&&c!==void 0?c:0,v[E]=(l=r==null?void 0:r[1])!==null&&l!==void 0?l:0,k[E]=(h=r==null?void 0:r[2])!==null&&h!==void 0?h:0,E++}for(var G=go(S,P),rt=go(S,v),L=go(S,k),q=new Array(x),O=0;O<x;O++)q[O]=[G[O],rt[O],L[O]];var dt=new Array(x).fill(1);return{controlPoints:q,knots:w,weights:dt}}function Ze(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],o=r>1e-10?(e-i[n])/r:0,a=s>1e-10?(i[n+t+1]-e)/s:0;return o*Ze(n,t-1,e,i)+a*Ze(n+1,t-1,e,i)}function ci(n,t,e,i,r){var s=i.length-1,o=t;if(n=Math.max(e[o],Math.min(e[s+1],n)),Math.abs(n-e[s+1])<1e-8)return Ji([],Qi(i[s]),!1);if(Math.abs(n-e[o])<1e-8)return Ji([],Qi(i[0]),!1);for(var a=[0,0,0],c=0,l=0;l<=s;l++){var h=Ze(l,o,n,e),u=r[l]*h;a[0]+=i[l][0]*u,a[1]+=i[l][1]*u,a[2]+=i[l][2]*u,c+=u}if(Math.abs(c)<1e-10){var d=e[e.length-o-1];if(Math.abs(n-d)<1e-8)return Ji([],Qi(i[s]),!1);if(Math.abs(n-e[o])<1e-8)return Ji([],Qi(i[0]),!1)}return Math.abs(c)>=1e-10&&(a[0]/=c,a[1]/=c,a[2]/=c),a}function jo(n,t,e,i){if(t===0)return 0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],o=0;return r>1e-10&&(o+=t/r*Ze(n,t-1,e,i)),s>1e-10&&(o-=t/s*Ze(n+1,t-1,e,i)),o}function n0(n,t,e,i){if(t<=1)return 0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],o=0;return r>1e-10&&(o+=t/r*jo(n,t-1,e,i)),s>1e-10&&(o-=t/s*jo(n+1,t-1,e,i)),o}function i0(n,t,e,i,r){var s=i.length-1,o=t,a=e[o],c=e[s+1];n=Math.max(a,Math.min(c,n));for(var l=[0,0,0],h=[0,0,0],u=[0,0,0],d=0,g=0,f=0,p=0;p<=s;p++){var m=Ze(p,o,n,e),y=jo(p,o,n,e),b=n0(p,o,n,e),w=r[p],x=w*m,S=w*y,P=w*b,v=i[p];l[0]+=x*v[0],l[1]+=x*v[1],l[2]+=x*v[2],h[0]+=S*v[0],h[1]+=S*v[1],h[2]+=S*v[2],u[0]+=P*v[0],u[1]+=P*v[1],u[2]+=P*v[2],d+=x,g+=S,f+=P}if(Math.abs(d)<1e-10){var k=ci(n,t,e,i,r);return{point:k,deriv1:[0,0,0],deriv2:[0,0,0]}}var E=d*d,O=[l[0]/d,l[1]/d,l[2]/d],N=[(h[0]*d-l[0]*g)/E,(h[1]*d-l[1]*g)/E,(h[2]*d-l[2]*g)/E],R=u[0]*d-l[0]*f,nt=u[1]*d-l[1]*f,et=u[2]*d-l[2]*f,G=[R/E-2*g*N[0]/d,nt/E-2*g*N[1]/d,et/E-2*g*N[2]/d];return{point:O,deriv1:N,deriv2:G}}function r0(n,t){var e=n[0],i=n[1],r=t[0],s=t[1],o=e*e+i*i;return o<1e-20?0:(e*s-i*r)/Math.pow(o,1.5)}function tu(n,t,e,i){for(var r=n,s=t[r],o=t[t.length-r-1],a=0,c=1e3,l=(o-s)/c,h=ci(s,n,t,e,i),u=1;u<=c;u++){var d=s+u*l,g=ci(d,n,t,e,i),f=g[0]-h[0],p=g[1]-h[1],m=g[2]-h[2];a+=Math.sqrt(f*f+p*p+m*m),h=g}var y=ci(o,n,t,e,i),b=y[0]-h[0],w=y[1]-h[1],x=y[2]-h[2];return a+=Math.sqrt(b*b+w*w+x*x),a}function s0(n,t,e,i,r){return t===void 0&&(t=3),e===void 0&&(e="Uniform"),n.length===0?[]:Va(n,t,e,i,r).controlPoints}var fl=new D,pl=new A,o0=new A,a0=new A,fo=new _;function eu(n){return new D().setFromExtrusionDirection(new A(n.x,n.y,n.z))}function Qe(n){return fl.setFromExtrusionDirection(new A(n.x,n.y,n.z)),fl.extractBasis(pl,o0,a0),pl.clone()}function At(n,t){var e;return new _(n.x,n.y,(e=n.z)!==null&&e!==void 0?e:0).applyMatrix4(eu(t))}function jt(n,t){var e;return new _(n.x,n.y,(e=n.z)!==null&&e!==void 0?e:0).applyMatrix4(eu(t).invert())}function Le(n,t,e){var i,r,s=jt(n,e),o=jt(t,e);return fo.set(o.x-s.x,o.y-s.y,((i=o.z)!==null&&i!==void 0?i:0)-((r=s.z)!==null&&r!==void 0?r:0)),C.normalizeAngle(Math.atan2(fo.y,fo.x))}function nu(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],o=n[i];e+=s.x*o.y-o.x*s.y}return e*.5}function c0(n){return Math.abs(nu(n))}function l0(n){var t,e,i=n.length;if(i<3)return 0;for(var r=0,s=0,o=0,a=0,c=i-1;a<i;c=a++){var l=n[c],h=n[a],u=l.x,d=l.y,g=(t=l.z)!==null&&t!==void 0?t:0,f=h.x,p=h.y,m=(e=h.z)!==null&&e!==void 0?e:0;r+=(g+m)*(d-p),s+=(u+f)*(g-m),o+=(d+p)*(u-f)}return .5*Math.hypot(r,s,o)}function h0(n){return n.length<3?0:c0(n)}function iu(n){return n.length<3?0:l0(n)}function ja(n,t,e){var i=n.x,r=n.y,s=t.x,o=t.y,a=e.x,c=e.y,l=2*(i*(o-c)+s*(c-r)+a*(r-o));if(V.equalToZero(l))return null;var h=((i*i+r*r)*(o-c)+(s*s+o*o)*(c-r)+(a*a+c*c)*(r-o))/l,u=((i*i+r*r)*(a-s)+(s*s+o*o)*(i-a)+(a*a+c*c)*(s-i))/l,d=Math.hypot(h-i,u-r);return!Number.isFinite(d)||V.isNonPositive(d)?null:{center:new M(h,u),radius:d}}function ml(n,t,e){var i,r,s,o=n.x,a=n.y,c=(i=n.z)!==null&&i!==void 0?i:0,l=new A(t.x-o,t.y-a,((r=t.z)!==null&&r!==void 0?r:0)-c),h=new A(e.x-o,e.y-a,((s=e.z)!==null&&s!==void 0?s:0)-c),u=new A().crossVectors(l,h),d=u.lengthSq();if(d<W*W)return null;var g=l.lengthSq(),f=h.lengthSq(),p=new A().crossVectors(u,l).multiplyScalar(f).add(new A().crossVectors(h,u).multiplyScalar(g)).multiplyScalar(1/(2*d)),m=new _(o+p.x,a+p.y,c+p.z),y=Math.hypot(m.x-o,m.y-a,m.z-c);return!Number.isFinite(y)||V.isNonPositive(y)?null:{center:m,radius:y}}function He(n,t){return Math.atan2(t.y-n.y,t.x-n.x)}function Ae(n,t){return Math.hypot(t.x-n.x,t.y-n.y)}function ru(n,t,e){if(V.isNonPositive(t))return null;var i=e.x-n.x,r=e.y-n.y,s=Math.hypot(i,r);if(V.isNonPositive(s))return null;var o=t/s;return new M(n.x+i*o,n.y+r*o)}var u0=1e-8;function su(n,t,e,i){var r=Math.abs(Ae(n,t)-e);return r<=(i??Math.max(W,e*1e-5))}function ou(n,t,e,i,r){return r===void 0&&(r=u0),Math.abs(n.x-e.x)<=r&&Math.abs(n.y-e.y)<=r&&Math.abs(t-i)<=r}function au(n,t,e,i){var r=Math.max(1e-18,Math.abs(e)*1e-9);return n<e-r?!0:n>e+r?!1:t>i}function yl(n,t,e,i){i===void 0&&(i=!1);var r=ja(n,t,e);if(!r)return null;var s=He(r.center,n),o=He(r.center,t),a=He(r.center,e),c=!C.isAngleOnCcwSweep(s,o,a);return i&&(c=!c),$.fromMathAngles(r.center,r.radius,s,a,c)}function Ua(n,t){return!Number.isFinite(t)||V.isNonPositive(t)?null:new $(n,t,0,Y,!1)}function d0(n,t){var e=Ae(n,t);return V.isNonPositive(e)?null:Ua({x:(n.x+t.x)/2,y:(n.y+t.y)/2},e/2)}function g0(n,t,e){var i=ja(n,t,e);return i?Ua(i.center,i.radius):null}function f0(n,t,e){var i=Ae(e,n);if(V.isNonPositive(i))return null;var r=He(e,n),s=He(e,t),o=C.normalizeAngle(s-r);return $.fromMathAngles(e,i,r,s,o>Math.PI)}function ji(n,t,e,i){var r=Ae(n,t),s=Ae(n,e);if(V.isNonPositive(r)||V.isNonPositive(s))return null;var o=Math.max(W,r*W);return Math.abs(r-s)>o?null:$.fromMathAngles(n,r,He(n,t),He(n,e),i)}function p0(n,t,e,i){var r=Ae(n,t);if(V.isNonPositive(r))return null;var s=ru(n,r,e);return s?ji(n,t,s,i):null}function cu(n,t,e){var i=Ae(n,t),r=Math.abs(e);if(V.isNonPositive(i)||V.isNonPositive(r)||!V.great(Y-r,0))return null;var s=e<0,o=He(n,t),a=s?o-r:o+r;return $.fromMathAngles(n,i,o,a,s)}function m0(n,t,e){var i=Ae(n,t),r=Math.abs(e);if(V.isNonPositive(i)||V.isNonPositive(r)||V.great(r,2*i))return null;var s=Math.max(-1,Math.min(1,r/(2*i))),o=2*Math.asin(s);return cu(n,t,e>=0?o:-o)}function y0(n,t,e){var i=Ae(n,t),r=Math.abs(e);if(V.isNonPositive(i)||V.isNonPositive(r)||!V.great(Y-r,0))return null;var s=Math.sin(r/2);if(V.equalToZero(s))return null;var o=i/(2*s),a=o*o-i*i/4;if(V.less(a,0))return null;var c=Math.sqrt(Math.max(0,a)),l=(n.x+t.x)/2,h=(n.y+t.y)/2,u=t.x-n.x,d=t.y-n.y,g=-d/i,f=u/i,p=e>=0,m=p&&r<=Math.PI||!p&&r>Math.PI,y=m?1:-1,b={x:l+g*c*y,y:h+f*c*y};return ji(b,n,t,!p)}function b0(n,t,e){var i=Math.cos(e),r=Math.sin(e),s=t.x-n.x,o=t.y-n.y,a=-r,c=i,l=2*(s*a+o*c);if(V.equalToZero(l))return null;var h=(s*s+o*o)/l;if(!Number.isFinite(h))return null;var u={x:n.x+a*h,y:n.y+c*h},d=n.x-u.x,g=n.y-u.y,f=d*r-g*i;return V.equalToZero(f)?null:ji(u,n,t,f<0)}function _0(n,t,e){var i=Math.abs(e),r=Ae(n,t);if(V.isNonPositive(i)||V.isNonPositive(r)||V.great(r,2*i))return null;var s=(n.x+t.x)/2,o=(n.y+t.y)/2,a=t.x-n.x,c=t.y-n.y,l=-c/r,h=a/r,u=Math.sqrt(Math.max(0,i*i-r*r/4)),d=e>=0?1:-1,g={x:s+l*u*d,y:o+h*u*d};return ji(g,n,t,e<0)}var lu=(function(){function n(){this._boundingBoxNeedsUpdate=!1}return Object.defineProperty(n.prototype,"boundingBoxNeedUpdate",{get:function(){return this._boundingBoxNeedsUpdate},enumerable:!1,configurable:!0}),n})(),x0=(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)}})(),Ga=(function(n){x0(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.translate=function(e){return this.transform(new zi().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})(lu),w0=(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)}})(),Kn=(function(n){w0(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),o=0;i.push(0);for(var a=1;a<=e;a++)r=this.getPoint(a/e),o+=r.distanceTo(s),i.push(o),s=r;return i},t.prototype.getUtoTmapping=function(e,i){var r=this.getLengths(),s=0,o=r.length,a;i?a=i:a=e*r[o-1];for(var c=0,l=o-1,h;c<=l;)if(s=Math.floor(c+(l-c)/2),h=r[s]-a,h<0)c=s+1;else if(h>0)l=s-1;else{l=s;break}if(s=l,r[s]===a)return s/(o-1);var u=r[s],d=r[s+1],g=d-u,f=(a-u)/g,p=(s+f)/(o-1);return p},t.prototype.getTangent=function(e){var i=1e-4,r=e-i,s=e+i;r<0&&(r=0),s>1&&(s=1);var o=this.getPoint(r),a=this.getPoint(s),c=new M;return c.copy(a).sub(o).normalize(),c},t.prototype.getTangentAt=function(e){var i=this.getUtoTmapping(e);return this.getTangent(i)},t})(Ga),v0=(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)}})(),Ir=function(){return Ir=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},Ir.apply(this,arguments)},tr=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.")},er=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},nr=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(n){v0(t,n);function t(e,i,r,s,o){var a=n.call(this)||this,c=+(e!==void 0)+ +(i!==void 0)+ +(r!==void 0)+ +(s!==void 0)+ +(o!==void 0);if(c==3)typeof e=="object"&&typeof i=="object"&&typeof r=="object"?a.createByThreePoints(e,i,r):a.createByStartEndPointsAndBulge(e,i,r);else if(c==5){var l=e;a.center=new M(l.x,l.y),a.radius=i,a._clockwise=o,a._startAngle=a._clockwise?a._mirrorAngle(C.normalizeAngle(r)):C.normalizeAngle(r),a._endAngle=a._clockwise?a._mirrorAngle(C.normalizeAngle(s)):C.normalizeAngle(s)}else throw Ot.ILLEGAL_PARAMETERS;return a}return t.fromMathAngles=function(e,i,r,s,o){var a=new t(e,i,C.normalizeAngle(r),C.normalizeAngle(s),!1);return a._clockwise=o,a._boundingBoxNeedsUpdate=!0,a},t.computeCircumcircle=function(e,i,r){return ja(e,i,r)},t.projectPoint=function(e,i,r){return ru(e,i,r)},t.pointLiesOnCircle=function(e,i,r,s){return su(e,i,r,s)},t.sameCircle=function(e,i,r,s,o){return ou(e,i,r,s,o)},t.isBetterDistanceAlign=function(e,i,r,s){return au(e,i,r,s)},t.tryCreateByThreePoints=function(e,i,r,s){return s===void 0&&(s=!1),yl(e,i,r,s)},t.tryCreateCircle=function(e,i){return Ua(e,i)},t.tryCreateCircleByDiameter=function(e,i){return d0(e,i)},t.tryCreateCircleByThreePoints=function(e,i,r){return g0(e,i,r)},t.tryCreateShorterArc=function(e,i,r){return f0(e,i,r)},t.tryCreateByCenterStartEnd=function(e,i,r,s){return ji(e,i,r,s)},t.tryCreateByCenterStartProjectedEnd=function(e,i,r,s){return p0(e,i,r,s)},t.tryCreateByCenterStartSweep=function(e,i,r){return cu(e,i,r)},t.tryCreateByCenterStartChord=function(e,i,r){return m0(e,i,r)},t.tryCreateByStartEndAngle=function(e,i,r){return y0(e,i,r)},t.tryCreateByStartEndDirection=function(e,i,r){return b0(e,i,r)},t.tryCreateByStartEndRadius=function(e,i,r){return _0(e,i,r)},t.prototype.createByThreePoints=function(e,i,r){var s=yl(e,i,r);if(!s)throw Ot.ILLEGAL_PARAMETERS;this.center=s.center,this.radius=s.radius,this._clockwise=s._clockwise,this._startAngle=s._startAngle,this._endAngle=s._endAngle,this._boundingBoxNeedsUpdate=!0},t.prototype.createByStartEndPointsAndBulge=function(e,i,r){var s,o,a;r<0?(s=Math.atan(-r)*4,o=new ht(e),a=new ht(i)):(s=Math.atan(r)*4,o=new ht(i),a=new ht(e));var c=new ht().subVectors(a,o),l=c.length(),h=new ht().addVectors(o,c.multiplyScalar(.5)),u=Math.abs(l/2/Math.tan(s/2)),d=c.normalize(),g=r<0?-Math.PI/2:Math.PI/2,f=new ht(d.x*Math.cos(g)-d.y*Math.sin(g),d.y*Math.cos(g)+d.x*Math.sin(g)),p;s<Math.PI?r<0?p=h.add(f.multiplyScalar(u)):p=h.add(f.multiplyScalar(-u)):r<0?p=h.add(f.multiplyScalar(-u)):p=h.add(f.multiplyScalar(u)),r<0?(this._startAngle=Math.atan2(o.y-p.y,o.x-p.x),this._endAngle=Math.atan2(a.y-p.y,a.x-p.x)):(this._startAngle=Math.atan2(a.y-p.y,a.x-p.x),this._endAngle=Math.atan2(o.y-p.y,o.x-p.x)),this._clockwise=r<0,this.center=p,this.radius=a.sub(p).length()},Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new M(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==Y?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 o=tr(s),a=o.next();!a.done;a=o.next()){var c=a.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{a&&!a.done&&(i=o.return)&&i.call(o)}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 kt(new M(Math.min.apply(Math,nr([],er(h),!1)),Math.min.apply(Math,nr([],er(u),!1))),new M(Math.max.apply(Math,nr([],er(h),!1)),Math.max.apply(Math,nr([],er(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),o=this.startPoint.clone().applyMatrix2d(r);if(this.closed)return this.center=s,this.radius=s.distanceTo(o),this._startAngle=Math.atan2(o.y-s.y,o.x-s.x),this._endAngle=this._startAngle,this._clockwise=r.determinant()<0?!this._clockwise:this._clockwise,this._boundingBoxNeedsUpdate=!0,this;var a=this.midPoint.clone().applyMatrix2d(r),c=this.endPoint.clone().applyMatrix2d(r),l=new t(o,a,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(o.y-l.center.y,o.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 M(r,s)},t.prototype.getQuadrantPoints=function(){var e,i,r=[],s=this._getInternalAngle(this.startAngle),o=this._getInternalAngle(this.endAngle),a=[0,Math.PI/2,Math.PI,3*Math.PI/2];try{for(var c=tr(a),l=c.next();!l.done;l=c.next()){var h=l.value,u=this._getInternalAngle(h);C.isBetweenAngle(u,s,o,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 M(e.x,e.y),r=i.x-this.center.x,s=i.y-this.center.y,o=Math.hypot(r,s);if(o<1e-12)return this.startPoint.clone();var a=Math.atan2(s,r),c=this.clockwise?this._mirrorAngle(C.normalizeAngle(a)):C.normalizeAngle(a),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.inwardAlignment=function(e,i){var r=i.x-e.x,s=i.y-e.y;if(r*r+s*s<1e-24)return 0;var o=this.radius>0?this.radius:1,a=Math.max(1e-16,1e-12*o*o),c=this.startPoint.distanceToSquared(e)<=a,l=this.endPoint.distanceToSquared(e)<=a;if(!c&&!l)return 0;var h=this.getPoints(8);if(h.length<3)return 0;var u=c&&!l?h[1]:h[h.length-2],d=u.x-e.x,g=u.y-e.y,f=Math.hypot(d,g);return f>1e-18?(r*d+s*g)/f:0},t.prototype.perpendicularPoints=function(e){var i,r,s=new M(e.x,e.y),o=s.x-this.center.x,a=s.y-this.center.y,c=Math.hypot(o,a);if(c<1e-12)return[];var l=o/c,h=a/c,u=[new M(this.center.x+l*this.radius,this.center.y+h*this.radius),new M(this.center.x-l*this.radius,this.center.y-h*this.radius)],d=[],g=this._getInternalAngle(this.startAngle),f=this._getInternalAngle(this.endAngle);try{for(var p=tr(u),m=p.next();!m.done;m=p.next()){var y=m.value,b=Math.atan2(y.y-this.center.y,y.x-this.center.x),w=this.clockwise?this._mirrorAngle(C.normalizeAngle(b)):C.normalizeAngle(b),x=this._getInternalAngle(w);(this.closed||C.isBetweenAngle(x,g,f,this.clockwise))&&d.push(y)}}catch(S){i={error:S}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}finally{if(i)throw i.error}}return d},t.prototype.tangentPoints=function(e){var i,r,s=[],o=e.x-this.center.x,a=e.y-this.center.y,c=Math.hypot(o,a),l=this.radius;if(c<l)return s;var h=Math.acos(l/c),u=Math.atan2(a,o),d=[u+h,u-h],g=this._getInternalAngle(this.startAngle),f=this._getInternalAngle(this.endAngle);try{for(var p=tr(d),m=p.next();!m.done;m=p.next()){var y=m.value,b=this.clockwise?this._mirrorAngle(C.normalizeAngle(y)):C.normalizeAngle(y),w=this._getInternalAngle(b);(this.closed||C.isBetweenAngle(w,g,f,this.clockwise))&&s.push(this.getPointAtAngle(b))}}catch(x){i={error:x}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}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=Y,s=0),this.clockwise)for(var o=0;o<=e;o++){var a=s-r*(o/e),c=this._clockwise?this._mirrorAngle(a):a,l=this.getPointAtAngle(c);i.push(new M(l.x,l.y))}else for(var o=0;o<=e;o++){var a=s+r*(o/e),c=this._clockwise?this._mirrorAngle(a):a,l=this.getPointAtAngle(c);i.push(new M(l.x,l.y))}return i},t.prototype.tessellate=function(e){var i,r=this.closed?Y:this.deltaAngle,s=t.segmentCount(this.radius,r,Ir(Ir({},e),{minSegments:(i=e==null?void 0:e.minSegments)!==null&&i!==void 0?i:this.closed?8:3}));return this.getPoints(s)},t.resolveCircleSides=function(e){return e==null||!Number.isFinite(e)?t.DEFAULT_CIRCLE_SIDES:Jt(Math.round(e),t.MIN_CIRCLE_SIDES,t.MAX_CIRCLE_SIDES)},t.resolveTessellateOptions=function(e){var i,r=t.resolveCircleSides(e==null?void 0:e.circleSides),s=Math.max(1,Math.round((i=e==null?void 0:e.maxSegments)!==null&&i!==void 0?i:r));return{deviation:e==null?void 0:e.deviation,circleSides:r,minSegments:e==null?void 0:e.minSegments,maxSegments:s}},t.chordDeviationFromRadius=function(e,i){i===void 0&&(i=t.DEFAULT_CIRCLE_SIDES);var r=Math.abs(e),s=t.resolveCircleSides(i);return r<=W?W:Math.max(W,r*(1-Math.cos(Math.PI/s)))},t.segmentCount=function(e,i,r){var s,o,a=t.resolveTessellateOptions(r),c=Math.abs(i),l=c>=Y-1e-8,h=Math.max(1,Math.round((s=a.minSegments)!==null&&s!==void 0?s:l?8:3)),u=Math.max(h,a.maxSegments),d=Math.abs(e);if(d<=W||c<=W)return h;var g=(o=a.deviation)!==null&&o!==void 0?o:t.chordDeviationFromRadius(d,a.circleSides),f=1-g/d;if(!Number.isFinite(f)||f>=1)return u;if(f<=-1)return h;var p=2*Math.acos(f);return p<=W?u:Jt(Math.ceil(c/p),h,u)},t.DEFAULT_CIRCLE_SIDES=100,t.MIN_CIRCLE_SIDES=8,t.MAX_CIRCLE_SIDES=2e4,t})(Kn),Uo=function(){return Uo=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},Uo.apply(this,arguments)},A0=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.")},ir=1e-6;function hu(n,t){if(G0(n)){var e=S0(n,t);return e?[e]:[]}var i=fu(n),r=i.numberOfVertices;if(r<2)return[];var s=W0(i,t);return s?[s]:[]}function P0(n){return fu(n)}function S0(n,t){var e,i,r=k0(n);if(r.length===0)return null;var s=[];try{for(var o=A0(r),a=o.next();!a.done;a=o.next()){var c=a.value,l=I0(c,t);if(!l)return null;s.push(l)}}catch(g){e={error:g}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}var h=E0(n),u=C0(s,h,n.closed,t);if(u.length<2)return null;var d=new it;return u.forEach(function(g,f){d.addVertexAt(f,{x:g.x,y:g.y})}),d.closed=n.closed,d}function k0(n){for(var t,e=[],i=n.numberOfVertices,r=n.closed?i:i-1,s=0;s<r;s++){var o=n.vertices[s],a=n.vertices[(s+1)%i];V.isPositive(Math.abs((t=o.bulge)!==null&&t!==void 0?t:0))?e.push({kind:"arc",arc:new $(o,a,o.bulge)}):e.push({kind:"line",start:new M(o.x,o.y),end:new M(a.x,a.y)})}return e}function E0(n){for(var t=[],e=0;e<n.numberOfVertices;e++)t.push(n.getPointAt(e));return t}function I0(n,t){if(n.kind==="line"){var e=M0(n.start,n.end,t);return e?Uo({kind:"line"},e):null}var i=T0(n.arc,n.arc.startPoint,n.arc.endPoint,t);return i?{kind:"arc",arc:i}:null}function T0(n,t,e,i){var r=L0(n,t,e,i),s=n.radius+r;return V.isNonPositive(s)?null:new $(n.center,s,n.startAngle,n.endAngle,n.clockwise)}function L0(n,t,e,i){var r=e.x-t.x,s=e.y-t.y,o=Math.hypot(r,s);if(V.isNonPositive(o))return n.clockwise?-i:i;var a=-s/o,c=r/o,l=n.center.x-(t.x+e.x)/2,h=n.center.y-(t.y+e.y)/2,u=l*a+h*c>0;return u?-i:i}function M0(n,t,e){var i=t.x-n.x,r=t.y-n.y,s=Math.hypot(i,r);if(V.isNonPositive(s))return null;var o=-r/s*e,a=i/s*e;return{start:new M(n.x+o,n.y+a),end:new M(t.x+o,t.y+a),dx:i,dy:r}}function C0(n,t,e,i){var r,s,o,a=n.length;if(a===0)return[];for(var c=O0(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<a;h++){var u=n[h],d=h===a-1&&!e?{point:D0(u)}:c[(h+1)%a];if(h>0&&c[h].filletPoints&&c[h].filletPoints.forEach(function(y){return l.push(y.clone())}),u.kind==="arc")for(var g=(o=c[h].nextSegmentStart)!==null&&o!==void 0?o:c[h].point,f=d.point,p=R0(u.arc,g,f,Math.max(16,32)),m=1;m<p.length;m++)l.push(p[m]);else l.push(d.point.clone())}return pu(l)}function O0(n,t,e,i){for(var r=n.length,s=[],o=0;o<r;o++)o===0?s.push(e?bl(n[r-1],n[0],t[0],i):{point:F0(n[0])}):s.push(bl(n[o-1],n[o],t[o],i));return s}function R0(n,t,e,i){for(var r=n.nearestPoint(t),s=n.nearestPoint(e),o=Go(n,r),a=Go(n,s),c=B0(n,o,a),l=[],h=0;h<=i;h++){var u=h/i,d=n.clockwise?o-c*u:o+c*u;l.push(n.getPointAtAngle(N0(n,d)))}return l}function Go(n,t){return Math.atan2(t.y-n.center.y,t.x-n.center.x)}function N0(n,t){var e=C.normalizeAngle(t);return n.clockwise?Ho(e):e}function Ho(n){var t=n*180/Math.PI;return(360-t)%360*(Math.PI/180)}function B0(n,t,e){if(n.clockwise){var i=t-e;return V.isNonPositive(i)&&(i+=Y),i}var r=e-t;return V.isNonPositive(r)&&(r+=Y),r}function F0(n){return n.kind==="line"?n.start.clone():n.arc.startPoint.clone()}function D0(n){return n.kind==="line"?n.end.clone():n.arc.endPoint.clone()}function bl(n,t,e,i){return n.kind==="line"&&t.kind==="line"?{point:Wo({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"?_l(n,t.arc,e,i,!0):n.kind==="arc"&&t.kind==="line"?_l(t,n.arc,e,i,!1):n.kind==="arc"&&t.kind==="arc"?X0(n.arc,t.arc,e,i):{point:e.clone()}}function X0(n,t,e,i){var r=gu(n.endPoint,t.startPoint),s=U0(n,t),o=s.filter(function(h){return Tr(n,h)&&Tr(t,h)});if(o.length>0)return{point:du(o,r)};var a=n.endPoint.clone(),c=t.startPoint.clone(),l=uu(e,Math.abs(i),a,c);return{point:a,filletPoints:l,nextSegmentStart:c}}function _l(n,t,e,i,r){var s=gu(r?n.end:n.start,r?t.startPoint:t.endPoint),o=j0(n,t,s);if(z0(n,o)&&Tr(t,o))return{point:o};var a=Y0(n,e,i),c=r?t.startPoint.clone():t.endPoint.clone(),l=uu(e,Math.abs(i),r?a:c,r?c:a);return r?{point:a,filletPoints:l,nextSegmentStart:c}:{point:c,filletPoints:l,nextSegmentStart:a}}function Y0(n,t,e){var i=Math.hypot(n.dx,n.dy),r=-n.dy/i*e,s=n.dx/i*e;return new M(t.x+r,t.y+s)}function z0(n,t){var e=Math.hypot(n.dx,n.dy);if(V.isNonPositive(e))return!1;var i=n.dx/e,r=n.dy/e,s=t.x-n.start.x,o=t.y-n.start.y,a=Math.abs(s*r-o*i);return V.equalToZero(a)}function uu(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),o=V0(r,s);if(V.equalToZero(Math.abs(o)))return[];for(var a=[],c=Math.max(2,Math.ceil(Math.abs(o)/Math.PI*16)),l=1;l<c;l++){var h=l/c,u=r+o*h;a.push(new M(n.x+t*Math.cos(u),n.y+t*Math.sin(u)))}return a}function V0(n,t){for(var e=t-n;e>Math.PI;)e-=Y;for(;e<=-Math.PI;)e+=Y;return e}function j0(n,t,e){var i=Math.hypot(n.dx,n.dy);if(V.isNonPositive(i))return e.clone();var r=n.dx/i,s=n.dy/i,o=n.start.x-t.center.x,a=n.start.y-t.center.y,c=2*(o*r+a*s),l=o*o+a*a-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(f){return new M(n.start.x+r*f,n.start.y+s*f)}),g=d.filter(function(f){return Tr(t,f)});return du(g.length>0?g:d,e)}function Tr(n,t){var e=Math.abs(Math.hypot(t.x-n.center.x,t.y-n.center.y)-n.radius);if(V.isPositive(e))return!1;var i=Go(n,t),r=n.clockwise?Ho(C.normalizeAngle(n.startAngle)):C.normalizeAngle(n.startAngle),s=n.clockwise?Ho(C.normalizeAngle(n.endAngle)):C.normalizeAngle(n.endAngle);return C.isBetweenAngle(i,r,s,n.clockwise)}function U0(n,t){var e=t.center.x-n.center.x,i=t.center.y-n.center.y,r=Math.hypot(e,i);if(V.isNonPositive(r))return[];var s=n.radius+t.radius,o=Math.abs(n.radius-t.radius);if(r>s+ir)return[];if(r<o-ir)return[];var a=(n.radius*n.radius-t.radius*t.radius+r*r)/(2*r),c=n.radius*n.radius-a*a;if(c<-ir)return[];var l=n.center.x+a*e/r,h=n.center.y+a*i/r;if(c<=ir)return[new M(l,h)];var u=Math.sqrt(c),d=-i*u/r,g=e*u/r;return[new M(l+d,h+g),new M(l-d,h-g)]}function du(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 gu(n,t){return new M((n.x+t.x)/2,(n.y+t.y)/2)}function G0(n){for(var t,e=n.numberOfVertices,i=n.closed?e:e-1,r=0;r<i;r++){var s=n.vertices[r];if(V.isPositive(Math.abs((t=s.bulge)!==null&&t!==void 0?t:0)))return!0}return!1}function fu(n){var t=H0(n.vertices.map(function(e){return new M(e.x,e.y)}),n.closed);return t.length===n.numberOfVertices?n:new it(t.map(function(e){return{x:e.x,y:e.y}}),n.closed)}function H0(n,t){var e=pu(n);if(!t||e.length<2)return e;var i=e[0],r=e[e.length-1];return V.isNonPositive(Math.hypot(i.x-r.x,i.y-r.y))&&e.pop(),e}function pu(n){var t=[];return n.forEach(function(e){var i=t[t.length-1];(!i||V.isPositive(Math.hypot(i.x-e.x,i.y-e.y)))&&t.push(new M(e.x,e.y))}),t}function W0(n,t){for(var e=[],i=0;i<n.numberOfVertices;i++)e.push(n.getPointAt(i));var r=$0(e,n.closed,t);if(r.length===0)return null;var s=[];if(n.closed){if(r.length<2)return null;for(var o=r.length,i=0;i<o;i++){var a=r[(i-1+o)%o],c=r[i];s.push(Wo(a,c))}}else{s.push(r[0].start);for(var i=1;i<r.length;i++)s.push(Wo(r[i-1],r[i]));s.push(r[r.length-1].end)}var l=new it;return s.forEach(function(h,u){l.addVertexAt(u,{x:h.x,y:h.y})}),l.closed=n.closed,l}function $0(n,t,e){for(var i=[],r=t?n.length:n.length-1,s=0;s<r;s++){var o=n[s],a=n[t?(s+1)%n.length:s+1],c=a.x-o.x,l=a.y-o.y,h=Math.hypot(c,l);if(!V.isNonPositive(h)){var u=-l/h*e,d=c/h*e;i.push({start:new M(o.x+u,o.y+d),end:new M(a.x+u,a.y+d),dx:c,dy:l})}}return i}function Wo(n,t){var e=n.dx*t.dy-n.dy*t.dx;if(V.equalToZero(e))return new M((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 M(n.start.x+s*n.dx,n.start.y+s*n.dy)}var q0=(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)}})(),$o=function(){return $o=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},$o.apply(this,arguments)},it=(function(n){q0(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 M(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 M(i.x,i.y)}else{var i=this._vertices[e-1];return new M(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],o=null;if(r<i-1?o=this._vertices[r+1]:r==i-1&&this.closed&&(o=this._vertices[0]),o)if(s.bulge){var a=new $(s,o,s.bulge);e+=a.length}else e+=new M(s.x,s.y).distanceTo(o)}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 h0(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 M(i.x,i.y)},t.prototype.calculateBoundingBox=function(){var e=this.getPoints(100);return new kt().setFromPoints(e)},t.prototype.transform=function(e){var i=e.determinant()<0;return this._vertices.forEach(function(r){var s=new M(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 $o({},e)}),this._closed)},t.prototype.getPoints3d=function(e,i){var r=[],s=this.getPoints(e);return s.forEach(function(o){return r.push(new _().set(o.x,o.y,i))}),r},t.prototype.getPoints=function(e){for(var i=[],r=this._vertices.length,s=0;s<r;++s){var o=this._vertices[s];if(o.bulge){var a=null;if(s<r-1?a=this._vertices[s+1]:s==r-1&&this.closed&&(a=this._vertices[0]),a)for(var c=new $(o,a,o.bulge),l=c.getPoints(e),h=l.length,u=0;u<h;++u){var d=l[u];i.push(new M(d.x,d.y))}}else i.push(new M(o.x,o.y)),s==r-1&&this.closed&&i.push(i[0])}return i},t.prototype.tessellate=function(e){for(var i=[],r=this._vertices.length,s=0;s<r;++s){var o=this._vertices[s];if(o.bulge){var a=null;if(s<r-1?a=this._vertices[s+1]:s===r-1&&this.closed&&(a=this._vertices[0]),a)for(var c=new $(o,a,o.bulge),l=c.tessellate(e),h=0;h<l.length;++h)xl(i,l[h])}else xl(i,o),s===r-1&&this.closed&&i.length>0&&i.push(i[0].clone())}return i},t.prototype.offset=function(e){return hu(this,e)},t})(Kn);function xl(n,t){var e=n[n.length-1];if(e){var i=e.x-t.x,r=e.y-t.y;if(i*i+r*r<=W*W)return}n.push(new M(t.x,t.y))}function mu(n,t,e){var i=Math.hypot(t.x,t.y);if(V.isNonPositive(i))return null;var r=-t.y/i*e,s=t.x/i*e;return new _(n.x+r,n.y+s,n.z)}function K0(n,t,e){var i;if(n.length<2)return null;var r=P0(new it(n.map(function(o){return{x:o.x,y:o.y}}),t)),s=hu(r,e);return(i=s[0])!==null&&i!==void 0?i:null}var Lr=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Cn=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 Z0(n,t,e,i){if(n.length<2||V.equalToZero(e))return null;var r=bu(n,i),s=r.points,o=r.tangents;if(s.length<2)return null;var a=o??Q0(s,t),c=J0(s,a,e),l=t?em(c):tm(c);if(l.length<2)return null;var h=new it;return l.forEach(function(u,d){h.addVertexAt(d,{x:u.x,y:u.y})}),h.closed=t,h}function Q0(n,t){for(var e=n.length,i=new Array(e),r=0;r<e;r++){var s=0,o=0;if(t){var a=n[(r-1+e)%e],c=n[(r+1)%e];s=c.x-a.x,o=c.y-a.y}else r===0?(s=n[1].x-n[0].x,o=n[1].y-n[0].y):r===e-1?(s=n[e-1].x-n[e-2].x,o=n[e-1].y-n[e-2].y):(s=n[r+1].x-n[r-1].x,o=n[r+1].y-n[r-1].y);var l=Math.hypot(s,o);V.isNonPositive(l)?i[r]=new M(1,0):i[r]=new M(s/l,o/l)}return i}function J0(n,t,e){return n.map(function(i,r){var s=t[r],o=-s.y*e,a=s.x*e;return new M(i.x+o,i.y+a)})}function tm(n){var t=Mr(n);if(t.length<3)return t;for(;;){var e=yu(t,!1);if(!e||(t=Mr(Cn(Cn(Cn([],Lr(t.slice(0,e.segmentA+1)),!1),[e.point],!1),Lr(t.slice(e.segmentB+1)),!1)),t.length<2))break}return t}function em(n){var t=Mr(n);if(t.length<4)return t;for(;;){var e=yu(t,!0);if(!e||(t=Mr(Cn(Cn(Cn([],Lr(t.slice(0,e.segmentA+1)),!1),[e.point],!1),Lr(t.slice(e.segmentB+1)),!1)),t.length<3))break}return t}function yu(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],o=i+1;o<e;o++)if(!nm(i,o,e,t)){var a=n[o],c=n[(o+1)%n.length],l=im(r,s,a,c);if(l)return{point:l,segmentA:i,segmentB:o}}return null}function nm(n,t,e,i){return!!(t===n||t===n+1||i&&n===0&&t===e-1)}function im(n,t,e,i){var r=t.x-n.x,s=t.y-n.y,o=i.x-e.x,a=i.y-e.y,c=r*a-s*o;if(V.equalToZero(c))return null;var l=e.x-n.x,h=e.y-n.y,u=(l*a-h*o)/c,d=(l*s-h*r)/c,g=Vi.equalPointTol;return u<-g||u>1+g||d<-g||d>1+g?null:new M(n.x+u*r,n.y+u*s)}function bu(n,t){var e=[],i=[],r=t!=null&&t.length===n.length;return n.forEach(function(s,o){var a=e[e.length-1];if((!a||V.isPositive(Math.hypot(a.x-s.x,a.y-s.y)))&&(e.push(new M(s.x,s.y)),r)){var c=t[o];i.push(new M(c.x,c.y))}}),{points:e,tangents:r?i:void 0}}function Mr(n){return bu(n).points}var rm=(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)}})(),oe=(function(n){rm(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 kt},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],o=s.getPoints(e);i.push(o)}return i},t.prototype.tessellate=function(e){return this.loops.map(function(i){return i.tessellate(e)})},t.prototype.buildHierarchy=function(e){for(var i,r=this.tessellate(e),s=this.calculateBoundaryBoxes(r),o=this.sortBoundaryBoxesByAreas(s),a=new Map,c=o.length,l=0;l<c;l++)a.set(o[l],{index:o[l],children:[]});for(var h={index:-1,children:[]},l=0;l<c;l++){for(var u=o[l],d=r[u],g=s[u],f=l+1;f<c;f++){var p=o[f],m=r[p],y=s[p];if(y.containsBox(g)&&Lt.isPointInPolygon(d[C.randInt(0,d.length-1)],m)){(i=a.get(p))===null||i===void 0||i.children.push(a.get(u));break}}f===c&&h.children.push(a.get(u))}return h},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),o=nu(s);i===0?e+=Math.abs(o):e-=Math.abs(o)}return e},enumerable:!1,configurable:!0}),t.prototype.calculateBoundaryBoxes=function(e){var i=[];return e.forEach(function(r){i.push(new kt().setFromPoints(r))}),i},t.prototype.sortBoundaryBoxesByAreas=function(e){var i=[];e.forEach(function(s,o){var a=s.size,c=a.width*a.height;i.push({area:c,index:o})}),i.sort(function(s,o){return s.area-o.area});var r=[];return i.forEach(function(s){r.push(s.index)}),r},t})(Ga),sm=(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)}})(),om=(function(n){sm(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})(lu),am=(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)}})(),un=(function(n){am(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.tessellateParametricCurve=function(e,i,r,s){var o=Math.max(2,Math.round(s.maxSegments)),a=Math.max(1,Math.round(s.minSegments)),c=Math.max(0,s.deviation)*Math.max(0,s.deviation);if(!Number.isFinite(e)||!Number.isFinite(i))return[r(0)];if(Math.abs(i-e)<=W)return[r(e)];for(var l=Math.min(o,Math.max(2,a+1)),h=Math.min(o,Math.max(l,8)),u=lm(e,i,h),d=[],g=0;g<u.length;g++)d.push(r(u[g]));for(var f=d.length,p=0;p<8&&f<o;p++){for(var m=[],g=0;g<u.length-1&&!(f>=o);g++){var y=(u[g]+u[g+1])/2,b=r(y);f++,cm(b,d[g],d[g+1])>c&&m.push({index:g,t:y,point:b})}if(m.length===0)break;var w=hm(u,d,m);u=w.params,d.length=0;for(var g=0;g<w.points.length;g++)d.push(w.points[g])}return d},t})(om);function cm(n,t,e){var i=e.x-t.x,r=e.y-t.y,s=e.z-t.z,o=n.x-t.x,a=n.y-t.y,c=n.z-t.z,l=i*i+r*r+s*s;if(l<=W*W)return o*o+a*a+c*c;var h=Jt((o*i+a*r+c*s)/l,0,1),u=o-i*h,d=a-r*h,g=c-s*h;return u*u+d*d+g*g}function lm(n,t,e){if(e<=1)return[n];for(var i=[],r=0;r<e;r++)i.push(r===e-1?t:n+(t-n)*r/(e-1));return i}function hm(n,t,e){for(var i=[],r=[],s=0,o=0;o<n.length;o++)for(i.push(n[o]),r.push(t[o]);s<e.length&&e[s].index===o;)i.push(e[s].t),r.push(e[s].point),s++;return{params:i,points:r}}var um=(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)}})(),Cr=function(){return Cr=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},Cr.apply(this,arguments)},po=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.")},Pt=(function(n){um(t,n);function t(e,i,r,s,o,a){a===void 0&&(a=A.X_AXIS);var c=n.call(this)||this;return c.center=e,c.radius=i,c.startAngle=r,c.endAngle=s,c.normal=o,c.refVec=a,(s-r)%Y==0?(c.startAngle=0,c.endAngle=Y):(c.startAngle=r,c.endAngle=s),c}return t.computeCenterPoint=function(e,i,r){var s,o;return(o=(s=ml(e,r,i))===null||s===void 0?void 0:s.center)!==null&&o!==void 0?o:null},t.tryCreateByThreePoints=function(e,i,r){var s,o,a,c=ml(e,r,i);if(!c)return null;var l=c.center,h=c.radius,u=new A(e.x-l.x,e.y-l.y,((s=e.z)!==null&&s!==void 0?s:0)-l.z),d=new A(r.x-l.x,r.y-l.y,((o=r.z)!==null&&o!==void 0?o:0)-l.z),g=new A(i.x-l.x,i.y-l.y,((a=i.z)!==null&&a!==void 0?a:0)-l.z);if(u.lengthSq()===0||g.lengthSq()===0)return null;var f=new A().crossVectors(u,g);if(f.lengthSq()===0&&(f.crossVectors(u,d),f.lengthSq()===0))return null;f.normalize();var p=u.clone().normalize(),m=new A().crossVectors(f,p),y=function(w){return C.normalizeAngle(Math.atan2(w.dot(m),w.dot(p)))};C.isAngleOnCcwSweep(0,y(d),y(g))||(f.negate(),m.negate());var b=y(g);return V.equalToZero(b)&&(b=Y),new t(l,h,0,b,f,p)},t.createByThreePoints=function(e,i,r){return t.tryCreateByThreePoints(e,i,r)},Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new _(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 Ot.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==Y?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 A(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 A(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=Y);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 A(e.x,e.y,e.z||0),r=this.center,s=this.normal,o=i.clone().sub(r),a=o.dot(s),c=i.clone().sub(s.clone().multiplyScalar(a)),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,f=C.normalizeAngle(u-d);f<0&&(f=0),f>g&&(f=g);var p=this.getPointAtAngle(d+f),m=p.distanceTo(i),y=this.startPoint.distanceTo(i),b=this.endPoint.distanceTo(i);return y<m&&y<=b?this.startPoint.clone():b<m&&b<y?this.endPoint.clone():p},t.prototype.tangentPoints=function(e){var i,r,s=[],o=new A(e.x,e.y,e.z||0),a=this.center,c=this.normal,l=this.radius,h=o.clone().sub(a),u=h.dot(c),d=o.clone().sub(c.clone().multiplyScalar(u)),g=a.clone(),f=d.clone().sub(g),p=f.length();if(p<l)return s;var m=Math.acos(l/p),y=this.getAngle(d.clone()),b=[y+m,y-m];try{for(var w=po(b),x=w.next();!x.done;x=w.next()){var S=x.value,P=C.normalizeAngle(S-this.startAngle);P>=0&&P<=this.deltaAngle&&s.push(this.getPointAtAngle(this.startAngle+P))}}catch(v){i={error:v}}finally{try{x&&!x.done&&(r=w.return)&&r.call(w)}finally{if(i)throw i.error}}return s},t.prototype.perpendicularPoints=function(e){var i,r,s=[],o=new A(e.x,e.y,e.z||0),a=this.center,c=this.normal,l=this.radius,h=o.clone().sub(a),u=h.dot(c),d=o.clone().sub(c.clone().multiplyScalar(u)),g=d.clone().sub(a);if(g.lengthSq()<1e-24)return s;g.normalize();var f=[a.clone().add(g.clone().multiplyScalar(l)),a.clone().sub(g.clone().multiplyScalar(l))];try{for(var p=po(f),m=p.next();!m.done;m=p.next()){var y=m.value,b=this.getAngle(y.clone()),w=C.normalizeAngle(b-this.startAngle);w>=0&&w<=this.deltaAngle&&s.push(new _(y.x,y.y,y.z||0))}}catch(x){i={error:x}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}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 _(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 o=1/0,a=1/0,c=1/0,l=-1/0,h=-1/0,u=-1/0;try{for(var d=po(r),g=d.next();!g.done;g=d.next()){var f=g.value,p=this.getPointAtAngle(f);p.x<o&&(o=p.x),p.y<a&&(a=p.y),p.z<c&&(c=p.z),p.x>l&&(l=p.x),p.y>h&&(h=p.y),p.z>u&&(u=p.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 j({x:o,y:a,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=Y,s=0);for(var o=0;o<=e;o++){var a=s+r*(o/e),c=this.getPointAtAngle(a);i.push(c)}return i},t.prototype.tessellate=function(e){var i,r=this.closed?Y:this.deltaAngle,s=t.segmentCount(this.radius,r,Cr(Cr({},e),{minSegments:(i=e==null?void 0:e.minSegments)!==null&&i!==void 0?i:this.closed?8:3}));return this.getPoints(s)},t.segmentCount=function(e,i,r){return $.segmentCount(e,i,r)},t.prototype.transform=function(e){var i=this.center.clone().applyMatrix4(e),r=this.startPoint.clone().applyMatrix4(e),s=this.endPoint.clone().applyMatrix4(e),o=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(e),a=new A(r).sub(i).normalize(),c=i.distanceTo(r),l=new A().crossVectors(new A(r).sub(i),new A(o).sub(i)).normalize();l.lengthSq()===0&&(l=this.normal.clone().transformDirection(e));var h=function(u){var d=new A(u).sub(i);return Math.atan2(d.dot(wl.crossVectors(l,a)),d.dot(a))};return this.center=i,this.radius=c,this.normal=l,this.refVec=a,this.startAngle=0,this.endAngle=this.closed?Y: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(wl.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},o=this.center,a=this.radius;return new _(o.x+a*(r.x*Math.cos(e)+s.x*Math.sin(e)),o.y+a*(r.y*Math.cos(e)+s.y*Math.sin(e)),o.z+a*(r.z*Math.cos(e)+s.z*Math.sin(e)))},Object.defineProperty(t.prototype,"plane",{get:function(){var e=new A(this.center).distanceTo(za);return new Ds(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})(un),wl=new A,dm=(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)}})(),Ie=(function(n){dm(t,n);function t(e,i,r,s,o,a,c){s===void 0&&(s=0),o===void 0&&(o=Y),a===void 0&&(a=!1),c===void 0&&(c=0);var l=n.call(this)||this;return l.center=e,l.majorAxisRadius=i,l.minorAxisRadius=r,(o-s)%Y==0?(l.startAngle=0,l.endAngle=Y):(l.startAngle=s,l.endAngle=o),l.clockwise=a,l.rotation=c,l}return Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new _(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 Ot.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 Ot.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==Y?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,o=-1/0,a=0;a<=e;a++){var c=this.getPoint(a/e);i=Math.min(i,c.x),r=Math.min(r,c.y),s=Math.max(s,c.x),o=Math.max(o,c.y)}return new kt({x:i,y:r},{x:s,y:o})},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 o=this.startAngle+e*r,a=this.center.x+this.majorAxisRadius*Math.cos(o),c=this.center.y+this.minorAxisRadius*Math.sin(o);if(this.rotation!==0){var l=Math.cos(this.rotation),h=Math.sin(this.rotation),u=a-this.center.x,d=c-this.center.y;a=u*l-d*h+this.center.x,c=u*h+d*l+this.center.y}return new M(a,c)},t.prototype.transform=function(e){var i=e,r=new M(this.center).applyMatrix2d(i),s=new _(r.x,r.y,this.center.z),o=this.getPointAtAngle(0).clone().applyMatrix2d(i),a=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(i),c=new M(o).sub(r),l=new M(a).sub(r),h=c.length(),u=l.length(),d=Math.atan2(c.y,c.x),g=c.clone().normalize(),f=l.clone().normalize(),p=function(b){var w=new M(b).sub(r),x=w.dot(g),S=w.dot(f);return C.normalizeAngle(Math.atan2(S/u,x/h))},m=i.determinant()<0?!this.clockwise:this.clockwise,y=this.closed?new t(s,h,u,0,Y,m,d):new t(s,h,u,p(this.startPoint.clone().applyMatrix2d(i)),p(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/Y: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),o=Math.sin(this.rotation),a=this.majorAxisRadius>=this.minorAxisRadius,c=a?s:-o,l=a?o:s;return[new M(this.center.x-r*c,this.center.y-r*l),new M(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 M(e.x,e.y),r=this.getPoint(0),s=i.distanceToSquared(r),o=72,a=1;a<=o;a++){var c=this.getPoint(a/o),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(o,a,c,l){var h=-i.majorAxisRadius*l,u=i.minorAxisRadius*c;return(o-r.x)*u-(a-r.y)*h});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype.perpendicularPoints=function(e){var i=this,r=this._projectPointToLocal(e),s=this._findSnapAngles(r,function(o,a,c,l){var h=i.minorAxisRadius*c,u=i.majorAxisRadius*l;return(o-r.x)*u-(a-r.y)*h});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype._projectPointToLocal=function(e){var i=e.x-this.center.x,r=e.y-this.center.y,s=Math.cos(-this.rotation),o=Math.sin(-this.rotation);return{x:i*s-r*o,y:i*o+r*s}},t.prototype._findSnapAngles=function(e,i,r){r===void 0&&(r=144);for(var s=this.majorAxisRadius,o=this.minorAxisRadius,a=this.startAngle,c=this.deltaAngle,l=[],h=function(x){var S=Math.cos(x),P=Math.sin(x);return i(s*S,o*P,S,P)},u=a,d=h(u),g=1;g<=r;g++){var f=a+c*g/r,p=h(f);if(Math.abs(d)<1e-10&&l.push(u),d*p<0){for(var m=u,y=f,b=0;b<32;b++){var w=(m+y)/2;h(m)*h(w)<=0?y=w:m=w}l.push((m+y)/2)}u=f,d=p}return l},t})(Kn),gm=(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)}})(),Or=function(){return Or=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},Or.apply(this,arguments)},fm=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.")},Pe=(function(n){gm(t,n);function t(e,i,r,s,o,a,c){a===void 0&&(a=0),c===void 0&&(c=Y);var l=n.call(this)||this;l.center=e,l.normal=i,l.majorAxis=r,l.majorAxisRadius=s,l.minorAxisRadius=o;var h=Math.abs(c-a);return Math.abs(h-Y)<1e-10||Math.abs(h-2*Y)<1e-10?(l.startAngle=0,l.endAngle=Y):(l.startAngle=a,l.endAngle=c),l}return Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new _(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 Ot.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 Ot.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==Y?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-Y)<1e-10?Y: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 A(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 A(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 A().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-Y)<1e-10)&&(e=0,i=Y);var r=e+i/2;return this.getPointAtAngle(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCircular",{get:function(){return V.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),o=1;o<=e;o++){var a=this.startAngle+o*i,c=this.getPointAtAngle(a),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-Y)>=1e-10?0:Math.PI*this.majorAxisRadius*this.minorAxisRadius},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e,i;if(this.majorAxis.equals(A.X_AXIS)||this.majorAxis.equals(A.Y_AXIS)||this.majorAxis.isParallelTo(A.X_AXIS)||this.majorAxis.isParallelTo(A.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 o=1/0,a=1/0,c=1/0,l=-1/0,h=-1/0,u=-1/0;try{for(var d=fm(r),g=d.next();!g.done;g=d.next()){var f=g.value,p=this.getPointAtAngle(f);p.x<o&&(o=p.x),p.y<a&&(a=p.y),p.z<c&&(c=p.z),p.x>l&&(l=p.x),p.y>h&&(h=p.y),p.z>u&&(u=p.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 j({x:o,y:a,z:c},{x:l,y:h,z:u})}else{for(var m=100,o=1/0,a=1/0,c=1/0,l=-1/0,h=-1/0,u=-1/0,s=0;s<=m;s++){var f=this.startAngle+this.deltaAngle*(s/m),p=this.getPointAtAngle(f);o=Math.min(o,p.x),a=Math.min(a,p.y),c=Math.min(c,p.z),l=Math.max(l,p.x),h=Math.max(h,p.y),u=Math.max(u,p.z)}return new j({x:o,y:a,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=Y,s=0);for(var o=0;o<=e;o++){var a=s+r*(o/e),c=this.getPointAtAngle(a);i.push(c)}return i},t.prototype.tessellate=function(e){var i=this,r,s,o=$.resolveTessellateOptions(e),a=this.closed?Y:this.deltaAngle,c=Math.max(this.majorAxisRadius,this.minorAxisRadius),l=Math.abs(a)>=Y-1e-8,h=(r=o.minSegments)!==null&&r!==void 0?r:l?8:3;if(this.isCircular){var u=Pt.segmentCount(c,a,Or(Or({},e),{minSegments:h}));return this.getPoints(u)}var d=(s=o.deviation)!==null&&s!==void 0?s:$.chordDeviationFromRadius(c,o.circleSides),g=this.closed?0:this.startAngle;return un.tessellateParametricCurve(g,g+a,function(f){return i.getPointAtAngle(f)},{deviation:Math.max(W,d),minSegments:h,maxSegments:o.maxSegments})},t.prototype.getPointAtAngle=function(e){var i=Math.cos(e),r=Math.sin(e),s=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(r),o=this.majorAxis.clone().multiplyScalar(i*this.majorAxisRadius).add(s);return new _(this.center.x+o.x,this.center.y+o.y,this.center.z+o.z)},t.prototype.nearestPoint=function(e,i){i===void 0&&(i=72);for(var r=new _(e.x,e.y,e.z||0),s=this.getPointAtAngle(this.startAngle),o=r.distanceToSquared(s),a=1;a<=i;a++){var c=this.startAngle+this.deltaAngle*a/i,l=this.getPointAtAngle(c),h=r.distanceToSquared(l);h<o&&(o=h,s=l)}var u=r.distanceToSquared(this.startPoint),d=r.distanceToSquared(this.endPoint);return u<o&&u<=d?this.startPoint.clone():d<o&&d<u?this.endPoint.clone():s.clone()},t.prototype.tangentPoints=function(e){var i=this,r=this._projectPointToLocalPlane(e),s=this._findSnapParameterAngles(function(o,a,c,l){var h=-i.majorAxisRadius*l,u=i.minorAxisRadius*c;return(o-r.x)*u-(a-r.y)*h});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype.perpendicularPoints=function(e){var i=this,r=this._projectPointToLocalPlane(e),s=this._findSnapParameterAngles(function(o,a,c,l){var h=i.minorAxisRadius*c,u=i.majorAxisRadius*l;return(o-r.x)*u-(a-r.y)*h});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype._projectPointToLocalPlane=function(e){var i=new _(e.x,e.y,e.z||0),r=new A(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,o=this.startAngle,a=this.deltaAngle,c=[],l=function(w){var x=Math.cos(w),S=Math.sin(w);return e(r*x,s*S,x,S)},h=o,u=l(h),d=1;d<=i;d++){var g=o+a*d/i,f=l(g);if(Math.abs(u)<1e-10&&c.push(h),u*f<0){for(var p=h,m=g,y=0;y<32;y++){var b=(p+m)/2;l(p)*l(b)<=0?m=b:p=b}c.push((p+m)/2)}h=g,u=f}return c},t.prototype.contains=function(e){var i=new A(e).sub(this.center),r=i.dot(this.majorAxis),s=i.dot(this.minorAxis),o=r/this.majorAxisRadius,a=s/this.minorAxisRadius;return o*o+a*a<=1},t.prototype.transform=function(e){var i=e,r=this.center.clone().applyMatrix4(i),s=this.getPointAtAngle(0).clone().applyMatrix4(i),o=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(i),a=new A(s).sub(r),c=new A(o).sub(r),l=a.length(),h=c.length(),u=a.clone().normalize(),d=new A().crossVectors(a,c).normalize(),g=new A().crossVectors(d,u).normalize();g.dot(c)<0&&(d.negate(),g=new A().crossVectors(d,u).normalize());var f=function(m){var y=new A(m).sub(r),b=y.dot(u),w=y.dot(g);return C.normalizeAngle(Math.atan2(w/h,b/l))},p=this.closed?new t(r,d,u,l,h,0,Y):new t(r,d,u,l,h,f(this.startPoint.clone().applyMatrix4(i)),f(this.endPoint.clone().applyMatrix4(i)));return this.center=p.center,this.normal=p.normal,this.majorAxis=p.majorAxis,this.majorAxisRadius=p.majorAxisRadius,this.minorAxisRadius=p.minorAxisRadius,this._startAngle=p._startAngle,this._endAngle=p._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 A(this.center).distanceTo(za);return new Ds(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})(un),pm=(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){pm(t,n);function t(e,i){var r=n.call(this)||this;return r._start=new M(e),r._end=new M(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 M(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),i=new M(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new kt(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 o=((e.x-this._start.x)*i+(e.y-this._start.y)*r)/s;return o=Math.max(0,Math.min(1,o)),new M(this._start.x+o*i,this._start.y+o*r)},t.prototype.nearestPoint=function(e){return this.project(e)},t})(Kn),mm=(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)}})(),Dt=(function(n){mm(t,n);function t(e,i){var r=n.call(this)||this;return r._start=new _(e),r._end=new _(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 A().subVectors(this.endPoint,this.startPoint).normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){return new _((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(tn).normalize();return new _(this._start).addScaledVector(r,e)}else{var r=this.delta(tn).normalize();return new _(this._end).addScaledVector(r,e)}},t.prototype.extend=function(e,i){if(i===void 0&&(i=!1),i){var r=tn.subVectors(this._start,this._end).normalize();this._start=new _(this._start).addScaledVector(r,e)}else{var r=this.delta(tn).normalize();this._end=new _(this._end).addScaledVector(r,e)}return this._boundingBoxNeedsUpdate=!0,this},t.prototype.closestPointToPointParameter=function(e,i){vl.subVectors(e,this._start),rr.subVectors(this.endPoint,this.startPoint);var r=rr.dot(rr),s=rr.dot(vl),o=s/r;return i&&(o=C.clamp(o,0,1)),o},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=tn.subVectors(e,this.startPoint),s=r.dot(i);return new _().copy(i).multiplyScalar(s).add(this.startPoint)},t.prototype.perpPoint=function(e){var i=this.direction,r=this.startPoint,s=tn.subVectors(e,r),o=s.dot(i),a=tn.copy(i).multiplyScalar(o);return new _().addVectors(r,a)},t.prototype.calculateBoundingBox=function(){var e=new _(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 _(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 j(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 o=new A(r.x-i.x,r.y-i.y,0).normalize(),a=new A(-o.y,o.x,0);return new t(new _(i.x+a.x*e,i.y+a.y*e,i.z),new _(r.x+a.x*e,r.y+a.y*e,r.z))},t})(un),tn=new A,vl=new A,rr=new A,ym=(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)}})(),mo=(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,o,a){var c=(e-t)/s-(i-t)/(s+o)+(i-e)/o,l=(i-e)/o-(r-e)/(o+a)+(r-i)/a;c*=o,l*=o,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})(),_u=(function(n){ym(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 o=n.call(this)||this;return o.isCatmullRomCurve3d=!0,o.type="CatmullRomCurve3d",o._tmp=new A,o._px=new mo,o._py=new mo,o._pz=new mo,o._points=e.map(function(a){return new _(a)}),o._closed=i,o._curveType=r,o._tension=s,o}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 _},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this._points.length>0?this._points[this._points.length-1]:new _},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 _);var r=i,s=this._points,o=s.length;if(o===0)return r.set(0,0,0);if(o===1)return r.copy(s[0]);var a=(o-(this._closed?0:1))*e,c=Math.floor(a),l=a-c;this._closed?c+=c>0?0:(Math.floor(Math.abs(c)/o)+1)*o:l===0&&c===o-1&&(c=o-2,l=1);var h,u;this._closed||c>0?h=s[(c-1)%o]:(this._tmp.subVectors(s[0],s[1]).add(s[0]),h=new _(this._tmp.x,this._tmp.y,this._tmp.z));var d=s[c%o],g=s[(c+1)%o];if(this._closed||c+2<o?u=s[(c+2)%o]:(this._tmp.subVectors(s[o-1],s[o-2]).add(s[o-1]),u=new _(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){var f=this._curveType==="chordal"?.5:.25,p=Math.pow(h.distanceToSquared(d),f),m=Math.pow(d.distanceToSquared(g),f),y=Math.pow(g.distanceToSquared(u),f);m<1e-4&&(m=1),p<1e-4&&(p=m),y<1e-4&&(y=m),this._px.initNonuniformCatmullRom(h.x,d.x,g.x,u.x,p,m,y),this._py.initNonuniformCatmullRom(h.y,d.y,g.y,u.y,p,m,y),this._pz.initNonuniformCatmullRom(h.z,d.z,g.z,u.z,p,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 _(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 _;return r.copy(i),r.applyMatrix4(e),r}),this._boundingBoxNeedsUpdate=!0,this},t.prototype.calculateBoundingBox=function(){if(this._points.length===0)return new j;var e=new j;return this._points.forEach(function(i){e.expandByPoint(i)}),e},t})(un),An=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Pn=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 Al(n,t){var e,i,r=n.x-t[0],s=n.y-t[1],o=((e=n.z)!==null&&e!==void 0?e:0)-((i=t[2])!==null&&i!==void 0?i:0);return r*r+s*s+o*o}var qt=(function(){function n(t,e,i,r){this._degree=t,this._knots=Pn([],An(e),!1),this._controlPoints=i.map(function(s){return{x:s.x,y:s.y,z:s.z}}),this._weights=r?Pn([],An(r),!1):new Array(i.length).fill(1)}return n.prototype.degree=function(){return this._degree},n.prototype.knots=function(){return Pn([],An(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 Pn([],An(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 i0(t,this._degree,this._knots,e,this._weights)},n.prototype.signedPlanarCurvatureAt=function(t){var e=this.evaluate(t);return r0(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(),o=s.start,a=s.end,c=this.length(),l=Math.max(64,Math.ceil(c/Math.max(r*.2,1e-6))),h=bm(o,a,Math.min(l,e)),u=0;u<8&&h.length<e;u++){for(var d=[],g=0;g<h.length-1;g++){var f=h[g],p=h[g+1],m=(f+p)/2,y=Math.max(Math.abs(this.signedPlanarCurvatureAt(f)),Math.abs(this.signedPlanarCurvatureAt(p)),Math.abs(this.signedPlanarCurvatureAt(m)));r*y>.85&&d.push(m)}if(d.length===0)break;if(h=_m(h,d),h.length>e){h=h.slice(0,e);break}}var b=[],w=[];return h.forEach(function(x){var S=i.evaluate(x);b.push(new M(S.point[0],S.point[1]));var P=S.deriv1[0],v=S.deriv1[1],k=Math.hypot(P,v);w.push(k>1e-10?new M(P/k,v/k):new M(1,0))}),{points:b,tangents:w}},n.prototype.length=function(){var t=this._controlPoints.map(function(e){return[e.x,e.y,e.z]});return tu(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 o=Va(t,e,i,r,s),a=o.controlPoints.map(function(c){return{x:c[0],y:c[1],z:c[2]}});return new n(e,o.knots,a,o.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,o=0;o<=t;o++){var a=r+(s-r)*(o/t);e.push(this.point(a))}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),o=this.point(r),a=s[0]-o[0],c=s[1]-o[1],l=s[2]-o[2];return Math.sqrt(a*a+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 _u(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,o=r.end,a=this.point(s),c=Al(t,a),l=0;l<=e;l++){var h=s+(o-s)*l/e,u=this.point(h),d=Al(t,u);d<c&&(c=d,a=u)}return{x:a[0],y:a[1],z:(i=a[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(o){return[o.x,o.y,o.z]});return n.byPoints(s,e,i)},n})();function bm(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 _m(n,t){var e=Pn(Pn([],An(n),!1),An(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 Pl(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,o=(i=n.z)!==null&&i!==void 0?i:0;return r*r+s*s+o*o>1e-20}function xm(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 wm(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 vm(n,t){if(!(!n||n.length!==t))return n}var Am=(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)}})(),Sl=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},kl=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))},El=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.")},Ut=(function(n){Am(t,n);function t(e,i,r,s,o,a){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 Ot.ILLEGAL_PARAMETERS;c._controlPoints=e;var g=void 0,f=3,p=!1;if(l>=3&&(Array.isArray(r)?(g=r,l>=4&&(f=s||3),l>=5&&(p=o)):r!==void 0&&(f=r||3,l>=4&&(p=s))),r===void 0&&l>=4&&(f=s||3,l>=5&&(p=o)),c._degree=f,c._closed=p,c._controlPoints.length<c._degree+1)throw Ot.ILLEGAL_PARAMETERS;c._nurbsCurve=qt.byKnotsControlPointsWeights(c._degree,i,c._controlPoints,g)}else{if(l<2||l>6)throw Ot.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=o),l>=6&&(c._endTangent=a)):(l>=4&&(c._startTangent=s),l>=5&&(c._endTangent=o)),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 Ot.ILLEGAL_PARAMETERS;if(c._closed)c._nurbsCurve=qt.createClosedCurve(c._fitPoints,c._degree,c._knotParameterization);else{var d=c.toNurbsPoints(c._fitPoints);c._nurbsCurve=qt.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=qt.createFitPointsForClosedCurve(this._fitPoints),i=this.toNurbsPoints(e);this._nurbsCurve=qt.byPoints(i,this._degree,this._knotParameterization)}else{var i=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=qt.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(o){return[o.x,o.y,o.z||0]}))}else if(this._controlPoints)if(this._closed){var e=qt.createFitPointsForClosedCurve(this._controlPoints),i=this.toNurbsPoints(e);this._nurbsCurve=qt.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=qt.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(Lt.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(Lt.point2dToPoint3d)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"knots",{get:function(){return kl([],Sl(this._nurbsCurve.knots()),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"weights",{get:function(){return kl([],Sl(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 _(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 _(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 _(r.x,r.y,r.z||0)},t.prototype.evaluateAt=function(e){var i=this._nurbsCurve.point(e);return new _(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 Lt.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 _(e.x,e.y,(i=e.z)!==null&&i!==void 0?i:0)}):this._controlPoints.map(function(e){var i;return new _(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 o=El(e),a=o.next();!a.done;a=o.next()){var c=a.value;if(!(!Number.isInteger(c)||c<0)){var l=this._fitPoints[c];l&&Lt.applyOffsetToPoint3d(l,i)}}}catch(h){r={error:h}}finally{try{a&&!a.done&&(s=o.return)&&s.call(o)}finally{if(r)throw r.error}}this._boundingBoxNeedsUpdate=!0,this.buildCurve()}},t.prototype.moveControlPointsAt=function(e,i){var r,s;try{for(var o=El(e),a=o.next();!a.done;a=o.next()){var c=a.value;if(!(!Number.isInteger(c)||c<0)){var l=this.getControlPointAt(c);l&&Lt.applyOffsetToPoint3d(l,i)}}}catch(h){r={error:h}}finally{try{a&&!a.done&&(s=o.return)&&s.call(o)}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=qt.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(),o=this._nurbsCurve.degree(),a=s[o],c=s[s.length-o-1],l=(c-a)/(e-1),h=0;h<e;h++){var u=h===e-1?c:a+h*l,d=i.point(u);r.push(new _(d[0],d[1],d[2]))}return r},t.prototype.tessellate=function(e){var i=this,r,s,o=$.resolveTessellateOptions(e),a=this._nurbsCurve.knots(),c=this._nurbsCurve.degree();if(a.length<c+2)return[this.startPoint.clone(),this.endPoint.clone()];var l=a[c],h=a[a.length-c-1],u=o.circleSides,d=Math.abs(this.length),g=(r=o.deviation)!==null&&r!==void 0?r:Math.max(W,d<=W?W:d/(2*u*u));return un.tessellateParametricCurve(l,h,function(f){return i.evaluateAt(f)},{deviation:g,minSegments:(s=o.minSegments)!==null&&s!==void 0?s:this.closed?8:2,maxSegments:o.maxSegments})},t.prototype.getCurvePoints=function(e,i){for(var r=[],s=e.knots(),o=e.degree(),a=s[o],c=s[s.length-o-1],l=(c-a)/(i-1),h=0;h<i;h++){var u=a+h*l;r.push(e.point(u))}return r},t.prototype.calculateBoundingBox=function(){var e=this.getPoints(100);return new j().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 iu(e)},enumerable:!1,configurable:!0}),t.prototype.transform=function(e){if(this._fitPoints&&this._knotParameterization)this._fitPoints=this._fitPoints.map(function(s){return new _(s).applyMatrix4(e)}),this._startTangent&&(this._startTangent=new _(this._startTangent).transformDirection(e)),this._endTangent&&(this._endTangent=new _(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 _(s).applyMatrix4(e)}),this._nurbsCurve=qt.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(Lt.point2dToPoint3d),this._knotParameterization,this._degree,this._closed,this._startTangent?Lt.point2dToPoint3d(this._startTangent):void 0,this._endTangent?Lt.point2dToPoint3d(this._endTangent):void 0):new t(this._controlPoints.map(Lt.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,o){if(e.length<2||i.length<2)return null;var a=xm(s,e.length,i.length);if(e.length<a+1)return null;try{return new t(e,i,vm(r,e.length),a,o)}catch{return null}},t.fromFitPoints=function(e,i,r,s,o,a){if(e.length<2)return null;var c=Pl(o),l=Pl(a),h=(c?1:0)+(l?1:0),u=wm(r,e.length,h);if(e.length+h<u+1)return null;try{return c||l?new t(e,i,u,s,c?o:void 0,l?a: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(Lt.point2dToPoint3d),r=!0,s=e.controlPoints.map(function(a){return a.weight==null&&(r=!1),a.weight||1});return t.fromControlPoints(i,e.knots,r?s:void 0,e.degree,!1)}if(e.numberOfFitData>0){var o=e.fitDatum.map(Lt.point2dToPoint3d);return t.fromFitPoints(o,"Uniform",e.degree,!1,e.startTangent?Lt.point2dToPoint3d(e.startTangent):void 0,e.endTangent?Lt.point2dToPoint3d(e.endTangent):void 0)}return null},t})(un),Pm=(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)}})(),yo=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},bo=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))},On=(function(n){Pm(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=bo([],yo(e),!1),s=[],o=i*i,a=function(f,p){var m=f.x-p.x,y=f.y-p.y;return m*m+y*y<=o};r.length>0;){var c=[],l=r.shift();c.push(l);var h=t.getEdgeStartPoint(l),u=t.getEdgeEndPoint(l);if(!a(h,u))for(;r.length>0;){var d=t.findConnectingEdge(r,u,o);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),a(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 M(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 kt;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 Ut?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 M(s.x,s.y))})}),i},t.prototype.tessellate=function(e){var i=[];return this._curves.forEach(function(r){Sm(r,e).forEach(function(s){var o=i[i.length-1];o&&Math.pow(o.x-s.x,2)+Math.pow(o.y-s.y,2)<=W*W||i.push(new M(s.x,s.y))})}),i},t.findConnectingEdge=function(e,i,r){for(var s=-1,o=!1,a=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,f=d*d+g*g;f<a&&(a=f,s=c,o=!1);var p=i.x-u.x,m=i.y-u.y,y=p*p+m*m;y<a&&(a=y,s=c,o=!0)}return a>r?{index:-1,reverse:!1}:{index:s,reverse:o}},t.getEdgeStartPoint=function(e){var i=e.startPoint;return new M(i.x,i.y)},t.getEdgeEndPoint=function(e){var i=e.endPoint;return new M(i.x,i.y)},t.reverseEdge=function(e){return e instanceof Vt?new Vt(e.endPoint,e.startPoint):e instanceof $?t.reverseCircArcEdge(e):e instanceof Ie?new Ie(e.center,e.majorAxisRadius,e.minorAxisRadius,e.endAngle,e.startAngle,!e.clockwise,e.rotation):e instanceof Ut?t.reverseSplineEdge(e):e},t.reverseCircArcEdge=function(e){var i=e.startPoint,r=e.endPoint,s=!e.clockwise,o=Math.atan2(r.y-e.center.y,r.x-e.center.x),a=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 $(e.center,e.radius,c(o),c(a),s)},t.reverseSplineEdge=function(e){var i=bo([],yo(e.controlPoints),!1).reverse(),r=e.knots,s=r[0],o=r[r.length-1],a=r.map(function(h){return s+o-h}).reverse(),c=e.weights,l=c.length>0?bo([],yo(c),!1).reverse():void 0;return new Ut(i,a,l,e.degree,e.closed)},t})(Kn);function Sm(n,t){if(n instanceof Vt)return n.getPoints();if(n instanceof $||n instanceof Ut)return n.tessellate(t);var e=n.closed?Y:n.deltaAngle,i=$.segmentCount(Math.max(n.majorAxisRadius,n.minorAxisRadius),e,t);return n.getPoints(i)}var Gt=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.")},_i=128,Rr=96,X=Vi.equalPointTol,Ha=X*8;function km(n,t,e,i,r){var s,o,a,c;e===void 0&&(e=!1),i===void 0&&(i=!1);var l=Il(n,e,r),h=Il(t,i,r),u=[];try{for(var d=Gt(l),g=d.next();!g.done;g=d.next()){var f=g.value;try{for(var p=(a=void 0,Gt(h)),m=p.next();!m.done;m=p.next()){var y=m.value;Wa(f,y)&&Qa(u,vu(f,y))}}catch(b){a={error:b}}finally{try{m&&!m.done&&(c=p.return)&&c.call(p)}finally{if(a)throw a.error}}}}catch(b){s={error:b}}finally{try{g&&!g.done&&(o=d.return)&&o.call(d)}finally{if(s)throw s.error}}return Gm(u)}function Em(n,t){var e=Im(n);switch(e.kind){case"line":return e.line.transform(t),e;case"circArc":return e.arc.transform(t),e;case"ellipseArc":return e.arc.transform(t),e;case"spline":return e.spline.transform(t),e}}function Im(n){switch(n.kind){case"line":return{kind:"line",line:n.line.clone(),extent:n.extent,extendable:n.extendable};case"circArc":return{kind:"circArc",arc:n.arc.clone(),extendable:n.extendable};case"ellipseArc":return{kind:"ellipseArc",arc:n.arc.clone(),extendable:n.extendable};case"spline":return{kind:"spline",spline:n.spline.clone(),extendable:n.extendable}}}function Il(n,t,e){var i,r,s=[];try{for(var o=Gt(n),a=o.next();!a.done;a=o.next()){var c=a.value,l=t&&c.extendable!==!1;switch(c.kind){case"line":{var h=Cm(c.line,e);if(!h)break;var u=l?"unbounded":c.extent;s.push(Zn(h.start,h.end,u));break}case"circArc":{var d=Lm(c.arc,l);if(e&&!xi(d.normal,e.normal)){var g=Rm(d,e);(g==null?void 0:g.kind)==="circArc"?s.push(Tl(g.arc,me(g.arc))):(g==null?void 0:g.kind)==="ellipseArc"?s.push(Ll(g.arc,Ce(g.arc))):_o(s,xu(d,me(d)),me(d),e)}else{var g=Om(d,e);g&&s.push(Tl(g,me(g)))}break}case"ellipseArc":{var d=Mm(c.arc,l);if(e&&!xi(d.normal,e.normal))_o(s,wu(d,Ce(d)),Ce(d),e);else{var g=Nm(d,e);g&&s.push(Ll(g,Ce(g)))}break}case"spline":{e?_o(s,c.spline.getPoints(_i),c.spline.closed,e):s.push(Tm(c.spline));break}}}}catch(f){i={error:f}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function Zn(n,t,e){var i=new A().subVectors(t,n);return{kind:"line",start:n,dir:i,extent:e,box:e==="bounded"?new j().setFromPoints([n,t]):void 0}}function Tl(n,t){return{kind:"circArc",arc:n,full:t||me(n),box:n.box}}function Ll(n,t){return{kind:"ellipseArc",arc:n,full:t||Ce(n),box:n.box}}function Tm(n){var t,e,i=[],r=n.getPoints(_i);if(r.length>=2)for(var s=n.closed?r.length:r.length-1,o=0;o<s;o++){var a=r[o],c=r[(o+1)%r.length];a.distanceToSquared(c)<X*X||i.push(Zn(a.clone(),c.clone(),"bounded"))}var l=new j;try{for(var h=Gt(i),u=h.next();!u.done;u=h.next()){var d=u.value;d.box&&l.union(d.box)}}catch(g){t={error:g}}finally{try{u&&!u.done&&(e=h.return)&&e.call(h)}finally{if(t)throw t.error}}return{kind:"spline",spline:n,samples:i,box:i.length>0?l:void 0}}function Lm(n,t){return!t||me(n)?n:new Pt(n.center,n.radius,0,Y,n.normal,n.refVec)}function Mm(n,t){return!t||Ce(n)?n:new Pe(n.center,n.normal,n.majorAxis,n.majorAxisRadius,n.minorAxisRadius,0,Y)}function Cm(n,t){if(!t)return{start:n.startPoint.clone(),end:n.endPoint.clone()};var e=Me(n.startPoint,t),i=Me(n.endPoint,t);return e.distanceToSquared(i)<X*X?null:{start:e,end:i}}function Om(n,t){if(!t)return n;var e=Me(n.center,t);return new Pt(e,n.radius,n.startAngle,n.endAngle,t.normal.clone(),qa(n.refVec,t.normal))}function Rm(n,t){var e=Me(n.center,t),i=n.normal.clone();if(i.lengthSq()<X*X)return null;i.normalize();var r=t.normal.clone();if(r.lengthSq()<X*X)return null;r.normalize();var s=i.dot(r),o=Math.abs(s);if(o>1-1e-8)return{kind:"circArc",arc:new Pt(e,n.radius,n.startAngle,n.endAngle,r,qa(n.refVec,r))};if(o<1e-8)return null;var a=new A().crossVectors(i,r);if(a.lengthSq()<X*X)return null;a.normalize();var c=new Pe(e,r,a,n.radius,n.radius*o,0,Y);if(me(n))return{kind:"ellipseArc",arc:c};var l=Me(n.startPoint,t),h=Me(n.endPoint,t),u=Me(n.midPoint,t),d=Rn(c,l),g=Rn(c,h),f=Rn(c,u),p=C.normalizeAngle(f-d),m=C.normalizeAngle(g-d),y=p<=m||m<1e-8?d+m:d+m+Y;return{kind:"ellipseArc",arc:new Pe(e,r,a,n.radius,n.radius*o,d,y)}}function Nm(n,t){if(!t)return n;var e=Me(n.center,t),i=qa(n.majorAxis,t.normal);return i.lengthSq()<X*X?null:new Pe(e,t.normal.clone(),i,n.majorAxisRadius,n.minorAxisRadius,n.startAngle,n.endAngle)}function _o(n,t,e,i){if(!(t.length<2))for(var r=i?t.map(function(l){return Me(l,i)}):t,s=e?r.length:r.length-1,o=0;o<s;o++){var a=r[o],c=r[(o+1)%r.length];a.distanceToSquared(c)<X*X||n.push(Zn(a.clone(),c.clone(),"bounded"))}}function xu(n,t){return t||me(n)?new Pt(n.center,n.radius,0,Y,n.normal,n.refVec).getPoints(Rr):n.getPoints(Rr)}function wu(n,t){return t||Ce(n)?new Pe(n.center,n.normal,n.majorAxis,n.majorAxisRadius,n.minorAxisRadius,0,Y).getPoints(Rr):n.getPoints(Rr)}function Wa(n,t){return!n.box||!t.box?!0:n.box.intersectsBox(t.box)}function vu(n,t){return n.kind==="spline"&&t.kind==="spline"?Bm(n,t):n.kind==="spline"?Ml(n,t):t.kind==="spline"?Ml(t,n):n.kind==="line"&&t.kind==="line"?Au(n,t):n.kind==="line"&&t.kind==="circArc"?Nr(n,t.arc,t.full):t.kind==="line"&&n.kind==="circArc"?Nr(t,n.arc,n.full):n.kind==="line"&&t.kind==="ellipseArc"?qo(n,t.arc,t.full):t.kind==="line"&&n.kind==="ellipseArc"?qo(t,n.arc,n.full):n.kind==="circArc"&&t.kind==="circArc"?zm(n.arc,n.full,t.arc,t.full):n.kind==="circArc"&&t.kind==="ellipseArc"?Cl(n.arc,n.full,t.arc,t.full):n.kind==="ellipseArc"&&t.kind==="circArc"?Cl(t.arc,t.full,n.arc,n.full):n.kind==="ellipseArc"&&t.kind==="ellipseArc"?jm(n.arc,n.full,t.arc,t.full):[]}function Ml(n,t){var e,i,r=[];try{for(var s=Gt(n.samples),o=s.next();!o.done;o=s.next()){var a=o.value;Wa(a,t)&&Qa(r,vu(a,t))}}catch(c){e={error:c}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}return Fm(n.spline,r,t)}function Bm(n,t){var e,i,r,s,o,a,c=[];try{for(var l=Gt(n.samples),h=l.next();!h.done;h=l.next()){var u=h.value;try{for(var d=(r=void 0,Gt(t.samples)),g=d.next();!g.done;g=d.next()){var f=g.value;Wa(u,f)&&Qa(c,Au(u,f))}}catch(S){r={error:S}}finally{try{g&&!g.done&&(s=d.return)&&s.call(d)}finally{if(r)throw r.error}}}}catch(S){e={error:S}}finally{try{h&&!h.done&&(i=l.return)&&i.call(l)}finally{if(e)throw e.error}}var p=[];try{for(var m=Gt(c),y=m.next();!y.done;y=m.next()){var b=y.value,w=n.spline.nearestPoint(b,_i),x=t.spline.nearestPoint(b,_i);w.distanceTo(x)<=Ha&&p.push(w)}}catch(S){o={error:S}}finally{try{y&&!y.done&&(a=m.return)&&a.call(m)}finally{if(o)throw o.error}}return p}function Fm(n,t,e){var i,r,s=[];try{for(var o=Gt(t),a=o.next();!a.done;a=o.next()){var c=a.value,l=n.nearestPoint(c,_i);Dm(e,l)<=Ha&&s.push(l)}}catch(h){i={error:h}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function Dm(n,t){if(n.kind==="line"){var e=n.dir.lengthSq();if(e<X*X)return Number.POSITIVE_INFINITY;var i=new A().subVectors(t,n.start).dot(n.dir)/e;return Xn(i,n.extent)?Yn(n.start,n.dir,i).distanceTo(t):Number.POSITIVE_INFINITY}if(n.kind==="circArc"){if(!Za(t,n.arc)){var r=ee(n.arc.normal,n.arc.center),s=Math.abs(r.distanceToPoint(t)),o=Math.abs(t.distanceTo(n.arc.center)-n.arc.radius),a=Math.hypot(s,o);if(a>Ha)return a}return gn(n.arc,dn(n.arc,t),n.full)?0:Number.POSITIVE_INFINITY}return n.kind==="ellipseArc"?zn(t,n.arc,n.full)?0:Math.abs(Xs(n.arc,t)):Number.POSITIVE_INFINITY}function Au(n,t){var e=n.dir,i=t.dir,r=e.lengthSq(),s=i.lengthSq();if(r<X*X||s<X*X)return[];var o=new A().subVectors(n.start,t.start),a=e.dot(e),c=e.dot(i),l=i.dot(i),h=e.dot(o),u=i.dot(o),d=a*l-c*c;if(Math.abs(d)<W*W*a*l)return[];var g=(c*u-l*h)/d,f=(a*u-c*h)/d;if(!Xn(g,n.extent)||!Xn(f,t.extent))return[];var p=Yn(n.start,e,g),m=Yn(t.start,i,f);return p.distanceTo(m)>X?[]:[p]}function Nr(n,t,e){var i=ee(t.normal,t.center),r=Su(n,i);return r==="coplanar"?Xm(n,t,e):r?Za(r,t)?gn(t,dn(t,r),e)?[r]:[]:[]:[]}function Xm(n,t,e){var i,r,s=new A().subVectors(n.start,t.center),o=n.dir.dot(n.dir);if(o<X*X)return[];var a=2*n.dir.dot(s),c=s.dot(s)-t.radius*t.radius,l=[];try{for(var h=Gt(Eu(o,a,c)),u=h.next();!u.done;u=h.next()){var d=u.value;if(Xn(d,n.extent)){var g=Yn(n.start,n.dir,d);gn(t,dn(t,g),e)&&l.push(g)}}}catch(f){i={error:f}}finally{try{u&&!u.done&&(r=h.return)&&r.call(h)}finally{if(i)throw i.error}}return l}function qo(n,t,e){var i=ee(t.normal,t.center),r=Su(n,i);return r==="coplanar"?Ym(n,t,e):r?zn(r,t,e)?[r]:[]:[]}function Ym(n,t,e){var i,r,s=t.majorAxis,o=t.minorAxis,a=t.majorAxisRadius,c=t.minorAxisRadius;if(a<X||c<X)return[];var l=new A().subVectors(n.start,t.center),h=l.dot(s),u=l.dot(o),d=n.dir.dot(s),g=n.dir.dot(o),f=d*d/(a*a)+g*g/(c*c),p=2*h*d/(a*a)+2*u*g/(c*c),m=h*h/(a*a)+u*u/(c*c)-1,y=[];try{for(var b=Gt(Eu(f,p,m)),w=b.next();!w.done;w=b.next()){var x=w.value;if(Xn(x,n.extent)){var S=Yn(n.start,n.dir,x);Ka(t,Rn(t,S),e)&&y.push(S)}}}catch(P){i={error:P}}finally{try{w&&!w.done&&(r=b.return)&&r.call(b)}finally{if(i)throw i.error}}return y}function zm(n,t,e,i){if(xi(n.normal,e.normal)){var r=ee(n.normal,n.center);return Math.abs(r.distanceToPoint(e.center))>X?[]:Um(Vm(n,e),n,t,e,i)}var s=$a(ee(n.normal,n.center),ee(e.normal,e.center));if(!s)return[];var o=Zn(s.point.clone(),new _().addVectors(s.point,s.dir),"unbounded"),a=Nr(o,n,t);return a.filter(function(c){return Za(c,e)?gn(e,dn(e,c),i):!1})}function Vm(n,t){var e=new A().subVectors(t.center,n.center),i=e.length(),r=n.radius,s=t.radius;if(i<X&&V.equal(r,s,X))return[];if(i>r+s+X)return[];if(i+Math.min(r,s)+X<Math.max(r,s))return[];var o=i<X?ku(n.normal):e.clone().normalize(),a=(r*r-s*s+i*i)/(2*Math.max(i,X)),c=r*r-a*a,l=new _().copy(n.center).addScaledVector(o,a);if(c<-X*X)return[];if(c<X*X)return[l];var h=Math.sqrt(Math.max(0,c)),u=new A().crossVectors(n.normal,o).normalize();return[new _().copy(l).addScaledVector(u,h),new _().copy(l).addScaledVector(u,-h)]}function Cl(n,t,e,i){if(!xi(n.normal,e.normal)){var r=$a(ee(n.normal,n.center),ee(e.normal,e.center));if(!r)return[];var s=Zn(r.point.clone(),new _().addVectors(r.point,r.dir),"unbounded");return Nr(s,n,t).filter(function(o){return zn(o,e,i)})}return Pu(xu(n,t),me(n)||t,function(o){return Xs(e,o)},function(o){return gn(n,dn(n,o),t)&&zn(o,e,i)})}function jm(n,t,e,i){if(!xi(n.normal,e.normal)){var r=$a(ee(n.normal,n.center),ee(e.normal,e.center));if(!r)return[];var s=Zn(r.point.clone(),new _().addVectors(r.point,r.dir),"unbounded");return qo(s,n,t).filter(function(o){return zn(o,e,i)})}return Pu(wu(n,t),Ce(n)||t,function(o){return Xs(e,o)},function(o){return Ka(n,Rn(n,o),t)&&zn(o,e,i)})}function Pu(n,t,e,i){for(var r=[],s=t?n.length:n.length-1,o=0;o<s;o++){var a=n[o],c=n[(o+1)%n.length],l=e(a),h=e(c);if(Math.abs(l)<=X){i(a)&&r.push(a.clone());continue}if(!(l*h>0)){for(var u=0,d=1,g=l,f=0;f<40;f++){var p=(u+d)/2,m=new _().lerpVectors(a,c,p),y=e(m);g*y<=0?d=p:(u=p,g=y)}var b=new _().lerpVectors(a,c,(u+d)/2);i(b)&&r.push(b)}}return r}function Su(n,t){var e=t.normal.dot(n.dir),i=t.distanceToPoint(n.start);if(V.equalToZero(e,X*Math.max(1,n.dir.length())))return V.equalToZero(i,X)?"coplanar":null;var r=-i/e;return Xn(r,n.extent)?Yn(n.start,n.dir,r):null}function $a(n,t){var e=new A().crossVectors(n.normal,t.normal);if(e.lengthSq()<X*X)return null;e.normalize();var i=n.normal,r=t.normal,s=i.dot(i)*r.dot(r)-Math.pow(i.dot(r),2);if(Math.abs(s)<W)return null;var o=-n.constant,a=-t.constant,c=(r.dot(r)*o-i.dot(r)*a)/s,l=(i.dot(i)*a-i.dot(r)*o)/s,h=new _().addScaledVector(i,c).addScaledVector(r,l);return{point:h,dir:e}}function Xn(n,t){return t==="unbounded"?!0:t==="ray"?n>=-X:n>=-X&&n<=1+X}function Yn(n,t,e){return new _().copy(n).addScaledVector(t,e)}function Me(n,t){var e=new _;return t.projectPoint(n,e),e}function qa(n,t){var e=n.clone().addScaledVector(t,-n.dot(t));return e.lengthSq()<X*X?ku(t):e.normalize()}function ee(n,t){return new Ds().setFromNormalAndCoplanarPoint(n,t)}function xi(n,t){return new A().crossVectors(n,t).lengthSq()<X*X}function dn(n,t){var e=new A().subVectors(t,n.center),i=new A().crossVectors(n.normal,n.refVec);return Math.atan2(e.dot(i),e.dot(n.refVec))}function Rn(n,t){var e=new A().subVectors(t,n.center),i=e.dot(n.majorAxis)/n.majorAxisRadius,r=e.dot(n.minorAxis)/n.minorAxisRadius;return Math.atan2(r,i)}function me(n){return n.closed||Math.abs(n.deltaAngle-Y)<1e-10}function Ce(n){return n.closed||Math.abs(n.endAngle-n.startAngle)<1e-10||Math.abs(n.deltaAngle-Y)<1e-10}function gn(n,t,e){if(e||me(n))return!0;var i=C.normalizeAngle(t-n.startAngle);return i<=n.deltaAngle+1e-8}function Ka(n,t,e){if(e||Ce(n))return!0;var i=C.normalizeAngle(t-n.startAngle);return i<=n.deltaAngle+1e-8}function Za(n,t){var e=ee(t.normal,t.center);return Math.abs(e.distanceToPoint(n))>X?!1:Math.abs(n.distanceTo(t.center)-t.radius)<=X}function Xs(n,t){var e=new A().subVectors(t,n.center),i=e.dot(n.majorAxis)/n.majorAxisRadius,r=e.dot(n.minorAxis)/n.minorAxisRadius;return i*i+r*r-1}function zn(n,t,e){var i=ee(t.normal,t.center);return Math.abs(i.distanceToPoint(n))>X||Math.abs(Xs(t,n))>1e-4?!1:Ka(t,Rn(t,n),e)}function Um(n,t,e,i,r){return n.filter(function(s){return gn(t,dn(t,s),e)&&gn(i,dn(i,s),r)})}function ku(n){var t=Math.abs(n.x)<.9?A.X_AXIS:A.Y_AXIS,e=new A().crossVectors(n,t);return e.lengthSq()<X*X&&e.crossVectors(n,A.Z_AXIS),e.normalize()}function Eu(n,t,e){if(Math.abs(n)<W)return Math.abs(t)<W?[]:[-e/t];var i=t*t-4*n*e;if(i<-X)return[];if(i<X)return[-t/(2*n)];var r=Math.sqrt(Math.max(0,i));return[(-t-r)/(2*n),(-t+r)/(2*n)]}function Qa(n,t){var e,i;try{for(var r=Gt(t),s=r.next();!s.done;s=r.next()){var o=s.value;n.push(o)}}catch(a){e={error:a}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}}function Gm(n){var t,e,i=[],r=function(c){if(i.some(function(l){return l.distanceTo(c)<=X}))return"continue";i.push(c)};try{for(var s=Gt(n),o=s.next();!o.done;o=s.next()){var a=o.value;r(a)}}catch(c){t={error:c}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return i}const Ol=[{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 St{constructor(t){if(typeof t=="string"){const e=Ol.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=Ol.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 St.capabilitiesFor(this.value)}static get latest(){return new St("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 Ui(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 Iu(n){return n>=90&&n<=99||n>=420&&n<=429||n>=440&&n<=449||n>=450&&n<=459||n===1071}var Ja=(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))(Ja||{});const Hm=["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"],Tu=n=>Hm[n],xo=(()=>{const n=`AutoCAD Binary DXF\r
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var Ra=(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))(Ra||{});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 fp=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.")},pp=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},ol={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},ao=[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],ue=(function(){function n(){}return n.getColorByIndex=function(t){return ao[t]},n.getIndexByColor=function(t){for(var e=ao.length-1,i=1;i<e;++i)if(ao[i]===t)return i},n.getColorByName=function(t){return ol[t.toLowerCase()]},n.getNameByColor=function(t){var e,i;try{for(var r=fp(Object.entries(ol)),s=r.next();!s.done;s=r.next()){var o=pp(s.value,2),a=o[0],c=o[1];if(c===t)return a}}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})(),mp=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},U=(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?ue.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))),o=Math.max(0,Math.min(255,Math.round(i)));return this._value=r<<16|s<<8|o,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 o=e.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);if(o){var i=parseInt(o[1],10),r=parseInt(o[2],10),s=parseInt(o[3],10);return this.setRGB(i,r,s)}var a=ue.getColorByName(t);return a!==void 0?this.setRGBValue(a):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?ue.getNameByColor(this._value):"";case exports.AcCmColorMethod.ByACI:return this._value?ue.getNameByIndex(this._value):"";default:return}},set:function(t){if(t){var e=ue.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]),o=Number(i[3]),a=new n(exports.AcCmColorMethod.ByColor);return a.setRGB(r,s,o),a}if(/^\d{1,3},\d{1,3},\d{1,3}$/.test(e)){var c=mp(e.split(",").map(Number),3),r=c[0],s=c[1],o=c[2],a=new n(exports.AcCmColorMethod.ByColor);return a.setRGB(r,s,o),a}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=ue.getColorByName(h);return u!=null?new n(exports.AcCmColorMethod.ByColor,u):void 0}var d=ue.getColorByName(e);if(d!=null)return new n(exports.AcCmColorMethod.ByColor,d)}},n})(),yp=(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})(),Ot={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")}},bp=(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,o=r.length;s<o;s++)r[s].call(this,t)}}},n})(),_p=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.")},xp=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},wp=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))},gt=(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 o=_p(this.listeners),a=o.next();!a.done;a=o.next()){var c=a.value,l=c;l.call.apply(l,wp([null,t],xp(r),!1))}}catch(h){e={error:h}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}},n})(),Yo=function(){return Yo=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},Yo.apply(this,arguments)},vp=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Ap=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))},Ph=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 ri(n){return n===null||typeof n!="object"?n:Array.isArray(n)?Ap([],vp(n),!1):Yo({},n)}function zo(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(zo);var t={};for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=zo(n[e]));return t}function ne(n){for(var t,e,i=[],r=1;r<arguments.length;r++)i[r-1]=arguments[r];try{for(var s=Ph(i),o=s.next();!o.done;o=s.next()){var a=o.value;if(a)for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&n[c]===void 0&&(n[c]=a[c])}}catch(l){t={error:l}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return n}function Sh(n,t){return n!=null&&Object.prototype.hasOwnProperty.call(n,t)}function kh(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 ln(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(!ln(n[r],t[r]))return!1;return!0}var s=Object.keys(n),o=Object.keys(t);if(s.length!==o.length)return!1;try{for(var a=Ph(s),c=a.next();!c.done;c=a.next()){var l=c.value;if(!Object.prototype.hasOwnProperty.call(t,l)||!ln(n[l],t[l]))return!1}}catch(h){e={error:h}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(e)throw e.error}}return!0}function Pp(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var vr={exports:{}},Sp=vr.exports,al;function kp(){return al||(al=1,(function(n){(function(t,e){n.exports?n.exports=e():t.log=e()})(Sp,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={},o=null;function a(p,m){var y=p[m];if(typeof y.bind=="function")return y.bind(p);try{return Function.prototype.bind.call(y,p)}catch{return function(){return Function.prototype.apply.apply(y,[p,arguments])}}}function c(){console.log&&(console.log.apply||Function.prototype.apply.apply(console.log,[console,arguments]))}function l(p){return p==="debug"&&(p="log"),typeof console===e?!1:p==="trace"&&i?c:console[p]!==void 0?a(console,p):console.log!==void 0?a(console,"log"):t}function h(){for(var p=this.getLevel(),m=0;m<r.length;m++){var y=r[m];this[y]=m<p?t:this.methodFactory(y,p,this.name)}if(this.log=this.debug,typeof console===e&&p<this.levels.SILENT)return"No console available for logging"}function u(p){return function(){typeof console!==e&&(h.call(this),this[p].apply(this,arguments))}}function d(p,m,y){return l(p)||u.apply(this,arguments)}function g(p,m){var y=this,b,w,x,S="loglevel";typeof p=="string"?S+=":"+p:typeof p=="symbol"&&(S=void 0);function P(N){var R=(r[N]||"silent").toUpperCase();if(!(typeof window===e||!S)){try{window.localStorage[S]=R;return}catch{}try{window.document.cookie=encodeURIComponent(S)+"="+R+";"}catch{}}}function v(){var N;if(!(typeof window===e||!S)){try{N=window.localStorage[S]}catch{}if(typeof N===e)try{var R=window.document.cookie,nt=encodeURIComponent(S),et=R.indexOf(nt+"=");et!==-1&&(N=/^([^;]+)/.exec(R.slice(et+nt.length+1))[1])}catch{}return y.levels[N]===void 0&&(N=void 0),N}}function k(){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 E(N){var R=N;if(typeof R=="string"&&y.levels[R.toUpperCase()]!==void 0&&(R=y.levels[R.toUpperCase()]),typeof R=="number"&&R>=0&&R<=y.levels.SILENT)return R;throw new TypeError("log.setLevel() called with invalid level: "+N)}y.name=p,y.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},y.methodFactory=m||d,y.getLevel=function(){return x??w??b},y.setLevel=function(N,R){return x=E(N),R!==!1&&P(x),h.call(y)},y.setDefaultLevel=function(N){w=E(N),v()||y.setLevel(N,!1)},y.resetLevel=function(){x=null,k(),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(o!==y&&(b=E(o.getLevel())),h.call(y),o===y)for(var N in s)s[N].rebuild()},b=E(o?o.getLevel():"WARN");var O=v();O!=null&&(x=E(O)),h.call(y)}o=new g,o.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,o.methodFactory)),y};var f=typeof window!==e?window.log:void 0;return o.noConflict=function(){return typeof window!==e&&window.log===o&&(window.log=f),o},o.getLoggers=function(){return s},o.default=o,o})})(vr)),vr.exports}var Ep=kp();const Ip=Pp(Ep);var Tp=!0,ai=Ip;ai.setLevel("debug");var Lp=function(n){try{ai.setLevel(n)}catch(t){ai.setLevel("error"),ai.error(t)}},Vo=(function(){function n(t,e){this.events={attrChanged:new gt,modelChanged:new gt},this._changing=!1,this._previousAttributes={},this._pending=!1;var i=t||{};e&&ne(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,o=i.silent,a=[],c=this._changing;this._changing=!0,c||(this._previousAttributes=ri(this.attributes),this.changed={});var l=this.attributes,h=this.changed,u=this._previousAttributes;for(var d in r)e=r[d],ln(l[d],e)||a.push(d),ln(u[d],e)?delete h[d]:h[d]=e,s?delete l[d]:l[d]=e;if(!o){a.length&&(this._pending=i);for(var g=0;g<a.length;g++)this.events.attrChanged.dispatch({object:this,attrName:a[g],attrValue:l[a[g]],options:i})}if(c)return this;if(!o)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?!kh(this.changed):Sh(this.changed,t)},n.prototype.changedAttributes=function(t){if(!t)return this.hasChanged()?ri(this.changed):{};var e=this._changing?this._previousAttributes:this.attributes,i={};for(var r in t){var s=t[r];ln(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 ri(this._previousAttributes)},n.prototype.clone=function(){var t=ri(this.attributes);return new n(t)},n})(),Mp=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.")},Cp=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Na=(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=Mp(this.entries),r=i.next();!r.done;r=i.next())var s=Cp(r.value,2),o=s[0],a=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})(),Op=(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"],o=Math.floor(Math.log(t)/Math.log(i)),a=t/Math.pow(i,o);return"".concat(parseFloat(a.toFixed(r))," ").concat(s[o])},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 pt=(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 o=Number(e);if(Number.isInteger(o)&&o>=0&&o<=255){var a=new n;return o<=90?a.percentage=o:a.alpha=o,a}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})(),Rp=function(n,t,e,i){function r(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(h){try{l(i.next(h))}catch(u){o(u)}}function c(h){try{l(i.throw(h))}catch(u){o(u)}}function l(h){h.done?s(h.value):r(h.value).then(a,c)}l((i=i.apply(n,t||[])).next())})},Np=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=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}}},bi=50;function qn(){return new Promise(function(n){typeof globalThis<"u"&&typeof globalThis.requestAnimationFrame=="function"?globalThis.requestAnimationFrame(function(){return n()}):setTimeout(n,0)})}function Eh(){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 Fs=(function(){function n(t){t===void 0&&(t=bi),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 Rp(this,arguments,void 0,function(t){var e;return t===void 0&&(t=qn),Np(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})(),co=function(n,t,e,i){function r(s){return s instanceof e?s:new e(function(o){o(s)})}return new(e||(e=Promise))(function(s,o){function a(h){try{l(i.next(h))}catch(u){o(u)}}function c(h){try{l(i.throw(h))}catch(u){o(u)}}function l(h){h.done?s(h.value):r(h.value).then(a,c)}l((i=i.apply(n,t||[])).next())})},Ki=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=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}}},Ih=(function(){function n(t){this.name=t}return n.prototype.run=function(t){throw new Error("run() must be implemented by subclass")},n})(),Th=(function(){function n(){this.tasks=[],this.onProgress=function(){},this.onComplete=function(){},this.onError=function(){return!1}}return n.prototype.scheduleTask=function(t){return co(this,void 0,void 0,function(){return Ki(this,function(e){switch(e.label){case 0:return[4,qn()];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 co(this,void 0,void 0,function(){var e,i,r,s,o,a,c=this;return Ki(this,function(l){switch(l.label){case 0:e=this.tasks.length,i=t,r=function(h){var u,d,g;return Ki(this,function(f){switch(f.label){case 0:u=s.tasks[h],f.label=1;case 1:return f.trys.push([1,3,,4]),[4,s.scheduleTask(function(){return co(c,void 0,void 0,function(){var p;return Ki(this,function(m){switch(m.label){case 0:return[4,u.run(i)];case 1:return p=m.sent(),this.onProgress((h+1)/e,u),[2,p]}})})})];case 2:return i=f.sent(),[3,4];case 3:return d=f.sent(),g=s.onError({error:d,taskIndex:h,task:u}),g?[2,{value:Promise.reject(d)}]:[3,4];case 4:return[2]}})},s=this,o=0,l.label=1;case 1:return o<e?[5,r(o)]:[3,4];case 2:if(a=l.sent(),typeof a=="object")return[2,a.value];l.label=3;case 3:return o++,[3,1];case 4:return this.onComplete(i),[2]}})})},n})(),Lh=(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})(),Mh=new Lh,Bp=(function(){function n(t){this.manager=t!==void 0?t:Mh,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})(),Tt=["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"],cl=1234567,Ba=Math.PI/180,Fa=180/Math.PI;function Ch(){var n=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0,r=Tt[n&255]+Tt[n>>8&255]+Tt[n>>16&255]+Tt[n>>24&255]+"-"+Tt[t&255]+Tt[t>>8&255]+"-"+Tt[t>>16&15|64]+Tt[t>>24&255]+"-"+Tt[e&63|128]+Tt[e>>8&255]+"-"+Tt[e>>16&255]+Tt[e>>24&255]+Tt[i&255]+Tt[i>>8&255]+Tt[i>>16&255]+Tt[i>>24&255];return r.toLowerCase()}function Jt(n,t,e){return Math.max(t,Math.min(e,n))}function Da(n,t){return(n%t+t)%t}function Oh(n,t,e,i,r){return i+(n-t)*(r-i)/(e-t)}function Rh(n,t,e){return n!==t?(e-n)/(t-n):0}function Xa(n,t,e){return(1-e)*n+e*t}function Nh(n,t,e,i){return Xa(n,t,1-Math.exp(-e*i))}function Bh(n,t){return t===void 0&&(t=1),t-Math.abs(Da(n,t*2)-t)}function Fh(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*(3-2*n))}function Dh(n,t,e){return n<=t?0:n>=e?1:(n=(n-t)/(e-t),n*n*n*(n*(n*6-15)+10))}function Xh(n,t){return n+Math.floor(Math.random()*(t-n+1))}function Yh(n,t){return n+Math.random()*(t-n)}function zh(n){return n*(.5-Math.random())}function Vh(n){n!==void 0&&(cl=n);var t=cl+=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 jh(n){return n*Ba}function Uh(n){return n*Fa}function Gh(n){return(n&n-1)===0&&n!==0}function Hh(n){return Math.pow(2,Math.ceil(Math.log(n)/Math.LN2))}function Wh(n){return Math.pow(2,Math.floor(Math.log(n)/Math.LN2))}function hn(n){var t=Math.PI*2;return(n%t+t)%t}function $h(n,t,e){return n>t&&n<e||n>e&&n<t}function qh(n,t,e,i){return i===void 0&&(i=!1),n=hn(n),t=hn(t),e=hn(e),i?t>e?n<=t&&n>=e:n<=t||n>=e:t<e?n>=t&&n<=e:n>=t||n<=e}function Kh(n,t,e){var i=hn(e-n),r=hn(t-n);return r<=i+1e-7}function Ya(n){return n=Math.abs(n),n<1?0:Math.ceil(Math.log10(Math.abs(n)+1))}function Zh(n,t){t===void 0&&(t=1e-7);var e=Ya(n);return Math.max(Math.pow(10,e)*t,t)}var C={DEG2RAD:Ba,RAD2DEG:Fa,generateUUID:Ch,clamp:Jt,euclideanModulo:Da,mapLinear:Oh,inverseLerp:Rh,lerp:Xa,damp:Nh,pingpong:Bh,smoothstep:Fh,smootherstep:Dh,randInt:Xh,randFloat:Yh,randFloatSpread:zh,seededRandom:Vh,degToRad:jh,radToDeg:Uh,isPowerOfTwo:Gh,ceilPowerOfTwo:Hh,floorPowerOfTwo:Wh,normalizeAngle:hn,isBetween:$h,isBetweenAngle:qh,isAngleOnCcwSweep:Kh,intPartLength:Ya,relativeEps:Zh},Fp=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=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}}},ht=(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,o=r.y;this.x=s,this.y=o;return}if(i===2){this.x=t,this.y=e;return}throw Ot.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,o=this.y-t.y;return this.x=s*i-o*r+t.x,this.y=s*r+o*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 Fp(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})(),zi=(function(){function n(t,e,i,r,s,o,a,c,l){this.elements=[1,0,0,0,1,0,0,0,1],t!=null&&e!=null&&i!=null&&r!=null&&s!=null&&o!=null&&a!=null&&c!=null&&l!=null&&this.set(t,e,i,r,s,o,a,c,l)}return n.prototype.set=function(t,e,i,r,s,o,a,c,l){var h=this.elements;return h[0]=t,h[1]=r,h[2]=a,h[3]=e,h[4]=s,h[5]=c,h[6]=i,h[7]=o,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,o=i[0],a=i[3],c=i[6],l=i[1],h=i[4],u=i[7],d=i[2],g=i[5],f=i[8],p=r[0],m=r[3],y=r[6],b=r[1],w=r[4],x=r[7],S=r[2],P=r[5],v=r[8];return s[0]=o*p+a*b+c*S,s[3]=o*m+a*w+c*P,s[6]=o*y+a*x+c*v,s[1]=l*p+h*b+u*S,s[4]=l*m+h*w+u*P,s[7]=l*y+h*x+u*v,s[2]=d*p+g*b+f*S,s[5]=d*m+g*w+f*P,s[8]=d*y+g*x+f*v,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],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8];return e*o*h-e*a*l-i*s*h+i*a*c+r*s*l-r*o*c},n.prototype.invert=function(){var t=this.elements,e=t[0],i=t[1],r=t[2],s=t[3],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8],u=h*o-a*l,d=a*c-h*s,g=l*s-o*c,f=e*u+i*d+r*g;if(f===0)return this.set(0,0,0,0,0,0,0,0,0);var p=1/f;return t[0]=u*p,t[1]=(r*l-h*i)*p,t[2]=(a*i-r*o)*p,t[3]=d*p,t[4]=(h*e-r*c)*p,t[5]=(r*s-a*e)*p,t[6]=g*p,t[7]=(i*c-l*e)*p,t[8]=(o*e-i*s)*p,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,o,a){var c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*o+l*a)+o+t,-r*l,r*c,-r*(-l*o+c*a)+a+e,0,0,1),this},n.prototype.scale=function(t,e){return this.premultiply(lo.makeScale(t,e)),this},n.prototype.rotate=function(t){return this.premultiply(lo.makeRotation(-t)),this},n.prototype.translate=function(t,e){return this.premultiply(lo.makeTranslation(t,e)),this},n.prototype.makeTranslation=function(t,e){return t instanceof ht?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})(),lo=new zi,W=1e-6,Y=2*Math.PI,Dp={x:0,y:0},za={x:0,y:0,z:0},V=(function(){function n(){this.equalPointTol=W,this.equalVectorTol=W}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 ht(t).sub(e).length()<this.equalPointTol},n.prototype.equalPoint3d=function(t,e){return new A(t).sub(e).length()<this.equalPointTol},n.equalToZero=function(t,e){return e===void 0&&(e=W),t<e&&t>-e},n.equal=function(t,e,i){return i===void 0&&(i=W),Math.abs(t-e)<i},n.great=function(t,e,i){return i===void 0&&(i=W),t-e>i},n.less=function(t,e,i){return i===void 0&&(i=W),t-e<i},n.isPositive=function(t,e){return e===void 0&&(e=W),t>e},n.isNonPositive=function(t,e){return e===void 0&&(e=W),t<=e},n})(),Vi=new V,Xp=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=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}}},Dn=(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,o,a){var c=i[r+0],l=i[r+1],h=i[r+2],u=i[r+3],d=s[o+0],g=s[o+1],f=s[o+2],p=s[o+3];if(a===0){t[e+0]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u;return}if(a===1){t[e+0]=d,t[e+1]=g,t[e+2]=f,t[e+3]=p;return}if(u!==p||c!==d||l!==g||h!==f){var m=1-a,y=c*d+l*g+h*f+u*p,b=y>=0?1:-1,w=1-y*y;if(w>Number.EPSILON){var x=Math.sqrt(w),S=Math.atan2(x,y*b);m=Math.sin(m*S)/x,a=Math.sin(a*S)/x}var P=a*b;if(c=c*m+d*P,l=l*m+g*P,h=h*m+f*P,u=u*m+p*P,m===1-a){var v=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=v,l*=v,h*=v,u*=v}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u},n.multiplyQuaternionsFlat=function(t,e,i,r,s,o){var a=i[r],c=i[r+1],l=i[r+2],h=i[r+3],u=s[o],d=s[o+1],g=s[o+2],f=s[o+3];return t[e]=a*f+h*u+c*g-l*d,t[e+1]=c*f+h*d+l*u-a*g,t[e+2]=l*f+h*g+a*d-c*u,t[e+3]=h*f-a*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,o=t.order,a=Math.cos,c=Math.sin,l=a(i/2),h=a(r/2),u=a(s/2),d=c(i/2),g=c(r/2),f=c(s/2);switch(o){case"XYZ":this._x=d*h*u+l*g*f,this._y=l*g*u-d*h*f,this._z=l*h*f+d*g*u,this._w=l*h*u-d*g*f;break;case"YXZ":this._x=d*h*u+l*g*f,this._y=l*g*u-d*h*f,this._z=l*h*f-d*g*u,this._w=l*h*u+d*g*f;break;case"ZXY":this._x=d*h*u-l*g*f,this._y=l*g*u+d*h*f,this._z=l*h*f+d*g*u,this._w=l*h*u-d*g*f;break;case"ZYX":this._x=d*h*u-l*g*f,this._y=l*g*u+d*h*f,this._z=l*h*f-d*g*u,this._w=l*h*u+d*g*f;break;case"YZX":this._x=d*h*u+l*g*f,this._y=l*g*u+d*h*f,this._z=l*h*f-d*g*u,this._w=l*h*u-d*g*f;break;case"XZY":this._x=d*h*u-l*g*f,this._y=l*g*u-d*h*f,this._z=l*h*f+d*g*u,this._w=l*h*u+d*g*f;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],o=e[1],a=e[5],c=e[9],l=e[2],h=e[6],u=e[10],d=i+a+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=(o-r)*g}else if(i>a&&i>u){var g=2*Math.sqrt(1+i-a-u);this._w=(h-c)/g,this._x=.25*g,this._y=(r+o)/g,this._z=(s+l)/g}else if(a>u){var g=2*Math.sqrt(1+a-i-u);this._w=(s-l)/g,this._x=(r+o)/g,this._y=.25*g,this._z=(c+h)/g}else{var g=2*Math.sqrt(1+u-i-a);this._w=(o-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(Jt(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,o=t._w,a=e._x,c=e._y,l=e._z,h=e._w;return this._x=i*h+o*a+r*l-s*c,this._y=r*h+o*c+s*a-i*l,this._z=s*h+o*l+i*c-r*a,this._w=o*h-i*a-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,o=this._w,a=o*t._w+i*t._x+r*t._y+s*t._z;if(a<0?(this._w=-t._w,this._x=-t._x,this._y=-t._y,this._z=-t._z,a=-a):this.copy(t),a>=1)return this._w=o,this._x=i,this._y=r,this._z=s,this;var c=1-a*a;if(c<=Number.EPSILON){var l=1-e;return this._w=l*o+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,a),d=Math.sin((1-e)*u)/h,g=Math.sin(e*u)/h;return this._w=o*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 Xp(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})(),Yp=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=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}}},A=(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,o=s.x,a=s.y,c=s.z;this.x=o,this.y=a,this.z=c||0;return}if(r===3){this.x=t,this.y=e,this.z=i;return}throw Ot.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(ll.setFromEuler(t))},n.prototype.applyAxisAngle=function(t,e){return this.applyQuaternion(ll.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,o=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])*o,this.y=(s[1]*e+s[5]*i+s[9]*r+s[13])*o,this.z=(s[2]*e+s[6]*i+s[10]*r+s[14])*o,this},n.prototype.applyQuaternion=function(t){var e=this.x,i=this.y,r=this.z,s=t.x,o=t.y,a=t.z,c=t.w,l=2*(o*r-a*i),h=2*(a*e-s*r),u=2*(s*i-o*e);return this.x=e+c*l+o*u-a*h,this.y=i+c*h+a*l-s*u,this.z=r+c*u+s*h-o*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,o=e.x,a=e.y,c=e.z;return this.x=r*c-s*a,this.y=s*o-i*c,this.z=i*a-r*o,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 ho.copy(this).projectOnVector(t),this.sub(ho)},n.prototype.reflect=function(t){return this.sub(ho.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 Yp(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})(),ho=new A,ll=new Dn,D=(function(){function n(t,e,i,r,s,o,a,c,l,h,u,d,g,f,p,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&&o!=null&&a!=null&&c!=null&&l!=null&&h!=null&&u!=null&&d!=null&&g!=null&&f!=null&&p!=null&&m!=null&&this.set(t,e,i,r,s,o,a,c,l,h,u,d,g,f,p,m)}return n.makeTranslation=function(t,e,i){return new n().makeTranslation(t,e,i)},n.prototype.set=function(t,e,i,r,s,o,a,c,l,h,u,d,g,f,p,m){var y=this.elements;return y[0]=t,y[4]=e,y[8]=i,y[12]=r,y[1]=s,y[5]=o,y[9]=a,y[13]=c,y[2]=l,y[6]=h,y[10]=u,y[14]=d,y[3]=g,y[7]=f,y[11]=p,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(Vi.equalPoint3d(i,A.Z_AXIS))this.identity();else{var r=new A(1,0,0);Math.abs(i.x)<1/64&&Math.abs(i.y)<1/64?r.crossVectors(A.Y_AXIS,i).normalize():r.crossVectors(A.Z_AXIS,i).normalize();var s=i.clone().cross(r).normalize();this.makeBasis(r,s,i)}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/yn.setFromMatrixColumn(t,0).length(),s=1/yn.setFromMatrixColumn(t,1).length(),o=1/yn.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]*o,e[9]=i[9]*o,e[10]=i[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this},n.prototype.makeRotationFromQuaternion=function(t){return this.compose(zp,t,Vp)},n.prototype.lookAt=function(t,e,i){var r=this.elements;return Xt.subVectors(t,e),Xt.lengthSq()===0&&(Xt.z=1),Xt.normalize(),Xe.crossVectors(i,Xt),Xe.lengthSq()===0&&(Math.abs(i.z)===1?Xt.x+=1e-4:Xt.z+=1e-4,Xt.normalize(),Xe.crossVectors(i,Xt)),Xe.normalize(),Zi.crossVectors(Xt,Xe),r[0]=Xe.x,r[4]=Zi.x,r[8]=Xt.x,r[1]=Xe.y,r[5]=Zi.y,r[9]=Xt.y,r[2]=Xe.z,r[6]=Zi.z,r[10]=Xt.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,o=i[0],a=i[4],c=i[8],l=i[12],h=i[1],u=i[5],d=i[9],g=i[13],f=i[2],p=i[6],m=i[10],y=i[14],b=i[3],w=i[7],x=i[11],S=i[15],P=r[0],v=r[4],k=r[8],E=r[12],O=r[1],N=r[5],R=r[9],nt=r[13],et=r[2],G=r[6],rt=r[10],L=r[14],q=r[3],dt=r[7],B=r[11],Ct=r[15];return s[0]=o*P+a*O+c*et+l*q,s[4]=o*v+a*N+c*G+l*dt,s[8]=o*k+a*R+c*rt+l*B,s[12]=o*E+a*nt+c*L+l*Ct,s[1]=h*P+u*O+d*et+g*q,s[5]=h*v+u*N+d*G+g*dt,s[9]=h*k+u*R+d*rt+g*B,s[13]=h*E+u*nt+d*L+g*Ct,s[2]=f*P+p*O+m*et+y*q,s[6]=f*v+p*N+m*G+y*dt,s[10]=f*k+p*R+m*rt+y*B,s[14]=f*E+p*nt+m*L+y*Ct,s[3]=b*P+w*O+x*et+S*q,s[7]=b*v+w*N+x*G+S*dt,s[11]=b*k+w*R+x*rt+S*B,s[15]=b*E+w*nt+x*L+S*Ct,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],o=t[1],a=t[5],c=t[9],l=t[13],h=t[2],u=t[6],d=t[10],g=t[14],f=t[3],p=t[7],m=t[11],y=t[15];return f*(+s*c*u-r*l*u-s*a*d+i*l*d+r*a*g-i*c*g)+p*(+e*c*g-e*l*d+s*o*d-r*o*g+r*l*h-s*c*h)+m*(+e*l*u-e*a*g-s*o*u+i*o*g+s*a*h-i*l*h)+y*(-r*a*h-e*c*u+e*a*d+r*o*u-i*o*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 A?(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],o=t[4],a=t[5],c=t[6],l=t[7],h=t[8],u=t[9],d=t[10],g=t[11],f=t[12],p=t[13],m=t[14],y=t[15],b=u*m*l-p*d*l+p*c*g-a*m*g-u*c*y+a*d*y,w=f*d*l-h*m*l-f*c*g+o*m*g+h*c*y-o*d*y,x=h*p*l-f*u*l+f*a*g-o*p*g-h*a*y+o*u*y,S=f*u*c-h*p*c-f*a*d+o*p*d+h*a*m-o*u*m,P=e*b+i*w+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 v=1/P;return t[0]=b*v,t[1]=(p*d*s-u*m*s-p*r*g+i*m*g+u*r*y-i*d*y)*v,t[2]=(a*m*s-p*c*s+p*r*l-i*m*l-a*r*y+i*c*y)*v,t[3]=(u*c*s-a*d*s-u*r*l+i*d*l+a*r*g-i*c*g)*v,t[4]=w*v,t[5]=(h*m*s-f*d*s+f*r*g-e*m*g-h*r*y+e*d*y)*v,t[6]=(f*c*s-o*m*s-f*r*l+e*m*l+o*r*y-e*c*y)*v,t[7]=(o*d*s-h*c*s+h*r*l-e*d*l-o*r*g+e*c*g)*v,t[8]=x*v,t[9]=(f*u*s-h*p*s-f*i*g+e*p*g+h*i*y-e*u*y)*v,t[10]=(o*p*s-f*a*s+f*i*l-e*p*l-o*i*y+e*a*y)*v,t[11]=(h*a*s-o*u*s-h*i*l+e*u*l+o*i*g-e*a*g)*v,t[12]=S*v,t[13]=(h*p*r-f*u*r+f*i*d-e*p*d-h*i*m+e*u*m)*v,t[14]=(f*a*r-o*p*r-f*i*c+e*p*c+o*i*m-e*a*m)*v,t[15]=(o*u*r-h*a*r+h*i*c-e*u*c-o*i*d+e*a*d)*v,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,o=t.x,a=t.y,c=t.z,l=s*o,h=s*a;return this.set(l*o+i,l*a-r*c,l*c+r*a,0,l*a+r*c,h*a+i,h*c-r*o,0,l*c-r*a,h*c+r*o,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,o){return this.set(1,i,s,0,t,1,o,0,e,r,1,0,0,0,0,1),this},n.prototype.compose=function(t,e,i){var r=this.elements,s=e.x,o=e.y,a=e.z,c=e.w,l=s+s,h=o+o,u=a+a,d=s*l,g=s*h,f=s*u,p=o*h,m=o*u,y=a*u,b=c*l,w=c*h,x=c*u,S=i.x,P=i.y,v=i.z;return r[0]=(1-(p+y))*S,r[1]=(g+x)*S,r[2]=(f-w)*S,r[3]=0,r[4]=(g-x)*P,r[5]=(1-(d+y))*P,r[6]=(m+b)*P,r[7]=0,r[8]=(f+w)*v,r[9]=(m-b)*v,r[10]=(1-(d+p))*v,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=yn.set(r[0],r[1],r[2]).length(),o=yn.set(r[4],r[5],r[6]).length(),a=yn.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],re.copy(this);var l=1/s,h=1/o,u=1/a;return re.elements[0]*=l,re.elements[1]*=l,re.elements[2]*=l,re.elements[4]*=h,re.elements[5]*=h,re.elements[6]*=h,re.elements[8]*=u,re.elements[9]*=u,re.elements[10]*=u,e.setFromRotationMatrix(re),i.x=s,i.y=o,i.z=a,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})(),yn=new A,re=new D,zp=new A(0,0,0),Vp=new A(1,1,1),Xe=new A,Zi=new A,Xt=new A,j=(function(){function n(t,e){t===void 0&&(t=void 0),e===void 0&&(e=void 0),this.min=t==null?new A(1/0,1/0,1/0):new A(t.x,t.y,t.z),this.max=e==null?new A(-1/0,-1/0,-1/0):new A(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(uo.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=uo.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 A(0,0,0):new A(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 A(0,0,0):new A(0,0,0).subVectors(this.max,this.min)},enumerable:!1,configurable:!0}),n.prototype.expandByPoint=function(t){return!Number.isFinite(t.x)||!Number.isFinite(t.y)||!Number.isFinite(t.z)?this:(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,uo).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:(Ee[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ee[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ee[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ee[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ee[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ee[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ee[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ee[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ee),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})(),Ee=[new A,new A,new A,new A,new A,new A,new A,new A],uo=new A,hl=new ht,kt=(function(){function n(t,e){t===void 0&&(t=void 0),e===void 0&&(e=void 0),this.min=t==null?new ht(1/0,1/0):new ht(t.x,t.y),this.max=e==null?new ht(-1/0,-1/0):new ht(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=hl.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 ht(0,0):new ht(0,0).addVectors(this.min,this.max).multiplyScalar(.5)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return this.isEmpty()?new ht(0,0):new ht(0,0).subVectors(this.max,this.min)},enumerable:!1,configurable:!0}),n.prototype.expandByPoint=function(t){return!Number.isFinite(t.x)||!Number.isFinite(t.y)?this:(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,hl).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})(),ul=new A,jp=new A,Up=new zi,Ds=(function(){function n(t,e){t===void 0&&(t=new A(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=ul.subVectors(i,e).cross(jp.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||Up.getNormalMatrix(t),r=this.coplanarPoint(ul).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})(),Gp=(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)}})(),M=(function(n){Gp(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})(ht),Hp=(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)}})(),_=(function(n){Hp(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(o,a){o.toArray(s,a*r)}),s},t})(A),Wp=function(n,t){var e={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,r,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(l){return function(h){return c([l,h])}}function c(l){if(i)throw new TypeError("Generator is already executing.");for(;o&&(o=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}}},dl=new D,gl=new Dn,$p=(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],o=r[4],a=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(Jt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(-h,g),this._z=Math.atan2(-o,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Jt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(a,g),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(Jt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,g),this._z=Math.atan2(-o,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Jt(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(-o,l));break;case"YZX":this._z=Math.asin(Jt(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(a,g));break;case"XZY":this._z=Math.asin(-Jt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(a,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),dl.makeRotationFromQuaternion(t),this.setFromRotationMatrix(dl,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 gl.setFromEuler(this),this.setFromQuaternion(gl,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 Wp(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 qp(n){var t,e=n;return{x:n.x,y:n.y,z:(t=e.z)!==null&&t!==void 0?t:0}}function Kp(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 Zp(n,t,e){e===void 0&&(e=!1);for(var i=n.x,r=n.y,s=!1,o=t.length,a=0,c=o-1;a<o;c=a++){var l=t[a].x,h=t[a].y,u=t[c].x,d=t[c].y,g=h>r!=d>r;e&&(g=h>=r!=d>=r);var f=g&&i<(u-l)*(r-h)/(d-h)+l;f&&(s=!s)}return s}function Qp(n,t){if(n.length===0||t.length===0)return!1;var e=new kt().setFromPoints(n),i=new kt().setFromPoints(t);if(!e.intersectsBox(i))return!1;for(var r=0;r<n.length;){if(Lt.isPointInPolygon(n[r],t,!0))return!0;r<n.length-1&&Vi.equalPoint2d(n[r+1],n[r])&&++r,++r}return!1}var Lt={applyOffsetToPoint3d:Kp,isPointInPolygon:Zp,isPolygonIntersect:Qp,point2dToPoint3d:qp},Qi=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Ji=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 Jp(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 t0(n,t){for(var e=t.length-1,i=n,r=[0],s=0,o=1;o<=e;o++){var a=t[o][0]-t[o-1][0],c=t[o][1]-t[o-1][1],l=t[o][2]-t[o-1][2],h=Math.sqrt(a*a+c*c+l*l);s+=h,r.push(s)}for(var u=[],o=0;o<=i;o++)u.push(0);for(var o=1;o<=e-i;o++){var d=r[o]/s;u.push(d*(e-i+1))}for(var o=0;o<=i;o++)u.push(e-i+1);return u}function Qh(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,o=1;o<=i;o++){var a=n[o][0]-n[o-1][0],c=n[o][1]-n[o-1][1],l=n[o][2]-n[o-1][2],h=Math.sqrt(a*a+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 Jh(n,t){for(var e=t.length-1,i=n,r=e+i+1,s=new Array(r+1).fill(0),o=t[t.length-1],a=r-i;a<=r;a++)s[a]=o;for(var c=1;c<=e-i;c++){for(var l=0,a=c;a<c+i;a++)l+=t[a];s[c+i]=l/i}return s}function e0(n,t){for(var e=t.length-1,i=n,r=[0],s=0,o=1;o<=e;o++){var a=t[o][0]-t[o-1][0],c=t[o][1]-t[o-1][1],l=t[o][2]-t[o-1][2],h=Math.sqrt(a*a+c*c+l*l),u=Math.sqrt(h);s+=u,r.push(s)}for(var d=[],o=0;o<=i;o++)d.push(0);for(var o=1;o<=e-i;o++){var g=r[o]/s;d.push(g*(e-i+1))}for(var o=0;o<=i;o++)d.push(e-i+1);return d}function go(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 o=s,a=Math.abs(i[s][s]),c=s+1;c<e;c++){var l=Math.abs(i[c][s]);l>a&&(a=l,o=c)}if(a<1e-12)throw new Error("Interpolation matrix is singular.");if(o!==s){var h=i[s];i[s]=i[o],i[o]=h;var u=r[s];r[s]=r[o],r[o]=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 f=new Array(e).fill(0),c=e-1;c>=0;c--){for(var p=r[c],g=c+1;g<e;g++)p-=i[c][g]*f[g];f[c]=p/i[c][c]}return f}function Va(n,t,e,i,r){var s,o,a,c,l,h;if(e===void 0&&(e="Uniform"),n.length===0)return{controlPoints:[],knots:[],weights:[]};var u=n.map(function(B){var Ct;return[B[0],B[1],(Ct=B[2])!==null&&Ct!==void 0?Ct:0]}),d=!!i,g=!!r,f=(d?1:0)+(g?1:0),p=u.length-1,m=p+f;if(m<t)throw new Error("Not enough points to interpolate a curve of this degree.");var y=Qh(u,e),b=y.slice();d&&b.unshift(y[0]),g&&b.push(y[y.length-1]);var w=Jh(t,b),x=m+1,S=new Array(x),P=new Array(x),v=new Array(x),k=new Array(x),E=0;S[E]=new Array(x).fill(0),S[E][0]=1,P[E]=u[0][0],v[E]=u[0][1],k[E]=u[0][2],E++;for(var O=1;O<=p-1;O++){var N=y[O];S[E]=new Array(x).fill(0);for(var R=0;R<=m;R++)S[E][R]=Ze(R,t,N,w);P[E]=u[O][0],v[E]=u[O][1],k[E]=u[O][2],E++}if(S[E]=new Array(x).fill(0),S[E][m]=1,P[E]=u[p][0],v[E]=u[p][1],k[E]=u[p][2],E++,d){var nt=w[t+1]-w[0],et=nt!==0?t/nt:0;S[E]=new Array(x).fill(0),S[E][0]=-et,S[E][1]=et,P[E]=(s=i==null?void 0:i[0])!==null&&s!==void 0?s:0,v[E]=(o=i==null?void 0:i[1])!==null&&o!==void 0?o:0,k[E]=(a=i==null?void 0:i[2])!==null&&a!==void 0?a:0,E++}if(g){var nt=w[m+t+1]-w[m],et=nt!==0?t/nt:0;S[E]=new Array(x).fill(0),S[E][m-1]=-et,S[E][m]=et,P[E]=(c=r==null?void 0:r[0])!==null&&c!==void 0?c:0,v[E]=(l=r==null?void 0:r[1])!==null&&l!==void 0?l:0,k[E]=(h=r==null?void 0:r[2])!==null&&h!==void 0?h:0,E++}for(var G=go(S,P),rt=go(S,v),L=go(S,k),q=new Array(x),O=0;O<x;O++)q[O]=[G[O],rt[O],L[O]];var dt=new Array(x).fill(1);return{controlPoints:q,knots:w,weights:dt}}function Ze(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],o=r>1e-10?(e-i[n])/r:0,a=s>1e-10?(i[n+t+1]-e)/s:0;return o*Ze(n,t-1,e,i)+a*Ze(n+1,t-1,e,i)}function ci(n,t,e,i,r){var s=i.length-1,o=t;if(n=Math.max(e[o],Math.min(e[s+1],n)),Math.abs(n-e[s+1])<1e-8)return Ji([],Qi(i[s]),!1);if(Math.abs(n-e[o])<1e-8)return Ji([],Qi(i[0]),!1);for(var a=[0,0,0],c=0,l=0;l<=s;l++){var h=Ze(l,o,n,e),u=r[l]*h;a[0]+=i[l][0]*u,a[1]+=i[l][1]*u,a[2]+=i[l][2]*u,c+=u}if(Math.abs(c)<1e-10){var d=e[e.length-o-1];if(Math.abs(n-d)<1e-8)return Ji([],Qi(i[s]),!1);if(Math.abs(n-e[o])<1e-8)return Ji([],Qi(i[0]),!1)}return Math.abs(c)>=1e-10&&(a[0]/=c,a[1]/=c,a[2]/=c),a}function jo(n,t,e,i){if(t===0)return 0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],o=0;return r>1e-10&&(o+=t/r*Ze(n,t-1,e,i)),s>1e-10&&(o-=t/s*Ze(n+1,t-1,e,i)),o}function n0(n,t,e,i){if(t<=1)return 0;var r=i[n+t]-i[n],s=i[n+t+1]-i[n+1],o=0;return r>1e-10&&(o+=t/r*jo(n,t-1,e,i)),s>1e-10&&(o-=t/s*jo(n+1,t-1,e,i)),o}function i0(n,t,e,i,r){var s=i.length-1,o=t,a=e[o],c=e[s+1];n=Math.max(a,Math.min(c,n));for(var l=[0,0,0],h=[0,0,0],u=[0,0,0],d=0,g=0,f=0,p=0;p<=s;p++){var m=Ze(p,o,n,e),y=jo(p,o,n,e),b=n0(p,o,n,e),w=r[p],x=w*m,S=w*y,P=w*b,v=i[p];l[0]+=x*v[0],l[1]+=x*v[1],l[2]+=x*v[2],h[0]+=S*v[0],h[1]+=S*v[1],h[2]+=S*v[2],u[0]+=P*v[0],u[1]+=P*v[1],u[2]+=P*v[2],d+=x,g+=S,f+=P}if(Math.abs(d)<1e-10){var k=ci(n,t,e,i,r);return{point:k,deriv1:[0,0,0],deriv2:[0,0,0]}}var E=d*d,O=[l[0]/d,l[1]/d,l[2]/d],N=[(h[0]*d-l[0]*g)/E,(h[1]*d-l[1]*g)/E,(h[2]*d-l[2]*g)/E],R=u[0]*d-l[0]*f,nt=u[1]*d-l[1]*f,et=u[2]*d-l[2]*f,G=[R/E-2*g*N[0]/d,nt/E-2*g*N[1]/d,et/E-2*g*N[2]/d];return{point:O,deriv1:N,deriv2:G}}function r0(n,t){var e=n[0],i=n[1],r=t[0],s=t[1],o=e*e+i*i;return o<1e-20?0:(e*s-i*r)/Math.pow(o,1.5)}function tu(n,t,e,i){for(var r=n,s=t[r],o=t[t.length-r-1],a=0,c=1e3,l=(o-s)/c,h=ci(s,n,t,e,i),u=1;u<=c;u++){var d=s+u*l,g=ci(d,n,t,e,i),f=g[0]-h[0],p=g[1]-h[1],m=g[2]-h[2];a+=Math.sqrt(f*f+p*p+m*m),h=g}var y=ci(o,n,t,e,i),b=y[0]-h[0],w=y[1]-h[1],x=y[2]-h[2];return a+=Math.sqrt(b*b+w*w+x*x),a}function s0(n,t,e,i,r){return t===void 0&&(t=3),e===void 0&&(e="Uniform"),n.length===0?[]:Va(n,t,e,i,r).controlPoints}var fl=new D,pl=new A,o0=new A,a0=new A,fo=new _;function eu(n){return new D().setFromExtrusionDirection(new A(n.x,n.y,n.z))}function Qe(n){return fl.setFromExtrusionDirection(new A(n.x,n.y,n.z)),fl.extractBasis(pl,o0,a0),pl.clone()}function At(n,t){var e;return new _(n.x,n.y,(e=n.z)!==null&&e!==void 0?e:0).applyMatrix4(eu(t))}function jt(n,t){var e;return new _(n.x,n.y,(e=n.z)!==null&&e!==void 0?e:0).applyMatrix4(eu(t).invert())}function Le(n,t,e){var i,r,s=jt(n,e),o=jt(t,e);return fo.set(o.x-s.x,o.y-s.y,((i=o.z)!==null&&i!==void 0?i:0)-((r=s.z)!==null&&r!==void 0?r:0)),C.normalizeAngle(Math.atan2(fo.y,fo.x))}function nu(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],o=n[i];e+=s.x*o.y-o.x*s.y}return e*.5}function c0(n){return Math.abs(nu(n))}function l0(n){var t,e,i=n.length;if(i<3)return 0;for(var r=0,s=0,o=0,a=0,c=i-1;a<i;c=a++){var l=n[c],h=n[a],u=l.x,d=l.y,g=(t=l.z)!==null&&t!==void 0?t:0,f=h.x,p=h.y,m=(e=h.z)!==null&&e!==void 0?e:0;r+=(g+m)*(d-p),s+=(u+f)*(g-m),o+=(d+p)*(u-f)}return .5*Math.hypot(r,s,o)}function h0(n){return n.length<3?0:c0(n)}function iu(n){return n.length<3?0:l0(n)}function ja(n,t,e){var i=n.x,r=n.y,s=t.x,o=t.y,a=e.x,c=e.y,l=2*(i*(o-c)+s*(c-r)+a*(r-o));if(V.equalToZero(l))return null;var h=((i*i+r*r)*(o-c)+(s*s+o*o)*(c-r)+(a*a+c*c)*(r-o))/l,u=((i*i+r*r)*(a-s)+(s*s+o*o)*(i-a)+(a*a+c*c)*(s-i))/l,d=Math.hypot(h-i,u-r);return!Number.isFinite(d)||V.isNonPositive(d)?null:{center:new M(h,u),radius:d}}function ml(n,t,e){var i,r,s,o=n.x,a=n.y,c=(i=n.z)!==null&&i!==void 0?i:0,l=new A(t.x-o,t.y-a,((r=t.z)!==null&&r!==void 0?r:0)-c),h=new A(e.x-o,e.y-a,((s=e.z)!==null&&s!==void 0?s:0)-c),u=new A().crossVectors(l,h),d=u.lengthSq();if(d<W*W)return null;var g=l.lengthSq(),f=h.lengthSq(),p=new A().crossVectors(u,l).multiplyScalar(f).add(new A().crossVectors(h,u).multiplyScalar(g)).multiplyScalar(1/(2*d)),m=new _(o+p.x,a+p.y,c+p.z),y=Math.hypot(m.x-o,m.y-a,m.z-c);return!Number.isFinite(y)||V.isNonPositive(y)?null:{center:m,radius:y}}function He(n,t){return Math.atan2(t.y-n.y,t.x-n.x)}function Ae(n,t){return Math.hypot(t.x-n.x,t.y-n.y)}function ru(n,t,e){if(V.isNonPositive(t))return null;var i=e.x-n.x,r=e.y-n.y,s=Math.hypot(i,r);if(V.isNonPositive(s))return null;var o=t/s;return new M(n.x+i*o,n.y+r*o)}var u0=1e-8;function su(n,t,e,i){var r=Math.abs(Ae(n,t)-e);return r<=(i??Math.max(W,e*1e-5))}function ou(n,t,e,i,r){return r===void 0&&(r=u0),Math.abs(n.x-e.x)<=r&&Math.abs(n.y-e.y)<=r&&Math.abs(t-i)<=r}function au(n,t,e,i){var r=Math.max(1e-18,Math.abs(e)*1e-9);return n<e-r?!0:n>e+r?!1:t>i}function yl(n,t,e,i){i===void 0&&(i=!1);var r=ja(n,t,e);if(!r)return null;var s=He(r.center,n),o=He(r.center,t),a=He(r.center,e),c=!C.isAngleOnCcwSweep(s,o,a);return i&&(c=!c),$.fromMathAngles(r.center,r.radius,s,a,c)}function Ua(n,t){return!Number.isFinite(t)||V.isNonPositive(t)?null:new $(n,t,0,Y,!1)}function d0(n,t){var e=Ae(n,t);return V.isNonPositive(e)?null:Ua({x:(n.x+t.x)/2,y:(n.y+t.y)/2},e/2)}function g0(n,t,e){var i=ja(n,t,e);return i?Ua(i.center,i.radius):null}function f0(n,t,e){var i=Ae(e,n);if(V.isNonPositive(i))return null;var r=He(e,n),s=He(e,t),o=C.normalizeAngle(s-r);return $.fromMathAngles(e,i,r,s,o>Math.PI)}function ji(n,t,e,i){var r=Ae(n,t),s=Ae(n,e);if(V.isNonPositive(r)||V.isNonPositive(s))return null;var o=Math.max(W,r*W);return Math.abs(r-s)>o?null:$.fromMathAngles(n,r,He(n,t),He(n,e),i)}function p0(n,t,e,i){var r=Ae(n,t);if(V.isNonPositive(r))return null;var s=ru(n,r,e);return s?ji(n,t,s,i):null}function cu(n,t,e){var i=Ae(n,t),r=Math.abs(e);if(V.isNonPositive(i)||V.isNonPositive(r)||!V.great(Y-r,0))return null;var s=e<0,o=He(n,t),a=s?o-r:o+r;return $.fromMathAngles(n,i,o,a,s)}function m0(n,t,e){var i=Ae(n,t),r=Math.abs(e);if(V.isNonPositive(i)||V.isNonPositive(r)||V.great(r,2*i))return null;var s=Math.max(-1,Math.min(1,r/(2*i))),o=2*Math.asin(s);return cu(n,t,e>=0?o:-o)}function y0(n,t,e){var i=Ae(n,t),r=Math.abs(e);if(V.isNonPositive(i)||V.isNonPositive(r)||!V.great(Y-r,0))return null;var s=Math.sin(r/2);if(V.equalToZero(s))return null;var o=i/(2*s),a=o*o-i*i/4;if(V.less(a,0))return null;var c=Math.sqrt(Math.max(0,a)),l=(n.x+t.x)/2,h=(n.y+t.y)/2,u=t.x-n.x,d=t.y-n.y,g=-d/i,f=u/i,p=e>=0,m=p&&r<=Math.PI||!p&&r>Math.PI,y=m?1:-1,b={x:l+g*c*y,y:h+f*c*y};return ji(b,n,t,!p)}function b0(n,t,e){var i=Math.cos(e),r=Math.sin(e),s=t.x-n.x,o=t.y-n.y,a=-r,c=i,l=2*(s*a+o*c);if(V.equalToZero(l))return null;var h=(s*s+o*o)/l;if(!Number.isFinite(h))return null;var u={x:n.x+a*h,y:n.y+c*h},d=n.x-u.x,g=n.y-u.y,f=d*r-g*i;return V.equalToZero(f)?null:ji(u,n,t,f<0)}function _0(n,t,e){var i=Math.abs(e),r=Ae(n,t);if(V.isNonPositive(i)||V.isNonPositive(r)||V.great(r,2*i))return null;var s=(n.x+t.x)/2,o=(n.y+t.y)/2,a=t.x-n.x,c=t.y-n.y,l=-c/r,h=a/r,u=Math.sqrt(Math.max(0,i*i-r*r/4)),d=e>=0?1:-1,g={x:s+l*u*d,y:o+h*u*d};return ji(g,n,t,e<0)}var lu=(function(){function n(){this._boundingBoxNeedsUpdate=!1}return Object.defineProperty(n.prototype,"boundingBoxNeedUpdate",{get:function(){return this._boundingBoxNeedsUpdate},enumerable:!1,configurable:!0}),n})(),x0=(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)}})(),Ga=(function(n){x0(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.prototype.translate=function(e){return this.transform(new zi().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})(lu),w0=(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)}})(),Kn=(function(n){w0(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),o=0;i.push(0);for(var a=1;a<=e;a++)r=this.getPoint(a/e),o+=r.distanceTo(s),i.push(o),s=r;return i},t.prototype.getUtoTmapping=function(e,i){var r=this.getLengths(),s=0,o=r.length,a;i?a=i:a=e*r[o-1];for(var c=0,l=o-1,h;c<=l;)if(s=Math.floor(c+(l-c)/2),h=r[s]-a,h<0)c=s+1;else if(h>0)l=s-1;else{l=s;break}if(s=l,r[s]===a)return s/(o-1);var u=r[s],d=r[s+1],g=d-u,f=(a-u)/g,p=(s+f)/(o-1);return p},t.prototype.getTangent=function(e){var i=1e-4,r=e-i,s=e+i;r<0&&(r=0),s>1&&(s=1);var o=this.getPoint(r),a=this.getPoint(s),c=new M;return c.copy(a).sub(o).normalize(),c},t.prototype.getTangentAt=function(e){var i=this.getUtoTmapping(e);return this.getTangent(i)},t})(Ga),v0=(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)}})(),Ir=function(){return Ir=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},Ir.apply(this,arguments)},tr=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.")},er=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},nr=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(n){v0(t,n);function t(e,i,r,s,o){var a=n.call(this)||this,c=+(e!==void 0)+ +(i!==void 0)+ +(r!==void 0)+ +(s!==void 0)+ +(o!==void 0);if(c==3)typeof e=="object"&&typeof i=="object"&&typeof r=="object"?a.createByThreePoints(e,i,r):a.createByStartEndPointsAndBulge(e,i,r);else if(c==5){var l=e;a.center=new M(l.x,l.y),a.radius=i,a._clockwise=o,a._startAngle=a._clockwise?a._mirrorAngle(C.normalizeAngle(r)):C.normalizeAngle(r),a._endAngle=a._clockwise?a._mirrorAngle(C.normalizeAngle(s)):C.normalizeAngle(s)}else throw Ot.ILLEGAL_PARAMETERS;return a}return t.fromMathAngles=function(e,i,r,s,o){var a=new t(e,i,C.normalizeAngle(r),C.normalizeAngle(s),!1);return a._clockwise=o,a._boundingBoxNeedsUpdate=!0,a},t.computeCircumcircle=function(e,i,r){return ja(e,i,r)},t.projectPoint=function(e,i,r){return ru(e,i,r)},t.pointLiesOnCircle=function(e,i,r,s){return su(e,i,r,s)},t.sameCircle=function(e,i,r,s,o){return ou(e,i,r,s,o)},t.isBetterDistanceAlign=function(e,i,r,s){return au(e,i,r,s)},t.tryCreateByThreePoints=function(e,i,r,s){return s===void 0&&(s=!1),yl(e,i,r,s)},t.tryCreateCircle=function(e,i){return Ua(e,i)},t.tryCreateCircleByDiameter=function(e,i){return d0(e,i)},t.tryCreateCircleByThreePoints=function(e,i,r){return g0(e,i,r)},t.tryCreateShorterArc=function(e,i,r){return f0(e,i,r)},t.tryCreateByCenterStartEnd=function(e,i,r,s){return ji(e,i,r,s)},t.tryCreateByCenterStartProjectedEnd=function(e,i,r,s){return p0(e,i,r,s)},t.tryCreateByCenterStartSweep=function(e,i,r){return cu(e,i,r)},t.tryCreateByCenterStartChord=function(e,i,r){return m0(e,i,r)},t.tryCreateByStartEndAngle=function(e,i,r){return y0(e,i,r)},t.tryCreateByStartEndDirection=function(e,i,r){return b0(e,i,r)},t.tryCreateByStartEndRadius=function(e,i,r){return _0(e,i,r)},t.prototype.createByThreePoints=function(e,i,r){var s=yl(e,i,r);if(!s)throw Ot.ILLEGAL_PARAMETERS;this.center=s.center,this.radius=s.radius,this._clockwise=s._clockwise,this._startAngle=s._startAngle,this._endAngle=s._endAngle,this._boundingBoxNeedsUpdate=!0},t.prototype.createByStartEndPointsAndBulge=function(e,i,r){var s,o,a;r<0?(s=Math.atan(-r)*4,o=new ht(e),a=new ht(i)):(s=Math.atan(r)*4,o=new ht(i),a=new ht(e));var c=new ht().subVectors(a,o),l=c.length(),h=new ht().addVectors(o,c.multiplyScalar(.5)),u=Math.abs(l/2/Math.tan(s/2)),d=c.normalize(),g=r<0?-Math.PI/2:Math.PI/2,f=new ht(d.x*Math.cos(g)-d.y*Math.sin(g),d.y*Math.cos(g)+d.x*Math.sin(g)),p;s<Math.PI?r<0?p=h.add(f.multiplyScalar(u)):p=h.add(f.multiplyScalar(-u)):r<0?p=h.add(f.multiplyScalar(-u)):p=h.add(f.multiplyScalar(u)),r<0?(this._startAngle=Math.atan2(o.y-p.y,o.x-p.x),this._endAngle=Math.atan2(a.y-p.y,a.x-p.x)):(this._startAngle=Math.atan2(a.y-p.y,a.x-p.x),this._endAngle=Math.atan2(o.y-p.y,o.x-p.x)),this._clockwise=r<0,this.center=p,this.radius=a.sub(p).length()},Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new M(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==Y?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 o=tr(s),a=o.next();!a.done;a=o.next()){var c=a.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{a&&!a.done&&(i=o.return)&&i.call(o)}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 kt(new M(Math.min.apply(Math,nr([],er(h),!1)),Math.min.apply(Math,nr([],er(u),!1))),new M(Math.max.apply(Math,nr([],er(h),!1)),Math.max.apply(Math,nr([],er(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),o=this.startPoint.clone().applyMatrix2d(r);if(this.closed)return this.center=s,this.radius=s.distanceTo(o),this._startAngle=Math.atan2(o.y-s.y,o.x-s.x),this._endAngle=this._startAngle,this._clockwise=r.determinant()<0?!this._clockwise:this._clockwise,this._boundingBoxNeedsUpdate=!0,this;var a=this.midPoint.clone().applyMatrix2d(r),c=this.endPoint.clone().applyMatrix2d(r),l=new t(o,a,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(o.y-l.center.y,o.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 M(r,s)},t.prototype.getQuadrantPoints=function(){var e,i,r=[],s=this._getInternalAngle(this.startAngle),o=this._getInternalAngle(this.endAngle),a=[0,Math.PI/2,Math.PI,3*Math.PI/2];try{for(var c=tr(a),l=c.next();!l.done;l=c.next()){var h=l.value,u=this._getInternalAngle(h);C.isBetweenAngle(u,s,o,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 M(e.x,e.y),r=i.x-this.center.x,s=i.y-this.center.y,o=Math.hypot(r,s);if(o<1e-12)return this.startPoint.clone();var a=Math.atan2(s,r),c=this.clockwise?this._mirrorAngle(C.normalizeAngle(a)):C.normalizeAngle(a),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.inwardAlignment=function(e,i){var r=i.x-e.x,s=i.y-e.y;if(r*r+s*s<1e-24)return 0;var o=this.radius>0?this.radius:1,a=Math.max(1e-16,1e-12*o*o),c=this.startPoint.distanceToSquared(e)<=a,l=this.endPoint.distanceToSquared(e)<=a;if(!c&&!l)return 0;var h=this.getPoints(8);if(h.length<3)return 0;var u=c&&!l?h[1]:h[h.length-2],d=u.x-e.x,g=u.y-e.y,f=Math.hypot(d,g);return f>1e-18?(r*d+s*g)/f:0},t.prototype.perpendicularPoints=function(e){var i,r,s=new M(e.x,e.y),o=s.x-this.center.x,a=s.y-this.center.y,c=Math.hypot(o,a);if(c<1e-12)return[];var l=o/c,h=a/c,u=[new M(this.center.x+l*this.radius,this.center.y+h*this.radius),new M(this.center.x-l*this.radius,this.center.y-h*this.radius)],d=[],g=this._getInternalAngle(this.startAngle),f=this._getInternalAngle(this.endAngle);try{for(var p=tr(u),m=p.next();!m.done;m=p.next()){var y=m.value,b=Math.atan2(y.y-this.center.y,y.x-this.center.x),w=this.clockwise?this._mirrorAngle(C.normalizeAngle(b)):C.normalizeAngle(b),x=this._getInternalAngle(w);(this.closed||C.isBetweenAngle(x,g,f,this.clockwise))&&d.push(y)}}catch(S){i={error:S}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}finally{if(i)throw i.error}}return d},t.prototype.tangentPoints=function(e){var i,r,s=[],o=e.x-this.center.x,a=e.y-this.center.y,c=Math.hypot(o,a),l=this.radius;if(c<l)return s;var h=Math.acos(l/c),u=Math.atan2(a,o),d=[u+h,u-h],g=this._getInternalAngle(this.startAngle),f=this._getInternalAngle(this.endAngle);try{for(var p=tr(d),m=p.next();!m.done;m=p.next()){var y=m.value,b=this.clockwise?this._mirrorAngle(C.normalizeAngle(y)):C.normalizeAngle(y),w=this._getInternalAngle(b);(this.closed||C.isBetweenAngle(w,g,f,this.clockwise))&&s.push(this.getPointAtAngle(b))}}catch(x){i={error:x}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}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=Y,s=0),this.clockwise)for(var o=0;o<=e;o++){var a=s-r*(o/e),c=this._clockwise?this._mirrorAngle(a):a,l=this.getPointAtAngle(c);i.push(new M(l.x,l.y))}else for(var o=0;o<=e;o++){var a=s+r*(o/e),c=this._clockwise?this._mirrorAngle(a):a,l=this.getPointAtAngle(c);i.push(new M(l.x,l.y))}return i},t.prototype.tessellate=function(e){var i,r=this.closed?Y:this.deltaAngle,s=t.segmentCount(this.radius,r,Ir(Ir({},e),{minSegments:(i=e==null?void 0:e.minSegments)!==null&&i!==void 0?i:this.closed?8:3}));return this.getPoints(s)},t.resolveCircleSides=function(e){return e==null||!Number.isFinite(e)?t.DEFAULT_CIRCLE_SIDES:Jt(Math.round(e),t.MIN_CIRCLE_SIDES,t.MAX_CIRCLE_SIDES)},t.resolveTessellateOptions=function(e){var i,r=t.resolveCircleSides(e==null?void 0:e.circleSides),s=Math.max(1,Math.round((i=e==null?void 0:e.maxSegments)!==null&&i!==void 0?i:r));return{deviation:e==null?void 0:e.deviation,circleSides:r,minSegments:e==null?void 0:e.minSegments,maxSegments:s}},t.chordDeviationFromRadius=function(e,i){i===void 0&&(i=t.DEFAULT_CIRCLE_SIDES);var r=Math.abs(e),s=t.resolveCircleSides(i);return r<=W?W:Math.max(W,r*(1-Math.cos(Math.PI/s)))},t.segmentCount=function(e,i,r){var s,o,a=t.resolveTessellateOptions(r),c=Math.abs(i),l=c>=Y-1e-8,h=Math.max(1,Math.round((s=a.minSegments)!==null&&s!==void 0?s:l?8:3)),u=Math.max(h,a.maxSegments),d=Math.abs(e);if(d<=W||c<=W)return h;var g=(o=a.deviation)!==null&&o!==void 0?o:t.chordDeviationFromRadius(d,a.circleSides),f=1-g/d;if(!Number.isFinite(f)||f>=1)return u;if(f<=-1)return h;var p=2*Math.acos(f);return p<=W?u:Jt(Math.ceil(c/p),h,u)},t.DEFAULT_CIRCLE_SIDES=100,t.MIN_CIRCLE_SIDES=8,t.MAX_CIRCLE_SIDES=2e4,t})(Kn),Uo=function(){return Uo=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},Uo.apply(this,arguments)},A0=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.")},ir=1e-6;function hu(n,t){if(G0(n)){var e=S0(n,t);return e?[e]:[]}var i=fu(n),r=i.numberOfVertices;if(r<2)return[];var s=W0(i,t);return s?[s]:[]}function P0(n){return fu(n)}function S0(n,t){var e,i,r=k0(n);if(r.length===0)return null;var s=[];try{for(var o=A0(r),a=o.next();!a.done;a=o.next()){var c=a.value,l=I0(c,t);if(!l)return null;s.push(l)}}catch(g){e={error:g}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(e)throw e.error}}var h=E0(n),u=C0(s,h,n.closed,t);if(u.length<2)return null;var d=new it;return u.forEach(function(g,f){d.addVertexAt(f,{x:g.x,y:g.y})}),d.closed=n.closed,d}function k0(n){for(var t,e=[],i=n.numberOfVertices,r=n.closed?i:i-1,s=0;s<r;s++){var o=n.vertices[s],a=n.vertices[(s+1)%i];V.isPositive(Math.abs((t=o.bulge)!==null&&t!==void 0?t:0))?e.push({kind:"arc",arc:new $(o,a,o.bulge)}):e.push({kind:"line",start:new M(o.x,o.y),end:new M(a.x,a.y)})}return e}function E0(n){for(var t=[],e=0;e<n.numberOfVertices;e++)t.push(n.getPointAt(e));return t}function I0(n,t){if(n.kind==="line"){var e=M0(n.start,n.end,t);return e?Uo({kind:"line"},e):null}var i=T0(n.arc,n.arc.startPoint,n.arc.endPoint,t);return i?{kind:"arc",arc:i}:null}function T0(n,t,e,i){var r=L0(n,t,e,i),s=n.radius+r;return V.isNonPositive(s)?null:new $(n.center,s,n.startAngle,n.endAngle,n.clockwise)}function L0(n,t,e,i){var r=e.x-t.x,s=e.y-t.y,o=Math.hypot(r,s);if(V.isNonPositive(o))return n.clockwise?-i:i;var a=-s/o,c=r/o,l=n.center.x-(t.x+e.x)/2,h=n.center.y-(t.y+e.y)/2,u=l*a+h*c>0;return u?-i:i}function M0(n,t,e){var i=t.x-n.x,r=t.y-n.y,s=Math.hypot(i,r);if(V.isNonPositive(s))return null;var o=-r/s*e,a=i/s*e;return{start:new M(n.x+o,n.y+a),end:new M(t.x+o,t.y+a),dx:i,dy:r}}function C0(n,t,e,i){var r,s,o,a=n.length;if(a===0)return[];for(var c=O0(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<a;h++){var u=n[h],d=h===a-1&&!e?{point:D0(u)}:c[(h+1)%a];if(h>0&&c[h].filletPoints&&c[h].filletPoints.forEach(function(y){return l.push(y.clone())}),u.kind==="arc")for(var g=(o=c[h].nextSegmentStart)!==null&&o!==void 0?o:c[h].point,f=d.point,p=R0(u.arc,g,f,Math.max(16,32)),m=1;m<p.length;m++)l.push(p[m]);else l.push(d.point.clone())}return pu(l)}function O0(n,t,e,i){for(var r=n.length,s=[],o=0;o<r;o++)o===0?s.push(e?bl(n[r-1],n[0],t[0],i):{point:F0(n[0])}):s.push(bl(n[o-1],n[o],t[o],i));return s}function R0(n,t,e,i){for(var r=n.nearestPoint(t),s=n.nearestPoint(e),o=Go(n,r),a=Go(n,s),c=B0(n,o,a),l=[],h=0;h<=i;h++){var u=h/i,d=n.clockwise?o-c*u:o+c*u;l.push(n.getPointAtAngle(N0(n,d)))}return l}function Go(n,t){return Math.atan2(t.y-n.center.y,t.x-n.center.x)}function N0(n,t){var e=C.normalizeAngle(t);return n.clockwise?Ho(e):e}function Ho(n){var t=n*180/Math.PI;return(360-t)%360*(Math.PI/180)}function B0(n,t,e){if(n.clockwise){var i=t-e;return V.isNonPositive(i)&&(i+=Y),i}var r=e-t;return V.isNonPositive(r)&&(r+=Y),r}function F0(n){return n.kind==="line"?n.start.clone():n.arc.startPoint.clone()}function D0(n){return n.kind==="line"?n.end.clone():n.arc.endPoint.clone()}function bl(n,t,e,i){return n.kind==="line"&&t.kind==="line"?{point:Wo({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"?_l(n,t.arc,e,i,!0):n.kind==="arc"&&t.kind==="line"?_l(t,n.arc,e,i,!1):n.kind==="arc"&&t.kind==="arc"?X0(n.arc,t.arc,e,i):{point:e.clone()}}function X0(n,t,e,i){var r=gu(n.endPoint,t.startPoint),s=U0(n,t),o=s.filter(function(h){return Tr(n,h)&&Tr(t,h)});if(o.length>0)return{point:du(o,r)};var a=n.endPoint.clone(),c=t.startPoint.clone(),l=uu(e,Math.abs(i),a,c);return{point:a,filletPoints:l,nextSegmentStart:c}}function _l(n,t,e,i,r){var s=gu(r?n.end:n.start,r?t.startPoint:t.endPoint),o=j0(n,t,s);if(z0(n,o)&&Tr(t,o))return{point:o};var a=Y0(n,e,i),c=r?t.startPoint.clone():t.endPoint.clone(),l=uu(e,Math.abs(i),r?a:c,r?c:a);return r?{point:a,filletPoints:l,nextSegmentStart:c}:{point:c,filletPoints:l,nextSegmentStart:a}}function Y0(n,t,e){var i=Math.hypot(n.dx,n.dy),r=-n.dy/i*e,s=n.dx/i*e;return new M(t.x+r,t.y+s)}function z0(n,t){var e=Math.hypot(n.dx,n.dy);if(V.isNonPositive(e))return!1;var i=n.dx/e,r=n.dy/e,s=t.x-n.start.x,o=t.y-n.start.y,a=Math.abs(s*r-o*i);return V.equalToZero(a)}function uu(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),o=V0(r,s);if(V.equalToZero(Math.abs(o)))return[];for(var a=[],c=Math.max(2,Math.ceil(Math.abs(o)/Math.PI*16)),l=1;l<c;l++){var h=l/c,u=r+o*h;a.push(new M(n.x+t*Math.cos(u),n.y+t*Math.sin(u)))}return a}function V0(n,t){for(var e=t-n;e>Math.PI;)e-=Y;for(;e<=-Math.PI;)e+=Y;return e}function j0(n,t,e){var i=Math.hypot(n.dx,n.dy);if(V.isNonPositive(i))return e.clone();var r=n.dx/i,s=n.dy/i,o=n.start.x-t.center.x,a=n.start.y-t.center.y,c=2*(o*r+a*s),l=o*o+a*a-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(f){return new M(n.start.x+r*f,n.start.y+s*f)}),g=d.filter(function(f){return Tr(t,f)});return du(g.length>0?g:d,e)}function Tr(n,t){var e=Math.abs(Math.hypot(t.x-n.center.x,t.y-n.center.y)-n.radius);if(V.isPositive(e))return!1;var i=Go(n,t),r=n.clockwise?Ho(C.normalizeAngle(n.startAngle)):C.normalizeAngle(n.startAngle),s=n.clockwise?Ho(C.normalizeAngle(n.endAngle)):C.normalizeAngle(n.endAngle);return C.isBetweenAngle(i,r,s,n.clockwise)}function U0(n,t){var e=t.center.x-n.center.x,i=t.center.y-n.center.y,r=Math.hypot(e,i);if(V.isNonPositive(r))return[];var s=n.radius+t.radius,o=Math.abs(n.radius-t.radius);if(r>s+ir)return[];if(r<o-ir)return[];var a=(n.radius*n.radius-t.radius*t.radius+r*r)/(2*r),c=n.radius*n.radius-a*a;if(c<-ir)return[];var l=n.center.x+a*e/r,h=n.center.y+a*i/r;if(c<=ir)return[new M(l,h)];var u=Math.sqrt(c),d=-i*u/r,g=e*u/r;return[new M(l+d,h+g),new M(l-d,h-g)]}function du(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 gu(n,t){return new M((n.x+t.x)/2,(n.y+t.y)/2)}function G0(n){for(var t,e=n.numberOfVertices,i=n.closed?e:e-1,r=0;r<i;r++){var s=n.vertices[r];if(V.isPositive(Math.abs((t=s.bulge)!==null&&t!==void 0?t:0)))return!0}return!1}function fu(n){var t=H0(n.vertices.map(function(e){return new M(e.x,e.y)}),n.closed);return t.length===n.numberOfVertices?n:new it(t.map(function(e){return{x:e.x,y:e.y}}),n.closed)}function H0(n,t){var e=pu(n);if(!t||e.length<2)return e;var i=e[0],r=e[e.length-1];return V.isNonPositive(Math.hypot(i.x-r.x,i.y-r.y))&&e.pop(),e}function pu(n){var t=[];return n.forEach(function(e){var i=t[t.length-1];(!i||V.isPositive(Math.hypot(i.x-e.x,i.y-e.y)))&&t.push(new M(e.x,e.y))}),t}function W0(n,t){for(var e=[],i=0;i<n.numberOfVertices;i++)e.push(n.getPointAt(i));var r=$0(e,n.closed,t);if(r.length===0)return null;var s=[];if(n.closed){if(r.length<2)return null;for(var o=r.length,i=0;i<o;i++){var a=r[(i-1+o)%o],c=r[i];s.push(Wo(a,c))}}else{s.push(r[0].start);for(var i=1;i<r.length;i++)s.push(Wo(r[i-1],r[i]));s.push(r[r.length-1].end)}var l=new it;return s.forEach(function(h,u){l.addVertexAt(u,{x:h.x,y:h.y})}),l.closed=n.closed,l}function $0(n,t,e){for(var i=[],r=t?n.length:n.length-1,s=0;s<r;s++){var o=n[s],a=n[t?(s+1)%n.length:s+1],c=a.x-o.x,l=a.y-o.y,h=Math.hypot(c,l);if(!V.isNonPositive(h)){var u=-l/h*e,d=c/h*e;i.push({start:new M(o.x+u,o.y+d),end:new M(a.x+u,a.y+d),dx:c,dy:l})}}return i}function Wo(n,t){var e=n.dx*t.dy-n.dy*t.dx;if(V.equalToZero(e))return new M((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 M(n.start.x+s*n.dx,n.start.y+s*n.dy)}var q0=(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)}})(),$o=function(){return $o=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},$o.apply(this,arguments)},it=(function(n){q0(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 M(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 M(i.x,i.y)}else{var i=this._vertices[e-1];return new M(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],o=null;if(r<i-1?o=this._vertices[r+1]:r==i-1&&this.closed&&(o=this._vertices[0]),o)if(s.bulge){var a=new $(s,o,s.bulge);e+=a.length}else e+=new M(s.x,s.y).distanceTo(o)}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 h0(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 M(i.x,i.y)},t.prototype.calculateBoundingBox=function(){var e=this.getPoints(100);return new kt().setFromPoints(e)},t.prototype.transform=function(e){var i=e.determinant()<0;return this._vertices.forEach(function(r){var s=new M(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 $o({},e)}),this._closed)},t.prototype.getPoints3d=function(e,i){var r=[],s=this.getPoints(e);return s.forEach(function(o){return r.push(new _().set(o.x,o.y,i))}),r},t.prototype.getPoints=function(e){for(var i=[],r=this._vertices.length,s=0;s<r;++s){var o=this._vertices[s];if(o.bulge){var a=null;if(s<r-1?a=this._vertices[s+1]:s==r-1&&this.closed&&(a=this._vertices[0]),a)for(var c=new $(o,a,o.bulge),l=c.getPoints(e),h=l.length,u=0;u<h;++u){var d=l[u];i.push(new M(d.x,d.y))}}else i.push(new M(o.x,o.y)),s==r-1&&this.closed&&i.push(i[0])}return i},t.prototype.tessellate=function(e){for(var i=[],r=this._vertices.length,s=0;s<r;++s){var o=this._vertices[s];if(o.bulge){var a=null;if(s<r-1?a=this._vertices[s+1]:s===r-1&&this.closed&&(a=this._vertices[0]),a)for(var c=new $(o,a,o.bulge),l=c.tessellate(e),h=0;h<l.length;++h)xl(i,l[h])}else xl(i,o),s===r-1&&this.closed&&i.length>0&&i.push(i[0].clone())}return i},t.prototype.offset=function(e){return hu(this,e)},t})(Kn);function xl(n,t){var e=n[n.length-1];if(e){var i=e.x-t.x,r=e.y-t.y;if(i*i+r*r<=W*W)return}n.push(new M(t.x,t.y))}function mu(n,t,e){var i=Math.hypot(t.x,t.y);if(V.isNonPositive(i))return null;var r=-t.y/i*e,s=t.x/i*e;return new _(n.x+r,n.y+s,n.z)}function K0(n,t,e){var i;if(n.length<2)return null;var r=P0(new it(n.map(function(o){return{x:o.x,y:o.y}}),t)),s=hu(r,e);return(i=s[0])!==null&&i!==void 0?i:null}var Lr=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Cn=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 Z0(n,t,e,i){if(n.length<2||V.equalToZero(e))return null;var r=bu(n,i),s=r.points,o=r.tangents;if(s.length<2)return null;var a=o??Q0(s,t),c=J0(s,a,e),l=t?em(c):tm(c);if(l.length<2)return null;var h=new it;return l.forEach(function(u,d){h.addVertexAt(d,{x:u.x,y:u.y})}),h.closed=t,h}function Q0(n,t){for(var e=n.length,i=new Array(e),r=0;r<e;r++){var s=0,o=0;if(t){var a=n[(r-1+e)%e],c=n[(r+1)%e];s=c.x-a.x,o=c.y-a.y}else r===0?(s=n[1].x-n[0].x,o=n[1].y-n[0].y):r===e-1?(s=n[e-1].x-n[e-2].x,o=n[e-1].y-n[e-2].y):(s=n[r+1].x-n[r-1].x,o=n[r+1].y-n[r-1].y);var l=Math.hypot(s,o);V.isNonPositive(l)?i[r]=new M(1,0):i[r]=new M(s/l,o/l)}return i}function J0(n,t,e){return n.map(function(i,r){var s=t[r],o=-s.y*e,a=s.x*e;return new M(i.x+o,i.y+a)})}function tm(n){var t=Mr(n);if(t.length<3)return t;for(;;){var e=yu(t,!1);if(!e||(t=Mr(Cn(Cn(Cn([],Lr(t.slice(0,e.segmentA+1)),!1),[e.point],!1),Lr(t.slice(e.segmentB+1)),!1)),t.length<2))break}return t}function em(n){var t=Mr(n);if(t.length<4)return t;for(;;){var e=yu(t,!0);if(!e||(t=Mr(Cn(Cn(Cn([],Lr(t.slice(0,e.segmentA+1)),!1),[e.point],!1),Lr(t.slice(e.segmentB+1)),!1)),t.length<3))break}return t}function yu(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],o=i+1;o<e;o++)if(!nm(i,o,e,t)){var a=n[o],c=n[(o+1)%n.length],l=im(r,s,a,c);if(l)return{point:l,segmentA:i,segmentB:o}}return null}function nm(n,t,e,i){return!!(t===n||t===n+1||i&&n===0&&t===e-1)}function im(n,t,e,i){var r=t.x-n.x,s=t.y-n.y,o=i.x-e.x,a=i.y-e.y,c=r*a-s*o;if(V.equalToZero(c))return null;var l=e.x-n.x,h=e.y-n.y,u=(l*a-h*o)/c,d=(l*s-h*r)/c,g=Vi.equalPointTol;return u<-g||u>1+g||d<-g||d>1+g?null:new M(n.x+u*r,n.y+u*s)}function bu(n,t){var e=[],i=[],r=t!=null&&t.length===n.length;return n.forEach(function(s,o){var a=e[e.length-1];if((!a||V.isPositive(Math.hypot(a.x-s.x,a.y-s.y)))&&(e.push(new M(s.x,s.y)),r)){var c=t[o];i.push(new M(c.x,c.y))}}),{points:e,tangents:r?i:void 0}}function Mr(n){return bu(n).points}var rm=(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)}})(),oe=(function(n){rm(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 kt},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],o=s.getPoints(e);i.push(o)}return i},t.prototype.tessellate=function(e){return this.loops.map(function(i){return i.tessellate(e)})},t.prototype.buildHierarchy=function(e){for(var i,r=this.tessellate(e),s=this.calculateBoundaryBoxes(r),o=this.sortBoundaryBoxesByAreas(s),a=new Map,c=o.length,l=0;l<c;l++)a.set(o[l],{index:o[l],children:[]});for(var h={index:-1,children:[]},l=0;l<c;l++){for(var u=o[l],d=r[u],g=s[u],f=l+1;f<c;f++){var p=o[f],m=r[p],y=s[p];if(y.containsBox(g)&&Lt.isPointInPolygon(d[C.randInt(0,d.length-1)],m)){(i=a.get(p))===null||i===void 0||i.children.push(a.get(u));break}}f===c&&h.children.push(a.get(u))}return h},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),o=nu(s);i===0?e+=Math.abs(o):e-=Math.abs(o)}return e},enumerable:!1,configurable:!0}),t.prototype.calculateBoundaryBoxes=function(e){var i=[];return e.forEach(function(r){i.push(new kt().setFromPoints(r))}),i},t.prototype.sortBoundaryBoxesByAreas=function(e){var i=[];e.forEach(function(s,o){var a=s.size,c=a.width*a.height;i.push({area:c,index:o})}),i.sort(function(s,o){return s.area-o.area});var r=[];return i.forEach(function(s){r.push(s.index)}),r},t})(Ga),sm=(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)}})(),om=(function(n){sm(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})(lu),am=(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)}})(),un=(function(n){am(t,n);function t(){return n!==null&&n.apply(this,arguments)||this}return t.tessellateParametricCurve=function(e,i,r,s){var o=Math.max(2,Math.round(s.maxSegments)),a=Math.max(1,Math.round(s.minSegments)),c=Math.max(0,s.deviation)*Math.max(0,s.deviation);if(!Number.isFinite(e)||!Number.isFinite(i))return[r(0)];if(Math.abs(i-e)<=W)return[r(e)];for(var l=Math.min(o,Math.max(2,a+1)),h=Math.min(o,Math.max(l,8)),u=lm(e,i,h),d=[],g=0;g<u.length;g++)d.push(r(u[g]));for(var f=d.length,p=0;p<8&&f<o;p++){for(var m=[],g=0;g<u.length-1&&!(f>=o);g++){var y=(u[g]+u[g+1])/2,b=r(y);f++,cm(b,d[g],d[g+1])>c&&m.push({index:g,t:y,point:b})}if(m.length===0)break;var w=hm(u,d,m);u=w.params,d.length=0;for(var g=0;g<w.points.length;g++)d.push(w.points[g])}return d},t})(om);function cm(n,t,e){var i=e.x-t.x,r=e.y-t.y,s=e.z-t.z,o=n.x-t.x,a=n.y-t.y,c=n.z-t.z,l=i*i+r*r+s*s;if(l<=W*W)return o*o+a*a+c*c;var h=Jt((o*i+a*r+c*s)/l,0,1),u=o-i*h,d=a-r*h,g=c-s*h;return u*u+d*d+g*g}function lm(n,t,e){if(e<=1)return[n];for(var i=[],r=0;r<e;r++)i.push(r===e-1?t:n+(t-n)*r/(e-1));return i}function hm(n,t,e){for(var i=[],r=[],s=0,o=0;o<n.length;o++)for(i.push(n[o]),r.push(t[o]);s<e.length&&e[s].index===o;)i.push(e[s].t),r.push(e[s].point),s++;return{params:i,points:r}}var um=(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)}})(),Cr=function(){return Cr=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},Cr.apply(this,arguments)},po=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.")},Pt=(function(n){um(t,n);function t(e,i,r,s,o,a){a===void 0&&(a=A.X_AXIS);var c=n.call(this)||this;return c.center=e,c.radius=i,c.startAngle=r,c.endAngle=s,c.normal=o,c.refVec=a,(s-r)%Y==0?(c.startAngle=0,c.endAngle=Y):(c.startAngle=r,c.endAngle=s),c}return t.computeCenterPoint=function(e,i,r){var s,o;return(o=(s=ml(e,r,i))===null||s===void 0?void 0:s.center)!==null&&o!==void 0?o:null},t.tryCreateByThreePoints=function(e,i,r){var s,o,a,c=ml(e,r,i);if(!c)return null;var l=c.center,h=c.radius,u=new A(e.x-l.x,e.y-l.y,((s=e.z)!==null&&s!==void 0?s:0)-l.z),d=new A(r.x-l.x,r.y-l.y,((o=r.z)!==null&&o!==void 0?o:0)-l.z),g=new A(i.x-l.x,i.y-l.y,((a=i.z)!==null&&a!==void 0?a:0)-l.z);if(u.lengthSq()===0||g.lengthSq()===0)return null;var f=new A().crossVectors(u,g);if(f.lengthSq()===0&&(f.crossVectors(u,d),f.lengthSq()===0))return null;f.normalize();var p=u.clone().normalize(),m=new A().crossVectors(f,p),y=function(w){return C.normalizeAngle(Math.atan2(w.dot(m),w.dot(p)))};C.isAngleOnCcwSweep(0,y(d),y(g))||(f.negate(),m.negate());var b=y(g);return V.equalToZero(b)&&(b=Y),new t(l,h,0,b,f,p)},t.createByThreePoints=function(e,i,r){return t.tryCreateByThreePoints(e,i,r)},Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new _(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 Ot.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==Y?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 A(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 A(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=Y);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 A(e.x,e.y,e.z||0),r=this.center,s=this.normal,o=i.clone().sub(r),a=o.dot(s),c=i.clone().sub(s.clone().multiplyScalar(a)),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,f=C.normalizeAngle(u-d);f<0&&(f=0),f>g&&(f=g);var p=this.getPointAtAngle(d+f),m=p.distanceTo(i),y=this.startPoint.distanceTo(i),b=this.endPoint.distanceTo(i);return y<m&&y<=b?this.startPoint.clone():b<m&&b<y?this.endPoint.clone():p},t.prototype.tangentPoints=function(e){var i,r,s=[],o=new A(e.x,e.y,e.z||0),a=this.center,c=this.normal,l=this.radius,h=o.clone().sub(a),u=h.dot(c),d=o.clone().sub(c.clone().multiplyScalar(u)),g=a.clone(),f=d.clone().sub(g),p=f.length();if(p<l)return s;var m=Math.acos(l/p),y=this.getAngle(d.clone()),b=[y+m,y-m];try{for(var w=po(b),x=w.next();!x.done;x=w.next()){var S=x.value,P=C.normalizeAngle(S-this.startAngle);P>=0&&P<=this.deltaAngle&&s.push(this.getPointAtAngle(this.startAngle+P))}}catch(v){i={error:v}}finally{try{x&&!x.done&&(r=w.return)&&r.call(w)}finally{if(i)throw i.error}}return s},t.prototype.perpendicularPoints=function(e){var i,r,s=[],o=new A(e.x,e.y,e.z||0),a=this.center,c=this.normal,l=this.radius,h=o.clone().sub(a),u=h.dot(c),d=o.clone().sub(c.clone().multiplyScalar(u)),g=d.clone().sub(a);if(g.lengthSq()<1e-24)return s;g.normalize();var f=[a.clone().add(g.clone().multiplyScalar(l)),a.clone().sub(g.clone().multiplyScalar(l))];try{for(var p=po(f),m=p.next();!m.done;m=p.next()){var y=m.value,b=this.getAngle(y.clone()),w=C.normalizeAngle(b-this.startAngle);w>=0&&w<=this.deltaAngle&&s.push(new _(y.x,y.y,y.z||0))}}catch(x){i={error:x}}finally{try{m&&!m.done&&(r=p.return)&&r.call(p)}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 _(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 o=1/0,a=1/0,c=1/0,l=-1/0,h=-1/0,u=-1/0;try{for(var d=po(r),g=d.next();!g.done;g=d.next()){var f=g.value,p=this.getPointAtAngle(f);p.x<o&&(o=p.x),p.y<a&&(a=p.y),p.z<c&&(c=p.z),p.x>l&&(l=p.x),p.y>h&&(h=p.y),p.z>u&&(u=p.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 j({x:o,y:a,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=Y,s=0);for(var o=0;o<=e;o++){var a=s+r*(o/e),c=this.getPointAtAngle(a);i.push(c)}return i},t.prototype.tessellate=function(e){var i,r=this.closed?Y:this.deltaAngle,s=t.segmentCount(this.radius,r,Cr(Cr({},e),{minSegments:(i=e==null?void 0:e.minSegments)!==null&&i!==void 0?i:this.closed?8:3}));return this.getPoints(s)},t.segmentCount=function(e,i,r){return $.segmentCount(e,i,r)},t.prototype.transform=function(e){var i=this.center.clone().applyMatrix4(e),r=this.startPoint.clone().applyMatrix4(e),s=this.endPoint.clone().applyMatrix4(e),o=this.getPointAtAngle(this.closed?Math.PI/2:this.startAngle+this.deltaAngle/2).clone().applyMatrix4(e),a=new A(r).sub(i).normalize(),c=i.distanceTo(r),l=new A().crossVectors(new A(r).sub(i),new A(o).sub(i)).normalize();l.lengthSq()===0&&(l=this.normal.clone().transformDirection(e));var h=function(u){var d=new A(u).sub(i);return Math.atan2(d.dot(wl.crossVectors(l,a)),d.dot(a))};return this.center=i,this.radius=c,this.normal=l,this.refVec=a,this.startAngle=0,this.endAngle=this.closed?Y: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(wl.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},o=this.center,a=this.radius;return new _(o.x+a*(r.x*Math.cos(e)+s.x*Math.sin(e)),o.y+a*(r.y*Math.cos(e)+s.y*Math.sin(e)),o.z+a*(r.z*Math.cos(e)+s.z*Math.sin(e)))},Object.defineProperty(t.prototype,"plane",{get:function(){var e=new A(this.center).distanceTo(za);return new Ds(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})(un),wl=new A,dm=(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)}})(),Ie=(function(n){dm(t,n);function t(e,i,r,s,o,a,c){s===void 0&&(s=0),o===void 0&&(o=Y),a===void 0&&(a=!1),c===void 0&&(c=0);var l=n.call(this)||this;return l.center=e,l.majorAxisRadius=i,l.minorAxisRadius=r,(o-s)%Y==0?(l.startAngle=0,l.endAngle=Y):(l.startAngle=s,l.endAngle=o),l.clockwise=a,l.rotation=c,l}return Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new _(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 Ot.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 Ot.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==Y?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,o=-1/0,a=0;a<=e;a++){var c=this.getPoint(a/e);i=Math.min(i,c.x),r=Math.min(r,c.y),s=Math.max(s,c.x),o=Math.max(o,c.y)}return new kt({x:i,y:r},{x:s,y:o})},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 o=this.startAngle+e*r,a=this.center.x+this.majorAxisRadius*Math.cos(o),c=this.center.y+this.minorAxisRadius*Math.sin(o);if(this.rotation!==0){var l=Math.cos(this.rotation),h=Math.sin(this.rotation),u=a-this.center.x,d=c-this.center.y;a=u*l-d*h+this.center.x,c=u*h+d*l+this.center.y}return new M(a,c)},t.prototype.transform=function(e){var i=e,r=new M(this.center).applyMatrix2d(i),s=new _(r.x,r.y,this.center.z),o=this.getPointAtAngle(0).clone().applyMatrix2d(i),a=this.getPointAtAngle(Math.PI/2).clone().applyMatrix2d(i),c=new M(o).sub(r),l=new M(a).sub(r),h=c.length(),u=l.length(),d=Math.atan2(c.y,c.x),g=c.clone().normalize(),f=l.clone().normalize(),p=function(b){var w=new M(b).sub(r),x=w.dot(g),S=w.dot(f);return C.normalizeAngle(Math.atan2(S/u,x/h))},m=i.determinant()<0?!this.clockwise:this.clockwise,y=this.closed?new t(s,h,u,0,Y,m,d):new t(s,h,u,p(this.startPoint.clone().applyMatrix2d(i)),p(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/Y: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),o=Math.sin(this.rotation),a=this.majorAxisRadius>=this.minorAxisRadius,c=a?s:-o,l=a?o:s;return[new M(this.center.x-r*c,this.center.y-r*l),new M(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 M(e.x,e.y),r=this.getPoint(0),s=i.distanceToSquared(r),o=72,a=1;a<=o;a++){var c=this.getPoint(a/o),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(o,a,c,l){var h=-i.majorAxisRadius*l,u=i.minorAxisRadius*c;return(o-r.x)*u-(a-r.y)*h});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype.perpendicularPoints=function(e){var i=this,r=this._projectPointToLocal(e),s=this._findSnapAngles(r,function(o,a,c,l){var h=i.minorAxisRadius*c,u=i.majorAxisRadius*l;return(o-r.x)*u-(a-r.y)*h});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype._projectPointToLocal=function(e){var i=e.x-this.center.x,r=e.y-this.center.y,s=Math.cos(-this.rotation),o=Math.sin(-this.rotation);return{x:i*s-r*o,y:i*o+r*s}},t.prototype._findSnapAngles=function(e,i,r){r===void 0&&(r=144);for(var s=this.majorAxisRadius,o=this.minorAxisRadius,a=this.startAngle,c=this.deltaAngle,l=[],h=function(x){var S=Math.cos(x),P=Math.sin(x);return i(s*S,o*P,S,P)},u=a,d=h(u),g=1;g<=r;g++){var f=a+c*g/r,p=h(f);if(Math.abs(d)<1e-10&&l.push(u),d*p<0){for(var m=u,y=f,b=0;b<32;b++){var w=(m+y)/2;h(m)*h(w)<=0?y=w:m=w}l.push((m+y)/2)}u=f,d=p}return l},t})(Kn),gm=(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)}})(),Or=function(){return Or=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},Or.apply(this,arguments)},fm=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.")},Pe=(function(n){gm(t,n);function t(e,i,r,s,o,a,c){a===void 0&&(a=0),c===void 0&&(c=Y);var l=n.call(this)||this;l.center=e,l.normal=i,l.majorAxis=r,l.majorAxisRadius=s,l.minorAxisRadius=o;var h=Math.abs(c-a);return Math.abs(h-Y)<1e-10||Math.abs(h-2*Y)<1e-10?(l.startAngle=0,l.endAngle=Y):(l.startAngle=a,l.endAngle=c),l}return Object.defineProperty(t.prototype,"center",{get:function(){return this._center},set:function(e){this._center=new _(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 Ot.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 Ot.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==Y?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-Y)<1e-10?Y: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 A(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 A(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 A().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-Y)<1e-10)&&(e=0,i=Y);var r=e+i/2;return this.getPointAtAngle(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCircular",{get:function(){return V.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),o=1;o<=e;o++){var a=this.startAngle+o*i,c=this.getPointAtAngle(a),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-Y)>=1e-10?0:Math.PI*this.majorAxisRadius*this.minorAxisRadius},enumerable:!1,configurable:!0}),t.prototype.calculateBoundingBox=function(){var e,i;if(this.majorAxis.equals(A.X_AXIS)||this.majorAxis.equals(A.Y_AXIS)||this.majorAxis.isParallelTo(A.X_AXIS)||this.majorAxis.isParallelTo(A.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 o=1/0,a=1/0,c=1/0,l=-1/0,h=-1/0,u=-1/0;try{for(var d=fm(r),g=d.next();!g.done;g=d.next()){var f=g.value,p=this.getPointAtAngle(f);p.x<o&&(o=p.x),p.y<a&&(a=p.y),p.z<c&&(c=p.z),p.x>l&&(l=p.x),p.y>h&&(h=p.y),p.z>u&&(u=p.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 j({x:o,y:a,z:c},{x:l,y:h,z:u})}else{for(var m=100,o=1/0,a=1/0,c=1/0,l=-1/0,h=-1/0,u=-1/0,s=0;s<=m;s++){var f=this.startAngle+this.deltaAngle*(s/m),p=this.getPointAtAngle(f);o=Math.min(o,p.x),a=Math.min(a,p.y),c=Math.min(c,p.z),l=Math.max(l,p.x),h=Math.max(h,p.y),u=Math.max(u,p.z)}return new j({x:o,y:a,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=Y,s=0);for(var o=0;o<=e;o++){var a=s+r*(o/e),c=this.getPointAtAngle(a);i.push(c)}return i},t.prototype.tessellate=function(e){var i=this,r,s,o=$.resolveTessellateOptions(e),a=this.closed?Y:this.deltaAngle,c=Math.max(this.majorAxisRadius,this.minorAxisRadius),l=Math.abs(a)>=Y-1e-8,h=(r=o.minSegments)!==null&&r!==void 0?r:l?8:3;if(this.isCircular){var u=Pt.segmentCount(c,a,Or(Or({},e),{minSegments:h}));return this.getPoints(u)}var d=(s=o.deviation)!==null&&s!==void 0?s:$.chordDeviationFromRadius(c,o.circleSides),g=this.closed?0:this.startAngle;return un.tessellateParametricCurve(g,g+a,function(f){return i.getPointAtAngle(f)},{deviation:Math.max(W,d),minSegments:h,maxSegments:o.maxSegments})},t.prototype.getPointAtAngle=function(e){var i=Math.cos(e),r=Math.sin(e),s=this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(r),o=this.majorAxis.clone().multiplyScalar(i*this.majorAxisRadius).add(s);return new _(this.center.x+o.x,this.center.y+o.y,this.center.z+o.z)},t.prototype.nearestPoint=function(e,i){i===void 0&&(i=72);for(var r=new _(e.x,e.y,e.z||0),s=this.getPointAtAngle(this.startAngle),o=r.distanceToSquared(s),a=1;a<=i;a++){var c=this.startAngle+this.deltaAngle*a/i,l=this.getPointAtAngle(c),h=r.distanceToSquared(l);h<o&&(o=h,s=l)}var u=r.distanceToSquared(this.startPoint),d=r.distanceToSquared(this.endPoint);return u<o&&u<=d?this.startPoint.clone():d<o&&d<u?this.endPoint.clone():s.clone()},t.prototype.tangentPoints=function(e){var i=this,r=this._projectPointToLocalPlane(e),s=this._findSnapParameterAngles(function(o,a,c,l){var h=-i.majorAxisRadius*l,u=i.minorAxisRadius*c;return(o-r.x)*u-(a-r.y)*h});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype.perpendicularPoints=function(e){var i=this,r=this._projectPointToLocalPlane(e),s=this._findSnapParameterAngles(function(o,a,c,l){var h=i.minorAxisRadius*c,u=i.majorAxisRadius*l;return(o-r.x)*u-(a-r.y)*h});return s.map(function(o){return i.getPointAtAngle(o)})},t.prototype._projectPointToLocalPlane=function(e){var i=new _(e.x,e.y,e.z||0),r=new A(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,o=this.startAngle,a=this.deltaAngle,c=[],l=function(w){var x=Math.cos(w),S=Math.sin(w);return e(r*x,s*S,x,S)},h=o,u=l(h),d=1;d<=i;d++){var g=o+a*d/i,f=l(g);if(Math.abs(u)<1e-10&&c.push(h),u*f<0){for(var p=h,m=g,y=0;y<32;y++){var b=(p+m)/2;l(p)*l(b)<=0?m=b:p=b}c.push((p+m)/2)}h=g,u=f}return c},t.prototype.contains=function(e){var i=new A(e).sub(this.center),r=i.dot(this.majorAxis),s=i.dot(this.minorAxis),o=r/this.majorAxisRadius,a=s/this.minorAxisRadius;return o*o+a*a<=1},t.prototype.transform=function(e){var i=e,r=this.center.clone().applyMatrix4(i),s=this.getPointAtAngle(0).clone().applyMatrix4(i),o=this.getPointAtAngle(Math.PI/2).clone().applyMatrix4(i),a=new A(s).sub(r),c=new A(o).sub(r),l=a.length(),h=c.length(),u=a.clone().normalize(),d=new A().crossVectors(a,c).normalize(),g=new A().crossVectors(d,u).normalize();g.dot(c)<0&&(d.negate(),g=new A().crossVectors(d,u).normalize());var f=function(m){var y=new A(m).sub(r),b=y.dot(u),w=y.dot(g);return C.normalizeAngle(Math.atan2(w/h,b/l))},p=this.closed?new t(r,d,u,l,h,0,Y):new t(r,d,u,l,h,f(this.startPoint.clone().applyMatrix4(i)),f(this.endPoint.clone().applyMatrix4(i)));return this.center=p.center,this.normal=p.normal,this.majorAxis=p.majorAxis,this.majorAxisRadius=p.majorAxisRadius,this.minorAxisRadius=p.minorAxisRadius,this._startAngle=p._startAngle,this._endAngle=p._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 A(this.center).distanceTo(za);return new Ds(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})(un),pm=(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){pm(t,n);function t(e,i){var r=n.call(this)||this;return r._start=new M(e),r._end=new M(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 M(Math.min(this._start.x,this._end.x),Math.min(this._start.y,this._end.y)),i=new M(Math.max(this._start.x,this._end.x),Math.max(this._start.y,this._end.y));return new kt(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 o=((e.x-this._start.x)*i+(e.y-this._start.y)*r)/s;return o=Math.max(0,Math.min(1,o)),new M(this._start.x+o*i,this._start.y+o*r)},t.prototype.nearestPoint=function(e){return this.project(e)},t})(Kn),mm=(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)}})(),Dt=(function(n){mm(t,n);function t(e,i){var r=n.call(this)||this;return r._start=new _(e),r._end=new _(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 A().subVectors(this.endPoint,this.startPoint).normalize()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"midPoint",{get:function(){return new _((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(tn).normalize();return new _(this._start).addScaledVector(r,e)}else{var r=this.delta(tn).normalize();return new _(this._end).addScaledVector(r,e)}},t.prototype.extend=function(e,i){if(i===void 0&&(i=!1),i){var r=tn.subVectors(this._start,this._end).normalize();this._start=new _(this._start).addScaledVector(r,e)}else{var r=this.delta(tn).normalize();this._end=new _(this._end).addScaledVector(r,e)}return this._boundingBoxNeedsUpdate=!0,this},t.prototype.closestPointToPointParameter=function(e,i){vl.subVectors(e,this._start),rr.subVectors(this.endPoint,this.startPoint);var r=rr.dot(rr),s=rr.dot(vl),o=s/r;return i&&(o=C.clamp(o,0,1)),o},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=tn.subVectors(e,this.startPoint),s=r.dot(i);return new _().copy(i).multiplyScalar(s).add(this.startPoint)},t.prototype.perpPoint=function(e){var i=this.direction,r=this.startPoint,s=tn.subVectors(e,r),o=s.dot(i),a=tn.copy(i).multiplyScalar(o);return new _().addVectors(r,a)},t.prototype.calculateBoundingBox=function(){var e=new _(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 _(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 j(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 o=new A(r.x-i.x,r.y-i.y,0).normalize(),a=new A(-o.y,o.x,0);return new t(new _(i.x+a.x*e,i.y+a.y*e,i.z),new _(r.x+a.x*e,r.y+a.y*e,r.z))},t})(un),tn=new A,vl=new A,rr=new A,ym=(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)}})(),mo=(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,o,a){var c=(e-t)/s-(i-t)/(s+o)+(i-e)/o,l=(i-e)/o-(r-e)/(o+a)+(r-i)/a;c*=o,l*=o,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})(),_u=(function(n){ym(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 o=n.call(this)||this;return o.isCatmullRomCurve3d=!0,o.type="CatmullRomCurve3d",o._tmp=new A,o._px=new mo,o._py=new mo,o._pz=new mo,o._points=e.map(function(a){return new _(a)}),o._closed=i,o._curveType=r,o._tension=s,o}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 _},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"endPoint",{get:function(){return this._points.length>0?this._points[this._points.length-1]:new _},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 _);var r=i,s=this._points,o=s.length;if(o===0)return r.set(0,0,0);if(o===1)return r.copy(s[0]);var a=(o-(this._closed?0:1))*e,c=Math.floor(a),l=a-c;this._closed?c+=c>0?0:(Math.floor(Math.abs(c)/o)+1)*o:l===0&&c===o-1&&(c=o-2,l=1);var h,u;this._closed||c>0?h=s[(c-1)%o]:(this._tmp.subVectors(s[0],s[1]).add(s[0]),h=new _(this._tmp.x,this._tmp.y,this._tmp.z));var d=s[c%o],g=s[(c+1)%o];if(this._closed||c+2<o?u=s[(c+2)%o]:(this._tmp.subVectors(s[o-1],s[o-2]).add(s[o-1]),u=new _(this._tmp.x,this._tmp.y,this._tmp.z)),this._curveType==="centripetal"||this._curveType==="chordal"){var f=this._curveType==="chordal"?.5:.25,p=Math.pow(h.distanceToSquared(d),f),m=Math.pow(d.distanceToSquared(g),f),y=Math.pow(g.distanceToSquared(u),f);m<1e-4&&(m=1),p<1e-4&&(p=m),y<1e-4&&(y=m),this._px.initNonuniformCatmullRom(h.x,d.x,g.x,u.x,p,m,y),this._py.initNonuniformCatmullRom(h.y,d.y,g.y,u.y,p,m,y),this._pz.initNonuniformCatmullRom(h.z,d.z,g.z,u.z,p,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 _(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 _;return r.copy(i),r.applyMatrix4(e),r}),this._boundingBoxNeedsUpdate=!0,this},t.prototype.calculateBoundingBox=function(){if(this._points.length===0)return new j;var e=new j;return this._points.forEach(function(i){e.expandByPoint(i)}),e},t})(un),An=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},Pn=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 Al(n,t){var e,i,r=n.x-t[0],s=n.y-t[1],o=((e=n.z)!==null&&e!==void 0?e:0)-((i=t[2])!==null&&i!==void 0?i:0);return r*r+s*s+o*o}var qt=(function(){function n(t,e,i,r){this._degree=t,this._knots=Pn([],An(e),!1),this._controlPoints=i.map(function(s){return{x:s.x,y:s.y,z:s.z}}),this._weights=r?Pn([],An(r),!1):new Array(i.length).fill(1)}return n.prototype.degree=function(){return this._degree},n.prototype.knots=function(){return Pn([],An(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 Pn([],An(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 i0(t,this._degree,this._knots,e,this._weights)},n.prototype.signedPlanarCurvatureAt=function(t){var e=this.evaluate(t);return r0(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(),o=s.start,a=s.end,c=this.length(),l=Math.max(64,Math.ceil(c/Math.max(r*.2,1e-6))),h=bm(o,a,Math.min(l,e)),u=0;u<8&&h.length<e;u++){for(var d=[],g=0;g<h.length-1;g++){var f=h[g],p=h[g+1],m=(f+p)/2,y=Math.max(Math.abs(this.signedPlanarCurvatureAt(f)),Math.abs(this.signedPlanarCurvatureAt(p)),Math.abs(this.signedPlanarCurvatureAt(m)));r*y>.85&&d.push(m)}if(d.length===0)break;if(h=_m(h,d),h.length>e){h=h.slice(0,e);break}}var b=[],w=[];return h.forEach(function(x){var S=i.evaluate(x);b.push(new M(S.point[0],S.point[1]));var P=S.deriv1[0],v=S.deriv1[1],k=Math.hypot(P,v);w.push(k>1e-10?new M(P/k,v/k):new M(1,0))}),{points:b,tangents:w}},n.prototype.length=function(){var t=this._controlPoints.map(function(e){return[e.x,e.y,e.z]});return tu(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 o=Va(t,e,i,r,s),a=o.controlPoints.map(function(c){return{x:c[0],y:c[1],z:c[2]}});return new n(e,o.knots,a,o.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,o=0;o<=t;o++){var a=r+(s-r)*(o/t);e.push(this.point(a))}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),o=this.point(r),a=s[0]-o[0],c=s[1]-o[1],l=s[2]-o[2];return Math.sqrt(a*a+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 _u(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,o=r.end,a=this.point(s),c=Al(t,a),l=0;l<=e;l++){var h=s+(o-s)*l/e,u=this.point(h),d=Al(t,u);d<c&&(c=d,a=u)}return{x:a[0],y:a[1],z:(i=a[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(o){return[o.x,o.y,o.z]});return n.byPoints(s,e,i)},n})();function bm(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 _m(n,t){var e=Pn(Pn([],An(n),!1),An(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 Pl(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,o=(i=n.z)!==null&&i!==void 0?i:0;return r*r+s*s+o*o>1e-20}function xm(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 wm(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 vm(n,t){if(!(!n||n.length!==t))return n}var Am=(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)}})(),Sl=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},kl=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))},El=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.")},Ut=(function(n){Am(t,n);function t(e,i,r,s,o,a){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 Ot.ILLEGAL_PARAMETERS;c._controlPoints=e;var g=void 0,f=3,p=!1;if(l>=3&&(Array.isArray(r)?(g=r,l>=4&&(f=s||3),l>=5&&(p=o)):r!==void 0&&(f=r||3,l>=4&&(p=s))),r===void 0&&l>=4&&(f=s||3,l>=5&&(p=o)),c._degree=f,c._closed=p,c._controlPoints.length<c._degree+1)throw Ot.ILLEGAL_PARAMETERS;c._nurbsCurve=qt.byKnotsControlPointsWeights(c._degree,i,c._controlPoints,g)}else{if(l<2||l>6)throw Ot.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=o),l>=6&&(c._endTangent=a)):(l>=4&&(c._startTangent=s),l>=5&&(c._endTangent=o)),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 Ot.ILLEGAL_PARAMETERS;if(c._closed)c._nurbsCurve=qt.createClosedCurve(c._fitPoints,c._degree,c._knotParameterization);else{var d=c.toNurbsPoints(c._fitPoints);c._nurbsCurve=qt.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=qt.createFitPointsForClosedCurve(this._fitPoints),i=this.toNurbsPoints(e);this._nurbsCurve=qt.byPoints(i,this._degree,this._knotParameterization)}else{var i=this.toNurbsPoints(this._fitPoints);this._nurbsCurve=qt.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(o){return[o.x,o.y,o.z||0]}))}else if(this._controlPoints)if(this._closed){var e=qt.createFitPointsForClosedCurve(this._controlPoints),i=this.toNurbsPoints(e);this._nurbsCurve=qt.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=qt.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(Lt.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(Lt.point2dToPoint3d)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"knots",{get:function(){return kl([],Sl(this._nurbsCurve.knots()),!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"weights",{get:function(){return kl([],Sl(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 _(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 _(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 _(r.x,r.y,r.z||0)},t.prototype.evaluateAt=function(e){var i=this._nurbsCurve.point(e);return new _(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 Lt.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 _(e.x,e.y,(i=e.z)!==null&&i!==void 0?i:0)}):this._controlPoints.map(function(e){var i;return new _(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 o=El(e),a=o.next();!a.done;a=o.next()){var c=a.value;if(!(!Number.isInteger(c)||c<0)){var l=this._fitPoints[c];l&&Lt.applyOffsetToPoint3d(l,i)}}}catch(h){r={error:h}}finally{try{a&&!a.done&&(s=o.return)&&s.call(o)}finally{if(r)throw r.error}}this._boundingBoxNeedsUpdate=!0,this.buildCurve()}},t.prototype.moveControlPointsAt=function(e,i){var r,s;try{for(var o=El(e),a=o.next();!a.done;a=o.next()){var c=a.value;if(!(!Number.isInteger(c)||c<0)){var l=this.getControlPointAt(c);l&&Lt.applyOffsetToPoint3d(l,i)}}}catch(h){r={error:h}}finally{try{a&&!a.done&&(s=o.return)&&s.call(o)}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=qt.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(),o=this._nurbsCurve.degree(),a=s[o],c=s[s.length-o-1],l=(c-a)/(e-1),h=0;h<e;h++){var u=h===e-1?c:a+h*l,d=i.point(u);r.push(new _(d[0],d[1],d[2]))}return r},t.prototype.tessellate=function(e){var i=this,r,s,o=$.resolveTessellateOptions(e),a=this._nurbsCurve.knots(),c=this._nurbsCurve.degree();if(a.length<c+2)return[this.startPoint.clone(),this.endPoint.clone()];var l=a[c],h=a[a.length-c-1],u=o.circleSides,d=Math.abs(this.length),g=(r=o.deviation)!==null&&r!==void 0?r:Math.max(W,d<=W?W:d/(2*u*u));return un.tessellateParametricCurve(l,h,function(f){return i.evaluateAt(f)},{deviation:g,minSegments:(s=o.minSegments)!==null&&s!==void 0?s:this.closed?8:2,maxSegments:o.maxSegments})},t.prototype.getCurvePoints=function(e,i){for(var r=[],s=e.knots(),o=e.degree(),a=s[o],c=s[s.length-o-1],l=(c-a)/(i-1),h=0;h<i;h++){var u=a+h*l;r.push(e.point(u))}return r},t.prototype.calculateBoundingBox=function(){var e=this.getPoints(100);return new j().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 iu(e)},enumerable:!1,configurable:!0}),t.prototype.transform=function(e){if(this._fitPoints&&this._knotParameterization)this._fitPoints=this._fitPoints.map(function(s){return new _(s).applyMatrix4(e)}),this._startTangent&&(this._startTangent=new _(this._startTangent).transformDirection(e)),this._endTangent&&(this._endTangent=new _(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 _(s).applyMatrix4(e)}),this._nurbsCurve=qt.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(Lt.point2dToPoint3d),this._knotParameterization,this._degree,this._closed,this._startTangent?Lt.point2dToPoint3d(this._startTangent):void 0,this._endTangent?Lt.point2dToPoint3d(this._endTangent):void 0):new t(this._controlPoints.map(Lt.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,o){if(e.length<2||i.length<2)return null;var a=xm(s,e.length,i.length);if(e.length<a+1)return null;try{return new t(e,i,vm(r,e.length),a,o)}catch{return null}},t.fromFitPoints=function(e,i,r,s,o,a){if(e.length<2)return null;var c=Pl(o),l=Pl(a),h=(c?1:0)+(l?1:0),u=wm(r,e.length,h);if(e.length+h<u+1)return null;try{return c||l?new t(e,i,u,s,c?o:void 0,l?a: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(Lt.point2dToPoint3d),r=!0,s=e.controlPoints.map(function(a){return a.weight==null&&(r=!1),a.weight||1});return t.fromControlPoints(i,e.knots,r?s:void 0,e.degree,!1)}if(e.numberOfFitData>0){var o=e.fitDatum.map(Lt.point2dToPoint3d);return t.fromFitPoints(o,"Uniform",e.degree,!1,e.startTangent?Lt.point2dToPoint3d(e.startTangent):void 0,e.endTangent?Lt.point2dToPoint3d(e.endTangent):void 0)}return null},t})(un),Pm=(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)}})(),yo=function(n,t){var e=typeof Symbol=="function"&&n[Symbol.iterator];if(!e)return n;var i=e.call(n),r,s=[],o;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(a){o={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(o)throw o.error}}return s},bo=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))},On=(function(n){Pm(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=bo([],yo(e),!1),s=[],o=i*i,a=function(f,p){var m=f.x-p.x,y=f.y-p.y;return m*m+y*y<=o};r.length>0;){var c=[],l=r.shift();c.push(l);var h=t.getEdgeStartPoint(l),u=t.getEdgeEndPoint(l);if(!a(h,u))for(;r.length>0;){var d=t.findConnectingEdge(r,u,o);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),a(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 M(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 kt;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 Ut?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 M(s.x,s.y))})}),i},t.prototype.tessellate=function(e){var i=[];return this._curves.forEach(function(r){Sm(r,e).forEach(function(s){var o=i[i.length-1];o&&Math.pow(o.x-s.x,2)+Math.pow(o.y-s.y,2)<=W*W||i.push(new M(s.x,s.y))})}),i},t.findConnectingEdge=function(e,i,r){for(var s=-1,o=!1,a=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,f=d*d+g*g;f<a&&(a=f,s=c,o=!1);var p=i.x-u.x,m=i.y-u.y,y=p*p+m*m;y<a&&(a=y,s=c,o=!0)}return a>r?{index:-1,reverse:!1}:{index:s,reverse:o}},t.getEdgeStartPoint=function(e){var i=e.startPoint;return new M(i.x,i.y)},t.getEdgeEndPoint=function(e){var i=e.endPoint;return new M(i.x,i.y)},t.reverseEdge=function(e){return e instanceof Vt?new Vt(e.endPoint,e.startPoint):e instanceof $?t.reverseCircArcEdge(e):e instanceof Ie?new Ie(e.center,e.majorAxisRadius,e.minorAxisRadius,e.endAngle,e.startAngle,!e.clockwise,e.rotation):e instanceof Ut?t.reverseSplineEdge(e):e},t.reverseCircArcEdge=function(e){var i=e.startPoint,r=e.endPoint,s=!e.clockwise,o=Math.atan2(r.y-e.center.y,r.x-e.center.x),a=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 $(e.center,e.radius,c(o),c(a),s)},t.reverseSplineEdge=function(e){var i=bo([],yo(e.controlPoints),!1).reverse(),r=e.knots,s=r[0],o=r[r.length-1],a=r.map(function(h){return s+o-h}).reverse(),c=e.weights,l=c.length>0?bo([],yo(c),!1).reverse():void 0;return new Ut(i,a,l,e.degree,e.closed)},t})(Kn);function Sm(n,t){if(n instanceof Vt)return n.getPoints();if(n instanceof $||n instanceof Ut)return n.tessellate(t);var e=n.closed?Y:n.deltaAngle,i=$.segmentCount(Math.max(n.majorAxisRadius,n.minorAxisRadius),e,t);return n.getPoints(i)}var Gt=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.")},_i=128,Rr=96,X=Vi.equalPointTol,Ha=X*8;function km(n,t,e,i,r){var s,o,a,c;e===void 0&&(e=!1),i===void 0&&(i=!1);var l=Il(n,e,r),h=Il(t,i,r),u=[];try{for(var d=Gt(l),g=d.next();!g.done;g=d.next()){var f=g.value;try{for(var p=(a=void 0,Gt(h)),m=p.next();!m.done;m=p.next()){var y=m.value;Wa(f,y)&&Qa(u,vu(f,y))}}catch(b){a={error:b}}finally{try{m&&!m.done&&(c=p.return)&&c.call(p)}finally{if(a)throw a.error}}}}catch(b){s={error:b}}finally{try{g&&!g.done&&(o=d.return)&&o.call(d)}finally{if(s)throw s.error}}return Gm(u)}function Em(n,t){var e=Im(n);switch(e.kind){case"line":return e.line.transform(t),e;case"circArc":return e.arc.transform(t),e;case"ellipseArc":return e.arc.transform(t),e;case"spline":return e.spline.transform(t),e}}function Im(n){switch(n.kind){case"line":return{kind:"line",line:n.line.clone(),extent:n.extent,extendable:n.extendable};case"circArc":return{kind:"circArc",arc:n.arc.clone(),extendable:n.extendable};case"ellipseArc":return{kind:"ellipseArc",arc:n.arc.clone(),extendable:n.extendable};case"spline":return{kind:"spline",spline:n.spline.clone(),extendable:n.extendable}}}function Il(n,t,e){var i,r,s=[];try{for(var o=Gt(n),a=o.next();!a.done;a=o.next()){var c=a.value,l=t&&c.extendable!==!1;switch(c.kind){case"line":{var h=Cm(c.line,e);if(!h)break;var u=l?"unbounded":c.extent;s.push(Zn(h.start,h.end,u));break}case"circArc":{var d=Lm(c.arc,l);if(e&&!xi(d.normal,e.normal)){var g=Rm(d,e);(g==null?void 0:g.kind)==="circArc"?s.push(Tl(g.arc,me(g.arc))):(g==null?void 0:g.kind)==="ellipseArc"?s.push(Ll(g.arc,Ce(g.arc))):_o(s,xu(d,me(d)),me(d),e)}else{var g=Om(d,e);g&&s.push(Tl(g,me(g)))}break}case"ellipseArc":{var d=Mm(c.arc,l);if(e&&!xi(d.normal,e.normal))_o(s,wu(d,Ce(d)),Ce(d),e);else{var g=Nm(d,e);g&&s.push(Ll(g,Ce(g)))}break}case"spline":{e?_o(s,c.spline.getPoints(_i),c.spline.closed,e):s.push(Tm(c.spline));break}}}}catch(f){i={error:f}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function Zn(n,t,e){var i=new A().subVectors(t,n);return{kind:"line",start:n,dir:i,extent:e,box:e==="bounded"?new j().setFromPoints([n,t]):void 0}}function Tl(n,t){return{kind:"circArc",arc:n,full:t||me(n),box:n.box}}function Ll(n,t){return{kind:"ellipseArc",arc:n,full:t||Ce(n),box:n.box}}function Tm(n){var t,e,i=[],r=n.getPoints(_i);if(r.length>=2)for(var s=n.closed?r.length:r.length-1,o=0;o<s;o++){var a=r[o],c=r[(o+1)%r.length];a.distanceToSquared(c)<X*X||i.push(Zn(a.clone(),c.clone(),"bounded"))}var l=new j;try{for(var h=Gt(i),u=h.next();!u.done;u=h.next()){var d=u.value;d.box&&l.union(d.box)}}catch(g){t={error:g}}finally{try{u&&!u.done&&(e=h.return)&&e.call(h)}finally{if(t)throw t.error}}return{kind:"spline",spline:n,samples:i,box:i.length>0?l:void 0}}function Lm(n,t){return!t||me(n)?n:new Pt(n.center,n.radius,0,Y,n.normal,n.refVec)}function Mm(n,t){return!t||Ce(n)?n:new Pe(n.center,n.normal,n.majorAxis,n.majorAxisRadius,n.minorAxisRadius,0,Y)}function Cm(n,t){if(!t)return{start:n.startPoint.clone(),end:n.endPoint.clone()};var e=Me(n.startPoint,t),i=Me(n.endPoint,t);return e.distanceToSquared(i)<X*X?null:{start:e,end:i}}function Om(n,t){if(!t)return n;var e=Me(n.center,t);return new Pt(e,n.radius,n.startAngle,n.endAngle,t.normal.clone(),qa(n.refVec,t.normal))}function Rm(n,t){var e=Me(n.center,t),i=n.normal.clone();if(i.lengthSq()<X*X)return null;i.normalize();var r=t.normal.clone();if(r.lengthSq()<X*X)return null;r.normalize();var s=i.dot(r),o=Math.abs(s);if(o>1-1e-8)return{kind:"circArc",arc:new Pt(e,n.radius,n.startAngle,n.endAngle,r,qa(n.refVec,r))};if(o<1e-8)return null;var a=new A().crossVectors(i,r);if(a.lengthSq()<X*X)return null;a.normalize();var c=new Pe(e,r,a,n.radius,n.radius*o,0,Y);if(me(n))return{kind:"ellipseArc",arc:c};var l=Me(n.startPoint,t),h=Me(n.endPoint,t),u=Me(n.midPoint,t),d=Rn(c,l),g=Rn(c,h),f=Rn(c,u),p=C.normalizeAngle(f-d),m=C.normalizeAngle(g-d),y=p<=m||m<1e-8?d+m:d+m+Y;return{kind:"ellipseArc",arc:new Pe(e,r,a,n.radius,n.radius*o,d,y)}}function Nm(n,t){if(!t)return n;var e=Me(n.center,t),i=qa(n.majorAxis,t.normal);return i.lengthSq()<X*X?null:new Pe(e,t.normal.clone(),i,n.majorAxisRadius,n.minorAxisRadius,n.startAngle,n.endAngle)}function _o(n,t,e,i){if(!(t.length<2))for(var r=i?t.map(function(l){return Me(l,i)}):t,s=e?r.length:r.length-1,o=0;o<s;o++){var a=r[o],c=r[(o+1)%r.length];a.distanceToSquared(c)<X*X||n.push(Zn(a.clone(),c.clone(),"bounded"))}}function xu(n,t){return t||me(n)?new Pt(n.center,n.radius,0,Y,n.normal,n.refVec).getPoints(Rr):n.getPoints(Rr)}function wu(n,t){return t||Ce(n)?new Pe(n.center,n.normal,n.majorAxis,n.majorAxisRadius,n.minorAxisRadius,0,Y).getPoints(Rr):n.getPoints(Rr)}function Wa(n,t){return!n.box||!t.box?!0:n.box.intersectsBox(t.box)}function vu(n,t){return n.kind==="spline"&&t.kind==="spline"?Bm(n,t):n.kind==="spline"?Ml(n,t):t.kind==="spline"?Ml(t,n):n.kind==="line"&&t.kind==="line"?Au(n,t):n.kind==="line"&&t.kind==="circArc"?Nr(n,t.arc,t.full):t.kind==="line"&&n.kind==="circArc"?Nr(t,n.arc,n.full):n.kind==="line"&&t.kind==="ellipseArc"?qo(n,t.arc,t.full):t.kind==="line"&&n.kind==="ellipseArc"?qo(t,n.arc,n.full):n.kind==="circArc"&&t.kind==="circArc"?zm(n.arc,n.full,t.arc,t.full):n.kind==="circArc"&&t.kind==="ellipseArc"?Cl(n.arc,n.full,t.arc,t.full):n.kind==="ellipseArc"&&t.kind==="circArc"?Cl(t.arc,t.full,n.arc,n.full):n.kind==="ellipseArc"&&t.kind==="ellipseArc"?jm(n.arc,n.full,t.arc,t.full):[]}function Ml(n,t){var e,i,r=[];try{for(var s=Gt(n.samples),o=s.next();!o.done;o=s.next()){var a=o.value;Wa(a,t)&&Qa(r,vu(a,t))}}catch(c){e={error:c}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}return Fm(n.spline,r,t)}function Bm(n,t){var e,i,r,s,o,a,c=[];try{for(var l=Gt(n.samples),h=l.next();!h.done;h=l.next()){var u=h.value;try{for(var d=(r=void 0,Gt(t.samples)),g=d.next();!g.done;g=d.next()){var f=g.value;Wa(u,f)&&Qa(c,Au(u,f))}}catch(S){r={error:S}}finally{try{g&&!g.done&&(s=d.return)&&s.call(d)}finally{if(r)throw r.error}}}}catch(S){e={error:S}}finally{try{h&&!h.done&&(i=l.return)&&i.call(l)}finally{if(e)throw e.error}}var p=[];try{for(var m=Gt(c),y=m.next();!y.done;y=m.next()){var b=y.value,w=n.spline.nearestPoint(b,_i),x=t.spline.nearestPoint(b,_i);w.distanceTo(x)<=Ha&&p.push(w)}}catch(S){o={error:S}}finally{try{y&&!y.done&&(a=m.return)&&a.call(m)}finally{if(o)throw o.error}}return p}function Fm(n,t,e){var i,r,s=[];try{for(var o=Gt(t),a=o.next();!a.done;a=o.next()){var c=a.value,l=n.nearestPoint(c,_i);Dm(e,l)<=Ha&&s.push(l)}}catch(h){i={error:h}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return s}function Dm(n,t){if(n.kind==="line"){var e=n.dir.lengthSq();if(e<X*X)return Number.POSITIVE_INFINITY;var i=new A().subVectors(t,n.start).dot(n.dir)/e;return Xn(i,n.extent)?Yn(n.start,n.dir,i).distanceTo(t):Number.POSITIVE_INFINITY}if(n.kind==="circArc"){if(!Za(t,n.arc)){var r=ee(n.arc.normal,n.arc.center),s=Math.abs(r.distanceToPoint(t)),o=Math.abs(t.distanceTo(n.arc.center)-n.arc.radius),a=Math.hypot(s,o);if(a>Ha)return a}return gn(n.arc,dn(n.arc,t),n.full)?0:Number.POSITIVE_INFINITY}return n.kind==="ellipseArc"?zn(t,n.arc,n.full)?0:Math.abs(Xs(n.arc,t)):Number.POSITIVE_INFINITY}function Au(n,t){var e=n.dir,i=t.dir,r=e.lengthSq(),s=i.lengthSq();if(r<X*X||s<X*X)return[];var o=new A().subVectors(n.start,t.start),a=e.dot(e),c=e.dot(i),l=i.dot(i),h=e.dot(o),u=i.dot(o),d=a*l-c*c;if(Math.abs(d)<W*W*a*l)return[];var g=(c*u-l*h)/d,f=(a*u-c*h)/d;if(!Xn(g,n.extent)||!Xn(f,t.extent))return[];var p=Yn(n.start,e,g),m=Yn(t.start,i,f);return p.distanceTo(m)>X?[]:[p]}function Nr(n,t,e){var i=ee(t.normal,t.center),r=Su(n,i);return r==="coplanar"?Xm(n,t,e):r?Za(r,t)?gn(t,dn(t,r),e)?[r]:[]:[]:[]}function Xm(n,t,e){var i,r,s=new A().subVectors(n.start,t.center),o=n.dir.dot(n.dir);if(o<X*X)return[];var a=2*n.dir.dot(s),c=s.dot(s)-t.radius*t.radius,l=[];try{for(var h=Gt(Eu(o,a,c)),u=h.next();!u.done;u=h.next()){var d=u.value;if(Xn(d,n.extent)){var g=Yn(n.start,n.dir,d);gn(t,dn(t,g),e)&&l.push(g)}}}catch(f){i={error:f}}finally{try{u&&!u.done&&(r=h.return)&&r.call(h)}finally{if(i)throw i.error}}return l}function qo(n,t,e){var i=ee(t.normal,t.center),r=Su(n,i);return r==="coplanar"?Ym(n,t,e):r?zn(r,t,e)?[r]:[]:[]}function Ym(n,t,e){var i,r,s=t.majorAxis,o=t.minorAxis,a=t.majorAxisRadius,c=t.minorAxisRadius;if(a<X||c<X)return[];var l=new A().subVectors(n.start,t.center),h=l.dot(s),u=l.dot(o),d=n.dir.dot(s),g=n.dir.dot(o),f=d*d/(a*a)+g*g/(c*c),p=2*h*d/(a*a)+2*u*g/(c*c),m=h*h/(a*a)+u*u/(c*c)-1,y=[];try{for(var b=Gt(Eu(f,p,m)),w=b.next();!w.done;w=b.next()){var x=w.value;if(Xn(x,n.extent)){var S=Yn(n.start,n.dir,x);Ka(t,Rn(t,S),e)&&y.push(S)}}}catch(P){i={error:P}}finally{try{w&&!w.done&&(r=b.return)&&r.call(b)}finally{if(i)throw i.error}}return y}function zm(n,t,e,i){if(xi(n.normal,e.normal)){var r=ee(n.normal,n.center);return Math.abs(r.distanceToPoint(e.center))>X?[]:Um(Vm(n,e),n,t,e,i)}var s=$a(ee(n.normal,n.center),ee(e.normal,e.center));if(!s)return[];var o=Zn(s.point.clone(),new _().addVectors(s.point,s.dir),"unbounded"),a=Nr(o,n,t);return a.filter(function(c){return Za(c,e)?gn(e,dn(e,c),i):!1})}function Vm(n,t){var e=new A().subVectors(t.center,n.center),i=e.length(),r=n.radius,s=t.radius;if(i<X&&V.equal(r,s,X))return[];if(i>r+s+X)return[];if(i+Math.min(r,s)+X<Math.max(r,s))return[];var o=i<X?ku(n.normal):e.clone().normalize(),a=(r*r-s*s+i*i)/(2*Math.max(i,X)),c=r*r-a*a,l=new _().copy(n.center).addScaledVector(o,a);if(c<-X*X)return[];if(c<X*X)return[l];var h=Math.sqrt(Math.max(0,c)),u=new A().crossVectors(n.normal,o).normalize();return[new _().copy(l).addScaledVector(u,h),new _().copy(l).addScaledVector(u,-h)]}function Cl(n,t,e,i){if(!xi(n.normal,e.normal)){var r=$a(ee(n.normal,n.center),ee(e.normal,e.center));if(!r)return[];var s=Zn(r.point.clone(),new _().addVectors(r.point,r.dir),"unbounded");return Nr(s,n,t).filter(function(o){return zn(o,e,i)})}return Pu(xu(n,t),me(n)||t,function(o){return Xs(e,o)},function(o){return gn(n,dn(n,o),t)&&zn(o,e,i)})}function jm(n,t,e,i){if(!xi(n.normal,e.normal)){var r=$a(ee(n.normal,n.center),ee(e.normal,e.center));if(!r)return[];var s=Zn(r.point.clone(),new _().addVectors(r.point,r.dir),"unbounded");return qo(s,n,t).filter(function(o){return zn(o,e,i)})}return Pu(wu(n,t),Ce(n)||t,function(o){return Xs(e,o)},function(o){return Ka(n,Rn(n,o),t)&&zn(o,e,i)})}function Pu(n,t,e,i){for(var r=[],s=t?n.length:n.length-1,o=0;o<s;o++){var a=n[o],c=n[(o+1)%n.length],l=e(a),h=e(c);if(Math.abs(l)<=X){i(a)&&r.push(a.clone());continue}if(!(l*h>0)){for(var u=0,d=1,g=l,f=0;f<40;f++){var p=(u+d)/2,m=new _().lerpVectors(a,c,p),y=e(m);g*y<=0?d=p:(u=p,g=y)}var b=new _().lerpVectors(a,c,(u+d)/2);i(b)&&r.push(b)}}return r}function Su(n,t){var e=t.normal.dot(n.dir),i=t.distanceToPoint(n.start);if(V.equalToZero(e,X*Math.max(1,n.dir.length())))return V.equalToZero(i,X)?"coplanar":null;var r=-i/e;return Xn(r,n.extent)?Yn(n.start,n.dir,r):null}function $a(n,t){var e=new A().crossVectors(n.normal,t.normal);if(e.lengthSq()<X*X)return null;e.normalize();var i=n.normal,r=t.normal,s=i.dot(i)*r.dot(r)-Math.pow(i.dot(r),2);if(Math.abs(s)<W)return null;var o=-n.constant,a=-t.constant,c=(r.dot(r)*o-i.dot(r)*a)/s,l=(i.dot(i)*a-i.dot(r)*o)/s,h=new _().addScaledVector(i,c).addScaledVector(r,l);return{point:h,dir:e}}function Xn(n,t){return t==="unbounded"?!0:t==="ray"?n>=-X:n>=-X&&n<=1+X}function Yn(n,t,e){return new _().copy(n).addScaledVector(t,e)}function Me(n,t){var e=new _;return t.projectPoint(n,e),e}function qa(n,t){var e=n.clone().addScaledVector(t,-n.dot(t));return e.lengthSq()<X*X?ku(t):e.normalize()}function ee(n,t){return new Ds().setFromNormalAndCoplanarPoint(n,t)}function xi(n,t){return new A().crossVectors(n,t).lengthSq()<X*X}function dn(n,t){var e=new A().subVectors(t,n.center),i=new A().crossVectors(n.normal,n.refVec);return Math.atan2(e.dot(i),e.dot(n.refVec))}function Rn(n,t){var e=new A().subVectors(t,n.center),i=e.dot(n.majorAxis)/n.majorAxisRadius,r=e.dot(n.minorAxis)/n.minorAxisRadius;return Math.atan2(r,i)}function me(n){return n.closed||Math.abs(n.deltaAngle-Y)<1e-10}function Ce(n){return n.closed||Math.abs(n.endAngle-n.startAngle)<1e-10||Math.abs(n.deltaAngle-Y)<1e-10}function gn(n,t,e){if(e||me(n))return!0;var i=C.normalizeAngle(t-n.startAngle);return i<=n.deltaAngle+1e-8}function Ka(n,t,e){if(e||Ce(n))return!0;var i=C.normalizeAngle(t-n.startAngle);return i<=n.deltaAngle+1e-8}function Za(n,t){var e=ee(t.normal,t.center);return Math.abs(e.distanceToPoint(n))>X?!1:Math.abs(n.distanceTo(t.center)-t.radius)<=X}function Xs(n,t){var e=new A().subVectors(t,n.center),i=e.dot(n.majorAxis)/n.majorAxisRadius,r=e.dot(n.minorAxis)/n.minorAxisRadius;return i*i+r*r-1}function zn(n,t,e){var i=ee(t.normal,t.center);return Math.abs(i.distanceToPoint(n))>X||Math.abs(Xs(t,n))>1e-4?!1:Ka(t,Rn(t,n),e)}function Um(n,t,e,i,r){return n.filter(function(s){return gn(t,dn(t,s),e)&&gn(i,dn(i,s),r)})}function ku(n){var t=Math.abs(n.x)<.9?A.X_AXIS:A.Y_AXIS,e=new A().crossVectors(n,t);return e.lengthSq()<X*X&&e.crossVectors(n,A.Z_AXIS),e.normalize()}function Eu(n,t,e){if(Math.abs(n)<W)return Math.abs(t)<W?[]:[-e/t];var i=t*t-4*n*e;if(i<-X)return[];if(i<X)return[-t/(2*n)];var r=Math.sqrt(Math.max(0,i));return[(-t-r)/(2*n),(-t+r)/(2*n)]}function Qa(n,t){var e,i;try{for(var r=Gt(t),s=r.next();!s.done;s=r.next()){var o=s.value;n.push(o)}}catch(a){e={error:a}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}}function Gm(n){var t,e,i=[],r=function(c){if(i.some(function(l){return l.distanceTo(c)<=X}))return"continue";i.push(c)};try{for(var s=Gt(n),o=s.next();!o.done;o=s.next()){var a=o.value;r(a)}}catch(c){t={error:c}}finally{try{o&&!o.done&&(e=s.return)&&e.call(s)}finally{if(t)throw t.error}}return i}const Ol=[{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 St{constructor(t){if(typeof t=="string"){const e=Ol.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=Ol.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 St.capabilitiesFor(this.value)}static get latest(){return new St("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 Ui(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 Iu(n){return n>=90&&n<=99||n>=420&&n<=429||n>=440&&n<=449||n>=450&&n<=459||n===1071}var Ja=(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))(Ja||{});const Hm=["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"],Tu=n=>Hm[n],xo=(()=>{const n=`AutoCAD Binary DXF\r
2
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})(),Rl=(()=>{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 Lu(n){if(n.length<xo.length)return!1;for(let t=0;t<xo.length;t++)if(n[t]!==xo[t])return!1;return!0}function Mu(n){var c,l,h;const e=new TextDecoder("utf-8");let i=0,r="",s=null,o=null,a=!1;for(;i<n.byteLength;){const u=Math.min(i+65536,n.byteLength),d=n.slice(i,u);i=u;const f=(r+e.decode(d,{stream:!0})).split(/\r?\n/);r=f.pop()??"";for(let p=0;p<f.length;p++){const m=f[p].trim();if(m==="SECTION"&&((c=f[p+2])==null?void 0:c.trim())==="HEADER")a=!0;else if(m==="ENDSEC"&&a)return{version:s,encoding:o};if(a&&m==="$ACADVER"){const y=(l=f[p+2])==null?void 0:l.trim();y&&(s=new St(y))}else if(a&&m==="$DWGCODEPAGE"){const y=(h=f[p+2])==null?void 0:h.trim();if(y){const b=Ja[y];o=Tu(b)}}if(s&&o)return{version:s,encoding:o}}}return{version:s,encoding:o}}function Wm(n){const t=n.trim(),e=t.length>>>1,i=new Uint8Array(e);for(let r=0;r<e;r++){const s=Rl[t.charCodeAt(r*2)&127],o=Rl[t.charCodeAt(r*2+1)&127];i[r]=s<<4|o}return i}function Cu(n,t){const e=Ui(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:Wm(t)};default:return null}}function tc(n){let t=0,e=1,i,r=!1;function s(){if(t>=n.length)return;let a=t;for(;a<n.length;){const l=n.charCodeAt(a);if(l===10||l===13)break;a++}const c=n.slice(t,a);return a<n.length&&n.charCodeAt(a)===13&&a++,a<n.length&&n.charCodeAt(a)===10&&a++,t=a,e++,c}function o(){for(;;){const a=s();if(a===void 0)return;const c=a.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=Cu(h,l);if(u)return u}}return{kind:"ascii",next(){if(r){const a=i;return i=void 0,r=!1,a}return o()},peek(){return r||(i=o(),r=!0),i},position(){return{line:e,byteOffset:t}}}}function $m(n){const t=n.toLowerCase().replace(/_/g,"-");return t==="utf-8"||t==="utf8"||t==="unicode-1-1-utf-8"}const qm=64*1024;function Ou(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 o=t,a=t,c="",l=0;function h(){if(a>=n.length)return!1;o=a;let g=Math.min(o+qm,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++,a=g,c=s.decode(n.subarray(o,a)),l=0,!0}function u(){for(;l>=c.length;)if(!h())return;let g=l;for(;g<c.length;){const p=c.charCodeAt(g);if(p===10||p===13)break;g++}const f=c.slice(l,g);return g<c.length&&c.charCodeAt(g)===13&&g++,g<c.length&&c.charCodeAt(g)===10&&g++,l=g,e++,f}function d(){for(;;){const g=u();if(g===void 0)return;const f=g.trim();if(f==="")continue;const p=u();if(p===void 0)return;const m=Number(f);if(!Number.isFinite(m)||m===999)continue;const y=Cu(m,p);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=a-o,f=g>0&&c.length>0?o+Math.round(l/c.length*g):a;return{line:e,byteOffset:f}}}}function Km(n){const t=BigInt(Number.MAX_SAFE_INTEGER),e=-t;return n>=e&&n<=t?Number(n):n}function Ru(n,t={}){const e=t.encoding??"utf-8",i=t.legacyR12??!1,r=22,s=new DataView(n.buffer,n.byteOffset,n.byteLength);let o=n.length>=r?r:n.length,a,c=!1;function l(){if(o>=n.length)return;if(i){const w=n[o];if(w===void 0)return;if(w===255){if(o+3>n.length)return;o+=1;const x=n[o],S=n[o+1];return o+=2,S<<8|x}return o+=1,w}if(o+2>n.length)return;const b=s.getUint16(o,!0);return o+=2,b}function h(){const b=o;for(;o<n.length&&n[o]!==0;)o+=1;if(o>=n.length)return;const w=n.subarray(b,o);return o+=1,new TextDecoder(e).decode(w)}function u(){if(o+2>n.length)return;const b=s.getInt16(o,!0);return o+=2,b}function d(){if(o+4>n.length)return;const b=s.getInt32(o,!0);return o+=4,b}function g(){if(o+8>n.length)return;const b=s.getBigInt64(o,!0);return o+=8,Km(b)}function f(){if(o+8>n.length)return;const b=s.getFloat64(o,!0);return o+=8,b}function p(){if(o>=n.length)return;const b=n[o];if(b!==void 0)return o+=1,b!==0}function m(){if(o>=n.length)return;const b=n[o];if(b===void 0||(o+=1,o+b>n.length))return;const w=n.slice(o,o+b);return o+=b,w}function y(){for(;o<n.length;){const b=l();if(b===void 0)return;if(b===999){if(h()===void 0)return;continue}switch(Ui(b)){case"string":{const x=h();return x===void 0?void 0:{code:b,type:"string",value:x}}case"int":{const x=Iu(b)?d():u();return x===void 0?void 0:{code:b,type:"int",value:x}}case"long":{const x=g();return x===void 0?void 0:{code:b,type:"long",value:x}}case"double":{const x=f();return x===void 0?void 0:{code:b,type:"double",value:x}}case"bool":{const x=p();return x===void 0?void 0:{code:b,type:"bool",value:x}}case"handle":{const x=h();return x===void 0?void 0:{code:b,type:"handle",value:x}}case"binary":{const x=m();return x===void 0?void 0:{code:b,type:"binary",value:x}}case"comment":continue;default:h();continue}}}return{kind:"binary",next(){if(c){const b=a;return a=void 0,c=!1,b}return y()},peek(){return c||(a=y(),c=!0),a},position(){return{byteOffset:o}}}}function Nu(n,t={}){const e=n instanceof Uint8Array?n:new Uint8Array(n);if(Lu(e)){let o=t.encoding,a=t.legacyR12;if((o==null||a==null)&&(o=o??"utf-8",a==null)){const l=e[22],h=e[23],u=e[24];l===0&&h===83?a=!0:a=!1}return Ru(e,{encoding:o,legacyR12:a})}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 o=Mu(i);o.version&&!o.version.capabilities.supportsUtf8CodePage&&o.encoding?r=o.encoding:r="utf-8"}if($m(r))return Ou(e);const s=new TextDecoder(r).decode(e);return tc(s)}const si=250,Bu=255,Fu=127;function Du(n){const t=n??"";if(t.length<=si)return[{code:1,value:t}];const e=[];let i=0;for(;t.length-i>si;)e.push({code:3,value:t.slice(i,i+si)}),i+=si;return e.push({code:1,value:t.slice(i)}),e}function Xu(n,t){if(t<=0)return[n??""];const e=n??"";if(e.length===0)return[""];const i=new TextEncoder,r=[];let s="",o=0;for(const a of e){const c=i.encode(a).byteLength;if(c>t){s.length>0&&(r.push(s),s="",o=0),r.push(a);continue}o+c>t&&s.length>0?(r.push(s),s=a,o=c):(s+=a,o+=c)}return s.length>0&&r.push(s),r}function Yu(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 zu=(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))(zu||{});const Zm=(()=>{const n=`AutoCAD Binary DXF\r
3
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 We{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 St?t.version:t.version!=null?new St(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(Zm)}static forReading(t,e={}){return new We({...e,reader:t})}static fromBuffer(t,e={}){return We.forReading(Nu(t),e)}static fromString(t,e={}){return We.forReading(tc(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 St?t:new St(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
  `)+`
@@ -6,12 +6,12 @@
6
6
  `)}function Fl(n,t,e){if(t===1){n.push(e);return}if(n.length===0){n.push(e);return}n[n.length-1]+=e}const vy=["ACIS BinaryFile","ASM BinaryFile4"],Ad=new Set(["End-of-ACIS-data","End-of-ASM-data","End-of-ACIS-History-data"]),H={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 Ay{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=Py.decode(this.data.subarray(this.index,this.index+t));return this.index+=t,e}}const Py=new TextDecoder("latin1");function Sy(n,t){let e="";for(const g of vy)if(Iy(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(),o=n.readInt(),a=wo(n),c=wo(n),l=wo(n),h=vo(n),u=vo(n),d=vo(n);return{signature:e,version:i,numRecords:r,numEntities:s,flags:o,productId:a,acisVersion:c,creationDate:l,unitsInMm:h,resTol:u,norTol:d}}function wo(n){if(n.readByte()!==H.Str)throw new RangeError("SAB: expected string tag (0x07)");return n.readStr(n.readByte())}function vo(n){if(n.readByte()!==H.Double)throw new RangeError("SAB: expected double tag (0x06)");return n.readFloat()}function ky(n){const t=[],e=[];let i="",r=0;for(;;){if(!n.hasData){if(Ad.has(i))return{type:i,tokens:t};throw new RangeError("SAB: premature end of data")}const s=n.readByte();switch(s){case H.Int:t.push({tag:s,value:n.readInt()});break;case H.Double:t.push({tag:s,value:n.readFloat()});break;case H.Str:t.push({tag:s,value:n.readStr(n.readByte())});break;case H.Pointer:t.push({tag:s,value:n.readInt()});break;case H.BoolTrue:t.push({tag:s,value:!0});break;case H.BoolFalse:t.push({tag:s,value:!1});break;case H.LiteralStr:t.push({tag:s,value:n.readStr(n.readInt())});break;case H.EntityTypeEx:e.push(n.readStr(n.readByte()));break;case H.EntityType:{e.push(n.readStr(n.readByte()));const o=e.join("-");e.length=0,i===""&&(i=o),t.push({tag:s,value:o});break}case H.LocationVec:t.push({tag:s,value:Dl(n)});break;case H.DirectionVec:t.push({tag:s,value:Dl(n)});break;case H.Enum:t.push({tag:s,value:n.readInt()});break;case H.Unknown0x17:t.push({tag:s,value:n.readFloat()});break;case H.SubtypeStart:r++,t.push({tag:s,value:r});break;case H.SubtypeEnd:t.push({tag:s,value:r}),r--;break;case H.RecordEnd:return{type:i,tokens:t};default:throw new RangeError(`SAB: unknown tag 0x${s.toString(16)} (${String(s)}) in record '${i}'`)}}}function Dl(n){return[n.readFloat(),n.readFloat(),n.readFloat()]}function Ey(n){const t=new Ay(n),e=Sy(t,n),i=[];for(;t.hasData;){const r=ky(t);if(i.push(r),Ad.has(r.type))break}return{header:e,records:i}}function Iy(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 Ty=new Set(["End-of-ACIS-data","End-of-ASM-data","End-of-ACIS-History-data"]);function Ly(n){const e=n.records.map((o,a)=>({index:a,type:o.type,record:o,refs:[]}));for(const o of e)for(const a of o.record.tokens){if(a.tag!==H.Pointer)continue;const c=a.value;o.refs.push(c>=0&&c<e.length?e[c]:null)}const i=e,r=new Map,s=new Map;for(const o of i){if(Ty.has(o.type))continue;let a=r.get(o.type);a===void 0&&(a=[],r.set(o.type,a)),a.push(o),s.set(o.type,(s.get(o.type)??0)+1)}return{header:n.header,nodes:i,bodies:r.get("body")??[],typeCounts:s,nodesOfType:o=>r.get(o)??[],pointLocations(){const o=[];for(const a of r.get("point")??[]){const c=a.record.tokens.find(l=>l.tag===H.LocationVec);c!==void 0&&o.push(c.value)}return o}}}const My=["ACIS BinaryFile","ASM BinaryFile","ASM BinaryFile4"];function Cy(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 Oy(n){for(const t of My){const e=Cy(n,t);if(e>=0)return e}return-1}function Ry(n){if(n.length===0)return null;const t=Oy(n);if(t<0)return null;try{return Ly(Ey(n.subarray(t)))}catch{return null}}const zr={xAxis:[1,0,0],yAxis:[0,1,0],zAxis:[0,0,1],translation:[0,0,0],scale:1},Ny=1e-12,By=new Set([H.LocationVec,H.DirectionVec]),Pr=(n,t)=>Math.abs(n-t)<=Ny,or=(n,t)=>Pr(n[0],t[0])&&Pr(n[1],t[1])&&Pr(n[2],t[2]);function nc(){return zr}function Pd(n,t){return Pr(n.scale,t.scale)&&or(n.xAxis,t.xAxis)&&or(n.yAxis,t.yAxis)&&or(n.zAxis,t.zAxis)&&or(n.translation,t.translation)}function Fy(n){const t=[];let e;for(const i of n.record.tokens){if(By.has(i.tag)){t.push(i.value);continue}i.tag===H.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 Dy(n){const t=n.refs.find(e=>(e==null?void 0:e.type)==="transform");return t==null?zr:Fy(t)??zr}function hi(n){return Pd(n,zr)}function be(n,t){const e=t.scale,[i,r,s]=n,{xAxis:o,yAxis:a,zAxis:c,translation:l}=t;return[e*(o[0]*i+a[0]*r+c[0]*s)+l[0],e*(o[1]*i+a[1]*r+c[1]*s)+l[1],e*(o[2]*i+a[2]*r+c[2]*s)+l[2]]}function de(n,t){const e=t.scale,[i,r,s]=n,{xAxis:o,yAxis:a,zAxis:c}=t;return[e*(o[0]*i+a[0]*r+c[0]*s),e*(o[1]*i+a[1]*r+c[1]*s),e*(o[2]*i+a[2]*r+c[2]*s)]}function Sd(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 o of i.refs)e(o,r,s)}};for(const i of n.bodies)e(i,Dy(i),new Set);return t}function Xy(n,t){if(hi(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,o]=be([n[i],n[i+1],n[i+2]],t);e[i]=r,e[i+1]=s,e[i+2]=o}return e}class kd{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(H.LocationVec,H.DirectionVec))==null?void 0:t.value}nextDouble(){var t;return(t=this.next(H.Double))==null?void 0:t.value}}const Sn=(n,t)=>n.refs.find(e=>e!==null&&(e.type===t||e.type.endsWith(t)))??null,Ed=(n,t)=>n.refs.filter(e=>e!==null&&e.type===t);function Ao(n){if(n===null)return null;const t=Sn(n,"point");if(t===null)return null;const e=t.record.tokens.find(i=>i.tag===H.LocationVec);return e?e.value:null}function Yy(n){const t=new kd(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:zy(n.record.tokens)};return{kind:"unknown"}}function zy(n){var o,a,c;const t=n.findIndex(l=>l.tag===H.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===H.Double)break;if(l.tag===H.Int&&(i=l.value),l.tag===H.EntityType||l.tag===H.SubtypeEnd)return[]}if(i<0)return[];for(let l=0;l<i;l++){if(((o=n[e])==null?void 0:o.tag)!==H.Double)return[];e+=1,((a=n[e])==null?void 0:a.tag)===H.Int&&(e+=1)}const r=[];for(;((c=n[e])==null?void 0:c.tag)===H.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 Id(n){const t=new kd(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(),o=t.nextDouble(),a=t.nextDouble();if(e&&i&&r&&s!==void 0&&o!==void 0&&a!==void 0)return{kind:"cone",origin:e,axis:i,majorAxis:r,ratio:s,sineAngle:o,cosineAngle:a}}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 Vy(n){return Id(n)}const jy={"plane-surface":"plane","cone-surface":"cone","torus-surface":"torus","sphere-surface":"sphere","spline-surface":"spline"},Uy={"straight-curve":"straight","ellipse-curve":"ellipse","intcurve-curve":"intcurve"};function Gy(n){const t=Sn(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=Ed(i,"coedge")[0]??null;return e.size}function Hy(n,t){return n.kind==="straight"?{kind:"straight",origin:be(n.origin,t),direction:de(n.direction,t)}:n.kind==="ellipse"?{kind:"ellipse",center:be(n.center,t),normal:de(n.normal,t),majorAxis:de(n.majorAxis,t),ratio:n.ratio}:n.kind==="intcurve"?{kind:"intcurve",controlPoints:n.controlPoints.map(e=>be(e,t))}:n}function Wy(n,t){return n.kind==="plane"?{kind:"plane",origin:be(n.origin,t),normal:de(n.normal,t),...n.uDir?{uDir:de(n.uDir,t)}:{}}:n.kind==="cone"?{kind:"cone",origin:be(n.origin,t),axis:de(n.axis,t),majorAxis:de(n.majorAxis,t),ratio:n.ratio,sineAngle:n.sineAngle,cosineAngle:n.cosineAngle}:n.kind==="torus"?{kind:"torus",center:be(n.center,t),axis:de(n.axis,t),majorRadius:n.majorRadius*t.scale,minorRadius:n.minorRadius*t.scale}:n.kind==="sphere"?{kind:"sphere",center:be(n.center,t),radius:n.radius*t.scale,uDir:de(n.uDir,t),poleAxis:de(n.poleAxis,t)}:n}function $y(n){const t=[],e=Sd(n),i=nc(),r=y=>e.get(y)??i,s=(y,b)=>{if(y===null)return null;const w=r(b);return hi(w)?y:be(y,w)};let o=1/0,a=1/0,c=1/0,l=-1/0,h=-1/0,u=-1/0;const d=y=>{y[0]<o&&(o=y[0]),y[0]>l&&(l=y[0]),y[1]<a&&(a=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 b=s(Ao(y),y.index);return b===null?t.push(`vertex#${String(y.index)}: no resolvable point`):d(b),{nodeIndex:y.index,point:b}}),f=n.nodesOfType("edge").map(y=>{const b=Ed(y,"vertex"),w=s(Ao(b[0]??null),y.index),x=s(Ao(b[1]??null),y.index),S=Sn(y,"-curve"),P=S?Uy[S.type]??"unknown":"unknown";let v=S?Yy(S):void 0;const k=r(y.index);return v!==void 0&&v.kind!=="unknown"&&!hi(k)&&(v=Hy(v,k)),w!==null&&x!==null&&w[0]===x[0]&&w[1]===x[1]&&w[2]===x[2]&&t.push(`edge#${String(y.index)}: degenerate (coincident endpoints)`),v===void 0||v.kind==="unknown"?{nodeIndex:y.index,start:w,end:x,curveType:P}:{nodeIndex:y.index,start:w,end:x,curveType:P,curve:v}}),p=n.nodesOfType("face").map(y=>{const b=Sn(y,"-surface"),w=b?jy[b.type]??"unknown":"unknown";let x=b?Id(b):void 0;const S=r(y.index);x!==void 0&&x.kind!=="unknown"&&!hi(S)&&(x=Wy(x,S));const P=[],v=new Set;let k=Sn(y,"loop");for(;k!==null&&!v.has(k.index);)v.add(k.index),P.push({nodeIndex:k.index,coedgeCount:Gy(k)}),k=Sn(k,"loop");return b===null&&t.push(`face#${String(y.index)}: no surface`),x===void 0||x.kind==="unknown"?{nodeIndex:y.index,surfaceType:w,loops:P}:{nodeIndex:y.index,surfaceType:w,surface:x,loops:P}});return{vertices:g,edges:f,faces:p,bbox:o===1/0?null:{min:[o,a,c],max:[l,h,u]},diagnostics:t}}const sn=(n,t)=>[n[0]+t[0],n[1]+t[1],n[2]+t[2]],je=(n,t)=>[n[0]*t,n[1]*t,n[2]*t],qy=n=>Math.hypot(n[0],n[1],n[2]),Sr=(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]],wn=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 Ky(n){const t=[];for(const r of n.record.tokens)if(r.tag===H.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 Td(n,t,e,i){const r=je(Sr(wn(n.normal),n.majorAxis),n.ratio),s=Math.max(1,i),o=[];for(let a=0;a<=s;a++){const c=t+(e-t)*a/s;o.push(sn(n.center,sn(je(n.majorAxis,Math.cos(c)),je(r,Math.sin(c)))))}return o}function Zy(n,t=16){const e=wn(n.poleAxis);let i=wn(n.uDir),r=Sr(e,i);qy(r)<1e-9?(i=Math.abs(e[0])<.9?[1,0,0]:[0,1,0],r=wn(Sr(e,i))):r=wn(r),i=wn(Sr(r,e));const s=[],o=(a,c)=>{const l=[],h=Math.max(8,t);for(let u=0;u<=h;u++){const d=Math.PI*2*u/h;l.push(sn(n.center,sn(je(a,n.radius*Math.cos(d)),je(c,n.radius*Math.sin(d)))))}s.push(l)};o(i,r),o(i,e),o(r,e);for(const a of[-.5,.5]){const c=je(e,n.radius*a),l=sn(n.center,c),h=n.radius*Math.sqrt(Math.max(0,1-a*a));if(h>1e-6){const u=[],d=Math.max(8,t);for(let g=0;g<=d;g++){const f=Math.PI*2*g/d;u.push(sn(l,sn(je(i,h*Math.cos(f)),je(r,h*Math.sin(f)))))}s.push(u)}}return s}const Qy=16,Jy=(n,t)=>n.refs.find(e=>e!==null&&(e.type===t||e.type.endsWith(t)))??null;function Ld(n,t,e){n.push(t[0],t[1],t[2],e[0],e[1],e[2])}function Vr(n,t){for(let e=0;e+1<t.length;e++){const i=t[e],r=t[e+1];i&&r&&Ld(n,i,r)}}function tb(n){const t=[],e=Sd(n),i=nc();for(const r of n.nodesOfType("face")){const s=Jy(r,"-surface");if((s==null?void 0:s.type)!=="sphere-surface")continue;const o=Vy(s);if(o.kind!=="sphere")continue;const a=e.get(r.index)??i;for(const c of Zy(o)){if(hi(a)){Vr(t,c);continue}Vr(t,c.map(l=>be(l,a)))}}return new Float32Array(t)}function eb(n,t){var i,r;const e=[];for(const s of n.edges){const o=t==null?void 0:t.nodes[s.nodeIndex];if(((i=s.curve)==null?void 0:i.kind)==="ellipse"){const a=o!==void 0?Ky(o):null,c=(a==null?void 0:a[0])??0,l=(a==null?void 0:a[1])??Math.PI*2;Vr(e,Td(s.curve,c,l,Qy));continue}if(((r=s.curve)==null?void 0:r.kind)==="intcurve"&&s.curve.controlPoints.length>0){Vr(e,s.curve.controlPoints);continue}s.start&&s.end&&Ld(e,s.start,s.end)}return new Float32Array(e)}function nb(n){const t=Ry(n);if(t===null)return null;const e=$y(t),i=eb(e,t);if(i.length>0)return i;const r=tb(t);return r.length>0?r:null}const ib=16;function ic(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 o=Number.parseFloat(s);Number.isFinite(o)&&i.push(o)}return i}function Xl(n,t,e){n.push(t[0],t[1],t[2],e[0],e[1],e[2])}function Md(n){return n.split("#").map(t=>t.trim()).filter(t=>t.length>0)}function rb(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 Yl(n){if(!/(?:^|\s)transform\b/.test(n))return null;const t=ic(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 sb(n){const t=nc(),e=rb(Md(n)),i=[];for(const s of e){if(s==null||!/(?:^|\s)body\b/.test(s))continue;const o=[...s.matchAll(/\$(-?\d+)/g)].map(a=>Number(a[1]));for(const a of o){if(a<0)continue;const c=e[a];if(c==null)continue;const l=Yl(c);if(l!=null){i.push(l);break}}}if(i.length===0){const s=[];for(const o of e){if(o==null)continue;const a=Yl(o);a!=null&&s.push(a)}return s.length===1?s[0]:t}const r=i[0];for(let s=1;s<i.length;s++)if(!Pd(i[s],r))return t;return r}function ob(n){if(!n.includes("straight-curve"))return null;const t=ic(n);if(t.length<6)return null;const e=t[0],i=t[1],r=t[2],s=t[3],o=t[4],a=t[5];return[[e,i,r],[e+s,i+o,r+a]]}function ab(n){if(!n.includes("ellipse-curve"))return null;const t=ic(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 cb(n){const t=[];if(!n||n.trim().length===0)return new Float32Array(0);for(const e of Md(n)){const i=ob(e);if(i!==null){Xl(t,i[0],i[1]);continue}const r=ab(e);if(r!==null){const s=Td(r,0,Math.PI*2,ib);for(let o=1;o<s.length;o++)Xl(t,s[o-1],s[o])}}return t.length===0?new Float32Array(0):Xy(new Float32Array(t),sb(n))}const lb=/\bpoint\s+(?:\$-?\d+\s+){1,4}([-\d.eE+]+)\s+([-\d.eE+]+)\s+([-\d.eE+]+)/g;function hb(n){return n.split("#").map(t=>t.trim()).filter(t=>t.length>0)}function ub(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 o=Number.parseFloat(s);Number.isFinite(o)&&i.push(o)}return i}function db(n){const t=[];for(const e of n.matchAll(lb)){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 _(i,r,s))}if(t.length>0)return t;for(const e of hb(n)){if(!e.startsWith("point "))continue;const i=ub(e);if(i.length>=3){const r=i[i.length-3],s=i[i.length-2],o=i[i.length-1];t.push(new _(r,s,o))}}return t}function gb(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 _(i,r,s))}return t}function fb(n,t){return typeof n=="string"?{satText:n,version:t}:{sabBytes:n.sabBytes,satText:n.satText??n.acisData??"",version:n.version??t}}const Pc=class Pc extends tt{constructor(t,e){super(),this._points=[],this._wireframe=new Float32Array(0);const i=fb(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=nb(this._sabBytes)??new Float32Array(0)),t.length===0&&this._acisData&&(t=cb(this._acisData)),this._wireframe=t,this._points=t.length>0?gb(t):db(this._acisData)}get hasRenderableGeometry(){return this._wireframe.length>0||this._points.length>0}get geometricExtents(){return this._points.length===0?new j(new _(0,0,0),new _(0,0,0)):new j().setFromPoints(this._points)}subGetIntersectCurves(){const t=[];for(let e=0;e+5<this._wireframe.length;e+=6)t.push({kind:"line",line:new Dt({x:this._wireframe[e],y:this._wireframe[e+1],z:this._wireframe[e+2]},{x:this._wireframe[e+3],y:this._wireframe[e+4],z:this._wireframe[e+5]}),extent:"bounded",extendable:!1});return t}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 _(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 _(i.x,i.y,i.z),new _(r.x,i.y,i.z),new _(r.x,r.y,i.z),new _(i.x,r.y,i.z),new _(i.x,i.y,r.z),new _(r.x,i.y,r.z),new _(r.x,r.y,r.z),new _(i.x,r.y,r.z)],o=new Float32Array(s.length*3);s.forEach((c,l)=>{o[l*3]=c.x,o[l*3+1]=c.y,o[l*3+2]=c.z});const a=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(o,3,a)}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
7
  `);for(let r=0;r<i.length;r++){const s=r===i.length-1;let o=i[r];for(;o.length>e;)t.writeString(3,o.slice(0,e)),o=o.slice(e);t.writeString(s?1:3,o)}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 o=Number(r.value);switch(s){case 1:Fl(e,1,String(r.value));break;case 3:Fl(e,3,String(r.value));break;case 70:i=o;break;case 350:this._historyObjectSoftId=String(r.value);break;case 2:this._guid=String(r.value);break;case 290:this._satCache=o!==0;break}}return this.setAcisData(wy(e),i),this}};Pc.typeName="3dSolid";let Ai=Pc;var I=(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.Intersection=6]="Intersection",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))(I||{});function pb(n){let t=0;for(const e of n)t|=1<<e-1;return t}function mb(n){const t=[];for(const e of Object.values(I)){if(typeof e!="number")continue;const i=1<<e-1;(n&i)!==0&&t.push(e)}return t}function yb(n,t){return n^1<<t-1}function bb(n,t){return(n&1<<t-1)!==0}const Sc=class Sc extends tt{getOffsetSideAtPoint(t){return 1}};Sc.typeName="Curve";let It=Sc;function bt(n,t){for(const e of n)Number.isInteger(e)&&e>=0&&t(e)}function Se(n,t,e){bt(n,i=>{i===0&&e.add(t)})}function ui(n,t,e){const i=n[t];i&&(i.x+=e.x,i.y+=e.y)}function Qn(n,t,e){bt(n,i=>{const r=e[i];r&&r.add(t)})}function zl(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 ie(n,t){if(t.length===0)return;let e=new _(t[0].x,t[0].y,t[0].z||0),i=zl(n,e);for(let r=1;r<t.length;r++){const s=t[r],o=new _(s.x,s.y,s.z||0),a=zl(n,o);a<i&&(e=o,i=a)}return e}function Jn(n,t,e,i,r){const s=new _(n.x,n.y,n.z||0),o=new _(t.x,t.y,t.z||0),a=new Dt(s,o);switch(e){case I.EndPoint:r.push(s,o);break;case I.MidPoint:r.push(a.midPoint);break;case I.Nearest:r.push(a.nearestPoint(i));break;case I.Perpendicular:r.push(a.perpPoint(i));break}}function Pi(n,t,e,i,r,s,o){if(e){const a=new $(n,t,e);switch(r){case I.EndPoint:o.push(new _(a.startPoint.x,a.startPoint.y,i),new _(a.endPoint.x,a.endPoint.y,i));break;case I.MidPoint:o.push(new _(a.midPoint.x,a.midPoint.y,i));break;case I.Nearest:{const c=a.nearestPoint({x:s.x,y:s.y});o.push(new _(c.x,c.y,i));break}case I.Perpendicular:{a.perpendicularPoints({x:s.x,y:s.y}).forEach(l=>o.push(new _(l.x,l.y,i)));break}case I.Tangent:{a.tangentPoints({x:s.x,y:s.y}).forEach(l=>o.push(new _(l.x,l.y,i)));break}}return}Jn(new _(n.x,n.y,i),new _(t.x,t.y,i),r,s,o)}function Ks(n,t,e,i,r){if(n.length!==0)switch(e){case I.EndPoint:n.forEach(s=>r.push(new _(s.x,s.y,s.z||0)));break;case I.MidPoint:case I.Nearest:case I.Perpendicular:{const s=n.length,o=[];for(let a=0;a<s;a++){const c=[];Jn(n[a],n[(a+1)%n.length],e,i,c),o.push(...c)}if(e===I.MidPoint)r.push(...o);else{const a=ie(i,o);a&&r.push(a)}break}}}const Is=class Is extends It{constructor(t,e,i,r,s=A.Z_AXIS){super(),this._thickness=0;const o=Qe(s);this._geo=new Pt(t,e,i,r,s,o)}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.setNormalAndRefVec(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}subGetIntersectCurves(){return[{kind:"circArc",arc:this._geo.clone(),extendable:!this.closed}]}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 bt(t,i=>{this.moveGripAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){const s=this.startPoint,o=this.endPoint;switch(t){case I.EndPoint:r.push(s),r.push(o);break;case I.MidPoint:r.push(this.midPoint);break;case I.Center:case I.Centroid:r.push(this._geo.center);break;case I.Quadrant:{const a=[0,Math.PI/2,Math.PI,3*Math.PI/2];for(const c of a)C.isBetweenAngle(c,this.startAngle,this.endAngle)&&r.push(this._geo.getPointAtAngle(c));break}case I.Nearest:{const a=this._geo.nearestPoint(e);r.push(a)}break;case I.Perpendicular:{const a=this._geo.perpendicularPoints(e),c=ie(e,a);c&&r.push(c);break}case I.Tangent:{const a=this._geo.tangentPoints(e);r.push(...a);break}}}transformBy(t){return this._geo.transform(t),this}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){return t.circularArc(this._geo)}dxfOutFields(t){super.dxfOutFields(t);const e=jt(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,Le(this.center,this.startPoint,this.normal)),t.writeAngle(51,Le(this.center,this.endPoint,this.normal)),this}dxfInFields(t){var d;super.dxfInFields(t);let e=0,i=0,r=0,s=this.radius,o=C.radToDeg(this.startAngle),a=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 f=t.readItem();if(!f)break;const p=Number(f.code);if(g&&p===100)return t.pushBackItem(f),!0;const m=Number(f.value);switch(p){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:o=m;break;case 51:a=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,o,a,c,l,h),this}applyDxfInGeometry(t,e,i,r,s,o,a,c,l){const h=new A(a,c,l);this.setNormalAndRefVec(h),this.center=At({x:t,y:e,z:i},this.normal),this.radius=r,this.startAngle=C.degToRad(s),this.endAngle=C.degToRad(o)}setNormalAndRefVec(t){this._geo.normal=t,this._geo.refVec=Qe(this._geo.normal)}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=Le(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=Le(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 Is(e.center,e.radius,e.startAngle,e.endAngle,e.normal):null}};Is.typeName="Arc";let jr=Is;const _b=1,xb=/\\[fF][^\\|{}]*(?:\|[^;\\|{}]*)*;./i,wb=/\\[fF][^\\|{}]*(?:\|[^;\\|{}]*)*;./gi;function rc(n){return n.replace(/\\[PpNn]/g,`
8
8
  `).replace(/\\[A-Za-z][^;]*;/g,"").replace(/[{}]/g,"")}function vb(n){return n.replace(/\\[PpNn]/g,`
9
- `).replace(wb,"").replace(/\\[A-Za-z][^;]*;/g,"").replace(/[{}]/g,"").trim()}function Ab(n,t,e=1){const i=n.trim();if(!i||t<=0)return 0;const r=vb(i),s=xb.test(i);return r?Math.max(t,Wi(r,t,e)):s?t:0}function Wi(n,t,e=1){if(!n||t<=0)return 0;const i=rc(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*_b*e)}function Cd(n){const t=rc(n);return Math.max(t.split(/\r\n|\r|\n/g).length,1)}function Od(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 sc(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 oc(n,t){let e;t&&t.lengthSq()>0?e=t.clone().normalize():e=new A(Math.cos(n),Math.sin(n),0);const i=new A(-e.y,e.x,e.z);return i.lengthSq()===0?i.set(0,1,0):i.normalize(),{xAxis:e,yAxis:i}}function Rd(n,t,e,i,r,s=0,o){if(e<=0&&i<=0)return n.expandByPoint(t),n;const a=sc(e,i,r),{xAxis:c,yAxis:l}=oc(s,o?new A(o.x,o.y,o.z||0):void 0),h=[[a.minX,a.minY],[a.maxX,a.minY],[a.maxX,a.maxY],[a.minX,a.maxY]];for(const[u,d]of h)n.expandByPoint(new _(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 Pb(n){const t=n.extentsWidth>0?n.extentsWidth:n.width>0?n.width:Wi(n.contents,n.height),e=Od(Cd(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 _(n.location.x,n.location.y,n.location.z??0)}}function Sb(n,t){const{xAxis:e,yAxis:i}=oc(t.rotation,t.direction),r=n.x-t.location.x,s=n.y-t.location.y,o=(n.z??0)-t.location.z;return{x:r*e.x+s*e.y+o*e.z,y:r*i.x+s*i.y+o*i.z}}function kb(n){const t=sc(n.width,n.height,n.attachment),{xAxis:e,yAxis:i}=oc(n.rotation,n.direction);return[[t.minX,t.minY],[t.maxX,t.minY],[t.maxX,t.maxY],[t.minX,t.maxY]].map(([s,o])=>new _(n.location.x+e.x*s+i.x*o,n.location.y+e.y*s+i.y*o,n.location.z+e.z*s+i.z*o))}function Eb(n,t,e){const i=sc(t.width,t.height,t.attachment),{x:r,y:s}=Sb(n,t),o=i.minX-e.padX,a=i.maxX+e.padX,c=i.minY-e.padYBelow,l=i.maxY+e.padYAbove;if(r<o||r>a||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 Nd=(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))(Nd||{}),Bd=(n=>(n[n.BASELINE=0]="BASELINE",n[n.BOTTOM=1]="BOTTOM",n[n.MIDDLE=2]="MIDDLE",n[n.TOP=3]="TOP",n))(Bd||{});const kc=class kc extends tt{constructor(){super(),this._generationFlag=0,this._normal=new A(0,0,1),this._textString="",this._height=0,this._thickness=1,this._position=new _,this._alignmentPoint=new _,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 j,{anchor:e,attachmentPoint:i}=this.resolveTextAnchor(),r=Wi(this.textString,this.height,this.widthFactor);return Rd(t,e,r,this.height,i,this.rotation)}subGetGripPoints(){return[this._position]}subMoveGripPointsAt(t,e){return Se(t,e,this._position),this._alignmentPoint.add(e),this}subGetOsnapPoints(t,e,i,r){I.Insertion===t&&r.push(this._position)}transformBy(t){const e=this._position.clone(),i=this._position.clone().add(new A(Math.cos(this._rotation),Math.sin(this._rotation),0)),r=this._position.clone().add(new A(-Math.sin(this._rotation),Math.cos(this._rotation),0)),s=this._position.clone().add(new A(0,0,1));e.applyMatrix4(t),i.applyMatrix4(t),r.applyMatrix4(t),s.applyMatrix4(t);const o=new A(i).sub(e),a=new A(r).sub(e),c=new A(s).sub(e),l=a.length(),h=o.length(),u=c.length();this._position.copy(e),h>0&&(this._rotation=Math.atan2(o.y,o.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,o=this.alignmentPoint.y,a=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),f=Number(d.value);switch(g){case 10:e=f;break;case 20:i=f;break;case 30:r=f;break;case 11:s=f,c=!0;break;case 21:o=f,c=!0;break;case 31:a=f,c=!0;break;case 1:this.textString=String(d.value);break;case 7:this.styleName=String(d.value);break;case 39:this.thickness=f;break;case 40:this.height=f;break;case 41:this.widthFactor=f;break;case 50:this.rotation=C.degToRad(f);break;case 51:this.oblique=C.degToRad(f);break;case 71:this.generationFlag=f;break;case 72:this.horizontalMode=f;break;case 73:this.verticalMode=f;break;case 210:l=f;break;case 220:h=f;break;case 230:u=f;break;case 100:{if(String(d.value)==="AcDbText")break;return t.pushBackItem(d),this.finishTextDxfIn(e,i,r,s,o,a,c,l,h,u),this}}}return this.finishTextDxfIn(e,i,r,s,o,a,c,l,h,u),this}finishTextDxfIn(t,e,i,r,s,o,a,c,l,h){this.position=new _(t,e,i),a&&!(r===0&&s===0&&o===0)?this.alignmentPoint=new _(r,s,o):this.alignmentPoint=new _(t,e,i);const u=new A(c,l,h);u.lengthSq()>0&&this.normal.copy(u.normalize())}};kc.typeName="Text";let Gn=kc;var xt=(n=>(n[n.Invisible=1]="Invisible",n[n.Const=2]="Const",n[n.Verifiable=4]="Verifiable",n[n.Preset=8]="Preset",n))(xt||{}),le=(n=>(n[n.MultiLine=2]="MultiLine",n[n.ConstMultiLine=4]="ConstMultiLine",n))(le||{});const Ec=class Ec extends Gn{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}};Ec.typeName="AttDef";let Ur=Ec;function Ib(n){return n!=null&&typeof n=="object"&&"blockTableRecord"in n}const Ic=class Ic extends Gn{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(Ib(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&xt.Invisible)!==0}set isInvisible(t){t?this._flags|=xt.Invisible:this._flags&=~xt.Invisible}get isConst(){return(this._flags&xt.Const)!==0}set isConst(t){t?this._flags|=xt.Const:this._flags&=~xt.Const}get isVerifiable(){return(this._flags&xt.Verifiable)!==0}set isVerifiable(t){t?this._flags|=xt.Verifiable:this._flags&=~xt.Verifiable}get isPreset(){return(this._flags&xt.Preset)!==0}set isPreset(t){t?this._flags|=xt.Preset:this._flags&=~xt.Preset}get isMTextAttribute(){return(this._mtextFlag&le.MultiLine)!==0}set isMTextAttribute(t){t?this._mtextFlag|=le.MultiLine:this._mtextFlag&=~le.MultiLine}get isConstMTextAttribute(){return(this._mtextFlag&le.ConstMultiLine)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=le.ConstMultiLine:this._mtextFlag&=~le.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&xt.Invisible)!==0,this.isConst=(r&xt.Const)!==0,this.isVerifiable=(r&xt.Verifiable)!==0,this.isPreset=(r&xt.Preset)!==0;break;case 71:this.isMTextAttribute=(r&le.MultiLine)!==0,this.isConstMTextAttribute=(r&le.ConstMultiLine)!==0;break;case 73:this.fieldLength=r;break;case 74:this.verticalMode=r;break;case 280:this.lockPositionInBlock=r!==0;break}}return this}};Ic.typeName="Attrib";let Si=Ic;const Tb=()=>({hits:0,misses:0,hitMs:0,missBuildMs:0,missCompactMs:0,cloneMs:0,setCloneMs:0,applyMs:0}),Vl=()=>({hits:0,misses:0,hitMs:0,missBuildMs:0,missCompactMs:0,cloneMs:0,setCloneMs:0,applyMs:0,topLevel:Tb(),blockMisses:[]}),wt=class wt{static get profileStats(){return this._profileStats}static resetProfile(){this._profileStats=Vl(),this._drawDepth=0}static get instance(){return this._instance||(this._instance=new wt),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){return this._blocks.set(t,e),e}get(t){const e=this._blocks.get(t);if(e){if(wt.profiling){const i=performance.now();if(this.maybeCompactTemplate(e,!0)){const c=performance.now()-i;wt._profileStats.missCompactMs+=c,wt._drawDepth===1&&(wt._profileStats.topLevel.missCompactMs+=c)}const s=performance.now(),o=e.fastDeepClone(),a=performance.now()-s;return wt._profileStats.cloneMs+=a,wt._drawDepth===1&&(wt._profileStats.topLevel.cloneMs+=a),o}return this.maybeCompactTemplate(e,!0),e.fastDeepClone()}}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 o=0;const a=new U().setForeground(),c=new Fs;for(const l of r){const h=this.createCacheKey(l.name,a,!1);this.has(h)||this.draw(t,l,a,[],!0),o++,i&&await i(o,s,l.name),await c.maybeYield(qn)}}draw(t,e,i,r=[],s=!0,o,a){const c=wt.profiling;c&&wt._drawDepth++;const l=c&&wt._drawDepth===1,h=wt._profileStats,u=[];try{if(e!=null){const d=i.RGB??0,g=e.name;let f;if(g&&this.has(g))f=g;else if(g){const y=this.createKey(g,i);this.has(y)&&(f=y)}let p;if(f!==void 0){const y=c?performance.now():0;if(p=this.get(f),c){const b=performance.now()-y;h.hits++,h.hitMs+=b,l&&(h.topLevel.hits++,h.topLevel.hitMs+=b)}}else{const y=c?performance.now():0;let b=!1;const w=e.newIterator();for(const k of w)if(k.visibility)if(k.color.isByBlock){b=!0;const E=Fb(k.color);try{i.isForeground?k.color.setForeground():k.color.setRGBValue(d),this.addEntity(k,u,t)}finally{k.color.copy(E),Db(E)}}else this.addEntity(k,u,t);p=t.group(u);let x=0;c&&(x=performance.now()-y,h.missBuildMs+=x,l&&(h.topLevel.missBuildMs+=x));let S=0;const P=!!s&&!!g&&!g.startsWith("*U");if(p&&P){const k=c?performance.now():0,E=this.maybeCompactTemplate(p,!1);c&&E&&(S=performance.now()-k,h.missCompactMs+=S,l&&(h.topLevel.missCompactMs+=S))}f=this.createCacheKey(g,i,b);const v=c?h.setCloneMs:0;if(p&&P)if(Bb(p),this.set(f,p),c){const k=performance.now();p=p.fastDeepClone();const E=performance.now()-k;h.setCloneMs+=E,l&&(h.topLevel.setCloneMs+=E)}else p=p.fastDeepClone();c&&(h.misses++,l&&h.topLevel.misses++,h.blockMisses.push({blockName:g||"(unnamed)",buildMs:x,compactMs:S,setCloneMs:h.setCloneMs-v}))}const m=c?performance.now():0;if(p&&o&&(ar.copy(o),p.applyMatrix(ar),a&&(a.x!=0||a.y!=0||a.z!=1)&&(Po.setFromExtrusionDirection(a),p.applyMatrix(Po),ar.premultiply(Po))),p&&r&&r.length>0){const y=o!=null?Lb.copy(ar).invert():void 0;r.forEach(b=>{y&&b.applyMatrix(y),p.addChild(b)})}if(c){const y=performance.now()-m;h.applyMs+=y,l&&(h.topLevel.applyMs+=y)}return p}else return t.group(u)}finally{c&&wt._drawDepth--}}shouldSkipPrebuild(t){const e=t.name;if(ct.isModelSapceName(e)||ct.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}maybeCompactTemplate(t,e){return!t.compactForInstancing||Rb(t)||!Nb(t,e)?!1:(t.compactForInstancing(),!0)}};wt.profiling=!1,wt._profileStats=Vl(),wt._drawDepth=0;let Je=wt;const ar=new D,Po=new D,Lb=new D,Mb=8,Cb=32,Fd=[];function Ob(n){const t=n.childCount;return typeof t=="number"?t:Number.POSITIVE_INFINITY}function Rb(n){return n.isCompacted===!0}function Nb(n,t){const e=Ob(n);return e<Mb?!1:e>=Cb?!0:t}function Bb(n){const t=n.prepareCacheTemplate;typeof t=="function"&&t.call(n)}function Fb(n){const t=Fd.pop()??new U;return t.copy(n),t}function Db(n){Fd.push(n)}const Xb=1e-10;function $t(n,t,e){const i=t?n.length:n.length-1;if(i<1||n.length<2)return[];const r=[];for(let s=0;s<i;s++){const o=n[s],a=n[(s+1)%n.length];if(Zs(o,a))continue;const c=!t&&(s===0||s===i-1);r.push({kind:"line",line:new Dt(o,a),extent:"bounded",extendable:e??c})}return r}function ac(n,t,e,i){const r=t?n.length:n.length-1;if(r<1||n.length<2)return[];const s=[];for(let o=0;o<r;o++){const a=n[o],c=n[(o+1)%n.length],h=!t&&(o===0||o===r-1),u=a.bulge??0;if(Math.abs(u)>Xb){const f=Xd(new $(a,c,u),e,i,h);f&&s.push(f);continue}const d=Ne(a.x,a.y,e,i),g=Ne(c.x,c.y,e,i);Zs(d,g)||s.push({kind:"line",line:new Dt(d,g),extent:"bounded",extendable:h})}return s}function Yb(n,t,e){const i=[];for(const r of n){if(r instanceof it){i.push(...ac(r.vertices,r.closed,t,e));continue}if(r instanceof On)for(const s of r.curves){const o=zb(s,t,e);o&&i.push(...o)}}return i}function Dd(n,t){return n.map(e=>Em(e,t))}function zb(n,t,e){if(n instanceof Vt){const i=Ne(n.startPoint.x,n.startPoint.y,t,e),r=Ne(n.endPoint.x,n.endPoint.y,t,e);return Zs(i,r)?[]:[{kind:"line",line:new Dt(i,r),extent:"bounded",extendable:!1}]}if(n instanceof $){const i=Xd(n,t,e,!1);return i?[i]:[]}if(n instanceof Ie){const i=Vb(n,t,e,!1);return i?[i]:[]}if(n instanceof Ut){const i=n.clone(),r=jb(t,e);return r&&i.transform(r),[{kind:"spline",spline:i,extendable:!1}]}return[]}function Xd(n,t,e,i){if(n.closed||Math.abs(n.deltaAngle-Y)<1e-10){const c=Ne(n.center.x,n.center.y,t,e);return{kind:"circArc",arc:new Pt(c,n.radius,0,Y,e,Qe(e)),extendable:!1}}const r=Ne(n.startPoint.x,n.startPoint.y,t,e),s=Ne(n.endPoint.x,n.endPoint.y,t,e),o=Ne(n.midPoint.x,n.midPoint.y,t,e),a=Pt.tryCreateByThreePoints(r,s,o);return a?{kind:"circArc",arc:a,extendable:i&&!a.closed}:Zs(r,s)?null:{kind:"line",line:new Dt(r,s),extent:"bounded",extendable:i}}function Vb(n,t,e,i){const r=Ne(n.center.x,n.center.y,t,e),s=new D().setFromExtrusionDirection(new A(e.x,e.y,e.z)),o=new A(Math.cos(n.rotation),Math.sin(n.rotation),0).transformDirection(s);if(o.lengthSq()===0)return null;const a=n.clockwise?n.endAngle:n.startAngle,c=n.clockwise?n.startAngle:n.endAngle,l=new Pe(r,e,o,n.majorAxisRadius,n.minorAxisRadius,a,c);return{kind:"ellipseArc",arc:l,extendable:i&&!l.closed&&Math.abs(l.deltaAngle-Y)>1e-10}}function Ne(n,t,e,i){return At({x:n,y:t,z:e},i)}function jb(n,t){if(Math.abs(t.x)<1e-10&&Math.abs(t.y)<1e-10&&Math.abs(t.z-1)<1e-10&&Math.abs(n)<1e-10)return null;const i=new D().setFromExtrusionDirection(new A(t.x,t.y,t.z));return Math.abs(n)<1e-10?i:i.multiply(new D().makeTranslation(0,0,n))}function Zs(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<1e-20}const In=class In extends tt{constructor(t){super(),this._columnCount=1,this._rowCount=1,this._columnSpacing=0,this._rowSpacing=0,this._blockName=t??"",this._position=new _,this._rotation=0,this._normal=new A(0,0,1),this._scaleFactors=new _(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(){if(this._blockName)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 jn(this._attribs)}get blockTransform(){const t=this.blockTableRecord,e=(t==null?void 0:t.origin)??_.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 Dn().setFromAxisAngle(A.Z_AXIS,this._rotation),o=new D().makeRotationFromQuaternion(s),a=new D().makeTranslation(this._position.x,this._position.y,this._position.z);return new D().multiplyMatrices(a,o).multiply(r).multiply(i)}subGetGripPoints(){return[this._position]}subMoveGripPointsAt(t,e){return Se(t,e,this._position),this}subGetOsnapPoints(t,e,i,r,s,o){const a=o??new D;I.Insertion===t?r.push(this.getInsertionPoint(a)):s?this.subEntityGetOsnapPoints(t,e,i,r,s,a):this.collectBlockOsnapPoints(t,e,i,r,a)}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(),o=new _(this._scaleFactors.x,0,0).applyMatrix4(r).add(s),a=new _(0,this._scaleFactors.y,0).applyMatrix4(r).add(s),c=new _(0,0,this._scaleFactors.z).applyMatrix4(r).add(s);s.applyMatrix4(t),o.applyMatrix4(t),a.applyMatrix4(t),c.applyMatrix4(t);const l=new A(o).sub(s),h=new A(a).sub(s),u=new A(c).sub(s);let d=new A().crossVectors(l,h);d.lengthSq()===0?d=this._normal.clone().transformDirection(t):d.normalize();const f=new D().setFromExtrusionDirection(d).clone().invert(),p=l.clone().applyMatrix4(f);return this._position.copy(s),this._normal.copy(d),this._rotation=Math.atan2(p.y,p.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 j,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}subGetIntersectCurves(){const t=this.blockTableRecord;if(t==null)return[];const e=[],i=Math.max(1,this.columnCount),r=Math.max(1,this.rowCount);for(let s=0;s<r;s++)for(let o=0;o<i;o++){const a=new D().makeTranslation(o*this.columnSpacing,s*this.rowSpacing,0),c=new D().multiplyMatrices(this.getFullInsertionTransform(),a);for(const l of t.newIterator())e.push(...Dd(l.subGetIntersectCurves(),c))}return e}subWorldDraw(t){const e=this.blockTableRecord;if(e!=null){const i=[];this._attribs.forEach(a=>{if(!a.isInvisible){const c=a.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 Je.instance.draw(t,e,this.resolvedColor,i,!0,this.blockTransform,this._normal);const o=[];for(let a=0;a<s;a++)for(let c=0;c<r;c++){const l=new D().makeTranslation(c*this.columnSpacing,a*this.rowSpacing,0),h=new D().multiplyMatrices(this.blockTransform,l),u=Je.instance.draw(t,e,this.resolvedColor,c===0&&a===0?i:[],!0,h,this._normal);u&&o.push(u)}return t.group(o)}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 o=this.blockTableRecord;if(!o)return;const a=new D().multiplyMatrices(s,this.getFullInsertionTransform()),c=a.clone().invert(),l=new _(e).applyMatrix4(c),h=new _(i).applyMatrix4(c),u=[];for(const d of o.newIterator()){const g=[];if(d instanceof In){d.subGetOsnapPoints(t,e,i,g,void 0,a),u.push(...g);continue}d.subGetOsnapPoints(t,l,h,g,void 0,a),g.forEach(f=>u.push(new _(f).applyMatrix4(a)))}if(u.length!==0)if(t===I.Nearest||t===I.Perpendicular||t===I.Tangent){const d=ie(e,u);d&&r.push(d)}else r.push(...u)}subEntityGetOsnapPoints(t,e,i,r,s,o,a=new Set){if(s===this.objectId||a.has(this.objectId))return!1;a.add(this.objectId);try{const c=this.blockTableRecord;if(c==null)return!1;const l=new D().multiplyMatrices(o,this.getFullInsertionTransform());for(const h of c.newIterator()){if(h.objectId===s){const u=new _(e).applyMatrix4(l.clone().invert()),d=new _(i).applyMatrix4(l.clone().invert()),g=[];return h.subGetOsnapPoints(t,u,d,g,s,l),h instanceof In?g.forEach(f=>{r.push(f.clone())}):g.forEach(f=>{r.push(new _(f).applyMatrix4(l))}),!0}if(h instanceof In&&h.subEntityGetOsnapPoints(t,e,i,r,s,l,a))return!0}return!1}finally{a.delete(this.objectId)}}getInsertionPoint(t){var r;const e=((r=this.blockTableRecord)==null?void 0:r.origin)??_.ORIGIN,i=new D().multiplyMatrices(t,this.getFullInsertionTransform());return new _(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,o=this.scaleFactors.y,a=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,f=this.columnSpacing,p=this.rowSpacing;const m=()=>{this.position=new _(e,i,r),this.scaleFactors=new _(s,o,a),this.rotation=C.degToRad(c),this.normal.copy(new A(l,h,u)),this.columnCount=d>0?d:1,this.rowCount=g>0?g:1,this.columnSpacing=f,this.rowSpacing=p};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const y=t.readItem();if(!y)break;const b=Number(y.code),w=Number(y.value);switch(b){case 10:e=w;break;case 20:i=w;break;case 30:r=w;break;case 2:this.blockName=String(y.value);break;case 41:s=w;break;case 42:o=w;break;case 43:a=w;break;case 44:f=w;break;case 45:p=w;break;case 50:c=w;break;case 66:break;case 70:d=w;break;case 71:g=w;break;case 210:l=w;break;case 220:h=w;break;case 230:u=w;break;case 100:return t.pushBackItem(y),m(),this}}return m(),this}};In.typeName="BlockReference";let xe=In;const jl=[0,Math.PI/2,Math.PI,Math.PI/2*3],Ts=class Ts extends It{constructor(t,e,i=A.Z_AXIS){super(),this._thickness=0;const r=Qe(i);this._geo=new Pt(t,e,0,Y,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}subGetIntersectCurves(){return[{kind:"circArc",arc:this._geo.clone(),extendable:!1}]}get closed(){return this._geo.closed}get area(){return this._geo.area}subGetOsnapPoints(t,e,i,r){switch(t){case I.Center:case I.Centroid:r.push(this._geo.center);break;case I.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 I.Nearest:{const s=this._geo.nearestPoint(e);r.push(s)}break;case I.Tangent:{const s=this._geo.tangentPoints(e);r.push(...s);break}case I.Perpendicular:{const s=this._geo.perpendicularPoints(e),o=ie(e,s);o&&r.push(o);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 jl)t.push(this._geo.getPointAtAngle(e));return t}subMoveGripPointsAt(t,e){return bt(t,i=>{this.moveGripAt(i,e)}),this}transformBy(t){return this._geo.transform(t),this}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){return t.circularArc(this._geo)}dxfOutFields(t){super.dxfOutFields(t);const e=jt(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,o=this.normal.x,a=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:o=u;break;case 220:a=u;break;case 230:c=u;break}}return this.applyDxfInGeometry(e,i,r,s,o,a,c),this}applyDxfInGeometry(t,e,i,r,s,o,a){const c=new A(s,o,a);this._geo.normal=c,this._geo.refVec=Qe(this._geo.normal),this.center=At({x:t,y:e,z:i},this.normal),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 Ts(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=jl[t-1],r=this._geo.getPointAtAngle(i),o=new _(r.x+e.x,r.y+e.y,(r.z??0)+(e.z??0)).distanceTo(this.center);o>0&&(this.radius=o);break}}}};Ts.typeName="Circle";let Gr=Ts;const ni=[0,Math.PI/2,Math.PI,Math.PI/2*3],Ls=class Ls extends It{get dxfTypeName(){return"ELLIPSE"}constructor(t,e,i,r,s,o,a){super(),this._geo=new Pe(t,e,i,r,s,o,a)}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}subGetIntersectCurves(){return[{kind:"ellipseArc",arc:this._geo.clone(),extendable:!this.closed}]}get closed(){return this._geo.closed||Math.abs(this._geo.deltaAngle-Y)<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 ni)t.push(this._geo.getPointAtAngle(e));else t.push(this._geo.startPoint),t.push(this._geo.endPoint);return t}subMoveGripPointsAt(t,e){return bt(t,i=>{this.moveGripAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){switch(t){case I.EndPoint:this.closed||(r.push(this._geo.startPoint),r.push(this._geo.endPoint));break;case I.MidPoint:this.closed||r.push(this._geo.midPoint);break;case I.Center:case I.Centroid:r.push(this._geo.center);break;case I.Quadrant:if(this.closed)for(const s of ni)r.push(this._geo.getPointAtAngle(s));break;case I.Nearest:r.push(this._geo.nearestPoint(e));break;case I.Tangent:r.push(...this._geo.tangentPoints(e));break;case I.Perpendicular:{const s=this._geo.perpendicularPoints(e),o=ie(e,s);o&&r.push(o);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}}]}]}}get directBatchPrimitive(){return"lineStrip"}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,o=this.majorAxis.y*this.majorAxisRadius,a=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 f=t.readItem();if(!f)break;const p=Number(f.code),m=Number(f.value);switch(p){case 10:e=m;break;case 20:i=m;break;case 30:r=m;break;case 11:s=m;break;case 21:o=m;break;case 31:a=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,o,a,c,l,h,u,d,g),this}applyDxfInGeometry(t,e,i,r,s,o,a,c,l,h,u,d){const g=Math.hypot(r,s,o)||1;this._geo=new Pe({x:t,y:e,z:i},{x:a,y:c,z:l},{x:r,y:s,z:o},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,o=Math.hypot(s.x,s.y)||1,a=this.minorAxisRadius/this.majorAxisRadius*o||1,c=s.x/o,l=s.y/o,h=-l,u=c,d=i*c+r*l,g=i*h+r*u;return(d/o)**2+(g/a)**2>=1?1:-1}moveGripAt(t,e){switch(t){case 0:this.transformBy(D.makeTranslation(e));break;case 1:if(this.closed)this.moveQuadrantGripAt(ni[0],e);else{const i=this._geo.startPoint;this._geo.startAngle=Le(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(ni[1],e);else{const i=this._geo.endPoint;this._geo.endAngle=Le(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(ni[t-1],e);break}}moveQuadrantGripAt(t,e){const i=this._geo.getPointAtAngle(t),r=new _(i.x+e.x,i.y+e.y,(i.z??0)+(e.z??0)),s=this._geo.center,o=r.x-s.x,a=r.y-s.y,c=(r.z??0)-(s.z??0),l=t===0||t===Math.PI?this._geo.majorAxis:this._geo.minorAxis,h=o*l.x+a*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 Ls(e.center,e.normal,e.majorAxis,e.majorAxisRadius,e.minorAxisRadius,e.startAngle,e.endAngle):null}};Ls.typeName="Ellipse";let Hr=Ls;const Tc=class Tc extends tt{get dxfTypeName(){return"3DFACE"}constructor(){super(),this._vertices=[new _,new _,new _],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 _),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 j().setFromPoints(this._vertices)}subGetIntersectCurves(){return $t(this._vertices,!0)}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),iu(t)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subMoveGripPointsAt(t,e){return Qn(t,e,this._vertices),this}subGetOsnapPoints(t,e,i,r){Ks(this._vertices,!0,t,e,r)}transformBy(t){return this._vertices.forEach(e=>e.applyMatrix4(t)),this}get directBatchPrimitive(){return"lineSegments"}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 o=0;for(let a=0;a<4;++a)this.isEdgeVisibleAt(a)||(o|=1<<a);return t.writeInt16(70,o),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),o=Number(r.value);switch(s){case 10:case 11:case 12:case 13:e[s-10].x=o;break;case 20:case 21:case 22:case 23:e[s-20].y=o;break;case 30:case 31:case 32:case 33:e[s-30].z=o;break;case 70:i=o;break}}return e.forEach((r,s)=>this.setVertexAt(s,r)),this._edgeInvisibilities=i,this}};Tc.typeName="Face";let Wr=Tc;var Bt=(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))(Bt||{}),ut=(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))(ut||{}),at=(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))(at||{});function Ub(n){return n==4||n==5||n==6||n==7||n==12||n==13||n==14||n==15||n==16||n==17}function Gb(n){return n==1||n==2||n==3||n==8||n==9||n==10||n==21}const T={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",COMPAREHATCH:"COMPAREHATCH",COMPAREPROPS:"COMPAREPROPS",COMPARERCMARGIN:"COMPARERCMARGIN",COMPARETEXT:"COMPARETEXT",COMPARETOLERANCE:"COMPARETOLERANCE",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",LOGINNAME:"LOGINNAME",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"},Hb=Object.freeze(Object.values(T));function Wb(){try{const n=typeof process<"u"&&process.env?process.env:void 0;if(!n)return"";const t=n.USERNAME||n.USER||n.LOGNAME||"";return typeof t=="string"?t.trim():""}catch{return""}}const Ms=class Ms{constructor(){this.registry=new Map,this.cache=new Map,this.events={sysVarChanged:new gt},this.registerVar({name:T.ANGBASE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:T.ANGDIR,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:T.AUNITS,type:"number",isDbVar:!0,defaultValue:Bt.DecimalDegrees}),this.registerVar({name:T.AUPREC,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:T.CECOLOR,type:"color",isDbVar:!0,defaultValue:new U(exports.AcCmColorMethod.ByLayer)}),this.registerVar({name:T.CELTSCALE,type:"number",isDbVar:!0,defaultValue:-1}),this.registerVar({name:T.CELTYPE,type:"string",isDbVar:!0,defaultValue:mt}),this.registerVar({name:T.CELWEIGHT,type:"number",isDbVar:!0,defaultValue:exports.AcGiLineWeight.ByLayer}),this.registerVar({name:T.CETRANSPARENCY,type:"transparency",isDbVar:!0,defaultValue:new pt}),this.registerVar({name:T.CLAYER,type:"string",isDbVar:!0,defaultValue:"0"}),this.registerVar({name:T.CMLEADERSTYLE,type:"string",isDbVar:!0,defaultValue:Re}),this.registerVar({name:T.CMLSCALE,type:"number",isDbVar:!0,defaultValue:1}),this.registerVar({name:T.CMLSTYLE,type:"string",isDbVar:!0,defaultValue:Oe}),this.registerVar({name:T.COLORTHEME,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:T.COMPAREHATCH,type:"number",isDbVar:!0,defaultValue:Br}),this.registerVar({name:T.COMPAREPROPS,type:"number",isDbVar:!1,defaultValue:cd}),this.registerVar({name:T.COMPARERCMARGIN,type:"number",isDbVar:!0,defaultValue:Fr}),this.registerVar({name:T.COMPARETEXT,type:"number",isDbVar:!0,defaultValue:Dr}),this.registerVar({name:T.COMPARETOLERANCE,type:"number",isDbVar:!0,defaultValue:Xr}),this.registerVar({name:T.DYNMODE,type:"number",isDbVar:!1,defaultValue:3}),this.registerVar({name:T.DYNPROMPT,type:"boolean",isDbVar:!1,defaultValue:!0}),this.registerVar({name:T.DWGNAME,type:"string",isDbVar:!0,readOnly:!0,defaultValue:"Drawing1.dwg"}),this.registerVar({name:T.GRIPCOLOR,type:"number",isDbVar:!1,defaultValue:Qu}),this.registerVar({name:T.GRIPHOT,type:"number",isDbVar:!1,defaultValue:Ju}),this.registerVar({name:T.GRIPOBJLIMIT,type:"number",isDbVar:!1,defaultValue:100}),this.registerVar({name:T.GRIPS,type:"number",isDbVar:!1,defaultValue:2}),this.registerVar({name:T.GRIPSIZE,type:"number",isDbVar:!1,defaultValue:td}),this.registerVar({name:T.HPANG,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:T.HPASSOC,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:T.HPBACKGROUNDCOLOR,type:"color",isDbVar:!0,defaultValue:new U(exports.AcCmColorMethod.None)}),this.registerVar({name:T.HPCOLOR,type:"color",isDbVar:!0,defaultValue:new U(exports.AcCmColorMethod.ByLayer)}),this.registerVar({name:T.HPDOUBLE,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:T.HPISLANDDETECTION,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:T.HPLAYER,type:"string",isDbVar:!0,defaultValue:"."}),this.registerVar({name:T.HPNAME,type:"string",isDbVar:!1,defaultValue:qu}),this.registerVar({name:T.HPSCALE,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:T.HPSEPARATE,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:T.HPTRANSPARENCY,type:"transparency",isDbVar:!0,defaultValue:new pt}),this.registerVar({name:T.INSUNITS,type:"number",isDbVar:!0,defaultValue:at.Millimeters}),this.registerVar({name:T.LOGINNAME,type:"string",isDbVar:!1,readOnly:!0,defaultValue:Wb()}),this.registerVar({name:T.LUNITS,type:"number",isDbVar:!0,defaultValue:ut.Decimal}),this.registerVar({name:T.LUPREC,type:"number",isDbVar:!0,defaultValue:4}),this.registerVar({name:T.LWDISPLAY,type:"boolean",isDbVar:!0,defaultValue:!1}),this.registerVar({name:T.MEASUREMENT,type:"number",isDbVar:!0,defaultValue:1}),this.registerVar({name:T.MEASUREMENTCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new U(exports.AcCmColorMethod.ByColor);return t.setRGB(96,165,250),t})()}),this.registerVar({name:T.MODELBKCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new U(exports.AcCmColorMethod.ByColor);return t.setRGB(0,0,0),t})()}),this.registerVar({name:T.OSMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:T.ORTHOMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:T.OPENPROF,type:"boolean",isDbVar:!1,defaultValue:!1}),this.registerVar({name:T.PAPERBKCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new U(exports.AcCmColorMethod.ByColor);return t.setRGB(255,255,255),t})()}),this.registerVar({name:T.PICKBOX,type:"number",isDbVar:!1,defaultValue:10}),this.registerVar({name:T.POLARADDANG,type:"string",isDbVar:!1,defaultValue:""}),this.registerVar({name:T.POLARMODE,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:T.POLARANG,type:"number",isDbVar:!1,defaultValue:90}),this.registerVar({name:T.SHORTCUTMENU,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:T.TEXTSTYLE,type:"string",isDbVar:!0,defaultValue:lt}),this.registerVar({name:T.UNITMODE,type:"number",isDbVar:!0,defaultValue:0})}static instance(){return this._instance||(this._instance=new Ms),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))}setLoginName(t){const e=this.normalizeName(T.LOGINNAME);this.cache.set(e,t.trim())}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 o=this.normalizeName(t);if(this.hasValueChanged(e,i)){if(r.transactionManager.isRecording())r.transactionManager.recordSysvar(o,e);else if(r.transactionManager.strictMode&&!r.transactionManager.isApplyingUndoRedo())throw new Error(`Cannot change system variable ${o} outside an active transaction.`);s(),!r.transactionManager.isApplyingUndoRedo()&&!r.transactionManager.isRecording()&&this.events.sysVarChanged.dispatch({database:r,name:o,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 o=this.parseTransparency(e);if(o==null||o.isInvalid)throw new Error("Invalid transparency value!");e=o}else if(r.type!=="string"&&(typeof e=="string"||e instanceof String)){if(r.type==="number"){const o=Number(e);if(Number.isNaN(o))throw new Error("Invalid number input!");e=o}else if(r.type==="boolean")e=this.parseBoolean(e);else if(r.type==="color"){const o=this.parseColorSysVar(t,e,i);if(o==null)throw new Error("Invalid color value!");e=o}}if(t===T.GRIPCOLOR.toLowerCase()){const o=Math.trunc(e);if(!Number.isFinite(o)||o<Qo||o>Jo)throw new Error(`Invalid GRIPCOLOR value! Valid range is ${Qo} to ${Jo}.`);e=o}if(t===T.GRIPHOT.toLowerCase()){const o=Math.trunc(e);if(!Number.isFinite(o)||o<ta||o>ea)throw new Error(`Invalid GRIPHOT value! Valid range is ${ta} to ${ea}.`);e=o}if(t===T.GRIPOBJLIMIT.toLowerCase()){const o=Math.trunc(e);if(!Number.isFinite(o)||o<0||o>32767)throw new Error("Invalid GRIPOBJLIMIT value! Valid range is 0 to 32767.");e=o}if(t===T.GRIPS.toLowerCase()){const o=Math.trunc(e);if(!Number.isFinite(o)||o<0||o>2)throw new Error("Invalid GRIPS value! Valid range is 0 to 2.");e=o}if(t===T.GRIPSIZE.toLowerCase()){const o=Math.trunc(e);if(!Number.isFinite(o)||o<na||o>ia)throw new Error(`Invalid GRIPSIZE value! Valid range is ${na} to ${ia}.`);e=o}t===T.COMPAREHATCH.toLowerCase()&&(e=pe("COMPAREHATCH",e,zs,Vs)),t===T.COMPAREPROPS.toLowerCase()&&(e=pe("COMPAREPROPS",e,ld,hd)),t===T.COMPARERCMARGIN.toLowerCase()&&(e=pe("COMPARERCMARGIN",e,js,Us)),t===T.COMPARETEXT.toLowerCase()&&(e=pe("COMPARETEXT",e,Gs,Hs)),t===T.COMPARETOLERANCE.toLowerCase()&&(e=pe("COMPARETOLERANCE",e,Ws,$s)),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===T.HPCOLOR.toLowerCase()&&(r==="."||r==="use current")?i.cecolor.clone():t===T.HPBACKGROUNDCOLOR.toLowerCase()&&(r===""||r==="."||r==="none")?new U(exports.AcCmColorMethod.None):U.fromString(e)}parseTransparency(t){if(t instanceof pt)return t;if(typeof t=="number")return pt.deserialize(t);if(!(typeof t!="string"&&!(t instanceof String)))return pt.fromString(String(t))}hasValueChanged(t,e){return t instanceof U&&e instanceof U||t instanceof pt&&e instanceof pt?!t.equals(e):!Object.is(t,e)}normalizeName(t){return t.toLowerCase()}};Ms._instance=null;let vt=Ms;const Yd="Load Database",Ul=3e4,$b=12e4,qb=1024*1024;class Yt extends Ih{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=Na.getInstance().getEntry(Yd),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 cc{constructor(t={}){this.config={useWorker:t.useWorker??!0,...t}}async read(t,e,i={}){const{minimumChunkSize:r=10,progress:s,timeout:o,sysVars:a}=i,c={name:Yd,data:{total:0},format(){let d="";return Object.keys(this.data).forEach(g=>{g!=="total"&&(d+=`- ${g}: ${this.data[g]} ms
10
- `)}),d+=`- total: ${this.data.total} ms`,d}};Na.getInstance().collect(c),this.progress=s;const l={value:0},h=new Th;h.setCompleteCallback(()=>this.onFinished()),h.setErrorCallback(d=>this.onError(d)),h.addTask(new Yt({stage:"START",step:1,progress:l,task:async d=>d},s)),h.addTask(new Yt({stage:"PARSE",step:5,progress:l,task:async d=>await this.parse(d,o)},s)),h.addTask(new Yt({stage:"LTYPE",step:1,progress:l,task:async d=>(this.processLineTypes(d.model,e),d)},s)),h.addTask(new Yt({stage:"STYLE",step:1,progress:l,task:async d=>(this.processTextStyles(d.model,e),d)},s)),h.addTask(new Yt({stage:"DIMSTYLE",step:1,progress:l,task:async d=>(this.processDimStyles(d.model,e),d)},s)),h.addTask(new Yt({stage:"LAYER",step:1,progress:l,task:async d=>(this.processLayers(d.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),d)},s)),h.addTask(new Yt({stage:"VPORT",step:1,progress:l,task:async d=>(this.processViewports(d.model,e),d)},s)),h.addTask(new Yt({stage:"HEADER",step:1,progress:l,task:async d=>{if(this.processClasses(d.model,e),this.processHeader(d.model,e),a){const g=vt.instance();for(const[f,p]of Object.entries(a))g.setVar(f,p,e)}return d}},s)),h.addTask(new Yt({stage:"BLOCK_RECORD",step:5,progress:l,task:async d=>(this.processBlockTables(d.model,e),d)},s)),h.addTask(new Yt({stage:"OBJECT",step:5,progress:l,task:async d=>(this.processObjects(d.model,e),e.objects.layout.numEntries===0&&e.createDefaultData({layout:!0}),d)},s)),h.addTask(new Yt({stage:"BLOCK",step:5,progress:l,task:async d=>(await this.processBlocks(d.model,e),d)},s)),h.addTask(new Yt({stage:"ENTITY",step:100,progress:l,task:async d=>(await this.processEntities(d.model,e,r,l,s),d)},s)),h.addTask(new Yt({stage:"END",step:0,progress:l,task:async d=>d},s));const u=Date.now();await h.run(t),c.data.total=Date.now()-u}onError(t){if(this.progress){const e=t.task;this.progress(e.data.progress.value,e.data.stage,"ERROR",void 0,t)}return t.task.name==="ENTITY"?!1:(this.onFinished(),!0)}onFinished(){this.progress&&(this.progress(100,"END","END"),Je.instance.clear())}getParserWorkerTimeout(t,e){const i=e??this.config.timeout;if(i!=null)return i;const r=Math.ceil(t.byteLength/qb),s=Ul+r*1e3;return Math.min($b,Math.max(Ul,s))}async parse(t,e){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 zd{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 qn(),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,o=Math.min(i+this._chunkSize,this._count);await t(s,o),i=o,i<this._count&&await this.scheduleTask(r)};await r(),await(e==null?void 0:e())}}class Vd extends cc{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}async processEntities(t,e,i,r,s){let o=t.tables.blockTable.modelSpace.newIterator().toArray();const a=o.length,c=new zd(a,100-r.value,i);this.config.convertByEntityType&&(o=this.groupAndFlattenByType(o));const l=e.tables.blockTable.modelSpace;await c.processChunk(async(h,u)=>{let d=[],g=h<u?o[h].type:"";for(let f=h;f<u;f++){const p=o[f];this.config.convertByEntityType&&p.type!==g&&(this.triggerEvents(l,d),d=[],g=p.type),d.push(p)}if(this.triggerEvents(l,d),s){let f=r.value+u/a*(100-r.value);f>100&&(f=100),await s(f,"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 o of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:o,key:o.layoutName});const e=this._database.objects.imageDefinition.newIterator();for(const o of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:o,key:o.objectId});const i=this._database.objects.mleaderStyle.newIterator();for(const o of i)this._database.events.dictObjetSet.dispatch({database:this._database,object:o,key:o.objectId});const r=this._database.objects.layerFilter.newIterator();for(const o of r)this._database.events.dictObjetSet.dispatch({database:this._database,object:o,key:o.objectId});const s=this._database.objects.layerIndex.newIterator();for(const o of s)this._database.events.dictObjetSet.dispatch({database:this._database,object:o,key:o.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})}}var jd=(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))(jd||{}),lc=(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))(lc||{}),Ud=(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))(Ud||{}),Gd=(n=>(n[n.None=0]="None",n[n.Leading=1]="Leading",n[n.Trailing=2]="Trailing",n[n.LeadingAndTrailing=3]="LeadingAndTrailing",n))(Gd||{}),Hd=(n=>(n[n.Bottom=0]="Bottom",n[n.Middle=1]="Middle",n[n.Top=2]="Top",n))(Hd||{});const Cs=class Cs extends De{constructor(t,e){t=t||{},ne(t,Cs.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),o=this.database.tables.blockTable.getAt(this.dimblk2);return t.writeSubclassMarker("AcDbDimStyleTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),t.writeString(3,this.dimpost),t.writeString(4,this.dimapost),t.writeDouble(40,this.dimscale),t.writeDouble(41,this.dimasz),t.writeDouble(42,this.dimexo),t.writeDouble(43,this.dimdli),t.writeDouble(44,this.dimexe),t.writeDouble(140,this.dimtxt),t.writeDouble(147,this.dimgap),t.writeInt16(170,this.dimalt),t.writeInt16(171,this.dimtol),t.writeInt16(172,this.dimlim),t.writeInt16(173,this.dimtih),t.writeInt16(174,this.dimtoh),t.writeObjectId(340,e==null?void 0:e.objectId),t.writeObjectId(341,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,o==null?void 0:o.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}};Cs.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:lt,dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let Ht=Cs;function Wd(){return{color:new U,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:new pt,linetype:"",lineWeight:1,materialId:-1}}const Kb=["name",...Object.keys(Wd())];class $i extends De{constructor(t,e){t=t||{},ne(t,Wd()),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=pt.deserialize(Number(e.value));break;case 4:this.description=String(e.value);break}}return this}}class qe extends De{constructor(t,e){t=t||{},ne(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),o=this.escapeSvgAttribute((t==null?void 0:t.stroke)??"currentColor"),a=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(w=>w.elementLength!==0))return this.buildSvgString({width:e,height:i,stroke:o,strokeWidth:s,lineSegments:[[l,h]],dots:[],y:c});const g=[],f=[],p=u/(this.patternLength*a),m=.5,y=Math.max(s*2,2);let b=l;for(;b<h;)for(const w of d){if(b>=h)break;const x=w.elementLength;if(x===0){f.push(b),b=Math.min(b+y,h);continue}const S=Math.max(Math.abs(x)*p,m),P=Math.min(b+S,h);x>0&&P>b&&g.push([b,P]),b=P}return this.buildSvgString({width:e,height:i,stroke:o,strokeWidth:s,lineSegments:g,dots:f,y:c})}buildSvgString(t){const{width:e,height:i,stroke:r,strokeWidth:s,lineSegments:o,dots:a,y:c}=t,l=o.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=a.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 $r extends De{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 Qs extends De{constructor(t,e){t=t||{},ne(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 $d extends De{constructor(t,e){t=t||{},ne(t,{standardFlags:0,origin:new _(0,0,0),xAxis:new _(1,0,0),yAxis:new _(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 _,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 Zb=()=>({center:new M,viewDirectionFromTarget:new _(0,0,1),viewTarget:new _(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 _(0,0,0),ucsXAxis:new _(1,0,0),ucsYAxis:new _(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 hc extends De{constructor(t,e){t=t||{},ne(t,{gsView:Zb()}),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 Gl=2,Qb=.45,Jb=1e5;function t1(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 e1(n,t){if(Number.isFinite(t)&&t>0)return t;const e=t1(n);return e!=null&&e>0?e:1}function n1(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 Hl(n){return{x:(n.min.x+n.max.x)/2,y:(n.min.y+n.max.y)/2}}function i1(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 hc{static isActiveVportName(t){return t.toLowerCase()===Vn.toLowerCase()}constructor(t,e){t=t||{},ne(t,{circleSides:100,lowerLeftCorner:new M(0,0),upperRightCorner:new M(1,1),snapBase:new M(0,0),snapAngle:0,snapSpacing:new M(0,0),standardFlag:0,gridSpacing:new M,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,o=e.y;if(Number.isFinite(r)&&r!==0){const d=Math.cos(r),g=Math.sin(r);s=e.x*d-e.y*g,o=e.x*g+e.y*d}const a=this.viewTarget;a&&Number.isFinite(a.x)&&Number.isFinite(a.y)&&(s+=a.x,o+=a.y);const c=e1(this,t),l=i*c,h=i/2,u=l/2;return new kt().expandByPoint({x:s-u,y:o-h}).expandByPoint({x:s+u,y:o+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,o=e.max.y-e.min.y;if(i<=0||r<=0||s<=0||o<=0||i>s*Gl||r>o*Gl)return!1;const a=Math.max(s,o)*Qb,c=Hl(t),l=Hl(e);if(Math.hypot(c.x-l.x,c.y-l.y)>a)return!1;const u=i*r,d=n1(t,e);return!(d<=0||d/u<.25)}resolveModelViewBox(t,e){const i=this.modelViewBox(t);if(!(!i||!Ke.isModelViewBoxStructurallyValid(i))){if(i1(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)<=Jb}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 qd extends hc{constructor(t,e){t=t||{};const i=t.viewWidth!==void 0;ne(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 Js=192,ki=193,to=194,eo=195,Kd=200;function So(n){if(n.isByBlock)return ki<<24>>0;if(n.isByLayer)return Js<<24>>0;const t=n.colorIndex;if(t!=null&&t>0&&t<256)return(eo<<24|t&255)>>0;const e=n.RGB;return e!=null?(to<<24|e&16777215)>>0:ki<<24>>0}function fe(n){const t=new U(exports.AcCmColorMethod.ByBlock);switch(n>>>24&255){case Js:t.setByLayer();break;case ki:case Kd:t.setByBlock();break;case eo:t.colorIndex=n&255;break;case to: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 r1=127;var Zd=(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))(Zd||{});const en=A.Z_AXIS,s1=529;function o1(n){const t=n>>24&255;return t===to?{rgb:n&16777215}:t===Js?{colorIndex:256}:t===ki?{colorIndex:0}:t===eo?{colorIndex:n&255}:{colorIndex:n&255}}function ko(n){return new A(n.x,n.y,n.z??0)}function Eo(n){return new _(n.x,n.y,n.z??0)}function Wl(n){return{x:n[0],y:n[1],z:n[2]}}class ra{constructor(t,e={}){this._index=8,this._colorIndex=256,this._layer="0",this._linetype=mt,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),o=r.getUint32(4,!0);if(s<8)break;if(o===1){const a=t.subarray(e+8,e+s);return this.readExtents(a),((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 o=this._index;for(;o<s.length;){const a=new DataView(s.buffer,s.byteOffset+o,8),c=a.getUint32(0,!0),l=a.getUint32(4,!0);if(c<8)break;const h=s.subarray(o+8,o+c);this.dispatchChunk(t,e,l,h),l!==20&&(this._fill=!1),o+=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 U(exports.AcCmColorMethod.ByColor,this._rgbColor):this._colorIndex===256?e.color=new U(exports.AcCmColorMethod.ByLayer):this._colorIndex===0?e.color=new U(exports.AcCmColorMethod.ByBlock):this._colorIndex===7?e.color=new U(exports.AcCmColorMethod.ByACI,7):e.color=new U(exports.AcCmColorMethod.ByACI,this._colorIndex),e.lineType={name:this._linetype,type:this.resolveLineStyleType(),standardFlag:0,description:"",totalPatternLength:0}}resolveLineStyleType(){return this._linetype===mt?"ByLayer":this._linetype===ye?"ByBlock":"UserSpecified"}transformPoint(t){const e=Array.isArray(t)?Wl(t):t,i=Eo(e);return this._matrices.length>0&&i.applyMatrix4(this._matrices[this._matrices.length-1]),i}transformVector(t){const e=Array.isArray(t)?Wl(t):t,i=ko(e);return this._matrices.length>0&&i.transformDirection(this._matrices[this._matrices.length-1]),!Number.isFinite(i.lengthSq())||i.lengthSq()<1e-24?en.clone():i.normalize()}pushEntity(t,e){e&&t.push(e)}readExtents(t){const e=new Kt(t),i=e.readVertex(),r=e.readVertex();this._extents=[new _(i[0],i[1],i[2]),new _(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=ye:this._linetype=mt}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=o1(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>s1?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 Kt(t);let r=i.readLong();e&&(r+=1);const s=[];for(;r>0;){const[a,c,l]=i.readVertex();s.push(this.transformPoint({x:a,y:c,z:l})),r-=1}let o=en;return e&&s.length>0&&(o=ko(s.pop())),{vertices:s,normal:o}}drawCircle(t,e,i){const r=new Kt(i),s=r.readVertex(),o=r.readFloat(),a=this.transformVector(r.readVertex());let c=Eo({x:s[0],y:s[1],z:s[2]});a.equals(en)||(c=jt(c,a)),c=this.transformPoint(c);const l=Qe(a),h=new Pt(At(c,a),o,0,Y,a,l);this.applyTraits(t),this.pushEntity(e,t.circularArc(h))}drawCircle3P(t,e,i){const r=new Kt(i),s=this.transformPoint(r.readVertex()),o=this.transformPoint(r.readVertex()),a=this.transformPoint(r.readVertex()),c=Pt.computeCenterPoint(s,o,a);if(!c)return;const l=c.distanceTo(s),h=new Pt(c,l,0,Y,en);this.applyTraits(t),this.pushEntity(e,t.circularArc(h))}drawCircularArc(t,e,i){const r=new Kt(i),s=r.readVertex(),o=r.readFloat(),a=r.readVertex(),c=r.readVertex(),l=r.readFloat(),h=this.transformVector(a),u=Eo({x:s[0],y:s[1],z:s[2]}),d=ko({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():Qe(h),f=0,p=l,m=new Pt(this.transformPoint(u),o,f,p,h,g);this.applyTraits(t),this.pushEntity(e,t.circularArc(m))}drawCircularArc3P(t,e,i){const r=new Kt(i),s=this.transformPoint(r.readVertex()),o=this.transformPoint(r.readVertex()),a=this.transformPoint(r.readVertex()),c=Pt.computeCenterPoint(s,a,o);if(!c)return;const l=c.distanceTo(s),h=Le(c,s,en),u=Le(c,a,en),d=new Pt(c,l,h,u,en);this.applyTraits(t),this.pushEntity(e,t.circularArc(d))}drawEllipticArc(t,e,i){const r=new Kt(i),s=this.transformPoint(r.readVertex()),o=this.transformVector(r.readVertex()),a=r.readFloat(),c=r.readFloat(),l=r.readFloat(),h=r.readFloat(),u=r.readFloat(),d=At({x:Math.cos(u)*a,y:Math.sin(u)*a,z:0},o),g=new Pe(s,o,d,a,c,l,h);this.applyTraits(t),this.pushEntity(e,t.ellipticalArc(g))}drawPolyline(t,e,i,r){var o,a;const{vertices:s}=this.loadVertices(i,r);if(s.length!==0){if(s.length===1){this.applyTraits(t);const c=((o=this._database)==null?void 0:o.pdmode)??0,l=((a=this._database)==null?void 0:a.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 o=new it(r.map(l=>({x:l.x,y:l.y})),!0),a=new oe;a.add(o);const c=t.subEntityTraits;c.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},c.drawOrder=-1,this.applyTraits(t),this.pushEntity(e,t.area(a));return}const s=[...r,r[0]];this.applyTraits(t),this.pushEntity(e,t.lines(s))}drawLwPolyline(t,e,i){const r=new dd(i,this._dxfversion,this._encoding);let s=0,o=!1;r.readUnsignedLong();const a=r.readBitShort();a&8&&(s=r.readBitDouble()),a&512&&(o=!0);const c=r.readBitLong();if(c<=0)return;const l=a&16?r.readBitLong():0;this._dxfversion>="AC1024"&&(a&1024&&r.readBitLong(),a&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 f=r.readBitDoubleDefault(1,d[0]),p=r.readBitDoubleDefault(1,d[1]);d=[f,p],u.push(this.transformPoint({x:f,y:p,z:s}))}for(let g=0;g<l;g++)r.readBitDouble();o&&u.length>1&&u.push(u[0].clone()),this.applyTraits(t),this.pushEntity(e,t.lines(u))}drawShell(t,e,i){const r=new Kt(i),s=r.readLong(),o=[];for(let h=0;h<s;h++){const[u,d,g]=r.readVertex();o.push(this.transformPoint({x:u,y:d,z:g}))}const a=r.readLong(),c=[];let l=0;for(;l<a;){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=>o[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 Kt(i),o=this.transformPoint(s.readVertex()),a=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:o,normal:a,textDirection:c,text:d,height:l,widthFactor:h,obliqueAngle:u})}drawText2(t,e,i,r){const s=new Kt(i),o=this.transformPoint(s.readVertex()),a=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:o,normal:a,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},o={name:lt,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,o))}drawXline(t,e,i,r){const s=new Kt(i),o=this.transformPoint(s.readVertex()),a=this.transformPoint(s.readVertex()),c=new A().subVectors(a,o);if(c.lengthSq()===0)return;const l=1e6,h=r?o.clone().add(c.normalize().multiplyScalar(l)):o.clone().sub(c.normalize().multiplyScalar(l)),u=a.clone().add(c.normalize().multiplyScalar(l));this.applyTraits(t),this.pushEntity(e,t.lines([h,u]))}}function a1(n,t){if(!(t!=null&&t.length))return;const e=Gi(t);return n!=null&&n>0&&e.length>=n?e.subarray(0,n):e}const c1="ASM_Data";function sa(n){return String(n).trim().toUpperCase()}function l1(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=sa(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[c1]??[]}}function h1(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=l1(n);if(r.ownerHandle&&r.hexChunks.length>0){const s=Gi(r.hexChunks);s.length>0&&(t[r.ownerHandle]=s)}}else n.skipToEndOfObject()}return{byOwnerHandle:t}}function Qd(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();u1(n,t,i)}}function u1(n,t,e){switch(e){case"$ACADVER":{const i=ae(n);i&&(t.version=i);break}case"$CECOLOR":{const i=st(n);t.cecolor.colorIndex=i??256;break}case"$ANGBASE":t.angbase=st(n)??0;break;case"$ANGDIR":t.angdir=st(n)??0;break;case"$AUNITS":{const i=st(n);i!=null&&(t.aunits=i);break}case"$AUPREC":{const i=st(n);i!=null&&(t.auprec=i);break}case"$LUNITS":{const i=st(n);i!=null&&(t.lunits=i);break}case"$LUPREC":{const i=st(n);i!=null&&(t.luprec=i);break}case"$UNITMODE":{const i=st(n);i!=null&&(t.unitmode=i);break}case"$MEASUREMENT":{const i=st(n);i!=null&&(t.measurement=i);break}case"$CELTYPE":t.celtype=ae(n)||mt;break;case"$CETRANSPARENCY":{const i=ae(n)||"ByLayer";vt.instance().setVar(T.CETRANSPARENCY,i,t);break}case"$CELTSCALE":t.celtscale=st(n)??1;break;case"$CELWEIGHT":{const i=st(n);i!=null&&(t.celweight=i);break}case"$LWDISPLAY":t.lwdisplay=(st(n)??0)!==0;break;case"$TILEMODE":t.tilemode=(st(n)??1)!==0;break;case"$PSLTSCALE":t.psltscale=(st(n)??1)!==0;break;case"$CMLSTYLE":case"CMLSTYLE":t.cmlstyle=ae(n)||Oe;break;case"$CMLSCALE":case"CMLSCALE":{const i=st(n);i!=null&&Number.isFinite(i)&&(t.cmlscale=i);break}case"$CMLEADERSTYLE":case"CMLEADERSTYLE":t.cmleaderstyle=ae(n)||Re;break;case"$HPLAYER":case"HPLAYER":t.hplayer=ae(n)||".";break;case"$LTSCALE":t.ltscale=st(n)??1;break;case"$EXTMAX":{const i=$l(n);i&&(t.extmax=i);break}case"$EXTMIN":{const i=$l(n);i&&(t.extmin=i);break}case"$INSUNITS":{const i=st(n);i!=null&&(t.insunits=i);break}case"$OSMODE":t.osmode=st(n)??0;break;case"$ORTHOMODE":t.orthomode=st(n)??0;break;case"$COMPAREHATCH":{const i=oi(st(n),zs,Vs);i!=null&&(t.comparehatch=i);break}case"$COMPARERCMARGIN":{const i=oi(st(n),js,Us);i!=null&&(t.comparercmargin=i);break}case"$COMPARETEXT":{const i=oi(st(n),Gs,Hs);i!=null&&(t.comparetext=i);break}case"$COMPARETOLERANCE":{const i=oi(st(n),Ws,$s);i!=null&&(t.comparetolerance=i);break}case"$PDMODE":t.pdmode=st(n)??0;break;case"$PDSIZE":t.pdsize=st(n)??0;break;case"$TEXTSTYLE":t.textstyle=ae(n)||lt;break;case"$DIMSTYLE":t.dimstyle=ae(n)||lt;break;case"$CLAYER":t.clayer=ae(n)||"0";break;case"$HANDSEED":{const i=ae(n);i&&t.initializeHandleSeed(i);break}default:d1(n);break}}function ae(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 st(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 $l(n){let t=0,e=0,i=0,r=!1;for(;!n.atEof;){const s=n.peekItem();if(!s)break;const o=Number(s.code);if(o===9||o===0)break;n.readItem();const a=Number(s.value);o===10?(t=a,r=!0):o===20?(e=a,r=!0):o===30&&(i=a,r=!0)}return r?new _(t,e,i):void 0}function d1(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 Jd{constructor(t){this._expression=t}get expression(){return this._expression}}var tg=(n=>(n[n.Cancel=0]="Cancel",n[n.Ok=1]="Ok",n))(tg||{});class no{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 Jd(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?g1(this._filterExpression,t):!0:!1}showEditor(){return 0}}function g1(n,t){const e=n.trim();return e?ql(e,"OR").some(r=>ql(r,"AND").every(o=>f1(o,t))):!0}function ql(n,t){const e=new RegExp(`\\s+${t}\\s+`,"i");return n.split(e).map(i=>i.trim()).filter(i=>i.length>0)}function f1(n,t){var o;const e=n.trim().match(/^([A-Za-z_]+)\s*(==|=)\s*"?(.*?)"?\s*$/);if(!e)return!1;const i=e[1].toUpperCase(),r=e[3],s=m1(r);switch(i){case"NAME":return p1(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 a=(o=t.color)==null?void 0:o.colorIndex;return a!=null&&String(a)===r}case"LINETYPE":return t.linetype.localeCompare(r,void 0,{sensitivity:"accent"})===0;default:return!1}}function p1(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 m1(n){const t=n.trim().toLowerCase();return t==="true"||t==="1"?!0:t==="false"||t==="0"?!1:null}class Be{constructor(t,e){this._root=t??Be.createDefaultRoot(),this._current=e===void 0?this._root:e}static createDefaultRoot(){const t=new no;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 Be(this._root,this._current)}}class eg extends no{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 io="ACAD_LAYERFILTERS",Hn="ACLYDICTIONARY";function ng(n){const t=Be.createDefaultRoot(),e=new Be(t,t),i=Kl(n,Hn),r=Kl(n,io);if(i){for(const[s,o]of Object.entries(i.entries)){const a=oa(n,o,s);a&&t.addNested(a)}return e}if(r)for(const[s,o]of Object.entries(r.entries)){const a=oa(n,o,s);a&&t.addNested(a)}return e}function ig(n){const t=[];for(const e of n.root.getNestedFilters())t.push(og(e));return{nodes:t}}function rg(n){const t=new fn;for(const e of n)t.add({code:e.code,value:e.value});return t}function y1(n){return n?n.toArray().map(t=>({code:Number(t.code),value:t.value})):[]}function Kl(n,t){let e;for(const i of n.dictionaries.values()){const r=i.entries[t];if(!r)continue;const s=n.dictionaries.get(Te(r));if(!s)continue;if(!(i.ownerObjectId?n.xrecords.has(Te(i.ownerObjectId)):!1))return s;e=s}return e}function oa(n,t,e){const i=n.xrecords.get(Te(t));if(!i)return;const r=sg(i.data,e),s=r.isIdFilter?new eg:new no;if(s.setAllowRename(!0),s.setName(r.name||e),!r.isIdFilter)s.setFilterExpression(r.filterExpression);else{const o=s;for(const a of r.layerIds)o.addLayerId(a)}for(const o of b1(n,i)){const a=oa(n,o.handle,o.key);a&&s.addNested(a)}return s}function b1(n,t){const e=[],i=new Set,r=Te(t.handle),s=t.extensionDictionaryId?Te(t.extensionDictionaryId):void 0,o=(a,c)=>{const l=Te(c);i.has(l)||(i.add(l),e.push({key:a,handle:c}))};for(const a of n.dictionaries.values()){const c=a.ownerObjectId?Te(a.ownerObjectId):void 0;if(!c||!(c===r||c===s))continue;const h=a.entries[Hn];if(h){const u=n.dictionaries.get(Te(h));if(u){for(const[d,g]of Object.entries(u.entries))o(d,g);continue}}for(const[u,d]of Object.entries(a.entries))u===Hn||u===io||o(u,d)}return e}function sg(n,t=""){const e=[],i=[];let r=0,s,o,a;for(const f of n){const p=Number(f.code),m=f.value;p===1&&typeof m=="string"?e.push(m):p===300&&typeof m=="string"?o=m:p===301&&typeof m=="string"?a=m:p===70||p===90?r=Number(m)||0:p===290||p===280?s=Number(m)===1:(p===330||p===340||p===350||p===360)&&m!=null&&String(m).length>0&&i.push(Te(String(m)))}const c=e[0],h=o||(c==="AcLyLayerFilter"||c==="AcLyLayerGroup"?void 0:c)||t,u=e[1]??"";let d=a??u;!a&&d&&d!=="*"&&!/==/.test(d)&&(d=`NAME=="${d}"`);const g=a!=null&&a.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 og(n){const t=n.isIdFilter(),e=ag(n),i=n.getNestedFilters().map(s=>og(s));return{key:n.name||(t?"Group":"Filter"),isIdFilter:t,data:e,children:i}}function ag(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 Te(n){return n.trim().toUpperCase()}class cg extends Et{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 lg extends Et{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 o=Number(r.value);switch(s){case 70:break;case 10:e&&this._boundaryVertices.push(new M(e.x,e.y)),e={x:o,y:0};break;case 20:e&&(e.y=o);break;case 210:this._clipBoundaryNormal=this._clipBoundaryNormal??new _,this._clipBoundaryNormal.x=o;break;case 220:this._clipBoundaryNormal&&(this._clipBoundaryNormal.y=o);break;case 230:this._clipBoundaryNormal&&(this._clipBoundaryNormal.z=o);break;case 11:this._clipBoundaryOrigin=this._clipBoundaryOrigin??new _,this._clipBoundaryOrigin.x=o;break;case 21:this._clipBoundaryOrigin&&(this._clipBoundaryOrigin.y=o);break;case 31:this._clipBoundaryOrigin&&(this._clipBoundaryOrigin.z=o);break;case 71:this._clipBoundaryDisplayEnabled=o!==0;break;case 72:this._frontClippingEnabled=o!==0;break;case 73:this._backClippingEnabled=o!==0;break;case 40:i||(this._frontClippingDistance=o,i=!0);break;case 41:this._backClippingDistance=o;break}}return e&&this._boundaryVertices.push(new M(e.x,e.y)),this}}class hg extends lg{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 ug extends Et{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 dg extends ug{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 ro extends Et{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 U(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 U(exports.AcCmColorMethod.ByLayer),this._textHeight=4,this._enableFrameText=!1,this._textAlignAlwaysLeft=!1,this._alignSpace=0,this._blockColor=new U(exports.AcCmColorMethod.ByBlock),this._blockScale=new A(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,So(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,So(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,So(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=fe(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=fe(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=fe(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 uc extends Et{constructor(){super(),this._styleName="STANDARD",this._flags=0,this._description="",this._fillColor=new U,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 o=Number(s.code),a=Number(s.value);switch(o){case 2:this.styleName=String(s.value);break;case 70:this.flags=a;break;case 3:this.description=String(s.value);break;case 51:this.startAngle=a;break;case 52:this.endAngle=a;break;case 71:r=a;break;case 49:{i={offset:a,color:new U,lineType:"BYLAYER"},i.color.colorIndex=256,e.push(i);break}case 62:i?i.color.colorIndex=a:this.fillColor.colorIndex=a;break;case 420:i?i.color.setRGBValue(a):this.fillColor.setRGBValue(a);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 o=t[s];if(o)return o;const a=new U;return a.colorIndex=256,{offset:0,color:a,lineType:"BYLAYER"}})}}class gg extends Et{constructor(){super(),this._isLoaded=!0,this._resolutionUnits=0,this._sourceFileName="",this._classVersion=0,this._imageSize=new M,this._pixelSize=new M(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 fg extends Et{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 pg=(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))(pg||{});class dc extends Et{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 fn;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 zt=n=>n?n.trim().toUpperCase():"";class mg{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 Hi;i.dxfIn(t),i.layoutName&&this._db.objects.layout.setAt(i.layoutName,i);break}case"IMAGEDEF":{const i=new gg;i.dxfIn(t),this._db.objects.imageDefinition.setAt(i.objectId,i);break}case"LAYER_FILTER":{const i=new hg;i.dxfIn(t),this._db.objects.layerFilter.setAt(i.objectId,i);break}case"LAYER_INDEX":{const i=new dg;i.dxfIn(t),this._db.objects.layerIndex.setAt(i.objectId,i);break}case"MLEADERSTYLE":{const i=new ro;i.dxfIn(t),this._db.objects.mleaderStyle.setAt(i.objectId,i);break}case"MLINESTYLE":{const i=new uc;i.dxfIn(t),this._db.objects.mlineStyle.setAt(i.styleName||i.objectId,i);break}case"GROUP":{const i=new cg;i.dxfIn(t);const r=i.name||i.objectId;this._db.objects.group.setAt(r,i);break}case"SORTENTSTABLE":{const i=new fg;i.dxfIn(t),this._db.objects.sortentsTable.setAt(i.objectId,i);break}case"DICTIONARY":{const i=this.readPersistDictionary(t);i.handle&&this._dictionaries.set(zt(i.handle),i);break}case"XRECORD":{const i=new dc;i.dxfIn(t);const r=zt(i.objectId);if(r){this._db.objects.xrecord.setAt(r,i);const s={handle:r,ownerObjectId:zt(i.ownerId),data:i.data?i.data.toArray().map(o=>({code:Number(o.code),value:o.value})):[]};i.extensionDictionary&&(s.extensionDictionaryId=zt(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,o]of Object.entries(t.entries)){const a=i[s.toUpperCase()];if(!a)continue;a.objectId=o,a.ownerId=t.handle,e.setAt(s,a);const c=this._dictionaries.get(zt(o));if(c)for(const[l,h]of Object.entries(c.entries)){const u=r.get(zt(h));u&&(a.getAt(l)||a.setAt(l,u))}}}collectLoadedObjectsByHandle(){const t=new Map,e=i=>{const r=zt(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 o=zt(String(r.value));i?(e.entries[i]=o,i=void 0):s===360&&!e.extensionDictionaryId&&(e.extensionDictionaryId=o);break}}}return e.handle=zt(e.handle),e.ownerObjectId=zt(e.ownerObjectId),e.extensionDictionaryId&&(e.extensionDictionaryId=zt(e.extensionDictionaryId)),e}finishLayerFilterTree(){if(this._dictionaries.size===0&&this._xrecords.size===0)return;const t=ng({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=ct.MODEL_SPACE_NAME.toUpperCase();for(const[,i]of this._db.objects.layout.entries()){if(i.layoutName==="Model"){const o=t.modelSpace;i.blockTableRecordId=o.objectId,o.layoutId=i.objectId;continue}const r=zt(i.objectId);let s=!1;for(const o of t.newIterator())if(zt(o.layoutId)===r){i.blockTableRecordId=o.objectId,s=!0;break}if(!s&&i.blockTableRecordId){const o=t.getIdAt(i.blockTableRecordId);o&&(o.layoutId=i.objectId)}else if(!s){for(const o of t.newIterator())if(o.isPaperSapce&&o.name.toUpperCase()!==e&&!o.layoutId){i.blockTableRecordId=o.objectId,o.layoutId=i.objectId;break}}}}}class yg{constructor(t,e={}){this._db=t,this._options=e,this._unknownEntityCount=0,this._unknownObjectCount=0,this._attributeMap=new Map,this._yieldGate=new Fs(this._options.yieldBudgetMs??bi)}get unknownEntityCount(){return this._unknownEntityCount}get unknownObjectCount(){return this._unknownObjectCount}async read(t){for(this._unknownEntityCount=0,this._unknownObjectCount=0,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}}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":Qd(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 mg(this._db);i.read(t),this._unknownObjectCount+=i.unknownObjectCount}await this.reportParseProgress(t);break;case"ACDSDATA":this.applyAcdsDataToSolids(h1(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 Ai&&i.set(sa(s.objectId),s);for(const r of e){const s=t.byOwnerHandle[r];if(!s)continue;const o=i.get(sa(r));o&&o.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=Gi(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 $i,i=>{i.name&&this._db.tables.layerTable.add(i)});break;case"LTYPE":this.readNamedTable(t,"LTYPE",()=>new qe,i=>{i.name&&this._db.tables.linetypeTable.add(i)});break;case"STYLE":this.readNamedTable(t,"STYLE",()=>new Qs,i=>{this._db.tables.textStyleTable.add(i)});break;case"DIMSTYLE":this.readNamedTable(t,"DIMSTYLE",()=>new Ht,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 $r,i=>{i.name&&this._db.tables.appIdTable.add(i)});break;case"VIEW":this.readNamedTable(t,"VIEW",()=>new qd,i=>{i.name&&this._db.tables.viewTable.add(i)});break;case"UCS":this.readNamedTable(t,"UCS",()=>new $d,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 o=String(s.value).toUpperCase();if(o==="ENDTAB"){t.readItem();break}if(o==="ENDSEC")break;if(o===e){t.readItem();const a=i();a.dxfIn(t),r(a);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 ct;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 o=t.peekItem();if(!o)break;if(Number(o.code)!==0){t.readItem();continue}const a=String(o.value).toUpperCase();if(a==="ENDBLK"){t.readItem(),t.skipToEndOfObject();break}if(a==="ENDSEC")break;if(t.readItem(),this.consumeSeqend(t,a)){i+=1,i>=e&&(i=0,await this.yieldAndReportProgress(t));continue}const c=Ma(t,a);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 _;let i="",r=0,s="",o,a;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:o=String(c.value);break;case 330:a=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:o,ownerId:a}}ensureBlockTableRecord(t){let e=t.name?this._db.tables.blockTable.getAt(t.name):void 0;e||(e=new ct,e.name=t.name||"*UNKNOWN",t.objectId&&(e.objectId=t.objectId),this._db.tables.blockTable.add(e)),e.origin.copy(t.origin);let i=ct.sanitizeImportedFlags(t.flags);return t.pathName&&(e.pathName=t.pathName,(i&(li.Xref|li.XrefOverlay))===0&&(i=i|li.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 o=String(s.value).toUpperCase();if(o==="ENDSEC"){t.readItem();break}if(t.readItem(),this.consumeSeqend(t,o)){i+=1,i>=e&&(i=0,await this.yieldAndReportProgress(t));continue}const a=Ma(t,o);a?this.acceptEntity(a,this.resolveEntityOwner(a,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(ct.PAPER_SPACE_NAME_PREFIX);if(r)return r}return e}acceptEntity(t,e){if(t instanceof Si){this.linkOrDeferAttribute(t,e);return}if(e.appendEntity(t),t instanceof xe){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 xe){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 xe)for(const r of e)i.appendAttributes(r)}this._attributeMap.clear()}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(qn)}}const cr=1,Io=18,lr=20,hr=98;class bg extends cc{constructor(t={}){super({useWorker:!1,...t})}async read(t,e,i={}){const{minimumChunkSize:r=10,progress:s}=i;this.progress=s;const o=async(c,l,h,u)=>{s&&await s(c,l,h,u)};await o(0,"START","START"),await o(cr,"PARSE","START"),await Eh(),e.beginEventBatch();let a=!0;try{const c=We.fromBuffer(t,{database:e}),l=t.byteLength;let h=cr;const d=await new yg(e,{entityBatchSize:Math.max(1,r||200),yieldBudgetMs:bi,totalBytes:l,onProgress:async m=>{const y=Math.min(Io-1,cr+Math.floor(m*(Io-cr)));y<=h||(h=y,await o(y,"PARSE","IN-PROGRESS"))}}).read(c);await o(Io,"PARSE","END",{unknownEntityCount:d.unknownEntityCount}),await o(lr,"ENTITY","START");const g=Math.max(1,r||200);let f=lr;const p=new Fs(bi);await e.endEventBatchChunked(g,async(m,y)=>{const b=y<=0?hr:Math.min(hr,lr+Math.floor(m/y*(hr-lr)));b>f&&(f=b,await o(b,"ENTITY","IN-PROGRESS")),await p.maybeYield()}),a=!1,await o(hr,"ENTITY","END"),await o(100,"END","END")}catch(c){throw a&&e.endEventBatch(),c}}async parse(t){return{model:null,data:{unknownEntityCount:0}}}}var di=(n=>(n.DXF="dxf",n.DWG="dwg",n))(di||{});class ge{constructor(){this.events={registered:new gt,unregistered:new gt},this._converters=new Map,this.register("dxf",new bg)}static createInstance(){return ge._instance==null&&(ge._instance=new ge),this._instance}static get instance(){return ge._instance||(ge._instance=new ge),ge._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 aa=50,_1=$.DEFAULT_CIRCLE_SIDES,x1=1e3;function qi(n){var e;const t=_g((e=n==null?void 0:n.context)==null?void 0:e.database);return{circleSides:t,maxSegments:t}}function _g(n){if(n!=null&&typeof n=="object"){const t=n.drawCircleSides;if(typeof t=="number"&&Number.isFinite(t))return $.resolveCircleSides(t)}return $.DEFAULT_CIRCLE_SIDES}function w1(n){var i,r,s;if(n==null||typeof n!="object")return $.DEFAULT_CIRCLE_SIDES;const t=n.tables,e=(s=(r=(i=t==null?void 0:t.viewportTable)==null?void 0:i.getActiveVport)==null?void 0:r.call(i))==null?void 0:s.circleSides;return typeof e!="number"||!Number.isFinite(e)?$.DEFAULT_CIRCLE_SIDES:$.resolveCircleSides(e)}const Tn=class Tn extends It{constructor(){super(),this._thickness=0,this._normal=new A(0,0,1),this._elevation=0,this._geo=new it}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 o=r<0?void 0:r,a=s<0?void 0:s,c={x:e.x,y:e.y,bulge:i,startWidth:o,endWidth:a};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 _(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return new j({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetIntersectCurves(){return ac(this._geo.vertices,this.closed,this._elevation,this._normal)}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 bt(t,o=>{if(o<i){ui(this._geo.vertices,o,e);return}if(!r||o>=i+s)return;const a=o-i;ui(this._geo.vertices,a,e),ui(this._geo.vertices,(a+1)%i,e)}),this}shouldIncludeSegmentMidpointGrips(){return this.getGripsMode()>=2}getGripsMode(){try{const t=vt.instance().getVar(T.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 o;const e=this._geo,i=this._elevation,r=this.getSegmentCount(),s=e.numberOfVertices;for(let a=0;a<r;a++){const c=[];Pi(e.getPointAt(a),e.getPointAt((a+1)%s),(o=e.vertices[a])==null?void 0:o.bulge,i,I.MidPoint,{x:0,y:0,z:0},c),t.push(...c)}}subGetOsnapPoints(t,e,i,r){var c;const s=this._geo,o=this._elevation,a=s.numberOfVertices;if(a!==0)switch(t){case I.EndPoint:for(let l=0;l<a;l++){const h=s.getPointAt(l);r.push(new _(h.x,h.y,o))}break;case I.MidPoint:case I.Nearest:case I.Perpendicular:case I.Tangent:{const l=this.closed?a:a-1,h=[];for(let u=0;u<l;u++){const d=[];Pi(s.getPointAt(u),s.getPointAt((u+1)%a),(c=s.vertices[u])==null?void 0:c.bulge,o,t,e,d),h.push(...d)}if(t===I.MidPoint)r.push(...h);else{const u=ie(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 _(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}}}]}]}}get directBatchPrimitive(){return this.hasRenderableWidth()?"area":"lineStrip"}subWorldDraw(t){const e=qi(t),i=this._geo.tessellate(e),r=this.createWidthProfile(e);if(r!=null){const o=A1(r,this.closed);if(o!=null){const a=t.subEntityTraits;return a.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},t.area(o)}}const s=[];return i.forEach(o=>s.push(new _().set(o.x,o.y,this.elevation))),t.lines(s)}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 o=s.bulge??0;o!==0&&t.writeDouble(42,o),s.identifier!=null&&t.writeInt32(91,s.identifier)}return t.writeVector3d(210,this.normal),this}dxfOutAs2dPolyline(t,e=!1){var r,s,o;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 a=0;a<this.numberOfVertices;++a){const c=this._geo.vertices[a];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(a).x,y:this.getPoint2dAt(a).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,(o=this.database)==null?void 0:o.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,o=this.normal.y,a=this.normal.z,c=-1,l=0,h=0,u=!1,d=0,g=-1,f=-1,p,m=0;const y=()=>{if(!u)return;const w=g<0?c:g,x=f<0?c:f;if(this.addVertexAt(m++,new M(l,h),d,w,x),p!=null){const S=this._geo.vertices[m-1];S&&(S.identifier=p)}u=!1,d=0,g=-1,f=-1,p=void 0};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const w=t.readItem();if(!w)break;const x=Number(w.code),S=Number(w.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:y(),l=S,h=0,u=!0;break;case 20:h=S;break;case 40:g=S;break;case 41:f=S;break;case 42:d=S;break;case 91:p=S;break;case 210:s=S;break;case 220:o=S;break;case 230:a=S;break}}y(),this.closed=e,this.elevation=i,this.thickness=r;const b=new A(s,o,a);return b.lengthSq()>0&&this.normal.copy(b.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 o=r??0;if(o!==(s??0))return;if(e==null)e=o;else if(e!==o)return}return e!=null&&e!==0?e:void 0}hasRenderableWidth(){const t=this._geo.vertices;for(let e=0;e<t.length;e++){const i=Math.max(0,t[e].startWidth??0),r=Math.max(0,t[e].endWidth??0);if(i>yt||r>yt)return!0}return!1}createWidthProfile(t){const e=this._geo.vertices,i=e.length;if(i<2)return null;const r=this.closed?i:i-1,s=[];let o=!1;for(let a=0;a<r;a++){const c=e[a],l=e[(a+1)%i],h=Math.max(0,c.startWidth??0),u=Math.max(0,c.endWidth??0);(h>yt||u>yt)&&(o=!0);const d=this.sampleSegment(c,l,t),g=d.length-1;for(let f=0;f<=g;f++){if(f===0&&s.length>0||this.closed&&a===r-1&&f===g)continue;const p=g>0?f/g:0;s.push({x:d[f].x,y:d[f].y,width:C1(h,u,p)})}}return o&&s.length>=2?s:null}sampleSegment(t,e,i){if(t.bulge&&Math.abs(t.bulge)>yt){const s=new $(t,e,t.bulge).tessellate(i);if(s.length>1)return s.map(o=>new M(o.x,o.y))}return[new M(t.x,t.y),new M(e.x,e.y)]}static from2dPoints(t,e){const i=new Tn;return t.forEach((r,s)=>i.addVertexAt(s,r)),i.closed=e,i}static fromGePolyline(t){const e=new Tn;return t.vertices.forEach((i,r)=>{e.addVertexAt(r,new M(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 o=0;o<s;o++){const a=this.getPoint2dAt(o),c=this.getPoint2dAt((o+1)%e),l=c.x-a.x,h=c.y-a.y,u=l*l+h*h;if(u===0)continue;const d=Math.max(0,Math.min(1,((t.x-a.x)*l+(t.y-a.y)*h)/u)),g=(t.x-a.x-d*l)**2+(t.y-a.y-d*h)**2;g<i&&(i=g,r=l*(t.y-a.y)-h*(t.x-a.x)>=0?1:-1)}return r}createOffsetCurve(t){const e=this._geo.offset(t);return e.length===0?null:Tn.fromGePolyline(e[0])}};Tn.typeName="Polyline";let Rt=Tn;function so(n,t,e){const i=K0(n,t,e);return i?Rt.fromGePolyline(i):null}const yt=1e-6,Zl=4,v1=.75;function A1(n,t){if(n.length<2)return null;if(t)return To(n,!0);const e=P1(n);if(e.length===1)return To(e[0],!1);const i=new oe;let r=!1;for(const s of e){const o=To(s,!1);if(o!=null){for(const a of o.loops)i.add(a);r=!0}}return r?i:null}function To(n,t){const e=L1(n,t);if(e.length<2)return null;const{left:i,right:r}=xg(e,t);if(Jl(i)<2||Jl(r)<2)return null;const s=new oe;if(t){const o=qr(i),a=qr(r);if(!Ii(o)||!Ii(a))return null;const c=Math.abs(Ei(o)),l=Math.abs(Ei(a)),[h,u]=c>=l?[o,a]:[a,o];return s.add(new it(h,!0)),s.add(new it(u,!0)),s}return k1(e)&&E1(s,e)||T1(s,i,r)?s:null}function P1(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 o=Ql(n[s]),a=i.get(o);if(a!=null&&s-a>1){const c=n.slice(e,s+1);c.length>=2&&t.push(c),e=a,i.clear();for(let l=e;l<=s;l++)i.set(Ql(n[l]),l);continue}i.set(o,s)}const r=n.slice(e);return r.length>=2&&t.push(r),t.length>0?t:[n]}function Ql(n){return`${n.x.toFixed(4)}:${n.y.toFixed(4)}`}function S1(n,t){const e=Math.max(n,t),i=Math.min(n,t);return e<=yt||e-i<=yt?!1:i/e<=v1}function k1(n){const t=n[0],e=n[n.length-1],i=Math.hypot(e.x-t.x,e.y-t.y);if(i<=yt)return!0;const r=Math.max(...n.map(s=>s.width));return r<=yt?!1:i<=r*4}function E1(n,t){const{left:e,right:i}=xg(t,!0),r=qr(e),s=qr(i);if(!Ii(r)||!Ii(s))return!1;const o=Math.abs(Ei(r)),a=Math.abs(Ei(s));if(!S1(o,a))return!1;const[c,l]=o>=a?[r,s]:[s,r];return n.add(new it(c,!0)),n.add(new it(l,!0)),!0}function xg(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],o=Math.max(0,s.width)/2;if(o<=yt){e[r]=null,i[r]=null;continue}const a=M1(n,r,t);if(a==null){e[r]=null,i[r]=null;continue}e[r]={x:s.x+a.x*o,y:s.y+a.y*o},i[r]={x:s.x-a.x*o,y:s.y-a.y*o}}return{left:e,right:i}}function I1(n,t,e,i,r){const s=[t,e,i,r];return Ii(s)?(n.add(new it(s,!0)),!0):!1}function T1(n,t,e){let i=!1;for(let r=0;r<t.length-1;r++){const s=t[r],o=t[r+1],a=e[r],c=e[r+1];s==null||o==null||a==null||c==null||I1(n,s,o,c,a)&&(i=!0)}return i}function Jl(n){return n.reduce((t,e)=>e==null?t:t+1,0)}function qr(n){return n.filter(t=>t!=null)}function L1(n,t){const e=[];if(n.forEach(i=>{const r=e[e.length-1];(!r||Math.abs(r.x-i.x)>yt||Math.abs(r.y-i.y)>yt||Math.abs(r.width-i.width)>yt)&&e.push(i)}),t&&e.length>1){const i=e[0],r=e[e.length-1];Math.abs(i.x-r.x)<=yt&&Math.abs(i.y-r.y)<=yt&&e.pop()}return e}function M1(n,t,e){const i=n.length,r=n[t],s=n[(t-1+i)%i],o=n[(t+1)%i];let a=th(r.x-s.x,r.y-s.y),c=th(o.x-r.x,o.y-r.y);if(e||(t===0&&(a=c),t===i-1&&(c=a)),a==null&&c==null)return null;if(a==null)return ur(c);if(c==null)return ur(a);const l=ur(a),h=ur(c),u=l.x+h.x,d=l.y+h.y,g=Math.hypot(u,d);if(g<=yt)return h;const f={x:u/g,y:d/g},p=Math.abs(f.x*h.x+f.y*h.y),m=p<=yt?Zl:Math.min(1/p,Zl);return{x:f.x*m,y:f.y*m}}function th(n,t){const e=Math.hypot(n,t);return e<=yt?null:{x:n/e,y:t/e}}function ur(n){return{x:-n.y,y:n.x}}function Ei(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 Ii(n){return n.length>=3&&Math.abs(Ei(n))>yt}function C1(n,t,e){return n+(t-n)*e}const O1={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:[]},wg={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 gi=(n=>(n[n.UserDefined=0]="UserDefined",n[n.Predefined=1]="Predefined",n[n.Custom=2]="Custom",n))(gi||{}),vg=(n=>(n[n.Normal=0]="Normal",n[n.Outer=1]="Outer",n[n.Ignore=2]="Ignore",n))(vg||{}),Ag=(n=>(n[n.HatchObject=0]="HatchObject",n[n.GradientObject=1]="GradientObject",n))(Ag||{}),Pg=(n=>(n[n.PreDefinedGradient=0]="PreDefinedGradient",n[n.UserDefinedGradient=1]="UserDefinedGradient",n))(Pg||{});const Lc=class Lc extends tt{constructor(){super(),this._areasFromLoopsCache=null,this._normal=new A(0,0,1),this._gradientAngle=0,this._elevation=0,this._geo=new oe,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()===an}set isSolidFill(t){this._isSolidFill=t}get color(){if(this.hasExplicitColor())return this.getEntityColor();const t=this.database,e=vt.instance().getVar(T.HPCOLOR,t);return e instanceof U&&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()===an,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 normal(){return this._normal}set normal(t){this._normal.copy(t),this._normal.lengthSq()>0&&this._normal.normalize()}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()===""?Zu: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=vt.instance();if(!this.hasExplicitLayer()){const i=e.getVar(T.HPLAYER,t);this.shouldUseSysVarOverride(i)&&(this.layer=i)}if(!this.hasExplicitTransparency()){const i=this.parseHpTransparency(e.getVar(T.HPTRANSPARENCY,t));i&&(this.transparency=i)}if(this._backgroundColorSet||(this._backgroundColor=this.parseHpBackgroundColor(e.getVar(T.HPBACKGROUNDCOLOR,t)),this._backgroundColorSet=!0),!this._patternNameSet){const i=e.getVar(T.HPNAME,t);this._patternName=typeof i=="string"?i:"",this._patternNameSet=!0}if(!this._patternAngleSet){const i=e.getVar(T.HPANG,t);this._patternAngle=typeof i=="number"&&Number.isFinite(i)?i:0,this._patternAngleSet=!0}if(this._patternScaleSet||(this._patternScale=this.normalizePatternScale(e.getVar(T.HPSCALE,t)),this._patternScaleSet=!0),!this._associativeSet){const i=e.getVar(T.HPASSOC,t);this._associative=typeof i=="number"?i!==0:!1,this._associativeSet=!0}if(this._hatchStyleSet||(this._hatchStyle=this.normalizeHatchStyle(e.getVar(T.HPISLANDDETECTION,t)),this._hatchStyleSet=!0),!this._patternDoubleSet){const i=e.getVar(T.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=vt.instance().getVar(T.HPNAME,t);return typeof e=="string"?e:this._patternName}shouldResolveColorFromCecolor(){return!1}getEffectivePatternAngle(){if(this._patternAngleSet)return this._patternAngle;const t=this.database,e=vt.instance().getVar(T.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(vt.instance().getVar(T.HPSCALE,t))}getEffectiveAssociative(){if(this._associativeSet)return this._associative;const t=this.database,e=vt.instance().getVar(T.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 U)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 U.fromString(t)}parseHpTransparency(t){if(t instanceof pt)return t.clone();if(!this.shouldUseSysVarOverride(t))return;const e=t.trim();if(/^bylayer$/i.test(e)||/^byblock$/i.test(e))return pt.fromString(e);const i=Number(e);if(Number.isInteger(i)&&i>=0&&i<=90){const r=new pt;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===an){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 o=wg.patterns.find(a=>a.name.trim().toUpperCase()===r);if(!o){this._definitionLinesAutoGenerated&&(this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1);return}this._definitionLines=o.lines.map(a=>({angle:a.angle*Math.PI/180,base:{x:a.originX*s,y:a.originY*s},offset:{x:a.deltaX*s,y:a.deltaY*s},dashLengths:a.dashes.map(c=>c*s)})),this._definitionLinesAutoGenerated=!0,this._definitionLinesPatternName=r,this._definitionLinesPatternScale=s}add(t){this._geo.add(t),this.invalidateAreasFromLoopsCache()}invalidateAreasFromLoopsCache(){this._areasFromLoopsCache=null}buildAreasFromLoops(){if(this._areasFromLoopsCache!=null)return this._areasFromLoopsCache;const t=this._geo.loops;if(t.length===0)return this._areasFromLoopsCache=[],this._areasFromLoopsCache;if(t.length===1)return this._areasFromLoopsCache=[this._geo],this._areasFromLoopsCache;const e=this._geo.buildHierarchy(),i=[],r=(s,o)=>{if(s.index>=0&&o%2===0){const a=new oe;a.add(t[s.index]),s.children.forEach(c=>{c.index>=0&&a.add(t[c.index])}),i.push(a)}s.children.forEach(a=>r(a,o+1))};return e.children.forEach(s=>r(s,0)),this._areasFromLoopsCache=i.length>0?i:[this._geo],this._areasFromLoopsCache}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 j;const e=new j;return t.forEach(i=>{const r=i.box;e.union(new j().setFromPoints([At({x:r.min.x,y:r.min.y,z:this._elevation},this._normal),At({x:r.max.x,y:r.min.y,z:this._elevation},this._normal),At({x:r.max.x,y:r.max.y,z:this._elevation},this._normal),At({x:r.min.x,y:r.max.y,z:this._elevation},this._normal)]))}),e}subGetIntersectCurves(){return Yb(this._geo.loops,this._elevation,this._normal)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"pattern",properties:[{name:"patternType",type:"enum",editable:!0,options:[{label:gi[0],value:0},{label:gi[1],value:1},{label:gi[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:(bt(t,i=>{this.moveBoundaryGripPointAt(i,e)}),this.invalidateAreasFromLoopsCache(),this)}collectBoundaryGripPoints(){const t=new Array,e=this._elevation,i=new Set,r=s=>{const o=`${s.x},${s.y},${s.z??0}`;i.has(o)||(i.add(o),t.push(new _(s.x,s.y,s.z??e)))};return this._geo.loops.forEach(s=>{if(s instanceof it){const o=s.numberOfVertices;for(let a=0;a<o;a++){const c=s.getPointAt(a);r({x:c.x,y:c.y,z:e})}return}s.curves.forEach(o=>{if(o instanceof Vt)r({x:o.startPoint.x,y:o.startPoint.y,z:e}),r({x:o.endPoint.x,y:o.endPoint.y,z:e});else if(o instanceof $)r({x:o.startPoint.x,y:o.startPoint.y,z:e}),r({x:o.endPoint.x,y:o.endPoint.y,z:e}),r({x:o.midPoint.x,y:o.midPoint.y,z:e});else if(o instanceof Ie){r({x:o.startPoint.x,y:o.startPoint.y,z:e}),r({x:o.endPoint.x,y:o.endPoint.y,z:e});const a=o.getPoint(.5);r({x:a.x,y:a.y,z:e})}})}),t}moveBoundaryGripPointAt(t,e){let i=0;const r=this._elevation,s=new Set,o=(a,c)=>{const l=`${a.x},${a.y},${a.z??0}`;s.has(l)||(s.add(l),i===t&&c(),i++)};this._geo.loops.forEach(a=>{if(a instanceof it){const c=a.numberOfVertices;for(let l=0;l<c;l++){const h=a.vertices[l];h&&o({x:h.x,y:h.y,z:r},()=>{ui(a.vertices,l,e)})}return}a.curves.forEach(c=>{if(c instanceof Vt)o({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>{c.startPoint.x+=e.x,c.startPoint.y+=e.y}),o({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>{c.endPoint.x+=e.x,c.endPoint.y+=e.y});else if(c instanceof $)o({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"start",e)),o({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"end",e)),o({x:c.midPoint.x,y:c.midPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"mid",e));else if(c instanceof Ie){o({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"start",e)),o({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"end",e));const l=c.getPoint(.5);o({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,o=new $(t.startPoint,{x:s.x+i.x,y:s.y+i.y},t.endPoint);t.center=o.center,t.radius=o.radius,t.startAngle=o.startAngle,t.endAngle=o.endAngle,t.clockwise=o.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),o=s.x+i.x-t.center.x,a=s.y+i.y-t.center.y,c=Math.hypot(s.x-t.center.x,s.y-t.center.y),l=Math.hypot(o,a);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,o=[];if(this._geo.loops.forEach(a=>{var c;if(a instanceof it){const l=a,h=l.numberOfVertices;if(h===0)return;switch(t){case I.EndPoint:for(let u=0;u<h;u++){const d=l.getPointAt(u);r.push(new _(d.x,d.y,s))}break;case I.MidPoint:case I.Nearest:case I.Perpendicular:case I.Tangent:{const u=a.closed?h:h-1;for(let d=0;d<u;d++){const g=[];Pi(l.getPointAt(d),l.getPointAt((d+1)%h),(c=l.vertices[d])==null?void 0:c.bulge,s,t,e,g),t===I.MidPoint?r.push(...g):o.push(...g)}break}}return}a.curves.forEach(l=>{if(l instanceof Vt){const h=[];Pi(l.startPoint,l.endPoint,void 0,s,t,e,h),t===I.MidPoint?r.push(...h):t===I.Nearest||t===I.Perpendicular||t===I.Tangent?o.push(...h):r.push(...h)}else if(l instanceof $)switch(t){case I.EndPoint:r.push(new _(l.startPoint.x,l.startPoint.y,s),new _(l.endPoint.x,l.endPoint.y,s));break;case I.MidPoint:r.push(new _(l.midPoint.x,l.midPoint.y,s));break;case I.Nearest:{const h=l.nearestPoint({x:e.x,y:e.y});o.push(new _(h.x,h.y,s));break}case I.Perpendicular:{l.perpendicularPoints({x:e.x,y:e.y}).forEach(u=>o.push(new _(u.x,u.y,s)));break}case I.Tangent:{l.tangentPoints({x:e.x,y:e.y}).forEach(u=>o.push(new _(u.x,u.y,s)));break}}else if(l instanceof Ie)switch(t){case I.EndPoint:r.push(new _(l.startPoint.x,l.startPoint.y,s),new _(l.endPoint.x,l.endPoint.y,s));break;case I.MidPoint:{const h=l.getPoint(.5);r.push(new _(h.x,h.y,s));break}case I.Nearest:{const h=l.nearestPoint({x:e.x,y:e.y});o.push(new _(h.x,h.y,s));break}case I.Perpendicular:{l.perpendicularPoints({x:e.x,y:e.y}).forEach(u=>o.push(new _(u.x,u.y,s)));break}case I.Tangent:{l.tangentPoints({x:e.x,y:e.y}).forEach(u=>o.push(new _(u.x,u.y,s)));break}}})}),(t===I.Nearest||t===I.Perpendicular||t===I.Tangent)&&o.length>0){const a=ie(e,o);r.length=0,a&&r.push(a)}}get directBatchPrimitive(){return!this.isSolidFill||this.isGradient||this.buildAreasFromLoops().length>1?null:"area"}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(o=>t.area(o));return t.group(r)}transformBy(t){const e=t.elements,i=new zi(e[0],e[4],e[12],e[1],e[5],e[13],0,0,1);this._geo.transform(i),this.invalidateAreasFromLoopsCache(),this._elevation=new _(0,0,this._elevation).applyMatrix4(t).z,this._normal.transformDirection(t),this._normal.lengthSq()>0&&this._normal.normalize();const r=new _(1,0,0).applyMatrix4(t),s=new _().applyMatrix4(t),o=new _(r).sub(s);if(o.length()>0){const a=Math.atan2(o.y,o.x);this._patternAngle=this.getEffectivePatternAngle()+a,this._gradientAngle+=a,this._patternScale=this.getEffectivePatternScale()*o.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,this.normal),t.writeString(2,i||(this.isSolidFill?an:Ku)),t.writeInt16(70,this.isSolidFill?1:0),t.writeInt16(71,this.getEffectiveAssociative()?1:0),t.writeInt16(91,e.length),e.forEach((o,a)=>{const c=a===0;if(o instanceof it){const l=o.vertices,h=l.some(d=>(d.bulge??0)!==0);t.writeInt16(92,2),t.writeInt16(72,h?1:0),t.writeInt16(73,o.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(o instanceof On){const l=c?1:0;t.writeInt16(92,l),t.writeInt16(93,o.numberOfEdges);for(const h of o.curves){if(h instanceof Vt){t.writeInt16(72,1),t.writePoint2d(10,h.startPoint),t.writePoint2d(11,h.endPoint);continue}if(h instanceof $){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 Ie){t.writeInt16(72,3),t.writePoint2d(10,h.center);const u=new M(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 Ut){const u=h.knots,d=h.controlPoints,g=h.weights,f=h.fitPoints,p=g.some(m=>m!==1);t.writeInt16(72,4),t.writeInt16(94,h.degree),t.writeInt16(73,p?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),p&&t.writeDouble(42,g[y]??1)}),t.writeInt16(97,(f==null?void 0:f.length)??0),f==null||f.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(o=>{t.writeAngle(53,o.angle),t.writeDouble(43,o.base.x),t.writeDouble(44,o.base.y),t.writeDouble(45,o.offset.x),t.writeDouble(46,o.offset.y),t.writeInt16(79,o.dashLengths.length),o.dashLengths.forEach(a=>t.writeDouble(49,a))}),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 o=this._gradientStartColor,a=this._gradientEndColor,c=o!=null&&a!=null?2:o!=null||a!=null?1:0;t.writeInt16(453,c);const l=(h,u)=>{t.writeDouble(463,h);const d=ue.getIndexByColor(u);d!=null&&t.writeInt16(63,d),t.writeInt32(421,u)};o!=null&&l(0,o),a!=null&&l(1,a),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.normal.x,r=this.normal.y,s=this.normal.z,o=this.patternAngle*180/Math.PI,a=0,c=!1,l=!1,h=!1,u=[],d=null,g=[],f=null,p="type",m=0,y=!1,b=null,w=!1,x=0,S;const P=G=>{x===0?this.gradientStartColor=G:this.gradientEndColor=G,x++,S=void 0},v=()=>{if(S==null)return;const G=ue.getColorByIndex(S);G!=null?P(G):S=void 0},k=()=>{d&&(u.push(d),d=null)},E=()=>{if(k(),u.length===0)return;const G=new it;G.closed=h,u.forEach((rt,L)=>{G.addVertexAt(L,{x:rt.x,y:rt.y,bulge:rt.bulge??0})}),this.add(G),u=[]},O=()=>{if(g.length===0)return;const G=[];for(const L of g)if(L.kind==="line")G.push(new Vt({x:L.sx,y:L.sy},{x:L.ex,y:L.ey}));else if(L.kind==="arc")G.push(new $({x:L.cx,y:L.cy},L.radius,L.startDeg*Math.PI/180,L.endDeg*Math.PI/180,!L.isCcw));else if(L.kind==="ellipse"){const q=Math.hypot(L.mx,L.my),dt=q*L.ratio;let B=L.startDeg*Math.PI/180,Ct=L.endDeg*Math.PI/180;const ot=Math.atan2(L.my,L.mx);L.isCcw||(B=Math.PI*2-B,Ct=Math.PI*2-Ct),G.push(new Ie({x:L.cx,y:L.cy,z:0},q,dt,B,Ct,!L.isCcw,ot))}else{const q=Ut.fromDwgSplineEdge({degree:L.degree,numberOfControlPoints:L.controlPoints.length,numberOfKnots:L.knots.length,numberOfFitData:L.fitPoints.length,knots:L.knots,controlPoints:L.controlPoints.map(dt=>({x:dt.x,y:dt.y,z:0,weight:L.rational?dt.weight??1:void 0})),fitDatum:L.fitPoints.map(dt=>({x:dt.x,y:dt.y,z:0})),startTangent:null,endTangent:null});q&&G.push(q)}const rt=On.buildFromEdges(G);rt.length===0&&G.length>0?this.add(new On(G)):rt.forEach(L=>this.add(L)),g=[],f=null},N=()=>{c?E():O()},R=()=>{f&&(g.push(f),f=null)},nt=()=>{R(),N(),m=Math.max(0,m-1),m===0&&(w=!0)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const G=t.readItem();if(!G)break;const rt=Number(G.code),L=Number(G.value);if(y||w){switch(rt){case 75:this.hatchStyle=L,w=!0;break;case 76:this.patternType=L;break;case 52:o=L;break;case 41:this.patternScale=L;break;case 77:break;case 78:y=!0;break;case 53:b&&this.definitionLines.push(b),b={angle:L*Math.PI/180,base:{x:0,y:0},offset:{x:0,y:0},dashLengths:[]};break;case 43:b&&(b.base.x=L);break;case 44:b&&(b.base.y=L);break;case 45:b&&(b.offset.x=L);break;case 46:b&&(b.offset.y=L);break;case 79:break;case 49:b&&b.dashLengths.push(L);break;case 47:this.pixelSize=L;break;case 99:break;case 450:this.hatchObjectType=L,this.gradientStartColor=void 0,this.gradientEndColor=void 0,x=0,S=void 0;break;case 451:break;case 452:this.gradientOneColorMode=L!==0;break;case 453:break;case 460:this.gradientAngle=L;break;case 461:this.gradientShift=L;break;case 462:this.shadeTintValue=L;break;case 463:v();break;case 63:S=L;break;case 421:P(L);break;case 470:v(),this.gradientName=String(G.value);break}continue}switch(rt){case 10:c||f&&f.kind!=="line"&&f.kind!=="arc"&&f.kind!=="ellipse"&&f.kind,m>0&&c?(k(),d={x:L,y:0}):(f==null?void 0:f.kind)==="line"&&p==="type"?f.sx=L:(f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse"?f.cx=L:(f==null?void 0:f.kind)==="spline"&&f.controlPoints.push({x:L,y:0});break;case 20:m>0&&c&&d?d.y=L:(f==null?void 0:f.kind)==="line"&&p==="type"?f.sy=L:(f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse"?f.cy=L:(f==null?void 0:f.kind)==="spline"&&f.controlPoints.length>0&&(f.controlPoints[f.controlPoints.length-1].y=L);break;case 30:m<=0&&!w&&(e=L);break;case 2:this.patternName=String(G.value);break;case 70:this.isSolidFill=L!==0;break;case 71:this.associative=L!==0;break;case 91:m=L;break;case 92:m>0&&(u.length>0||g.length>0||f)&&(R(),N()),a=L,c=(a&2)!==0,l=!1,h=!1,u=[],g=[],f=null,p="type";break;case 72:c?l=L!==0:(R(),L===1?(f={kind:"line",sx:0,sy:0,ex:0,ey:0},p="type"):L===2?f={kind:"arc",cx:0,cy:0,radius:0,startDeg:0,endDeg:0,isCcw:!0}:L===3?f={kind:"ellipse",cx:0,cy:0,mx:0,my:0,ratio:1,startDeg:0,endDeg:0,isCcw:!0}:L===4?f={kind:"spline",degree:3,rational:!1,closed:!1,knots:[],controlPoints:[],fitPoints:[],expectedKnots:0,expectedControls:0,expectedFits:0,fitCountSeen:!1}:f=null);break;case 73:c?h=L!==0:(f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse"?f.isCcw=L!==0:(f==null?void 0:f.kind)==="spline"&&(f.rational=L!==0);break;case 74:(f==null?void 0:f.kind)==="spline"&&(f.closed=L!==0);break;case 93:break;case 42:c&&l&&d?d.bulge=L:(f==null?void 0:f.kind)==="spline"&&f.rational&&f.controlPoints.length>0&&(f.controlPoints[f.controlPoints.length-1].weight=L);break;case 11:(f==null?void 0:f.kind)==="line"?(f.ex=L,p="line-end"):(f==null?void 0:f.kind)==="ellipse"?f.mx=L:(f==null?void 0:f.kind)==="spline"&&f.fitPoints.push({x:L,y:0});break;case 21:(f==null?void 0:f.kind)==="line"?f.ey=L:(f==null?void 0:f.kind)==="ellipse"?f.my=L:(f==null?void 0:f.kind)==="spline"&&f.fitPoints.length>0&&(f.fitPoints[f.fitPoints.length-1].y=L);break;case 40:(f==null?void 0:f.kind)==="arc"?f.radius=L:(f==null?void 0:f.kind)==="ellipse"?f.ratio=L:(f==null?void 0:f.kind)==="spline"&&f.knots.push(L);break;case 50:((f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse")&&(f.startDeg=L);break;case 51:((f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse")&&(f.endDeg=L);break;case 94:(f==null?void 0:f.kind)==="spline"&&(f.degree=L);break;case 95:(f==null?void 0:f.kind)==="spline"&&(f.expectedKnots=L);break;case 96:(f==null?void 0:f.kind)==="spline"&&(f.expectedControls=L);break;case 97:if((f==null?void 0:f.kind)==="spline"&&!f.fitCountSeen&&(f.controlPoints.length>0||f.knots.length>0)){f.expectedFits=L,f.fitCountSeen=!0;break}nt();break;case 75:R(),N(),m=0,w=!0,this.hatchStyle=L;break;case 210:i=L;break;case 220:r=L;break;case 230:s=L;break}}f&&(g.push(f),f=null),N(),b&&this.definitionLines.push(b),v(),this.elevation=e;const et=new A(i,r,s);return et.lengthSq()>0&&(this.normal=et),this.patternAngle=o*Math.PI/180,this}};Lc.typeName="Hatch";let Ti=Lc;class Sg{constructor(t){this.db=t}createDefaultLayer(){const t=new U;return t.colorIndex=7,this.db.tables.layerTable.add(new $i({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new qe({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new qe({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new qe({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new Qs({name:lt,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new Ht({name:lt,dimtxsty:lt}))}createDefaultLayout(){const t=new Hi;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 Ti;e.patternName=an;const i=new On;i.add(new Vt({x:0,y:0},{x:-1,y:.125})),i.add(new Vt({x:-1,y:.125},{x:-1,y:-.125})),i.add(new Vt({x:-1,y:-.125},{x:0,y:0})),e.add(i);const r=new ct;r.name="_CAXARROW",r.appendEntity(e),this.db.tables.blockTable.add(r)}}}const ca=Math.PI/200;class kg{constructor(t){this.database=t}formatLength(t,e){const i=this.createContext(e);return bn(t,i)}formatPoint2d(t,e){const i=this.createContext(e);return`${bn(t.x,i)}, ${bn(t.y,i)}`}formatPoint3d(t,e){const i=this.createContext(e);return`${bn(t.x,i)}, ${bn(t.y,i)}, ${bn(t.z,i)}`}formatAngle(t,e){const i=this.createContext(e),s=(e==null?void 0:e.applyAngbaseAngdir)??!0?N1(t,this.database.angbase,this.database.angdir):C.normalizeAngle(t);return R1(s,i)}createContext(t){return{lunits:this.database.lunits,luprec:Li(this.database.luprec),insunits:this.database.insunits,unitmode:this.database.unitmode,measurement:this.database.measurement,aunits:this.database.aunits,auprec:Li(this.database.auprec),showUnits:(t==null?void 0:t.showUnits)??!1,showApproximate:(t==null?void 0:t.showApproximate)??!1}}}function bn(n,t){let e;switch(t.lunits){case ut.Scientific:e=Lo(U1(n,t.luprec),t);break;case ut.Engineering:e=G1(n,t);break;case ut.Architectural:e=H1(n,t);break;case ut.Fractional:e=Lo(W1(n,t),t);break;case ut.WindowsDesktop:case ut.Decimal:default:e=Lo(ei(n,t.luprec),t)}return Eg(e,B1(n,t),t)}function R1(n,t){let e;switch(t.aunits){case Bt.DegreesMinutesSeconds:e=Lg(n,t);break;case Bt.Gradians:e=K1(n,t);break;case Bt.Radians:e=q1(n,t);break;case Bt.SurveyorsUnits:e=Z1(n,t);break;case Bt.DecimalDegrees:default:e=$1(n,t)}return Eg(e,F1(n,t),t)}function N1(n,t,e){let i=n-t;return e===1&&(i=-i),C.normalizeAngle(i)}function gc(n){const t=n.showUnits?'"':"";return n.unitmode===1?{feetInchSeparator:"",fractionSeparator:"-",inchSuffix:t}:{feetInchSeparator:"-",fractionSeparator:" ",inchSuffix:t}}function Li(n,t=0,e=8){return Number.isFinite(n)?Math.max(t,Math.min(e,Math.round(n))):t}function ti(n){return Object.is(n,-0)?0:n}function Eg(n,t,e){return!e.showApproximate||!t?n:`~ ${n}`}function B1(n,t){if(!Number.isFinite(n))return!1;const e=X1(n,t);return fc(n,e)}function F1(n,t){if(!Number.isFinite(n))return!1;if(t.aunits===Bt.SurveyorsUnits)return D1(n,t.auprec);const e=Y1(n,t);return fc(n,e)}function D1(n,t){const i=((90-C.radToDeg(n))%360+360)%360,r=Mg(i),s=Math.min(Math.abs(i-r.base),Math.abs(r.base+90-i)),o=C.degToRad(s),a=Ig(o,t);return fc(o,a)}function X1(n,t){const e=ti(n);switch(t.lunits){case ut.Scientific:return z1(e,t.luprec);case ut.Engineering:case ut.Architectural:case ut.Fractional:return V1(e,t);case ut.WindowsDesktop:case ut.Decimal:default:return Nn(e,t.luprec)}}function Y1(n,t){const e=ti(n);switch(t.aunits){case Bt.DegreesMinutesSeconds:return Ig(e,t.auprec);case Bt.Gradians:return Nn(e/ca,t.auprec)*ca;case Bt.Radians:return Nn(e,t.auprec);case Bt.DecimalDegrees:default:return C.degToRad(Nn(C.radToDeg(e),t.auprec))}}function Nn(n,t){if(!Number.isFinite(n))return 0;const e=10**t;return Math.round(ti(n)*e)/e}function z1(n,t){if(!Number.isFinite(n))return 0;const e=ti(n);if(e===0)return 0;const i=e.toExponential(t);return Number(i)}function V1(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===ut.Architectural||t.lunits===ut.Fractional){const o=1<<Li(t.luprec,0,8),a=j1(s,o);return e*(r*12+a)}return e*(r*12+Nn(s,t.luprec))}function j1(n,t){const e=Math.floor(n),i=n-e,r=Math.round(i*t);return r>=t?e+1:e+r/t}function Ig(n,t){const e=C.radToDeg(n),i=e<0?-1:1,r=Math.abs(e),s=Math.floor(r),o=(r-s)*60,a=Math.floor(o),c=Nn((o-a)*60,t),l=s+a/60+c/3600;return C.degToRad(i*l)}function fc(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 ei(n,t){if(!Number.isFinite(n))return"0";const e=ti(n);if(Number.isInteger(e)&&t===0)return String(e);const r=e.toFixed(t).replace(/\.?0+$/,"");return r===""||r==="-"?"0":r}function U1(n,t){if(!Number.isFinite(n))return"0";const e=ti(n);if(e===0)return"0";const i=e.toExponential(t).match(/^(.+)e([+-])(\d+)$/i);if(!i)return"0";const[,r,s,o]=i,a=o.length<2?o.padStart(2,"0"):o;return`${r}E${s}${a}`.toUpperCase()}function G1(n,t){if(!Number.isFinite(n))return"0";const e=gc(t),i=n<0?"-":"",r=Math.abs(n),s=Math.floor(r/12),o=r-s*12,a=ei(o,t.luprec);return s===0?`${i}${a}${e.inchSuffix}`:`${i}${s}'${e.feetInchSeparator}${a}${e.inchSuffix}`}function H1(n,t){if(!Number.isFinite(n))return"0";const e=gc(t),i=n<0?"-":"",r=Math.abs(n),s=Math.floor(r/12),o=r-s*12,a=1<<Li(t.luprec,0,8),c=Tg(o,a,e.fractionSeparator);return s===0?`${i}${c}${e.inchSuffix}`:`${i}${s}'${e.feetInchSeparator}${c}${e.inchSuffix}`}function W1(n,t){if(!Number.isFinite(n))return"0";const e=gc(t),i=n<0?"-":"",r=Math.abs(n),s=1<<Li(t.luprec,0,8);return`${i}${Tg(r,s,e.fractionSeparator)}`}function Tg(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 o=e_(s,t);s/=o;const a=t/o,c=`${s}/${a}`;return i===0?c:`${i}${e}${c}`}function $1(n,t){const e=C.radToDeg(n);return`${ei(e,t.auprec)}${t.showUnits?"°":""}`}function q1(n,t){return`${ei(n,t.auprec)}${t.showUnits?" rad":""}`}function K1(n,t){const e=n/ca;return`${ei(e,t.auprec)}${t.showUnits?"g":""}`}function Lg(n,t){const e=C.radToDeg(n),i=e<0?"-":"",r=Math.abs(e),s=Math.floor(r),o=(r-s)*60,a=Math.floor(o),c=(o-a)*60,l=ei(c,t.auprec),h=t.showUnits?'"':"";return`${i}${s}d${a}'${l}${h}`}function Z1(n,t){const i=((90-C.radToDeg(n))%360+360)%360,r=Mg(i),s=Math.min(Math.abs(i-r.base),Math.abs(r.base+90-i)),a=Lg(C.degToRad(s),t).replace(/^-/,"");return`${r.prefix} ${a} ${r.suffix}`.trim()}function Mg(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 Lo(n,t){if(!t.showUnits||t.lunits===ut.Engineering||t.lunits===ut.Architectural)return n;const e=Q1(t.insunits,t.measurement);return e?`${n}${e}`:n}function Q1(n,t){return n===at.Undefined?t===0?'"':" mm":Ub(n)?J1(n):Gb(n)?t_(n):""}function J1(n){switch(n){case at.Millimeters:return" mm";case at.Centimeters:return" cm";case at.Meters:return" m";case at.Kilometers:return" km";case at.Decimeters:return" dm";case at.Microns:return" µm";case at.Nanometers:return" nm";default:return""}}function t_(n){switch(n){case at.Inches:case at.Microinches:case at.Mils:case at.USSurveyInch:return'"';case at.Feet:case at.USSurveyFeet:return"'";case at.Miles:case at.USSurveyMile:return" mi";case at.Yards:case at.USSurveyYard:return" yd";default:return""}}function e_(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 Qt extends Et{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 jn(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 ke extends Et{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 jn([...this._recordsByName.values(),...this._unnamedRecords]):new jn(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 Cg extends ke{constructor(t){super(t)}get modelSpace(){let t=this.getAt(ct.MODEL_SPACE_NAME);return t||(t=new ct,t.name=ct.MODEL_SPACE_NAME,this.add(t)),t}getEntityById(t){const e=this.database.getObjectById(t);if(e instanceof tt)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(!e)return"";if(ct.isModelSapceName(e))return ct.MODEL_SPACE_NAME;if(ct.isPaperSapceName(e)){const i=ct.PAPER_SPACE_NAME_PREFIX,r=e.substring(i.length);return i+r}return super.normalizeName(e)}}const Og="DwgConverterLicenseError",n_=["evaluation of @mlight-cad/dwg-converter has expired"],i_=["invalid @mlight-cad/dwg-converter license key"];function Rg(n){return n==="license_expired"||n==="license_invalid"}function pc(n){const t=n.toLowerCase();if(n_.some(e=>t.includes(e)))return"license_expired";if(i_.some(e=>t.includes(e)))return"license_invalid"}function Ng(n){return pc(n)??"license_invalid"}const Nt=class Nt extends Error{constructor(t,e,i){super(t),this.name="AcDbOpenDatabaseError",this.code=e,this.stage=i==null?void 0:i.stage,this.cause=i==null?void 0:i.cause}static isLicenseErrorCode(t){return Rg(t)}static isWorkerOutOfMemoryMessage(t){const e=t.toLowerCase();return Nt.WORKER_OOM_PATTERNS.some(i=>e.includes(i))}static classifyThrownError(t){if(t instanceof Error){const i=Nt.readStructuredCode(t);if(i)return i;if(t.name===Og)return Ng(t.message)}const e=t instanceof Error?t.message:String(t);return Nt.classifyWorkerErrorMessage(e)}static classifyWorkerErrorMessage(t){const e=pc(t);return e||(Nt.isWorkerOutOfMemoryMessage(t)?"worker_oom":t.toLowerCase().includes("timed out")?"worker_timeout":"worker_error")}static from(t,e){if(t instanceof Nt)return t;const i=t instanceof Error?t.message:String(t),r=Nt.classifyThrownError(t);return new Nt(i,r,{stage:e,cause:t})}static fromTask(t){const e=t.task.name;return Nt.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=Nt.mapWorkerResultCode(t.errorCode,t.error);throw new Nt(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";case"license_expired":return"license_expired";case"license_invalid":return"license_invalid";default:return Nt.classifyWorkerErrorMessage(e??"")}}static readStructuredCode(t){const e=t.code;if(typeof e=="string")switch(e){case"license_expired":case"license_invalid":case"worker_oom":case"worker_timeout":case"worker_error":case"parse_failed":case"font_load_failed":case"fetch_failed":case"unknown":return e;default:return}}};Nt.WORKER_OOM_PATTERNS=["out of memory","data cannot be cloned","allocation failed","memory access out of bounds"];let Mi=Nt;class Bg extends ke{constructor(t){super(t)}}class Fg extends ke{constructor(t){super(t)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class Dg extends ke{constructor(t){super(t)}}class Ci extends ke{constructor(t){super(t)}static normalizeFontFileName(t){if(!t)return;const e=t.lastIndexOf(".");return e>=0?t.substring(0,e).toLowerCase():t.toLowerCase()}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(lt),i("STANDARD");for(const r of e){const s=this.getAt(r);if(s)return s;const o=r.toUpperCase();for(const a of this.newIterator())if(a.name.toUpperCase()===o)return a}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=Ci.normalizeFontFileName(e.fileName);i&&t.add(i);const r=Ci.normalizeFontFileName(e.bigFontFileName);r&&t.add(r)}return Array.from(t)}}class Xg extends ke{constructor(t){super(t)}}class Yg extends ke{constructor(t){super(t)}}class zg extends ke{constructor(t){super(t)}normalizeName(t){const e=(t??"").trim();return e?Ke.isActiveVportName(e)?Vn:super.normalizeName(e):""}getActiveVport(){return this.getAt(Vn)}getActiveVportBox(t,e){const i=this.getActiveVport();return i==null?void 0:i.resolveModelViewBox(t,e)}}class Vg extends ke{constructor(t){super(t)}}class jg extends Qt{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 Ug{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&&vt.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 la(n,t){const e=[],i=[],r=[];for(const s of t)if(s.kind==="modify"){const o=n.getObjectById(s.objectId);o instanceof tt&&e.push(o)}else if(s.kind==="append"){if(s.container.type==="blockTableRecord"){const o=n.tables.blockTable.getEntityById(s.object.objectId)??(s.object instanceof tt?s.object:void 0);o&&i.push(o)}}else s.kind==="remove"&&s.container.type==="blockTableRecord"&&s.object instanceof tt&&r.push(s.object);return{modified:e,appended:i,erased:r}}function eh(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 o=n.getObjectById(r.object.objectId)??r.object;e.push({object:o,key:s})}else r.kind==="remove"&&i.push({object:r.object,key:s})}return{set:e,erased:i}}function nh(n,t){const e={};for(const i of Kb){const r=n.getAttrWithoutException(i),s=t.getAttrWithoutException(i);ln(r,s)||(e[i]=s)}return e}function ih(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 $i))continue;const o=r.before,a=r.after;if(!o||!a)continue;const c=e?nh(a,o):nh(o,a);Object.keys(c).length!==0&&i.push({database:n,layer:s,changes:c})}return i}function r_(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 Gg{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&&r_(r.container,e))}getSysvarValue(t,e){return vt.instance().getVar(e,t)}}class mc{constructor(){this.openedObjects=new Map,this.originalStates=new Map,this.recorder=new Gg}getObject(t,e,i=!1){const r=this.openedObjects.get(t);if(r){if(e===Un.kForWrite&&!this.originalStates.has(t)){const o=r.clonePreservingIdentity();this.originalStates.set(t,o),this.recorder.recordModify(r)}return r}const s=this.lookupObject(t,i);if(this.openedObjects.set(t,s),e===Un.kForWrite){const o=s.clonePreservingIdentity();this.originalStates.set(s.objectId,o),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 Hg extends mc{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 Wg{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 $g{constructor(t){this.database=t,this.transactionStack=[],this.undoStack=new Wg,this.undoMarkStack=[],this._applyingUndoRedo=!1,this._pendingEntityModified=new Set,this._pendingLayerModified=new Map,this.strictMode=!1,this.changeApplier=new Ug(t)}startTransaction(){const t=new Hg(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}=la(this.database,t);for(const a of e)this.dispatchEntityModified(a);i.length>0&&this.database.notifyEntityAppended(i),r.length>0&&this.database.notifyEntityErased(r);const{set:s,erased:o}=eh(this.database,t);for(const{object:a,key:c}of s)this.database.notifyDictObjectSet(a,c);for(const{object:a,key:c}of o)this.database.notifyDictObjectErased(a,c);for(const a of t)a.kind==="sysvar"&&a.after!==void 0&&vt.instance().events.sysVarChanged.dispatch({database:this.database,name:a.name,oldVal:a.before,newVal:a.after});for(const a of ih(this.database,t))this.dispatchLayerModified(a)}dispatchUndoRedoEvents(t,e){const{modified:i,appended:r,erased:s}=la(this.database,t),{set:o,erased:a}=eh(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 a)this.database.notifyDictObjectSet(c,l);for(const{object:c,key:l}of o)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 o)this.database.notifyDictObjectSet(c,l);for(const{object:c,key:l}of a)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&&vt.instance().events.sysVarChanged.dispatch({database:this.database,name:c.name,oldVal:l,newVal:h})}for(const c of ih(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 yi=class yi extends Et{constructor(){super({objectId:"0"}),this._classes=[],this._handleRegistry=new Map,this._drawNoPlotLayers=!0,this._drawCircleSides=aa,this._eventBatchDepth=0,this._pendingEntityAppended=[],this._pendingEntityErased=[],this._pendingDictObjectSet=[],this._pendingDictObjectErased=[],this._lastOpenError=null,this.events={dictObjetSet:new gt,dictObjectErased:new gt,entityAppended:new gt,entityModified:new gt,entityErased:new gt,layerAppended:new gt,layerModified:new gt,layerErased:new gt,openProgress:new gt,openFailed:new gt},yi._unsavedDrawingSequence+=1,this._dwgname=`Drawing${yi._unsavedDrawingSequence}.dwg`,this._version=new St("AC1014"),this._angbase=0,this._angdir=0,this._aunits=Bt.DecimalDegrees,this._auprec=0,this._lunits=ut.Decimal,this._luprec=4,this._celtscale=1,this._cecolor=new U,this._celtype=mt,this._celweight=exports.AcGiLineWeight.ByLayer,this._cetransparency=new pt,this._clayer="0",this._cmlstyle=Oe,this._cmlscale=1,this._cmleaderstyle=Re,this._hpbackgroundcolor=new U(exports.AcCmColorMethod.None),this._hpcolor=this._cecolor.clone(),this._hplayer=".",this._hptransparency=new pt,this._textstyle=lt,this._dimstyle=lt,this._extents=new j,this._insunits=at.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._comparehatch=Br,this._comparercmargin=Fr,this._comparetext=Dr,this._comparetolerance=Xr,this._maxHandle=0,this._tables={appIdTable:new Vg(this),blockTable:new Cg(this),dimStyleTable:new Bg(this),linetypeTable:new Dg(this),textStyleTable:new Ci(this),ucsTable:new Xg(this),viewTable:new Yg(this),layerTable:new Fg(this),viewportTable:new zg(this)},this._objects={dictionary:new Qt(this),group:new Qt(this),imageDefinition:new Qt(this),layerFilter:new Qt(this),layerIndex:new Qt(this),layout:new jg(this),mleaderStyle:new Qt(this),mlineStyle:new Qt(this),sortentsTable:new Qt(this),xrecord:new Qt(this)},this._layerFilters=new Be,this.transactionManager=new $g(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 Be}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,Un.kForRead)}openObjectForWrite(t){return this.openObject(t,Un.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 o=0;try{for(let a=0;a<r;a+=s){const c=Math.min(a+s,r),l=i.slice(a,c);this.events.entityAppended.dispatch({database:this,entity:l}),o=c,e&&await e(c,r)}}finally{o<r&&this.events.entityAppended.dispatch({database:this,entity:i.slice(o)}),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 kg(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(Ue)&&!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(Ue)||this._handleRegistry.set(e,t)}releaseObjectHandle(t){const e=t.objectId;!e||e.startsWith(Ue)||this._handleRegistry.get(e)===t&&this._handleRegistry.delete(e)}isHandleTaken(t,e){if(!t||t.startsWith(Ue))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 o=this._handleRegistry.get(i);if(o&&o!==t)if(this.shouldPreserveIncomingHandle(t))this.assignGeneratedHandle(o);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(T.AUNITS,this._aunits,t??0,e=>{this._aunits=e})}get auprec(){return this._auprec}set auprec(t){this.updateSysVar(T.AUPREC,this._auprec,t??0,e=>{this._auprec=e})}get lunits(){return this._lunits}set lunits(t){this.updateSysVar(T.LUNITS,this._lunits,t??ut.Decimal,e=>{this._lunits=e})}get luprec(){return this._luprec}set luprec(t){this.updateSysVar(T.LUPREC,this._luprec,t??4,e=>{this._luprec=e})}get version(){return this._version}set version(t){this.updateSysVar(T.ACADVER,this._version,new St(t),e=>{this._version=e})}get insunits(){return this._insunits}set insunits(t){this.updateSysVar(T.INSUNITS,this._insunits,t??4,e=>{this._insunits=e})}get unitmode(){return this._unitmode}set unitmode(t){this.updateSysVar(T.UNITMODE,this._unitmode,t??0,e=>{this._unitmode=e})}get measurement(){return this._measurement}set measurement(t){this.updateSysVar(T.MEASUREMENT,this._measurement,t??1,e=>{this._measurement=e})}get ltscale(){return this._ltscale}set ltscale(t){this.updateSysVar(T.LTSCALE,this._ltscale,t??1,e=>{this._ltscale=e})}get lwdisplay(){return this._lwdisplay}get drawNoPlotLayers(){return this._drawNoPlotLayers}get drawCircleSides(){return this._drawCircleSides}set drawCircleSides(t){this._drawCircleSides=$.resolveCircleSides(t)}get dwgname(){return this._dwgname}setDwgName(t){const e=t.trim();e&&this.updateSysVar(T.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(T.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(T.CECOLOR,this._cecolor,t||0,e=>{this._cecolor=e.clone()})}get celtscale(){return this._celtscale}set celtscale(t){this.updateSysVar(T.CELTSCALE,this._celtscale,t??1,e=>{this._celtscale=e})}get celtype(){return this._celtype}set celtype(t){const e=this.normalizeLinetypeName(t??mt);this.updateSysVar(T.CELTYPE,this._celtype,e,i=>{this._celtype=i})}get celweight(){return this._celweight}set celweight(t){this.updateSysVar(T.CELWEIGHT,this._celweight,t??exports.AcGiLineWeight.ByLayer,e=>{this._celweight=e})}get cetransparency(){return this._cetransparency}set cetransparency(t){this.updateSysVar(T.CETRANSPARENCY,this._cetransparency,t??new pt,e=>{this._cetransparency=e.clone()})}get clayer(){return this._clayer}set clayer(t){this.updateSysVar(T.CLAYER,this._clayer,t??"0",e=>{this._clayer=e})}get cmlstyle(){return this._cmlstyle}set cmlstyle(t){this.updateSysVar(T.CMLSTYLE,this._cmlstyle,t??Oe,e=>{this._cmlstyle=e})}get cmlscale(){return this._cmlscale}set cmlscale(t){this.updateSysVar(T.CMLSCALE,this._cmlscale,t??1,e=>{this._cmlscale=e})}get cmleaderstyle(){return this._cmleaderstyle}set cmleaderstyle(t){this.updateSysVar(T.CMLEADERSTYLE,this._cmleaderstyle,t??Re,e=>{this._cmleaderstyle=e})}get hpbackgroundcolor(){return this._hpbackgroundcolor}set hpbackgroundcolor(t){this.updateSysVar(T.HPBACKGROUNDCOLOR,this._hpbackgroundcolor,t??new U(exports.AcCmColorMethod.None),e=>{this._hpbackgroundcolor=e.clone()})}get hpcolor(){return this._hpcolor}set hpcolor(t){this.updateSysVar(T.HPCOLOR,this._hpcolor,t??this._cecolor,e=>{this._hpcolor=e.clone()})}get hplayer(){return this._hplayer}set hplayer(t){this.updateSysVar(T.HPLAYER,this._hplayer,t??".",e=>{this._hplayer=e})}get hptransparency(){return this._hptransparency}set hptransparency(t){this.updateSysVar(T.HPTRANSPARENCY,this._hptransparency,t??new pt,e=>{this._hptransparency=e.clone()})}get textstyle(){return this._textstyle}set textstyle(t){this.updateSysVar(T.TEXTSTYLE,this._textstyle,t??lt,e=>{this._textstyle=e})}get dimstyle(){return this._dimstyle}set dimstyle(t){this.updateSysVar(T.DIMSTYLE,this._dimstyle,t??lt,e=>{this._dimstyle=e})}get angbase(){return this._angbase}set angbase(t){this.updateSysVar(T.ANGBASE,this._angbase,t??0,e=>{this._angbase=e})}get angdir(){return this._angdir}set angdir(t){this.updateSysVar(T.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(T.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(T.EXTMIN,e,this._extents.min)}}get extents(){return this._extents}get pdmode(){return this._pdmode}set pdmode(t){this.updateSysVar(T.PDMODE,this._pdmode,t??0,e=>{this._pdmode=e})}get pdsize(){return this._pdsize}set pdsize(t){this.updateSysVar(T.PDSIZE,this._pdsize,t??0,e=>{this._pdsize=e})}get osmode(){return this._osmode}set osmode(t){this.updateSysVar(T.OSMODE,this._osmode,t??0,e=>{this._osmode=e})}get orthomode(){return this._orthomode}set orthomode(t){this.updateSysVar(T.ORTHOMODE,this._orthomode,t??0,e=>{this._orthomode=e})}get comparehatch(){return this._comparehatch}set comparehatch(t){const e=pe("COMPAREHATCH",t??Br,zs,Vs);this.updateSysVar(T.COMPAREHATCH,this._comparehatch,e,i=>{this._comparehatch=i})}get comparercmargin(){return this._comparercmargin}set comparercmargin(t){const e=pe("COMPARERCMARGIN",t??Fr,js,Us);this.updateSysVar(T.COMPARERCMARGIN,this._comparercmargin,e,i=>{this._comparercmargin=i})}get comparetext(){return this._comparetext}set comparetext(t){const e=pe("COMPARETEXT",t??Dr,Gs,Hs);this.updateSysVar(T.COMPARETEXT,this._comparetext,e,i=>{this._comparetext=i})}get comparetolerance(){return this._comparetolerance}set comparetolerance(t){const e=pe("COMPARETOLERANCE",t??Xr,Ws,$s);this.updateSysVar(T.COMPARETOLERANCE,this._comparetolerance,e,i=>{this._comparetolerance=i})}get lastOpenError(){return this._lastOpenError}async read(t,e,i=di.DXF){const r=ge.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,this.drawCircleSides=(e==null?void 0:e.circleSides)??aa,e!=null&&e.fileName&&this.setDwgName(e.fileName),Uu(this);try{await r.read(t,this,{minimumChunkSize:e&&e.minimumChunkSize||10,progress:this.createConversionProgressHandler(),timeout:e==null?void 0:e.timeout,sysVars:e==null?void 0:e.sysVars})}catch(s){const o=Mi.from(s);throw this._lastOpenError=o,this.events.openFailed.dispatch({database:this,error:o}),o}this._lastOpenError=null,this.ensureDatabaseDefaults()}createConversionProgressHandler(){return async(t,e,i,r,s)=>{let o=r;if(i==="ERROR"&&s){const a=Mi.fromTask(s);this._lastOpenError=a,o={code:a.code,message:a.message,stage:a.stage??e}}this.events.openProgress.dispatch({database:this,percentage:t,stage:"CONVERSION",subStage:e,subStageStatus:i,data:o})}}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 o=0;const a=(g=i.body)==null?void 0:g.getReader();if(!a)throw new Error("Failed to get response reader");const c=[];for(;;){const{done:f,value:p}=await a.read();if(f)break;if(c.push(p),o+=p.length,s!==null){const m=Math.round(o/s*100);this.events.openProgress.dispatch({database:this,percentage:m,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const l=new Uint8Array(o);let h=0;for(const f of c)l.set(f,h),h+=f.length;const u=this.getFileNameFromUri(t);u&&this.setDwgName(u);const d=u.toLowerCase().split(".").pop();d==="dwg"?await this.read(l.buffer,e,di.DWG):d==="dxf"?await this.read(l.buffer,e,di.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"},o=i instanceof St?i:new St(i),a=new We({database:this,precision:e,version:o,outputFormat:s.format});return this.writeDxfHeaderSection(a),this.writeDxfClassesSection(a),this.writeDxfTablesSection(a,o),this.writeDxfBlocksSection(a),this.writeDxfEntitiesSection(a),this.writeDxfObjectsSection(a),this.writeDxfThumbnailImageSection(a,s.saveThumbnailImage),a.writeStart("EOF"),s.format==="binary"?a.toBinary():a.toString()}async regen(){await new Vd(this).read(null,this,{minimumChunkSize:500,progress:this.createConversionProgressHandler()})}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){const e=new Sg(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||Re);return}if(t.dxfTypeName==="HATCH"){const i=t;(e=i.applyPatternDefaultsFromSysVars)==null||e.call(i,this)}}ensureTextStyleDefaults(){this.hasDefaultTextStyle()||this.tables.textStyleTable.add(new Qs({name:lt,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}hasDefaultTextStyle(){const t=[lt,"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()===lt.toUpperCase())return!0;return!1}ensureDatabaseDefaults(){if(!this.tables.layerTable.has("0")){const e=new U;e.colorIndex=7,this.tables.layerTable.add(new $i({name:"0",standardFlags:0,linetype:$e,lineWeight:0,isOff:!1,color:e,isPlottable:!0}))}if(this.tables.linetypeTable.has(ye)||this.tables.linetypeTable.add(new qe({name:ye,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(mt)||this.tables.linetypeTable.add(new qe({name:mt,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has($e)||this.tables.linetypeTable.add(new qe({name:$e,standardFlag:0,description:"Solid line",totalPatternLength:0})),this.ensureTextStyleDefaults(),this.tables.dimStyleTable.has(lt)||this.tables.dimStyleTable.add(new Ht({name:lt,dimtxsty:lt})),!this.tables.viewportTable.has(Vn)){const e=new Ke;e.name=Vn,this.tables.viewportTable.add(e)}this.ensureMLineStyle(this._cmlstyle||Oe),this.ensureMLeaderStyle(this._cmleaderstyle||Re);const t=this.tables.blockTable.modelSpace;if(!this.objects.layout.getAt("Model")){const e=new Hi;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(Zo)||this.tables.appIdTable.add(new $r(Zo)),this.tables.appIdTable.has(Ko)||this.tables.appIdTable.add(new $r(Ko))}ensureMLineStyle(t){const e=this.objects.mlineStyle,i=t.trim();if(!i||e.getAt(i))return;for(const[s,o]of e.entries())if(s.toUpperCase()===i.toUpperCase()||o.styleName.toUpperCase()===i.toUpperCase())return;const r=new uc;r.styleName=i,r.elements=[{offset:.5,color:new U().setByLayer(),lineType:mt},{offset:-.5,color:new U().setByLayer(),lineType:mt}],e.setAt(i,r)}ensureMLeaderStyle(t){const e=this.objects.mleaderStyle,i=t.trim();if(!i||e.getAt(i))return;for(const[a]of e.entries())if(a.toUpperCase()===i.toUpperCase())return;const r=new ro;r.unknown1=2,r.maxLeaderSegmentsPoints=2,r.leaderLineColor=new U().setByBlock(),r.textColor=new U().setByBlock(),r.blockColor=new U().setByBlock(),r.alignSpace=4,r.breakSize=3.75,r.enableBlockRotation=!0,r.unknown2=!1;const s=this.tables.linetypeTable.getAt(ye);r.leaderLineTypeId=s==null?void 0:s.objectId;const o=this.tables.textStyleTable.getAt(lt);r.textStyleId=o==null?void 0:o.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=o=>{t.writeStart("DICTIONARY"),o.dxfOut(t,!0)},r=(o,a)=>{e.getAt(o)!==a&&e.setAt(o,a)},s=o=>{e.getAt(o)&&e.remove(o)};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[o,a]of this.objects.layout.entries())t.writeStart("LAYOUT"),a.dxfOut(t,!0);for(const[o,a]of this.objects.group.entries())a.name||(a.name=o),t.writeStart("GROUP"),a.dxfOut(t,!0);for(const[o,a]of this.objects.sortentsTable.entries())t.writeStart("SORTENTSTABLE"),a.dxfOut(t,!0);for(const[o,a]of this.objects.imageDefinition.entries())t.writeStart("IMAGEDEF"),a.dxfOut(t,!0);for(const[o,a]of this.objects.layerFilter.entries())t.writeStart("LAYER_FILTER"),a.dxfOut(t,!0);for(const[o,a]of this.objects.layerIndex.entries())t.writeStart("LAYER_INDEX"),a.dxfOut(t,!0);for(const[o,a]of this.objects.mleaderStyle.entries())t.writeStart("MLEADERSTYLE"),a.dxfOut(t,!0);for(const[o,a]of this.objects.mlineStyle.entries())t.writeStart("MLINESTYLE"),a.dxfOut(t,!0);for(const[o,a]of this.objects.xrecord.entries())t.writeStart("XRECORD"),a.dxfOut(t,!0);this.writeAcLyLayerFilterObjects(t),t.endSection()}writeAcLyLayerFilterObjects(t){const e=ig(this._layerFilters);if(e.nodes.length===0)return;const i=[],r=[],s=this.tables.layerTable,o=s.extensionDictionary??this.generateHandle();s.extensionDictionary=o;const a=this.generateHandle(),c=this.generateHandle(),l=[],h=[],u=(f,p,m)=>{const y=this.generateHandle();let b;if(f.children.length>0){const w=this.generateHandle(),x=this.generateHandle(),S=[];for(const P of f.children)S.push({name:P.key,id:u(P,x,!1)});i.push({handle:w,ownerId:y,entries:[{name:Hn,id:x}]}),i.push({handle:x,ownerId:w,entries:S}),b=w}return r.push({handle:y,ownerId:p,extensionDictionaryId:b,data:f.data}),m&&h.push({name:f.key,id:y}),y};for(const f of e.nodes)l.push({name:f.key,id:u(f,a,!0)});const d=new Map,g=this.getObjectById(o);if(g instanceof Qt)for(const[f,p]of g.entries())d.set(f,p.objectId);d.set(Hn,a),d.set(io,c),i.unshift({handle:o,ownerId:s.objectId,entries:Array.from(d,([f,p])=>({name:f,id:p}))},{handle:a,ownerId:o,entries:l},{handle:c,ownerId:o,entries:h});for(const f of i){t.writeStart("DICTIONARY"),t.writeHandle(5,f.handle),t.writeObjectId(330,f.ownerId),t.writeSubclassMarker("AcDbDictionary"),t.writeInt16(280,1),t.writeInt16(281,1);for(const p of f.entries)t.writeString(3,p.name),t.writeObjectId(350,p.id)}for(const f of r){const p=new dc;p.objectId=f.handle,p.ownerId=f.ownerId,f.extensionDictionaryId&&(p.extensionDictionary=f.extensionDictionaryId),p.data=rg(f.data),t.writeStart("XRECORD"),p.dxfOut(t)}}writeDxfTable(t,e,i,r,s){const o=[...r];t.startTable(e),i.dxfOut(t);for(const a of o){if(s==="BLOCK_RECORD"&&a instanceof ct){a.dxfOutBlockRecord(t);continue}t.writeStart(s),a.dxfOut(t,!0)}t.endTable()}writeDxfEntity(t,e){if(e instanceof Rt&&!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 o=i.subarray(s,s+r);t.writeString(310,qs(o))}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 Be,this._currentSpace=void 0,this._extents.makeEmpty(),this.registerBootstrapHandles()}updateSysVar(t,e,i,r){vt.instance().applyVarMutation(t,e,i,this,()=>r(i))}normalizeLinetypeName(t){const e=t.trim();return e.toUpperCase()==="BYLAYER"?mt:e.toUpperCase()==="BYBLOCK"?ye:e}triggerSysVarChangedEvent(t,e,i){const r=vt.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""}}};yi._unsavedDrawingSequence=0;let ha=yi;class s_{constructor(){this.transactionStack=[]}startTransaction(){const t=new mc;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 Mo=6,Mc=class Mc extends tt{get dxfTypeName(){return"TOLERANCE"}constructor(){super(),this._location=new _,this._text="",this._dimensionStyle="",this._normal=new A(0,0,1),this._direction=new A(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 _(0,r,0),new _(t,r,0),new _(t,s,0),new _(0,s,0),new _(0,r,0)].map(a=>this.toFrameWcs(a.x,a.y))}get geometricExtents(){const t=new j;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 Se(t,e,this._location),this}subGetOsnapPoints(t,e,i,r){t===I.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 o=new A(r).sub(i),a=new A(s).sub(i);let c=new A().crossVectors(o,a);c.lengthSq()===0?c=this._normal.clone().transformDirection(t):c.normalize();let l=o.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(([o,a])=>t.lines([o,a])),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(A.Z_AXIS)||t.writeVector3d(210,this._normal),this._direction.equals(A.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,o=this.normal.y,a=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 f=Number(g.code),p=Number(g.value);switch(f){case 1:this.text=String(g.value);break;case 3:this.dimensionStyle=String(g.value);break;case 10:e=p;break;case 20:i=p;break;case 30:r=p;break;case 11:c=p,d=!0;break;case 21:l=p,d=!0;break;case 31:h=p,d=!0;break;case 210:s=p,u=!0;break;case 220:o=p,u=!0;break;case 230:a=p,u=!0;break}}return this.location={x:e,y:i,z:r},u&&(this.normal={x:s,y:o,z:a}),d&&(this.direction={x:c,y:l,z:h}),this}get textHeight(){const t=this.resolveDimensionStyle(),e=(t==null?void 0:t.dimtxt)??Ht.DEFAULT_DIM_VALUES.dimtxt,i=(t==null?void 0:t.dimscale)??Ht.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(),o=[];for(let a=0;a<i.length;a++){const c=i[a];let l=r.cellPadding;const h=-r.rowHeight*a;for(let u=0;u<c.cells.length;u++){const d=c.cells[u],g=r.columnWidths[u]??this.textHeight;if(d.trim()){const f=this.toFrameWcs(l+g/2,h),p={text:d,height:this.textHeight,width:1/0,position:f,directionVector:this._direction,attachmentPoint:exports.AcGiMTextAttachmentPoint.MiddleCenter,drawingDirection:exports.AcGiMTextFlowDirection.LEFT_TO_RIGHT};o.push(t.mtext(p,s,e))}l+=g+r.columnGap}}if(o.length!==0)return o.length===1?o[0]:t.group(o)}collectFrameLineSegments(){const t=this.parseToleranceFrame(this._text),e=this.resolveFrameLayout(t),{width:i,rowHeight:r,rowCount:s,columnDivisions:o}=e;if(i<=0||r<=0||s<=0)return[];const a=r/2,c=a-r*s,l=[],h=(u,d)=>{l.push([u,d])};h(this.toFrameWcs(0,a),this.toFrameWcs(i,a)),h(this.toFrameWcs(i,a),this.toFrameWcs(i,c)),h(this.toFrameWcs(i,c),this.toFrameWcs(0,c)),h(this.toFrameWcs(0,c),this.toFrameWcs(0,a));for(const u of o)h(this.toFrameWcs(u,a),this.toFrameWcs(u,c));for(let u=1;u<t.length;u++){const d=a-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,o=i;if(i<=0||e.length===0)return{width:0,totalHeight:0,rowHeight:0,columnWidths:[],columnDivisions:[],rowCount:0,cellPadding:0,columnGap:0};const a=Math.max(...e.map(d=>d.cells.length),0),c=[];for(let d=0;d<a;d++){let g=i;for(const f of e){const p=f.cells[d]??"";if(!p.trim())continue;const m=Ab(p,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+=o,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:o}}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 a=this.splitToleranceTokens(s,"%%v").slice(0,Mo);for(;a.length<Mo;)a.push("");return a}),r=[0,1];i.some(s=>{var o;return(o=s[2])==null?void 0:o.trim()})&&r.push(2);for(let s=3;s<Mo;s++)i.some(o=>{var a;return(a=o[s])==null?void 0:a.trim()})&&r.push(s);return i.map(s=>({cells:r.map(o=>s[o]??"")}))}splitToleranceRows(t){return t.replace(/\^J/g,`
9
+ `).replace(wb,"").replace(/\\[A-Za-z][^;]*;/g,"").replace(/[{}]/g,"").trim()}function Ab(n,t,e=1){const i=n.trim();if(!i||t<=0)return 0;const r=vb(i),s=xb.test(i);return r?Math.max(t,Wi(r,t,e)):s?t:0}function Wi(n,t,e=1){if(!n||t<=0)return 0;const i=rc(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*_b*e)}function Cd(n){const t=rc(n);return Math.max(t.split(/\r\n|\r|\n/g).length,1)}function Od(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 sc(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 oc(n,t){let e;t&&t.lengthSq()>0?e=t.clone().normalize():e=new A(Math.cos(n),Math.sin(n),0);const i=new A(-e.y,e.x,e.z);return i.lengthSq()===0?i.set(0,1,0):i.normalize(),{xAxis:e,yAxis:i}}function Rd(n,t,e,i,r,s=0,o){if(e<=0&&i<=0)return n.expandByPoint(t),n;const a=sc(e,i,r),{xAxis:c,yAxis:l}=oc(s,o?new A(o.x,o.y,o.z||0):void 0),h=[[a.minX,a.minY],[a.maxX,a.minY],[a.maxX,a.maxY],[a.minX,a.maxY]];for(const[u,d]of h)n.expandByPoint(new _(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 Pb(n){const t=n.extentsWidth>0?n.extentsWidth:n.width>0?n.width:Wi(n.contents,n.height),e=Od(Cd(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 _(n.location.x,n.location.y,n.location.z??0)}}function Sb(n,t){const{xAxis:e,yAxis:i}=oc(t.rotation,t.direction),r=n.x-t.location.x,s=n.y-t.location.y,o=(n.z??0)-t.location.z;return{x:r*e.x+s*e.y+o*e.z,y:r*i.x+s*i.y+o*i.z}}function kb(n){const t=sc(n.width,n.height,n.attachment),{xAxis:e,yAxis:i}=oc(n.rotation,n.direction);return[[t.minX,t.minY],[t.maxX,t.minY],[t.maxX,t.maxY],[t.minX,t.maxY]].map(([s,o])=>new _(n.location.x+e.x*s+i.x*o,n.location.y+e.y*s+i.y*o,n.location.z+e.z*s+i.z*o))}function Eb(n,t,e){const i=sc(t.width,t.height,t.attachment),{x:r,y:s}=Sb(n,t),o=i.minX-e.padX,a=i.maxX+e.padX,c=i.minY-e.padYBelow,l=i.maxY+e.padYAbove;if(r<o||r>a||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 Nd=(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))(Nd||{}),Bd=(n=>(n[n.BASELINE=0]="BASELINE",n[n.BOTTOM=1]="BOTTOM",n[n.MIDDLE=2]="MIDDLE",n[n.TOP=3]="TOP",n))(Bd||{});const kc=class kc extends tt{constructor(){super(),this._generationFlag=0,this._normal=new A(0,0,1),this._textString="",this._height=0,this._thickness=1,this._position=new _,this._alignmentPoint=new _,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 j,{anchor:e,attachmentPoint:i}=this.resolveTextAnchor(),r=Wi(this.textString,this.height,this.widthFactor);return Rd(t,e,r,this.height,i,this.rotation)}subGetGripPoints(){return[this._position]}subMoveGripPointsAt(t,e){return Se(t,e,this._position),this._alignmentPoint.add(e),this}subGetOsnapPoints(t,e,i,r){I.Insertion===t&&r.push(this._position)}transformBy(t){const e=this._position.clone(),i=this._position.clone().add(new A(Math.cos(this._rotation),Math.sin(this._rotation),0)),r=this._position.clone().add(new A(-Math.sin(this._rotation),Math.cos(this._rotation),0)),s=this._position.clone().add(new A(0,0,1));e.applyMatrix4(t),i.applyMatrix4(t),r.applyMatrix4(t),s.applyMatrix4(t);const o=new A(i).sub(e),a=new A(r).sub(e),c=new A(s).sub(e),l=a.length(),h=o.length(),u=c.length();this._position.copy(e),h>0&&(this._rotation=Math.atan2(o.y,o.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,o=this.alignmentPoint.y,a=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),f=Number(d.value);switch(g){case 10:e=f;break;case 20:i=f;break;case 30:r=f;break;case 11:s=f,c=!0;break;case 21:o=f,c=!0;break;case 31:a=f,c=!0;break;case 1:this.textString=String(d.value);break;case 7:this.styleName=String(d.value);break;case 39:this.thickness=f;break;case 40:this.height=f;break;case 41:this.widthFactor=f;break;case 50:this.rotation=C.degToRad(f);break;case 51:this.oblique=C.degToRad(f);break;case 71:this.generationFlag=f;break;case 72:this.horizontalMode=f;break;case 73:this.verticalMode=f;break;case 210:l=f;break;case 220:h=f;break;case 230:u=f;break;case 100:{if(String(d.value)==="AcDbText")break;return t.pushBackItem(d),this.finishTextDxfIn(e,i,r,s,o,a,c,l,h,u),this}}}return this.finishTextDxfIn(e,i,r,s,o,a,c,l,h,u),this}finishTextDxfIn(t,e,i,r,s,o,a,c,l,h){this.position=new _(t,e,i),a&&!(r===0&&s===0&&o===0)?this.alignmentPoint=new _(r,s,o):this.alignmentPoint=new _(t,e,i);const u=new A(c,l,h);u.lengthSq()>0&&this.normal.copy(u.normalize())}};kc.typeName="Text";let Gn=kc;var xt=(n=>(n[n.Invisible=1]="Invisible",n[n.Const=2]="Const",n[n.Verifiable=4]="Verifiable",n[n.Preset=8]="Preset",n))(xt||{}),le=(n=>(n[n.MultiLine=2]="MultiLine",n[n.ConstMultiLine=4]="ConstMultiLine",n))(le||{});const Ec=class Ec extends Gn{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){if(this.isLooseInDrawingSpace())return this.tag||this.textString;if(this.isConst||this.isConstMTextAttribute)return 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}};Ec.typeName="AttDef";let Ur=Ec;function Ib(n){return n!=null&&typeof n=="object"&&"blockTableRecord"in n}const Ic=class Ic extends Gn{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(Ib(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&xt.Invisible)!==0}set isInvisible(t){t?this._flags|=xt.Invisible:this._flags&=~xt.Invisible}get isConst(){return(this._flags&xt.Const)!==0}set isConst(t){t?this._flags|=xt.Const:this._flags&=~xt.Const}get isVerifiable(){return(this._flags&xt.Verifiable)!==0}set isVerifiable(t){t?this._flags|=xt.Verifiable:this._flags&=~xt.Verifiable}get isPreset(){return(this._flags&xt.Preset)!==0}set isPreset(t){t?this._flags|=xt.Preset:this._flags&=~xt.Preset}get isMTextAttribute(){return(this._mtextFlag&le.MultiLine)!==0}set isMTextAttribute(t){t?this._mtextFlag|=le.MultiLine:this._mtextFlag&=~le.MultiLine}get isConstMTextAttribute(){return(this._mtextFlag&le.ConstMultiLine)!==0}set isConstMTextAttribute(t){t?this._mtextFlag|=le.ConstMultiLine:this._mtextFlag&=~le.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&xt.Invisible)!==0,this.isConst=(r&xt.Const)!==0,this.isVerifiable=(r&xt.Verifiable)!==0,this.isPreset=(r&xt.Preset)!==0;break;case 71:this.isMTextAttribute=(r&le.MultiLine)!==0,this.isConstMTextAttribute=(r&le.ConstMultiLine)!==0;break;case 73:this.fieldLength=r;break;case 74:this.verticalMode=r;break;case 280:this.lockPositionInBlock=r!==0;break}}return this}};Ic.typeName="Attrib";let Si=Ic;const Tb=()=>({hits:0,misses:0,hitMs:0,missBuildMs:0,missCompactMs:0,cloneMs:0,setCloneMs:0,applyMs:0}),Vl=()=>({hits:0,misses:0,hitMs:0,missBuildMs:0,missCompactMs:0,cloneMs:0,setCloneMs:0,applyMs:0,topLevel:Tb(),blockMisses:[]}),wt=class wt{static get profileStats(){return this._profileStats}static resetProfile(){this._profileStats=Vl(),this._drawDepth=0}static get instance(){return this._instance||(this._instance=new wt),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){return this._blocks.set(t,e),e}get(t){const e=this._blocks.get(t);if(e){if(wt.profiling){const i=performance.now();if(this.maybeCompactTemplate(e,!0)){const c=performance.now()-i;wt._profileStats.missCompactMs+=c,wt._drawDepth===1&&(wt._profileStats.topLevel.missCompactMs+=c)}const s=performance.now(),o=e.fastDeepClone(),a=performance.now()-s;return wt._profileStats.cloneMs+=a,wt._drawDepth===1&&(wt._profileStats.topLevel.cloneMs+=a),o}return this.maybeCompactTemplate(e,!0),e.fastDeepClone()}}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 o=0;const a=new U().setForeground(),c=new Fs;for(const l of r){const h=this.createCacheKey(l.name,a,!1);this.has(h)||this.draw(t,l,a,[],!0),o++,i&&await i(o,s,l.name),await c.maybeYield(qn)}}draw(t,e,i,r=[],s=!0,o,a){const c=wt.profiling;c&&wt._drawDepth++;const l=c&&wt._drawDepth===1,h=wt._profileStats,u=[];try{if(e!=null){const d=i.RGB??0,g=e.name;let f;if(g&&this.has(g))f=g;else if(g){const y=this.createKey(g,i);this.has(y)&&(f=y)}let p;if(f!==void 0){const y=c?performance.now():0;if(p=this.get(f),c){const b=performance.now()-y;h.hits++,h.hitMs+=b,l&&(h.topLevel.hits++,h.topLevel.hitMs+=b)}}else{const y=c?performance.now():0;let b=!1;const w=e.newIterator();for(const k of w)if(k.visibility)if(k.color.isByBlock){b=!0;const E=Fb(k.color);try{i.isForeground?k.color.setForeground():k.color.setRGBValue(d),this.addEntity(k,u,t)}finally{k.color.copy(E),Db(E)}}else this.addEntity(k,u,t);p=t.group(u);let x=0;c&&(x=performance.now()-y,h.missBuildMs+=x,l&&(h.topLevel.missBuildMs+=x));let S=0;const P=!!s&&!!g&&!g.startsWith("*U");if(p&&P){const k=c?performance.now():0,E=this.maybeCompactTemplate(p,!1);c&&E&&(S=performance.now()-k,h.missCompactMs+=S,l&&(h.topLevel.missCompactMs+=S))}f=this.createCacheKey(g,i,b);const v=c?h.setCloneMs:0;if(p&&P)if(Bb(p),this.set(f,p),c){const k=performance.now();p=p.fastDeepClone();const E=performance.now()-k;h.setCloneMs+=E,l&&(h.topLevel.setCloneMs+=E)}else p=p.fastDeepClone();c&&(h.misses++,l&&h.topLevel.misses++,h.blockMisses.push({blockName:g||"(unnamed)",buildMs:x,compactMs:S,setCloneMs:h.setCloneMs-v}))}const m=c?performance.now():0;if(p&&o&&(ar.copy(o),p.applyMatrix(ar),a&&(a.x!=0||a.y!=0||a.z!=1)&&(Po.setFromExtrusionDirection(a),p.applyMatrix(Po),ar.premultiply(Po))),p&&r&&r.length>0){const y=o!=null?Lb.copy(ar).invert():void 0;r.forEach(b=>{y&&b.applyMatrix(y),p.addChild(b)})}if(c){const y=performance.now()-m;h.applyMs+=y,l&&(h.topLevel.applyMs+=y)}return p}else return t.group(u)}finally{c&&wt._drawDepth--}}shouldSkipPrebuild(t){const e=t.name;if(ct.isModelSapceName(e)||ct.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}maybeCompactTemplate(t,e){return!t.compactForInstancing||Rb(t)||!Nb(t,e)?!1:(t.compactForInstancing(),!0)}};wt.profiling=!1,wt._profileStats=Vl(),wt._drawDepth=0;let Je=wt;const ar=new D,Po=new D,Lb=new D,Mb=8,Cb=32,Fd=[];function Ob(n){const t=n.childCount;return typeof t=="number"?t:Number.POSITIVE_INFINITY}function Rb(n){return n.isCompacted===!0}function Nb(n,t){const e=Ob(n);return e<Mb?!1:e>=Cb?!0:t}function Bb(n){const t=n.prepareCacheTemplate;typeof t=="function"&&t.call(n)}function Fb(n){const t=Fd.pop()??new U;return t.copy(n),t}function Db(n){Fd.push(n)}const Xb=1e-10;function $t(n,t,e){const i=t?n.length:n.length-1;if(i<1||n.length<2)return[];const r=[];for(let s=0;s<i;s++){const o=n[s],a=n[(s+1)%n.length];if(Zs(o,a))continue;const c=!t&&(s===0||s===i-1);r.push({kind:"line",line:new Dt(o,a),extent:"bounded",extendable:e??c})}return r}function ac(n,t,e,i){const r=t?n.length:n.length-1;if(r<1||n.length<2)return[];const s=[];for(let o=0;o<r;o++){const a=n[o],c=n[(o+1)%n.length],h=!t&&(o===0||o===r-1),u=a.bulge??0;if(Math.abs(u)>Xb){const f=Xd(new $(a,c,u),e,i,h);f&&s.push(f);continue}const d=Ne(a.x,a.y,e,i),g=Ne(c.x,c.y,e,i);Zs(d,g)||s.push({kind:"line",line:new Dt(d,g),extent:"bounded",extendable:h})}return s}function Yb(n,t,e){const i=[];for(const r of n){if(r instanceof it){i.push(...ac(r.vertices,r.closed,t,e));continue}if(r instanceof On)for(const s of r.curves){const o=zb(s,t,e);o&&i.push(...o)}}return i}function Dd(n,t){return n.map(e=>Em(e,t))}function zb(n,t,e){if(n instanceof Vt){const i=Ne(n.startPoint.x,n.startPoint.y,t,e),r=Ne(n.endPoint.x,n.endPoint.y,t,e);return Zs(i,r)?[]:[{kind:"line",line:new Dt(i,r),extent:"bounded",extendable:!1}]}if(n instanceof $){const i=Xd(n,t,e,!1);return i?[i]:[]}if(n instanceof Ie){const i=Vb(n,t,e,!1);return i?[i]:[]}if(n instanceof Ut){const i=n.clone(),r=jb(t,e);return r&&i.transform(r),[{kind:"spline",spline:i,extendable:!1}]}return[]}function Xd(n,t,e,i){if(n.closed||Math.abs(n.deltaAngle-Y)<1e-10){const c=Ne(n.center.x,n.center.y,t,e);return{kind:"circArc",arc:new Pt(c,n.radius,0,Y,e,Qe(e)),extendable:!1}}const r=Ne(n.startPoint.x,n.startPoint.y,t,e),s=Ne(n.endPoint.x,n.endPoint.y,t,e),o=Ne(n.midPoint.x,n.midPoint.y,t,e),a=Pt.tryCreateByThreePoints(r,s,o);return a?{kind:"circArc",arc:a,extendable:i&&!a.closed}:Zs(r,s)?null:{kind:"line",line:new Dt(r,s),extent:"bounded",extendable:i}}function Vb(n,t,e,i){const r=Ne(n.center.x,n.center.y,t,e),s=new D().setFromExtrusionDirection(new A(e.x,e.y,e.z)),o=new A(Math.cos(n.rotation),Math.sin(n.rotation),0).transformDirection(s);if(o.lengthSq()===0)return null;const a=n.clockwise?n.endAngle:n.startAngle,c=n.clockwise?n.startAngle:n.endAngle,l=new Pe(r,e,o,n.majorAxisRadius,n.minorAxisRadius,a,c);return{kind:"ellipseArc",arc:l,extendable:i&&!l.closed&&Math.abs(l.deltaAngle-Y)>1e-10}}function Ne(n,t,e,i){return At({x:n,y:t,z:e},i)}function jb(n,t){if(Math.abs(t.x)<1e-10&&Math.abs(t.y)<1e-10&&Math.abs(t.z-1)<1e-10&&Math.abs(n)<1e-10)return null;const i=new D().setFromExtrusionDirection(new A(t.x,t.y,t.z));return Math.abs(n)<1e-10?i:i.multiply(new D().makeTranslation(0,0,n))}function Zs(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<1e-20}const In=class In extends tt{constructor(t){super(),this._columnCount=1,this._rowCount=1,this._columnSpacing=0,this._rowSpacing=0,this._blockName=t??"",this._position=new _,this._rotation=0,this._normal=new A(0,0,1),this._scaleFactors=new _(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(){if(this._blockName)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 jn(this._attribs)}get blockTransform(){const t=this.blockTableRecord,e=(t==null?void 0:t.origin)??_.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 Dn().setFromAxisAngle(A.Z_AXIS,this._rotation),o=new D().makeRotationFromQuaternion(s),a=new D().makeTranslation(this._position.x,this._position.y,this._position.z);return new D().multiplyMatrices(a,o).multiply(r).multiply(i)}subGetGripPoints(){return[this._position]}subMoveGripPointsAt(t,e){return Se(t,e,this._position),this}subGetOsnapPoints(t,e,i,r,s,o){const a=o??new D;I.Insertion===t?r.push(this.getInsertionPoint(a)):s?this.subEntityGetOsnapPoints(t,e,i,r,s,a):this.collectBlockOsnapPoints(t,e,i,r,a)}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(),o=new _(this._scaleFactors.x,0,0).applyMatrix4(r).add(s),a=new _(0,this._scaleFactors.y,0).applyMatrix4(r).add(s),c=new _(0,0,this._scaleFactors.z).applyMatrix4(r).add(s);s.applyMatrix4(t),o.applyMatrix4(t),a.applyMatrix4(t),c.applyMatrix4(t);const l=new A(o).sub(s),h=new A(a).sub(s),u=new A(c).sub(s);let d=new A().crossVectors(l,h);d.lengthSq()===0?d=this._normal.clone().transformDirection(t):d.normalize();const f=new D().setFromExtrusionDirection(d).clone().invert(),p=l.clone().applyMatrix4(f);return this._position.copy(s),this._normal.copy(d),this._rotation=Math.atan2(p.y,p.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 j,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}subGetIntersectCurves(){const t=this.blockTableRecord;if(t==null)return[];const e=[],i=Math.max(1,this.columnCount),r=Math.max(1,this.rowCount);for(let s=0;s<r;s++)for(let o=0;o<i;o++){const a=new D().makeTranslation(o*this.columnSpacing,s*this.rowSpacing,0),c=new D().multiplyMatrices(this.getFullInsertionTransform(),a);for(const l of t.newIterator())e.push(...Dd(l.subGetIntersectCurves(),c))}return e}subWorldDraw(t){const e=this.blockTableRecord;if(e!=null){const i=[];this._attribs.forEach(a=>{if(!a.isInvisible){const c=a.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 Je.instance.draw(t,e,this.resolvedColor,i,!0,this.blockTransform,this._normal);const o=[];for(let a=0;a<s;a++)for(let c=0;c<r;c++){const l=new D().makeTranslation(c*this.columnSpacing,a*this.rowSpacing,0),h=new D().multiplyMatrices(this.blockTransform,l),u=Je.instance.draw(t,e,this.resolvedColor,c===0&&a===0?i:[],!0,h,this._normal);u&&o.push(u)}return t.group(o)}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 o=this.blockTableRecord;if(!o)return;const a=new D().multiplyMatrices(s,this.getFullInsertionTransform()),c=a.clone().invert(),l=new _(e).applyMatrix4(c),h=new _(i).applyMatrix4(c),u=[];for(const d of o.newIterator()){const g=[];if(d instanceof In){d.subGetOsnapPoints(t,e,i,g,void 0,a),u.push(...g);continue}d.subGetOsnapPoints(t,l,h,g,void 0,a),g.forEach(f=>u.push(new _(f).applyMatrix4(a)))}if(u.length!==0)if(t===I.Nearest||t===I.Perpendicular||t===I.Tangent){const d=ie(e,u);d&&r.push(d)}else r.push(...u)}subEntityGetOsnapPoints(t,e,i,r,s,o,a=new Set){if(s===this.objectId||a.has(this.objectId))return!1;a.add(this.objectId);try{const c=this.blockTableRecord;if(c==null)return!1;const l=new D().multiplyMatrices(o,this.getFullInsertionTransform());for(const h of c.newIterator()){if(h.objectId===s){const u=new _(e).applyMatrix4(l.clone().invert()),d=new _(i).applyMatrix4(l.clone().invert()),g=[];return h.subGetOsnapPoints(t,u,d,g,s,l),h instanceof In?g.forEach(f=>{r.push(f.clone())}):g.forEach(f=>{r.push(new _(f).applyMatrix4(l))}),!0}if(h instanceof In&&h.subEntityGetOsnapPoints(t,e,i,r,s,l,a))return!0}return!1}finally{a.delete(this.objectId)}}getInsertionPoint(t){var r;const e=((r=this.blockTableRecord)==null?void 0:r.origin)??_.ORIGIN,i=new D().multiplyMatrices(t,this.getFullInsertionTransform());return new _(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,o=this.scaleFactors.y,a=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,f=this.columnSpacing,p=this.rowSpacing;const m=()=>{this.position=new _(e,i,r),this.scaleFactors=new _(s,o,a),this.rotation=C.degToRad(c),this.normal.copy(new A(l,h,u)),this.columnCount=d>0?d:1,this.rowCount=g>0?g:1,this.columnSpacing=f,this.rowSpacing=p};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const y=t.readItem();if(!y)break;const b=Number(y.code),w=Number(y.value);switch(b){case 10:e=w;break;case 20:i=w;break;case 30:r=w;break;case 2:this.blockName=String(y.value);break;case 41:s=w;break;case 42:o=w;break;case 43:a=w;break;case 44:f=w;break;case 45:p=w;break;case 50:c=w;break;case 66:break;case 70:d=w;break;case 71:g=w;break;case 210:l=w;break;case 220:h=w;break;case 230:u=w;break;case 100:return t.pushBackItem(y),m(),this}}return m(),this}};In.typeName="BlockReference";let xe=In;const jl=[0,Math.PI/2,Math.PI,Math.PI/2*3],Ts=class Ts extends It{constructor(t,e,i=A.Z_AXIS){super(),this._thickness=0;const r=Qe(i);this._geo=new Pt(t,e,0,Y,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}subGetIntersectCurves(){return[{kind:"circArc",arc:this._geo.clone(),extendable:!1}]}get closed(){return this._geo.closed}get area(){return this._geo.area}subGetOsnapPoints(t,e,i,r){switch(t){case I.Center:case I.Centroid:r.push(this._geo.center);break;case I.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 I.Nearest:{const s=this._geo.nearestPoint(e);r.push(s)}break;case I.Tangent:{const s=this._geo.tangentPoints(e);r.push(...s);break}case I.Perpendicular:{const s=this._geo.perpendicularPoints(e),o=ie(e,s);o&&r.push(o);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 jl)t.push(this._geo.getPointAtAngle(e));return t}subMoveGripPointsAt(t,e){return bt(t,i=>{this.moveGripAt(i,e)}),this}transformBy(t){return this._geo.transform(t),this}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){return t.circularArc(this._geo)}dxfOutFields(t){super.dxfOutFields(t);const e=jt(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,o=this.normal.x,a=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:o=u;break;case 220:a=u;break;case 230:c=u;break}}return this.applyDxfInGeometry(e,i,r,s,o,a,c),this}applyDxfInGeometry(t,e,i,r,s,o,a){const c=new A(s,o,a);this._geo.normal=c,this._geo.refVec=Qe(this._geo.normal),this.center=At({x:t,y:e,z:i},this.normal),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 Ts(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=jl[t-1],r=this._geo.getPointAtAngle(i),o=new _(r.x+e.x,r.y+e.y,(r.z??0)+(e.z??0)).distanceTo(this.center);o>0&&(this.radius=o);break}}}};Ts.typeName="Circle";let Gr=Ts;const ni=[0,Math.PI/2,Math.PI,Math.PI/2*3],Ls=class Ls extends It{get dxfTypeName(){return"ELLIPSE"}constructor(t,e,i,r,s,o,a){super(),this._geo=new Pe(t,e,i,r,s,o,a)}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}subGetIntersectCurves(){return[{kind:"ellipseArc",arc:this._geo.clone(),extendable:!this.closed}]}get closed(){return this._geo.closed||Math.abs(this._geo.deltaAngle-Y)<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 ni)t.push(this._geo.getPointAtAngle(e));else t.push(this._geo.startPoint),t.push(this._geo.endPoint);return t}subMoveGripPointsAt(t,e){return bt(t,i=>{this.moveGripAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){switch(t){case I.EndPoint:this.closed||(r.push(this._geo.startPoint),r.push(this._geo.endPoint));break;case I.MidPoint:this.closed||r.push(this._geo.midPoint);break;case I.Center:case I.Centroid:r.push(this._geo.center);break;case I.Quadrant:if(this.closed)for(const s of ni)r.push(this._geo.getPointAtAngle(s));break;case I.Nearest:r.push(this._geo.nearestPoint(e));break;case I.Tangent:r.push(...this._geo.tangentPoints(e));break;case I.Perpendicular:{const s=this._geo.perpendicularPoints(e),o=ie(e,s);o&&r.push(o);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}}]}]}}get directBatchPrimitive(){return"lineStrip"}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,o=this.majorAxis.y*this.majorAxisRadius,a=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 f=t.readItem();if(!f)break;const p=Number(f.code),m=Number(f.value);switch(p){case 10:e=m;break;case 20:i=m;break;case 30:r=m;break;case 11:s=m;break;case 21:o=m;break;case 31:a=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,o,a,c,l,h,u,d,g),this}applyDxfInGeometry(t,e,i,r,s,o,a,c,l,h,u,d){const g=Math.hypot(r,s,o)||1;this._geo=new Pe({x:t,y:e,z:i},{x:a,y:c,z:l},{x:r,y:s,z:o},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,o=Math.hypot(s.x,s.y)||1,a=this.minorAxisRadius/this.majorAxisRadius*o||1,c=s.x/o,l=s.y/o,h=-l,u=c,d=i*c+r*l,g=i*h+r*u;return(d/o)**2+(g/a)**2>=1?1:-1}moveGripAt(t,e){switch(t){case 0:this.transformBy(D.makeTranslation(e));break;case 1:if(this.closed)this.moveQuadrantGripAt(ni[0],e);else{const i=this._geo.startPoint;this._geo.startAngle=Le(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(ni[1],e);else{const i=this._geo.endPoint;this._geo.endAngle=Le(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(ni[t-1],e);break}}moveQuadrantGripAt(t,e){const i=this._geo.getPointAtAngle(t),r=new _(i.x+e.x,i.y+e.y,(i.z??0)+(e.z??0)),s=this._geo.center,o=r.x-s.x,a=r.y-s.y,c=(r.z??0)-(s.z??0),l=t===0||t===Math.PI?this._geo.majorAxis:this._geo.minorAxis,h=o*l.x+a*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 Ls(e.center,e.normal,e.majorAxis,e.majorAxisRadius,e.minorAxisRadius,e.startAngle,e.endAngle):null}};Ls.typeName="Ellipse";let Hr=Ls;const Tc=class Tc extends tt{get dxfTypeName(){return"3DFACE"}constructor(){super(),this._vertices=[new _,new _,new _],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 _),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 j().setFromPoints(this._vertices)}subGetIntersectCurves(){return $t(this._vertices,!0)}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),iu(t)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subMoveGripPointsAt(t,e){return Qn(t,e,this._vertices),this}subGetOsnapPoints(t,e,i,r){Ks(this._vertices,!0,t,e,r)}transformBy(t){return this._vertices.forEach(e=>e.applyMatrix4(t)),this}get directBatchPrimitive(){return"lineSegments"}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 o=0;for(let a=0;a<4;++a)this.isEdgeVisibleAt(a)||(o|=1<<a);return t.writeInt16(70,o),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),o=Number(r.value);switch(s){case 10:case 11:case 12:case 13:e[s-10].x=o;break;case 20:case 21:case 22:case 23:e[s-20].y=o;break;case 30:case 31:case 32:case 33:e[s-30].z=o;break;case 70:i=o;break}}return e.forEach((r,s)=>this.setVertexAt(s,r)),this._edgeInvisibilities=i,this}};Tc.typeName="Face";let Wr=Tc;var Bt=(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))(Bt||{}),ut=(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))(ut||{}),at=(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))(at||{});function Ub(n){return n==4||n==5||n==6||n==7||n==12||n==13||n==14||n==15||n==16||n==17}function Gb(n){return n==1||n==2||n==3||n==8||n==9||n==10||n==21}const T={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",COMPAREHATCH:"COMPAREHATCH",COMPAREPROPS:"COMPAREPROPS",COMPARERCMARGIN:"COMPARERCMARGIN",COMPARETEXT:"COMPARETEXT",COMPARETOLERANCE:"COMPARETOLERANCE",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",LOGINNAME:"LOGINNAME",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"},Hb=Object.freeze(Object.values(T));function Wb(){try{const n=typeof process<"u"&&process.env?process.env:void 0;if(!n)return"";const t=n.USERNAME||n.USER||n.LOGNAME||"";return typeof t=="string"?t.trim():""}catch{return""}}const Ms=class Ms{constructor(){this.registry=new Map,this.cache=new Map,this.events={sysVarChanged:new gt},this.registerVar({name:T.ANGBASE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:T.ANGDIR,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:T.AUNITS,type:"number",isDbVar:!0,defaultValue:Bt.DecimalDegrees}),this.registerVar({name:T.AUPREC,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:T.CECOLOR,type:"color",isDbVar:!0,defaultValue:new U(exports.AcCmColorMethod.ByLayer)}),this.registerVar({name:T.CELTSCALE,type:"number",isDbVar:!0,defaultValue:-1}),this.registerVar({name:T.CELTYPE,type:"string",isDbVar:!0,defaultValue:mt}),this.registerVar({name:T.CELWEIGHT,type:"number",isDbVar:!0,defaultValue:exports.AcGiLineWeight.ByLayer}),this.registerVar({name:T.CETRANSPARENCY,type:"transparency",isDbVar:!0,defaultValue:new pt}),this.registerVar({name:T.CLAYER,type:"string",isDbVar:!0,defaultValue:"0"}),this.registerVar({name:T.CMLEADERSTYLE,type:"string",isDbVar:!0,defaultValue:Re}),this.registerVar({name:T.CMLSCALE,type:"number",isDbVar:!0,defaultValue:1}),this.registerVar({name:T.CMLSTYLE,type:"string",isDbVar:!0,defaultValue:Oe}),this.registerVar({name:T.COLORTHEME,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:T.COMPAREHATCH,type:"number",isDbVar:!0,defaultValue:Br}),this.registerVar({name:T.COMPAREPROPS,type:"number",isDbVar:!1,defaultValue:cd}),this.registerVar({name:T.COMPARERCMARGIN,type:"number",isDbVar:!0,defaultValue:Fr}),this.registerVar({name:T.COMPARETEXT,type:"number",isDbVar:!0,defaultValue:Dr}),this.registerVar({name:T.COMPARETOLERANCE,type:"number",isDbVar:!0,defaultValue:Xr}),this.registerVar({name:T.DYNMODE,type:"number",isDbVar:!1,defaultValue:3}),this.registerVar({name:T.DYNPROMPT,type:"boolean",isDbVar:!1,defaultValue:!0}),this.registerVar({name:T.DWGNAME,type:"string",isDbVar:!0,readOnly:!0,defaultValue:"Drawing1.dwg"}),this.registerVar({name:T.GRIPCOLOR,type:"number",isDbVar:!1,defaultValue:Qu}),this.registerVar({name:T.GRIPHOT,type:"number",isDbVar:!1,defaultValue:Ju}),this.registerVar({name:T.GRIPOBJLIMIT,type:"number",isDbVar:!1,defaultValue:100}),this.registerVar({name:T.GRIPS,type:"number",isDbVar:!1,defaultValue:2}),this.registerVar({name:T.GRIPSIZE,type:"number",isDbVar:!1,defaultValue:td}),this.registerVar({name:T.HPANG,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:T.HPASSOC,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:T.HPBACKGROUNDCOLOR,type:"color",isDbVar:!0,defaultValue:new U(exports.AcCmColorMethod.None)}),this.registerVar({name:T.HPCOLOR,type:"color",isDbVar:!0,defaultValue:new U(exports.AcCmColorMethod.ByLayer)}),this.registerVar({name:T.HPDOUBLE,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:T.HPISLANDDETECTION,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:T.HPLAYER,type:"string",isDbVar:!0,defaultValue:"."}),this.registerVar({name:T.HPNAME,type:"string",isDbVar:!1,defaultValue:qu}),this.registerVar({name:T.HPSCALE,type:"number",isDbVar:!1,defaultValue:1}),this.registerVar({name:T.HPSEPARATE,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:T.HPTRANSPARENCY,type:"transparency",isDbVar:!0,defaultValue:new pt}),this.registerVar({name:T.INSUNITS,type:"number",isDbVar:!0,defaultValue:at.Millimeters}),this.registerVar({name:T.LOGINNAME,type:"string",isDbVar:!1,readOnly:!0,defaultValue:Wb()}),this.registerVar({name:T.LUNITS,type:"number",isDbVar:!0,defaultValue:ut.Decimal}),this.registerVar({name:T.LUPREC,type:"number",isDbVar:!0,defaultValue:4}),this.registerVar({name:T.LWDISPLAY,type:"boolean",isDbVar:!0,defaultValue:!1}),this.registerVar({name:T.MEASUREMENT,type:"number",isDbVar:!0,defaultValue:1}),this.registerVar({name:T.MEASUREMENTCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new U(exports.AcCmColorMethod.ByColor);return t.setRGB(96,165,250),t})()}),this.registerVar({name:T.MODELBKCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new U(exports.AcCmColorMethod.ByColor);return t.setRGB(0,0,0),t})()}),this.registerVar({name:T.OSMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:T.ORTHOMODE,type:"number",isDbVar:!0,defaultValue:0}),this.registerVar({name:T.OPENPROF,type:"boolean",isDbVar:!1,defaultValue:!1}),this.registerVar({name:T.PAPERBKCOLOR,type:"color",isDbVar:!1,defaultValue:(()=>{const t=new U(exports.AcCmColorMethod.ByColor);return t.setRGB(255,255,255),t})()}),this.registerVar({name:T.PICKBOX,type:"number",isDbVar:!1,defaultValue:10}),this.registerVar({name:T.POLARADDANG,type:"string",isDbVar:!1,defaultValue:""}),this.registerVar({name:T.POLARMODE,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:T.POLARANG,type:"number",isDbVar:!1,defaultValue:90}),this.registerVar({name:T.SHORTCUTMENU,type:"number",isDbVar:!1,defaultValue:0}),this.registerVar({name:T.TEXTSTYLE,type:"string",isDbVar:!0,defaultValue:lt}),this.registerVar({name:T.UNITMODE,type:"number",isDbVar:!0,defaultValue:0})}static instance(){return this._instance||(this._instance=new Ms),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))}setLoginName(t){const e=this.normalizeName(T.LOGINNAME);this.cache.set(e,t.trim())}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 o=this.normalizeName(t);if(this.hasValueChanged(e,i)){if(r.transactionManager.isRecording())r.transactionManager.recordSysvar(o,e);else if(r.transactionManager.strictMode&&!r.transactionManager.isApplyingUndoRedo())throw new Error(`Cannot change system variable ${o} outside an active transaction.`);s(),!r.transactionManager.isApplyingUndoRedo()&&!r.transactionManager.isRecording()&&this.events.sysVarChanged.dispatch({database:r,name:o,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 o=this.parseTransparency(e);if(o==null||o.isInvalid)throw new Error("Invalid transparency value!");e=o}else if(r.type!=="string"&&(typeof e=="string"||e instanceof String)){if(r.type==="number"){const o=Number(e);if(Number.isNaN(o))throw new Error("Invalid number input!");e=o}else if(r.type==="boolean")e=this.parseBoolean(e);else if(r.type==="color"){const o=this.parseColorSysVar(t,e,i);if(o==null)throw new Error("Invalid color value!");e=o}}if(t===T.GRIPCOLOR.toLowerCase()){const o=Math.trunc(e);if(!Number.isFinite(o)||o<Qo||o>Jo)throw new Error(`Invalid GRIPCOLOR value! Valid range is ${Qo} to ${Jo}.`);e=o}if(t===T.GRIPHOT.toLowerCase()){const o=Math.trunc(e);if(!Number.isFinite(o)||o<ta||o>ea)throw new Error(`Invalid GRIPHOT value! Valid range is ${ta} to ${ea}.`);e=o}if(t===T.GRIPOBJLIMIT.toLowerCase()){const o=Math.trunc(e);if(!Number.isFinite(o)||o<0||o>32767)throw new Error("Invalid GRIPOBJLIMIT value! Valid range is 0 to 32767.");e=o}if(t===T.GRIPS.toLowerCase()){const o=Math.trunc(e);if(!Number.isFinite(o)||o<0||o>2)throw new Error("Invalid GRIPS value! Valid range is 0 to 2.");e=o}if(t===T.GRIPSIZE.toLowerCase()){const o=Math.trunc(e);if(!Number.isFinite(o)||o<na||o>ia)throw new Error(`Invalid GRIPSIZE value! Valid range is ${na} to ${ia}.`);e=o}t===T.COMPAREHATCH.toLowerCase()&&(e=pe("COMPAREHATCH",e,zs,Vs)),t===T.COMPAREPROPS.toLowerCase()&&(e=pe("COMPAREPROPS",e,ld,hd)),t===T.COMPARERCMARGIN.toLowerCase()&&(e=pe("COMPARERCMARGIN",e,js,Us)),t===T.COMPARETEXT.toLowerCase()&&(e=pe("COMPARETEXT",e,Gs,Hs)),t===T.COMPARETOLERANCE.toLowerCase()&&(e=pe("COMPARETOLERANCE",e,Ws,$s)),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===T.HPCOLOR.toLowerCase()&&(r==="."||r==="use current")?i.cecolor.clone():t===T.HPBACKGROUNDCOLOR.toLowerCase()&&(r===""||r==="."||r==="none")?new U(exports.AcCmColorMethod.None):U.fromString(e)}parseTransparency(t){if(t instanceof pt)return t;if(typeof t=="number")return pt.deserialize(t);if(!(typeof t!="string"&&!(t instanceof String)))return pt.fromString(String(t))}hasValueChanged(t,e){return t instanceof U&&e instanceof U||t instanceof pt&&e instanceof pt?!t.equals(e):!Object.is(t,e)}normalizeName(t){return t.toLowerCase()}};Ms._instance=null;let vt=Ms;const Yd="Load Database",Ul=3e4,$b=12e4,qb=1024*1024;class Yt extends Ih{constructor(t,e){super(t.stage),this.data=t,this.progress=e}async run(t){const e=Na.getInstance().getEntry(Yd),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 cc{constructor(t={}){this.config={useWorker:t.useWorker??!0,...t}}async read(t,e,i={}){const{minimumChunkSize:r=10,progress:s,timeout:o,sysVars:a}=i,c={name:Yd,data:{total:0},format(){let d="";return Object.keys(this.data).forEach(g=>{g!=="total"&&(d+=`- ${g}: ${this.data[g]} ms
10
+ `)}),d+=`- total: ${this.data.total} ms`,d}};Na.getInstance().collect(c),this.progress=s;const l={value:0},h=new Th;h.setCompleteCallback(()=>this.onFinished()),h.setErrorCallback(d=>this.onError(d)),h.addTask(new Yt({stage:"START",step:1,progress:l,task:async d=>d},s)),h.addTask(new Yt({stage:"PARSE",step:5,progress:l,task:async d=>await this.parse(d,o)},s)),h.addTask(new Yt({stage:"LTYPE",step:1,progress:l,task:async d=>(this.processLineTypes(d.model,e),d)},s)),h.addTask(new Yt({stage:"STYLE",step:1,progress:l,task:async d=>(this.processTextStyles(d.model,e),d)},s)),h.addTask(new Yt({stage:"DIMSTYLE",step:1,progress:l,task:async d=>(this.processDimStyles(d.model,e),d)},s)),h.addTask(new Yt({stage:"LAYER",step:1,progress:l,task:async d=>(this.processLayers(d.model,e),e.tables.layerTable.numEntries===0&&e.createDefaultData({layer:!0}),d)},s)),h.addTask(new Yt({stage:"VPORT",step:1,progress:l,task:async d=>(this.processViewports(d.model,e),d)},s)),h.addTask(new Yt({stage:"HEADER",step:1,progress:l,task:async d=>{if(this.processClasses(d.model,e),this.processHeader(d.model,e),a){const g=vt.instance();for(const[f,p]of Object.entries(a))g.setVar(f,p,e)}return d}},s)),h.addTask(new Yt({stage:"BLOCK_RECORD",step:5,progress:l,task:async d=>(this.processBlockTables(d.model,e),d)},s)),h.addTask(new Yt({stage:"OBJECT",step:5,progress:l,task:async d=>(this.processObjects(d.model,e),e.objects.layout.numEntries===0&&e.createDefaultData({layout:!0}),d)},s)),h.addTask(new Yt({stage:"BLOCK",step:5,progress:l,task:async d=>(await this.processBlocks(d.model,e),d)},s)),h.addTask(new Yt({stage:"ENTITY",step:100,progress:l,task:async d=>(await this.processEntities(d.model,e,r,l,s),d)},s)),h.addTask(new Yt({stage:"END",step:0,progress:l,task:async d=>d},s));const u=Date.now();await h.run(t),c.data.total=Date.now()-u}onError(t){if(this.progress){const e=t.task;this.progress(e.data.progress.value,e.data.stage,"ERROR",void 0,t)}return t.task.name==="ENTITY"?!1:(this.onFinished(),!0)}onFinished(){this.progress&&(this.progress(100,"END","END"),Je.instance.clear())}getParserWorkerTimeout(t,e){const i=e??this.config.timeout;if(i!=null)return i;const r=Math.ceil(t.byteLength/qb),s=Ul+r*1e3;return Math.min($b,Math.max(Ul,s))}async parse(t,e){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 zd{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 qn(),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,o=Math.min(i+this._chunkSize,this._count);await t(s,o),i=o,i<this._count&&await this.scheduleTask(r)};await r(),await(e==null?void 0:e())}}class Vd extends cc{constructor(t){super({}),this._database=t}async parse(){return{model:this._database,data:{unknownEntityCount:0}}}async processEntities(t,e,i,r,s){let o=t.tables.blockTable.modelSpace.newIterator().toArray();const a=o.length,c=new zd(a,100-r.value,i);this.config.convertByEntityType&&(o=this.groupAndFlattenByType(o));const l=e.tables.blockTable.modelSpace;await c.processChunk(async(h,u)=>{let d=[],g=h<u?o[h].type:"";for(let f=h;f<u;f++){const p=o[f];this.config.convertByEntityType&&p.type!==g&&(this.triggerEvents(l,d),d=[],g=p.type),d.push(p)}if(this.triggerEvents(l,d),s){let f=r.value+u/a*(100-r.value);f>100&&(f=100),await s(f,"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 o of t)this._database.events.dictObjetSet.dispatch({database:this._database,object:o,key:o.layoutName});const e=this._database.objects.imageDefinition.newIterator();for(const o of e)this._database.events.dictObjetSet.dispatch({database:this._database,object:o,key:o.objectId});const i=this._database.objects.mleaderStyle.newIterator();for(const o of i)this._database.events.dictObjetSet.dispatch({database:this._database,object:o,key:o.objectId});const r=this._database.objects.layerFilter.newIterator();for(const o of r)this._database.events.dictObjetSet.dispatch({database:this._database,object:o,key:o.objectId});const s=this._database.objects.layerIndex.newIterator();for(const o of s)this._database.events.dictObjetSet.dispatch({database:this._database,object:o,key:o.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})}}var jd=(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))(jd||{}),lc=(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))(lc||{}),Ud=(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))(Ud||{}),Gd=(n=>(n[n.None=0]="None",n[n.Leading=1]="Leading",n[n.Trailing=2]="Trailing",n[n.LeadingAndTrailing=3]="LeadingAndTrailing",n))(Gd||{}),Hd=(n=>(n[n.Bottom=0]="Bottom",n[n.Middle=1]="Middle",n[n.Top=2]="Top",n))(Hd||{});const Cs=class Cs extends De{constructor(t,e){t=t||{},ne(t,Cs.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),o=this.database.tables.blockTable.getAt(this.dimblk2);return t.writeSubclassMarker("AcDbDimStyleTableRecord"),t.writeString(2,this.name),t.writeInt16(70,0),t.writeString(3,this.dimpost),t.writeString(4,this.dimapost),t.writeDouble(40,this.dimscale),t.writeDouble(41,this.dimasz),t.writeDouble(42,this.dimexo),t.writeDouble(43,this.dimdli),t.writeDouble(44,this.dimexe),t.writeDouble(140,this.dimtxt),t.writeDouble(147,this.dimgap),t.writeInt16(170,this.dimalt),t.writeInt16(171,this.dimtol),t.writeInt16(172,this.dimlim),t.writeInt16(173,this.dimtih),t.writeInt16(174,this.dimtoh),t.writeObjectId(340,e==null?void 0:e.objectId),t.writeObjectId(341,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,o==null?void 0:o.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}};Cs.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:lt,dimldrblk:"",dimblk:"",dimblk1:"",dimblk2:"",dimlwd:-2,dimlwe:-2};let Ht=Cs;function Wd(){return{color:new U,description:"",standardFlags:0,isHidden:!1,isInUse:!0,isOff:!1,isPlottable:!0,transparency:new pt,linetype:"",lineWeight:1,materialId:-1}}const Kb=["name",...Object.keys(Wd())];class $i extends De{constructor(t,e){t=t||{},ne(t,Wd()),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=pt.deserialize(Number(e.value));break;case 4:this.description=String(e.value);break}}return this}}class qe extends De{constructor(t,e){t=t||{},ne(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),o=this.escapeSvgAttribute((t==null?void 0:t.stroke)??"currentColor"),a=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(w=>w.elementLength!==0))return this.buildSvgString({width:e,height:i,stroke:o,strokeWidth:s,lineSegments:[[l,h]],dots:[],y:c});const g=[],f=[],p=u/(this.patternLength*a),m=.5,y=Math.max(s*2,2);let b=l;for(;b<h;)for(const w of d){if(b>=h)break;const x=w.elementLength;if(x===0){f.push(b),b=Math.min(b+y,h);continue}const S=Math.max(Math.abs(x)*p,m),P=Math.min(b+S,h);x>0&&P>b&&g.push([b,P]),b=P}return this.buildSvgString({width:e,height:i,stroke:o,strokeWidth:s,lineSegments:g,dots:f,y:c})}buildSvgString(t){const{width:e,height:i,stroke:r,strokeWidth:s,lineSegments:o,dots:a,y:c}=t,l=o.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=a.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 $r extends De{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 Qs extends De{constructor(t,e){t=t||{},ne(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 $d extends De{constructor(t,e){t=t||{},ne(t,{standardFlags:0,origin:new _(0,0,0),xAxis:new _(1,0,0),yAxis:new _(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 _,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 Zb=()=>({center:new M,viewDirectionFromTarget:new _(0,0,1),viewTarget:new _(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 _(0,0,0),ucsXAxis:new _(1,0,0),ucsYAxis:new _(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 hc extends De{constructor(t,e){t=t||{},ne(t,{gsView:Zb()}),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 Gl=2,Qb=.45,Jb=1e5;function t1(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 e1(n,t){if(Number.isFinite(t)&&t>0)return t;const e=t1(n);return e!=null&&e>0?e:1}function n1(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 Hl(n){return{x:(n.min.x+n.max.x)/2,y:(n.min.y+n.max.y)/2}}function i1(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 hc{static isActiveVportName(t){return t.toLowerCase()===Vn.toLowerCase()}constructor(t,e){t=t||{},ne(t,{circleSides:100,lowerLeftCorner:new M(0,0),upperRightCorner:new M(1,1),snapBase:new M(0,0),snapAngle:0,snapSpacing:new M(0,0),standardFlag:0,gridSpacing:new M,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,o=e.y;if(Number.isFinite(r)&&r!==0){const d=Math.cos(r),g=Math.sin(r);s=e.x*d-e.y*g,o=e.x*g+e.y*d}const a=this.viewTarget;a&&Number.isFinite(a.x)&&Number.isFinite(a.y)&&(s+=a.x,o+=a.y);const c=e1(this,t),l=i*c,h=i/2,u=l/2;return new kt().expandByPoint({x:s-u,y:o-h}).expandByPoint({x:s+u,y:o+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,o=e.max.y-e.min.y;if(i<=0||r<=0||s<=0||o<=0||i>s*Gl||r>o*Gl)return!1;const a=Math.max(s,o)*Qb,c=Hl(t),l=Hl(e);if(Math.hypot(c.x-l.x,c.y-l.y)>a)return!1;const u=i*r,d=n1(t,e);return!(d<=0||d/u<.25)}resolveModelViewBox(t,e){const i=this.modelViewBox(t);if(!(!i||!Ke.isModelViewBoxStructurallyValid(i))){if(i1(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)<=Jb}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 qd extends hc{constructor(t,e){t=t||{};const i=t.viewWidth!==void 0;ne(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 Js=192,ki=193,to=194,eo=195,Kd=200;function So(n){if(n.isByBlock)return ki<<24>>0;if(n.isByLayer)return Js<<24>>0;const t=n.colorIndex;if(t!=null&&t>0&&t<256)return(eo<<24|t&255)>>0;const e=n.RGB;return e!=null?(to<<24|e&16777215)>>0:ki<<24>>0}function fe(n){const t=new U(exports.AcCmColorMethod.ByBlock);switch(n>>>24&255){case Js:t.setByLayer();break;case ki:case Kd:t.setByBlock();break;case eo:t.colorIndex=n&255;break;case to: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 r1=127;var Zd=(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))(Zd||{});const en=A.Z_AXIS,s1=529;function o1(n){const t=n>>24&255;return t===to?{rgb:n&16777215}:t===Js?{colorIndex:256}:t===ki?{colorIndex:0}:t===eo?{colorIndex:n&255}:{colorIndex:n&255}}function ko(n){return new A(n.x,n.y,n.z??0)}function Eo(n){return new _(n.x,n.y,n.z??0)}function Wl(n){return{x:n[0],y:n[1],z:n[2]}}class ra{constructor(t,e={}){this._index=8,this._colorIndex=256,this._layer="0",this._linetype=mt,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),o=r.getUint32(4,!0);if(s<8)break;if(o===1){const a=t.subarray(e+8,e+s);return this.readExtents(a),((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 o=this._index;for(;o<s.length;){const a=new DataView(s.buffer,s.byteOffset+o,8),c=a.getUint32(0,!0),l=a.getUint32(4,!0);if(c<8)break;const h=s.subarray(o+8,o+c);this.dispatchChunk(t,e,l,h),l!==20&&(this._fill=!1),o+=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 U(exports.AcCmColorMethod.ByColor,this._rgbColor):this._colorIndex===256?e.color=new U(exports.AcCmColorMethod.ByLayer):this._colorIndex===0?e.color=new U(exports.AcCmColorMethod.ByBlock):this._colorIndex===7?e.color=new U(exports.AcCmColorMethod.ByACI,7):e.color=new U(exports.AcCmColorMethod.ByACI,this._colorIndex),e.lineType={name:this._linetype,type:this.resolveLineStyleType(),standardFlag:0,description:"",totalPatternLength:0}}resolveLineStyleType(){return this._linetype===mt?"ByLayer":this._linetype===ye?"ByBlock":"UserSpecified"}transformPoint(t){const e=Array.isArray(t)?Wl(t):t,i=Eo(e);return this._matrices.length>0&&i.applyMatrix4(this._matrices[this._matrices.length-1]),i}transformVector(t){const e=Array.isArray(t)?Wl(t):t,i=ko(e);return this._matrices.length>0&&i.transformDirection(this._matrices[this._matrices.length-1]),!Number.isFinite(i.lengthSq())||i.lengthSq()<1e-24?en.clone():i.normalize()}pushEntity(t,e){e&&t.push(e)}readExtents(t){const e=new Kt(t),i=e.readVertex(),r=e.readVertex();this._extents=[new _(i[0],i[1],i[2]),new _(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=ye:this._linetype=mt}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=o1(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>s1?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 Kt(t);let r=i.readLong();e&&(r+=1);const s=[];for(;r>0;){const[a,c,l]=i.readVertex();s.push(this.transformPoint({x:a,y:c,z:l})),r-=1}let o=en;return e&&s.length>0&&(o=ko(s.pop())),{vertices:s,normal:o}}drawCircle(t,e,i){const r=new Kt(i),s=r.readVertex(),o=r.readFloat(),a=this.transformVector(r.readVertex());let c=Eo({x:s[0],y:s[1],z:s[2]});a.equals(en)||(c=jt(c,a)),c=this.transformPoint(c);const l=Qe(a),h=new Pt(At(c,a),o,0,Y,a,l);this.applyTraits(t),this.pushEntity(e,t.circularArc(h))}drawCircle3P(t,e,i){const r=new Kt(i),s=this.transformPoint(r.readVertex()),o=this.transformPoint(r.readVertex()),a=this.transformPoint(r.readVertex()),c=Pt.computeCenterPoint(s,o,a);if(!c)return;const l=c.distanceTo(s),h=new Pt(c,l,0,Y,en);this.applyTraits(t),this.pushEntity(e,t.circularArc(h))}drawCircularArc(t,e,i){const r=new Kt(i),s=r.readVertex(),o=r.readFloat(),a=r.readVertex(),c=r.readVertex(),l=r.readFloat(),h=this.transformVector(a),u=Eo({x:s[0],y:s[1],z:s[2]}),d=ko({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():Qe(h),f=0,p=l,m=new Pt(this.transformPoint(u),o,f,p,h,g);this.applyTraits(t),this.pushEntity(e,t.circularArc(m))}drawCircularArc3P(t,e,i){const r=new Kt(i),s=this.transformPoint(r.readVertex()),o=this.transformPoint(r.readVertex()),a=this.transformPoint(r.readVertex()),c=Pt.computeCenterPoint(s,a,o);if(!c)return;const l=c.distanceTo(s),h=Le(c,s,en),u=Le(c,a,en),d=new Pt(c,l,h,u,en);this.applyTraits(t),this.pushEntity(e,t.circularArc(d))}drawEllipticArc(t,e,i){const r=new Kt(i),s=this.transformPoint(r.readVertex()),o=this.transformVector(r.readVertex()),a=r.readFloat(),c=r.readFloat(),l=r.readFloat(),h=r.readFloat(),u=r.readFloat(),d=At({x:Math.cos(u)*a,y:Math.sin(u)*a,z:0},o),g=new Pe(s,o,d,a,c,l,h);this.applyTraits(t),this.pushEntity(e,t.ellipticalArc(g))}drawPolyline(t,e,i,r){var o,a;const{vertices:s}=this.loadVertices(i,r);if(s.length!==0){if(s.length===1){this.applyTraits(t);const c=((o=this._database)==null?void 0:o.pdmode)??0,l=((a=this._database)==null?void 0:a.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 o=new it(r.map(l=>({x:l.x,y:l.y})),!0),a=new oe;a.add(o);const c=t.subEntityTraits;c.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},c.drawOrder=-1,this.applyTraits(t),this.pushEntity(e,t.area(a));return}const s=[...r,r[0]];this.applyTraits(t),this.pushEntity(e,t.lines(s))}drawLwPolyline(t,e,i){const r=new dd(i,this._dxfversion,this._encoding);let s=0,o=!1;r.readUnsignedLong();const a=r.readBitShort();a&8&&(s=r.readBitDouble()),a&512&&(o=!0);const c=r.readBitLong();if(c<=0)return;const l=a&16?r.readBitLong():0;this._dxfversion>="AC1024"&&(a&1024&&r.readBitLong(),a&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 f=r.readBitDoubleDefault(1,d[0]),p=r.readBitDoubleDefault(1,d[1]);d=[f,p],u.push(this.transformPoint({x:f,y:p,z:s}))}for(let g=0;g<l;g++)r.readBitDouble();o&&u.length>1&&u.push(u[0].clone()),this.applyTraits(t),this.pushEntity(e,t.lines(u))}drawShell(t,e,i){const r=new Kt(i),s=r.readLong(),o=[];for(let h=0;h<s;h++){const[u,d,g]=r.readVertex();o.push(this.transformPoint({x:u,y:d,z:g}))}const a=r.readLong(),c=[];let l=0;for(;l<a;){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=>o[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 Kt(i),o=this.transformPoint(s.readVertex()),a=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:o,normal:a,textDirection:c,text:d,height:l,widthFactor:h,obliqueAngle:u})}drawText2(t,e,i,r){const s=new Kt(i),o=this.transformPoint(s.readVertex()),a=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:o,normal:a,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},o={name:lt,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,o))}drawXline(t,e,i,r){const s=new Kt(i),o=this.transformPoint(s.readVertex()),a=this.transformPoint(s.readVertex()),c=new A().subVectors(a,o);if(c.lengthSq()===0)return;const l=1e6,h=r?o.clone().add(c.normalize().multiplyScalar(l)):o.clone().sub(c.normalize().multiplyScalar(l)),u=a.clone().add(c.normalize().multiplyScalar(l));this.applyTraits(t),this.pushEntity(e,t.lines([h,u]))}}function a1(n,t){if(!(t!=null&&t.length))return;const e=Gi(t);return n!=null&&n>0&&e.length>=n?e.subarray(0,n):e}const c1="ASM_Data";function sa(n){return String(n).trim().toUpperCase()}function l1(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=sa(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[c1]??[]}}function h1(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=l1(n);if(r.ownerHandle&&r.hexChunks.length>0){const s=Gi(r.hexChunks);s.length>0&&(t[r.ownerHandle]=s)}}else n.skipToEndOfObject()}return{byOwnerHandle:t}}function Qd(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();u1(n,t,i)}}function u1(n,t,e){switch(e){case"$ACADVER":{const i=ae(n);i&&(t.version=i);break}case"$CECOLOR":{const i=st(n);t.cecolor.colorIndex=i??256;break}case"$ANGBASE":t.angbase=st(n)??0;break;case"$ANGDIR":t.angdir=st(n)??0;break;case"$AUNITS":{const i=st(n);i!=null&&(t.aunits=i);break}case"$AUPREC":{const i=st(n);i!=null&&(t.auprec=i);break}case"$LUNITS":{const i=st(n);i!=null&&(t.lunits=i);break}case"$LUPREC":{const i=st(n);i!=null&&(t.luprec=i);break}case"$UNITMODE":{const i=st(n);i!=null&&(t.unitmode=i);break}case"$MEASUREMENT":{const i=st(n);i!=null&&(t.measurement=i);break}case"$CELTYPE":t.celtype=ae(n)||mt;break;case"$CETRANSPARENCY":{const i=ae(n)||"ByLayer";vt.instance().setVar(T.CETRANSPARENCY,i,t);break}case"$CELTSCALE":t.celtscale=st(n)??1;break;case"$CELWEIGHT":{const i=st(n);i!=null&&(t.celweight=i);break}case"$LWDISPLAY":t.lwdisplay=(st(n)??0)!==0;break;case"$TILEMODE":t.tilemode=(st(n)??1)!==0;break;case"$PSLTSCALE":t.psltscale=(st(n)??1)!==0;break;case"$CMLSTYLE":case"CMLSTYLE":t.cmlstyle=ae(n)||Oe;break;case"$CMLSCALE":case"CMLSCALE":{const i=st(n);i!=null&&Number.isFinite(i)&&(t.cmlscale=i);break}case"$CMLEADERSTYLE":case"CMLEADERSTYLE":t.cmleaderstyle=ae(n)||Re;break;case"$HPLAYER":case"HPLAYER":t.hplayer=ae(n)||".";break;case"$LTSCALE":t.ltscale=st(n)??1;break;case"$EXTMAX":{const i=$l(n);i&&(t.extmax=i);break}case"$EXTMIN":{const i=$l(n);i&&(t.extmin=i);break}case"$INSUNITS":{const i=st(n);i!=null&&(t.insunits=i);break}case"$OSMODE":t.osmode=st(n)??0;break;case"$ORTHOMODE":t.orthomode=st(n)??0;break;case"$COMPAREHATCH":{const i=oi(st(n),zs,Vs);i!=null&&(t.comparehatch=i);break}case"$COMPARERCMARGIN":{const i=oi(st(n),js,Us);i!=null&&(t.comparercmargin=i);break}case"$COMPARETEXT":{const i=oi(st(n),Gs,Hs);i!=null&&(t.comparetext=i);break}case"$COMPARETOLERANCE":{const i=oi(st(n),Ws,$s);i!=null&&(t.comparetolerance=i);break}case"$PDMODE":t.pdmode=st(n)??0;break;case"$PDSIZE":t.pdsize=st(n)??0;break;case"$TEXTSTYLE":t.textstyle=ae(n)||lt;break;case"$DIMSTYLE":t.dimstyle=ae(n)||lt;break;case"$CLAYER":t.clayer=ae(n)||"0";break;case"$HANDSEED":{const i=ae(n);i&&t.initializeHandleSeed(i);break}default:d1(n);break}}function ae(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 st(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 $l(n){let t=0,e=0,i=0,r=!1;for(;!n.atEof;){const s=n.peekItem();if(!s)break;const o=Number(s.code);if(o===9||o===0)break;n.readItem();const a=Number(s.value);o===10?(t=a,r=!0):o===20?(e=a,r=!0):o===30&&(i=a,r=!0)}return r?new _(t,e,i):void 0}function d1(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 Jd{constructor(t){this._expression=t}get expression(){return this._expression}}var tg=(n=>(n[n.Cancel=0]="Cancel",n[n.Ok=1]="Ok",n))(tg||{});class no{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 Jd(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?g1(this._filterExpression,t):!0:!1}showEditor(){return 0}}function g1(n,t){const e=n.trim();return e?ql(e,"OR").some(r=>ql(r,"AND").every(o=>f1(o,t))):!0}function ql(n,t){const e=new RegExp(`\\s+${t}\\s+`,"i");return n.split(e).map(i=>i.trim()).filter(i=>i.length>0)}function f1(n,t){var o;const e=n.trim().match(/^([A-Za-z_]+)\s*(==|=)\s*"?(.*?)"?\s*$/);if(!e)return!1;const i=e[1].toUpperCase(),r=e[3],s=m1(r);switch(i){case"NAME":return p1(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 a=(o=t.color)==null?void 0:o.colorIndex;return a!=null&&String(a)===r}case"LINETYPE":return t.linetype.localeCompare(r,void 0,{sensitivity:"accent"})===0;default:return!1}}function p1(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 m1(n){const t=n.trim().toLowerCase();return t==="true"||t==="1"?!0:t==="false"||t==="0"?!1:null}class Be{constructor(t,e){this._root=t??Be.createDefaultRoot(),this._current=e===void 0?this._root:e}static createDefaultRoot(){const t=new no;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 Be(this._root,this._current)}}class eg extends no{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 io="ACAD_LAYERFILTERS",Hn="ACLYDICTIONARY";function ng(n){const t=Be.createDefaultRoot(),e=new Be(t,t),i=Kl(n,Hn),r=Kl(n,io);if(i){for(const[s,o]of Object.entries(i.entries)){const a=oa(n,o,s);a&&t.addNested(a)}return e}if(r)for(const[s,o]of Object.entries(r.entries)){const a=oa(n,o,s);a&&t.addNested(a)}return e}function ig(n){const t=[];for(const e of n.root.getNestedFilters())t.push(og(e));return{nodes:t}}function rg(n){const t=new fn;for(const e of n)t.add({code:e.code,value:e.value});return t}function y1(n){return n?n.toArray().map(t=>({code:Number(t.code),value:t.value})):[]}function Kl(n,t){let e;for(const i of n.dictionaries.values()){const r=i.entries[t];if(!r)continue;const s=n.dictionaries.get(Te(r));if(!s)continue;if(!(i.ownerObjectId?n.xrecords.has(Te(i.ownerObjectId)):!1))return s;e=s}return e}function oa(n,t,e){const i=n.xrecords.get(Te(t));if(!i)return;const r=sg(i.data,e),s=r.isIdFilter?new eg:new no;if(s.setAllowRename(!0),s.setName(r.name||e),!r.isIdFilter)s.setFilterExpression(r.filterExpression);else{const o=s;for(const a of r.layerIds)o.addLayerId(a)}for(const o of b1(n,i)){const a=oa(n,o.handle,o.key);a&&s.addNested(a)}return s}function b1(n,t){const e=[],i=new Set,r=Te(t.handle),s=t.extensionDictionaryId?Te(t.extensionDictionaryId):void 0,o=(a,c)=>{const l=Te(c);i.has(l)||(i.add(l),e.push({key:a,handle:c}))};for(const a of n.dictionaries.values()){const c=a.ownerObjectId?Te(a.ownerObjectId):void 0;if(!c||!(c===r||c===s))continue;const h=a.entries[Hn];if(h){const u=n.dictionaries.get(Te(h));if(u){for(const[d,g]of Object.entries(u.entries))o(d,g);continue}}for(const[u,d]of Object.entries(a.entries))u===Hn||u===io||o(u,d)}return e}function sg(n,t=""){const e=[],i=[];let r=0,s,o,a;for(const f of n){const p=Number(f.code),m=f.value;p===1&&typeof m=="string"?e.push(m):p===300&&typeof m=="string"?o=m:p===301&&typeof m=="string"?a=m:p===70||p===90?r=Number(m)||0:p===290||p===280?s=Number(m)===1:(p===330||p===340||p===350||p===360)&&m!=null&&String(m).length>0&&i.push(Te(String(m)))}const c=e[0],h=o||(c==="AcLyLayerFilter"||c==="AcLyLayerGroup"?void 0:c)||t,u=e[1]??"";let d=a??u;!a&&d&&d!=="*"&&!/==/.test(d)&&(d=`NAME=="${d}"`);const g=a!=null&&a.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 og(n){const t=n.isIdFilter(),e=ag(n),i=n.getNestedFilters().map(s=>og(s));return{key:n.name||(t?"Group":"Filter"),isIdFilter:t,data:e,children:i}}function ag(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 Te(n){return n.trim().toUpperCase()}class cg extends Et{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 lg extends Et{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 o=Number(r.value);switch(s){case 70:break;case 10:e&&this._boundaryVertices.push(new M(e.x,e.y)),e={x:o,y:0};break;case 20:e&&(e.y=o);break;case 210:this._clipBoundaryNormal=this._clipBoundaryNormal??new _,this._clipBoundaryNormal.x=o;break;case 220:this._clipBoundaryNormal&&(this._clipBoundaryNormal.y=o);break;case 230:this._clipBoundaryNormal&&(this._clipBoundaryNormal.z=o);break;case 11:this._clipBoundaryOrigin=this._clipBoundaryOrigin??new _,this._clipBoundaryOrigin.x=o;break;case 21:this._clipBoundaryOrigin&&(this._clipBoundaryOrigin.y=o);break;case 31:this._clipBoundaryOrigin&&(this._clipBoundaryOrigin.z=o);break;case 71:this._clipBoundaryDisplayEnabled=o!==0;break;case 72:this._frontClippingEnabled=o!==0;break;case 73:this._backClippingEnabled=o!==0;break;case 40:i||(this._frontClippingDistance=o,i=!0);break;case 41:this._backClippingDistance=o;break}}return e&&this._boundaryVertices.push(new M(e.x,e.y)),this}}class hg extends lg{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 ug extends Et{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 dg extends ug{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 ro extends Et{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 U(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 U(exports.AcCmColorMethod.ByLayer),this._textHeight=4,this._enableFrameText=!1,this._textAlignAlwaysLeft=!1,this._alignSpace=0,this._blockColor=new U(exports.AcCmColorMethod.ByBlock),this._blockScale=new A(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,So(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,So(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,So(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=fe(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=fe(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=fe(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 uc extends Et{constructor(){super(),this._styleName="STANDARD",this._flags=0,this._description="",this._fillColor=new U,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 o=Number(s.code),a=Number(s.value);switch(o){case 2:this.styleName=String(s.value);break;case 70:this.flags=a;break;case 3:this.description=String(s.value);break;case 51:this.startAngle=a;break;case 52:this.endAngle=a;break;case 71:r=a;break;case 49:{i={offset:a,color:new U,lineType:"BYLAYER"},i.color.colorIndex=256,e.push(i);break}case 62:i?i.color.colorIndex=a:this.fillColor.colorIndex=a;break;case 420:i?i.color.setRGBValue(a):this.fillColor.setRGBValue(a);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 o=t[s];if(o)return o;const a=new U;return a.colorIndex=256,{offset:0,color:a,lineType:"BYLAYER"}})}}class gg extends Et{constructor(){super(),this._isLoaded=!0,this._resolutionUnits=0,this._sourceFileName="",this._classVersion=0,this._imageSize=new M,this._pixelSize=new M(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 fg extends Et{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 pg=(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))(pg||{});class dc extends Et{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 fn;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 zt=n=>n?n.trim().toUpperCase():"";class mg{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 Hi;i.dxfIn(t),i.layoutName&&this._db.objects.layout.setAt(i.layoutName,i);break}case"IMAGEDEF":{const i=new gg;i.dxfIn(t),this._db.objects.imageDefinition.setAt(i.objectId,i);break}case"LAYER_FILTER":{const i=new hg;i.dxfIn(t),this._db.objects.layerFilter.setAt(i.objectId,i);break}case"LAYER_INDEX":{const i=new dg;i.dxfIn(t),this._db.objects.layerIndex.setAt(i.objectId,i);break}case"MLEADERSTYLE":{const i=new ro;i.dxfIn(t),this._db.objects.mleaderStyle.setAt(i.objectId,i);break}case"MLINESTYLE":{const i=new uc;i.dxfIn(t),this._db.objects.mlineStyle.setAt(i.styleName||i.objectId,i);break}case"GROUP":{const i=new cg;i.dxfIn(t);const r=i.name||i.objectId;this._db.objects.group.setAt(r,i);break}case"SORTENTSTABLE":{const i=new fg;i.dxfIn(t),this._db.objects.sortentsTable.setAt(i.objectId,i);break}case"DICTIONARY":{const i=this.readPersistDictionary(t);i.handle&&this._dictionaries.set(zt(i.handle),i);break}case"XRECORD":{const i=new dc;i.dxfIn(t);const r=zt(i.objectId);if(r){this._db.objects.xrecord.setAt(r,i);const s={handle:r,ownerObjectId:zt(i.ownerId),data:i.data?i.data.toArray().map(o=>({code:Number(o.code),value:o.value})):[]};i.extensionDictionary&&(s.extensionDictionaryId=zt(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,o]of Object.entries(t.entries)){const a=i[s.toUpperCase()];if(!a)continue;a.objectId=o,a.ownerId=t.handle,e.setAt(s,a);const c=this._dictionaries.get(zt(o));if(c)for(const[l,h]of Object.entries(c.entries)){const u=r.get(zt(h));u&&(a.getAt(l)||a.setAt(l,u))}}}collectLoadedObjectsByHandle(){const t=new Map,e=i=>{const r=zt(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 o=zt(String(r.value));i?(e.entries[i]=o,i=void 0):s===360&&!e.extensionDictionaryId&&(e.extensionDictionaryId=o);break}}}return e.handle=zt(e.handle),e.ownerObjectId=zt(e.ownerObjectId),e.extensionDictionaryId&&(e.extensionDictionaryId=zt(e.extensionDictionaryId)),e}finishLayerFilterTree(){if(this._dictionaries.size===0&&this._xrecords.size===0)return;const t=ng({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=ct.MODEL_SPACE_NAME.toUpperCase();for(const[,i]of this._db.objects.layout.entries()){if(i.layoutName==="Model"){const o=t.modelSpace;i.blockTableRecordId=o.objectId,o.layoutId=i.objectId;continue}const r=zt(i.objectId);let s=!1;for(const o of t.newIterator())if(zt(o.layoutId)===r){i.blockTableRecordId=o.objectId,s=!0;break}if(!s&&i.blockTableRecordId){const o=t.getIdAt(i.blockTableRecordId);o&&(o.layoutId=i.objectId)}else if(!s){for(const o of t.newIterator())if(o.isPaperSapce&&o.name.toUpperCase()!==e&&!o.layoutId){i.blockTableRecordId=o.objectId,o.layoutId=i.objectId;break}}}}}class yg{constructor(t,e={}){this._db=t,this._options=e,this._unknownEntityCount=0,this._unknownObjectCount=0,this._attributeMap=new Map,this._yieldGate=new Fs(this._options.yieldBudgetMs??bi)}get unknownEntityCount(){return this._unknownEntityCount}get unknownObjectCount(){return this._unknownObjectCount}async read(t){for(this._unknownEntityCount=0,this._unknownObjectCount=0,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}}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":Qd(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 mg(this._db);i.read(t),this._unknownObjectCount+=i.unknownObjectCount}await this.reportParseProgress(t);break;case"ACDSDATA":this.applyAcdsDataToSolids(h1(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 Ai&&i.set(sa(s.objectId),s);for(const r of e){const s=t.byOwnerHandle[r];if(!s)continue;const o=i.get(sa(r));o&&o.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=Gi(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 $i,i=>{i.name&&this._db.tables.layerTable.add(i)});break;case"LTYPE":this.readNamedTable(t,"LTYPE",()=>new qe,i=>{i.name&&this._db.tables.linetypeTable.add(i)});break;case"STYLE":this.readNamedTable(t,"STYLE",()=>new Qs,i=>{this._db.tables.textStyleTable.add(i)});break;case"DIMSTYLE":this.readNamedTable(t,"DIMSTYLE",()=>new Ht,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 $r,i=>{i.name&&this._db.tables.appIdTable.add(i)});break;case"VIEW":this.readNamedTable(t,"VIEW",()=>new qd,i=>{i.name&&this._db.tables.viewTable.add(i)});break;case"UCS":this.readNamedTable(t,"UCS",()=>new $d,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 o=String(s.value).toUpperCase();if(o==="ENDTAB"){t.readItem();break}if(o==="ENDSEC")break;if(o===e){t.readItem();const a=i();a.dxfIn(t),r(a);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 ct;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 o=t.peekItem();if(!o)break;if(Number(o.code)!==0){t.readItem();continue}const a=String(o.value).toUpperCase();if(a==="ENDBLK"){t.readItem(),t.skipToEndOfObject();break}if(a==="ENDSEC")break;if(t.readItem(),this.consumeSeqend(t,a)){i+=1,i>=e&&(i=0,await this.yieldAndReportProgress(t));continue}const c=Ma(t,a);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 _;let i="",r=0,s="",o,a;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:o=String(c.value);break;case 330:a=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:o,ownerId:a}}ensureBlockTableRecord(t){let e=t.name?this._db.tables.blockTable.getAt(t.name):void 0;e||(e=new ct,e.name=t.name||"*UNKNOWN",t.objectId&&(e.objectId=t.objectId),this._db.tables.blockTable.add(e)),e.origin.copy(t.origin);let i=ct.sanitizeImportedFlags(t.flags);return t.pathName&&(e.pathName=t.pathName,(i&(li.Xref|li.XrefOverlay))===0&&(i=i|li.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 o=String(s.value).toUpperCase();if(o==="ENDSEC"){t.readItem();break}if(t.readItem(),this.consumeSeqend(t,o)){i+=1,i>=e&&(i=0,await this.yieldAndReportProgress(t));continue}const a=Ma(t,o);a?this.acceptEntity(a,this.resolveEntityOwner(a,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(ct.PAPER_SPACE_NAME_PREFIX);if(r)return r}return e}acceptEntity(t,e){if(t instanceof Si){this.linkOrDeferAttribute(t,e);return}if(e.appendEntity(t),t instanceof xe){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 xe){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 xe)for(const r of e)i.appendAttributes(r)}this._attributeMap.clear()}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(qn)}}const cr=1,Io=18,lr=20,hr=98;class bg extends cc{constructor(t={}){super({useWorker:!1,...t})}async read(t,e,i={}){const{minimumChunkSize:r=10,progress:s}=i;this.progress=s;const o=async(c,l,h,u)=>{s&&await s(c,l,h,u)};await o(0,"START","START"),await o(cr,"PARSE","START"),await Eh(),e.beginEventBatch();let a=!0;try{const c=We.fromBuffer(t,{database:e}),l=t.byteLength;let h=cr;const d=await new yg(e,{entityBatchSize:Math.max(1,r||200),yieldBudgetMs:bi,totalBytes:l,onProgress:async m=>{const y=Math.min(Io-1,cr+Math.floor(m*(Io-cr)));y<=h||(h=y,await o(y,"PARSE","IN-PROGRESS"))}}).read(c);await o(Io,"PARSE","END",{unknownEntityCount:d.unknownEntityCount}),await o(lr,"ENTITY","START");const g=Math.max(1,r||200);let f=lr;const p=new Fs(bi);await e.endEventBatchChunked(g,async(m,y)=>{const b=y<=0?hr:Math.min(hr,lr+Math.floor(m/y*(hr-lr)));b>f&&(f=b,await o(b,"ENTITY","IN-PROGRESS")),await p.maybeYield()}),a=!1,await o(hr,"ENTITY","END"),await o(100,"END","END")}catch(c){throw a&&e.endEventBatch(),c}}async parse(t){return{model:null,data:{unknownEntityCount:0}}}}var di=(n=>(n.DXF="dxf",n.DWG="dwg",n))(di||{});class ge{constructor(){this.events={registered:new gt,unregistered:new gt},this._converters=new Map,this.register("dxf",new bg)}static createInstance(){return ge._instance==null&&(ge._instance=new ge),this._instance}static get instance(){return ge._instance||(ge._instance=new ge),ge._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 aa=50,_1=$.DEFAULT_CIRCLE_SIDES,x1=1e3;function qi(n){var e;const t=_g((e=n==null?void 0:n.context)==null?void 0:e.database);return{circleSides:t,maxSegments:t}}function _g(n){if(n!=null&&typeof n=="object"){const t=n.drawCircleSides;if(typeof t=="number"&&Number.isFinite(t))return $.resolveCircleSides(t)}return $.DEFAULT_CIRCLE_SIDES}function w1(n){var i,r,s;if(n==null||typeof n!="object")return $.DEFAULT_CIRCLE_SIDES;const t=n.tables,e=(s=(r=(i=t==null?void 0:t.viewportTable)==null?void 0:i.getActiveVport)==null?void 0:r.call(i))==null?void 0:s.circleSides;return typeof e!="number"||!Number.isFinite(e)?$.DEFAULT_CIRCLE_SIDES:$.resolveCircleSides(e)}const Tn=class Tn extends It{constructor(){super(),this._thickness=0,this._normal=new A(0,0,1),this._elevation=0,this._geo=new it}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 o=r<0?void 0:r,a=s<0?void 0:s,c={x:e.x,y:e.y,bulge:i,startWidth:o,endWidth:a};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 _(e.x,e.y,this._elevation)}get geometricExtents(){const t=this._geo.box;return t.isEmpty()?new j:new j({x:t.min.x,y:t.min.y,z:this._elevation},{x:t.max.x,y:t.max.y,z:this._elevation})}subGetIntersectCurves(){return ac(this._geo.vertices,this.closed,this._elevation,this._normal)}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 bt(t,o=>{if(o<i){ui(this._geo.vertices,o,e);return}if(!r||o>=i+s)return;const a=o-i;ui(this._geo.vertices,a,e),ui(this._geo.vertices,(a+1)%i,e)}),this}shouldIncludeSegmentMidpointGrips(){return this.getGripsMode()>=2}getGripsMode(){try{const t=vt.instance().getVar(T.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 o;const e=this._geo,i=this._elevation,r=this.getSegmentCount(),s=e.numberOfVertices;for(let a=0;a<r;a++){const c=[];Pi(e.getPointAt(a),e.getPointAt((a+1)%s),(o=e.vertices[a])==null?void 0:o.bulge,i,I.MidPoint,{x:0,y:0,z:0},c),t.push(...c)}}subGetOsnapPoints(t,e,i,r){var c;const s=this._geo,o=this._elevation,a=s.numberOfVertices;if(a!==0)switch(t){case I.EndPoint:for(let l=0;l<a;l++){const h=s.getPointAt(l);r.push(new _(h.x,h.y,o))}break;case I.MidPoint:case I.Nearest:case I.Perpendicular:case I.Tangent:{const l=this.closed?a:a-1,h=[];for(let u=0;u<l;u++){const d=[];Pi(s.getPointAt(u),s.getPointAt((u+1)%a),(c=s.vertices[u])==null?void 0:c.bulge,o,t,e,d),h.push(...d)}if(t===I.MidPoint)r.push(...h);else{const u=ie(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 _(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}}}]}]}}get directBatchPrimitive(){return this.hasRenderableWidth()?"area":"lineStrip"}subWorldDraw(t){const e=qi(t),i=this._geo.tessellate(e),r=this.createWidthProfile(e);if(r!=null){const o=A1(r,this.closed);if(o!=null){const a=t.subEntityTraits;return a.fillType={solidFill:!0,patternAngle:0,definitionLines:[]},t.area(o)}}const s=[];return i.forEach(o=>s.push(new _().set(o.x,o.y,this.elevation))),t.lines(s)}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 o=s.bulge??0;o!==0&&t.writeDouble(42,o),s.identifier!=null&&t.writeInt32(91,s.identifier)}return t.writeVector3d(210,this.normal),this}dxfOutAs2dPolyline(t,e=!1){var r,s,o;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 a=0;a<this.numberOfVertices;++a){const c=this._geo.vertices[a];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(a).x,y:this.getPoint2dAt(a).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,(o=this.database)==null?void 0:o.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,o=this.normal.y,a=this.normal.z,c=-1,l=0,h=0,u=!1,d=0,g=-1,f=-1,p,m=0;const y=()=>{if(!u)return;const w=g<0?c:g,x=f<0?c:f;if(this.addVertexAt(m++,new M(l,h),d,w,x),p!=null){const S=this._geo.vertices[m-1];S&&(S.identifier=p)}u=!1,d=0,g=-1,f=-1,p=void 0};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const w=t.readItem();if(!w)break;const x=Number(w.code),S=Number(w.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:y(),l=S,h=0,u=!0;break;case 20:h=S;break;case 40:g=S;break;case 41:f=S;break;case 42:d=S;break;case 91:p=S;break;case 210:s=S;break;case 220:o=S;break;case 230:a=S;break}}y(),this.closed=e,this.elevation=i,this.thickness=r;const b=new A(s,o,a);return b.lengthSq()>0&&this.normal.copy(b.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 o=r??0;if(o!==(s??0))return;if(e==null)e=o;else if(e!==o)return}return e!=null&&e!==0?e:void 0}hasRenderableWidth(){const t=this._geo.vertices;for(let e=0;e<t.length;e++){const i=Math.max(0,t[e].startWidth??0),r=Math.max(0,t[e].endWidth??0);if(i>yt||r>yt)return!0}return!1}createWidthProfile(t){const e=this._geo.vertices,i=e.length;if(i<2)return null;const r=this.closed?i:i-1,s=[];let o=!1;for(let a=0;a<r;a++){const c=e[a],l=e[(a+1)%i],h=Math.max(0,c.startWidth??0),u=Math.max(0,c.endWidth??0);(h>yt||u>yt)&&(o=!0);const d=this.sampleSegment(c,l,t),g=d.length-1;for(let f=0;f<=g;f++){if(f===0&&s.length>0||this.closed&&a===r-1&&f===g)continue;const p=g>0?f/g:0;s.push({x:d[f].x,y:d[f].y,width:C1(h,u,p)})}}return o&&s.length>=2?s:null}sampleSegment(t,e,i){if(t.bulge&&Math.abs(t.bulge)>yt){const s=new $(t,e,t.bulge).tessellate(i);if(s.length>1)return s.map(o=>new M(o.x,o.y))}return[new M(t.x,t.y),new M(e.x,e.y)]}static from2dPoints(t,e){const i=new Tn;return t.forEach((r,s)=>i.addVertexAt(s,r)),i.closed=e,i}static fromGePolyline(t){const e=new Tn;return t.vertices.forEach((i,r)=>{e.addVertexAt(r,new M(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 o=0;o<s;o++){const a=this.getPoint2dAt(o),c=this.getPoint2dAt((o+1)%e),l=c.x-a.x,h=c.y-a.y,u=l*l+h*h;if(u===0)continue;const d=Math.max(0,Math.min(1,((t.x-a.x)*l+(t.y-a.y)*h)/u)),g=(t.x-a.x-d*l)**2+(t.y-a.y-d*h)**2;g<i&&(i=g,r=l*(t.y-a.y)-h*(t.x-a.x)>=0?1:-1)}return r}createOffsetCurve(t){const e=this._geo.offset(t);return e.length===0?null:Tn.fromGePolyline(e[0])}};Tn.typeName="Polyline";let Rt=Tn;function so(n,t,e){const i=K0(n,t,e);return i?Rt.fromGePolyline(i):null}const yt=1e-6,Zl=4,v1=.75;function A1(n,t){if(n.length<2)return null;if(t)return To(n,!0);const e=P1(n);if(e.length===1)return To(e[0],!1);const i=new oe;let r=!1;for(const s of e){const o=To(s,!1);if(o!=null){for(const a of o.loops)i.add(a);r=!0}}return r?i:null}function To(n,t){const e=L1(n,t);if(e.length<2)return null;const{left:i,right:r}=xg(e,t);if(Jl(i)<2||Jl(r)<2)return null;const s=new oe;if(t){const o=qr(i),a=qr(r);if(!Ii(o)||!Ii(a))return null;const c=Math.abs(Ei(o)),l=Math.abs(Ei(a)),[h,u]=c>=l?[o,a]:[a,o];return s.add(new it(h,!0)),s.add(new it(u,!0)),s}return k1(e)&&E1(s,e)||T1(s,i,r)?s:null}function P1(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 o=Ql(n[s]),a=i.get(o);if(a!=null&&s-a>1){const c=n.slice(e,s+1);c.length>=2&&t.push(c),e=a,i.clear();for(let l=e;l<=s;l++)i.set(Ql(n[l]),l);continue}i.set(o,s)}const r=n.slice(e);return r.length>=2&&t.push(r),t.length>0?t:[n]}function Ql(n){return`${n.x.toFixed(4)}:${n.y.toFixed(4)}`}function S1(n,t){const e=Math.max(n,t),i=Math.min(n,t);return e<=yt||e-i<=yt?!1:i/e<=v1}function k1(n){const t=n[0],e=n[n.length-1],i=Math.hypot(e.x-t.x,e.y-t.y);if(i<=yt)return!0;const r=Math.max(...n.map(s=>s.width));return r<=yt?!1:i<=r*4}function E1(n,t){const{left:e,right:i}=xg(t,!0),r=qr(e),s=qr(i);if(!Ii(r)||!Ii(s))return!1;const o=Math.abs(Ei(r)),a=Math.abs(Ei(s));if(!S1(o,a))return!1;const[c,l]=o>=a?[r,s]:[s,r];return n.add(new it(c,!0)),n.add(new it(l,!0)),!0}function xg(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],o=Math.max(0,s.width)/2;if(o<=yt){e[r]=null,i[r]=null;continue}const a=M1(n,r,t);if(a==null){e[r]=null,i[r]=null;continue}e[r]={x:s.x+a.x*o,y:s.y+a.y*o},i[r]={x:s.x-a.x*o,y:s.y-a.y*o}}return{left:e,right:i}}function I1(n,t,e,i,r){const s=[t,e,i,r];return Ii(s)?(n.add(new it(s,!0)),!0):!1}function T1(n,t,e){let i=!1;for(let r=0;r<t.length-1;r++){const s=t[r],o=t[r+1],a=e[r],c=e[r+1];s==null||o==null||a==null||c==null||I1(n,s,o,c,a)&&(i=!0)}return i}function Jl(n){return n.reduce((t,e)=>e==null?t:t+1,0)}function qr(n){return n.filter(t=>t!=null)}function L1(n,t){const e=[];if(n.forEach(i=>{const r=e[e.length-1];(!r||Math.abs(r.x-i.x)>yt||Math.abs(r.y-i.y)>yt||Math.abs(r.width-i.width)>yt)&&e.push(i)}),t&&e.length>1){const i=e[0],r=e[e.length-1];Math.abs(i.x-r.x)<=yt&&Math.abs(i.y-r.y)<=yt&&e.pop()}return e}function M1(n,t,e){const i=n.length,r=n[t],s=n[(t-1+i)%i],o=n[(t+1)%i];let a=th(r.x-s.x,r.y-s.y),c=th(o.x-r.x,o.y-r.y);if(e||(t===0&&(a=c),t===i-1&&(c=a)),a==null&&c==null)return null;if(a==null)return ur(c);if(c==null)return ur(a);const l=ur(a),h=ur(c),u=l.x+h.x,d=l.y+h.y,g=Math.hypot(u,d);if(g<=yt)return h;const f={x:u/g,y:d/g},p=Math.abs(f.x*h.x+f.y*h.y),m=p<=yt?Zl:Math.min(1/p,Zl);return{x:f.x*m,y:f.y*m}}function th(n,t){const e=Math.hypot(n,t);return e<=yt?null:{x:n/e,y:t/e}}function ur(n){return{x:-n.y,y:n.x}}function Ei(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 Ii(n){return n.length>=3&&Math.abs(Ei(n))>yt}function C1(n,t,e){return n+(t-n)*e}const O1={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:[]},wg={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 gi=(n=>(n[n.UserDefined=0]="UserDefined",n[n.Predefined=1]="Predefined",n[n.Custom=2]="Custom",n))(gi||{}),vg=(n=>(n[n.Normal=0]="Normal",n[n.Outer=1]="Outer",n[n.Ignore=2]="Ignore",n))(vg||{}),Ag=(n=>(n[n.HatchObject=0]="HatchObject",n[n.GradientObject=1]="GradientObject",n))(Ag||{}),Pg=(n=>(n[n.PreDefinedGradient=0]="PreDefinedGradient",n[n.UserDefinedGradient=1]="UserDefinedGradient",n))(Pg||{});const Lc=class Lc extends tt{constructor(){super(),this._areasFromLoopsCache=null,this._normal=new A(0,0,1),this._gradientAngle=0,this._elevation=0,this._geo=new oe,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()===an}set isSolidFill(t){this._isSolidFill=t}get color(){if(this.hasExplicitColor())return this.getEntityColor();const t=this.database,e=vt.instance().getVar(T.HPCOLOR,t);return e instanceof U&&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()===an,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 normal(){return this._normal}set normal(t){this._normal.copy(t),this._normal.lengthSq()>0&&this._normal.normalize()}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()===""?Zu: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=vt.instance();if(!this.hasExplicitLayer()){const i=e.getVar(T.HPLAYER,t);this.shouldUseSysVarOverride(i)&&(this.layer=i)}if(!this.hasExplicitTransparency()){const i=this.parseHpTransparency(e.getVar(T.HPTRANSPARENCY,t));i&&(this.transparency=i)}if(this._backgroundColorSet||(this._backgroundColor=this.parseHpBackgroundColor(e.getVar(T.HPBACKGROUNDCOLOR,t)),this._backgroundColorSet=!0),!this._patternNameSet){const i=e.getVar(T.HPNAME,t);this._patternName=typeof i=="string"?i:"",this._patternNameSet=!0}if(!this._patternAngleSet){const i=e.getVar(T.HPANG,t);this._patternAngle=typeof i=="number"&&Number.isFinite(i)?i:0,this._patternAngleSet=!0}if(this._patternScaleSet||(this._patternScale=this.normalizePatternScale(e.getVar(T.HPSCALE,t)),this._patternScaleSet=!0),!this._associativeSet){const i=e.getVar(T.HPASSOC,t);this._associative=typeof i=="number"?i!==0:!1,this._associativeSet=!0}if(this._hatchStyleSet||(this._hatchStyle=this.normalizeHatchStyle(e.getVar(T.HPISLANDDETECTION,t)),this._hatchStyleSet=!0),!this._patternDoubleSet){const i=e.getVar(T.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=vt.instance().getVar(T.HPNAME,t);return typeof e=="string"?e:this._patternName}shouldResolveColorFromCecolor(){return!1}getEffectivePatternAngle(){if(this._patternAngleSet)return this._patternAngle;const t=this.database,e=vt.instance().getVar(T.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(vt.instance().getVar(T.HPSCALE,t))}getEffectiveAssociative(){if(this._associativeSet)return this._associative;const t=this.database,e=vt.instance().getVar(T.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 U)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 U.fromString(t)}parseHpTransparency(t){if(t instanceof pt)return t.clone();if(!this.shouldUseSysVarOverride(t))return;const e=t.trim();if(/^bylayer$/i.test(e)||/^byblock$/i.test(e))return pt.fromString(e);const i=Number(e);if(Number.isInteger(i)&&i>=0&&i<=90){const r=new pt;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===an){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 o=wg.patterns.find(a=>a.name.trim().toUpperCase()===r);if(!o){this._definitionLinesAutoGenerated&&(this._definitionLines=[],this._definitionLinesAutoGenerated=!1,this._definitionLinesPatternName="",this._definitionLinesPatternScale=1);return}this._definitionLines=o.lines.map(a=>({angle:a.angle*Math.PI/180,base:{x:a.originX*s,y:a.originY*s},offset:{x:a.deltaX*s,y:a.deltaY*s},dashLengths:a.dashes.map(c=>c*s)})),this._definitionLinesAutoGenerated=!0,this._definitionLinesPatternName=r,this._definitionLinesPatternScale=s}add(t){this._geo.add(t),this.invalidateAreasFromLoopsCache()}invalidateAreasFromLoopsCache(){this._areasFromLoopsCache=null}buildAreasFromLoops(){if(this._areasFromLoopsCache!=null)return this._areasFromLoopsCache;const t=this._geo.loops;if(t.length===0)return this._areasFromLoopsCache=[],this._areasFromLoopsCache;if(t.length===1)return this._areasFromLoopsCache=[this._geo],this._areasFromLoopsCache;const e=this._geo.buildHierarchy(),i=[],r=(s,o)=>{if(s.index>=0&&o%2===0){const a=new oe;a.add(t[s.index]),s.children.forEach(c=>{c.index>=0&&a.add(t[c.index])}),i.push(a)}s.children.forEach(a=>r(a,o+1))};return e.children.forEach(s=>r(s,0)),this._areasFromLoopsCache=i.length>0?i:[this._geo],this._areasFromLoopsCache}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 j;const e=new j;return t.forEach(i=>{const r=i.box;e.union(new j().setFromPoints([At({x:r.min.x,y:r.min.y,z:this._elevation},this._normal),At({x:r.max.x,y:r.min.y,z:this._elevation},this._normal),At({x:r.max.x,y:r.max.y,z:this._elevation},this._normal),At({x:r.min.x,y:r.max.y,z:this._elevation},this._normal)]))}),e}subGetIntersectCurves(){return Yb(this._geo.loops,this._elevation,this._normal)}get properties(){return{type:this.type,groups:[this.getGeneralProperties(),{groupName:"pattern",properties:[{name:"patternType",type:"enum",editable:!0,options:[{label:gi[0],value:0},{label:gi[1],value:1},{label:gi[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:(bt(t,i=>{this.moveBoundaryGripPointAt(i,e)}),this.invalidateAreasFromLoopsCache(),this)}collectBoundaryGripPoints(){const t=new Array,e=this._elevation,i=new Set,r=s=>{const o=`${s.x},${s.y},${s.z??0}`;i.has(o)||(i.add(o),t.push(new _(s.x,s.y,s.z??e)))};return this._geo.loops.forEach(s=>{if(s instanceof it){const o=s.numberOfVertices;for(let a=0;a<o;a++){const c=s.getPointAt(a);r({x:c.x,y:c.y,z:e})}return}s.curves.forEach(o=>{if(o instanceof Vt)r({x:o.startPoint.x,y:o.startPoint.y,z:e}),r({x:o.endPoint.x,y:o.endPoint.y,z:e});else if(o instanceof $)r({x:o.startPoint.x,y:o.startPoint.y,z:e}),r({x:o.endPoint.x,y:o.endPoint.y,z:e}),r({x:o.midPoint.x,y:o.midPoint.y,z:e});else if(o instanceof Ie){r({x:o.startPoint.x,y:o.startPoint.y,z:e}),r({x:o.endPoint.x,y:o.endPoint.y,z:e});const a=o.getPoint(.5);r({x:a.x,y:a.y,z:e})}})}),t}moveBoundaryGripPointAt(t,e){let i=0;const r=this._elevation,s=new Set,o=(a,c)=>{const l=`${a.x},${a.y},${a.z??0}`;s.has(l)||(s.add(l),i===t&&c(),i++)};this._geo.loops.forEach(a=>{if(a instanceof it){const c=a.numberOfVertices;for(let l=0;l<c;l++){const h=a.vertices[l];h&&o({x:h.x,y:h.y,z:r},()=>{ui(a.vertices,l,e)})}return}a.curves.forEach(c=>{if(c instanceof Vt)o({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>{c.startPoint.x+=e.x,c.startPoint.y+=e.y}),o({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>{c.endPoint.x+=e.x,c.endPoint.y+=e.y});else if(c instanceof $)o({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"start",e)),o({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"end",e)),o({x:c.midPoint.x,y:c.midPoint.y,z:r},()=>this.moveCircArc2dGripPoint(c,"mid",e));else if(c instanceof Ie){o({x:c.startPoint.x,y:c.startPoint.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"start",e)),o({x:c.endPoint.x,y:c.endPoint.y,z:r},()=>this.moveEllipseArc2dGripPoint(c,"end",e));const l=c.getPoint(.5);o({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,o=new $(t.startPoint,{x:s.x+i.x,y:s.y+i.y},t.endPoint);t.center=o.center,t.radius=o.radius,t.startAngle=o.startAngle,t.endAngle=o.endAngle,t.clockwise=o.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),o=s.x+i.x-t.center.x,a=s.y+i.y-t.center.y,c=Math.hypot(s.x-t.center.x,s.y-t.center.y),l=Math.hypot(o,a);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,o=[];if(this._geo.loops.forEach(a=>{var c;if(a instanceof it){const l=a,h=l.numberOfVertices;if(h===0)return;switch(t){case I.EndPoint:for(let u=0;u<h;u++){const d=l.getPointAt(u);r.push(new _(d.x,d.y,s))}break;case I.MidPoint:case I.Nearest:case I.Perpendicular:case I.Tangent:{const u=a.closed?h:h-1;for(let d=0;d<u;d++){const g=[];Pi(l.getPointAt(d),l.getPointAt((d+1)%h),(c=l.vertices[d])==null?void 0:c.bulge,s,t,e,g),t===I.MidPoint?r.push(...g):o.push(...g)}break}}return}a.curves.forEach(l=>{if(l instanceof Vt){const h=[];Pi(l.startPoint,l.endPoint,void 0,s,t,e,h),t===I.MidPoint?r.push(...h):t===I.Nearest||t===I.Perpendicular||t===I.Tangent?o.push(...h):r.push(...h)}else if(l instanceof $)switch(t){case I.EndPoint:r.push(new _(l.startPoint.x,l.startPoint.y,s),new _(l.endPoint.x,l.endPoint.y,s));break;case I.MidPoint:r.push(new _(l.midPoint.x,l.midPoint.y,s));break;case I.Nearest:{const h=l.nearestPoint({x:e.x,y:e.y});o.push(new _(h.x,h.y,s));break}case I.Perpendicular:{l.perpendicularPoints({x:e.x,y:e.y}).forEach(u=>o.push(new _(u.x,u.y,s)));break}case I.Tangent:{l.tangentPoints({x:e.x,y:e.y}).forEach(u=>o.push(new _(u.x,u.y,s)));break}}else if(l instanceof Ie)switch(t){case I.EndPoint:r.push(new _(l.startPoint.x,l.startPoint.y,s),new _(l.endPoint.x,l.endPoint.y,s));break;case I.MidPoint:{const h=l.getPoint(.5);r.push(new _(h.x,h.y,s));break}case I.Nearest:{const h=l.nearestPoint({x:e.x,y:e.y});o.push(new _(h.x,h.y,s));break}case I.Perpendicular:{l.perpendicularPoints({x:e.x,y:e.y}).forEach(u=>o.push(new _(u.x,u.y,s)));break}case I.Tangent:{l.tangentPoints({x:e.x,y:e.y}).forEach(u=>o.push(new _(u.x,u.y,s)));break}}})}),(t===I.Nearest||t===I.Perpendicular||t===I.Tangent)&&o.length>0){const a=ie(e,o);r.length=0,a&&r.push(a)}}get directBatchPrimitive(){return!this.isSolidFill||this.isGradient||this.buildAreasFromLoops().length>1?null:"area"}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(o=>t.area(o));return t.group(r)}transformBy(t){const e=t.elements,i=new zi(e[0],e[4],e[12],e[1],e[5],e[13],0,0,1);this._geo.transform(i),this.invalidateAreasFromLoopsCache(),this._elevation=new _(0,0,this._elevation).applyMatrix4(t).z,this._normal.transformDirection(t),this._normal.lengthSq()>0&&this._normal.normalize();const r=new _(1,0,0).applyMatrix4(t),s=new _().applyMatrix4(t),o=new _(r).sub(s);if(o.length()>0){const a=Math.atan2(o.y,o.x);this._patternAngle=this.getEffectivePatternAngle()+a,this._gradientAngle+=a,this._patternScale=this.getEffectivePatternScale()*o.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,this.normal),t.writeString(2,i||(this.isSolidFill?an:Ku)),t.writeInt16(70,this.isSolidFill?1:0),t.writeInt16(71,this.getEffectiveAssociative()?1:0),t.writeInt16(91,e.length),e.forEach((o,a)=>{const c=a===0;if(o instanceof it){const l=o.vertices,h=l.some(d=>(d.bulge??0)!==0);t.writeInt16(92,2),t.writeInt16(72,h?1:0),t.writeInt16(73,o.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(o instanceof On){const l=c?1:0;t.writeInt16(92,l),t.writeInt16(93,o.numberOfEdges);for(const h of o.curves){if(h instanceof Vt){t.writeInt16(72,1),t.writePoint2d(10,h.startPoint),t.writePoint2d(11,h.endPoint);continue}if(h instanceof $){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 Ie){t.writeInt16(72,3),t.writePoint2d(10,h.center);const u=new M(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 Ut){const u=h.knots,d=h.controlPoints,g=h.weights,f=h.fitPoints,p=g.some(m=>m!==1);t.writeInt16(72,4),t.writeInt16(94,h.degree),t.writeInt16(73,p?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),p&&t.writeDouble(42,g[y]??1)}),t.writeInt16(97,(f==null?void 0:f.length)??0),f==null||f.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(o=>{t.writeAngle(53,o.angle),t.writeDouble(43,o.base.x),t.writeDouble(44,o.base.y),t.writeDouble(45,o.offset.x),t.writeDouble(46,o.offset.y),t.writeInt16(79,o.dashLengths.length),o.dashLengths.forEach(a=>t.writeDouble(49,a))}),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 o=this._gradientStartColor,a=this._gradientEndColor,c=o!=null&&a!=null?2:o!=null||a!=null?1:0;t.writeInt16(453,c);const l=(h,u)=>{t.writeDouble(463,h);const d=ue.getIndexByColor(u);d!=null&&t.writeInt16(63,d),t.writeInt32(421,u)};o!=null&&l(0,o),a!=null&&l(1,a),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.normal.x,r=this.normal.y,s=this.normal.z,o=this.patternAngle*180/Math.PI,a=0,c=!1,l=!1,h=!1,u=[],d=null,g=[],f=null,p="type",m=0,y=!1,b=null,w=!1,x=0,S;const P=G=>{x===0?this.gradientStartColor=G:this.gradientEndColor=G,x++,S=void 0},v=()=>{if(S==null)return;const G=ue.getColorByIndex(S);G!=null?P(G):S=void 0},k=()=>{d&&(u.push(d),d=null)},E=()=>{if(k(),u.length===0)return;const G=new it;G.closed=h,u.forEach((rt,L)=>{G.addVertexAt(L,{x:rt.x,y:rt.y,bulge:rt.bulge??0})}),this.add(G),u=[]},O=()=>{if(g.length===0)return;const G=[];for(const L of g)if(L.kind==="line")G.push(new Vt({x:L.sx,y:L.sy},{x:L.ex,y:L.ey}));else if(L.kind==="arc")G.push(new $({x:L.cx,y:L.cy},L.radius,L.startDeg*Math.PI/180,L.endDeg*Math.PI/180,!L.isCcw));else if(L.kind==="ellipse"){const q=Math.hypot(L.mx,L.my),dt=q*L.ratio;let B=L.startDeg*Math.PI/180,Ct=L.endDeg*Math.PI/180;const ot=Math.atan2(L.my,L.mx);L.isCcw||(B=Math.PI*2-B,Ct=Math.PI*2-Ct),G.push(new Ie({x:L.cx,y:L.cy,z:0},q,dt,B,Ct,!L.isCcw,ot))}else{const q=Ut.fromDwgSplineEdge({degree:L.degree,numberOfControlPoints:L.controlPoints.length,numberOfKnots:L.knots.length,numberOfFitData:L.fitPoints.length,knots:L.knots,controlPoints:L.controlPoints.map(dt=>({x:dt.x,y:dt.y,z:0,weight:L.rational?dt.weight??1:void 0})),fitDatum:L.fitPoints.map(dt=>({x:dt.x,y:dt.y,z:0})),startTangent:null,endTangent:null});q&&G.push(q)}const rt=On.buildFromEdges(G);rt.length===0&&G.length>0?this.add(new On(G)):rt.forEach(L=>this.add(L)),g=[],f=null},N=()=>{c?E():O()},R=()=>{f&&(g.push(f),f=null)},nt=()=>{R(),N(),m=Math.max(0,m-1),m===0&&(w=!0)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const G=t.readItem();if(!G)break;const rt=Number(G.code),L=Number(G.value);if(y||w){switch(rt){case 75:this.hatchStyle=L,w=!0;break;case 76:this.patternType=L;break;case 52:o=L;break;case 41:this.patternScale=L;break;case 77:break;case 78:y=!0;break;case 53:b&&this.definitionLines.push(b),b={angle:L*Math.PI/180,base:{x:0,y:0},offset:{x:0,y:0},dashLengths:[]};break;case 43:b&&(b.base.x=L);break;case 44:b&&(b.base.y=L);break;case 45:b&&(b.offset.x=L);break;case 46:b&&(b.offset.y=L);break;case 79:break;case 49:b&&b.dashLengths.push(L);break;case 47:this.pixelSize=L;break;case 99:break;case 450:this.hatchObjectType=L,this.gradientStartColor=void 0,this.gradientEndColor=void 0,x=0,S=void 0;break;case 451:break;case 452:this.gradientOneColorMode=L!==0;break;case 453:break;case 460:this.gradientAngle=L;break;case 461:this.gradientShift=L;break;case 462:this.shadeTintValue=L;break;case 463:v();break;case 63:S=L;break;case 421:P(L);break;case 470:v(),this.gradientName=String(G.value);break}continue}switch(rt){case 10:c||f&&f.kind!=="line"&&f.kind!=="arc"&&f.kind!=="ellipse"&&f.kind,m>0&&c?(k(),d={x:L,y:0}):(f==null?void 0:f.kind)==="line"&&p==="type"?f.sx=L:(f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse"?f.cx=L:(f==null?void 0:f.kind)==="spline"&&f.controlPoints.push({x:L,y:0});break;case 20:m>0&&c&&d?d.y=L:(f==null?void 0:f.kind)==="line"&&p==="type"?f.sy=L:(f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse"?f.cy=L:(f==null?void 0:f.kind)==="spline"&&f.controlPoints.length>0&&(f.controlPoints[f.controlPoints.length-1].y=L);break;case 30:m<=0&&!w&&(e=L);break;case 2:this.patternName=String(G.value);break;case 70:this.isSolidFill=L!==0;break;case 71:this.associative=L!==0;break;case 91:m=L;break;case 92:m>0&&(u.length>0||g.length>0||f)&&(R(),N()),a=L,c=(a&2)!==0,l=!1,h=!1,u=[],g=[],f=null,p="type";break;case 72:c?l=L!==0:(R(),L===1?(f={kind:"line",sx:0,sy:0,ex:0,ey:0},p="type"):L===2?f={kind:"arc",cx:0,cy:0,radius:0,startDeg:0,endDeg:0,isCcw:!0}:L===3?f={kind:"ellipse",cx:0,cy:0,mx:0,my:0,ratio:1,startDeg:0,endDeg:0,isCcw:!0}:L===4?f={kind:"spline",degree:3,rational:!1,closed:!1,knots:[],controlPoints:[],fitPoints:[],expectedKnots:0,expectedControls:0,expectedFits:0,fitCountSeen:!1}:f=null);break;case 73:c?h=L!==0:(f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse"?f.isCcw=L!==0:(f==null?void 0:f.kind)==="spline"&&(f.rational=L!==0);break;case 74:(f==null?void 0:f.kind)==="spline"&&(f.closed=L!==0);break;case 93:break;case 42:c&&l&&d?d.bulge=L:(f==null?void 0:f.kind)==="spline"&&f.rational&&f.controlPoints.length>0&&(f.controlPoints[f.controlPoints.length-1].weight=L);break;case 11:(f==null?void 0:f.kind)==="line"?(f.ex=L,p="line-end"):(f==null?void 0:f.kind)==="ellipse"?f.mx=L:(f==null?void 0:f.kind)==="spline"&&f.fitPoints.push({x:L,y:0});break;case 21:(f==null?void 0:f.kind)==="line"?f.ey=L:(f==null?void 0:f.kind)==="ellipse"?f.my=L:(f==null?void 0:f.kind)==="spline"&&f.fitPoints.length>0&&(f.fitPoints[f.fitPoints.length-1].y=L);break;case 40:(f==null?void 0:f.kind)==="arc"?f.radius=L:(f==null?void 0:f.kind)==="ellipse"?f.ratio=L:(f==null?void 0:f.kind)==="spline"&&f.knots.push(L);break;case 50:((f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse")&&(f.startDeg=L);break;case 51:((f==null?void 0:f.kind)==="arc"||(f==null?void 0:f.kind)==="ellipse")&&(f.endDeg=L);break;case 94:(f==null?void 0:f.kind)==="spline"&&(f.degree=L);break;case 95:(f==null?void 0:f.kind)==="spline"&&(f.expectedKnots=L);break;case 96:(f==null?void 0:f.kind)==="spline"&&(f.expectedControls=L);break;case 97:if((f==null?void 0:f.kind)==="spline"&&!f.fitCountSeen&&(f.controlPoints.length>0||f.knots.length>0)){f.expectedFits=L,f.fitCountSeen=!0;break}nt();break;case 75:R(),N(),m=0,w=!0,this.hatchStyle=L;break;case 210:i=L;break;case 220:r=L;break;case 230:s=L;break}}f&&(g.push(f),f=null),N(),b&&this.definitionLines.push(b),v(),this.elevation=e;const et=new A(i,r,s);return et.lengthSq()>0&&(this.normal=et),this.patternAngle=o*Math.PI/180,this}};Lc.typeName="Hatch";let Ti=Lc;class Sg{constructor(t){this.db=t}createDefaultLayer(){const t=new U;return t.colorIndex=7,this.db.tables.layerTable.add(new $i({name:"0",standardFlags:0,linetype:"Continuous",lineWeight:0,isOff:!1,color:t,isPlottable:!0}))}createDefaultLineType(){this.db.tables.linetypeTable.add(new qe({name:"ByBlock",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new qe({name:"ByLayer",standardFlag:0,description:"",totalPatternLength:0})),this.db.tables.linetypeTable.add(new qe({name:"Continuous",standardFlag:0,description:"Solid line",totalPatternLength:0}))}createDefaultTextStyle(){this.db.tables.textStyleTable.add(new Qs({name:lt,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}createDefaultDimStyle(){this.db.tables.dimStyleTable.add(new Ht({name:lt,dimtxsty:lt}))}createDefaultLayout(){const t=new Hi;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 Ti;e.patternName=an;const i=new On;i.add(new Vt({x:0,y:0},{x:-1,y:.125})),i.add(new Vt({x:-1,y:.125},{x:-1,y:-.125})),i.add(new Vt({x:-1,y:-.125},{x:0,y:0})),e.add(i);const r=new ct;r.name="_CAXARROW",r.appendEntity(e),this.db.tables.blockTable.add(r)}}}const ca=Math.PI/200;class kg{constructor(t){this.database=t}formatLength(t,e){const i=this.createContext(e);return bn(t,i)}formatPoint2d(t,e){const i=this.createContext(e);return`${bn(t.x,i)}, ${bn(t.y,i)}`}formatPoint3d(t,e){const i=this.createContext(e);return`${bn(t.x,i)}, ${bn(t.y,i)}, ${bn(t.z,i)}`}formatAngle(t,e){const i=this.createContext(e),s=(e==null?void 0:e.applyAngbaseAngdir)??!0?N1(t,this.database.angbase,this.database.angdir):C.normalizeAngle(t);return R1(s,i)}createContext(t){return{lunits:this.database.lunits,luprec:Li(this.database.luprec),insunits:this.database.insunits,unitmode:this.database.unitmode,measurement:this.database.measurement,aunits:this.database.aunits,auprec:Li(this.database.auprec),showUnits:(t==null?void 0:t.showUnits)??!1,showApproximate:(t==null?void 0:t.showApproximate)??!1}}}function bn(n,t){let e;switch(t.lunits){case ut.Scientific:e=Lo(U1(n,t.luprec),t);break;case ut.Engineering:e=G1(n,t);break;case ut.Architectural:e=H1(n,t);break;case ut.Fractional:e=Lo(W1(n,t),t);break;case ut.WindowsDesktop:case ut.Decimal:default:e=Lo(ei(n,t.luprec),t)}return Eg(e,B1(n,t),t)}function R1(n,t){let e;switch(t.aunits){case Bt.DegreesMinutesSeconds:e=Lg(n,t);break;case Bt.Gradians:e=K1(n,t);break;case Bt.Radians:e=q1(n,t);break;case Bt.SurveyorsUnits:e=Z1(n,t);break;case Bt.DecimalDegrees:default:e=$1(n,t)}return Eg(e,F1(n,t),t)}function N1(n,t,e){let i=n-t;return e===1&&(i=-i),C.normalizeAngle(i)}function gc(n){const t=n.showUnits?'"':"";return n.unitmode===1?{feetInchSeparator:"",fractionSeparator:"-",inchSuffix:t}:{feetInchSeparator:"-",fractionSeparator:" ",inchSuffix:t}}function Li(n,t=0,e=8){return Number.isFinite(n)?Math.max(t,Math.min(e,Math.round(n))):t}function ti(n){return Object.is(n,-0)?0:n}function Eg(n,t,e){return!e.showApproximate||!t?n:`~ ${n}`}function B1(n,t){if(!Number.isFinite(n))return!1;const e=X1(n,t);return fc(n,e)}function F1(n,t){if(!Number.isFinite(n))return!1;if(t.aunits===Bt.SurveyorsUnits)return D1(n,t.auprec);const e=Y1(n,t);return fc(n,e)}function D1(n,t){const i=((90-C.radToDeg(n))%360+360)%360,r=Mg(i),s=Math.min(Math.abs(i-r.base),Math.abs(r.base+90-i)),o=C.degToRad(s),a=Ig(o,t);return fc(o,a)}function X1(n,t){const e=ti(n);switch(t.lunits){case ut.Scientific:return z1(e,t.luprec);case ut.Engineering:case ut.Architectural:case ut.Fractional:return V1(e,t);case ut.WindowsDesktop:case ut.Decimal:default:return Nn(e,t.luprec)}}function Y1(n,t){const e=ti(n);switch(t.aunits){case Bt.DegreesMinutesSeconds:return Ig(e,t.auprec);case Bt.Gradians:return Nn(e/ca,t.auprec)*ca;case Bt.Radians:return Nn(e,t.auprec);case Bt.DecimalDegrees:default:return C.degToRad(Nn(C.radToDeg(e),t.auprec))}}function Nn(n,t){if(!Number.isFinite(n))return 0;const e=10**t;return Math.round(ti(n)*e)/e}function z1(n,t){if(!Number.isFinite(n))return 0;const e=ti(n);if(e===0)return 0;const i=e.toExponential(t);return Number(i)}function V1(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===ut.Architectural||t.lunits===ut.Fractional){const o=1<<Li(t.luprec,0,8),a=j1(s,o);return e*(r*12+a)}return e*(r*12+Nn(s,t.luprec))}function j1(n,t){const e=Math.floor(n),i=n-e,r=Math.round(i*t);return r>=t?e+1:e+r/t}function Ig(n,t){const e=C.radToDeg(n),i=e<0?-1:1,r=Math.abs(e),s=Math.floor(r),o=(r-s)*60,a=Math.floor(o),c=Nn((o-a)*60,t),l=s+a/60+c/3600;return C.degToRad(i*l)}function fc(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 ei(n,t){if(!Number.isFinite(n))return"0";const e=ti(n);if(Number.isInteger(e)&&t===0)return String(e);const r=e.toFixed(t).replace(/\.?0+$/,"");return r===""||r==="-"?"0":r}function U1(n,t){if(!Number.isFinite(n))return"0";const e=ti(n);if(e===0)return"0";const i=e.toExponential(t).match(/^(.+)e([+-])(\d+)$/i);if(!i)return"0";const[,r,s,o]=i,a=o.length<2?o.padStart(2,"0"):o;return`${r}E${s}${a}`.toUpperCase()}function G1(n,t){if(!Number.isFinite(n))return"0";const e=gc(t),i=n<0?"-":"",r=Math.abs(n),s=Math.floor(r/12),o=r-s*12,a=ei(o,t.luprec);return s===0?`${i}${a}${e.inchSuffix}`:`${i}${s}'${e.feetInchSeparator}${a}${e.inchSuffix}`}function H1(n,t){if(!Number.isFinite(n))return"0";const e=gc(t),i=n<0?"-":"",r=Math.abs(n),s=Math.floor(r/12),o=r-s*12,a=1<<Li(t.luprec,0,8),c=Tg(o,a,e.fractionSeparator);return s===0?`${i}${c}${e.inchSuffix}`:`${i}${s}'${e.feetInchSeparator}${c}${e.inchSuffix}`}function W1(n,t){if(!Number.isFinite(n))return"0";const e=gc(t),i=n<0?"-":"",r=Math.abs(n),s=1<<Li(t.luprec,0,8);return`${i}${Tg(r,s,e.fractionSeparator)}`}function Tg(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 o=e_(s,t);s/=o;const a=t/o,c=`${s}/${a}`;return i===0?c:`${i}${e}${c}`}function $1(n,t){const e=C.radToDeg(n);return`${ei(e,t.auprec)}${t.showUnits?"°":""}`}function q1(n,t){return`${ei(n,t.auprec)}${t.showUnits?" rad":""}`}function K1(n,t){const e=n/ca;return`${ei(e,t.auprec)}${t.showUnits?"g":""}`}function Lg(n,t){const e=C.radToDeg(n),i=e<0?"-":"",r=Math.abs(e),s=Math.floor(r),o=(r-s)*60,a=Math.floor(o),c=(o-a)*60,l=ei(c,t.auprec),h=t.showUnits?'"':"";return`${i}${s}d${a}'${l}${h}`}function Z1(n,t){const i=((90-C.radToDeg(n))%360+360)%360,r=Mg(i),s=Math.min(Math.abs(i-r.base),Math.abs(r.base+90-i)),a=Lg(C.degToRad(s),t).replace(/^-/,"");return`${r.prefix} ${a} ${r.suffix}`.trim()}function Mg(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 Lo(n,t){if(!t.showUnits||t.lunits===ut.Engineering||t.lunits===ut.Architectural)return n;const e=Q1(t.insunits,t.measurement);return e?`${n}${e}`:n}function Q1(n,t){return n===at.Undefined?t===0?'"':" mm":Ub(n)?J1(n):Gb(n)?t_(n):""}function J1(n){switch(n){case at.Millimeters:return" mm";case at.Centimeters:return" cm";case at.Meters:return" m";case at.Kilometers:return" km";case at.Decimeters:return" dm";case at.Microns:return" µm";case at.Nanometers:return" nm";default:return""}}function t_(n){switch(n){case at.Inches:case at.Microinches:case at.Mils:case at.USSurveyInch:return'"';case at.Feet:case at.USSurveyFeet:return"'";case at.Miles:case at.USSurveyMile:return" mi";case at.Yards:case at.USSurveyYard:return" yd";default:return""}}function e_(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 Qt extends Et{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 jn(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 ke extends Et{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 jn([...this._recordsByName.values(),...this._unnamedRecords]):new jn(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 Cg extends ke{constructor(t){super(t)}get modelSpace(){let t=this.getAt(ct.MODEL_SPACE_NAME);return t||(t=new ct,t.name=ct.MODEL_SPACE_NAME,this.add(t)),t}getEntityById(t){const e=this.database.getObjectById(t);if(e instanceof tt)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(!e)return"";if(ct.isModelSapceName(e))return ct.MODEL_SPACE_NAME;if(ct.isPaperSapceName(e)){const i=ct.PAPER_SPACE_NAME_PREFIX,r=e.substring(i.length);return i+r}return super.normalizeName(e)}}const Og="DwgConverterLicenseError",n_=["evaluation of @mlight-cad/dwg-converter has expired"],i_=["invalid @mlight-cad/dwg-converter license key"];function Rg(n){return n==="license_expired"||n==="license_invalid"}function pc(n){const t=n.toLowerCase();if(n_.some(e=>t.includes(e)))return"license_expired";if(i_.some(e=>t.includes(e)))return"license_invalid"}function Ng(n){return pc(n)??"license_invalid"}const Nt=class Nt extends Error{constructor(t,e,i){super(t),this.name="AcDbOpenDatabaseError",this.code=e,this.stage=i==null?void 0:i.stage,this.cause=i==null?void 0:i.cause}static isLicenseErrorCode(t){return Rg(t)}static isWorkerOutOfMemoryMessage(t){const e=t.toLowerCase();return Nt.WORKER_OOM_PATTERNS.some(i=>e.includes(i))}static classifyThrownError(t){if(t instanceof Error){const i=Nt.readStructuredCode(t);if(i)return i;if(t.name===Og)return Ng(t.message)}const e=t instanceof Error?t.message:String(t);return Nt.classifyWorkerErrorMessage(e)}static classifyWorkerErrorMessage(t){const e=pc(t);return e||(Nt.isWorkerOutOfMemoryMessage(t)?"worker_oom":t.toLowerCase().includes("timed out")?"worker_timeout":"worker_error")}static from(t,e){if(t instanceof Nt)return t;const i=t instanceof Error?t.message:String(t),r=Nt.classifyThrownError(t);return new Nt(i,r,{stage:e,cause:t})}static fromTask(t){const e=t.task.name;return Nt.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=Nt.mapWorkerResultCode(t.errorCode,t.error);throw new Nt(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";case"license_expired":return"license_expired";case"license_invalid":return"license_invalid";default:return Nt.classifyWorkerErrorMessage(e??"")}}static readStructuredCode(t){const e=t.code;if(typeof e=="string")switch(e){case"license_expired":case"license_invalid":case"worker_oom":case"worker_timeout":case"worker_error":case"parse_failed":case"font_load_failed":case"fetch_failed":case"unknown":return e;default:return}}};Nt.WORKER_OOM_PATTERNS=["out of memory","data cannot be cloned","allocation failed","memory access out of bounds"];let Mi=Nt;class Bg extends ke{constructor(t){super(t)}}class Fg extends ke{constructor(t){super(t)}add(t){super.add(t),this.database.events.layerAppended.dispatch({database:this.database,layer:t})}}class Dg extends ke{constructor(t){super(t)}}class Ci extends ke{constructor(t){super(t)}static normalizeFontFileName(t){if(!t)return;const e=t.lastIndexOf(".");return e>=0?t.substring(0,e).toLowerCase():t.toLowerCase()}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(lt),i("STANDARD");for(const r of e){const s=this.getAt(r);if(s)return s;const o=r.toUpperCase();for(const a of this.newIterator())if(a.name.toUpperCase()===o)return a}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=Ci.normalizeFontFileName(e.fileName);i&&t.add(i);const r=Ci.normalizeFontFileName(e.bigFontFileName);r&&t.add(r)}return Array.from(t)}}class Xg extends ke{constructor(t){super(t)}}class Yg extends ke{constructor(t){super(t)}}class zg extends ke{constructor(t){super(t)}normalizeName(t){const e=(t??"").trim();return e?Ke.isActiveVportName(e)?Vn:super.normalizeName(e):""}getActiveVport(){return this.getAt(Vn)}getActiveVportBox(t,e){const i=this.getActiveVport();return i==null?void 0:i.resolveModelViewBox(t,e)}}class Vg extends ke{constructor(t){super(t)}}class jg extends Qt{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 Ug{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&&vt.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 la(n,t){const e=[],i=[],r=[];for(const s of t)if(s.kind==="modify"){const o=n.getObjectById(s.objectId);o instanceof tt&&e.push(o)}else if(s.kind==="append"){if(s.container.type==="blockTableRecord"){const o=n.tables.blockTable.getEntityById(s.object.objectId)??(s.object instanceof tt?s.object:void 0);o&&i.push(o)}}else s.kind==="remove"&&s.container.type==="blockTableRecord"&&s.object instanceof tt&&r.push(s.object);return{modified:e,appended:i,erased:r}}function eh(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 o=n.getObjectById(r.object.objectId)??r.object;e.push({object:o,key:s})}else r.kind==="remove"&&i.push({object:r.object,key:s})}return{set:e,erased:i}}function nh(n,t){const e={};for(const i of Kb){const r=n.getAttrWithoutException(i),s=t.getAttrWithoutException(i);ln(r,s)||(e[i]=s)}return e}function ih(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 $i))continue;const o=r.before,a=r.after;if(!o||!a)continue;const c=e?nh(a,o):nh(o,a);Object.keys(c).length!==0&&i.push({database:n,layer:s,changes:c})}return i}function r_(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 Gg{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&&r_(r.container,e))}getSysvarValue(t,e){return vt.instance().getVar(e,t)}}class mc{constructor(){this.openedObjects=new Map,this.originalStates=new Map,this.recorder=new Gg}getObject(t,e,i=!1){const r=this.openedObjects.get(t);if(r){if(e===Un.kForWrite&&!this.originalStates.has(t)){const o=r.clonePreservingIdentity();this.originalStates.set(t,o),this.recorder.recordModify(r)}return r}const s=this.lookupObject(t,i);if(this.openedObjects.set(t,s),e===Un.kForWrite){const o=s.clonePreservingIdentity();this.originalStates.set(s.objectId,o),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 Hg extends mc{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 Wg{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 $g{constructor(t){this.database=t,this.transactionStack=[],this.undoStack=new Wg,this.undoMarkStack=[],this._applyingUndoRedo=!1,this._pendingEntityModified=new Set,this._pendingLayerModified=new Map,this.strictMode=!1,this.changeApplier=new Ug(t)}startTransaction(){const t=new Hg(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}=la(this.database,t);for(const a of e)this.dispatchEntityModified(a);i.length>0&&this.database.notifyEntityAppended(i),r.length>0&&this.database.notifyEntityErased(r);const{set:s,erased:o}=eh(this.database,t);for(const{object:a,key:c}of s)this.database.notifyDictObjectSet(a,c);for(const{object:a,key:c}of o)this.database.notifyDictObjectErased(a,c);for(const a of t)a.kind==="sysvar"&&a.after!==void 0&&vt.instance().events.sysVarChanged.dispatch({database:this.database,name:a.name,oldVal:a.before,newVal:a.after});for(const a of ih(this.database,t))this.dispatchLayerModified(a)}dispatchUndoRedoEvents(t,e){const{modified:i,appended:r,erased:s}=la(this.database,t),{set:o,erased:a}=eh(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 a)this.database.notifyDictObjectSet(c,l);for(const{object:c,key:l}of o)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 o)this.database.notifyDictObjectSet(c,l);for(const{object:c,key:l}of a)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&&vt.instance().events.sysVarChanged.dispatch({database:this.database,name:c.name,oldVal:l,newVal:h})}for(const c of ih(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 yi=class yi extends Et{constructor(){super({objectId:"0"}),this._classes=[],this._handleRegistry=new Map,this._drawNoPlotLayers=!0,this._drawCircleSides=aa,this._eventBatchDepth=0,this._pendingEntityAppended=[],this._pendingEntityErased=[],this._pendingDictObjectSet=[],this._pendingDictObjectErased=[],this._lastOpenError=null,this.events={dictObjetSet:new gt,dictObjectErased:new gt,entityAppended:new gt,entityModified:new gt,entityErased:new gt,layerAppended:new gt,layerModified:new gt,layerErased:new gt,openProgress:new gt,openFailed:new gt},yi._unsavedDrawingSequence+=1,this._dwgname=`Drawing${yi._unsavedDrawingSequence}.dwg`,this._version=new St("AC1014"),this._angbase=0,this._angdir=0,this._aunits=Bt.DecimalDegrees,this._auprec=0,this._lunits=ut.Decimal,this._luprec=4,this._celtscale=1,this._cecolor=new U,this._celtype=mt,this._celweight=exports.AcGiLineWeight.ByLayer,this._cetransparency=new pt,this._clayer="0",this._cmlstyle=Oe,this._cmlscale=1,this._cmleaderstyle=Re,this._hpbackgroundcolor=new U(exports.AcCmColorMethod.None),this._hpcolor=this._cecolor.clone(),this._hplayer=".",this._hptransparency=new pt,this._textstyle=lt,this._dimstyle=lt,this._extents=new j,this._insunits=at.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._comparehatch=Br,this._comparercmargin=Fr,this._comparetext=Dr,this._comparetolerance=Xr,this._maxHandle=0,this._tables={appIdTable:new Vg(this),blockTable:new Cg(this),dimStyleTable:new Bg(this),linetypeTable:new Dg(this),textStyleTable:new Ci(this),ucsTable:new Xg(this),viewTable:new Yg(this),layerTable:new Fg(this),viewportTable:new zg(this)},this._objects={dictionary:new Qt(this),group:new Qt(this),imageDefinition:new Qt(this),layerFilter:new Qt(this),layerIndex:new Qt(this),layout:new jg(this),mleaderStyle:new Qt(this),mlineStyle:new Qt(this),sortentsTable:new Qt(this),xrecord:new Qt(this)},this._layerFilters=new Be,this.transactionManager=new $g(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 Be}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,Un.kForRead)}openObjectForWrite(t){return this.openObject(t,Un.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 o=0;try{for(let a=0;a<r;a+=s){const c=Math.min(a+s,r),l=i.slice(a,c);this.events.entityAppended.dispatch({database:this,entity:l}),o=c,e&&await e(c,r)}}finally{o<r&&this.events.entityAppended.dispatch({database:this,entity:i.slice(o)}),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 kg(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(Ue)&&!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(Ue)||this._handleRegistry.set(e,t)}releaseObjectHandle(t){const e=t.objectId;!e||e.startsWith(Ue)||this._handleRegistry.get(e)===t&&this._handleRegistry.delete(e)}isHandleTaken(t,e){if(!t||t.startsWith(Ue))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 o=this._handleRegistry.get(i);if(o&&o!==t)if(this.shouldPreserveIncomingHandle(t))this.assignGeneratedHandle(o);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(T.AUNITS,this._aunits,t??0,e=>{this._aunits=e})}get auprec(){return this._auprec}set auprec(t){this.updateSysVar(T.AUPREC,this._auprec,t??0,e=>{this._auprec=e})}get lunits(){return this._lunits}set lunits(t){this.updateSysVar(T.LUNITS,this._lunits,t??ut.Decimal,e=>{this._lunits=e})}get luprec(){return this._luprec}set luprec(t){this.updateSysVar(T.LUPREC,this._luprec,t??4,e=>{this._luprec=e})}get version(){return this._version}set version(t){this.updateSysVar(T.ACADVER,this._version,new St(t),e=>{this._version=e})}get insunits(){return this._insunits}set insunits(t){this.updateSysVar(T.INSUNITS,this._insunits,t??4,e=>{this._insunits=e})}get unitmode(){return this._unitmode}set unitmode(t){this.updateSysVar(T.UNITMODE,this._unitmode,t??0,e=>{this._unitmode=e})}get measurement(){return this._measurement}set measurement(t){this.updateSysVar(T.MEASUREMENT,this._measurement,t??1,e=>{this._measurement=e})}get ltscale(){return this._ltscale}set ltscale(t){this.updateSysVar(T.LTSCALE,this._ltscale,t??1,e=>{this._ltscale=e})}get lwdisplay(){return this._lwdisplay}get drawNoPlotLayers(){return this._drawNoPlotLayers}get drawCircleSides(){return this._drawCircleSides}set drawCircleSides(t){this._drawCircleSides=$.resolveCircleSides(t)}get dwgname(){return this._dwgname}setDwgName(t){const e=t.trim();e&&this.updateSysVar(T.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(T.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(T.CECOLOR,this._cecolor,t||0,e=>{this._cecolor=e.clone()})}get celtscale(){return this._celtscale}set celtscale(t){this.updateSysVar(T.CELTSCALE,this._celtscale,t??1,e=>{this._celtscale=e})}get celtype(){return this._celtype}set celtype(t){const e=this.normalizeLinetypeName(t??mt);this.updateSysVar(T.CELTYPE,this._celtype,e,i=>{this._celtype=i})}get celweight(){return this._celweight}set celweight(t){this.updateSysVar(T.CELWEIGHT,this._celweight,t??exports.AcGiLineWeight.ByLayer,e=>{this._celweight=e})}get cetransparency(){return this._cetransparency}set cetransparency(t){this.updateSysVar(T.CETRANSPARENCY,this._cetransparency,t??new pt,e=>{this._cetransparency=e.clone()})}get clayer(){return this._clayer}set clayer(t){this.updateSysVar(T.CLAYER,this._clayer,t??"0",e=>{this._clayer=e})}get cmlstyle(){return this._cmlstyle}set cmlstyle(t){this.updateSysVar(T.CMLSTYLE,this._cmlstyle,t??Oe,e=>{this._cmlstyle=e})}get cmlscale(){return this._cmlscale}set cmlscale(t){this.updateSysVar(T.CMLSCALE,this._cmlscale,t??1,e=>{this._cmlscale=e})}get cmleaderstyle(){return this._cmleaderstyle}set cmleaderstyle(t){this.updateSysVar(T.CMLEADERSTYLE,this._cmleaderstyle,t??Re,e=>{this._cmleaderstyle=e})}get hpbackgroundcolor(){return this._hpbackgroundcolor}set hpbackgroundcolor(t){this.updateSysVar(T.HPBACKGROUNDCOLOR,this._hpbackgroundcolor,t??new U(exports.AcCmColorMethod.None),e=>{this._hpbackgroundcolor=e.clone()})}get hpcolor(){return this._hpcolor}set hpcolor(t){this.updateSysVar(T.HPCOLOR,this._hpcolor,t??this._cecolor,e=>{this._hpcolor=e.clone()})}get hplayer(){return this._hplayer}set hplayer(t){this.updateSysVar(T.HPLAYER,this._hplayer,t??".",e=>{this._hplayer=e})}get hptransparency(){return this._hptransparency}set hptransparency(t){this.updateSysVar(T.HPTRANSPARENCY,this._hptransparency,t??new pt,e=>{this._hptransparency=e.clone()})}get textstyle(){return this._textstyle}set textstyle(t){this.updateSysVar(T.TEXTSTYLE,this._textstyle,t??lt,e=>{this._textstyle=e})}get dimstyle(){return this._dimstyle}set dimstyle(t){this.updateSysVar(T.DIMSTYLE,this._dimstyle,t??lt,e=>{this._dimstyle=e})}get angbase(){return this._angbase}set angbase(t){this.updateSysVar(T.ANGBASE,this._angbase,t??0,e=>{this._angbase=e})}get angdir(){return this._angdir}set angdir(t){this.updateSysVar(T.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(T.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(T.EXTMIN,e,this._extents.min)}}get extents(){return this._extents}get pdmode(){return this._pdmode}set pdmode(t){this.updateSysVar(T.PDMODE,this._pdmode,t??0,e=>{this._pdmode=e})}get pdsize(){return this._pdsize}set pdsize(t){this.updateSysVar(T.PDSIZE,this._pdsize,t??0,e=>{this._pdsize=e})}get osmode(){return this._osmode}set osmode(t){this.updateSysVar(T.OSMODE,this._osmode,t??0,e=>{this._osmode=e})}get orthomode(){return this._orthomode}set orthomode(t){this.updateSysVar(T.ORTHOMODE,this._orthomode,t??0,e=>{this._orthomode=e})}get comparehatch(){return this._comparehatch}set comparehatch(t){const e=pe("COMPAREHATCH",t??Br,zs,Vs);this.updateSysVar(T.COMPAREHATCH,this._comparehatch,e,i=>{this._comparehatch=i})}get comparercmargin(){return this._comparercmargin}set comparercmargin(t){const e=pe("COMPARERCMARGIN",t??Fr,js,Us);this.updateSysVar(T.COMPARERCMARGIN,this._comparercmargin,e,i=>{this._comparercmargin=i})}get comparetext(){return this._comparetext}set comparetext(t){const e=pe("COMPARETEXT",t??Dr,Gs,Hs);this.updateSysVar(T.COMPARETEXT,this._comparetext,e,i=>{this._comparetext=i})}get comparetolerance(){return this._comparetolerance}set comparetolerance(t){const e=pe("COMPARETOLERANCE",t??Xr,Ws,$s);this.updateSysVar(T.COMPARETOLERANCE,this._comparetolerance,e,i=>{this._comparetolerance=i})}get lastOpenError(){return this._lastOpenError}async read(t,e,i=di.DXF){const r=ge.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,this.drawCircleSides=(e==null?void 0:e.circleSides)??aa,e!=null&&e.fileName&&this.setDwgName(e.fileName),Uu(this);try{await r.read(t,this,{minimumChunkSize:e&&e.minimumChunkSize||10,progress:this.createConversionProgressHandler(),timeout:e==null?void 0:e.timeout,sysVars:e==null?void 0:e.sysVars})}catch(s){const o=Mi.from(s);throw this._lastOpenError=o,this.events.openFailed.dispatch({database:this,error:o}),o}this._lastOpenError=null,this.ensureDatabaseDefaults()}createConversionProgressHandler(){return async(t,e,i,r,s)=>{let o=r;if(i==="ERROR"&&s){const a=Mi.fromTask(s);this._lastOpenError=a,o={code:a.code,message:a.message,stage:a.stage??e}}this.events.openProgress.dispatch({database:this,percentage:t,stage:"CONVERSION",subStage:e,subStageStatus:i,data:o})}}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 o=0;const a=(g=i.body)==null?void 0:g.getReader();if(!a)throw new Error("Failed to get response reader");const c=[];for(;;){const{done:f,value:p}=await a.read();if(f)break;if(c.push(p),o+=p.length,s!==null){const m=Math.round(o/s*100);this.events.openProgress.dispatch({database:this,percentage:m,stage:"FETCH_FILE",subStageStatus:"IN-PROGRESS"})}}const l=new Uint8Array(o);let h=0;for(const f of c)l.set(f,h),h+=f.length;const u=this.getFileNameFromUri(t);u&&this.setDwgName(u);const d=u.toLowerCase().split(".").pop();d==="dwg"?await this.read(l.buffer,e,di.DWG):d==="dxf"?await this.read(l.buffer,e,di.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"},o=i instanceof St?i:new St(i),a=new We({database:this,precision:e,version:o,outputFormat:s.format});return this.writeDxfHeaderSection(a),this.writeDxfClassesSection(a),this.writeDxfTablesSection(a,o),this.writeDxfBlocksSection(a),this.writeDxfEntitiesSection(a),this.writeDxfObjectsSection(a),this.writeDxfThumbnailImageSection(a,s.saveThumbnailImage),a.writeStart("EOF"),s.format==="binary"?a.toBinary():a.toString()}async regen(){await new Vd(this).read(null,this,{minimumChunkSize:500,progress:this.createConversionProgressHandler()})}createDefaultData(t={layer:!0,lineType:!0,textStyle:!0,dimStyle:!0,layout:!0}){const e=new Sg(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||Re);return}if(t.dxfTypeName==="HATCH"){const i=t;(e=i.applyPatternDefaultsFromSysVars)==null||e.call(i,this)}}ensureTextStyleDefaults(){this.hasDefaultTextStyle()||this.tables.textStyleTable.add(new Qs({name:lt,standardFlag:0,fixedTextHeight:0,widthFactor:1,obliqueAngle:0,textGenerationFlag:0,lastHeight:.2,font:"SimKai",bigFont:"",extendedFont:"SimKai"}))}hasDefaultTextStyle(){const t=[lt,"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()===lt.toUpperCase())return!0;return!1}ensureDatabaseDefaults(){if(!this.tables.layerTable.has("0")){const e=new U;e.colorIndex=7,this.tables.layerTable.add(new $i({name:"0",standardFlags:0,linetype:$e,lineWeight:0,isOff:!1,color:e,isPlottable:!0}))}if(this.tables.linetypeTable.has(ye)||this.tables.linetypeTable.add(new qe({name:ye,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has(mt)||this.tables.linetypeTable.add(new qe({name:mt,standardFlag:0,description:"",totalPatternLength:0})),this.tables.linetypeTable.has($e)||this.tables.linetypeTable.add(new qe({name:$e,standardFlag:0,description:"Solid line",totalPatternLength:0})),this.ensureTextStyleDefaults(),this.tables.dimStyleTable.has(lt)||this.tables.dimStyleTable.add(new Ht({name:lt,dimtxsty:lt})),!this.tables.viewportTable.has(Vn)){const e=new Ke;e.name=Vn,this.tables.viewportTable.add(e)}this.ensureMLineStyle(this._cmlstyle||Oe),this.ensureMLeaderStyle(this._cmleaderstyle||Re);const t=this.tables.blockTable.modelSpace;if(!this.objects.layout.getAt("Model")){const e=new Hi;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(Zo)||this.tables.appIdTable.add(new $r(Zo)),this.tables.appIdTable.has(Ko)||this.tables.appIdTable.add(new $r(Ko))}ensureMLineStyle(t){const e=this.objects.mlineStyle,i=t.trim();if(!i||e.getAt(i))return;for(const[s,o]of e.entries())if(s.toUpperCase()===i.toUpperCase()||o.styleName.toUpperCase()===i.toUpperCase())return;const r=new uc;r.styleName=i,r.elements=[{offset:.5,color:new U().setByLayer(),lineType:mt},{offset:-.5,color:new U().setByLayer(),lineType:mt}],e.setAt(i,r)}ensureMLeaderStyle(t){const e=this.objects.mleaderStyle,i=t.trim();if(!i||e.getAt(i))return;for(const[a]of e.entries())if(a.toUpperCase()===i.toUpperCase())return;const r=new ro;r.unknown1=2,r.maxLeaderSegmentsPoints=2,r.leaderLineColor=new U().setByBlock(),r.textColor=new U().setByBlock(),r.blockColor=new U().setByBlock(),r.alignSpace=4,r.breakSize=3.75,r.enableBlockRotation=!0,r.unknown2=!1;const s=this.tables.linetypeTable.getAt(ye);r.leaderLineTypeId=s==null?void 0:s.objectId;const o=this.tables.textStyleTable.getAt(lt);r.textStyleId=o==null?void 0:o.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=o=>{t.writeStart("DICTIONARY"),o.dxfOut(t,!0)},r=(o,a)=>{e.getAt(o)!==a&&e.setAt(o,a)},s=o=>{e.getAt(o)&&e.remove(o)};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[o,a]of this.objects.layout.entries())t.writeStart("LAYOUT"),a.dxfOut(t,!0);for(const[o,a]of this.objects.group.entries())a.name||(a.name=o),t.writeStart("GROUP"),a.dxfOut(t,!0);for(const[o,a]of this.objects.sortentsTable.entries())t.writeStart("SORTENTSTABLE"),a.dxfOut(t,!0);for(const[o,a]of this.objects.imageDefinition.entries())t.writeStart("IMAGEDEF"),a.dxfOut(t,!0);for(const[o,a]of this.objects.layerFilter.entries())t.writeStart("LAYER_FILTER"),a.dxfOut(t,!0);for(const[o,a]of this.objects.layerIndex.entries())t.writeStart("LAYER_INDEX"),a.dxfOut(t,!0);for(const[o,a]of this.objects.mleaderStyle.entries())t.writeStart("MLEADERSTYLE"),a.dxfOut(t,!0);for(const[o,a]of this.objects.mlineStyle.entries())t.writeStart("MLINESTYLE"),a.dxfOut(t,!0);for(const[o,a]of this.objects.xrecord.entries())t.writeStart("XRECORD"),a.dxfOut(t,!0);this.writeAcLyLayerFilterObjects(t),t.endSection()}writeAcLyLayerFilterObjects(t){const e=ig(this._layerFilters);if(e.nodes.length===0)return;const i=[],r=[],s=this.tables.layerTable,o=s.extensionDictionary??this.generateHandle();s.extensionDictionary=o;const a=this.generateHandle(),c=this.generateHandle(),l=[],h=[],u=(f,p,m)=>{const y=this.generateHandle();let b;if(f.children.length>0){const w=this.generateHandle(),x=this.generateHandle(),S=[];for(const P of f.children)S.push({name:P.key,id:u(P,x,!1)});i.push({handle:w,ownerId:y,entries:[{name:Hn,id:x}]}),i.push({handle:x,ownerId:w,entries:S}),b=w}return r.push({handle:y,ownerId:p,extensionDictionaryId:b,data:f.data}),m&&h.push({name:f.key,id:y}),y};for(const f of e.nodes)l.push({name:f.key,id:u(f,a,!0)});const d=new Map,g=this.getObjectById(o);if(g instanceof Qt)for(const[f,p]of g.entries())d.set(f,p.objectId);d.set(Hn,a),d.set(io,c),i.unshift({handle:o,ownerId:s.objectId,entries:Array.from(d,([f,p])=>({name:f,id:p}))},{handle:a,ownerId:o,entries:l},{handle:c,ownerId:o,entries:h});for(const f of i){t.writeStart("DICTIONARY"),t.writeHandle(5,f.handle),t.writeObjectId(330,f.ownerId),t.writeSubclassMarker("AcDbDictionary"),t.writeInt16(280,1),t.writeInt16(281,1);for(const p of f.entries)t.writeString(3,p.name),t.writeObjectId(350,p.id)}for(const f of r){const p=new dc;p.objectId=f.handle,p.ownerId=f.ownerId,f.extensionDictionaryId&&(p.extensionDictionary=f.extensionDictionaryId),p.data=rg(f.data),t.writeStart("XRECORD"),p.dxfOut(t)}}writeDxfTable(t,e,i,r,s){const o=[...r];t.startTable(e),i.dxfOut(t);for(const a of o){if(s==="BLOCK_RECORD"&&a instanceof ct){a.dxfOutBlockRecord(t);continue}t.writeStart(s),a.dxfOut(t,!0)}t.endTable()}writeDxfEntity(t,e){if(e instanceof Rt&&!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 o=i.subarray(s,s+r);t.writeString(310,qs(o))}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 Be,this._currentSpace=void 0,this._extents.makeEmpty(),this.registerBootstrapHandles()}updateSysVar(t,e,i,r){vt.instance().applyVarMutation(t,e,i,this,()=>r(i))}normalizeLinetypeName(t){const e=t.trim();return e.toUpperCase()==="BYLAYER"?mt:e.toUpperCase()==="BYBLOCK"?ye:e}triggerSysVarChangedEvent(t,e,i){const r=vt.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""}}};yi._unsavedDrawingSequence=0;let ha=yi;class s_{constructor(){this.transactionStack=[]}startTransaction(){const t=new mc;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 Mo=6,Mc=class Mc extends tt{get dxfTypeName(){return"TOLERANCE"}constructor(){super(),this._location=new _,this._text="",this._dimensionStyle="",this._normal=new A(0,0,1),this._direction=new A(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 _(0,r,0),new _(t,r,0),new _(t,s,0),new _(0,s,0),new _(0,r,0)].map(a=>this.toFrameWcs(a.x,a.y))}get geometricExtents(){const t=new j;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 Se(t,e,this._location),this}subGetOsnapPoints(t,e,i,r){t===I.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 o=new A(r).sub(i),a=new A(s).sub(i);let c=new A().crossVectors(o,a);c.lengthSq()===0?c=this._normal.clone().transformDirection(t):c.normalize();let l=o.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(([o,a])=>t.lines([o,a])),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(A.Z_AXIS)||t.writeVector3d(210,this._normal),this._direction.equals(A.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,o=this.normal.y,a=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 f=Number(g.code),p=Number(g.value);switch(f){case 1:this.text=String(g.value);break;case 3:this.dimensionStyle=String(g.value);break;case 10:e=p;break;case 20:i=p;break;case 30:r=p;break;case 11:c=p,d=!0;break;case 21:l=p,d=!0;break;case 31:h=p,d=!0;break;case 210:s=p,u=!0;break;case 220:o=p,u=!0;break;case 230:a=p,u=!0;break}}return this.location={x:e,y:i,z:r},u&&(this.normal={x:s,y:o,z:a}),d&&(this.direction={x:c,y:l,z:h}),this}get textHeight(){const t=this.resolveDimensionStyle(),e=(t==null?void 0:t.dimtxt)??Ht.DEFAULT_DIM_VALUES.dimtxt,i=(t==null?void 0:t.dimscale)??Ht.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(),o=[];for(let a=0;a<i.length;a++){const c=i[a];let l=r.cellPadding;const h=-r.rowHeight*a;for(let u=0;u<c.cells.length;u++){const d=c.cells[u],g=r.columnWidths[u]??this.textHeight;if(d.trim()){const f=this.toFrameWcs(l+g/2,h),p={text:d,height:this.textHeight,width:1/0,position:f,directionVector:this._direction,attachmentPoint:exports.AcGiMTextAttachmentPoint.MiddleCenter,drawingDirection:exports.AcGiMTextFlowDirection.LEFT_TO_RIGHT};o.push(t.mtext(p,s,e))}l+=g+r.columnGap}}if(o.length!==0)return o.length===1?o[0]:t.group(o)}collectFrameLineSegments(){const t=this.parseToleranceFrame(this._text),e=this.resolveFrameLayout(t),{width:i,rowHeight:r,rowCount:s,columnDivisions:o}=e;if(i<=0||r<=0||s<=0)return[];const a=r/2,c=a-r*s,l=[],h=(u,d)=>{l.push([u,d])};h(this.toFrameWcs(0,a),this.toFrameWcs(i,a)),h(this.toFrameWcs(i,a),this.toFrameWcs(i,c)),h(this.toFrameWcs(i,c),this.toFrameWcs(0,c)),h(this.toFrameWcs(0,c),this.toFrameWcs(0,a));for(const u of o)h(this.toFrameWcs(u,a),this.toFrameWcs(u,c));for(let u=1;u<t.length;u++){const d=a-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,o=i;if(i<=0||e.length===0)return{width:0,totalHeight:0,rowHeight:0,columnWidths:[],columnDivisions:[],rowCount:0,cellPadding:0,columnGap:0};const a=Math.max(...e.map(d=>d.cells.length),0),c=[];for(let d=0;d<a;d++){let g=i;for(const f of e){const p=f.cells[d]??"";if(!p.trim())continue;const m=Ab(p,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+=o,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:o}}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 a=this.splitToleranceTokens(s,"%%v").slice(0,Mo);for(;a.length<Mo;)a.push("");return a}),r=[0,1];i.some(s=>{var o;return(o=s[2])==null?void 0:o.trim()})&&r.push(2);for(let s=3;s<Mo;s++)i.some(o=>{var a;return(a=o[s])==null?void 0:a.trim()})&&r.push(s);return i.map(s=>({cells:r.map(o=>s[o]??"")}))}splitToleranceRows(t){return t.replace(/\^J/g,`
11
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 o=0;o<t.length;){if(t.startsWith(e,o)&&s===0){i.push(r),r="",o+=e.length;continue}const a=t[o];a==="{"?s++:a==="}"&&(s=Math.max(0,s-1)),r+=a,o++}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 A().crossVectors(t,e);return i.lengthSq()===0&&(e=A.X_AXIS.clone(),i=new A().crossVectors(t,e)),i.normalize(),e=new A().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)??Ht.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}};Mc.typeName="Fcf";let Kr=Mc;const Cc=class Cc extends tt{constructor(){super(),this._normal=new A(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 _,this._attachmentPoint=exports.AcGiMTextAttachmentPoint.TopLeft,this._direction=new A(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 j,e=this.extentsWidth>0?this.extentsWidth:this.width>0?this.width:Wi(this.contents,this.height),i=Cd(this.contents),r=Od(i,this.height,this.lineSpacingFactor);return Rd(t,this._location,e,r,this.attachmentPoint,this.rotation,this.direction)}subGetGripPoints(){return[this._location]}subMoveGripPointsAt(t,e){return Se(t,e,this._location),this}subGetOsnapPoints(t,e,i,r){I.Insertion===t&&r.push(this._location)}transformBy(t){const e=this._location.clone(),i=this._direction.lengthSq()>0?this._direction.clone().normalize():new A(Math.cos(this._rotation),Math.sin(this._rotation),0),r=new A(-i.y,i.x,i.z);r.lengthSq()===0&&r.set(0,1,0),r.normalize();const s=e.clone().add(i),o=e.clone().add(r);e.applyMatrix4(t),s.applyMatrix4(t),o.applyMatrix4(t);const a=new A(s).sub(e),c=new A(o).sub(e),l=a.length(),h=c.length();return this._location.copy(e),l>0&&(this._direction.copy(a).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,o=this.direction.y,a=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 f=Number(g.code),p=Number(g.value);switch(f){case 10:e=p;break;case 20:i=p;break;case 30:r=p;break;case 11:s=p,u=!0;break;case 21:o=p,u=!0;break;case 31:a=p,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=p;break;case 41:this.width=p;break;case 42:p>0&&(this.extentsWidth=p);break;case 43:break;case 44:this.lineSpacingFactor=p;break;case 45:this.backgroundScaleFactor=p;break;case 46:this.annotationHeight=p;break;case 48:this.columnWidth=p;break;case 49:this.columnGutter=p;break;case 50:this.rotation=C.degToRad(p);break;case 71:this.attachmentPoint=p;break;case 72:this.drawingDirection=p;break;case 73:this.lineSpacingStyle=p;break;case 75:this.columnType=p;break;case 76:this.columnCount=p;break;case 78:this.columnFlowReversed=p!==0;break;case 79:this.columnAutoHeight=p!==0;break;case 90:this.backgroundFill=p!==0;break;case 63:this.backgroundFillColor=p;break;case 441:this.backgroundFillTransparency=p;break;case 101:for(;!t.atEndOfObject&&!t.atEof&&t.readItem(););break;case 210:c=p;break;case 220:l=p;break;case 230:h=p;break;case 100:return t.pushBackItem(g),this.finishMTextDxfIn(d,e,i,r,s,o,a,u,c,l,h),this}}return this.finishMTextDxfIn(d,e,i,r,s,o,a,u,c,l,h),this}finishMTextDxfIn(t,e,i,r,s,o,a,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:o,z:a});const d=new A(l,h,u);d.lengthSq()>0&&this.normal.copy(d.normalize())}};Cc.typeName="MText";let mn=Cc;var qg=(n=>(n[n.MText=0]="MText",n[n.Fcf=1]="Fcf",n[n.BlockReference=2]="BlockReference",n[n.NoAnnotation=3]="NoAnnotation",n))(qg||{});const Oc=class Oc extends It{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 A(0,0,1),this._horizontalDirection=new A(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 A(t):void 0}get offsetFromAnnotation(){var t;return(t=this._offsetFromAnnotation)==null?void 0:t.clone()}set offsetFromAnnotation(t){this._offsetFromAnnotation=t?new A(t):void 0}appendVertex(t){this._vertices.push(new _().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 Qn(t,e,this._vertices),this}subGetOsnapPoints(t,e,i,r){if(this.numVertices===0)return;if(this.isSplined&&this.splineGeo){switch(t){case I.EndPoint:r.push(this._vertices[0]),r.push(this._vertices[this.numVertices-1]);break;case I.Nearest:r.push(this.splineGeo.nearestPoint(e));break}return}const s=this._vertices;switch(t){case I.EndPoint:r.push(...s);break;case I.MidPoint:case I.Nearest:case I.Perpendicular:{const o=[];for(let a=0;a<s.length-1;a++){const c=[];Jn(s[a],s[a+1],t,e,c),o.push(...c)}if(t===I.MidPoint)r.push(...o);else{const a=ie(e,o);a&&r.push(a)}break}}}get geometricExtents(){return this._isSplined&&this.splineGeo?this.splineGeo.calculateBoundingBox():new j().setFromPoints(this.collectDrawPoints())}subGetIntersectCurves(){return this.isSplined&&this.splineGeo?[{kind:"spline",spline:this.splineGeo.clone(),extendable:!1}]:$t(this._vertices,!1)}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}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){return t.lines(this.collectDrawPoints(t))}collectDrawPoints(t){if(this.isSplined&&this.splineGeo)return this.splineGeo.tessellate(qi(t));const e=this._vertices.map(i=>i.clone());if(e.length>0&&!this._isSplined){const i=e[e.length-1];if(this.shouldDrawHookLine(i)){const r=this.computeHookLineEndPoint(i);r&&e.push(r)}}return e}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)??Ht.DEFAULT_DIM_VALUES.dimtad)!==lc.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)??Ht.DEFAULT_DIM_VALUES.dimgap)*((e==null?void 0:e.dimscale)??Ht.DEFAULT_DIM_VALUES.dimscale);let r=this._textWidth+i;const s=this.resolveAssociatedMText();if(s){const o=this.resolveHookSpanFromMText(s,t);if(o>0)r=Math.max(r,o);else{const a=this.resolveAnnotationWidth(s);a>0&&(r=Math.max(r,a))}}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 o of kb(r)){const a=(o.x-e.x)*i.x+(o.y-e.y)*i.y+(o.z-e.z)*i.z;a>s&&(s=a)}return s}resolveAnnotationWidth(t){if(t.extentsWidth>0)return t.extentsWidth;const e=rc(t.contents).split(`
12
12
  `);return Math.max(...e.map(i=>Wi(i.trim(),t.height)),0)}resolveMTextLayoutMetrics(t){return Pb({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),o=Math.max(i.height,t.height*4,10);return Eb(e,i,{padX:r,padYAbove:s,padYBelow:o})}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 a=t.getObjectById(this._associatedAnnotation);if(a instanceof mn)return a}if(this._vertices.length===0)return;const e=this.getAttrWithoutException("ownerId");if(!e)return;const i=t.getObjectById(e);if(!(i instanceof ct))return;const r=this._vertices[this._vertices.length-1];let s,o=Number.POSITIVE_INFINITY;for(const a of i.newIterator()){if(!(a instanceof mn))continue;const c=this.scoreMTextAssociation(a,r);c==null||c>=o||(o=c,s=a)}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 Ut(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,o=this.horizontalDirection.x,a=this.horizontalDirection.y,c=this.horizontalDirection.z,l=0,h=0,u=0,d=0,g=0,f=0,p=!1,m=!1;const y=()=>{e&&(this.appendVertex(e),e=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const b=t.readItem();if(!b)break;const w=Number(b.code),x=Number(b.value);switch(w){case 3:this.dimensionStyle=String(b.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:o=x;break;case 221:a=x;break;case 231:c=x;break;case 212:l=x,p=!0;break;case 222:h=x,p=!0;break;case 232:u=x,p=!0;break;case 213:d=x,m=!0;break;case 223:g=x,m=!0;break;case 233:f=x,m=!0;break;case 340:this.associatedAnnotation=String(b.value);break}}return y(),this.normal={x:i,y:r,z:s},this.horizontalDirection={x:o,y:a,z:c},p&&(this.offsetFromBlock={x:l,y:h,z:u}),m&&(this.offsetFromAnnotation={x:d,y:g,z:f}),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectPath2d();return e.length<2?1:Rt.from2dPoints(e,!1).getOffsetSideAtPoint(t)}createOffsetCurve(t){return so(this.collectPath2d(),!1,t)}collectPath2d(){return this.isSplined&&this.splineGeo?this.splineGeo.getPoints(64).map(t=>new M(t.x,t.y)):this._vertices.map(t=>new M(t.x,t.y))}transformVector(t,e){const i=new _,r=new _(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)}};Oc.typeName="Leader";let Zr=Oc;const Os=class Os extends It{constructor(t,e){super(),this._normal=new A(0,0,1),this._thickness=0,this._geo=new Dt(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}subGetIntersectCurves(){return[{kind:"line",line:this._geo.clone(),extent:"bounded"}]}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 bt(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,o=this.endPoint;switch(t){case I.EndPoint:r.push(s),r.push(o);break;case I.MidPoint:r.push(this.midPoint);break;case I.Nearest:{const a=this._geo.project(e);r.push(a)}break;case I.Perpendicular:{const a=this._geo.perpPoint(e);r.push(a)}break;case I.Tangent:break}}transformBy(t){return this._geo.transform(t),this}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){const e=this.startPoint,i=this.endPoint,r=[new _(e.x,e.y,0),new _(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=jt(this.startPoint,this.normal),i=jt(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,o=this.endPoint.y,a=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 f=Number(g.code),p=Number(g.value);switch(f){case 10:e=p;break;case 20:i=p;break;case 30:r=p;break;case 11:s=p;break;case 21:o=p;break;case 31:a=p;break;case 39:c=p;break;case 210:l=p;break;case 220:h=p;break;case 230:u=p;break}}const d=new A(l,h,u);return d.lengthSq()>0&&this.normal.copy(d.normalize()),this.thickness=c,this.startPoint=At({x:e,y:i,z:r},this.normal),this.endPoint=At({x:s,y:o,z:a},this.normal),this}getOffsetCurves(t){const e=this._geo.offset(t);return[new Os(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}};Os.typeName="Line";let Oi=Os;var fi=(n=>(n[n.InvisibleLeader=0]="InvisibleLeader",n[n.StraightLeader=1]="StraightLeader",n[n.SplineLeader=2]="SplineLeader",n))(fi||{}),kn=(n=>(n[n.NoneContent=0]="NoneContent",n[n.BlockContent=1]="BlockContent",n[n.MTextContent=2]="MTextContent",n[n.ToleranceContent=3]="ToleranceContent",n))(kn||{}),Kg=(n=>(n[n.Horizontal=0]="Horizontal",n[n.Vertical=1]="Vertical",n))(Kg||{}),Zg=(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))(Zg||{});const o_=1,a_=2,c_=4,l_=8,h_=64,u_=128,d_=32768,Rc=class Rc extends tt{get dxfTypeName(){return"MULTILEADER"}constructor(){super(),this._leaders=[],this._leaderLineType=1,this._contentType=0,this._doglegEnabled=!1,this._doglegLength=0,this._doglegVector=new A(1,0,0),this._normal=new A(0,0,1),this._mleaderStyleId="",this._textHeight=2.5,this._textWidth=0,this._textRotation=0,this._textDirection=new A(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 _},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 A(t.normal):void 0,position:t.position?this.createPoint(t.position):void 0,scale:new A(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 A(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 A(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 j().setFromPoints(t):new j}subGetIntersectCurves(){const t=[];return this._leaders.forEach(e=>{e.leaderLines.forEach(i=>{t.push(...$t(i.vertices,!1))})}),t}subGetGripPoints(){return this.collectGeometryPoints().map(t=>t.clone())}subMoveGripPointsAt(t,e){return bt(t,i=>{this.moveGeometryGripPointAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){var s;if(t===I.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(o=>{o.leaderLines.forEach(a=>{const c=this.getLeaderLineDrawPoints(o,a);if(c.length!==0)switch(t){case I.EndPoint:r.push(...c);break;case I.MidPoint:case I.Nearest:case I.Perpendicular:{const l=[];for(let h=0;h<c.length-1;h++){const u=[];Jn(c[h],c[h+1],t,e,u),l.push(...u)}if(t===I.MidPoint)r.push(...l);else{const h=ie(e,l);h&&r.push(h)}break}}})})}transformBy(t){var e,i,r,s,o,a,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(f=>f.applyMatrix4(t)),g.breaks.forEach(f=>{f.start.applyMatrix4(t),f.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),(a=(o=this._blockContent)==null?void 0:o.position)==null||a.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:kn[0],value:0},{label:kn[1],value:1},{label:kn[2],value:2},{label:kn[3],value:3}],accessor:{get:()=>this.contentType,set:t=>{this.contentType=t}}},{name:"leaderLineType",type:"enum",editable:!0,options:[{label:fi[0],value:0},{label:fi[1],value:1},{label:fi[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,o=r.lineType,a=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(f=>{f.leaderLines.forEach(m=>{const y=this.getLeaderLineDrawPoints(f,m);if(y.length>0){const b=this.drawLeaderLine(t,y);b&&i.push(b)}});const p=this.getDoglegPoints(f);p&&i.push(t.lines(p))}));const d=this.getRenderableMTextContent();if(!!d&&(this.contentType===2||this.contentType===0||this.hasMText===!0)&&d){this.applyColorTraits(r,u,s);const f=this.getResolvedTextHeight(),p={text:d.text,height:f,width:this.getMTextRenderWidth(d.text,f),position:d.anchorPoint,rotation:this.textRotation,directionVector:this.textDirection,attachmentPoint:this.textAttachmentPoint,drawingDirection:this.textDrawingDirection,lineSpaceFactor:this.textLineSpacingFactor};i.push(t.mtext(p,this.getTextStyle(),e))}if(r.color=s,r.lineType=o,r.lineWeight=a,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 v,k,E,O,N,R,nt,et,G,rt,L,q,dt,B,Ct;super.dxfInFields(t),t.atSubclassData("AcDbMLeader"),this._leaders.length=0;let e=(v=this._mtextContent)==null?void 0:v.text,i=(E=(k=this._mtextContent)==null?void 0:k.anchorPoint)==null?void 0:E.clone(),r=!!this._mtextContent,s=(O=this._blockContent)==null?void 0:O.blockContentId,o=(R=(N=this._blockContent)==null?void 0:N.position)==null?void 0:R.clone(),a=(et=(nt=this._blockContent)==null?void 0:nt.scale)==null?void 0:et.clone(),c=(G=this._blockContent)==null?void 0:G.rotation,l=(L=(rt=this._blockContent)==null?void 0:rt.normal)==null?void 0:L.clone(),h=(dt=(q=this._blockContent)==null?void 0:q.color)==null?void 0:dt.clone(),u=(B=this._blockContent)!=null&&B.transformationMatrix?[...this._blockContent.transformationMatrix]:[],d=!!this._blockContent,g=!1,f=!1,p=(Ct=this._landingPoint)==null?void 0:Ct.clone(),m=this._doglegVector.clone(),y=null,b=null,w=!1,x;const S=()=>{b&&y&&y.leaderLines.push(b),b=null},P=()=>{S(),y&&this.addLeader(y),y=null};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const ot=t.readItem();if(!ot)break;const gp=Number(ot.code),J=Number(ot.value),_t=String(ot.value??"");switch(gp){case 100:return t.pushBackItem(ot),P(),this.finishMLeaderDxfIn(e,i,r,s,o,a,c,l,h,u,d,g,p,m,x),this;case 300:if(_t==="CONTEXT_DATA{"){f=!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&&(o=F.blockPosition,d=!0),F.blockScale&&(a=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:f=!0,this.version=J;break;case 340:this.leaderStyleId=_t,this.mleaderStyleId=_t;break;case 90:w?(S(),b={vertices:[],breakPointIndexes:[],breaks:[]}):this.propertyOverrideFlag=J;break;case 170:this.leaderLineType=J;break;case 91:this.leaderLineColor=fe(J);break;case 341:f?this.leaderLineTypeId=_t:this.isValidMLeaderHandle(_t)?(s=_t,d=!0):this.leaderLineTypeId=_t;break;case 171:w||(this.leaderLineWeight=J);break;case 290:f?this.landingEnabled=this.readDxfBoolean(ot):this.doglegEnabled=this.readDxfBoolean(ot);break;case 291:this.doglegEnabled=this.readDxfBoolean(ot);break;case 40:f?this.doglegLength=J:this.textHeight=J;break;case 41:this.doglegLength=J;break;case 342:this.arrowheadId=_t;break;case 42:f?this.arrowheadSize=J:this.textWidth=J;break;case 172:this.contentType=J,g=!0;break;case 343:this.textStyleId=_t;break;case 173:this.textLeftAttachmentType=J;break;case 95:this.textRightAttachmentType=J;break;case 174:this.textAngleType=J;break;case 175:this.textAlignmentType=J;break;case 92:this.textColor=fe(J);break;case 292:this.textFrameEnabled=this.readDxfBoolean(ot);break;case 344:this.isValidMLeaderHandle(_t)&&(s=_t,this.blockContentId=_t,d=!0);break;case 93:this.blockContentColor=fe(J);break;case 10:if(w){t.pushBackItem(ot);const F=t.readPoint3d(10);F&&b&&b.vertices.push(F)}else{t.pushBackItem(ot);const F=t.readPoint3d(10);if(!F)break;f?(this.blockContentScale=new A(F),a=new A(F),d=!0):p=F}break;case 43:this.blockContentRotation=J,c=J,d=!0;break;case 176:this.blockContentConnectionType=J;break;case 293:this.annotativeScaleEnabled=this.readDxfBoolean(ot);break;case 94:{this.arrowheadOverrides.push({index:J});break}case 345:{const F=this.arrowheadOverrides[this.arrowheadOverrides.length-1];F?F.handle=_t:this.arrowheadOverrides.push({index:0,handle:_t});break}case 330:this.blockAttributes.push({id:_t});break;case 177:{const F=this.blockAttributes[this.blockAttributes.length-1];F&&(F.index=J);break}case 44:{const F=this.blockAttributes[this.blockAttributes.length-1];F&&(F.width=J);break}case 302:{const F=this.blockAttributes[this.blockAttributes.length-1];F&&(F.text=_t);break}case 294:this.textDirectionNegative=this.readDxfBoolean(ot);break;case 178:this.textAlignInIPE=J;break;case 179:J!==0&&(this.textAttachmentPoint=J);break;case 271:this.textAttachmentDirection=J;break;case 272:this.bottomTextAttachmentDirection=J;break;case 273:this.topTextAttachmentDirection=J;break;case 210:t.pushBackItem(ot);{const F=t.readVector3d(210);F&&(this.normal=F)}break;case 110:P(),w=!0,t.pushBackItem(ot),y={landingPoint:t.readPoint3d(110),doglegVector:new A(1,0,0),doglegLength:0,breaks:[],leaderLines:[]};break;case 111:if(y){t.pushBackItem(ot);const F=t.readVector3d(111);F&&(y.doglegVector=F)}break;case 140:y?y.doglegLength=J:this.arrowheadSize=J;break;case 1:e=_t,r=!0;break;case 12:t.pushBackItem(ot);{const F=t.readPoint3d(12);F&&(i=F,r=!0)}break;case 7:this.textStyleName=_t;break;case 50:x=J;break;case 15:t.pushBackItem(ot);{const F=t.readPoint3d(15);F&&(o=F,d=!0)}break;case 16:t.pushBackItem(ot);{const F=t.readVector3d(16);F&&(a=F,d=!0)}break;case 52:c=J*Math.PI/180,d=!0;break;case 11:if(!w&&!f){t.pushBackItem(ot);const F=t.readVector3d(11);F&&(m=F)}break}}return P(),this.finishMLeaderDxfIn(e,i,r,s,o,a,c,l,h,u,d,g,p,m,x),this}finishMLeaderDxfIn(t,e,i,r,s,o,a,c,l,h,u,d,g,f,p){if(g&&(this.landingPoint=g),this.doglegVector=f,p!=null&&(this.textRotation=p*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:o??new A(1,1,1),rotation:a??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),o=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 a=t.readVector3d(11);a&&(this.normal=a)}break;case 12:t.pushBackItem(i);{const a=t.readPoint3d(12);a&&(e.textAnchor=a,this.textAnchor=a.clone())}break;case 13:t.pushBackItem(i);{const a=t.readVector3d(13);a&&(this.textDirection=a)}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=fe(s);break;case 91:this.textBackgroundColor=fe(s);break;case 92:this.textBackgroundTransparency=s;break;case 93:e.blockColor=fe(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(o==="LEADER{"){const a=this.dxfInLeaderSection(t);this.addLeader(a)}break;case 304:o!=="LEADER_LINE{"&&(e.textContent=o,this.hasMText=!0);break;case 340:this.textStyleId=o;break;case 341:e.blockContentId=o,this.isValidMLeaderHandle(o)&&(this.blockContentId=o);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 o=Number(s.code),a=Number(s.value),c=String(s.value??"");if(o===303){r();break}if(o===0||o===301){t.pushBackItem(s),r();break}switch(o){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=a;break;case 40:e.doglegLength=a;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 o=Number(s.code),a=Number(s.value);if(o===305){r();break}if(o===0||o===303||o===301){t.pushBackItem(s),r();break}switch(o){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(a),i={index:a,start:(i==null?void 0:i.start)??new _,end:(i==null?void 0:i.end)??new _};break;case 91:e.leaderLineIndex=a;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 _().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(o=>o.clone()),breakPointIndexes:[...s.breakPointIndexes],leaderLineIndex:s.leaderLineIndex,breaks:s.breaks.map(o=>({index:o.index,start:o.start.clone(),end:o.end.clone()}))}))}}checkLeaderIndex(t){if(t<0||t>=this._leaders.length)throw new Error("The leader index is out of range!")}getMutableLeaderLine(t,e){this.checkLeaderIndex(t);const 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(o=>t.push(o.start,o.end))});const r=this.getDoglegPoints(i);r&&t.push(...r),i.leaderLines.forEach(s=>{const o=this.getArrowheadPoints(this.getLeaderLineDrawPoints(i,s));o&&t.push(...o)})}),this._landingPoint&&t.push(this._landingPoint),this.contentBasePosition&&t.push(this.contentBasePosition),this.textAnchor&&t.push(this.textAnchor),this._mtextContent&&t.push(this._mtextContent.anchorPoint),(e=this._blockContent)!=null&&e.position&&t.push(this._blockContent.position),this.planeOrigin&&t.push(this.planeOrigin),t}moveGeometryGripPointAt(t,e){var s;let i=0;const r=(o,a)=>{if(o){i===t&&o.add(e),i++;return}a&&(i===t&&a(),i++)};this._leaders.forEach(o=>{r(o.lastLeaderLinePoint),r(o.landingPoint),o.breaks.forEach(c=>{r(c.start),r(c.end)}),o.leaderLines.forEach(c=>{c.vertices.forEach(l=>r(l)),c.breaks.forEach(l=>{r(l.start),r(l.end)})});const a=this.getDoglegPoints(o);a&&(r(a[0]),r(void 0,()=>{const c=a[0],l=a[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)});o.doglegLength!=null||o.doglegVectorSet?o.doglegLength=h:this._doglegLength=h})),o.leaderLines.forEach(c=>{const l=this.getLeaderLineDrawPoints(o,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,o=r.clone().add(s.clone().multiplyScalar(i)),a=i/6,c=new A(-s.y,s.x,0),l=o.clone().add(c.clone().multiplyScalar(a)),h=o.clone().add(c.clone().multiplyScalar(-a));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??_.ORIGIN;let r=i.x;for(const s of t.newIterator()){const o=s.geometricExtents;o.isEmpty()||o.max.x>r&&(r=o.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],o=t[r+1],a=o.distanceTo(s);if(!(a<=0)){if(i<a){const c=new A().subVectors(o,s);return[s.clone().add(c.multiplyScalar(i/a)),...t.slice(r+1)]}i-=a}}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 oe;s.add(new it(r,!0));const o=t.subEntityTraits,a=o.fillType;o.fillType={solidFill:!0,patternAngle:0,definitionLines:[]};const c=t.area(s);return o.fillType=a,c}drawArrowheadBlock(t,e){const i=this.getResolvedArrowheadBlockTableRecord();if(!i)return;const r=this.getArrowheadFrame(e);if(!r)return;const{tip:s,unit:o}=r,a=this.getResolvedArrowheadSize(),c=Math.atan2(o.y,o.x),l=i.origin??_.ORIGIN,h=new D().makeTranslation(-l.x,-l.y,-l.z),u=new D().makeScale(a,a,a),d=new D().makeRotationZ(c),g=new D().makeTranslation(s.x,s.y,s.z),f=new D().multiplyMatrices(g,d).multiply(u).multiply(h);return Je.instance.draw(t,i,this.resolvedColor,[],!0,f,new A(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 A().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
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 _,r=new _(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 o=e.toUpperCase();for(const[,c]of t.entries())if(((r=c.objectId)==null?void 0:r.toUpperCase())===o)return c;const a=this.database.getObjectById(e);if(a instanceof ro)return a}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 o=e.toUpperCase();for(const[a,c]of i.entries())if(a.toUpperCase()===o)return c}getDefaultMLeaderStyleName(){try{return this.database.cmleaderstyle||Re}catch{return Re}}getResolvedTextStyleName(){var s,o,a;const t=this.database.tables.textStyleTable,e=(s=this.getMLeaderStyle())==null?void 0:s.textStyleId,i=e?(o=t.getIdAt(e))==null?void 0:o.name:void 0,r=this.textStyleId?(a=t.getIdAt(this.textStyleId))==null?void 0:a.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,a_)}getResolvedLeaderLineType(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.leaderLineType;return this.getResolvedStyleDrivenValue(this.leaderLineType,t,o_)}getResolvedLeaderLineTypeId(){var t;return this.getResolvedStyleDrivenValue(this.leaderLineTypeId,(t=this.getMLeaderStyle())==null?void 0:t.leaderLineTypeId,c_)}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,l_);if(e!=null)return e}getResolvedDoglegEnabled(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.doglegEnabled;return this.getResolvedStyleDrivenValue(this.doglegEnabled,t,h_)}getResolvedDoglegLength(){var e;const t=(e=this.getMLeaderStyle())==null?void 0:e.doglegLength;return this.getResolvedStyleDrivenValue(this.doglegLength,t,u_)}getResolvedTextColor(){var t;return this.getResolvedComponentColor(this.textColor,(t=this.getMLeaderStyle())==null?void 0:t.textColor,d_)}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)}};Rc.typeName="MLeader";let Qr=Rc;var Qg=(n=>(n[n.Top=0]="Top",n[n.Zero=1]="Zero",n[n.Bottom=2]="Bottom",n))(Qg||{}),Jg=(n=>(n[n.HasVertex=1]="HasVertex",n[n.Closed=2]="Closed",n[n.SuppressStartCaps=4]="SuppressStartCaps",n[n.SuppressEndCaps=8]="SuppressEndCaps",n))(Jg||{});const Nc=class Nc extends tt{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 _,this._normal=new A(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 j().setFromPoints(t)}subGetIntersectCurves(){const t=[],e=this.getMLineStyle(),i=this.getRenderableElementCount(e);if(i<=0)return $t(this.getReferencePath(),this.closed);for(let r=0;r<i;r++)t.push(...$t(this.getElementPath(r,e),this.closed));return 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 Qn(t,e,i),bt(t,r=>{this.updateReferencePathDirectionsAfterGripMove(r)}),this}subGetOsnapPoints(t,e,i,r){const s=[this._startPosition,...this._segments.map(o=>o.position)];if(s.length!==0)switch(t){case I.EndPoint:r.push(...s);break;case I.MidPoint:case I.Nearest:case I.Perpendicular:{const o=[];for(let a=0;a<s.length-1;a++){const c=[];Jn(s[a],s[a+1],t,e,c),o.push(...c)}if(t===I.MidPoint)r.push(...o);else{const a=ie(e,o);a&&r.push(a)}break}}}subWorldDraw(t){if(this._segments.length===0)return;const e=[],i=this.getMLineStyle(),r=this.getRenderableElementCount(i),s=t.subEntityTraits,o=s.color,a=s.lineType,c=s.fillType,l=s.drawOrder,h=this.createFillArea(i,r);if(h&&(s.color=o,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=o,s.lineType=a,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,o,a)}if(s.color=o,s.lineType=a,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,o=this._normal.y,a=this._normal.z;const c=[];let l=null,h=null,u=!1,d=!1,g=0,f=0;const p=()=>{h&&l&&l.elements.push(h),h=null,u=!1,d=!1,g=0,f=0},m=()=>{p(),l&&c.push(l),l=null};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const y=t.readItem();if(!y)break;const b=Number(y.code),w=Number(y.value);switch(b){case 2:this.styleName=String(y.value);break;case 340:this.styleObjectHandle=String(y.value);break;case 40:this.scale=w;break;case 70:this.justification=w;break;case 71:this.flags=w;break;case 72:break;case 73:this.styleCount=w;break;case 10:e=w;break;case 20:i=w;break;case 30:r=w;break;case 210:s=w;break;case 220:o=w;break;case 230:a=w;break;case 11:m(),l={position:new _(w,0,0),direction:new A(1,0,0),miterDirection:new A(0,1,0),elements:[]};break;case 21:l&&(l.position.y=w);break;case 31:l&&(l.position.z=w);break;case 12:l&&(l.direction.x=w);break;case 22:l&&(l.direction.y=w);break;case 32:l&&(l.direction.z=w);break;case 13:l&&(l.miterDirection.x=w);break;case 23:l&&(l.miterDirection.y=w);break;case 33:l&&(l.miterDirection.z=w);break;case 74:p(),g=w,u=!0,d=!1,h={parameterCount:w,parameters:[],fillCount:0,fillParameters:[]};break;case 41:h&&u&&(h.parameters.push(w),g>0&&h.parameters.length>=g&&(u=!1));break;case 75:h&&(f=w,h.fillCount=w,d=!0,u=!1);break;case 42:h&&d&&(h.fillParameters.push(w),f>0&&h.fillParameters.length>=f&&(d=!1));break}}return m(),this.startPosition=new _(e,i,r),this.normal=new A(s,o,a),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 o=r===0?this._startPosition:this._segments[r-1].position,a=new A().subVectors(s.position,o);a.lengthSq()>0&&s.direction.copy(a.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 _().copy(t.position),direction:new A().copy(t.direction),miterDirection:new A().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),o=t==="start"?this._startPosition:e.position,a=this.offsetPoint(o,e.miterDirection,s);if(!this.shouldApplyCapCutAtSide(t,r))return a;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 a;const h=t==="start"?this.getStartSegmentDirection():this.getEndSegmentDirection();return h.lengthSq()===0?a:a.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 o=t/s;return o}normalizeCapAngle(t){if(t==null||!Number.isFinite(t))return Math.PI/2;let e=t%180;return e<0&&(e+=180),(e<1||e>179)&&(e=90),e*Math.PI/180}getStartSegmentDirection(){const t=this._segments[0],e=new A;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 A;const e=new A,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),o=this.stripClosingPoint(r),a=this.stripClosingPoint(s);if(o.length<2||a.length<2)return;const c=new oe;if(this.closed){if(o.length<3||a.length<3)return;c.add(new it(o.map(l=>({x:l.x,y:l.y})),!0)),c.add(new it(a.map(l=>({x:l.x,y:l.y})),!0))}else{const l=[...o,...a.slice().reverse()].map(h=>({x:h.x,y:h.y}));if(l.length<3)return;c.add(new it(l,!0))}return c}getFillBoundaryElementIndices(t,e){let i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,s=-1,o=-1;for(let a=0;a<t;a++){const c=this.getElementReferenceOffset(a,e);c<i&&(i=c,s=a),c>r&&(r=c,o=a)}if(!(s<0||o<0||s===o))return{outerIndex:o,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 o=s.offset;o<i&&(i=o),o>r&&(r=o)}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,o){!i||r<2||(e.push(...this.drawMiterJointEntities(t,i,r,s,o)),e.push(...this.drawCapEntities(t,i,r,s,o)))}drawMiterJointEntities(t,e,i,r,s){if(this.closed||this._segments.length<2||(e.flags&2)===0)return[];const o=[],a=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(a,r,s,e,h[u].elementIndex),o.push(t.lines([h[u].point,h[u+1].point]))}return o}drawCapEntities(t,e,i,r,s){if(this.closed||this._segments.length<=0)return[];const o=[];return o.push(...this.drawCapEntitiesForSide(t,"start",e,i,r,s)),o.push(...this.drawCapEntitiesForSide(t,"end",e,i,r,s)),o}drawCapEntitiesForSide(t,e,i,r,s,o){if(e==="start"&&this.suppressStartCaps)return[];if(e==="end"&&this.suppressEndCaps)return[];const a=i.flags,c=e==="start",l=c?(a&16)!==0:(a&256)!==0,h=c?(a&64)!==0:(a&1024)!==0,u=c?(a&32)!==0:(a&512)!==0;if(!l&&!h&&!u)return[];const d=this.getCapElementPoints(e,r,i);if(d.length<2)return[];const g=[],f=t.subEntityTraits;if(l)for(let m=0;m<d.length-1;m++)this.applyElementDrawTraits(f,s,o,i,d[m].elementIndex),g.push(t.lines([d[m].point,d[m+1].point]));const p=c?this.getStartSegmentDirection().multiplyScalar(-1):this.getEndSegmentDirection().clone();if(h){const m=this.drawCapArcBetweenElements(t,e,d[0],d[d.length-1],p,f,s,o,i);m&&g.push(m)}if(u)for(let m=1;m<Math.floor(d.length/2);m++){const y=d[m],b=d[d.length-1-m];if(!y||!b||y===b)continue;const w=this.drawCapArcBetweenElements(t,e,y,b,p,f,s,o,i);w&&g.push(w)}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,o)=>({elementIndex:o,offset:this.getElementMiterOffset(r,o,i),point:this.getElementBoundaryPoint(t,r,o,i)})).sort((s,o)=>o.offset-s.offset):[]}drawCapArcBetweenElements(t,e,i,r,s,o,a,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 f=h.clone().add(new A().subVectors(u,h).multiplyScalar(.5)).add(s.clone().normalize().multiplyScalar(d/2)),p=Pt.createByThreePoints(h,u,f);if(p)return this.applyElementDrawTraits(o,a,c,l,e==="end"?r.elementIndex:i.elementIndex),t.circularArc(p)}applyElementDrawTraits(t,e,i,r,s){t.color=e,t.lineType=i,this.applyStyleElementTraits(r,s,t)}transformVector(t,e){const i=new _,r=new _(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[o,a]of t.entries()){const c=(a.styleName||o).toUpperCase();if(o.toUpperCase()===r||c===r)return a}}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=mt.toUpperCase(),s=ye.toUpperCase();let o="UserSpecified",a=e;if(i===r){o="ByLayer";const h=(l=this.database.tables.layerTable.getAt(this.layer))==null?void 0:l.linetype;a=h&&h.toUpperCase()!==r&&h.toUpperCase()!==s?h:$e}else i===s&&(o="ByBlock",a=$e);const c=this.database.tables.linetypeTable.getAt(a);return c?{type:o,...c.linetype}:{type:o,name:a,standardFlag:0,description:"",totalPatternLength:0}}resolveEffectiveProperties(){super.resolveEffectiveProperties(),this._styleName||(this._styleName=this.getDefaultStyleName())}getDefaultStyleName(){try{return this.database.cmlstyle||Oe}catch{return Oe}}};Nc.typeName="MLine";let Jr=Nc;function tf(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 pt(0);const s=new oe;s.add(new it(t,!0));const o=n.area(s);e.fillType=i,e.transparency=r;const a=n.lines(t);return o?a?n.group([o,a]):o:a}const rh=[208,207,17,224,161,177,26,225],ua=128,da=8,Co=3*da,dr=2;function ef(n){if(!n||n.length<ua)return;for(let l=0;l<rh.length;l++)if(n[ua+l]!==rh[l])return;const t=new DataView(n.buffer,n.byteOffset,n.byteLength),e=l=>{const h=t.getFloat64(l,!0),u=t.getFloat64(l+da,!0),d=t.getFloat64(l+2*da,!0);if([h,u,d].every(Number.isFinite))return{x:h,y:u,z:d}},i=e(dr),r=e(dr+Co),s=e(dr+2*Co),o=e(dr+3*Co);if(!i||!r||!s||!o)return;const a=Math.abs(s.x-i.x),c=Math.abs(i.y-s.y);if(!(a<=0||c<=0))return{upperLeft:i,upperRight:r,lowerRight:s,lowerLeft:o}}const Ri="image/wmf",Bn="image/emf",nf=2596720087;function yc(n){return n===Ri||n===Bn}function we(n){if(n.length<18)return!1;const t=new DataView(n.buffer,n.byteOffset,n.byteLength);return n.length>=40&&t.getUint32(0,!0)===nf?sh(n.subarray(22)):sh(n)}function ts(n){return sf(n)>=0}const g_=1574,f_=15,p_=1128680791;function rf(n){if(!we(n))return;const t=new DataView(n.buffer,n.byteOffset,n.byteLength);let e=0;if(t.getUint32(0,!0)===nf&&(e=22),e+18>n.length)return;const i=t.getUint16(e+2,!0);if(i<9)return;e+=i*2;const r=[];let s=0;for(;e+6<=n.length;){const c=t.getUint32(e,!0),l=c*2,h=t.getUint16(e+4,!0);if(c<3||l<6||e+l>n.length)break;if(h===g_&&e+44<=e+l&&t.getUint16(e+6,!0)===f_){const d=t.getUint32(e+10,!0),g=t.getUint32(e+32,!0),f=t.getUint32(e+40,!0),p=g>0&&g===f||g>0?g:f,m=e+44;d===p_&&p>0&&m+p<=e+l&&(r.push(n.subarray(m,m+p)),s+=p)}if(h===0)break;e+=l}if(r.length===0||s<88)return;const o=new Uint8Array(s);let a=0;for(const c of r)o.set(c,a),a+=c.length;if(oo(o,0))return o}function sf(n){const t=Math.min(n.length-44,4096);for(let e=0;e<=t;e++)if(oo(n,e))return e;return-1}function oo(n,t){if(t+88>n.length)return!1;const e=new DataView(n.buffer,n.byteOffset+t,n.length-t);if(e.getUint32(0,!0)!==1)return!1;const i=e.getUint32(4,!0);if(i<88||t+i>n.length||n[t+40]!==32||n[t+41]!==69||n[t+42]!==77||n[t+43]!==70)return!1;const r=e.getUint32(48,!0),s=e.getUint32(52,!0);return!(r<i||t+r>n.length||s<2||s>1e7)}function sh(n){if(n.length<18)return!1;const t=new DataView(n.buffer,n.byteOffset,n.byteLength),e=t.getUint16(0,!0),i=t.getUint16(2,!0),r=t.getUint16(4,!0),s=t.getUint32(6,!0);return!(e!==1&&e!==2||i<9||i>100||r!==256&&r!==768||(s<i||s*2>n.length+16)&&s<i)}const ga=[208,207,17,224,161,177,26,225],m_=2,of=3,y_=8,b_=14,Oo=128,__=64*1024*1024;function af(n){if(!(n!=null&&n.length))return;const t=x_(n);return t||kr(n)}function x_(n){const t=Ni(n,ga);if(t<0)return;const e=n.subarray(t);let i;try{i=M_(e)}catch{return}for(const s of i.entries()){if(s.type!=="stream"||!/olepres/i.test(s.name)&&!s.name.includes("OlePres"))continue;const o=i.readStream(s.name);if(!(o!=null&&o.length))continue;const a=w_(o);if(a)return a;const c=kr(o);if(c)return c}const r=["CONTENTS","Ole10Native","Ole10Native","Package"];for(const s of r){const o=i.readStream(s);if(!(o!=null&&o.length))continue;const a=kr(o);if(a)return a}for(const s of i.entries()){if(s.type!=="stream")continue;const o=i.readStream(s.name);if(!(o!=null&&o.length))continue;const a=kr(o);if(a)return a}}function w_(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){if(e+4>n.length)return;const c=t.getUint32(e,!0);e+=4+c}else 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 o=t.getUint32(e,!0);if(e+=4,o<=0||e+o>n.length)return;const a=n.subarray(e,e+o);return v_(a,r)}function v_(n,t){if(t===y_){const i=lf(n);if(i)return i}if(t===m_){const i=pa(n);if(i)return i}if(t===b_||t===of){const i=fa(n,t);if(i)return i}const e=fa(n);return e||pa(n)}function fa(n,t){let e=n;if(t===of&&n.length>30){const r=n.subarray(12);we(r)&&(e=r)}if(we(e)){const r=rf(e);if(r)return new Blob([ii(r)],{type:Bn})}const i=sf(n);if(i>=0&&oo(n,i)){const r=A_(n,i);if(r)return new Blob([ii(r)],{type:Bn});const o=new DataView(n.buffer,n.byteOffset+i,n.length-i).getUint32(48,!0);if(o>88&&i+o<=n.length)return new Blob([ii(n.subarray(i,i+o))],{type:Bn})}if(we(e)){const r=P_(e);return r?new Blob([ii(r)],{type:Ri}):new Blob([ii(e)],{type:Ri})}}function ii(n){const t=new Uint8Array(n.length);return t.set(n),t}function A_(n,t){if(!oo(n,t))return;const e=new DataView(n.buffer,n.byteOffset+t,n.length-t),i=e.getUint32(48,!0),r=e.getUint32(52,!0);let s=0;for(let o=0;o<r;o++){if(s+8>i)return;const a=e.getUint32(s,!0),c=e.getUint32(s+4,!0);if(c<8||s+c>i)return;if(s+=c,a===14)return n.subarray(t,t+s)}}function P_(n){let t=0;const e=new DataView(n.buffer,n.byteOffset,n.byteLength);if(n.length>=40&&e.getUint32(0,!0)===2596720087&&(t=22),!we(n.subarray(t)))return;const i=new DataView(n.buffer,n.byteOffset+t,n.length-t),r=i.getUint16(2,!0),s=i.getUint32(6,!0),o=t+s*2;if(o>n.length)return;let a=t+r*2;const c=o;let l=0;for(;a+6<=c&&l<5e5;){const h=e.getUint32(a,!0),u=e.getUint16(a+4,!0);if(h<3||a+h*2>c)return;if(a+=h*2,l++,u===0)return n.subarray(0,a)}}function kr(n){const t=pa(n);if(t)return t;if(ts(n)||we(n))return fa(n)}function pa(n){const t=S_(n);if(t)return t;const e=k_(n);if(e)return e;const i=E_(n);if(i)return i;const r=I_(n);if(r)return r;const s=T_(n);if(s)return s}function S_(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 k_(n){const e=Ni(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 E_(n){const t=Ni(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 I_(n){const t=Ni(n,[71,73,70,56,55,97]),e=Ni(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 T_(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),o=e.getUint16(12,!0),a=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||o!==1||![1,4,8,16,24,32].includes(a)||c!==0&&c!==3)continue;const u=cf(i,a,c,h),d=Math.abs(s),g=r*a+31>>5<<2,f=l>0?l:g*d,p=u+f;if(!(p<=40||t+p>n.length))return lf(n.subarray(t,t+p))}}function cf(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 lf(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+L_(n),!0);const o=new Uint8Array(i);return o.set(r,0),o.set(n,14),new Blob([o],{type:"image/bmp"})}function L_(n){const t=new DataView(n.buffer,n.byteOffset,n.byteLength),e=t.getUint32(0,!0);if(e===12){const o=t.getUint16(10,!0),a=o<=8?1<<o:0;return e+a*3}const i=t.getUint16(14,!0),r=t.getUint32(16,!0),s=t.getUint32(32,!0);return cf(e,i,r,s)}function Ni(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 M_(n){if(n.length<512)throw new Error("CFB too small");for(let P=0;P<ga.length;P++)if(n[P]!==ga[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),o=t.getUint32(56,!0),a=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 v=t.getUint32(76+P*4,!0);v<=4294967290&&u.push(v)}let d=l;for(let P=0;P<h&&d<=4294967290;P++){const v=(d+1)*i;if(v+i>n.length)break;const k=i/4-1;for(let E=0;E<k;E++){const O=t.getUint32(v+E*4,!0);O<=4294967290&&u.push(O)}d=t.getUint32(v+k*4,!0)}const g=[];for(let P=0;P<Math.min(r,u.length);P++){const k=(u[P]+1)*i;if(k+i>n.length)break;const E=i/4;for(let O=0;O<E;O++)g.push(t.getUint32(k+O*4,!0))}const f=gr(g,s,4096),p=fr(n,f,i),m=[],y=Math.floor(p.length/Oo);for(let P=0;P<y;P++){const v=P*Oo,k=new DataView(p.buffer,p.byteOffset+v,Oo),E=k.getUint16(64,!0);if(E<2||E>64)continue;const O=Math.floor((E-2)/2);let N="";for(let q=0;q<O;q++)N+=String.fromCharCode(k.getUint16(q*2,!0));const R=k.getUint8(66),nt=k.getUint32(116,!0),et=k.getUint32(120,!0),G=k.getUint32(124,!0),rt=G===0?et:et+G*4294967296;let L="unknown";R===5?L="root":R===1?L="storage":R===2&&(L="stream"),m.push({name:N,type:L,size:rt,startSector:nt})}const b=m.find(P=>P.type==="root"),w=[];if(c>0&&a<=4294967290){const P=gr(g,a,c),v=fr(n,P,i),k=new DataView(v.buffer,v.byteOffset,v.byteLength);for(let E=0;E+4<=v.length;E+=4)w.push(k.getUint32(E,!0))}let x;if(b&&b.size>0){const P=gr(g,b.startSector,65536);x=fr(n,P,i).subarray(0,b.size)}return{entries:()=>m,readStream:P=>{const v=m.find(E=>E.type==="stream"&&(E.name===P||E.name.toLowerCase()===P.toLowerCase()));if(!v||v.size<=0||v.size>__)return;if(v.size<o&&x&&w.length>0){const O=hf(w,v.startSector,65536),N=new Uint8Array(v.size);let R=0;for(const nt of O){if(R>=v.size)break;const et=nt*64,G=Math.min(et+64,x.length);if(et>=x.length)break;const rt=x.subarray(et,G);N.set(rt.subarray(0,Math.min(rt.length,v.size-R)),R),R+=rt.length}return N.subarray(0,Math.min(R,v.size))}const k=gr(g,v.startSector,65536);return fr(n,k,i).subarray(0,v.size)}}}function gr(n,t,e){return hf(n,t,e)}function hf(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 fr(n,t,e){const i=new Uint8Array(t.length*e);let r=0;for(const s of t){const o=(s+1)*e,a=Math.min(o+e,n.length);if(o>=n.length)break;i.set(n.subarray(o,a),r),r+=e}return i}const Bc=class Bc extends tt{};Bc.typeName="Frame";let es=Bc;const Fc=class Fc extends es{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 j}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,qs(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,Gi(e))};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const s=t.readItem();if(!s)break;const o=Number(s.code),a=Number(s.value);switch(o){case 1:break;case 70:this.oleVersion=a;break;case 90:i=a;break;case 310:s.value instanceof Uint8Array?e.push(s.value):e.push(String(s.value));break}}return r(),this}};Fc.typeName="OleFrame";let Bi=Fc;var uf=(n=>(n[n.Link=1]="Link",n[n.Embedded=2]="Embedded",n[n.Static=3]="Static",n))(uf||{}),df=(n=>(n[n.ModelSpace=0]="ModelSpace",n[n.PaperSpace=1]="PaperSpace",n))(df||{});const Dc=class Dc extends Bi{constructor(){super(),this._upperLeft=new _,this._lowerRight=new _,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 j().setFromPoints(this.boundaryPath())}subGetIntersectCurves(){return $t(this.boundaryPath().slice(0,4),!0)}subGetGripPoints(){return this.boundaryPath().slice(0,4)}subMoveGripPointsAt(t,e){const i=this.boundaryPath().slice(0,4);return Qn(t,e,i),bt(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===I.Insertion){r.push(this._upperLeft.clone());return}const s=this.boundaryPath().slice(0,4);if(t===I.EndPoint){r.push(...s);return}Ks(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),o=this._upperLeft.clone(),a=o.clone().add(new A(e*r,e*s,0)),c=o.clone().add(new A(i*s,-i*r,0));o.applyMatrix4(t),a.applyMatrix4(t),c.applyMatrix4(t);const l=new A().subVectors(a,o),h=new A().subVectors(c,o);return this._upperLeft.copy(o),this._rotation=Math.atan2(l.y,l.x),this._lowerRight.set(o.x+l.length(),o.y-h.length(),o.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}):tf(t,this.boundaryPath())}onOleObjectChanged(){this._image=void 0,this._imageResolved=!1,this.applyGeometryFromOleObjectData()}applyGeometryFromOleObjectData(){const t=ef(this.oleObjectData);t&&(this._upperLeft.copy(t.upperLeft),this._lowerRight.copy(t.lowerRight))}resolveImage(){return this._imageResolved?this._image:(this._imageResolved=!0,this._image=af(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){tt.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,qs(r)),i+=127}}return t.writeString(1,"OLE"),this}dxfInFields(t){tt.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,o=this._lowerRight.y,a=this._lowerRight.z;const c=[];let l;const h=()=>{this.upperLeftCorner=new _(e,i,r),this.lowerRightCorner=new _(s,o,a),c.length>0&&this.loadOleObjectFromDxf(l,Gi(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:o=g;break;case 31:a=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 _(this._lowerRight.x,this._upperLeft.y,this._upperLeft.z)}cornerLowerLeft(){return new _(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)}};Dc.typeName="Ole2Frame";let ns=Dc;const Xc=class Xc extends tt{constructor(){super(),this._thickness=0,this._normal=new A(0,0,1),this._ecsRotation=0,this._geo=new _}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 j().expandByPoint(this._geo)}subGetGripPoints(){return[this._geo]}subMoveGripPointsAt(t,e){return Se(t,e,this._geo),this}subGetOsnapPoints(t,e,i,r){t===I.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}get directBatchPrimitive(){var e;return(((e=this.database)==null?void 0:e.pdmode)??0)===0?"point":null}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,jt(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,o=this.ecsRotation*180/Math.PI,a=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:o=g;break;case 210:a=g;break;case 220:c=g;break;case 230:l=g;break}}const h=new A(a,c,l);return h.lengthSq()>0&&this.normal.copy(h.normalize()),this.thickness=s,this.ecsRotation=o*Math.PI/180,this.position=At({x:e,y:i,z:r},this.normal),this}};Xc.typeName="Point";let is=Xc;const Yc=class Yc extends tt{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 _(e.x,e.y,e.z))}get geometricExtents(){const t=this._proxyGraphic;if(!(t!=null&&t.length))return new j;const i=new ra(t,{database:this.database,defaultLayer:this.layer}).scanExtents();if(i){const r=new j().setFromPoints(i);return this._worldTransform.equals(new D)||r.applyMatrix4(this._worldTransform),r}return new j}subGetGripPoints(){if(this._entityOrigins.length>0)return[...this._entityOrigins];const t=this.geometricExtents;return t.isEmpty()?[]:[new _(t.min.x,t.min.y,t.min.z),new _(t.max.x,t.max.y,t.max.z)]}subMoveGripPointsAt(t,e){return this._entityOrigins.length>0?(Qn(t,e,this._entityOrigins),this):this.geometricExtents.isEmpty()?this:(bt(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 ra(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,qs(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),o=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=o;break;case 90:this.proxyEntityClassId=o;break;case 91:this.applicationEntityClassId=o;break;case 95:this.objectDrawingFormat=o;break;case 160:i=o;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=a1(t,e);i&&this.setProxyGraphic(i)}};Yc.typeName="ProxyEntity";let rs=Yc;var gf=(n=>(n[n.Invalid=0]="Invalid",n[n.Rect=1]="Rect",n[n.Poly=2]="Poly",n))(gf||{}),ff=(n=>(n[n.Show=1]="Show",n[n.ShowUnAligned=2]="ShowUnAligned",n[n.Clip=4]="Clip",n[n.Transparent=8]="Transparent",n))(ff||{});const zc=class zc extends tt{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 _,this._scale=new ht(1,1),this._rotation=0,this._imageSize=new M,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 j;return t.min.copy(this._position),t.max.set(this._position.x+this._width,this._position.y+this._height,0),t}subGetIntersectCurves(){return $t(this.boundaryPath(),!0)}subGetGripPoints(){return this.boundaryPath()}subMoveGripPointsAt(t,e){return bt(t,i=>{this.isClipped&&this._clipBoundary.length>3?this.moveClippedBoundaryGripAt(i,e):this.moveUnclippedGripAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){if(t===I.Insertion){r.push(this._position);return}const s=this.boundaryPath();if(s.length===0)return;let o=s;if(s.length>1){const a=s[0],c=s[s.length-1];a.x===c.x&&a.y===c.y&&(a.z||0)===(c.z||0)&&(o=s.slice(0,-1))}if(t===I.EndPoint){r.push(...o);return}Ks(o,!0,t,e,r)}subWorldDraw(t){const e=this.boundaryPath();return this._image&&this.isImageShown?t.image(this._image,{boundary:e,roation:this._rotation}):tf(t,e)}transformBy(t){const e=this._width*this._scale.x,i=this._height*this._scale.y,r=new A(e*Math.cos(this._rotation),e*Math.sin(this._rotation),0),s=new A(-i*Math.sin(this._rotation),i*Math.cos(this._rotation),0),o=this._position.clone(),a=this._position.clone().add(r),c=this._position.clone().add(s);o.applyMatrix4(t),a.applyMatrix4(t),c.applyMatrix4(t);const l=new A(a).sub(o),h=new A(c).sub(o);return this._position.copy(o),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,o=this._height;switch(t){case 0:this._position.add(e);break;case 1:{const a=i,c=r+o,l=i+s+e.x,h=r+e.y;this._position.x=a,this._position.y=h,this._width=l-a,this._height=c-h;break}case 2:{const a=i+s+e.x,c=r+o+e.y;this._width=a-i,this._height=c-r;break}case 3:{const a=i+s,c=r,l=i+e.x,h=r+o+e.y;this._position.x=l,this._position.y=c,this._width=a-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 kt;s.setFromPoints(this._clipBoundary);const o=new M;o.setX(this._position.x-s.min.x*i),o.setY(this._position.y-s.min.y*r);const a=this._clipBoundary[t],c=a.x*i+o.x+e.x,l=a.y*r+o.y+e.y;a.x=(c-o.x)/i,a.y=(l-o.y)/r}boundaryPath(){const t=[];if(this.isClipped&&this._clipBoundary.length>3){const e=this._width,i=this._height,r=new kt;r.setFromPoints(this._clipBoundary);const s=new M;s.setX(this._position.x-r.min.x*e),s.setY(this._position.y-r.min.y*i),this._clipBoundary.forEach(o=>{const a=o.x*e+s.x,c=o.y*i+s.y;t.push(new _(a,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){oh.copy(t[1]);for(let e=1;e<4;e++)pr.copy(t[e]),pr.rotateAround(oh,this._rotation),t[e].setX(pr.x),t[e].setY(pr.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,o=r.y>0?i/r.y:i,a=Math.cos(this._rotation),c=Math.sin(this._rotation);t.writePoint3d(11,{x:s*a,y:s*c,z:0}),t.writePoint3d(12,{x:-o*c,y:o*a,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,o=0,a=0,c=0,l=1,h=0,u=this.imageSize.x,d=this.imageSize.y;const g=[];let f=null;const p=()=>{f&&(g.push(new M(f.x,f.y)),f=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const m=t.readItem();if(!m)break;const y=Number(m.code),b=Number(m.value);switch(y){case 10:e=b;break;case 20:i=b;break;case 30:r=b;break;case 11:s=b;break;case 21:o=b;break;case 31:a=b;break;case 12:c=b;break;case 22:l=b;break;case 32:h=b;break;case 13:u=b;break;case 23:d=b;break;case 14:p(),f={x:b,y:0};break;case 24:f&&(f.y=b);break;case 70:{this.isImageShown=(b&3)!==0,this.isShownClipped=(b&4)!==0,this.isImageTransparent=(b&8)!==0;break}case 71:this.clipBoundaryType=b;break;case 90:this.classVersion=b;break;case 91:break;case 280:this.isClipped=b!==0;break;case 281:this.brightness=b;break;case 282:this.contrast=b;break;case 283:this.fade=b;break;case 290:this.clipMode=b;break;case 340:this.imageDefId=String(m.value);break}}return p(),this.applyRasterImageDxfIn(e,i,r,s,o,a,c,l,h,u,d,g),this}applyRasterImageDxfIn(t,e,i,r,s,o,a,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,o),f=Math.hypot(a,c,l);this.width=g*(h||1),this.height=f*(u||1),this.rotation=Math.atan2(s,r),d.length>0&&(this.clipBoundary=d)}};zc.typeName="RasterImage";let Fi=zc;const oh=new M,pr=new M,Rs=class Rs extends It{get dxfTypeName(){return"RAY"}constructor(){super(),this._basePoint=new _,this._unitDir=new A}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 j;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetIntersectCurves(){const t=this._basePoint.clone().add(this._unitDir);return[{kind:"line",line:new Dt(this._basePoint,t),extent:"ray"}]}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 Se(t,e,this.basePoint),this}subGetOsnapPoints(t,e,i,r){const s=this.basePoint;if(t===I.EndPoint){r.push(s);return}const o=this.unitDir.clone();if(o.lengthSq()===0)return;o.normalize();const a=new Dt(s,s.clone().add(o));switch(t){case I.Nearest:{const c=a.project(e),h=new A(c).sub(s).dot(o);r.push(h<0?s:c);break}case I.Perpendicular:r.push(a.perpPoint(e));break}}transformBy(t){return this._basePoint.applyMatrix4(t),this._unitDir.transformDirection(t),this}get directBatchPrimitive(){return"lineStrip"}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,o=this.unitDir.y,a=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:o=h;break;case 31:a=h;break}}return this.basePoint=new _(e,i,r),this.unitDir=new A(s,o,a),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=mu(this.basePoint,this.unitDir,t);if(!e)return null;const i=new Rs;return i.basePoint=e,i.unitDir=this.unitDir.clone(),i}};Rs.typeName="Ray";let ss=Rs;const Vc=class Vc extends tt{get dxfTypeName(){return"SHAPE"}constructor(){super(),this._position=new _,this._size=1,this._name="",this._rotation=0,this._widthFactor=1,this._oblique=0,this._thickness=0,this._normal=new A(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 j;return e.expandByPoint(this._position),t>0&&(e.expandByPoint(new _(this._position.x-t,this._position.y-t,this._position.z)),e.expandByPoint(new _(this._position.x+t,this._position.y+t,this._position.z))),e}subGetGripPoints(){return[this._position]}subMoveGripPointsAt(t,e){return Se(t,e,this._position),this}subGetOsnapPoints(t,e,i,r){t===I.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(),o=new _(this._widthFactor,0,0).applyMatrix4(r).add(s),a=new _(0,1,0).applyMatrix4(r).add(s),c=new _(0,0,1).applyMatrix4(r).add(s);s.applyMatrix4(t),o.applyMatrix4(t),a.applyMatrix4(t),c.applyMatrix4(t);const l=new A(o).sub(s),h=new A(a).sub(s),u=new A(c).sub(s);let d=new A().crossVectors(l,h);d.lengthSq()===0?d=this._normal.clone().transformDirection(t):d.normalize();const f=new D().setFromExtrusionDirection(d).clone().invert(),p=l.clone().applyMatrix4(f),m=h.length(),y=l.length();this._position.copy(s),this._normal.copy(d),y>0&&(this._rotation=Math.atan2(p.y,p.x)),m>0&&(this._size*=m,y>0&&(this._widthFactor*=y/m));const b=u.length();return b>0&&(this._thickness*=b),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,o=this.normal.y,a=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:o=h;break;case 230:a=h;break}}return this.position={x:e,y:i,z:r},this.normal={x:s,y:o,z:a},this}};Vc.typeName="Shape";let os=Vc;const Ln=class Ln extends It{constructor(){super(),this._normal=new A(0,0,1),this._elevation=0,this._thickness=0,this._vertices=[new _,new _,new _,new _]}get dxfTypeName(){return"TRACE"}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get closed(){return!0}get area(){return new it(Ln.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 j().setFromPoints(this._vertices)}subGetIntersectCurves(){const t=this._vertices[0],e=this._vertices[1],i=this._vertices[2],r=this._vertices[3];return $t([t,e,r,i],!0)}subGetGripPoints(){const t=new Array;return t.push(...this._vertices),t}subMoveGripPointsAt(t,e){return Qn(t,e,this._vertices),this}subGetOsnapPoints(t,e,i,r){const s=[this._vertices[0],this._vertices[1],this._vertices[3],this._vertices[2]];Ks(s,!0,t,e,r)}transformBy(t){return this._vertices.forEach(e=>e.applyMatrix4(t)),this._elevation=this._vertices[0].z,this}get directBatchPrimitive(){return"area"}subWorldDraw(t){const e=new it(Ln.boundaryPointsFromVertices(this._vertices),!0),i=new oe;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,jt(this.getPointAt(0),this.normal)),t.writePoint3d(11,jt(this.getPointAt(1),this.normal)),t.writePoint3d(12,jt(this.getPointAt(2),this.normal)),t.writePoint3d(13,jt(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 a=t.readItem();if(!a)break;const c=Number(a.code),l=Number(a.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 o=new A(i,r,s);return o.lengthSq()>0&&this.normal.copy(o.normalize()),e.forEach((a,c)=>this.setPointAt(c,At(a,this.normal))),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectBoundary2d();return e.length<2?1:Rt.from2dPoints(e,!0).getOffsetSideAtPoint(t)}createOffsetCurve(t){return so(this.collectBoundary2d(),!0,t)}collectBoundary2d(){return Ln.boundaryPointsFromVertices(this._vertices)}static boundaryPointsFromVertices(t){const e=t[0],i=t[1],r=t[2],s=t[3];return[new M(e.x,e.y),new M(i.x,i.y),new M(s.x,s.y),new M(r.x,r.y)]}};Ln.typeName="Trace";let Di=Ln;const jc=class jc extends Di{get dxfTypeName(){return"SOLID"}};jc.typeName="Solid";let as=jc;function C_(n){return n&2048?"SqrtChord":n&1024?"Chord":"Uniform"}function ah(n,t){try{return new Xi(n.controlPoints,n.knots,O_(n.weights,n.controlPoints.length),n.degree,t)}catch{return null}}function O_(n,t){if(!(!n||n.length!==t))return n}const Mn=class Mn extends It{constructor(t,e,i,r,s){super(),this._knotTolerance=1e-6,this._controlTolerance=1e-6,this._fitTolerance=1e-9,this._normal=new A(0,0,1),this.rebuild(t,e,i,r,s)}get dxfTypeName(){return"SPLINE"}static fromControlPoints(t,e,i,r,s){const o=Ut.fromControlPoints(t,e,i,r,s);return o?ah(o,s):null}static fromFitPoints(t,e,i,r,s,o){const a=Ut.fromFitPoints(t,e,i,r,s,o);return a?ah(a,r):null}static fromDwgSpline(t){const e=!!(t.flag&1),i=C_(t.flag);if(t.numberOfControlPoints>0&&t.numberOfKnots>0){const r=Mn.fromControlPoints(t.controlPoints,t.knots,t.weights,t.degree,e);if(r)return r}return t.numberOfFitPoints>0?Mn.fromFitPoints(t.fitPoints,i,t.degree,e,t.startTangent,t.endTangent):null}rebuild(t,e,i,r,s){const o=+(t!==void 0)+ +(e!==void 0)+ +(i!==void 0)+ +(r!==void 0)+ +(s!==void 0);if(o<2||o>5)throw Ot.ILLEGAL_PARAMETERS;!Array.isArray(e)?this._geo=new Ut(t,e,i,r):this._geo=new Ut(t,e,i,r,s)}get geometricExtents(){return this._geo.box}subGetIntersectCurves(){return[{kind:"spline",spline:this._geo.clone(),extendable:!1}]}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 I.EndPoint:r.push(this._geo.startPoint),r.push(this._geo.endPoint);break;case I.Node:{const s=new Set;for(const o of this._geo.knots)s.has(o)||(s.add(o),r.push(this._geo.evaluateAt(o)));break}case I.Nearest:r.push(this._geo.nearestPoint(e));break}}transformBy(t){return this._geo.transform(t),this}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){const e=this._geo.tessellate(qi(t));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,o=0;const a=[],c=[],l=[],h=[];let u=null,d=null,g=this.knotTolerance,f=this.controlTolerance,p=this.fitTolerance,m=this.normal.x,y=this.normal.y,b=this.normal.z,w=null,x=null,S=null,P=null;const v=()=>{w&&(l.push(w),w=null)},k=()=>{x&&(h.push(x),x=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const O=t.readItem();if(!O)break;const N=Number(O.code),R=Number(O.value);switch(N){case 70:e=R;break;case 71:i=R;break;case 72:r=R;break;case 73:s=R;break;case 74:o=R;break;case 42:g=R;break;case 43:f=R;break;case 44:p=R;break;case 40:a.push(R);break;case 41:c.push(R);break;case 10:v(),w={x:R,y:0,z:0};break;case 20:w&&(w.y=R);break;case 30:w&&(w.z=R);break;case 11:k(),x={x:R,y:0,z:0};break;case 21:x&&(x.y=R);break;case 31:x&&(x.z=R);break;case 12:S={x:R,y:0,z:0};break;case 22:S&&(S.y=R);break;case 32:S&&(S.z=R,u=S,S=null);break;case 13:P={x:R,y:0,z:0};break;case 23:P&&(P.y=R);break;case 33:P&&(P.z=R,d=P,P=null);break;case 210:m=R;break;case 220:y=R;break;case 230:b=R;break}}v(),k(),this.knotTolerance=g,this.controlTolerance=f,this.fitTolerance=p;const E=new A(m,y,b);return E.lengthSq()>0&&this.normal.copy(E.normalize()),this.applyDxfInSpline({flag:e,degree:i,numberOfControlPoints:s||l.length,numberOfKnots:r||a.length,numberOfFitPoints:o||h.length,controlPoints:l,knots:a,weights:c.length>0?c:void 0,fitPoints:h,startTangent:u,endTangent:d}),this}applyDxfInSpline(t){const e=Mn.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:Rt.from2dPoints(e,this.closed).getOffsetSideAtPoint(t)}createOffsetCurve(t){const{points:e,tangents:i}=this._geo.getOffsetSamplePath2d(t),r=Z0(e,this.closed,t,i);return r?Rt.fromGePolyline(r):null}collectPath2d(t){return this._geo.getOffsetSamplePath2d(t).points}};Mn.typeName="Spline";let Xi=Mn;function R_(n){return n==null?St.latest.capabilities:typeof n=="object"&&"supportsHandles"in n?n:n instanceof St?n.capabilities:new St(n).capabilities}const N_=new A,Uc=class Uc extends xe{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 blockTableRecord(){const t=this.blockName;if(t){const i=this.database.tables.blockTable.getAt(t);if(i)return i}const e=this.owningBlockRecordId;if(e)return this.database.tables.blockTable.getIdAt(e)}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 a=new j;for(const c of t.newIterator())a.union(c.geometricExtents);return a.applyMatrix4(this.blockTransform),a}const e=this._columnWidth.reduce((a,c)=>a+c,0),i=this._rowHeight.reduce((a,c)=>a+c,0),r=new j;if(e===0&&i===0)return r.expandByPoint(this.position),r;const s=new Dn;s.setFromAxisAngle(A.Z_AXIS,this.rotation),_n.compose(this.position,s,this.scaleFactors);const o=[new _(0,0,0),new _(e,0,0),new _(e,-i,0),new _(0,-i,0)];for(const a of o)r.expandByPoint(a.applyMatrix4(_n));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),o=new Float32Array((this.numColumns+1)*(this.numRows+1)*3);let a=0;for(let g=0;g<=this.numRows;g++){i-=g>0?this.rowHeight(g-1):0,r=0;for(let f=0;f<=this.numColumns;f++)r+=f>0?this.columnWidth(f-1):0,o[a++]=r,o[a++]=i,o[a++]=0}const c=[],l=new Array(this.numRows*this.numColumns).fill(!1);r=0,a=0;let h=0;for(let g=0;g<this.numColumns;g++){r+=g>0?this.columnWidth(g-1):0,i=0;for(let f=0;f<this.numRows;f++){i+=f>0?this.rowHeight(f-1):0;const p=this.cell(f*this.numColumns+g);if(h=f*this.numColumns+g,p&&!l[h]){const m=p.borderWidth??1,y=p.borderHeight??1;this.fillVisited(l,h,this.numColumns,m,y),s[a++]=g+f*(this.numColumns+1),s[a++]=g+f*(this.numColumns+1)+m;const b=o[s[a-1]*3]-r,w=g+(f+y)*(this.numColumns+1)+m;g+m==this.numColumns&&(s[a++]=g+f*(this.numColumns+1)+m,s[a++]=w);const x=-o[w*3+1]-i;if(f+y==this.numRows&&(s[a++]=g+(f+y)*(this.numColumns+1)+y,s[a++]=g+(f+y)*(this.numColumns+1)),s[a++]=g+(f+y)*(this.numColumns+1),s[a++]=g+f*(this.numColumns+1),p.text){const S=p.attachmentPoint||this.attachmentPoint||exports.AcGiMTextAttachmentPoint.MiddleCenter,P=this.getTableTextOffset(S,b,x),v={text:p.text,height:this.getCellTextHeight(p,x),width:b,position:N_.set(r,-i,0).clone().add(P),rotation:this.rotation,attachmentPoint:S},k=this.getTextStyle(p);c.push(t.mtext(v,k))}}}}c.push(t.lineSegments(o,3,s));const u=t.group(c),d=new Dn;return d.setFromAxisAngle(A.Z_AXIS,this.rotation),_n.compose(this.position,d,this.scaleFactors),u.applyMatrix(_n),u}drawAnonymousTableBlock(t,e){const i=[],r=e.newIterator();for(const a of r){let c;if(a.color.isByBlock){ch.copy(a.color);const l=this.resolvedColor;l.isForeground?a.color.setForeground():l.RGB!=null&&a.color.setRGBValue(l.RGB),c=a.worldDraw(t),a.color.copy(ch)}else c=a.worldDraw(t);c&&(c.objectId=this.objectId,c.ownerId=this.ownerId,c.layerName=this.layer,c.visible=this.visibility&&a.visibility,i.push(c))}const s=t.group(i);s.applyMatrix(this.blockTransform);const o=this.normal;return o&&(o.x!==0||o.y!==0||o.z!==1)&&(_n.setFromExtrusionDirection(o),s.applyMatrix(_n)),s}fillVisited(t,e,i,r,s){if(s==1&&r==1)t[e]=!0;else for(let o=0;o<r;++o)for(let a=0;a<s;++a)t[e+o+a*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 A;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,o,a,c,l,h,u;super.dxfOutFields(t),t.writeSubclassMarker("AcDbTable");const e=t.version??((s=t.database)==null?void 0:s.version)??((o=this.database)==null?void 0:o.version),i=R_(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],f=(g==null?void 0:g.cellType)??(g!=null&&g.blockTableRecordId?2:1);if(t.writeInt16(171,f),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),f===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(f===2){if(t.writeObjectId(340,g==null?void 0:g.blockTableRecordId),t.writeDouble(144,g==null?void 0:g.blockScale),t.writeInt16(179,g==null?void 0:g.blockAttrNum),(a=g==null?void 0:g.attrDefineId)!=null&&a.length)for(const p of g.attrDefineId)t.writeObjectId(331,p);if((g==null?void 0:g.attrText)!=null)if(Array.isArray(g.attrText))for(const p of g.attrText)t.writeString(300,p);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 f=d.borderVisibility;f&&(t.writeInt16(284,f.top?1:0),t.writeInt16(285,f.right?1:0),t.writeInt16(286,f.bottom?1:0),t.writeInt16(287,f.left?1:0),t.writeInt16(288,f.insideHorizontal?1:0),t.writeInt16(289,f.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 p,m,y;super.dxfInFields(t),t.atSubclassData("AcDbTable");let e=this._numRows,i=this._numColumns,r=!1;const s=[],o=[];let a=0,c=null,l=[],h=((p=this.horizontalDirection)==null?void 0:p.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)},f=()=>{c&&(l.length>0&&(c.text=l.join(""),l=[]),g(),a<this._cells.length&&this.setCell(a,c),a+=1,c=null)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const b=t.readItem();if(!b)break;const w=Number(b.code),x=Number(b.value);switch(w){case 280:c||(this.tableDataVersion=x);break;case 342:this.tableStyleId=String(b.value);break;case 343:this.owningBlockRecordId=String(b.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:o.push(x);break;case 171:f(),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=!!b.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(b.value));break;case 300:if(c){const S=c.attrText;Array.isArray(S)?S.push(String(b.value)):S!=null&&S!==""?c.attrText=[String(S),String(b.value)]:c.attrText=String(b.value)}break;case 301:c&&(c.cellValueBlockBegin=String(b.value));break;case 304:break;case 7:c&&(c.textStyle=String(b.value));break;case 140:c&&(c.textHeight=x);break;case 340:c&&(c.blockTableRecordId=String(b.value));break;case 344:case 345:c&&(c.fieldObjetId=String(b.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 f(),this.horizontalDirection=new A(h,u,d),s.forEach((b,w)=>this.setRowHeight(w,b)),o.forEach((b,w)=>this.setColumnWidth(w,b)),this}writeCellText(t,e,i,r){if(!i){if(e.length<=250){t.writeString(1,e);return}const a=Math.ceil(e.length/250);for(let c=0;c<a;c++){const l=c*250,h=l+250,u=e.slice(l,h);c===a-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 o=Math.ceil(e.length/250);for(let a=0;a<o;a++){const c=a*250,l=c+250,h=e.slice(c,l);a===o-1?t.writeString(302,h):t.writeString(303,h)}t.writeString(304,"ACVALUE_END")}};Uc.typeName="Table";let cs=Uc;const _n=new D,ch=new U,Gc=class Gc extends tt{constructor(){super(),this._snapBase=new _,this._snapSpacing=new _(1,1,0),this._gridSpacing=new _(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 _,this._ucsXAxis=new A(1,0,0),this._ucsYAxis=new A(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 _,this._height=0,this._width=0,this._viewCenter=new _,this._viewTarget=new _,this._viewDirection=new A(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 j;return i.expandByPoint(new _(this._centerPoint.x-t,this._centerPoint.y-e,this._centerPoint.z)),i.expandByPoint(new _(this._centerPoint.x+t,this._centerPoint.y+e,this._centerPoint.z)),i}subGetIntersectCurves(){const t=this._width/2,e=this._height/2,i=this._centerPoint.z,r=[new _(this._centerPoint.x-t,this._centerPoint.y-e,i),new _(this._centerPoint.x+t,this._centerPoint.y-e,i),new _(this._centerPoint.x+t,this._centerPoint.y+e,i),new _(this._centerPoint.x-t,this._centerPoint.y+e,i)];return $t(r,!0)}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 _(this._centerPoint.x-e,this._centerPoint.y-i,r),new _(this._centerPoint.x+e,this._centerPoint.y-i,r),new _(this._centerPoint.x+e,this._centerPoint.y+i,r),new _(this._centerPoint.x-e,this._centerPoint.y+i,r)),t}subMoveGripPointsAt(t,e){return bt(t,i=>{this.moveGripAt(i,e)}),this}transformBy(t){const e=this._centerPoint.clone(),i=this._centerPoint.clone().add(new A(this._width,0,0)),r=this._centerPoint.clone().add(new A(0,this._height,0));e.applyMatrix4(t),i.applyMatrix4(t),r.applyMatrix4(t);const s=new A(i).sub(e),o=new A(r).sub(e),a=this._height!==0?o.length()/this._height:1;return this._centerPoint.copy(e),this._width=s.length(),this._height=o.length(),this._viewHeight*=a,this}subWorldDraw(t){if(this._number>1&&this.ownerId!=this.database.tables.blockTable.modelSpace.objectId){const e=this.toGiViewport();return t.group(this.createViewportRect(e,t))}}toGiViewport(){const t=new $u;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 _(t.centerPoint.x-t.width/2,t.centerPoint.y-t.height/2,0),new _(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0)])),i.push(e.lines([new _(t.centerPoint.x+t.width/2,t.centerPoint.y-t.height/2,0),new _(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0)])),i.push(e.lines([new _(t.centerPoint.x+t.width/2,t.centerPoint.y+t.height/2,0),new _(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0)])),i.push(e.lines([new _(t.centerPoint.x-t.width/2,t.centerPoint.y+t.height/2,0),new _(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,o=this.viewCenter.y,a=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,f=this.snapBase.x,p=this.snapBase.y,m=this.snapBase.z,y=this.snapSpacing.x,b=this.snapSpacing.y,w=this.snapSpacing.z,x=this.gridSpacing.x,S=this.gridSpacing.y,P=this.gridSpacing.z,v=this.ucsOrigin.x,k=this.ucsOrigin.y,E=this.ucsOrigin.z,O=this.ucsXAxis.x,N=this.ucsXAxis.y,R=this.ucsXAxis.z,nt=this.ucsYAxis.x,et=this.ucsYAxis.y,G=this.ucsYAxis.z;const rt=[],L=[];for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const q=t.readItem();if(!q)break;const dt=Number(q.code),B=Number(q.value);switch(dt){case 1:this.sheetName=String(q.value);break;case 10:e=B;break;case 20:i=B;break;case 30:r=B;break;case 12:s=B;break;case 22:o=B;break;case 32:a=B;break;case 13:f=B;break;case 23:p=B;break;case 33:m=B;break;case 14:y=B;break;case 24:b=B;break;case 34:w=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:L.push(String(q.value));break;case 110:v=B;break;case 120:k=B;break;case 130:E=B;break;case 111:O=B;break;case 121:N=B;break;case 131:R=B;break;case 112:nt=B;break;case 122:et=B;break;case 132:G=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:rt.push(String(q.value));break;case 332:this.backgroundId=String(q.value);break;case 333:this.shadePlotId=String(q.value);break;case 340:this.clippingBoundaryId=String(q.value);break;case 345:this.ucsId=String(q.value);break;case 346:this.ucsBaseId=String(q.value);break;case 348:this.visualStyleId=String(q.value);break;case 361:this.sunId=String(q.value);break;case 421:this.ambientLightColorInstance=B;break;case 431:this.ambientLightColorName=String(q.value);break}}return this.applyViewportDxfIn(e,i,r,s,o,a,c,l,h),this._viewDirection.copy({x:u,y:d,z:g}),this._snapBase.copy({x:f,y:p,z:m}),this._snapSpacing.copy({x:y,y:b,z:w}),this._gridSpacing.copy({x,y:S,z:P}),this._ucsOrigin.copy({x:v,y:k,z:E}),this._ucsXAxis.copy({x:O,y:N,z:R}),this._ucsYAxis.copy({x:nt,y:et,z:G}),this.frozenLayerIds=rt,this.softPointers=L,this}applyViewportDxfIn(t,e,i,r,s,o,a,c,l){this.centerPoint.copy({x:t,y:e,z:i}),this.viewCenter.copy({x:r,y:s,z:o}),this.viewTarget.copy({x:a,y:c,z:l});const h=1e-6,u=Math.abs(t)<h&&Math.abs(e)<h,d=Math.abs(a)<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,o=this._centerPoint.y,a={1:{x:s-i,y:o-r},2:{x:s+i,y:o-r},3:{x:s+i,y:o+r},4:{x:s-i,y:o+r}},c=t===1?3:t===2?4:t===3?1:2,l=a[t],h=a[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}}}};Gc.typeName="Viewport";let ls=Gc;const Hc=class Hc extends Fi{get dxfTypeName(){return"WIPEOUT"}subWorldDraw(t){const e=this.boundaryPath(),i=new oe;return i.add(new it(e)),t.area(i)}dxfOutFields(t){return super.dxfOutFields(t),this}};Hc.typeName="Wipeout";let hs=Hc;const Ns=class Ns extends It{get dxfTypeName(){return"XLINE"}constructor(){super(),this._basePoint=new _,this._unitDir=new A}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 j;return t.expandByPoint(this._unitDir.clone().multiplyScalar(10).add(this._basePoint)),t.expandByPoint(this._unitDir.clone().multiplyScalar(-10).add(this._basePoint)),t}subGetIntersectCurves(){const t=this._basePoint.clone().add(this._unitDir);return[{kind:"line",line:new Dt(this._basePoint,t),extent:"unbounded"}]}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 Se(t,e,this.basePoint),this}subGetOsnapPoints(t,e,i,r){const s=this.basePoint;if(t===I.EndPoint){r.push(s);return}const o=this.unitDir.clone();if(o.lengthSq()===0)return;o.normalize();const a=new Dt(s,s.clone().add(o));switch(t){case I.Nearest:r.push(a.project(e));break;case I.Perpendicular:r.push(a.perpPoint(e));break}}transformBy(t){return this._basePoint.applyMatrix4(t),this._unitDir.transformDirection(t),this}get directBatchPrimitive(){return"lineStrip"}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,o=this.unitDir.y,a=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:o=h;break;case 31:a=h;break}}return this.basePoint=new _(e,i,r),this.unitDir=new A(s,o,a),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=mu(this.basePoint,this.unitDir,t);if(!e)return null;const i=new Ns;return i.basePoint=e,i.unitDir=this.unitDir.clone(),i}};Ns.typeName="Xline";let us=Ns;var pf=(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))(pf||{});const xn=48,lh=8,B_=48,mf=80,yf=32,Ro=80,No=24,ma=40,F_=8,D_=4,hh=64,X_=64,Y_=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","_drawCircleSides","_dwgname","_currentSpace","_formatter","_eventBatchDepth","_pendingEntityAppended","_pendingEntityErased","_pendingDictObjectSet","_pendingDictObjectErased","_lastOpenError"]),bf=new Set(["constructor","prototype","__proto__","caller","callee","arguments"]);function ce(n,t){let e=n.get(t);return e||(e={bytes:0,count:0},n.set(t,e)),e}function Zt(n,t,e,i=0){if(e<=0&&i===0)return;const r=ce(n.byCategory,t);r.bytes+=e,r.count+=i}function z_(n){const t=Object.getPrototypeOf(n);return t===Object.prototype||t===null}function V_(n){return ArrayBuffer.isView(n)}function j_(n){return typeof n.addEventListener=="function"&&typeof n.dispatch=="function"&&"listeners"in n}function U_(n,t,e){return bf.has(t)?!0:!n.includeEventManagers&&(t==="events"||e==="events")?t==="events":!n.includeTransactionManager&&(t==="transactionManager"||e==="transaction")?t==="transactionManager":!1}function uh(n,t,e){return t==="_xDataMap"||n==="xdata"?"xdata":t==="_tables"||n==="tables"?e instanceof tt?"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"||Y_.has(t)?"sysvars":e instanceof tt?"entities":n==="other"?"other":n}function G_(n){const t=new Set;let e=n;for(;e&&e!==Object.prototype;){for(const i of Object.getOwnPropertyNames(e)){if(bf.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 _f(n){if(n==null)return 0;switch(typeof n){case"number":return F_;case"boolean":return D_;case"string":return ma+n.length*2;case"bigint":return 16;case"symbol":return ma+String(n.description??"").length*2;default:return 0}}function H_(n,t){if(n.visited.has(t))return 0;n.visited.add(t),n.objectCount+=1;let e=mf+t.size*yf;for(const i of t.keys())e+=_f(i);return Zt(n,"handleRegistry",e,1),e}function vn(n,t,e,i){if(t==null)return 0;const r=typeof t;if(r==="function")return 0;if(r!=="object"){const h=_f(t);if(Zt(n,e,h),i){const u=ce(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&&j_(s))return Zt(n,e,xn,1),xn;let o=i,a=e;if(s instanceof tt){a="entities",o=s.type,n.entityCount+=1;const h=ce(n.byEntityType,o);h.count+=1}if(typeof s.then=="function")return Zt(n,a,xn,1),xn;if(s instanceof ArrayBuffer){const h=hh+s.byteLength;return Zt(n,a,h,1),o&&(ce(n.byEntityType,o).bytes+=h),h}if(V_(s)){const h=hh+s.byteLength;return s.buffer&&!n.visited.has(s.buffer)&&n.visited.add(s.buffer),Zt(n,a,h,1),o&&(ce(n.byEntityType,o).bytes+=h),h}if(typeof Blob<"u"&&s instanceof Blob){const h=X_+s.size;return Zt(n,a,h,1),o&&(ce(n.byEntityType,o).bytes+=h),h}if(s instanceof Date){const h=xn+8;return Zt(n,a,h,1),h}if(s instanceof Map){const h=a==="handleRegistry",u=mf+s.size*yf;let d=u;Zt(n,a,u,1),o&&(ce(n.byEntityType,o).bytes+=u);for(const[g,f]of s)d+=vn(n,g,a,o),h||(d+=vn(n,f,a,o));return d}if(s instanceof Set){let h=Ro+s.size*No;for(const u of s)h+=vn(n,u,a,o);return Zt(n,a,Ro+s.size*No,1),o&&(ce(n.byEntityType,o).bytes+=Ro+s.size*No),h}if(Array.isArray(s)){let h=B_+s.length*lh;Zt(n,a,h,1),o&&(ce(n.byEntityType,o).bytes+=h);for(let u=0;u<s.length;u++){const d=s[u],g=uh(a,String(u),d);h+=vn(n,d,g,o)}return h}let c=xn;const l=z_(s)?Object.getOwnPropertyNames(s):G_(s);for(const h of l)c+=lh,c+=Math.min(ma+h.length*2,64);Zt(n,a,c,1),o&&(ce(n.byEntityType,o).bytes+=c);for(const h of l){if(U_(n,h,a)||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+=H_(n,u);continue}const d=uh(a,h,u);!n.includeTransactionManager&&d==="transaction"||!n.includeEventManagers&&d==="events"||(c+=vn(n,u,d,o))}return c}function W_(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};vn(e,n,"sysvars",null);let i=0;const r={};for(const[o,a]of e.byCategory)r[o]={bytes:a.bytes,count:a.count},i+=a.bytes;const s={};for(const[o,a]of e.byEntityType)s[o]={bytes:a.bytes,count:a.count};return{totalBytes:i,objectCount:e.objectCount,entityCount:e.entityCount,byCategory:r,byEntityType:s}}function Bo(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(2)} KiB`:`${(n/(1024*1024)).toFixed(2)} MiB`}function $_(n){const t=[`AcDbDatabase memory estimate: ${Bo(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}: ${Bo(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}: ${Bo(s.bytes)} (${s.bytes} bytes), count=${s.count}`)}return t.join(`
14
14
  `)}function q_(n,t,e){const i=r=>r.toString(16).padStart(2,"0");return`#${i(n&255)}${i(t&255)}${i(e&255)}`}function _e(n,t){const e=n.getUint8(t),i=n.getUint8(t+1),r=n.getUint8(t+2);return q_(e,i,r)}function te(n){const t=(n>>>24&255)/255,e=n>>>16&255,i=n>>>8&255,r=n&255;return`rgba(${e},${i},${r},${t.toFixed(3)})`}function xf(n,t,e){const i=Math.min(1,Math.max(0,e)),r=(u,d)=>Math.round(u+(d-u)*i),s=n>>>24&255,o=t>>>24&255,a=r(n>>>16&255,t>>>16&255),c=r(n>>>8&255,t>>>8&255),l=r(n&255,t&255),h=r(s,o)/255;return`rgba(${a},${c},${l},${h.toFixed(3)})`}function K_(n){const t=/^#([0-9a-f]{6})$/i.exec(n);if(t)return`#${(16777215^parseInt(t[1],16)).toString(16).padStart(6,"0")}`;const e=/^#([0-9a-f]{3})$/i.exec(n);if(e){const[r,s,o]=e[1].split("").map(c=>parseInt(c+c,16)),a=c=>(255-c).toString(16).padStart(2,"0");return`#${a(r)}${a(s)}${a(o)}`}const i=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/i.exec(n);if(i){const r=255-Math.min(255,parseInt(i[1],10)),s=255-Math.min(255,parseInt(i[2],10)),o=255-Math.min(255,parseInt(i[3],10));return i[4]!==void 0?`rgba(${r},${s},${o},${i[4]})`:`rgb(${r},${s},${o})`}return n}var wf=1,vf=2,Af=3,Z_=4,ya=5,Pf=6,Q_=7,J_=8,tx=9,ex=10,nx=11,ix=12,rx=13,sx=14,ox=15,ax=17,cx=18,lx=19,hx=20,ux=21,dx=1,gx=2,fx=3,px=4,mx=5,yx=6,bx=7,_x=8,xx=9,wx=10,vx=11,Ax=12,Px=14,Sx=15,kx=16,ba=8192,Sf=2e5,kf=5e5,dh=22,Ex=24,Ix=25,Tx=26,Lx=27,Mx=28,Cx=29,Ox=30,Rx=31,Nx=32,Bx=33,Fx=34,Dx=35,Xx=36,Yx=37,zx=38,Vx=39,jx=40,Ux=42,Gx=43,Hx=44,Wx=45,_a=46,Er=47,$x=54,Ef=55,qx=58,Kx=59,Zx=60,Qx=61,Jx=62,tw=63,ew=64,nw=67,iw=70,rw=75,sw=76,ow=81,aw=82,cw=84,If=85,Tf=86,lw=87,xa=88,Lf=89,hw=91,uw=95,dw=98,gw=115,gh=2147483648,fw=726027589,pw=1128875079,mw=16385,yw=16386,bw=16388,_w=16392,xw=16394,ww=16395,vw=16396,Aw=16397,Pw=16398,Sw=16399,Fo=16400,kw=16401,Ew=16402,Iw=16404,Tw=16405,Lw=16410,Mw=16411,Cw=16412,Ow=16414,Rw=16415,Nw=16417,Bw=16418,Fw=16420,Dw=16421,Xw=16422,Yw=16424,zw=16425,Vw=16426,jw=16427,Uw=16428,Gw=16429,Hw=16430,Ww=16431,$w=16432,qw=16433,Kw=16434,Zw=16435,Qw=16436,Jw=16438,tv=16437,ev=1,nv=2,iv=3,rv=4,sv=5,ov=6,av=7,cv=8,lv=0,hv=1,uv=3,dv=4,gv=0,fv=513,pv=258,mv=260,yv=262,bv=521,_v=302,xv=523,wv=524,vv=532,Av=531,Pv=1051,Sv=1564,kv=1048,Ev=2071,mr=2074,Do=2096,Iv=804,Tv=805,Lv=301,Mv=496,Cv=762,Ov=764,Rv=763,Nv=1313,Bv=2610,Fv=30,Dv=295,Xv=1336,z=(...n)=>{},ve=(...n)=>{},bc=1;function Mf(n,t,e,i,r=bc,s=ba){const o=Math.max(1,Math.min(r,4));let a=Math.round(n*o),c=Math.round(t*o),l=o,h=o;if(e&&a>e){const f=e/a;a=e,c=Math.round(c*f),l*=f,h*=f}if(i&&c>i){const f=i/c;a=Math.round(a*f),c=i,l*=f,h*=f}const u=Math.max(1,Math.floor(s)),d=Math.max(1,Math.min(a,u)),g=Math.max(1,Math.min(c,u));a=d,c=g;try{if(typeof OffscreenCanvas<"u"){z(`createCanvas: using OffscreenCanvas ${a}×${c}, scale=(${l.toFixed(3)},${h.toFixed(3)})`);const m=new OffscreenCanvas(a,c),y=m.getContext("2d");return y?{canvas:m,ctx:y,scaleX:l,scaleY:h}:(ve('createCanvas: OffscreenCanvas.getContext("2d") returned null'),null)}if(typeof document>"u")return ve("createCanvas: no OffscreenCanvas and no document — cannot create canvas"),null;z(`createCanvas: using HTMLCanvasElement ${a}×${c}, scale=(${l.toFixed(3)},${h.toFixed(3)})`);const f=document.createElement("canvas");f.width=a,f.height=c;const p=f.getContext("2d");return p?{canvas:f,ctx:p,scaleX:l,scaleY:h}:(ve('createCanvas: HTMLCanvasElement.getContext("2d") returned null'),null)}catch{return null}}function Cf(n,t){if(n<=0||t<=0)return null;if(n=Math.max(1,Math.min(Math.floor(n),ba)),t=Math.max(1,Math.min(Math.floor(t),ba)),typeof OffscreenCanvas<"u"){const e=new OffscreenCanvas(n,t),i=e.getContext("2d");return i?{canvas:e,ctx:i}:null}if(typeof document<"u"){const e=document.createElement("canvas");e.width=n,e.height=t;const i=e.getContext("2d");return i?{canvas:e,ctx:i}:null}return null}function Of(n){switch(n){case dx:return{gco:"source-over",colorTransform:"black",exact:!0};case kx:return{gco:"source-over",colorTransform:"white",exact:!0};case vx:return{gco:"source-over",colorTransform:"skip",exact:!0};case px:return{gco:"source-over",colorTransform:"invert",exact:!0};case yx:return{gco:"difference",colorTransform:"white",exact:!0};case bx:case mx:return{gco:"difference",colorTransform:"none",exact:!1};case wx:return{gco:"difference",colorTransform:"invert",exact:!1};case xx:return{gco:"darken",colorTransform:"none",exact:!1};case fx:case gx:return{gco:"darken",colorTransform:"invert",exact:!1};case Sx:case Px:return{gco:"lighten",colorTransform:"none",exact:!1};case Ax:case _x:return{gco:"lighten",colorTransform:"invert",exact:!1};default:return{gco:"source-over",colorTransform:"none",exact:!0}}}function Rf(n,t){switch(t){case"invert":return K_(n);case"black":return"#000000";case"white":return"#ffffff";case"skip":return"rgba(0,0,0,0)";default:return n}}function ft(n,t){const e=Of(t.rop2);if(n.globalCompositeOperation=e.gco,t.penStyle===5){n.strokeStyle="rgba(0,0,0,0)",n.lineWidth=0;return}switch(n.strokeStyle=Rf(t.penColor,e.colorTransform),n.lineWidth=Math.max(t.penWidth,1),t.penStyle){case 1:n.setLineDash([8,4]);break;case 2:n.setLineDash([2,2]);break;case 3:n.setLineDash([8,4,2,4]);break;case 4:n.setLineDash([8,4,2,4,2,4]);break;default:n.setLineDash([]);break}}function Mt(n,t){const e=Of(t.rop2);if(n.globalCompositeOperation=e.gco,t.brushStyle===1){n.fillStyle="rgba(0,0,0,0)";return}n.fillStyle=Rf(t.brushColor,e.colorTransform)}function Yv(n){if(!n||n===400)return"";const t=Math.round(n/100)*100;return t===700?"bold":t>=100&&t<=900?String(t):n>=700?"bold":""}function wa(n,t){const e=(t==null?void 0:t[n.toLowerCase().trim()])??n;return/[\s,]/.test(e)&&!/^["']/.test(e)?`"${e}"`:e}function _c(n,t=1){return Math.max(Math.abs(n.fontHeight)*Math.abs(t||1),8)}function va(n,t,e=1){const i=t.fontItalic?"italic ":"",r=Yv(t.fontWeight),s=r?`${r} `:"",o=_c(t,e),a=wa(t.fontFamily,t.fontFamilyMap);n.font=`${i}${s}${o}px ${a}`}function zv(n,t,e,i,r,s=1){if(!t.fontUnderline&&!t.fontStrikeOut)return;const o=_c(t,s),a=Math.max(1,Math.round(o/14)),c=n.fillStyle;n.fillStyle=t.textColor,t.fontUnderline&&n.fillRect(e,i+Math.round(o*.12),r,a),t.fontStrikeOut&&n.fillRect(e,i-Math.round(o*.3),r,a),n.fillStyle=c}function Yi(n,t,e){if(e<=0)return"";const i=n.byteLength-t;if(i<=0)return"";const r=Math.min(e,Math.floor(i/2));if(r<=0)return"";let s;try{const a=new Uint8Array(n.buffer,n.byteOffset+t,r*2);s=new TextDecoder("utf-16le").decode(a)}catch{const a=[];for(let c=0;c<r;c++){const l=n.getUint16(t+c*2,!0);if(l===0)return a.join("");a.push(String.fromCharCode(l))}return a.join("")}const o=s.indexOf("\0");return o===-1?s:s.slice(0,o)}function Vv(n){switch(n){case 0:return{kind:"brush",style:0,color:"#ffffff"};case 1:return{kind:"brush",style:0,color:"#c0c0c0"};case 2:return{kind:"brush",style:0,color:"#808080"};case 3:return{kind:"brush",style:0,color:"#404040"};case 4:return{kind:"brush",style:0,color:"#000000"};case 5:return{kind:"brush",style:1,color:"#000000"};case 6:return{kind:"pen",style:0,widthX:1,color:"#ffffff"};case 7:return{kind:"pen",style:0,widthX:1,color:"#000000"};case 8:return{kind:"pen",style:5,widthX:0,color:"#000000"};case 10:case 11:return{kind:"font",height:12,weight:400,italic:!1,underline:!1,strikeOut:!1,family:"monospace"};case 12:case 13:case 14:case 17:return{kind:"font",height:12,weight:400,italic:!1,underline:!1,strikeOut:!1,family:"sans-serif"};default:return null}}async function jv(n){return new Promise((t,e)=>{const i=new FileReader;i.onload=()=>t(i.result),i.onerror=()=>e(i.error),i.readAsDataURL(n)})}async function Nf(n){if(typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas){z(`exportCanvasToPngDataUrl: using OffscreenCanvas.convertToBlob (${n.width}×${n.height})`);const t=await n.convertToBlob({type:"image/png"});return z(`exportCanvasToPngDataUrl: blob size=${t.size} bytes, type=${t.type}`),jv(t)}return typeof HTMLCanvasElement<"u"&&n instanceof HTMLCanvasElement?(z(`exportCanvasToPngDataUrl: using HTMLCanvasElement.toDataURL (${n.width}×${n.height})`),n.toDataURL("image/png")):null}function Uv(n){if(z("parseEmfHeader: byteLength =",n.byteLength),n.byteLength<88||n.getUint32(0,!0)!==wf)return null;const e=n.getInt32(8,!0),i=n.getInt32(12,!0),r=n.getInt32(16,!0),s=n.getInt32(20,!0),o=n.getInt32(24,!0),a=n.getInt32(28,!0),c=n.getInt32(32,!0),l=n.getInt32(36,!0),h=c-o,u=l-a;return{bounds:{left:e,top:i,right:r,bottom:s},frameW:h,frameH:u}}function Gv(n){const t=n.bounds.right-n.bounds.left,e=n.bounds.bottom-n.bounds.top;return t>0&&e>0?n.bounds:n.frameW>0&&n.frameH>0?(z(`getRenderableEmfBounds: bounds invalid (${t}×${e}), falling back to frame ${n.frameW}×${n.frameH}`),{left:0,top:0,right:n.frameW,bottom:n.frameH}):null}function Hv(n){if(n.byteLength<22)return null;const t=n.getUint32(0,!0);let e=0,i=0,r=0,s=800,o=600,a=96;if(t===2596720087&&(i=n.getInt16(6,!0),r=n.getInt16(8,!0),s=n.getInt16(10,!0),o=n.getInt16(12,!0),a=n.getUint16(14,!0)||96,e=22),e+18>n.byteLength)return null;const c=n.getUint16(e,!0);if(c!==1&&c!==2)return null;const l=n.getUint16(e+2,!0)*2,h=n.getUint32(e+8,!0)*2;return{headerSize:e+l,maxRecordSize:h,boundsLeft:i,boundsTop:r,boundsRight:s,boundsBottom:o,unitsPerInch:a}}function Z(n,t){const e=n.state.worldTransform,i=e[0]*t+e[4];return n.useMappingMode?(i-n.windowOrg.x)/(n.windowExt.cx||1)*(n.viewportExt.cx||1)+n.viewportOrg.x:(i-n.bounds.left)*n.sx}function Q(n,t){const e=n.state.worldTransform,i=e[3]*t+e[5];return n.useMappingMode?(i-n.windowOrg.y)/(n.windowExt.cy||1)*(n.viewportExt.cy||1)+n.viewportOrg.y:(i-n.bounds.top)*n.sy}function Wt(n,t){const e=n.state.worldTransform[0]*t;return n.useMappingMode?e/(n.windowExt.cx||1)*(n.viewportExt.cx||1):e*n.sx}function Ft(n,t){const e=n.state.worldTransform[3]*t;return n.useMappingMode?e/(n.windowExt.cy||1)*(n.viewportExt.cy||1):e*n.sy}function nn(n){n.useMappingMode=!0}function Wv(n,t,e){const{ctx:i,view:r}=n;if(e>=20){const s=r.getInt32(t,!0),o=r.getInt32(t+4,!0),a=_e(r,t+8);i.fillStyle=a,i.fillRect(Z(n,s),Q(n,o),1,1)}return!0}function $v(n,t,e){const{ctx:i,view:r,state:s,inPath:o}=n;return e>=16&&(s.curX=r.getInt32(t,!0),s.curY=r.getInt32(t+4,!0),o&&i.moveTo(Z(n,s.curX),Q(n,s.curY))),!0}function qv(n,t,e){const{ctx:i,view:r,state:s,inPath:o}=n;if(e>=16){const a=r.getInt32(t,!0),c=r.getInt32(t+4,!0);o?i.lineTo(Z(n,a),Q(n,c)):(ft(i,s),i.beginPath(),i.moveTo(Z(n,s.curX),Q(n,s.curY)),i.lineTo(Z(n,a),Q(n,c)),i.stroke()),s.curX=a,s.curY=c}return!0}function Kv(n,t,e){const{ctx:i,view:r,state:s,inPath:o}=n;if(e>=24){const a=r.getInt32(t,!0),c=r.getInt32(t+4,!0),l=r.getInt32(t+8,!0),h=r.getInt32(t+12,!0);o?i.rect(Z(n,a),Q(n,c),Wt(n,l-a),Ft(n,h-c)):(Mt(i,s),i.fillRect(Z(n,a),Q(n,c),Wt(n,l-a),Ft(n,h-c)),ft(i,s),i.strokeRect(Z(n,a),Q(n,c),Wt(n,l-a),Ft(n,h-c)))}return!0}function Zv(n,t,e){const{ctx:i,view:r,state:s,inPath:o}=n;if(e>=32){const a=r.getInt32(t,!0),c=r.getInt32(t+4,!0),l=r.getInt32(t+8,!0),h=r.getInt32(t+12,!0),u=Math.abs(Wt(n,r.getInt32(t+16,!0)))/2,d=Math.abs(Ft(n,r.getInt32(t+20,!0)))/2,g=Z(n,a),f=Q(n,c),p=Wt(n,l-a),m=Ft(n,h-c),y=()=>{const b=Math.min(u,d,p/2,m/2);i.moveTo(g+b,f),i.lineTo(g+p-b,f),i.arcTo(g+p,f,g+p,f+b,b),i.lineTo(g+p,f+m-b),i.arcTo(g+p,f+m,g+p-b,f+m,b),i.lineTo(g+b,f+m),i.arcTo(g,f+m,g,f+m-b,b),i.lineTo(g,f+b),i.arcTo(g,f,g+b,f,b),i.closePath()};o?y():(i.beginPath(),y(),Mt(i,s),i.fill(),ft(i,s),i.stroke())}return!0}function Qv(n,t,e){const{ctx:i,view:r,state:s,inPath:o}=n;if(e>=24){const a=r.getInt32(t,!0),c=r.getInt32(t+4,!0),l=r.getInt32(t+8,!0),h=r.getInt32(t+12,!0),u=Z(n,(a+l)/2),d=Q(n,(c+h)/2),g=Math.abs(Wt(n,l-a))/2,f=Math.abs(Ft(n,h-c))/2;o?i.ellipse(u,d,g,f,0,0,Math.PI*2):(i.beginPath(),i.ellipse(u,d,g,f,0,0,Math.PI*2),Mt(i,s),i.fill(),ft(i,s),i.stroke())}return!0}function Jv(n,t,e,i){const{ctx:r,view:s,state:o,inPath:a}=n;if(i>=40){const c=s.getInt32(e,!0),l=s.getInt32(e+4,!0),h=s.getInt32(e+8,!0),u=s.getInt32(e+12,!0),d=s.getInt32(e+16,!0),g=s.getInt32(e+20,!0),f=s.getInt32(e+24,!0),p=s.getInt32(e+28,!0),m=(c+h)/2,y=(l+u)/2,b=Math.abs(h-c)/2,w=Math.abs(u-l)/2,x=Math.atan2((g-y)/(w||1),(d-m)/(b||1)),S=Math.atan2((p-y)/(w||1),(f-m)/(b||1)),P=Z(n,m),v=Q(n,y),k=Math.abs(Wt(n,b)),E=Math.abs(Ft(n,w)),O=t===Ef,N=t===Er||t===_a;a||r.beginPath(),t===Er&&r.moveTo(P,v),O&&r.lineTo(P+k*Math.cos(x),v+E*Math.sin(x)),r.ellipse(P,v,k,E,0,x,S,!1),(t===Er||t===_a)&&r.closePath(),a||(N&&(Mt(r,o),r.fill()),ft(r,o),r.stroke()),O&&(o.curX=f,o.curY=p)}return!0}function t2(n,t,e,i){switch(t){case ox:return Wv(n,e,i);case Lx:return $v(n,e,i);case $x:return qv(n,e,i);case Gx:return Kv(n,e,i);case Hx:return Zv(n,e,i);case Ux:return Qv(n,e,i);case Wx:case Ef:case _a:case Er:return Jv(n,t,e,i);default:return!1}}var yr=1<<24;function e2(n,t,e,i){return{cmds:[{op:"rect",x:n,y:t,w:e,h:i}],fillRule:"nonzero",simple:!0}}function n2(n){return{cmds:n.map(t=>({op:"rect",x:t.x,y:t.y,w:t.w,h:t.h})),fillRule:"nonzero",simple:!0}}function Fn(){return{cmds:[{op:"rect",x:0,y:0,w:0,h:0}],fillRule:"nonzero",simple:!0}}function i2(n,t,e){return{...n,cmds:n.cmds.map(i=>{switch(i.op){case"rect":return{...i,x:i.x+t,y:i.y+e};case"moveTo":case"lineTo":return{...i,x:i.x+t,y:i.y+e};case"bezierCurveTo":return{...i,cp1x:i.cp1x+t,cp1y:i.cp1y+e,cp2x:i.cp2x+t,cp2y:i.cp2y+e,x:i.x+t,y:i.y+e};case"closePath":return i}})}}function Bf(n,t,e){return n?n.map(i=>i2(i,t,e)):null}function Ye(n){return n.simple&&n.fillRule==="nonzero"}function br(n){return{cmds:[{op:"rect",x:-yr,y:-yr,w:2*yr,h:2*yr},...n.cmds],fillRule:"evenodd",simple:!1}}function pi(n,t,e){switch(e){case"replace":return{region:[t],exact:!0};case"intersect":return{region:n?[...n,t]:[t],exact:!0};case"exclude":{if(!Ye(t))return{region:n?[...n,t]:[t],exact:!1};const i=br(t);return{region:n?[...n,i]:[i],exact:!0}}case"union":return n?n.length===1&&Ye(n[0])&&Ye(t)?{region:[{cmds:[...n[0].cmds,...t.cmds],fillRule:"nonzero",simple:!1}],exact:!1}:{region:n,exact:!1}:{region:null,exact:!0};case"xor":return n?n.length===1&&Ye(n[0])&&Ye(t)?{region:[{cmds:[...n[0].cmds,...t.cmds],fillRule:"evenodd",simple:!1}],exact:!0}:Ye(t)?{region:[...n,br(t)],exact:!1}:{region:[...n,t],exact:!1}:Ye(t)?{region:[br(t)],exact:!0}:{region:[t],exact:!1};case"complement":return n?n.length===1&&Ye(n[0])?{region:[t,br(n[0])],exact:!0}:{region:[t],exact:!1}:{region:[Fn()],exact:!0}}}function Ff(n,t,e){if(e==="replace")return{region:t,exact:!0};if(t&&t.length===1)return pi(n,t[0],e);if(!t)switch(e){case"intersect":return{region:n,exact:!0};case"union":return{region:null,exact:!0};case"exclude":return{region:[Fn()],exact:!0};case"xor":case"complement":return n?n.length===1?pi(null,n[0],"exclude"):{region:n,exact:!1}:{region:[Fn()],exact:!0}}switch(e){case"intersect":return{region:n?[...n,...t]:t,exact:!0};case"union":return{region:n,exact:!1};case"xor":return{region:n??t,exact:!1};case"exclude":return{region:n,exact:!1};case"complement":return n?n.length===1?pi(t,n[0],"exclude"):{region:t,exact:!1}:{region:[Fn()],exact:!0}}}function r2(n,t){for(const e of t)switch(e.op){case"rect":n.rect(e.x,e.y,e.w,e.h);break;case"moveTo":n.moveTo(e.x,e.y);break;case"lineTo":n.lineTo(e.x,e.y);break;case"bezierCurveTo":n.bezierCurveTo(e.cp1x,e.cp1y,e.cp2x,e.cp2y,e.x,e.y);break;case"closePath":n.closePath();break}}function Aa(n,t){for(const e of t){n.beginPath(),r2(n,e.cmds);try{n.clip(e.fillRule)}catch{}}}function Wn(n,t,e=!1){const{ctx:i}=n;for(;n.clipSaveDepth>0;)i.restore(),n.clipSaveDepth--;t&&(i.save(),n.clipSaveDepth=1,e&&i.setTransform(1,0,0,1,0,0),Aa(i,t))}function s2(n,t,e,i,r,s,o,a,c,l){let h=0,u=r-1,d=t;const g=t+e;for(;d+1<g&&u>=0;){const f=n.getUint8(d),p=n.getUint8(d+1);if(d+=2,f===0)if(p===0)h=0,u--;else{if(p===1)break;if(p===2){if(d+1>=g)break;h+=n.getUint8(d),u-=n.getUint8(d+1),d+=2}else{const m=p;if(o){const y=Math.ceil(m/2);let b=0;for(let w=0;w<y&&d<g;w++){const x=n.getUint8(d++);for(let S=0;S<2&&b<m;S++){const P=S===0?x>>4&15:x&15;P<a.length&&h<i&&l(h,r-1-u,a[P][0],a[P][1],a[P][2],255),h++,b++}}y&1&&d++}else{for(let y=0;y<m&&d<g&&h<i;y++){const b=n.getUint8(d++);b<a.length&&l(h,r-1-u,a[b][0],a[b][1],a[b][2],255),h++}m&1&&d++}}}else if(o){const m=p>>4&15,y=p&15;for(let b=0;b<f&&h<i;b++){const w=(b&1)===0?m:y;w<a.length&&l(h,r-1-u,a[w][0],a[w][1],a[w][2],255),h++}}else{const m=p,y=m<a.length?a[m]:[0,0,0];for(let b=0;b<f&&h<i;b++)l(h,r-1-u,y[0],y[1],y[2],255),h++}}return new ImageData(new Uint8ClampedArray(c.buffer,c.byteOffset,c.byteLength),i,r)}function Xo(n){if(n===0)return 0;let t=0,e=n;for(;(e&1)===0;)e>>>=1,t++;return t}var o2=3;function a2(n,t,e,i,r){let s=0,o=0,a=0,c=0,l=0,h=0,u=1,d=1,g=1;if(i===o2){const f=t+e;if(f+12>n.byteLength)return null;s=n.getUint32(f,!0),o=n.getUint32(f+4,!0),a=n.getUint32(f+8,!0),c=Xo(s),l=Xo(o),h=Xo(a),u=s>>>c||1,d=o>>>l||1,g=a>>>h||1}else r===16&&(s=31744,o=992,a=31,c=10,l=5,h=0,u=31,d=31,g=31);return{rMask:s,gMask:o,bMask:a,rShift:c,gShift:l,bShift:h,rMax:u,gMax:d,bMax:g}}function c2(n,t,e,i,r,s,o,a,c){const l=Math.floor((s*e+31)/32)*4,{rMask:h,gMask:u,bMask:d,rShift:g,gShift:f,bShift:p,rMax:m,gMax:y,bMax:b}=a;for(let w=0;w<i;w++){const x=r?w:i-1-w,S=t+x*l;if(!(S+l>n.byteLength))for(let P=0;P<e;P++){const v=(w*e+P)*4;if(s===1){const k=S+(P>>3),E=n.getUint8(k)>>7-(P&7)&1;E<o.length&&(c[v]=o[E][0],c[v+1]=o[E][1],c[v+2]=o[E][2]),c[v+3]=255}else if(s===4){const k=S+(P>>1),E=(P&1)===0?n.getUint8(k)>>4&15:n.getUint8(k)&15;E<o.length&&(c[v]=o[E][0],c[v+1]=o[E][1],c[v+2]=o[E][2]),c[v+3]=255}else if(s===8){const k=n.getUint8(S+P);k<o.length&&(c[v]=o[k][0],c[v+1]=o[k][1],c[v+2]=o[k][2]),c[v+3]=255}else if(s===16){const k=n.getUint16(S+P*2,!0);c[v]=Math.round(((k&h)>>>g)*255/m),c[v+1]=Math.round(((k&u)>>>f)*255/y),c[v+2]=Math.round(((k&d)>>>p)*255/b),c[v+3]=255}else if(s===24){const k=S+P*3;c[v]=n.getUint8(k+2),c[v+1]=n.getUint8(k+1),c[v+2]=n.getUint8(k),c[v+3]=255}else{const k=S+P*4,E=n.getUint8(k),O=n.getUint8(k+1),N=n.getUint8(k+2),R=n.getUint8(k+3);c[v]=N,c[v+1]=O,c[v+2]=E,c[v+3]=R===0?255:R}}}}function Df(n,t,e,i){if(t<0||e<0||t+40>n.byteLength||e+i>n.byteLength)return null;const r=n.getUint32(t,!0);if(r<40||t+r>n.byteLength)return null;const s=n.getInt32(t+4,!0),o=n.getInt32(t+8,!0),a=n.getUint16(t+12,!0),c=n.getUint16(t+14,!0),l=n.getUint32(t+16,!0);if(a!==1||s<=0||o===0||s>8192||Math.abs(o)>8192)return null;const h=0,u=1,d=2,g=3;if(c!==1&&c!==4&&c!==8&&c!==16&&c!==24&&c!==32||l===u&&c!==8||l===d&&c!==4||l===g&&c!==16&&c!==32||l!==h&&l!==u&&l!==d&&l!==g)return null;const f=Math.abs(o),p=o<0,m=[];if(c<=8){const w=1<<c,x=n.getUint32(t+32,!0)||w,S=Math.min(x,w),P=t+r;if(P+S*4>n.byteLength)return null;for(let v=0;v<S;v++){const k=n.getUint8(P+v*4),E=n.getUint8(P+v*4+1),O=n.getUint8(P+v*4+2);m.push([O,E,k])}}const y=a2(n,t,r,l,c);if(!y)return null;const b=new Uint8ClampedArray(s*f*4);return l===u||l===d?s2(n,e,i,s,f,p,l===d,m,b,(x,S,P,v,k,E)=>{const O=(S*s+x)*4;b[O]=P,b[O+1]=v,b[O+2]=k,b[O+3]=E}):(c2(n,e,s,f,p,c,m,y,b),new ImageData(b,s,f))}function l2(n,t,e,i){const{ctx:r,view:s,state:o}=n;if(i>=76){const a=s.getInt32(e+28,!0),c=s.getInt32(e+32,!0),l=s.getUint32(e+36,!0),h=s.getUint32(e+40,!0),u=s.byteLength;if(l>0&&h>0&&t+h+l*2<=u){const d=Yi(s,t+h,l);if(d.length>0){const g=Math.abs(Ft(n,1));va(r,o,g),r.fillStyle=o.textColor;const f=o.textAlign&24,p=f===24?"alphabetic":f===8?"bottom":"top";let m="left";if(o.textAlign&6&&(m="center"),o.textAlign&2&&(m="right"),r.textBaseline=p,r.textAlign=m,o.bkMode===2){const y=r.measureText(d),b=_c(o,g);r.fillStyle=o.bkColor,r.fillRect(Z(n,a),Q(n,c)-b,y.width,b),r.fillStyle=o.textColor}if(r.fillText(d,Z(n,a),Q(n,c)),o.fontUnderline||o.fontStrikeOut){const y=r.measureText(d).width,b=Z(n,a),w=m==="center"?b-y/2:m==="right"?b-y:b;zv(r,o,w,Q(n,c),y,g)}}}}return!0}var h2=15728673,u2=1;function d2(n,t,e,i){const{ctx:r,view:s,state:o}=n;if(i>=96){const a=s.getInt32(e+16,!0),c=s.getInt32(e+20,!0),l=s.getInt32(e+24,!0),h=s.getInt32(e+28,!0),u=s.getUint32(e+32,!0),d=s.getUint32(e+76,!0),g=s.getUint32(e+80,!0),f=s.getUint32(e+84,!0),p=s.getUint32(e+88,!0);if(d===0&&u===h2){const m=r.fillStyle;return o.brushStyle!==u2&&(r.fillStyle=o.brushColor,r.fillRect(Z(n,a),Q(n,c),Wt(n,l),Ft(n,h))),r.fillStyle=m,!0}if(d>0&&g>0&&f>0&&p>0){const m=Df(s,t+d,t+f,p);if(m){const y=Cf(m.width,m.height);y&&(y.ctx.putImageData(m,0,0),r.drawImage(y.canvas,Z(n,a),Q(n,c),Wt(n,l),Ft(n,h)))}}}return!0}function g2(n,t,e,i){const{ctx:r,view:s}=n;if(i>=80){const o=s.getInt32(e+16,!0),a=s.getInt32(e+20,!0),c=s.getInt32(e+64,!0),l=s.getInt32(e+68,!0),h=s.getUint32(e+40,!0),u=s.getUint32(e+44,!0),d=s.getUint32(e+48,!0),g=s.getUint32(e+52,!0);if(h>0&&u>0&&d>0&&g>0){const f=Df(s,t+h,t+d,g);if(f){const p=Cf(f.width,f.height);p&&(p.ctx.putImageData(f,0,0),r.drawImage(p.canvas,Z(n,o),Q(n,a),Wt(n,c),Ft(n,l)))}}}return!0}function xc(n,t,e){const{ctx:i}=n;if(n.clipUntracked&&e!=="replace")switch(e){case"intersect":case"complement":{i.save(),n.clipSaveDepth++,Aa(i,[t]);return}case"exclude":case"xor":{const s=pi(null,t,"exclude");i.save(),n.clipSaveDepth++,Aa(i,s.region??[t]);return}case"union":return}const r=pi(e==="replace"?null:n.clipRegion??null,t,e);r.exact,n.clipRegion=r.region,n.clipUntracked=!1,Wn(n,r.region)}function Xf(n,t){const{view:e}=n,i=e.getInt32(t,!0),r=e.getInt32(t+4,!0),s=e.getInt32(t+8,!0),o=e.getInt32(t+12,!0);return e2(Z(n,i),Q(n,r),Wt(n,s-i),Ft(n,o-r))}function f2(n,t,e){return e>=24&&xc(n,Xf(n,t),"intersect"),!0}function p2(n,t,e){return e>=24&&xc(n,Xf(n,t),"exclude"),!0}var m2={1:"intersect",2:"union",3:"xor",4:"exclude",5:"replace"};function y2(n,t,e){const{view:i}=n;if(e<16)return!0;const r=i.getUint32(t,!0),s=i.getUint32(t+4,!0),o=m2[s];if(!o)return!0;if(r===0)return o==="replace"&&(n.clipRegion=null,n.clipUntracked=!1,Wn(n,null)),!0;const a=t+8;if(r<32)return!0;const c=i.getUint32(a+8,!0);if(c===0)return!0;const l=[],h=a+32;for(let u=0;u<c;u++){const d=h+u*16;if(d+16>t+8+r)break;const g=i.getInt32(d,!0),f=i.getInt32(d+4,!0),p=i.getInt32(d+8,!0),m=i.getInt32(d+12,!0);l.push({x:Z(n,g),y:Q(n,f),w:Wt(n,p-g),h:Ft(n,m-f)})}return l.length===0||xc(n,n2(l),o),!0}function b2(n,t,e){if(e>=16){const i=n.view.getInt32(t,!0),r=n.view.getInt32(t+4,!0);if(n.clipUntracked)return!0;n.clipRegion&&(n.clipRegion=Bf(n.clipRegion,Wt(n,i),Ft(n,r)),Wn(n,n.clipRegion))}return!0}function _2(n,t,e,i,r){switch(t){case cw:return l2(n,e,i,r);case sw:return d2(n,e,i,r);case ow:return g2(n,e,i,r);case Ox:return f2(n,i,r);case rw:return y2(n,i,r);case Cx:return p2(n,i,r);case Tx:return b2(n,i,r);default:return!1}}function x2(n,t,e,i,r){return t2(n,t,i,r)||_2(n,t,e,i,r)}function w2(n,t,e,i){const{ctx:r,view:s,state:o,inPath:a}=n,c=s.getUint32(e+16,!0),l=s.getUint32(e+20,!0);if(c===0||c>=1e4||l>=1e5)return;const h=e+24,u=h+c*4;if(u+l*8>t+i)return;a||r.beginPath();let d=0;for(let g=0;g<c;g++){const f=s.getUint32(h+g*4,!0);for(let p=0;p<f&&d<l;p++){const m=s.getInt32(u+d*8,!0),y=s.getInt32(u+d*8+4,!0);p===0?r.moveTo(Z(n,m),Q(n,y)):r.lineTo(Z(n,m),Q(n,y)),d++}r.closePath()}a||(Mt(r,o),r.fill(o.polyFillMode===2?"nonzero":"evenodd"),ft(r,o),r.stroke())}function v2(n,t,e,i){const{ctx:r,view:s,state:o,inPath:a}=n,c=s.getUint32(e+16,!0),l=s.getUint32(e+20,!0);if(c===0||c>=1e4||l>=1e5)return;const h=e+24,u=h+c*4;if(u+l*8>t+i)return;a||r.beginPath();let d=0;for(let g=0;g<c;g++){const f=s.getUint32(h+g*4,!0);for(let p=0;p<f&&d<l;p++){const m=s.getInt32(u+d*8,!0),y=s.getInt32(u+d*8+4,!0);p===0?r.moveTo(Z(n,m),Q(n,y)):r.lineTo(Z(n,m),Q(n,y)),d++}}a||(ft(r,o),r.stroke())}function A2(n,t,e,i){const{ctx:r,view:s,state:o,inPath:a}=n,c=s.getUint32(e+16,!0),l=s.getUint32(e+20,!0);if(c===0||c>=1e4||l>=1e5)return;const h=e+24,u=h+c*4;if(u+l*4>t+i)return;a||r.beginPath();let d=0;for(let g=0;g<c;g++){const f=s.getUint32(h+g*4,!0);for(let p=0;p<f&&d<l;p++){const m=s.getInt16(u+d*4,!0),y=s.getInt16(u+d*4+2,!0);p===0?r.moveTo(Z(n,m),Q(n,y)):r.lineTo(Z(n,m),Q(n,y)),d++}r.closePath()}a||(Mt(r,o),r.fill(o.polyFillMode===2?"nonzero":"evenodd"),ft(r,o),r.stroke())}function P2(n,t,e,i,r){const{ctx:s,view:o,state:a,inPath:c}=n;if(r<28)return!0;const l=o.getUint32(i+16,!0),h=i+20;if(l===0||h+l*8>e+r)return!0;const u=t===Af,d=t===vf||t===ya,g=t===ya||t===Pf;c||s.beginPath(),g||s.moveTo(Z(n,o.getInt32(h,!0)),Q(n,o.getInt32(h+4,!0)));let f=g?0:1;if(d)for(;f+2<l;)s.bezierCurveTo(Z(n,o.getInt32(h+f*8,!0)),Q(n,o.getInt32(h+f*8+4,!0)),Z(n,o.getInt32(h+(f+1)*8,!0)),Q(n,o.getInt32(h+(f+1)*8+4,!0)),Z(n,o.getInt32(h+(f+2)*8,!0)),Q(n,o.getInt32(h+(f+2)*8+4,!0))),f+=3;else for(;f<l;f++)s.lineTo(Z(n,o.getInt32(h+f*8,!0)),Q(n,o.getInt32(h+f*8+4,!0)));if(u&&s.closePath(),c||(u&&(Mt(s,a),s.fill(a.polyFillMode===2?"nonzero":"evenodd")),ft(s,a),s.stroke()),l>0){const p=l-1;a.curX=o.getInt32(h+p*8,!0),a.curY=o.getInt32(h+p*8+4,!0)}return!0}function S2(n,t,e,i,r){const{ctx:s,view:o,state:a,inPath:c}=n;if(r<28)return!0;const l=o.getUint32(i+16,!0),h=i+20;if(l===0||h+l*4>e+r)return!0;const u=t===Tf,d=t===If||t===xa,g=t===xa||t===Lf;c||s.beginPath(),g||s.moveTo(Z(n,o.getInt16(h,!0)),Q(n,o.getInt16(h+2,!0)));let f=g?0:1;if(d)for(;f+2<l;)s.bezierCurveTo(Z(n,o.getInt16(h+f*4,!0)),Q(n,o.getInt16(h+f*4+2,!0)),Z(n,o.getInt16(h+(f+1)*4,!0)),Q(n,o.getInt16(h+(f+1)*4+2,!0)),Z(n,o.getInt16(h+(f+2)*4,!0)),Q(n,o.getInt16(h+(f+2)*4+2,!0))),f+=3;else for(;f<l;f++)s.lineTo(Z(n,o.getInt16(h+f*4,!0)),Q(n,o.getInt16(h+f*4+2,!0)));if(u&&s.closePath(),c||(u&&(Mt(s,a),s.fill(a.polyFillMode===2?"nonzero":"evenodd")),ft(s,a),s.stroke()),l>0){const p=l-1;a.curX=o.getInt16(h+p*4,!0),a.curY=o.getInt16(h+p*4+2,!0)}return!0}function k2(n,t,e,i,r){const{ctx:s,state:o}=n;switch(t){case Z_:case Af:case vf:case ya:case Pf:return P2(n,t,e,i,r);case lw:case Tf:case If:case xa:case Lf:return S2(n,t,e,i,r);case Q_:return r>=28&&v2(n,e,i,r),!0;case J_:return r>=28&&w2(n,e,i,r),!0;case hw:return r>=28&&A2(n,e,i,r),!0;case Kx:return n.inPath=!0,s.beginPath(),!0;case Zx:return n.inPath=!1,!0;case Qx:return s.closePath(),!0;case Jx:return Mt(s,o),s.fill(o.polyFillMode===2?"nonzero":"evenodd"),!0;case tw:return Mt(s,o),s.fill(o.polyFillMode===2?"nonzero":"evenodd"),ft(s,o),s.stroke(),!0;case ew:return ft(s,o),s.stroke(),!0;case nw:{const a=r>=12?n.view.getUint32(i,!0):5;try{if(a===5)for(;n.clipSaveDepth>0;)s.restore(),n.clipSaveDepth--;s.save(),n.clipSaveDepth++,s.clip(o.polyFillMode===2?"nonzero":"evenodd"),n.clipRegion=null,n.clipUntracked=!0}catch{}return!0}default:return!1}}function E2(n,t,e,i){const{view:r,state:s}=n;switch(t){case zx:{if(i>=28){const o=r.getUint32(e,!0),a=r.getUint32(e+4,!0),c=r.getInt32(e+8,!0),l=_e(r,e+16);n.objectTable.set(o,{kind:"pen",style:a&255,widthX:c,color:l})}return!0}case uw:{if(i>=52){const o=r.getUint32(e,!0),a=r.getUint32(e+12,!0),c=r.getInt32(e+16,!0),l=_e(r,e+24);n.objectTable.set(o,{kind:"pen",style:a&255,widthX:c,color:l})}return!0}case Vx:{if(i>=24){const o=r.getUint32(e,!0),a=r.getUint32(e+4,!0),c=_e(r,e+8);n.objectTable.set(o,{kind:"brush",style:a,color:c})}return!0}case aw:{if(i>=332){const o=r.getUint32(e,!0),a=r.getInt32(e+4,!0),c=r.getInt32(e+20,!0),l=r.getUint8(e+24),h=r.getUint8(e+25),u=r.getUint8(e+26),d=Yi(r,e+28,32)||"sans-serif";n.objectTable.set(o,{kind:"font",height:Math.abs(a),weight:c,italic:l!==0,underline:h!==0,strikeOut:u!==0,family:d})}return!0}case Yx:{if(i>=12){const o=r.getUint32(e,!0),a=o>=gh?Vv(o-gh):n.objectTable.get(o)??null;if(a)switch(a.kind){case"pen":s.penStyle=a.style,s.penWidth=a.widthX,s.penColor=a.color;break;case"brush":s.brushStyle=a.style,s.brushColor=a.color;break;case"font":s.fontHeight=a.height,s.fontWeight=a.weight,s.fontItalic=a.italic,s.fontUnderline=a.underline,s.fontStrikeOut=a.strikeOut,s.fontFamily=a.family;break}}return!0}case jx:return i>=12&&n.objectTable.delete(r.getUint32(e,!0)),!0;default:return!1}}function I2(n,t,e,i){const{view:r}=n;switch(t){case tx:return i>=16&&(n.windowExt.cx=r.getInt32(e,!0),n.windowExt.cy=r.getInt32(e+4,!0),nn(n)),!0;case ex:return i>=16&&(n.windowOrg.x=r.getInt32(e,!0),n.windowOrg.y=r.getInt32(e+4,!0),nn(n)),!0;case nx:return i>=16&&(n.viewportExt.cx=r.getInt32(e,!0),n.viewportExt.cy=r.getInt32(e+4,!0),nn(n)),!0;case ix:return i>=16&&(n.viewportOrg.x=r.getInt32(e,!0),n.viewportOrg.y=r.getInt32(e+4,!0),nn(n)),!0;case ax:{if(i>=12){const s=r.getUint32(e,!0);(s===8||s===7)&&nn(n)}return!0}case Rx:{if(i>=24){const s=r.getInt32(e,!0),o=r.getInt32(e+4,!0),a=r.getInt32(e+8,!0),c=r.getInt32(e+12,!0);o!==0&&(n.viewportExt.cx=Math.round(n.viewportExt.cx*s/o)),c!==0&&(n.viewportExt.cy=Math.round(n.viewportExt.cy*a/c)),nn(n)}return!0}case Nx:{if(i>=24){const s=r.getInt32(e,!0),o=r.getInt32(e+4,!0),a=r.getInt32(e+8,!0),c=r.getInt32(e+12,!0);o!==0&&(n.windowExt.cx=Math.round(n.windowExt.cx*s/o)),c!==0&&(n.windowExt.cy=Math.round(n.windowExt.cy*a/c)),nn(n)}return!0}default:return!1}}function T2(n,t,e,i){const{view:r,state:s}=n;switch(t){case Dx:return i>=32&&(s.worldTransform=[r.getFloat32(e,!0),r.getFloat32(e+4,!0),r.getFloat32(e+8,!0),r.getFloat32(e+12,!0),r.getFloat32(e+16,!0),r.getFloat32(e+20,!0)]),!0;case Xx:{if(i>=36){const o=r.getUint32(e+24,!0);if(o===1)s.worldTransform=[1,0,0,1,0,0];else if(o===2||o===3){const a=[r.getFloat32(e,!0),r.getFloat32(e+4,!0),r.getFloat32(e+8,!0),r.getFloat32(e+12,!0),r.getFloat32(e+16,!0),r.getFloat32(e+20,!0)],[c,l,h,u,d,g]=s.worldTransform;o===2?s.worldTransform=[a[0]*c+a[1]*h,a[0]*l+a[1]*u,a[2]*c+a[3]*h,a[2]*l+a[3]*u,a[4]*c+a[5]*h+d,a[4]*l+a[5]*u+g]:s.worldTransform=[c*a[0]+l*a[2],c*a[1]+l*a[3],h*a[0]+u*a[2],h*a[1]+u*a[3],d*a[0]+g*a[2]+a[4],d*a[1]+g*a[3]+a[5]]}}return!0}default:return!1}}function L2(n,t,e,i){return I2(n,t,e,i)||T2(n,t,e,i)}function Yf(){return{penColor:"#000000",penWidth:1,penStyle:0,brushColor:"#ffffff",brushStyle:0,textColor:"#000000",bkColor:"#ffffff",bkMode:1,fontHeight:12,fontWeight:400,fontItalic:!1,fontFamily:"sans-serif",fontUnderline:!1,fontStrikeOut:!1,rop2:13,curX:0,curY:0,polyFillMode:1,textAlign:0,worldTransform:[1,0,0,1,0,0]}}function zf(n){return{...n,worldTransform:[...n.worldTransform]}}function Vf(){return{objectTable:new Map,worldTransform:[1,0,0,1,0,0],saveStack:[],saveIdMap:new Map,clipRegion:null,clipSaveDepth:0}}function M2(n,t,e,i,r){var c,l;if(L2(n,t,i,r)||E2(n,t,i,r))return!0;const{ctx:s,view:o,state:a}=n;switch(t){case Bx:{for(;n.clipSaveDepth>0;)s.restore(),n.clipSaveDepth--;return n.clipStack??(n.clipStack=[]),n.clipStack.push({region:n.clipRegion??null,untracked:n.clipUntracked??!1}),n.stateStack.push(zf(a)),s.save(),n.clipUntracked?(n.clipUntracked=!1,n.clipRegion=null):n.clipRegion&&Wn(n,n.clipRegion),!0}case Fx:{if(r>=12){for(;n.clipSaveDepth>0;)s.restore(),n.clipSaveDepth--;let h=o.getInt32(i,!0);for(h<0&&(h=n.stateStack.length+h+1);n.stateStack.length>h&&n.stateStack.length>0;)n.stateStack.pop(),(c=n.clipStack)==null||c.pop(),s.restore();const u=n.stateStack.pop();if(u){const d=(l=n.clipStack)==null?void 0:l.pop();Object.assign(a,u),s.restore(),n.clipRegion=(d==null?void 0:d.region)??null,n.clipUntracked=!1,n.clipRegion&&Wn(n,n.clipRegion)}}return!0}case Ex:return r>=12&&(a.textColor=_e(o,i)),!0;case Ix:return r>=12&&(a.bkColor=_e(o,i)),!0;case cx:return r>=12&&(a.bkMode=o.getUint32(i,!0)),!0;case lx:return r>=12&&(a.polyFillMode=o.getUint32(i,!0)),!0;case hx:return r>=12&&(a.rop2=o.getUint32(i,!0)),!0;case ux:case qx:case dh:return t===dh&&r>=12&&(a.textAlign=o.getUint32(i,!0)),!0;default:return!1}}function fh(n,t,e){return e?{x:n.getInt16(t,!0),y:n.getInt16(t+2,!0),w:n.getInt16(t+4,!0),h:n.getInt16(t+6,!0)}:{x:n.getFloat32(t,!0),y:n.getFloat32(t+4,!0),w:n.getFloat32(t+8,!0),h:n.getFloat32(t+12,!0)}}function ph(n,t,e){return e?{x:n.getInt16(t,!0),y:n.getInt16(t+2,!0)}:{x:n.getFloat32(t,!0),y:n.getFloat32(t+4,!0)}}function wc(n,t,e){if(e<12)return null;n.getUint32(t,!0);const i=n.getUint32(t+4,!0),r=n.getUint32(t+8,!0);if(i===0||i>1e5)return null;const s=(r&16384)!==0;if(12+(i*(s?4:8)+i)>e)return null;const h=[];let u=t+12;for(let f=0;f<i;f++)s?(h.push({x:n.getInt16(u,!0),y:n.getInt16(u+2,!0)}),u+=4):(h.push({x:n.getFloat32(u,!0),y:n.getFloat32(u+4,!0)}),u+=8);const d=u+3&-4,g=new Uint8Array(n.buffer,n.byteOffset+d,i);return{kind:"plus-path",points:h,types:new Uint8Array(g)}}function jf(n,t){const e=(c,l)=>t[0]*c+t[2]*l+t[4],i=(c,l)=>t[1]*c+t[3]*l+t[5],r=[],s=n.points,o=n.types;let a=0;for(;a<s.length;){const c=o[a]&15,l=(o[a]&128)!==0;if(c===0)r.push({op:"moveTo",x:e(s[a].x,s[a].y),y:i(s[a].x,s[a].y)}),a++;else if(c===3){if(a+2<s.length){r.push({op:"bezierCurveTo",cp1x:e(s[a].x,s[a].y),cp1y:i(s[a].x,s[a].y),cp2x:e(s[a+1].x,s[a+1].y),cp2y:i(s[a+1].x,s[a+1].y),x:e(s[a+2].x,s[a+2].y),y:i(s[a+2].x,s[a+2].y)}),(o[a+2]&128)!==0&&r.push({op:"closePath"}),a+=3;continue}break}else r.push({op:"lineTo",x:e(s[a].x,s[a].y),y:i(s[a].x,s[a].y)}),a++;l&&r.push({op:"closePath"})}return r}function mh(n,t){n.beginPath();const e=t.points,i=t.types;let r=0;for(;r<e.length;){const s=i[r]&15,o=(i[r]&128)!==0;if(s===0)n.moveTo(e[r].x,e[r].y),r++;else if(s===1)n.lineTo(e[r].x,e[r].y),r++;else if(s===3)if(r+2<e.length){n.bezierCurveTo(e[r].x,e[r].y,e[r+1].x,e[r+1].y,e[r+2].x,e[r+2].y),(i[r+2]&128)!==0&&n.closePath(),r+=3;continue}else break;else n.lineTo(e[r].x,e[r].y),r++;o&&n.closePath()}}function ze(n,t){return[n[0]*t[0]+n[1]*t[2],n[0]*t[1]+n[1]*t[3],n[2]*t[0]+n[3]*t[2],n[2]*t[1]+n[3]*t[3],n[4]*t[0]+n[5]*t[2]+t[4],n[4]*t[1]+n[5]*t[3]+t[5]]}function C2(n,t){const e=n.ctx;try{let i=null;if(t.type==="linear"&&typeof e.createLinearGradient=="function"){if(t.x1===t.x2&&t.y1===t.y2)return null;i=e.createLinearGradient(t.x1,t.y1,t.x2,t.y2)}else if(t.type==="radial"&&typeof e.createRadialGradient=="function"){if(!(t.r>0))return null;i=e.createRadialGradient(t.cx,t.cy,0,t.cx,t.cy,t.r)}if(!i)return null;for(const r of t.stops)i.addColorStop(r.offset,r.color);return i}catch{return null}}function cn(n,t,e){if(t&32768)return te(e);const i=n.objectTable.get(e&255);if(i&&i.kind==="plus-brush"){if(i.gradient){const r=C2(n,i.gradient);if(r)return r}return i.color}return"rgba(0,0,0,1)"}function ds(n,t){let i;switch(n){case 3:i=96/72;break;case 4:i=96;break;case 5:i=96/300;break;case 6:i=96/25.4;break;default:i=1;break}return i*t}function se(n){const t=n.worldTransform,e=ds(n.pageUnit,n.pageScale),i=n.dpiScale;n.ctx.setTransform(t[0]*e*i,t[1]*e*i,t[2]*e*i,t[3]*e*i,t[4]*e*i,t[5]*e*i)}function yh(n,t){n.saveStack.push({transform:[...n.worldTransform]}),n.saveIdMap.set(t,n.saveStack.length-1)}function bh(n,t){const e=n.saveIdMap.get(t);if(e!==void 0&&e<n.saveStack.length){n.worldTransform=[...n.saveStack[e].transform],n.saveStack.length=e;const i=new Map;for(const[r,s]of n.saveIdMap)s<e&&i.set(r,s);n.saveIdMap=i}}function _r(n){const t=n.worldTransform,e=ds(n.pageUnit,n.pageScale)*n.dpiScale;return[t[0]*e,t[1]*e,t[2]*e,t[3]*e,t[4]*e,t[5]*e]}function Uf(n,t,e,i,r){const s=(c,l)=>r[0]*c+r[2]*l+r[4],o=(c,l)=>r[1]*c+r[3]*l+r[5];return{cmds:[{op:"moveTo",x:s(n,t),y:o(n,t)},{op:"lineTo",x:s(n+e,t),y:o(n+e,t)},{op:"lineTo",x:s(n+e,t+i),y:o(n+e,t+i)},{op:"lineTo",x:s(n,t+i),y:o(n,t+i)},{op:"closePath"}],fillRule:"nonzero",simple:!0}}function O2(n,t){return{cmds:jf(n.path,t),fillRule:"nonzero",simple:!0}}var R2={0:"intersect",1:"intersect",2:"union",3:"xor",4:"exclude",5:"complement"},N2=64;function Pa(n,t,e=0){if(e>N2)return{region:[Fn()],exact:!1};switch(n.type){case"rect":return{region:[Uf(n.x,n.y,n.width,n.height,t)],exact:!0};case"path":return{region:[O2(n,t)],exact:!0};case"infinite":return{region:null,exact:!0};case"empty":return{region:[Fn()],exact:!0};case"combine":{const i=Pa(n.left,t,e+1),r=Pa(n.right,t,e+1),s=R2[n.combineMode]??"intersect",o=Ff(i.region,r.region,s);return{region:o.region,exact:o.exact&&i.exact&&r.exact}}}}var B2={0:"replace",1:"intersect",2:"union",3:"xor",4:"exclude",5:"complement"};function Sa(n){Wn(n,n.clipRegion??null,!0)}function Gf(n,t,e,i){const r=B2[e],s=Ff(n.clipRegion??null,t,r??"intersect");s.exact,n.clipRegion=s.region,Sa(n)}function _h(n,t,e,i){Gf(n,[t],e)}function F2(n,t,e,i,r){const{view:s}=n;switch(t){case Vw:return r>=24&&(n.worldTransform=[s.getFloat32(i,!0),s.getFloat32(i+4,!0),s.getFloat32(i+8,!0),s.getFloat32(i+12,!0),s.getFloat32(i+16,!0),s.getFloat32(i+20,!0)]),!0;case jw:return n.worldTransform=[1,0,0,1,0,0],!0;case Uw:{if(r>=24){const o=[s.getFloat32(i,!0),s.getFloat32(i+4,!0),s.getFloat32(i+8,!0),s.getFloat32(i+12,!0),s.getFloat32(i+16,!0),s.getFloat32(i+20,!0)];e&8192?n.worldTransform=ze(n.worldTransform,o):n.worldTransform=ze(o,n.worldTransform)}return!0}case Gw:{if(r>=8){const o=s.getFloat32(i,!0),a=s.getFloat32(i+4,!0),c=[1,0,0,1,o,a];e&8192?n.worldTransform=ze(n.worldTransform,c):n.worldTransform=ze(c,n.worldTransform)}return!0}case Hw:{if(r>=8){const o=s.getFloat32(i,!0),a=s.getFloat32(i+4,!0),c=[o,0,0,a,0,0];e&8192?n.worldTransform=ze(n.worldTransform,c):n.worldTransform=ze(c,n.worldTransform)}return!0}case Ww:{if(r>=4){const o=s.getFloat32(i,!0)*Math.PI/180,a=Math.cos(o),c=Math.sin(o),l=[a,c,-c,a,0,0];e&8192?n.worldTransform=ze(n.worldTransform,l):n.worldTransform=ze(l,n.worldTransform)}return!0}case Dw:return r>=4&&yh(n,s.getUint32(i,!0)),!0;case Xw:return r>=4&&bh(n,s.getUint32(i,!0)),!0;case Kw:{if(r>=16){const o=e>>8&15,a=s.getFloat32(i,!0),c=s.getFloat32(i+4,!0),l=s.getFloat32(i+8,!0),h=s.getFloat32(i+12,!0),u=Uf(a,c,l,h,_r(n));_h(n,u,o)}return!0}case qw:return n.clipRegion=null,Sa(n),!0;case Qw:{const o=e&255,a=e>>8&15,c=n.objectTable.get(o);if(c&&c.kind==="plus-region"&&c.nodes.length>0){const l=Pa(c.nodes[0],_r(n));l.exact,Gf(n,l.region,a)}return!0}case Zw:{const o=e&255,a=e>>8&15,c=n.objectTable.get(o);if(c&&c.kind==="plus-path"){const l={cmds:jf(c,_r(n)),fillRule:"nonzero",simple:!0};_h(n,l,a)}return!0}case tv:{if(r>=8){const o=s.getFloat32(i,!0),a=s.getFloat32(i+4,!0);if(n.clipRegion){const c=_r(n),l=c[0]*o+c[2]*a,h=c[1]*o+c[3]*a;n.clipRegion=Bf(n.clipRegion,l,h),Sa(n)}}return!0}case Yw:return r>=4&&yh(n,s.getUint32(i,!0)),!0;case zw:return r>=4&&bh(n,s.getUint32(i,!0)),!0;case $w:{const o=e&255,a=r>=4?s.getFloat32(i,!0):1;return n.pageUnit=o,n.pageScale=a,!0}case Ow:case Rw:case Nw:case Bw:case Fw:return!0;default:return!1}}function xr(n,t){n.strokeStyle=t.color,n.lineWidth=t.width;const e=t.width||1;switch(t.dashStyle){case 1:n.setLineDash([e*3,Number(e)]);break;case 2:n.setLineDash([Number(e),Number(e)]);break;case 3:n.setLineDash([e*3,Number(e),Number(e),Number(e)]);break;case 4:n.setLineDash([e*3,Number(e),Number(e),Number(e),Number(e),Number(e)]);break;default:n.setLineDash([]);break}}function D2(n,t,e,i,r){const{ctx:s,view:o,objectTable:a}=n;switch(t){case xw:{if(r>=8){const c=o.getUint32(i,!0),l=o.getUint32(i+4,!0),h=(e&16384)!==0,u=h?8:16;s.fillStyle=cn(n,e,c),se(n);let d=i+8;for(let g=0;g<l&&d+u<=i+r;g++){const{x:f,y:p,w:m,h:y}=fh(o,d,h);s.fillRect(f,p,m,y),d+=u}}return!0}case ww:{if(r>=4){const c=e&255,l=a.get(c),h=o.getUint32(i,!0),u=(e&16384)!==0,d=u?8:16;l&&l.kind==="plus-pen"&&xr(s,l),se(n);let g=i+4;for(let f=0;f<h&&g+d<=i+r;f++){const{x:p,y:m,w:y,h:b}=fh(o,g,u);s.strokeRect(p,m,y,b),g+=d}}return!0}case Pw:{if(r>=12){const c=o.getUint32(i,!0),l=(e&16384)!==0;let h,u,d,g;if(l)h=o.getInt16(i+4,!0),u=o.getInt16(i+6,!0),d=o.getInt16(i+8,!0),g=o.getInt16(i+10,!0);else{if(r<20)return!0;h=o.getFloat32(i+4,!0),u=o.getFloat32(i+8,!0),d=o.getFloat32(i+12,!0),g=o.getFloat32(i+16,!0)}s.fillStyle=cn(n,e,c),se(n),s.beginPath(),s.ellipse(h+d/2,u+g/2,Math.abs(d)/2,Math.abs(g)/2,0,0,Math.PI*2),s.fill()}return!0}case Sw:{const c=e&255,l=a.get(c),h=(e&16384)!==0;let u,d,g,f;if(h&&r>=8)u=o.getInt16(i,!0),d=o.getInt16(i+2,!0),g=o.getInt16(i+4,!0),f=o.getInt16(i+6,!0);else if(!h&&r>=16)u=o.getFloat32(i,!0),d=o.getFloat32(i+4,!0),g=o.getFloat32(i+8,!0),f=o.getFloat32(i+12,!0);else return!0;return l&&l.kind==="plus-pen"&&xr(s,l),se(n),s.beginPath(),s.ellipse(u+g/2,d+f/2,Math.abs(g)/2,Math.abs(f)/2,0,0,Math.PI*2),s.stroke(),!0}case Fo:case kw:case Ew:{const c=t===Fo;if(r<(c?12:8))return!0;let h=i;if(c){const P=o.getUint32(h,!0);s.fillStyle=cn(n,e,P),h+=4}const u=o.getFloat32(h,!0)*Math.PI/180,d=o.getFloat32(h+4,!0)*Math.PI/180;h+=8;const g=(e&16384)!==0;let f,p,m,y;if(g&&h+8<=i+r)f=o.getInt16(h,!0),p=o.getInt16(h+2,!0),m=o.getInt16(h+4,!0),y=o.getInt16(h+6,!0);else if(!g&&h+16<=i+r)f=o.getFloat32(h,!0),p=o.getFloat32(h+4,!0),m=o.getFloat32(h+8,!0),y=o.getFloat32(h+12,!0);else return!0;if(t!==Fo){const P=e&255,v=a.get(P);v&&v.kind==="plus-pen"&&xr(s,v)}se(n),s.beginPath();const b=f+m/2,w=p+y/2,x=Math.abs(m)/2,S=Math.abs(y)/2;return c&&s.moveTo(b,w),s.ellipse(b,w,x,S,0,u,u+d,d<0),c?(s.closePath(),s.fill()):s.stroke(),!0}case Aw:{if(r>=4){const c=e&255,l=a.get(c),h=o.getUint32(i,!0),u=(e&16384)!==0,d=u?4:8;l&&l.kind==="plus-pen"&&xr(s,l),se(n),s.beginPath();let g=i+4;for(let f=0;f<h&&g+d<=i+r;f++){const p=ph(o,g,u);f===0?s.moveTo(p.x,p.y):s.lineTo(p.x,p.y),g+=d}e&8192&&s.closePath(),s.stroke()}return!0}case vw:{if(r>=8){const c=o.getUint32(i,!0),l=o.getUint32(i+4,!0),h=(e&16384)!==0,u=h?4:8;s.fillStyle=cn(n,e,c),se(n),s.beginPath();let d=i+8;for(let g=0;g<l&&d+u<=i+r;g++){const f=ph(o,d,h);g===0?s.moveTo(f.x,f.y):s.lineTo(f.x,f.y),d+=u}s.closePath(),s.fill()}return!0}default:return!1}}var X2=1,Hf=2,Wf=4,$f=8,gs=4096;function qf(n){return n>>>12===900097}function Kf(n,t){return[n.getFloat32(t,!0),n.getFloat32(t+4,!0),n.getFloat32(t+8,!0),n.getFloat32(t+12,!0),n.getFloat32(t+16,!0),n.getFloat32(t+20,!0)]}function fs(n,t,e){return{x:n[0]*t+n[2]*e+n[4],y:n[1]*t+n[3]*e+n[5]}}function Y2(n){return Number.isFinite(n)?Math.min(1,Math.max(0,n)):0}function Zf(n){return n.map(t=>({offset:Y2(t.offset),color:t.color})).sort((t,e)=>t.offset-e.offset)}function Qf(n,t,e){if(t+4>e)return null;const i=n.getUint32(t,!0);if(i===0||i>gs)return null;const r=t+4,s=r+i*4,o=s+i*4;if(o>e)return null;const a=[];for(let c=0;c<i;c++)a.push({offset:n.getFloat32(r+c*4,!0),color:te(n.getUint32(s+c*4,!0))});return{stops:a,next:o}}function Jf(n,t,e){if(t+4>e)return null;const i=n.getUint32(t,!0);if(i===0||i>gs)return null;const r=t+4,s=r+i*4,o=s+i*4;if(o>e)return null;const a=[];for(let c=0;c<i;c++)a.push({pos:n.getFloat32(r+c*4,!0),factor:n.getFloat32(s+c*4,!0)});return{entries:a,next:o}}function z2(n,t,e){if(t+40>e)return null;const i=n.getUint32(t,!0),r=n.getFloat32(t+8,!0),s=n.getFloat32(t+12,!0),o=n.getFloat32(t+16,!0),a=n.getFloat32(t+20,!0),c=n.getUint32(t+24,!0),l=n.getUint32(t+28,!0);let h=t+40,u=null;i&Hf&&h+24<=e&&(u=Kf(n,h),h+=24);let d=[{offset:0,color:te(c)},{offset:1,color:te(l)}];if(i&Wf){const p=Qf(n,h,e);p&&(d=p.stops)}else if(i&$f){const p=Jf(n,h,e);p&&(d=p.entries.map(m=>({offset:m.pos,color:xf(c,l,m.factor)})))}let g={x:r,y:s+a/2},f={x:r+o,y:s+a/2};return u&&(g=fs(u,g.x,g.y),f=fs(u,f.x,f.y)),z(`parseEmfPlusBrushObject: linear gradient (${g.x.toFixed(1)},${g.y.toFixed(1)})→(${f.x.toFixed(1)},${f.y.toFixed(1)}), ${d.length} stop(s)`),{kind:"plus-brush",color:te(c),gradient:{type:"linear",x1:g.x,y1:g.y,x2:f.x,y2:f.y,stops:Zf(d)}}}function V2(n,t,e){if(t+24>e)return null;const i=n.getUint32(t,!0),r=n.getUint32(t+8,!0);let s=n.getFloat32(t+12,!0),o=n.getFloat32(t+16,!0);const a=n.getUint32(t+20,!0);if(a>gs)return{kind:"plus-brush",color:te(r)};const c=[];let l=t+24;for(let p=0;p<a&&l+4<=e;p++)c.push(n.getUint32(l,!0)),l+=4;let h=[];if(i&X2){if(l+4<=e){const p=n.getInt32(l,!0);if(l+=4,p>0&&l+p<=e){const m=wc(n,l,p);m&&(h=m.points),l+=p}}}else if(l+4<=e){const p=n.getUint32(l,!0);if(l+=4,p>0&&p<=gs&&l+p*8<=e){for(let m=0;m<p;m++)h.push({x:n.getFloat32(l+m*8,!0),y:n.getFloat32(l+m*8+4,!0)});l+=p*8}}let u=null;i&Hf&&l+24<=e&&(u=Kf(n,l),l+=24),u&&({x:s,y:o}=fs(u,s,o),h=h.map(p=>fs(u,p.x,p.y)));const d=c.length>0?c[0]:r;let g=[{offset:0,color:te(r)},{offset:1,color:te(d)}];if(i&Wf){const p=Qf(n,l,e);p&&(g=p.stops.map(m=>({offset:1-m.offset,color:m.color})))}else if(i&$f){const p=Jf(n,l,e);p&&(g=p.entries.map(m=>({offset:1-m.pos,color:xf(d,r,m.factor)})))}let f=0;for(const p of h){const m=Math.hypot(p.x-s,p.y-o);m>f&&(f=m)}return f>0?(z(`parseEmfPlusBrushObject: path gradient centre=(${s.toFixed(1)},${o.toFixed(1)}), r=${f.toFixed(1)}, ${g.length} stop(s)`),{kind:"plus-brush",color:te(r),gradient:{type:"radial",cx:s,cy:o,r:f,stops:Zf(g)}}):{kind:"plus-brush",color:te(r)}}function tp(n,t,e){if(e<8)return null;const i=t+e,r=qf(n.getUint32(t,!0)),s=t+(r?4:0);if(s+8>i)return null;const o=n.getUint32(s,!0),a=s+4;switch(o){case lv:return{kind:"plus-brush",color:te(n.getUint32(a,!0))};case hv:return a+8<=i?{kind:"plus-brush",color:te(n.getUint32(a+4,!0))}:{kind:"plus-brush",color:"rgba(0,0,0,1)"};case dv:return z2(n,a,i)??{kind:"plus-brush",color:"rgba(0,0,0,1)"};case uv:return V2(n,a,i)??{kind:"plus-brush",color:"rgba(0,0,0,1)"};default:return{kind:"plus-brush",color:"rgba(0,0,0,1)"}}}var j2=137224,U2=139273,G2=2498570,xh=925707;function H2(n,t,e,i,r,s){const o=Math.abs(r),a=r>0,l=e*4+3&-4,h=l*i,u=new Uint8Array(h);for(let b=0;b<i;b++){const w=a?b:i-1-b,x=t+w*o,S=(i-1-b)*l;switch(s){case G2:case xh:{for(let P=0;P<e;P++){const v=x+P*4;if(v+3>=n.byteLength)break;let k=n.getUint8(v),E=n.getUint8(v+1),O=n.getUint8(v+2);const N=n.getUint8(v+3);s===xh&&N>0&&N<255&&(O=Math.min(255,Math.round(O*255/N)),E=Math.min(255,Math.round(E*255/N)),k=Math.min(255,Math.round(k*255/N)));const R=S+P*4;u[R]=k,u[R+1]=E,u[R+2]=O,u[R+3]=N}break}case U2:{for(let P=0;P<e;P++){const v=x+P*4;if(v+3>=n.byteLength)break;const k=S+P*4;u[k]=n.getUint8(v),u[k+1]=n.getUint8(v+1),u[k+2]=n.getUint8(v+2),u[k+3]=255}break}case j2:{for(let P=0;P<e;P++){const v=x+P*3;if(v+2>=n.byteLength)break;const k=S+P*4;u[k]=n.getUint8(v),u[k+1]=n.getUint8(v+1),u[k+2]=n.getUint8(v+2),u[k+3]=255}break}default:return null}}const d=14,g=108,f=d+g+h,p=new ArrayBuffer(f),m=new DataView(p),y=new Uint8Array(p);return m.setUint8(0,66),m.setUint8(1,77),m.setUint32(2,f,!0),m.setUint32(6,0,!0),m.setUint32(10,d+g,!0),m.setUint32(14,g,!0),m.setInt32(18,e,!0),m.setInt32(22,i,!0),m.setUint16(26,1,!0),m.setUint16(28,32,!0),m.setUint32(30,3,!0),m.setUint32(34,h,!0),m.setInt32(38,2835,!0),m.setInt32(42,2835,!0),m.setUint32(46,0,!0),m.setUint32(50,0,!0),m.setUint32(54,16711680,!0),m.setUint32(58,65280,!0),m.setUint32(62,255,!0),m.setUint32(66,4278190080,!0),m.setUint32(70,1934772034,!0),y.set(u,d+g),p}function W2(n,t,e){if(e<20)return null;const i=qf(n.getUint32(t,!0)),r=n.getUint32(t+(i?8:4),!0),s=n.getFloat32(t+16,!0);let o=t+20;const a=[[1,4],[2,4],[4,4],[8,4],[16,4],[32,4],[64,4],[128,4]];let c=0;for(const[h,u]of a)r&h&&(h===1?o+=24:(h===32&&o+4<=t+e&&(c=n.getUint32(o,!0)),o+=u));if(r&256&&o+4<=t+e){const h=n.getUint32(o,!0);o+=4+h*4}if(r&512&&o+4<=t+e){const h=n.getUint32(o,!0);o+=4+h*4}if(r&1024&&o+4<=t+e){const h=n.getUint32(o,!0);o+=4+h}if(r&2048&&o+4<=t+e){const h=n.getUint32(o,!0);o+=4+h}let l="rgba(0,0,0,1)";if(o+8<=t+e){const h=tp(n,o,t+e-o);h&&(l=h.color)}return{kind:"plus-pen",color:l,width:s||1,dashStyle:c}}function $2(n,t,e,i){let r=null;const s=n.getUint32(t+4,!0);if(s===1&&e>=28){const o=n.getUint32(t+24,!0);if(o===1){const a=n.getInt32(t+8,!0),c=n.getInt32(t+12,!0),l=n.getInt32(t+16,!0),h=n.getUint32(t+20,!0);z(` Bitmap(Pixel): ${a}×${c}, stride=${l}, pixelFormat=0x${h.toString(16).padStart(8,"0")}`);const u=t+28,d=Math.abs(l);if(a>0&&c>0&&a<=8192&&c<=8192&&u+d*c<=n.byteLength){const g=H2(n,u,a,c,l,h);g&&(z(` Bitmap(Pixel): decoded successfully, size=${g.byteLength} bytes`),r=g)}}else if(o===2){const a=t+28,c=e-28;if(z(` Bitmap(Compressed): imgLen=${c}, imgStart=0x${a.toString(16)}`),c>0&&a+c<=n.byteLength&&(r=n.buffer.slice(n.byteOffset+a,n.byteOffset+a+c),r.byteLength>=4)){const l=new Uint8Array(r,0,4);z(` Bitmap(Compressed): first 4 bytes = [${Array.from(l).map(h=>h.toString(16).padStart(2,"0")).join(" ")}]`)}}}else if(s===2&&e>=12){n.getUint32(t+8,!0);const o=n.getUint32(t+12,!0),a=t+16;o>0&&a+o<=n.byteLength?(r=n.buffer.slice(n.byteOffset+a,n.byteOffset+a+o),r.byteLength>=4&&new DataView(r).getUint32(0,!0)):ve(` Metafile: out of bounds or empty (mfStart=0x${a.toString(16)}, mfDataSize=${o}, viewLen=${n.byteLength})`)}return{data:r,type:s}}function q2(n,t,e){if(e<28)return null;const i=n.getFloat32(t+4,!0),r=n.getInt32(t+12,!0),s=n.getUint32(t+20,!0);let o="sans-serif";return s>0&&t+24+s*2<=t+e&&(o=Yi(n,t+24,s)||"sans-serif"),{kind:"plus-font",emSize:i||12,flags:r,family:o}}function wh(n,t,e,i){const{view:r,objectTable:s}=n,o=t&255;switch(t>>8&127){case ev:{const c=tp(r,e,i);c&&s.set(o,c);break}case nv:{const c=W2(r,e,i);c&&s.set(o,c);break}case iv:{const c=wc(r,e,i);c&&s.set(o,c);break}case ov:{const c=q2(r,e,i);c&&s.set(o,c);break}case av:{if(i>=16){const c=r.getUint32(e+4,!0),l=r.getUint32(e+12,!0),h=r.getUint32(e+16,!0);s.set(o,{kind:"plus-stringformat",flags:c,alignment:l??0,lineAlignment:h??0})}break}case sv:{if(i<8)break;const c=$2(r,e,i);s.set(o,{kind:"plus-image",data:c.data,type:c.type}),n.totalImageObjects++;break}case rv:{s.set(o,{kind:"plus-imageattributes"});break}case cv:{const c=Z2(r,e,i);c&&s.set(o,c);break}}}var K2=64;function ka(n,t,e,i=0){if(t+4>e||i>K2)return null;const r=n.getUint32(t,!0);let s=t+4;if(r<=5){const o=ka(n,s,e,i+1);if(!o)return null;s+=o.bytesRead;const a=ka(n,s,e,i+1);return a?(s+=a.bytesRead,{node:{type:"combine",combineMode:r,left:o.node,right:a.node},bytesRead:s-t}):null}if(r===268435456){if(s+16>e)return null;const o=n.getFloat32(s,!0),a=n.getFloat32(s+4,!0),c=n.getFloat32(s+8,!0),l=n.getFloat32(s+12,!0);return{node:{type:"rect",x:o,y:a,width:c,height:l},bytesRead:s+16-t}}if(r===268435457){if(s+4>e)return null;const o=n.getInt32(s,!0);if(s+=4,o<=0||s+o>e)return null;const a=wc(n,s,o);return{node:a?{type:"path",path:a}:{type:"empty"},bytesRead:s+o-t}}return r===268435458?{node:{type:"empty"},bytesRead:4}:r===268435459?{node:{type:"infinite"},bytesRead:4}:(ve(`parseRegionNode: unknown node type 0x${r.toString(16)}`),{node:{type:"empty"},bytesRead:4})}function Z2(n,t,e){if(e<8)return null;n.getUint32(t,!0);const i=n.getUint32(t+4,!0);if(i===0||i>1e5)return null;const r=t+e,s=ka(n,t+8,r);return s?{kind:"plus-region",nodes:[s.node]}:null}function Q2(n,t,e,i,r){const{ctx:s,view:o,objectTable:a}=n;switch(t){case Iw:{if(r>=4){const c=o.getUint32(i,!0),l=e&255,h=a.get(l);h&&h.kind==="plus-path"&&(s.fillStyle=cn(n,e,c),se(n),mh(s,h),s.fill())}return!0}case Tw:{if(r>=4){const c=o.getUint32(i,!0),l=e&255,h=a.get(l),u=a.get(c&255);h&&h.kind==="plus-path"&&(u&&u.kind==="plus-pen"&&(s.strokeStyle=u.color,s.lineWidth=u.width),se(n),mh(s,h),s.stroke())}return!0}case Cw:{if(r>=28){const c=o.getUint32(i,!0),l=o.getUint32(i+4,!0),h=o.getUint32(i+8,!0),u=o.getFloat32(i+12,!0),d=o.getFloat32(i+16,!0);o.getFloat32(i+20,!0),o.getFloat32(i+24,!0);const g=e&255,f=a.get(g);if(h>0&&i+28+h*2<=i+r){const p=Yi(o,i+28,h);if(p.length>0&&f&&f.kind==="plus-font"){const m=f.flags&1?"bold ":"",y=f.flags&2?"italic ":"",b=wa(f.family,n.fontFamilyMap);s.font=`${y}${m}${f.emSize}px ${b}`,s.fillStyle=cn(n,e,c),s.textBaseline="top";const w=a.get(l);if(w&&w.kind==="plus-stringformat")switch(w.alignment){case 1:s.textAlign="center";break;case 2:s.textAlign="right";break;default:s.textAlign="left"}else s.textAlign="left";se(n),s.fillText(p,u,d)}}}return!0}case Jw:{if(r>=16){const c=o.getUint32(i,!0),l=o.getUint32(i+12,!0),h=e&255,u=a.get(h),d=i+16,f=d+l*2+3&-4;if(l>0&&l<1e5&&f+l*8<=i+r&&u&&u.kind==="plus-font"){const p=Yi(o,d,l);if(p.length>0){const m=u.flags&1?"bold ":"",y=u.flags&2?"italic ":"",b=wa(u.family,n.fontFamilyMap);s.font=`${y}${m}${u.emSize}px ${b}`,s.fillStyle=cn(n,e,c),s.textBaseline="alphabetic",s.textAlign="left",se(n);const w=o.getFloat32(f,!0),x=o.getFloat32(f+4,!0);s.fillText(p,w,x)}}}return!0}case Lw:{if(r>=24){const c=e&255,l=a.get(c),h=(e&16384)!==0,u=i+24;let d,g,f,p;if(h&&u+8<=i+r)d=o.getInt16(u,!0),g=o.getInt16(u+2,!0),f=o.getInt16(u+4,!0),p=o.getInt16(u+6,!0);else if(!h&&u+16<=i+r)d=o.getFloat32(u,!0),g=o.getFloat32(u+4,!0),f=o.getFloat32(u+8,!0),p=o.getFloat32(u+12,!0);else return!0;n.totalDrawImageCalls++;const m=l&&l.kind==="plus-image"&&l.data;if(z(`DrawImage: imgId=${c}, dest=(${d},${g},${f},${p}), compressed=${h}, hasObj=${!!l}, objKind=${l==null?void 0:l.kind}, hasData=${!!m}, dataLen=${m?l.data.byteLength:0}, isMetafile=${(l==null?void 0:l.kind)==="plus-image"?l.type===2:"N/A"}`),z(`DrawImage: worldTransform=[${n.worldTransform.map(y=>y.toFixed(3)).join(", ")}]`),l&&l.kind==="plus-image"&&l.data){const y=n.worldTransform,b=ds(n.pageUnit,n.pageScale)*n.dpiScale;n.deferredImages.push({imageData:l.data,dx:d,dy:g,dw:f,dh:p,transform:[y[0]*b,y[1]*b,y[2]*b,y[3]*b,y[4]*b,y[5]*b],isMetafile:l.type===2}),z(`DrawImage: queued deferred image (total=${n.deferredImages.length})`)}}return!0}case Mw:{if(r>=28){const c=e&255,l=a.get(c),h=o.getUint32(i+24,!0),u=(e&16384)!==0,d=i+28;if(h>=3&&l&&l.kind==="plus-image"&&l.data){let g,f,p,m,y,b;if(u&&d+12<=i+r)g=o.getInt16(d,!0),f=o.getInt16(d+2,!0),p=o.getInt16(d+4,!0),m=o.getInt16(d+6,!0),y=o.getInt16(d+8,!0),b=o.getInt16(d+10,!0);else if(!u&&d+24<=i+r)g=o.getFloat32(d,!0),f=o.getFloat32(d+4,!0),p=o.getFloat32(d+8,!0),m=o.getFloat32(d+12,!0),y=o.getFloat32(d+16,!0),b=o.getFloat32(d+20,!0);else return!0;const w=g,x=f,S=Math.sqrt((p-g)**2+(m-f)**2),P=Math.sqrt((y-g)**2+(b-f)**2);n.totalDrawImageCalls++,z(`DrawImagePoints: imgId=${c}, points=[(${g},${f}),(${p},${m}),(${y},${b})], dest=(${w.toFixed(1)},${x.toFixed(1)},${S.toFixed(1)},${P.toFixed(1)})`),z(`DrawImagePoints: worldTransform=[${n.worldTransform.map(E=>E.toFixed(3)).join(", ")}]`);const v=n.worldTransform,k=ds(n.pageUnit,n.pageScale)*n.dpiScale;n.deferredImages.push({imageData:l.data,dx:w,dy:x,dw:S,dh:P,transform:[v[0]*k,v[1]*k,v[2]*k,v[3]*k,v[4]*k,v[5]*k],isMetafile:l.type===2}),z(`DrawImagePoints: queued deferred image (total=${n.deferredImages.length})`)}else l&&l.kind==="plus-image"&&l.data}return!0}default:return!1}}var J2={16385:"Header",16386:"EndOfFile",16388:"GetDC",16392:"Object",16394:"FillRects",16395:"DrawRects",16396:"FillPolygon",16397:"DrawLines",16398:"FillEllipse",16399:"DrawEllipse",16404:"FillPath",16405:"DrawPath",16410:"DrawImage",16411:"DrawImagePoints",16412:"DrawString",16438:"DrawDriverString",16414:"SetAntiAliasMode",16426:"SetWorldTransform",16427:"ResetWorldTransform",16428:"MultiplyWorldTransform",16432:"SetPageTransform",16433:"ResetClip",16434:"SetClipRect",16435:"SetClipPath",16436:"SetClipRegion",16437:"OffsetClip",16421:"Save",16422:"Restore",16424:"BeginContainerNoParams",16425:"EndContainer"};function tA(n,t,e,i,r,s,o,a=1,c=kf,l){const h=o??Vf(),u={ctx:i,view:n,objectTable:h.objectTable,worldTransform:h.worldTransform,deferredImages:[],saveStack:h.saveStack,saveIdMap:h.saveIdMap,totalImageObjects:0,totalDrawImageCalls:0,clipSaveDepth:h.clipSaveDepth,clipRegion:h.clipRegion,pageUnit:2,pageScale:1,continuationBuffer:null,continuationObjectId:-1,continuationObjectType:0,continuationTotalSize:0,continuationOffset:0,dpiScale:a,fontFamilyMap:l},d=t+e;let g=0;const f=new Map;for(z(`replayEmfPlusRecords: offset=0x${t.toString(16)}, length=${e}`);t+12<=d&&g<c;){const m=n.getUint16(t,!0),y=n.getUint16(t+2,!0),b=n.getUint32(t+4,!0),w=n.getUint32(t+8,!0);if(b<12||t+b>d)break;g++,f.set(m,(f.get(m)??0)+1);const x=t+12;switch(m){case mw:{w>=16&&(n.getFloat32(x+8,!0),n.getFloat32(x+12,!0));break}case yw:t=d;continue;case bw:break;case _w:{const S=(y&32768)!==0,P=y&255;if(S)if(u.continuationBuffer===null){if(w>=4){const v=n.getUint32(x,!0),k=y>>8&127,E=64*1024*1024,O=n.byteLength-x;if(!(!Number.isFinite(v)||v<=0||v>E||v>O||w-4<0)){u.continuationTotalSize=v,u.continuationObjectId=P,u.continuationObjectType=k,u.continuationBuffer=new Uint8Array(v);const N=w-4,R=new Uint8Array(n.buffer,n.byteOffset+x+4,Math.min(N,v));u.continuationBuffer.set(R,0),u.continuationOffset=R.length}}}else{const v=u.continuationTotalSize-u.continuationOffset,k=new Uint8Array(n.buffer,n.byteOffset+x,Math.min(w,v));u.continuationBuffer.set(k,u.continuationOffset),u.continuationOffset+=k.length}else if(u.continuationBuffer!==null&&P===u.continuationObjectId){const v=u.continuationTotalSize-u.continuationOffset,k=new Uint8Array(n.buffer,n.byteOffset+x,Math.min(w,v));u.continuationBuffer.set(k,u.continuationOffset);const E=new DataView(u.continuationBuffer.buffer,u.continuationBuffer.byteOffset,u.continuationBuffer.byteLength),O=u.continuationObjectType<<8|P;wh({...u,view:E},O,0,u.continuationTotalSize),u.continuationBuffer=null,u.continuationObjectId=-1,u.continuationObjectType=0,u.continuationTotalSize=0,u.continuationOffset=0}else wh(u,y,x,w);break}default:{const S=D2(u,m,y,x,w)||Q2(u,m,y,x,w)||F2(u,m,y,x,w);break}}t+=b}g>=c;const p=[];for(const[m,y]of f)p.push(`${J2[m]??`0x${m.toString(16)}`}:${y}`);return z(`replayEmfPlusRecords: totalImageObjects=${u.totalImageObjects}, totalDrawImageCalls=${u.totalDrawImageCalls}, deferredImages=${u.deferredImages.length}`),z(`replayEmfPlusRecords: object table has ${u.objectTable.size} entries: [${Array.from(u.objectTable.entries()).map(([m,y])=>`${m}:${y.kind}`).join(", ")}]`),o&&(o.worldTransform=u.worldTransform,o.saveIdMap=u.saveIdMap,o.clipRegion=u.clipRegion??null,o.clipSaveDepth=u.clipSaveDepth),i.setTransform(1,0,0,1,0,0),u.deferredImages}var eA={1:"EMR_HEADER",2:"EMR_POLYBEZIER",3:"EMR_POLYGON",4:"EMR_POLYLINE",5:"EMR_POLYBEZIERTO",6:"EMR_POLYLINETO",14:"EMR_EOF",27:"EMR_MOVETOEX",37:"EMR_SELECTOBJECT",38:"EMR_CREATEPEN",39:"EMR_CREATEBRUSHINDIRECT",40:"EMR_DELETEOBJECT",42:"EMR_ELLIPSE",43:"EMR_RECTANGLE",54:"EMR_LINETO",59:"EMR_BEGINPATH",60:"EMR_ENDPATH",62:"EMR_FILLPATH",63:"EMR_STROKEANDFILLPATH",64:"EMR_STROKEPATH",70:"EMR_COMMENT",76:"EMR_BITBLT",81:"EMR_STRETCHDIBITS",84:"EMR_EXTTEXTOUTW",85:"EMR_POLYBEZIER16",86:"EMR_POLYGON16",87:"EMR_POLYLINE16",88:"EMR_POLYBEZIERTO16",91:"EMR_POLYPOLYGON16"};function nA(n,t,e,i,r,s=1,o={}){z(`replayEmfRecords: bounds=(${e.left},${e.top})→(${e.right},${e.bottom}), canvas=${i}×${r}`);const a=[],c=Vf(),l=o.maxRecords??Sf,h=o.maxRecordsEmfPlus??kf,u=e.right-e.left||1,d=e.bottom-e.top||1,g=i/u,f=r/d;z(`replayEmfRecords: logical=${u}×${d}, scale=(${g.toFixed(4)},${f.toFixed(4)})`);const p={ctx:t,view:n,objectTable:new Map,state:{...Yf(),fontFamilyMap:o.fontFamilyMap},stateStack:[],inPath:!1,windowOrg:{x:e.left,y:e.top},windowExt:{cx:u,cy:d},viewportOrg:{x:0,y:0},viewportExt:{cx:i,cy:r},useMappingMode:!1,clipSaveDepth:0,bounds:e,canvasW:i,canvasH:r,sx:g,sy:f};let m=0;const y=n.byteLength;let b=0,w=0;const x=new Map;for(;m+8<=y&&b<l;){const S=n.getUint32(m,!0),P=n.getUint32(m+4,!0);if(P<8||m+P>y)break;b++;const v=m+8;if(x.set(S,(x.get(S)??0)+1),S===iw){if(P>=16){const E=n.getUint32(v,!0),O=n.getUint32(v+4,!0);if(O===fw&&E>4){w++,z(`replayEmfRecords: EMF+ comment #${w} at offset 0x${m.toString(16)}, dataSize=${E}`);const N=tA(n,v+8,E-4,t,i,r,c,s,h,o.fontFamilyMap);z(`replayEmfRecords: EMF+ comment #${w} returned ${N.length} deferred images`),a.push(...N)}else z(O===pw?`replayEmfRecords: EMR_COMMENT_PUBLIC at offset 0x${m.toString(16)}, size=${E}`:`replayEmfRecords: EMR_COMMENT (sig=0x${O.toString(16).padStart(8,"0")}) at offset 0x${m.toString(16)}, size=${E}`)}m+=P;continue}if(S===sx){const E=[];for(const[O,N]of x)E.push(`${eA[O]??`0x${O.toString(16)}`}:${N}`);z(`replayEmfRecords: total deferred images = ${a.length}, EMF+ object table size = ${c.objectTable.size}`);break}if(S===rx||S===Mx||S===dw||S===gw||S===wf){m+=P;continue}const k=M2(p,S,m,v,P)||x2(p,S,m,v,P)||k2(p,S,m,v,P);m+=P}return b>=l,a}function iA(n,t,e,i,r){const{ctx:s,view:o,state:a,coord:c}=n,{mx:l,my:h,mw:u,mh:d}=c;switch(t){case vv:return r>=10&&(a.curY=o.getInt16(i,!0),a.curX=o.getInt16(i+2,!0)),!0;case Av:if(r>=10){const g=o.getInt16(i,!0),f=o.getInt16(i+2,!0);ft(s,a),s.beginPath(),s.moveTo(l(a.curX),h(a.curY)),s.lineTo(l(f),h(g)),s.stroke(),a.curX=f,a.curY=g}return!0;case Pv:if(r>=14){const g=o.getInt16(i,!0),f=o.getInt16(i+2,!0),p=o.getInt16(i+4,!0),m=o.getInt16(i+6,!0);Mt(s,a),s.fillRect(l(m),h(p),u(f-m),d(g-p)),ft(s,a),s.strokeRect(l(m),h(p),u(f-m),d(g-p))}return!0;case Sv:if(r>=18){const g=Math.abs(d(o.getInt16(i,!0)))/2,f=Math.abs(u(o.getInt16(i+2,!0)))/2,p=o.getInt16(i+4,!0),m=o.getInt16(i+6,!0),y=o.getInt16(i+8,!0),b=o.getInt16(i+10,!0),w=l(b),x=h(y),S=u(m-b),P=d(p-y),v=Math.min(f,g,S/2,P/2);s.beginPath(),s.moveTo(w+v,x),s.lineTo(w+S-v,x),s.arcTo(w+S,x,w+S,x+v,v),s.lineTo(w+S,x+P-v),s.arcTo(w+S,x+P,w+S-v,x+P,v),s.lineTo(w+v,x+P),s.arcTo(w,x+P,w,x+P-v,v),s.lineTo(w,x+v),s.arcTo(w,x,w+v,x,v),s.closePath(),Mt(s,a),s.fill(),ft(s,a),s.stroke()}return!0;case kv:if(r>=14){const g=o.getInt16(i,!0),f=o.getInt16(i+2,!0),p=o.getInt16(i+4,!0),m=o.getInt16(i+6,!0);s.beginPath(),s.ellipse(l((m+f)/2),h((p+g)/2),Math.abs(u(f-m))/2,Math.abs(d(g-p))/2,0,0,Math.PI*2),Mt(s,a),s.fill(),ft(s,a),s.stroke()}return!0;case Ev:case mr:case Do:if(r>=22){const g=o.getInt16(i,!0),f=o.getInt16(i+2,!0),p=o.getInt16(i+4,!0),m=o.getInt16(i+6,!0),y=o.getInt16(i+8,!0),b=o.getInt16(i+10,!0),w=o.getInt16(i+12,!0),x=o.getInt16(i+14,!0),S=(x+b)/2,P=(w+y)/2,v=Math.abs(b-x)/2,k=Math.abs(y-w)/2,E=Math.atan2((p-P)/(k||1),(m-S)/(v||1)),O=Math.atan2((g-P)/(k||1),(f-S)/(v||1));s.beginPath(),t===mr&&s.moveTo(l(S),h(P)),s.ellipse(l(S),h(P),Math.abs(u(v)),Math.abs(d(k)),0,E,O,!1),(t===mr||t===Do)&&s.closePath(),(t===mr||t===Do)&&(Mt(s,a),s.fill()),ft(s,a),s.stroke()}return!0;case Iv:if(r>=10){const g=o.getInt16(i,!0);if(g>0&&i+2+g*4<=e+r){s.beginPath();for(let f=0;f<g;f++){const p=o.getInt16(i+2+f*4,!0),m=o.getInt16(i+4+f*4,!0);f===0?s.moveTo(l(p),h(m)):s.lineTo(l(p),h(m))}s.closePath(),Mt(s,a),s.fill(a.polyFillMode===2?"nonzero":"evenodd"),ft(s,a),s.stroke()}}return!0;case Tv:if(r>=10){const g=o.getInt16(i,!0);if(g>0&&i+2+g*4<=e+r){s.beginPath();for(let f=0;f<g;f++){const p=o.getInt16(i+2+f*4,!0),m=o.getInt16(i+4+f*4,!0);f===0?s.moveTo(l(p),h(m)):s.lineTo(l(p),h(m))}ft(s,a),s.stroke()}}return!0;case Xv:if(r>=10){const g=o.getUint16(i,!0);let f=i+2;const p=[];for(let m=0;m<g&&f+2<=e+r;m++)p.push(o.getInt16(f,!0)),f+=2;s.beginPath();for(const m of p)if(m>0&&f+m*4<=e+r){for(let y=0;y<m;y++){const b=o.getInt16(f+y*4,!0),w=o.getInt16(f+y*4+2,!0);y===0?s.moveTo(l(b),h(w)):s.lineTo(l(b),h(w))}s.closePath(),f+=m*4}Mt(s,a),s.fill(a.polyFillMode===2?"nonzero":"evenodd"),ft(s,a),s.stroke()}return!0;case Nv:if(r>=12){const g=o.getInt16(i,!0);if(g>0&&i+2+g<=e+r){let f="";for(let y=0;y<g;y++){const b=o.getUint8(i+2+y);if(b===0)break;f+=String.fromCharCode(b)}const p=g+g%2,m=i+2+p;if(m+4<=e+r){const y=o.getInt16(m,!0),b=o.getInt16(m+2,!0);va(s,a,Math.abs(d(1))),s.fillStyle=a.textColor,s.fillText(f,l(b),h(y))}}}return!0;case Bv:if(r>=14){const g=o.getInt16(i,!0),f=o.getInt16(i+2,!0),p=o.getInt16(i+4,!0),m=(o.getUint16(i+6,!0)&4)!==0,y=i+8+(m?8:0);if(p>0&&y+p<=e+r){let b="";for(let w=0;w<p;w++){const x=o.getUint8(y+w);if(x===0)break;b+=String.fromCharCode(x)}va(s,a,Math.abs(d(1))),s.fillStyle=a.textColor,s.fillText(b,l(f),h(g))}}return!0;default:return!1}}function rA(n,t,e,i){return{mx:r=>(r-n.x)/(t.cx||1)*e,my:r=>(r-n.y)/(t.cy||1)*i,mw:r=>r/(t.cx||1)*e,mh:r=>r/(t.cy||1)*i}}function sA(n,t,e,i,r,s={}){const o=e.boundsRight-e.boundsLeft||1,a=e.boundsBottom-e.boundsTop||1,c={x:e.boundsLeft,y:e.boundsTop},l={cx:o,cy:a},h=rA(c,l,i,r),u=new Map,d=()=>{let x=0;for(;u.has(x);)x++;return x},g={...Yf(),fontFamilyMap:s.fontFamilyMap},f=[],p={view:n,ctx:t,state:g,coord:h};let m=e.headerSize;const y=n.byteLength,b=s.maxRecords??Sf;let w=0;for(;m+6<=y&&w<b;){const x=n.getUint32(m,!0),S=n.getUint16(m+4,!0),P=x*2;if(P<6||m+P>y||S===gv)break;w++;const v=m+6;if(iA(p,S,m,v,P)){m+=P;continue}switch(S){case xv:P>=10&&(c.y=n.getInt16(v,!0),c.x=n.getInt16(v+2,!0));break;case wv:P>=10&&(l.cy=n.getInt16(v,!0),l.cx=n.getInt16(v+2,!0));break;case Fv:f.push(zf(g));break;case Dv:{const k=f.pop();k&&Object.assign(g,k);break}case bv:P>=10&&(g.textColor=_e(n,v));break;case fv:P>=10&&(g.bkColor=_e(n,v));break;case pv:P>=8&&(g.bkMode=n.getUint16(v,!0));break;case mv:P>=8&&(g.rop2=n.getUint16(v,!0));break;case yv:P>=8&&(g.polyFillMode=n.getUint16(v,!0));break;case _v:P>=8&&(g.textAlign=n.getUint16(v,!0));break;case Cv:if(P>=16){const k=d();u.set(k,{kind:"pen",style:n.getUint16(v,!0)&255,widthX:n.getInt16(v+2,!0),color:_e(n,v+6)})}break;case Ov:if(P>=14){const k=d();u.set(k,{kind:"brush",style:n.getUint16(v,!0),color:_e(n,v+2)})}break;case Rv:if(P>=24){let k="";for(let O=0;O<32&&v+14+O<m+P;O++){const N=n.getUint8(v+14+O);if(N===0)break;k+=String.fromCharCode(N)}const E=d();u.set(E,{kind:"font",height:Math.abs(n.getInt16(v,!0)),weight:n.getInt16(v+8,!0),italic:n.getUint8(v+10)!==0,underline:n.getUint8(v+11)!==0,strikeOut:n.getUint8(v+12)!==0,family:k||"sans-serif"})}break;case Lv:if(P>=8){const k=u.get(n.getUint16(v,!0));if(k)switch(k.kind){case"pen":g.penStyle=k.style,g.penWidth=k.widthX,g.penColor=k.color;break;case"brush":g.brushStyle=k.style,g.brushColor=k.color;break;case"font":g.fontHeight=k.height,g.fontWeight=k.weight,g.fontItalic=k.italic,g.fontUnderline=k.underline,g.fontStrikeOut=k.strikeOut,g.fontFamily=k.family;break}}break;case Mv:P>=8&&u.delete(n.getUint16(v,!0));break}m+=P}w>=b}var ps=3;async function oA(n,t,e=0){z(`processDeferredImages: processing ${t.length} deferred images (recursionDepth=${e})...`);for(let i=0;i<t.length;i++){const r=t[i];z(` Deferred image [${i}]: isMetafile=${r.isMetafile}, dataLen=${r.imageData.byteLength}, dest=(${r.dx.toFixed(1)},${r.dy.toFixed(1)},${r.dw.toFixed(1)},${r.dh.toFixed(1)}), transform=[${r.transform.map(s=>s.toFixed(3)).join(",")}]`);try{const s=new ArrayBuffer(r.imageData.byteLength);if(new Uint8Array(s).set(new Uint8Array(r.imageData)),n.setTransform(r.transform[0],r.transform[1],r.transform[2],r.transform[3],r.transform[4],r.transform[5]),r.isMetafile){if(e>=ps){ve(` Deferred image [${i}]: skipping embedded metafile — recursion depth ${e} >= ${ps}`);continue}z(` Deferred image [${i}]: recursively converting embedded metafile...`);const a=await Ea(s,void 0,e+1)??await Ia(s,void 0,e+1);if(a){z(` Deferred image [${i}]: metafile converted, dataUrl length=${a.length}`);const c=atob(a.split(",")[1]),l=a.match(/data:([^;]+)/),h=l?l[1]:"image/png",u=new ArrayBuffer(c.length),d=new Uint8Array(u);for(let p=0;p<c.length;p++)d[p]=c.charCodeAt(p);const g=new Blob([u],{type:h});z(` Deferred image [${i}]: creating ImageBitmap from ${g.size} byte blob (${h})...`);const f=await createImageBitmap(g);z(` Deferred image [${i}]: ImageBitmap created ${f.width}×${f.height}`),n.drawImage(f,r.dx,r.dy,r.dw,r.dh),f.close()}else ve(` Deferred image [${i}]: metafile conversion returned null`)}else{z(` Deferred image [${i}]: creating ImageBitmap from ${s.byteLength} byte blob...`);const a=new Blob([s]),c=await createImageBitmap(a);z(` Deferred image [${i}]: ImageBitmap created ${c.width}×${c.height}`),n.drawImage(c,r.dx,r.dy,r.dw,r.dh),c.close()}}catch(s){s instanceof Error?s.message:String(s)}}n.setTransform(1,0,0,1,0,0)}async function Ea(n,t,e=0){if(e>ps)return null;const i=t??{},r=i.dpiScale??bc,s=i.maxWidth,o=i.maxHeight,a={maxRecords:i.maxRecords,maxRecordsEmfPlus:i.maxRecords,fontFamilyMap:i.fontFamilyMap};try{if(z("=== convertEmfToDataUrl START ==="),z(`Input buffer: ${n.byteLength} bytes, maxWidth=${s}, maxHeight=${o}, dpiScale=${r}`),n.byteLength>=16){const b=new Uint8Array(n,0,16);z(`First 16 bytes: [${Array.from(b).map(w=>w.toString(16).padStart(2,"0")).join(" ")}]`)}const c=new DataView(n),l=Uv(c);if(!l)return z("convertEmfToDataUrl: parseEmfHeader returned null — returning null"),null;const h=Gv(l);if(!h)return z("convertEmfToDataUrl: getRenderableEmfBounds returned null — returning null"),null;const u=h.right-h.left,d=h.bottom-h.top;z(`convertEmfToDataUrl: logicalSize=${u}×${d}`);const g=Mf(u,d,s,o,r,i.maxCanvasDimension);if(!g)return z("convertEmfToDataUrl: createCanvas returned null — returning null"),null;const{canvas:f,ctx:p}=g;z(`convertEmfToDataUrl: canvas created ${f.width}×${f.height} (dpiScale=${r})`),p.save(),z("convertEmfToDataUrl: starting replayEmfRecords...");const m=nA(c,p,h,f.width,f.height,r,a);z(`convertEmfToDataUrl: replayEmfRecords returned ${m.length} deferred images`),p.restore(),await oA(p,m),z("convertEmfToDataUrl: exporting canvas to PNG data URL...");const y=await Nf(f);return y?z(`convertEmfToDataUrl: SUCCESS — data URL length=${y.length}`):ve("convertEmfToDataUrl: exportCanvasToPngDataUrl returned null"),z("=== convertEmfToDataUrl END ==="),y}catch(c){return ve("convertEmfToDataUrl: EXCEPTION:",c instanceof Error?c.message:c),null}}async function Ia(n,t,e=0){if(e>ps)return null;const i=t??{},r=i.dpiScale??bc,s=i.maxWidth,o=i.maxHeight,a={maxRecords:i.maxRecords,fontFamilyMap:i.fontFamilyMap};try{z("=== convertWmfToDataUrl START ===",`buffer=${n.byteLength} bytes, dpiScale=${r}`);const c=new DataView(n),l=Hv(c);if(!l)return z("convertWmfToDataUrl: parseWmfHeader returned null"),null;const h=l.boundsRight-l.boundsLeft,u=l.boundsBottom-l.boundsTop;if(z(`convertWmfToDataUrl: logicalSize=${h}×${u}`),h<=0||u<=0)return z("convertWmfToDataUrl: invalid dimensions — returning null"),null;const d=Mf(h,u,s,o,r,i.maxCanvasDimension);if(!d)return null;const{canvas:g,ctx:f}=d;f.save(),sA(c,f,l,g.width,g.height,a),f.restore();const p=await Nf(g);return z(`convertWmfToDataUrl: result=${p?`dataUrl len=${p.length}`:"null"}`),z("=== convertWmfToDataUrl END ==="),p}catch(c){return ve("convertWmfToDataUrl: EXCEPTION:",c instanceof Error?c.message:c),null}}async function aA(n,t={}){const e=n instanceof Uint8Array?n:new Uint8Array(await n.arrayBuffer());if(!e.length)return;const i=n instanceof Blob&&yc(n.type)?n.type:void 0,r={maxWidth:t.maxWidth,maxHeight:t.maxHeight,dpiScale:t.dpiScale??1,maxCanvasDimension:t.maxCanvasDimension,fontFamilyMap:t.fontFamilyMap},s=e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength),o=i===Bn||i==null&&ts(e)&&!we(e);let a=null;if(o?(a=await Ea(s,r),!a&&we(e)&&(a=await Ia(s,r))):((i===Ri||we(e))&&(a=await Ia(s,r)),!a&&ts(e)&&(a=await Ea(s,r))),!!a)return lA(a)}function cA(n){return yc(n.type)}function wr(n){const t=n.indexOf(",");if(!n.startsWith("data:")||t<0)return;const e=n.slice(5,t),i=n.slice(t+1),r=e.split(";"),s=r[0]||"image/png";if(r.includes("base64")){const c=atob(i),l=new Uint8Array(c.length);for(let h=0;h<c.length;h++)l[h]=c.charCodeAt(h);return new Blob([l],{type:s})}const a=decodeURIComponent(i);return new Blob([a],{type:s})}async function lA(n){const t=hA();if(!t)return wr(n);try{const e=await t.decodeImage(n),i=Math.max(1,e.width),r=Math.max(1,e.height),s=t.createCanvas(i,r),o=s.getContext("2d");if(!o)return wr(n);if(o.fillStyle="#ffffff",o.fillRect(0,0,i,r),o.drawImage(e,0,0),s instanceof OffscreenCanvas)return await s.convertToBlob({type:"image/png"});const a=s;if(typeof a.toBlob=="function")return await new Promise(c=>{a.toBlob(l=>c(l||void 0),"image/png")});if(typeof a.toDataURL=="function")return wr(a.toDataURL("image/png"))}catch{}return wr(n)}function hA(){if(typeof OffscreenCanvas<"u")return{createCanvas:(n,t)=>new OffscreenCanvas(n,t),decodeImage:async n=>{const e=await(await fetch(n)).blob();return createImageBitmap(e)}};if(typeof document<"u"&&document.createElement)return{createCanvas:(n,t)=>{const e=document.createElement("canvas");return e.width=n,e.height=t,e},decodeImage:n=>new Promise((t,e)=>{const i=new Image;i.onload=()=>t(i),i.onerror=()=>e(new Error("Failed to decode PNG")),i.src=n})}}class vc{parse(t){const i=this.normalizeLineEndings(t).split(`
15
15
  `),r=[],s=[];let o=null;return i.forEach((a,c)=>{const l=c+1,h=this.stripInlineComment(a).trim();if(!h)return;if(h.startsWith("*")){this.flushCurrentPattern(o,r,s);const d=this.parseHeader(h.slice(1));if(!d){s.push({line:l,message:"Invalid pattern header.",source:a}),o=null;return}o={pattern:{name:d.name,description:d.description,lines:[]},headerLine:l};return}if(!o){s.push({line:l,message:"Line descriptor appears before any pattern header.",source:a});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:a});return}o.pattern.lines.push(u)}),this.flushCurrentPattern(o,r,s),{patterns:r,issues:s}}static parse(t){return new vc().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]),o=this.parseNumber(i[2]),a=this.parseNumber(i[3]),c=this.parseNumber(i[4]);if(r==null||s==null||o==null||a==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:o,deltaX:a,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 K=class K{static nextGradientId(t){return K.gradientIdCounter+=1,`acdb-pat-gradient-${t.toLowerCase()}-${K.gradientIdCounter}`}static packedRgbToCss(t){return`#${(t&16777215).toString(16).padStart(6,"0")}`}static gradientColorToCss(t,e){return typeof t=="number"?K.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,o=t>>16&255,a=t>>8&255,c=t&255,l=r>>16&255,h=r>>8&255,u=r&255;return Math.round(o+(l-o)*s)*65536+Math.round(a+(h-a)*s)*256+Math.round(c+(u-c)*s)}static resolveGradientColors(t){const e="#2563eb",i="#f8fafc",r=K.gradientColorToCss(t.startColor,e);if(t.oneColorMode&&t.endColor==null){if(typeof t.startColor=="number"){const s=K.applyShadeTint(t.startColor,t.shadeTintValue??.5);return{start:r,end:K.packedRgbToCss(s)}}return{start:r,end:(t.shadeTintValue??.5)<.5?"#000000":"#ffffff"}}return{start:r,end:K.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()===an}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 o of s.dashes)e.push(Math.abs(o))}const i=e.filter(s=>s>K.EPSILON);if(i.length===0)return 1;const r=i.sort((s,o)=>s-o);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,o,a){const c=t.dashes;if(c.length===0)return[{x1:r+o*e,y1:s+a*e,x2:r+o*i,y2:s+a*i}];const l=c.reduce((g,f)=>g+Math.abs(f),0);if(l<=K.EPSILON)return[{x1:r+o*e,y1:s+a*e,x2:r+o*i,y2:s+a*i}];const h=[],u=Math.ceil((i-e)/l)+2;let d=e-l;for(let g=0;g<u;g++){let f=d;for(const p of c){const m=Math.abs(p),y=f+m;if(p>0||p===0){const b=C.clamp(f,e,i),w=C.clamp(y,e,i);w>b?h.push({x1:r+o*b,y1:s+a*b,x2:r+o*w,y2:s+a*w}):p===0&&b>=e&&b<=i&&h.push({x1:r+o*(b-.35),y1:s+a*(b-.35),x2:r+o*(b+.35),y2:s+a*(b+.35)})}f=y}d+=l}return h}static renderFamily(t,e){const i=C.degToRad(t.angle),r=Math.cos(i),s=Math.sin(i),o=-s,a=r,c=r*t.deltaX+o*t.deltaY,l=s*t.deltaX+a*t.deltaY,h=Math.hypot(c,l),u=h<=K.EPSILON?1:Math.max(1,Math.ceil(e*2/h)+1),d=Math.floor(u/2),g=-e*1.5,f=e*1.5,p=[];for(let m=-d;m<=d;m++){const y=t.originX+c*m,b=t.originY+l*m,w=K.buildDashSegments(t,g,f,y,b,r,s);for(const x of w)p.push(K.segmentToSvgPath(x))}return`<path d="${p.join(" ")}" fill="none" />`}static renderLinearGradientDef(t,e,i,r,s){const o=K.getGradientVector(e),a=C.clamp(i,-1,1)*r*.5,c=o.x*a,l=o.y*a;return[`<linearGradient id="${t}" gradientUnits="userSpaceOnUse"`,` x1="${(-o.x*r+c).toFixed(2)}"`,` y1="${(-o.y*r+l).toFixed(2)}"`,` x2="${(o.x*r+c).toFixed(2)}"`,` y2="${(o.y*r+l).toFixed(2)}">`,K.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)}">`,K.renderGradientStops(s),"</radialGradient>"].join("")}static renderGradientDef(t,e,i,r,s,o,a){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(o,a)/2,f=K.getGradientVector(r),p=C.clamp(s,-1,1),m=f.x*p*o*.25,y=f.y*p*a*.25;switch(h){case"CYLINDER":{const b=C.clamp(.5+p*.45,.05,.95);return K.renderLinearGradientDef(t,r,0,g,[{offset:0,color:u},{offset:b,color:d},{offset:1,color:u}])}case"SPHERICAL":return K.renderRadialGradientDef(t,m,y,g,[{offset:0,color:d},{offset:1,color:u}]);case"HEMISPHERICAL":return K.renderRadialGradientDef(t,m+f.x*o*.18,y+f.y*a*.18,g*.92,[{offset:0,color:d},{offset:.72,color:u},{offset:1,color:u}]);case"CURVED":return K.renderRadialGradientDef(t,-f.x*o*.95+m,-f.y*a*.95+y,g*1.65,[{offset:0,color:u},{offset:.55,color:u},{offset:1,color:d}]);case"LINEAR":default:return K.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",o=e.strokeWidth??1.3,a=e.background??"#ffffff",c=`${-i/2} ${-r/2} ${i} ${r}`;if(K.isSolidPattern(t))return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${c}" width="${i}" height="${r}">`,K.renderBackground(i,r,a),`<rect x="${-i/2}" y="${-r/2}" width="${i}" height="${r}" fill="${s}" />`,"</svg>"].join("");const l=K.estimateUnitScale(t),u=Math.min(i,r)*.18/Math.max(l,K.EPSILON),d={...t,lines:t.lines.map(p=>({...p,originX:p.originX*u,originY:p.originY*u,deltaX:p.deltaX*u,deltaY:p.deltaY*u,dashes:p.dashes.map(m=>m*u)}))},g=Math.hypot(i,r)*.75,f=d.lines.map(p=>K.renderFamily(p,g)).join("");return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${c}" width="${i}" height="${r}">`,K.renderBackground(i,r,a),`<g stroke="${s}" stroke-width="${o.toFixed(2)}" stroke-linecap="round">`,f,"</g>","</svg>"].join("")}renderGradient(t,e={}){const i=e.width??260,r=e.height??160,s=e.background??"#ffffff",o=e.angle??0,a=e.shift??0,c=`${-i/2} ${-r/2} ${i} ${r}`,l=K.nextGradientId(t),h=K.resolveGradientColors(e),u=K.renderGradientDef(l,t,h,o,a,i,r);return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${c}" width="${i}" height="${r}">`,K.renderBackground(i,r,s),"<defs>",u,"</defs>",`<rect x="${-i/2}" y="${-r/2}" width="${i}" height="${r}" fill="url(#${l})" />`,"</svg>"].join("")}};K.EPSILON=1e-9,K.gradientIdCounter=0;let Ta=K;function ep(n){if(!n||n.length===0)return;const t=dA(n);if(t)return La(t,"image/bmp")}function uA(n){if(!(!n||n.length===0))return n.length>=8&&n[0]===137&&n[1]===80&&n[2]===78&&n[3]===71?La(n,"image/png"):n.length>=3&&n[0]===255&&n[1]===216&&n[2]===255?La(n,"image/jpeg"):ep(n)}function La(n,t){let e="";for(let i=0;i<n.length;i++)e+=String.fromCharCode(n[i]);return`data:${t};base64,${btoa(e)}`}function dA(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,o=e===12?s*3:s*4,a=14+e+o;if(a>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,a,!0);const u=new Uint8Array(c);return u.set(l,0),u.set(n,14),u}var ms=(n=>(n[n.AtLeast=1]="AtLeast",n[n.Exactly=2]="Exactly",n))(ms||{});const Wc=class Wc extends tt{get dxfTypeName(){return"DIMENSION"}constructor(){super(),this._dimBlockId=null,this._dimBlockPosition=new _,this._dxfDefinitionPoint=new _,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new _,this._textRotation=0,this._horizontalRotation=0,this._dimensionType=0,this._attachmentPoint=exports.AcGiMTextAttachmentPoint.MiddleCenter,this._dxfVersion=0,this._normal=new A(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 Ht),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 A(Math.cos(this._textRotation),Math.sin(this._textRotation),0));this._dimBlockPosition.applyMatrix4(t),this._textPosition.applyMatrix4(t),this._normal.transformDirection(t);const r=new A(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 A(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 o=this.getDimBlockTableRecord();if(!o)return;const a=this.getFullDimBlockTransform(),c=new _(e).applyMatrix4(a.clone().invert()),l=new _(i).applyMatrix4(a.clone().invert()),h=(u,d)=>{const g=[];u.subGetOsnapPoints(t,c,l,g,d,a),u instanceof xe?g.forEach(f=>r.push(f.clone())):g.forEach(f=>r.push(new _(f).applyMatrix4(a)))};if(s){const u=o.getIdAt(s);if(u&&(h(u,s),r.length>0))return}for(const u of o.newIterator())h(u)}subWorldDraw(t){const e=this.getDimBlockTableRecord();if(e){const r=this.computeDimBlockTransform();return Je.instance.draw(t,e,this.resolvedColor,[],!1,r,this._normal)}return t.group([])}subGetIntersectCurves(){const t=this.getDimBlockTableRecord();if(!t)return[];const e=this.getFullDimBlockTransform(),i=[];for(const r of t.newIterator())i.push(...Dd(r.subGetIntersectCurves(),e));return i}getDimBlockGeometricExtents(){const t=new j,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 j;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 bt(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:ms[1],value:1},{label:ms[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 _().subVectors(e,t).normalize();return new _(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)??_.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,o=this.textPosition.y,a=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),f=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=f;break;case 20:i=f;break;case 30:r=f;break;case 11:s=f;break;case 21:o=f;break;case 31:a=f;break;case 41:this.textLineSpacingFactor=f;break;case 42:this.measurement=f;break;case 53:c=f;break;case 51:this.horizontalRotation=C.degToRad(f);break;case 70:this.dimensionType=f;break;case 71:this.attachmentPoint=f;break;case 72:this.textLineSpacingStyle=f;break;case 210:l=f;break;case 220:h=f;break;case 230:u=f;break;case 280:this.dxfVersion=f;break}}return this._dxfDefinitionPoint.set(e,i,r),this.textPosition.copy(new _(s,o,a)),this.textRotation=c*Math.PI/180,this.normal.copy(new A(l,h,u)),this}};Wc.typeName="Dimension";let Fe=Wc;const $c=class $c extends Fe{constructor(t,e,i,r,s=null,o=null){super(),this._centerPoint=new _().copy(t),this._xLine1Point=new _().copy(e),this._xLine2Point=new _().copy(i),this._arcPoint=new _().copy(r),this.dimensionText=s,this.dimensionStyleName=o}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("centerPoint",()=>this.centerPoint),...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("arcPoint",()=>this.arcPoint)]}]}}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 k=String(e.value);k==="AcDb2LineAngularDimension"?(i=!0,t.atSubclassData("AcDb2LineAngularDimension")):k==="AcDb3PointAngularDimension"&&t.atSubclassData("AcDb3PointAngularDimension")}let r=this.xLine1Point.x,s=this.xLine1Point.y,o=this.xLine1Point.z,a=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,f=this.arcPoint.y,p=this.arcPoint.z,m=!1,y=r,b=s,w=o,x=a,S=c,P=l;const v=()=>{if(i){this.xLine1Point=new _(r,s,o),this.xLine2Point=new _(h,u,d);const k=gA({x:r,y:s},{x:y,y:b},{x:h,y:u},{x,y:S});k?this.centerPoint=new _(k.x,k.y,(o+P)/2):this.centerPoint=new _(y,b,w),this.arcPoint=new _(this._dxfDefinitionPoint.x,this._dxfDefinitionPoint.y,this._dxfDefinitionPoint.z);return}this.xLine1Point=new _(r,s,o),this.xLine2Point=new _(a,c,l),this.centerPoint=new _(h,u,d),m?this.arcPoint=new _(g,f,p):this.arcPoint=new _(this._dxfDefinitionPoint.x,this._dxfDefinitionPoint.y,this._dxfDefinitionPoint.z)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const k=t.readItem();if(!k)break;const E=Number(k.code),O=Number(k.value);switch(E){case 13:r=O;break;case 23:s=O;break;case 33:o=O;break;case 14:i?y=O:a=O;break;case 24:i?b=O:c=O;break;case 34:i?w=O:l=O;break;case 15:h=O;break;case 25:u=O;break;case 35:d=O;break;case 16:i?x=O:(g=O,m=!0);break;case 26:i?S=O:(f=O,m=!0);break;case 36:i?P=O:(p=O,m=!0);break}}return v(),this}};$c.typeName="3PointAngularDimension";let ys=$c;function gA(n,t,e,i){const r=t.x-n.x,s=t.y-n.y,o=i.x-e.x,a=i.y-e.y,c=r*a-s*o;if(Math.abs(c)<1e-12)return null;const l=((e.x-n.x)*a-(e.y-n.y)*o)/c;return{x:n.x+l*r,y:n.y+l*s}}const qc=class qc extends Fe{constructor(t,e,i,r=null,s=null){super(),this._dimLinePoint=new _().copy(i),this._xLine1Point=new _().copy(t),this._xLine2Point=new _().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 ct;e.name=t;const i=this.createLines();i.forEach(a=>e.appendEntity(new Oi(a.startPoint,a.endPoint))),this.createArrows(i[0]).forEach(a=>e.appendEntity(a));const s=i[0].midPoint,o=this.createMText(s,this._rotation);return o&&e.appendEntity(o),e}createMText(t,e){const i=r=>({x:Math.cos(r),y:Math.sin(r),z:0});if(this.dimensionText){const r=new mn;return r.attachmentPoint=this.attachmentPoint,r.layer="0",r.color=new U(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 xe(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),o=new Dt(r,s);return t.push(o),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 Dt(t,{...i,z:t.z})}findIntersectionPoint(t,e){const i=t.startPoint,r=t.endPoint,s=new A().subVectors(r,i).normalize(),a=new A().subVectors(e,i).dot(s),c=new A().copy(s).multiplyScalar(a);return new A().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,o=this.xLine2Point.y,a=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,f=this.dimBlockPosition.y,p=this.dimBlockPosition.z,m=!1,y=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const b=t.readItem();if(!b)break;const w=Number(b.code),x=Number(b.value);switch(w){case 12:g=x,m=!0;break;case 22:f=x,m=!0;break;case 32:p=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:o=x;break;case 34:a=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(b),this.finishAlignedDxfIn(e,i,r,s,o,a,c,l,h,u,d,g,f,p,m,y),this}}return this.finishAlignedDxfIn(e,i,r,s,o,a,c,l,h,u,d,g,f,p,m,y),this}finishAlignedDxfIn(t,e,i,r,s,o,a,c,l,h,u,d,g,f,p,m){this.xLine1Point={x:t,y:e,z:i},this.xLine2Point={x:r,y:s,z:o},m?this.dimLinePoint={x:a,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,p&&(this.dimBlockPosition={x:d,y:g,z:f})}};qc.typeName="AlignedDimension";let $n=qc;const Kc=class Kc extends Fe{constructor(t,e,i,r,s=null,o=null){super(),this._arcPoint=new _().copy(r),this._xLine1Point=new _().copy(e),this._xLine2Point=new _().copy(i),this._centerPoint=new _().copy(t),this.dimensionText=s,this.dimensionStyleName=o}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("centerPoint",()=>this.centerPoint),...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("arcPoint",()=>this.arcPoint)]}]}}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,o=this.xLine2Point.y,a=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 f=t.readItem();if(!f)break;const p=Number(f.code),m=Number(f.value);switch(p){case 13:e=m;break;case 23:i=m;break;case 33:r=m;break;case 14:s=m;break;case 24:o=m;break;case 34:a=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 _(e,i,r),this.xLine2Point=new _(s,o,a),this.centerPoint=new _(c,l,h),this.arcPoint=new _(u,d,g),this}};Kc.typeName="ArcDimension";let bs=Kc;const Zc=class Zc extends Fe{constructor(t,e,i=0,r=null,s=null){super(),this._chordPoint=new _().copy(t),this._farChordPoint=new _().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,o=this.farChordPoint.y,a=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 _(e,i,r),this.farChordPoint=new _(s,o,a)):c&&(this.chordPoint=new _(this._dxfDefinitionPoint.x,this._dxfDefinitionPoint.y,this._dxfDefinitionPoint.z),this.farChordPoint=new _(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 f=Number(g.code),p=Number(g.value);switch(f){case 15:e=p,c=!0;break;case 25:i=p,c=!0;break;case 35:r=p,c=!0;break;case 16:s=p,l=!0;break;case 26:o=p,l=!0;break;case 36:a=p,l=!0;break;case 40:this.leaderLength=p;break;case 52:h=p;break;case 53:u=p;break}}return d(),this}};Zc.typeName="DiametricDimension";let _s=Zc;const Qc=class Qc extends Fe{constructor(t,e,i=null,r=null){super(),this._definingPoint=new _().copy(t),this._leaderEndPoint=new _().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,o=this.leaderEndPoint.y,a=this.leaderEndPoint.z;const c=()=>{this.definingPoint=new _(e,i,r),this.leaderEndPoint=new _(s,o,a)};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:o=u;break;case 34:a=u;break}}return c(),this}};Qc.typeName="OrdinateDimension";let xs=Qc;const Jc=class Jc extends Fe{constructor(t,e,i,r=null,s=null){super(),this._center=new _().copy(t),this._chordPoint=new _().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,o=this.chordPoint.y,a=this.chordPoint.z,c=!1,l=this.extArcStartAngle*180/Math.PI,h=this.extArcEndAngle*180/Math.PI;const u=()=>{this.center=new _(e,i,r),this.chordPoint=new _(s,o,a),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),f=Number(d.value);switch(g){case 15:s=f,c=!0;break;case 25:o=f,c=!0;break;case 35:a=f,c=!0;break;case 13:c||(s=f);break;case 23:c||(o=f);break;case 33:c||(a=f);break;case 40:this.leaderLength=f;break;case 52:l=f;break;case 53:h=f;break}}return u(),this}};Jc.typeName="RadialDimension";let ws=Jc;const tl=class tl extends $n{get dxfSubclassMarker(){return"AcDbRotatedDimension"}};tl.typeName="RotatedDimension";let vs=tl;class fA{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 np(n){const t=Number(n.code),e=n.value,i=Ui(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 pA(n){const t=[];for(;!n.atEndOfObject&&!n.atEof&&!n.atExtendedData;){const e=n.readItem();if(!e)break;t.push(np(e))}return t}const mA=new Set(["AcDbAlignedDimension","AcDbRotatedDimension","AcDb3PointAngularDimension","AcDb2LineAngularDimension","AcDbOrdinateDimension","AcDbRadialDimension","AcDbDiametricDimension","AcDbArcDimension"]);function yA(n){const t=bA(n),e=_A(t),i=xA(e);if(!i)return null;const r=We.forReading(new fA(t),{database:n.database});return i.dxfIn(r),i}function bA(n){const t=pA(n);for(;!n.atEndOfObject&&!n.atEof;){const e=n.readItem();if(!e)break;if(Number(e.code)===0){n.pushBackItem(e);break}t.push(np(e))}return t}function _A(n){let t="";for(const e of n)e.code===100&&typeof e.value=="string"&&mA.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 xA(n,t){const e=new _;switch(n){case"AcDbRotatedDimension":return new vs(e,e,e);case"AcDbAlignedDimension":return new $n(e,e,e);case"AcDb3PointAngularDimension":case"AcDb2LineAngularDimension":return new ys(e,e,e,e);case"AcDbOrdinateDimension":return new xs(e,e);case"AcDbRadialDimension":return new ws(e,e,0);case"AcDbDiametricDimension":return new _s(e,e,0);case"AcDbArcDimension":return new bs(e,e,e,e);default:return new $n(e,e,e)}}var En=(n=>(n[n.SimplePoly=0]="SimplePoly",n[n.FitCurvePoly=1]="FitCurvePoly",n[n.QuadSplinePoly=2]="QuadSplinePoly",n[n.CubicSplinePoly=3]="CubicSplinePoly",n))(En||{});const el=class el extends It{constructor(t,e,i=0,r=!1,s=0,o=0,a=null){super(),this._normal=new A(0,0,1),this._polyType=t,this._elevation=i;const c=a&&(a==null?void 0:a.length)===e.length,l=e.map((h,u)=>({x:h.x,y:h.y,bulge:c?a[u]:void 0}));this._geo=new it(l,r)}get dxfTypeName(){return"POLYLINE"}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get normal(){return this._normal}set normal(t){this._normal.copy(t),this._normal.lengthSq()>0&&this._normal.normalize()}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 j().setFromPoints([At({x:t.min.x,y:t.min.y,z:this._elevation},this._normal),At({x:t.max.x,y:t.min.y,z:this._elevation},this._normal),At({x:t.max.x,y:t.max.y,z:this._elevation},this._normal),At({x:t.min.x,y:t.max.y,z:this._elevation},this._normal)])}subGetIntersectCurves(){return ac(this._geo.vertices,this.closed,this._elevation,this._normal)}subGetGripPoints(){const t=new Array;for(let e=0;e<this._geo.numberOfVertices;++e){const i=this._geo.getPointAt(e);t.push(new _(i.x,i.y,this._elevation))}return t}subMoveGripPointsAt(t,e){return bt(t,i=>{ui(this._geo.vertices,i,e)}),this}subGetOsnapPoints(t,e,i,r){var c;const s=this._geo,o=this._elevation,a=s.numberOfVertices;if(a!==0)switch(t){case I.EndPoint:for(let l=0;l<a;l++){const h=s.getPointAt(l);r.push(new _(h.x,h.y,o))}break;case I.MidPoint:case I.Nearest:case I.Perpendicular:case I.Tangent:{const l=this.closed?a:a-1,h=[];for(let u=0;u<l;u++){const d=[];Pi(s.getPointAt(u),s.getPointAt((u+1)%a),(c=s.vertices[u])==null?void 0:c.bulge,o,t,e,d),h.push(...d)}if(t===I.MidPoint)r.push(...h);else{const u=ie(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 _(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._normal.transformDirection(t),this._normal.lengthSq()>0&&this._normal.normalize(),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}}}]}]}}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){const e=[];return this._geo.tessellate(qi(t)).forEach(r=>e.push(new _().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),t.writeVector3d(210,this.normal),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectPath2d();return e.length<2?1:Rt.from2dPoints(e,this.closed).getOffsetSideAtPoint(t)}createOffsetCurve(t){const e=this._geo.offset(t);return e.length===0?null:Rt.fromGePolyline(e[0])}collectPath2d(){const t=Math.max(32,this.numberOfVertices*4);return this._geo.getPoints(t)}};el.typeName="2dPolyline";let As=el;var mi=(n=>(n[n.SimplePoly=0]="SimplePoly",n[n.QuadSplinePoly=1]="QuadSplinePoly",n[n.CubicSplinePoly=2]="CubicSplinePoly",n))(mi||{});const Bs=class Bs extends It{get dxfTypeName(){return"POLYLINE"}constructor(t,e,i=!1){super(),this._polyType=t,this._geo=new it(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 _(e.x,e.y,e.z||0)}get geometricExtents(){const t=this._geo.vertices.map(e=>new _(e.x,e.y,e.z||0));return new j().setFromPoints(t)}subGetIntersectCurves(){const t=[];for(let e=0;e<this.numberOfVertices;e++)t.push(this.getPointAt(e));return $t(t,this.closed)}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 bt(t,i=>{this.moveVertexAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){const s=Array.from({length:this._geo.numberOfVertices},(o,a)=>this.getPointAt(a));if(s.length!==0)switch(t){case I.EndPoint:r.push(...s);break;case I.MidPoint:case I.Nearest:case I.Perpendicular:{const o=[];for(let a=0;a<s.length-1;a++){const c=[];Jn(s[a],s[a+1],t,e,c),o.push(...c)}if(t===I.MidPoint)r.push(...o);else{const a=ie(e,o);a&&r.push(a)}break}}}transformBy(t){return this._geo.vertices.forEach(e=>{const i=new _(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}}}]}]}}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){const e=this._geo.vertices.map(i=>new _(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:Rt.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 o=i.getPointAt(s);r.push(new _(o.x,o.y,this.interpolateZ(o.x,o.y)))}return new Bs(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 o=this.closed?i:i-1;for(let a=0;a<o;a++){const c=this.getPointAt(a),l=this.getPointAt((a+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)),f=c.x+h*g,p=c.y+u*g,m=(t-f)**2+(e-p)**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)}};Bs.typeName="3dPolyline";let Ps=Bs;class ip{constructor(t){this.position=new _(t.x,t.y,t.z||0)}}class rp{constructor(t){this.vertexIndices=t}}const nl=class nl extends It{get dxfTypeName(){return"POLYLINE"}constructor(t,e){super(),this._vertices=t.map(i=>new ip(i)),this._faces=e.map(i=>new rp(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 j(new _(0,0,0),new _(0,0,0));let t=Number.MAX_VALUE,e=Number.MAX_VALUE,i=Number.MAX_VALUE,r=-Number.MAX_VALUE,s=-Number.MAX_VALUE,o=-Number.MAX_VALUE;return this._vertices.forEach(a=>{t=Math.min(t,a.position.x),e=Math.min(e,a.position.y),i=Math.min(i,a.position.z),r=Math.max(r,a.position.x),s=Math.max(s,a.position.y),o=Math.max(o,a.position.z)}),new j(new _(t,e,i),new _(r,s,o))}subGetIntersectCurves(){const t=[];return this._faces.forEach(e=>{const i=[];e.vertexIndices.forEach(r=>{const s=Math.abs(r)-1;s>=0&&s<this._vertices.length&&i.push(this._vertices[s].position)}),i.length>=2&&t.push(...$t(i,!0))}),t}subGetGripPoints(){const t=new Array;return this._vertices.forEach(e=>{t.push(e.position)}),t}subMoveGripPointsAt(t,e){return bt(t,i=>{const r=this._vertices[i];r&&r.position.add(e)}),this}subGetOsnapPoints(t,e,i,r){switch(t){case I.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 o=Math.abs(s)-1;o>=0&&o<this._vertices.length&&r.push(this._vertices[o].position)}),r.length>=3)for(let s=0;s<r.length;s++){const o=r[s],a=r[(s+1)%r.length];e.push(o),e.push(a)}}),t.lines(e)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPolyFaceMesh");const e=64;return t.writeInt16(66,1),t.writeInt16(70,e),this}dxfOut(t,e=!1){super.dxfOut(t,e);for(let 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,o)=>{t.writeInt32(10+o,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:Rt.from2dPoints(e,!0).getOffsetSideAtPoint(t)}createOffsetCurve(t){return so(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 M(e.position.x,e.position.y)):t.map(e=>{const i=this.getVertexAt(e).position;return new M(i.x,i.y)})}};nl.typeName="PolyFaceMesh";let Ss=nl;class sp{constructor(t){this.position=new _(t.x,t.y,t.z||0)}}const il=class il extends It{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(o=>new sp(o))}get mCount(){return this._mCount}get nCount(){return this._nCount}get closedM(){return this._closedM}get closedN(){return this._closedN}get closed(){return this._closedM}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 j(new _(0,0,0),new _(0,0,0));let t=Number.MAX_VALUE,e=Number.MAX_VALUE,i=Number.MAX_VALUE,r=-Number.MAX_VALUE,s=-Number.MAX_VALUE,o=-Number.MAX_VALUE;return this._vertices.forEach(a=>{t=Math.min(t,a.position.x),e=Math.min(e,a.position.y),i=Math.min(i,a.position.z),r=Math.max(r,a.position.x),s=Math.max(s,a.position.y),o=Math.max(o,a.position.z)}),new j(new _(t,e,i),new _(r,s,o))}subGetIntersectCurves(){const t=[];for(let e=0;e<this._mCount;e++)for(let i=0;i<this._nCount;i++){const r=this.getVertexAtMN(e,i);let s=i+1;if(s>=this._nCount)if(this._closedN)s=0;else continue;t.push(...$t([r.position,this.getVertexAtMN(e,s).position],!1,!1))}for(let e=0;e<this._nCount;e++)for(let i=0;i<this._mCount;i++){const r=this.getVertexAtMN(i,e);let s=i+1;if(s>=this._mCount)if(this._closedM)s=0;else continue;t.push(...$t([r.position,this.getVertexAtMN(s,e).position],!1,!1))}return t}subGetGripPoints(){const t=new Array;return this._vertices.forEach(e=>{t.push(e.position)}),t}subMoveGripPointsAt(t,e){return bt(t,i=>{const r=this._vertices[i];r&&r.position.add(e)}),this}subGetOsnapPoints(t,e,i,r){switch(t){case I.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 o=r+1;if(o>=this._nCount)if(this._closedN)o=0;else continue;const a=this.getVertexAtMN(i,o);e.push(s.position),e.push(a.position)}for(let i=0;i<this._nCount;i++)for(let r=0;r<this._mCount;r++){const s=this.getVertexAtMN(r,i);let o=r+1;if(o>=this._mCount)if(this._closedM)o=0;else continue;const a=this.getVertexAtMN(o,i);e.push(s.position),e.push(a.position)}return t.lines(e)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPolygonMesh");let e=16;return this._closedM&&(e|=1),this._closedN&&(e|=32),t.writeInt16(66,1),t.writeInt16(70,e),t.writeInt32(71,this._mCount),t.writeInt32(72,this._nCount),this}dxfOut(t,e=!1){super.dxfOut(t,e);for(let 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:Rt.from2dPoints(e,this.isBoundaryClosed()).getOffsetSideAtPoint(t)}createOffsetCurve(t){return so(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,o)=>{const a=this.getVertexAtMN(s,o).position;i.push(new M(a.x,a.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}};il.typeName="PolygonMesh";let ks=il;const wA=16,op=128,ap=64,vh=5,Ah=6;function vA(n){const t=AA(n),e=PA(n);return kA(t,e)}function AA(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 PA(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(SA(n))}return t}function SA(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 o=Number(s.code),a=Number(s.value);switch(o){case 10:t.x=a,i[0]=Math.trunc(a);break;case 20:t.y=a;break;case 30:t.z=a;break;case 11:i[1]=Math.trunc(a);break;case 12:i[2]=Math.trunc(a);break;case 13:i[3]=Math.trunc(a);break;case 42:t.bulge=a;break;case 70:t.flag=a;break;case 71:e[0]=Math.trunc(a);break;case 72:e[1]=Math.trunc(a);break;case 73:e[2]=Math.trunc(a);break;case 74:e[3]=Math.trunc(a);break}}if(!!(t.flag&op)&&!(t.flag&ap)){const s=e.length>0?e:i;t.faces=s.filter(o=>o!==0&&o!=null)}return t}function kA(n,t){const e=!!(n.flag&1),i=!!(n.flag&8),r=!!(n.flag&16),s=!!(n.flag&64),o=!!(n.flag&32),a=[],c=[],l=[];for(const u of t)u.flag&wA||(s&&u.flag&op?u.flag&ap?(a.push({x:u.x,y:u.y,z:u.z}),c.push(u.bulge)):u.faces.length>=3&&l.push([...u.faces]):(a.push({x:u.x,y:u.y,z:u.z}),c.push(u.bulge)));let h;if(r)h=new ks(n.meshM,n.meshN,a,e,o);else if(s)h=new Ss(a,l);else if(i){let u=mi.SimplePoly;n.flag&4&&(n.smoothType===Ah?u=mi.CubicSplinePoly:n.smoothType===vh&&(u=mi.QuadSplinePoly)),h=new Ps(u,a,e)}else{let u=En.SimplePoly;n.flag&2?u=En.FitCurvePoly:n.flag&4&&(n.smoothType===Ah?u=En.CubicSplinePoly:n.smoothType===vh&&(u=En.QuadSplinePoly)),h=new As(u,a,n.elevation,e,n.startWidth,n.endWidth,c)}return EA(h,n),h}function EA(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 cp(n){switch(n.toUpperCase()){case"LINE":return new Oi(new _,new _);case"CIRCLE":return new Gr(new _,1);case"ARC":return new jr(new _,1,0,Math.PI/2);case"POINT":return new is;case"RAY":return new ss;case"XLINE":return new us;case"ELLIPSE":return new Hr(new _,A.Z_AXIS,A.X_AXIS,1,1,0,Math.PI*2);case"SOLID":return new as;case"TRACE":return new Di;case"3DFACE":return new Wr;case"LWPOLYLINE":return new Rt;case"INSERT":return new xe("");case"TEXT":return new Gn;case"MTEXT":return new mn;case"SPLINE":return Xi.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 Ur;case"ATTRIB":return new Si;case"SHAPE":return new os;case"TOLERANCE":return new Kr;case"LEADER":return new Zr;case"VIEWPORT":return new ls;case"IMAGE":return new Fi;case"WIPEOUT":return new hs;case"ACAD_PROXY_ENTITY":return new rs;case"OLEFRAME":return new Bi;case"OLE2FRAME":return new ns;case"HATCH":return new Ti;case"MLINE":return new Jr;case"MULTILEADER":case"MLEADER":return new Qr;case"ACAD_TABLE":return new cs("",1,1);case"3DSOLID":return new Ai("");default:return null}}function Ma(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 vA(n);if(i==="DIMENSION")return yA(n);const r=cp(e);return r?(r.dxfIn(n),r):null}class lp{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 o=Date.now()-i,a=s instanceof Error?s.message:String(s);return{success:!1,error:a,errorCode:a.toLowerCase().includes("timed out")?"worker_timeout":void 0,duration:o}}}async executeInWorker(t,e,i){const r=Date.now();return new Promise((s,o)=>{const a=this.getAvailableWorker(i),c=setTimeout(()=>{this.cleanupTask(t),this.releaseWorker(a),o(new Error(`Worker operation timed out after ${this.config.timeout}ms`))},this.config.timeout);this.pendingTasks.set(t,{resolve:d=>{clearTimeout(c),this.releaseWorker(a),s(d)},reject:d=>{clearTimeout(c),this.releaseWorker(a),o(d)},timeout:c});const l=d=>{const{id:g,success:f,data:p,error:m,errorCode:y}=d.data;if(g!==t)return;this.cleanupTask(t);const b=Date.now()-r;s(f?{success:!0,data:p,duration:b}:{success:!1,error:m,errorCode:y,duration:b})},h=d=>{this.cleanupTask(t),o(new Error(`Worker error: ${d.message}`))};a.addEventListener("message",l),a.addEventListener("error",h);const u={id:t,input:e};e instanceof ArrayBuffer?a.postMessage(u,[e]):a.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 hp{constructor(t){this.framework=new lp(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function IA(n){return new hp(n)}class TA{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){const s=r instanceof Error?r.message:String(r);this.sendResponse(e,!1,void 0,s,this.classifyTaskError(r,s))}}}sendResponse(t,e,i,r,s){const o={id:t,success:e,data:i,error:r,errorCode:s};try{self.postMessage(o)}catch(a){const c=a instanceof Error?a.message:String(a);self.postMessage({id:t,success:!1,error:c,errorCode:this.classifyPostMessageError(c)})}}classifyTaskError(t,e){if(t instanceof Error){const r=t.code;if(Rg(r))return r;if(t.name===Og)return Ng(e)}const i=pc(e);return i||this.classifyPostMessageError(e)}classifyPostMessageError(t){const e=t.toLowerCase();return e.includes("out of memory")||e.includes("data cannot be cloned")?"worker_oom":"worker_error"}}var up=(n=>(n[n.Vertex=0]="Vertex",n[n.CurveFitVertex=1]="CurveFitVertex",n[n.SplineFitVertex=8]="SplineFitVertex",n[n.SplineCtlVertex=9]="SplineCtlVertex",n))(up||{});const rl=class rl extends tt{get dxfTypeName(){return"VERTEX"}constructor(){super(),this._position=new _,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 j().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subMoveGripPointsAt(t,e){return Se(t,e,this._position),this}subGetOsnapPoints(t,e,i,r){(t===I.EndPoint||t===I.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}};rl.typeName="2dVertex";let Ca=rl;var dp=(n=>(n[n.SimpleVertex=0]="SimpleVertex",n[n.ControlVertex=1]="ControlVertex",n[n.FitVertex=2]="FitVertex",n))(dp||{});const sl=class sl extends tt{get dxfTypeName(){return"VERTEX"}constructor(){super(),this._position=new _,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 j().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subMoveGripPointsAt(t,e){return Se(t,e,this._position),this}subGetOsnapPoints(t,e,i,r){(t===I.EndPoint||t===I.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}};sl.typeName="3dVertex";let Oa=sl;exports.ACAD_APPID=Zo;exports.ACAD_LAYERFILTERS_NAME=io;exports.ACCM_DEFAULT_UI_YIELD_BUDGET_MS=bi;exports.ACDB_COMPAREHATCH_DEFAULT=Br;exports.ACDB_COMPAREHATCH_MAX=Vs;exports.ACDB_COMPAREHATCH_MIN=zs;exports.ACDB_COMPAREPROPS_COLOR=ed;exports.ACDB_COMPAREPROPS_DEFAULT=cd;exports.ACDB_COMPAREPROPS_LAYER=nd;exports.ACDB_COMPAREPROPS_LINETYPE=id;exports.ACDB_COMPAREPROPS_LINETYPESCALE=rd;exports.ACDB_COMPAREPROPS_LINEWEIGHT=sd;exports.ACDB_COMPAREPROPS_MAX=hd;exports.ACDB_COMPAREPROPS_MIN=ld;exports.ACDB_COMPAREPROPS_THICKNESS=ad;exports.ACDB_COMPAREPROPS_TRANSPARENCY=od;exports.ACDB_COMPARERCMARGIN_DEFAULT=Fr;exports.ACDB_COMPARERCMARGIN_MAX=Us;exports.ACDB_COMPARERCMARGIN_MIN=js;exports.ACDB_COMPARETEXT_DEFAULT=Dr;exports.ACDB_COMPARETEXT_MAX=Hs;exports.ACDB_COMPARETEXT_MIN=Gs;exports.ACDB_COMPARETOLERANCE_DEFAULT=Xr;exports.ACDB_COMPARETOLERANCE_MAX=$s;exports.ACDB_COMPARETOLERANCE_MIN=Ws;exports.ACDB_DRAW_CIRCLE_SIDES_DRAFT=aa;exports.ACDB_DRAW_CIRCLE_SIDES_HIGH=x1;exports.ACDB_DRAW_CIRCLE_SIDES_STANDARD=_1;exports.ACDB_DXF_MTEXT_CHUNK_CHARS=si;exports.ACDB_DXF_XDATA_BINARY_MAX_BYTES=Fu;exports.ACDB_DXF_XDATA_STRING_MAX_BYTES=Bu;exports.ACDB_GRIPCOLOR_DEFAULT=Qu;exports.ACDB_GRIPCOLOR_MAX=Jo;exports.ACDB_GRIPCOLOR_MIN=Qo;exports.ACDB_GRIPHOT_DEFAULT=Ju;exports.ACDB_GRIPHOT_MAX=ea;exports.ACDB_GRIPHOT_MIN=ta;exports.ACDB_GRIPOBJLIMIT_MAX=gy;exports.ACDB_GRIPOBJLIMIT_MIN=dy;exports.ACDB_GRIPSIZE_DEFAULT=td;exports.ACDB_GRIPSIZE_MAX=ia;exports.ACDB_GRIPSIZE_MIN=na;exports.ACDB_GRIPS_MAX=py;exports.ACDB_GRIPS_MIN=fy;exports.ACDB_OLE2FRAME_GEOMETRY_HEADER_SIZE=ua;exports.ACDB_OLE_METAFILE_EMF_MIME=Bn;exports.ACDB_OLE_METAFILE_WMF_MIME=Ri;exports.ACDB_PROXY_GRAPHIC_CHUNK_SIZE=r1;exports.ACGI_DARK_THEME_FOREGROUND=wi;exports.ACGI_LIGHT_THEME_FOREGROUND=vi;exports.ACGI_MODEL_SPACE_BACKGROUND=Hu;exports.ACGI_PAPER_SPACE_BACKGROUND=ty;exports.ACLY_DICTIONARY_NAME=Hn;exports.ACTIVE_VPORT_NAME=Vn;exports.AC_DB_SYSTEM_VARIABLE_NAMES=Hb;exports.AcCmColor=U;exports.AcCmColorUtil=ue;exports.AcCmEntityColor=yp;exports.AcCmErrors=Ot;exports.AcCmEventDispatcher=bp;exports.AcCmEventManager=gt;exports.AcCmLoader=Bp;exports.AcCmLoadingManager=Lh;exports.AcCmObject=Vo;exports.AcCmPerformanceCollector=Na;exports.AcCmTask=Ih;exports.AcCmTaskScheduler=Th;exports.AcCmTransparency=pt;exports.AcCmUiYieldGate=Fs;exports.AcDb2dPolyline=As;exports.AcDb2dVertex=Ca;exports.AcDb2dVertexType=up;exports.AcDb3PointAngularDimension=ys;exports.AcDb3dPolyline=Ps;exports.AcDb3dSolid=Ai;exports.AcDb3dVertex=Oa;exports.AcDb3dVertexType=dp;exports.AcDbAbstractViewTableRecord=hc;exports.AcDbAlignedDimension=$n;exports.AcDbAngleUnits=Bt;exports.AcDbArc=jr;exports.AcDbArcDimension=bs;exports.AcDbAttribute=Si;exports.AcDbAttributeDefinition=Ur;exports.AcDbAttributeFlags=xt;exports.AcDbAttributeMTextFlag=le;exports.AcDbBaseWorker=TA;exports.AcDbBatchProcessing=zd;exports.AcDbBlockReference=xe;exports.AcDbBlockScaling=gd;exports.AcDbBlockTable=Cg;exports.AcDbBlockTableRecord=ct;exports.AcDbBlockTableRecordFlag=li;exports.AcDbChangeApplier=Ug;exports.AcDbChangeRecorder=Gg;exports.AcDbCircle=Gr;exports.AcDbCodePage=Ja;exports.AcDbCurve=It;exports.AcDbDataGenerator=Sg;exports.AcDbDatabase=ha;exports.AcDbDatabaseConverter=cc;exports.AcDbDatabaseConverterManager=ge;exports.AcDbDatabaseTransaction=Hg;exports.AcDbDatabaseTransactionManager=$g;exports.AcDbDiametricDimension=_s;exports.AcDbDictionary=Qt;exports.AcDbDimArrowType=pf;exports.AcDbDimStyleTable=Bg;exports.AcDbDimStyleTableRecord=Ht;exports.AcDbDimTextHorizontal=jd;exports.AcDbDimTextVertical=lc;exports.AcDbDimVerticalJustification=Hd;exports.AcDbDimZeroSuppression=Ud;exports.AcDbDimZeroSuppressionAngular=Gd;exports.AcDbDimension=Fe;exports.AcDbDuplicateRecordCloning=pg;exports.AcDbDwgVersion=St;exports.AcDbDxfCode=Ra;exports.AcDbDxfDocumentReader=yg;exports.AcDbDxfFiler=We;exports.AcDbDxfFilerStatus=zu;exports.AcDbDxfObjectsReader=mg;exports.AcDbEllipse=Hr;exports.AcDbEntity=tt;exports.AcDbFace=Wr;exports.AcDbFcf=Kr;exports.AcDbFileType=di;exports.AcDbFilter=lg;exports.AcDbFormatter=kg;exports.AcDbFrame=es;exports.AcDbGradientPatternType=Pg;exports.AcDbGroup=cg;exports.AcDbHatch=Ti;exports.AcDbHatchObjectType=Ag;exports.AcDbHatchPatternType=gi;exports.AcDbHatchStyle=vg;exports.AcDbHostApplicationServices=Yr;exports.AcDbIndex=ug;exports.AcDbIntersect=rn;exports.AcDbLayerFilter=hg;exports.AcDbLayerIndex=dg;exports.AcDbLayerTable=Fg;exports.AcDbLayerTableRecord=$i;exports.AcDbLayout=Hi;exports.AcDbLayoutDictionary=jg;exports.AcDbLayoutManager=wd;exports.AcDbLeader=Zr;exports.AcDbLeaderAnnotationType=qg;exports.AcDbLine=Oi;exports.AcDbLineSpacingStyle=ms;exports.AcDbLinearUnits=ut;exports.AcDbLinetypeTable=Dg;exports.AcDbLinetypeTableRecord=qe;exports.AcDbMLeader=Qr;exports.AcDbMLeaderContentType=kn;exports.AcDbMLeaderDirectionType=Zg;exports.AcDbMLeaderLineType=fi;exports.AcDbMLeaderStyle=ro;exports.AcDbMLeaderTextAttachmentDirection=Kg;exports.AcDbMLine=Jr;exports.AcDbMLineFlags=Jg;exports.AcDbMLineJustification=Qg;exports.AcDbMText=mn;exports.AcDbMlineStyle=uc;exports.AcDbNativeDxfConverter=bg;exports.AcDbObject=Et;exports.AcDbObjectIterator=jn;exports.AcDbOle2Frame=ns;exports.AcDbOleFrame=Bi;exports.AcDbOleObjectType=uf;exports.AcDbOleTileMode=df;exports.AcDbOpenDatabaseError=Mi;exports.AcDbOpenMode=Un;exports.AcDbOrdinateDimension=xs;exports.AcDbOsnapMode=I;exports.AcDbPatParser=vc;exports.AcDbPatSvgRenderer=Ta;exports.AcDbPlotPaperUnits=fd;exports.AcDbPlotRotation=pd;exports.AcDbPlotSettings=xd;exports.AcDbPlotShadePlotResLevel=yd;exports.AcDbPlotShadePlotType=bd;exports.AcDbPlotStdScaleType=_d;exports.AcDbPlotType=md;exports.AcDbPoint=is;exports.AcDbPoly2dType=En;exports.AcDbPoly3dType=mi;exports.AcDbPolyFaceMesh=Ss;exports.AcDbPolyFaceMeshFace=rp;exports.AcDbPolyFaceMeshVertex=ip;exports.AcDbPolygonMesh=ks;exports.AcDbPolygonMeshVertex=sp;exports.AcDbPolyline=Rt;exports.AcDbPredefinedAcadIsoPat=wg;exports.AcDbPredefinedAcadPat=O1;exports.AcDbProxyEntity=rs;exports.AcDbProxyGraphic=ra;exports.AcDbProxyGraphicBitStream=dd;exports.AcDbProxyGraphicByteStream=Kt;exports.AcDbProxyGraphicEndOfBufferError=Ge;exports.AcDbProxyGraphicType=Zd;exports.AcDbRadialDimension=ws;exports.AcDbRasterImage=Fi;exports.AcDbRasterImageClipBoundaryType=gf;exports.AcDbRasterImageDef=gg;exports.AcDbRasterImageImageDisplayOpt=ff;exports.AcDbRay=ss;exports.AcDbRegAppTable=Vg;exports.AcDbRegAppTableRecord=$r;exports.AcDbRegenerator=Vd;exports.AcDbRenderingCache=Je;exports.AcDbResultBuffer=fn;exports.AcDbRotatedDimension=vs;exports.AcDbShape=os;exports.AcDbSolid=as;exports.AcDbSortentsTable=fg;exports.AcDbSpline=Xi;exports.AcDbSymbolTable=ke;exports.AcDbSymbolTableRecord=De;exports.AcDbSysVarManager=vt;exports.AcDbSystemVariables=T;exports.AcDbTable=cs;exports.AcDbText=Gn;exports.AcDbTextHorizontalMode=Nd;exports.AcDbTextStyleTable=Ci;exports.AcDbTextStyleTableRecord=Qs;exports.AcDbTextVerticalMode=Bd;exports.AcDbTrace=Di;exports.AcDbTransaction=mc;exports.AcDbTransactionManager=s_;exports.AcDbUcsTable=Xg;exports.AcDbUcsTableRecord=$d;exports.AcDbUndoStack=Wg;exports.AcDbUnitsValue=at;exports.AcDbViewTable=Yg;exports.AcDbViewTableRecord=qd;exports.AcDbViewport=ls;exports.AcDbViewportTable=zg;exports.AcDbViewportTableRecord=Ke;exports.AcDbWipeout=hs;exports.AcDbWorkerApi=hp;exports.AcDbWorkerManager=lp;exports.AcDbXline=us;exports.AcDbXrecord=dc;exports.AcGeArea2d=oe;exports.AcGeBox2d=kt;exports.AcGeBox3d=j;exports.AcGeCatmullRomCurve3d=_u;exports.AcGeCircArc2d=$;exports.AcGeCircArc3d=Pt;exports.AcGeCurve2d=Kn;exports.AcGeEllipseArc2d=Ie;exports.AcGeEllipseArc3d=Pe;exports.AcGeEuler=$p;exports.AcGeGeometryUtil=Lt;exports.AcGeLine2d=Vt;exports.AcGeLine3d=Dt;exports.AcGeLoop2d=On;exports.AcGeMathUtil=C;exports.AcGeMatrix2d=zi;exports.AcGeMatrix3d=D;exports.AcGeNurbsCurve=qt;exports.AcGePlane=Ds;exports.AcGePoint2d=M;exports.AcGePoint3d=_;exports.AcGePolyline2d=it;exports.AcGeQuaternion=Dn;exports.AcGeShape2d=Ga;exports.AcGeSpline3d=Ut;exports.AcGeTol=V;exports.AcGeVector2d=ht;exports.AcGeVector3d=A;exports.AcGiContext=Ys;exports.AcGiViewport=$u;exports.AcLyBoolExpr=Jd;exports.AcLyLayerFilter=no;exports.AcLyLayerFilterDialogResult=tg;exports.AcLyLayerFilterTree=Be;exports.AcLyLayerGroup=eg;exports.AcTrStringUtil=Op;exports.ByBlock=ye;exports.ByLayer=mt;exports.DEBUG_MODE=Tp;exports.DEFAULT_ACGI_CONTEXT=ny;exports.DEFAULT_GRADIENT_HATCH_NAME=Zu;exports.DEFAULT_HATCH_PATTERN_IMPERIAL=oy;exports.DEFAULT_HATCH_PATTERN_METRIC=qu;exports.DEFAULT_LINE_TYPE=$e;exports.DEFAULT_MLEADER_STYLE=Re;exports.DEFAULT_MLINE_STYLE=Oe;exports.DEFAULT_TEXT_STYLE=lt;exports.DEFAULT_TOL=Vi;exports.DEG2RAD=Ba;exports.DefaultLoadingManager=Mh;exports.FLOAT_TOL=W;exports.HATCH_PATTERN_SOLID=an;exports.HATCH_PATTERN_USER=Ku;exports.MLIGHTCAD_APPID=Ko;exports.ORIGIN_POINT_2D=Dp;exports.ORIGIN_POINT_3D=za;exports.RAD2DEG=Fa;exports.RAW_COLOR_TYPE_ACI=eo;exports.RAW_COLOR_TYPE_BY_BLOCK=ki;exports.RAW_COLOR_TYPE_BY_LAYER=Js;exports.RAW_COLOR_TYPE_RGB=to;exports.RAW_COLOR_TYPE_WINDOW_BG=Kd;exports.TAU=Y;exports.TEMP_OBJECT_ID_PREFIX=Ue;exports.VPORT_FALLBACK_CENTER_2D=ay;exports.VPORT_FALLBACK_LLC=cy;exports.VPORT_FALLBACK_URC=ly;exports.VPORT_FALLBACK_VIEW_DIR=hy;exports.VPORT_FALLBACK_VIEW_TARGET=uy;exports.accmYieldForPaint=Eh;exports.accmYieldToUi=qn;exports.acdbAssignWorkingDatabase=Uu;exports.acdbChunkBinaryByMaxBytes=Yu;exports.acdbChunkDxfMTextContents=Du;exports.acdbChunkUtf8ByMaxBytes=Xu;exports.acdbCoerceIntegerSysVar=pe;exports.acdbCollectChangeEntities=la;exports.acdbCreateDxfPairReader=Nu;exports.acdbCreateEntityForDxfIn=cp;exports.acdbCreateWorkerApi=IA;exports.acdbDecodeMLeaderStyleRawColor=fe;exports.acdbDrawCircleSides=_g;exports.acdbDrawTessellateOptions=qi;exports.acdbDwgCodePageToEncoding=Tu;exports.acdbDxfInEntity=Ma;exports.acdbDxfInHeader=Qd;exports.acdbDxfValueType=Ui;exports.acdbEstimateDatabaseMemory=W_;exports.acdbExtractOleImageBlob=af;exports.acdbFormatMemoryEstimate=$_;exports.acdbGetWorkingDatabase=Gu;exports.acdbHasOsnapMode=bb;exports.acdbHexStringsToBytes=ec;exports.acdbHostApplicationServices=vd;exports.acdbIntegerSysVarIfInRange=oi;exports.acdbIsBinaryDxf=Lu;exports.acdbIsOleMetafileMimeType=yc;exports.acdbLayerGroupsToResultBuffer=rg;exports.acdbLooksLikeEmf=ts;exports.acdbLooksLikeWmf=we;exports.acdbMakeAsciiDxfPairReader=tc;exports.acdbMakeBinaryDxfPairReader=Ru;exports.acdbMakeUtf8AsciiDxfPairReader=Ou;exports.acdbMaskToOsnapModes=mb;exports.acdbOleBlobNeedsMetafileRasterization=cA;exports.acdbOsnapModesToMask=pb;exports.acdbParseFilterXRecordData=sg;exports.acdbParseOle2FrameGeometryHeader=ef;exports.acdbPeekDxfHeaderInfo=Mu;exports.acdbPreviewIconToDataUrl=ep;exports.acdbRasterizeOleMetafile=aA;exports.acdbReadLayerFilterTree=ng;exports.acdbReassembleEmfFromWmfEscapes=rf;exports.acdbResolveCircleSides=w1;exports.acdbResultBufferToLayerGroups=y1;exports.acdbSerializeLayerFilterTree=ig;exports.acdbSetHostApplicationServicesProvider=ju;exports.acdbSetLayoutManagerFactory=yy;exports.acdbThumbnailImageToDataUrl=uA;exports.acdbToggleOsnapMode=yb;exports.acdbWriteFilterXRecordData=ag;exports.acgeBasisFunction=Ze;exports.acgeCalculateCurveLength=tu;exports.acgeCeilPowerOfTwo=Hh;exports.acgeClamp=Jt;exports.acgeComputeParameterValues=Qh;exports.acgeDamp=Nh;exports.acgeDegToRad=jh;exports.acgeEuclideanModulo=Da;exports.acgeEvaluateNurbsPoint=ci;exports.acgeFloorPowerOfTwo=Wh;exports.acgeGenerateAveragedKnots=Jh;exports.acgeGenerateChordKnots=t0;exports.acgeGenerateSqrtChordKnots=e0;exports.acgeGenerateUUID=Ch;exports.acgeGenerateUniformKnots=Jp;exports.acgeGetOcsAngle=Le;exports.acgeGetOcsReferenceVector=Qe;exports.acgeIntPartLength=Ya;exports.acgeInterpolateControlPoints=s0;exports.acgeInterpolateNurbsCurve=Va;exports.acgeInverseLerp=Rh;exports.acgeIsAngleOnCcwSweep=Kh;exports.acgeIsBetterDistanceAlign=au;exports.acgeIsBetween=$h;exports.acgeIsBetweenAngle=qh;exports.acgeIsPowerOfTwo=Gh;exports.acgeLerp=Xa;exports.acgeMapLinear=Oh;exports.acgeNormalizeAngle=hn;exports.acgePingpong=Bh;exports.acgePointLiesOnCircle2d=su;exports.acgeRadToDeg=Uh;exports.acgeRandFloat=Yh;exports.acgeRandFloatSpread=zh;exports.acgeRandInt=Xh;exports.acgeRelativeEps=Zh;exports.acgeSameCircle2d=ou;exports.acgeSeededRandom=Vh;exports.acgeSmootherstep=Dh;exports.acgeSmoothstep=Fh;exports.acgeTransformOcsPointToWcs=At;exports.acgeTransformWcsPointToOcs=jt;exports.acgiContrastingForegroundColor=ry;exports.acgiForegroundColorForBackground=iy;exports.acgiIsLightBackground=Wu;exports.acgiResolveSubEntityTraitsRgbFromBackground=sy;exports.clone=ri;exports.deepClone=zo;exports.defaults=ne;exports.has=Sh;exports.isEmpty=kh;exports.isEqual=ln;exports.log=ai;exports.setLogLevel=Lp;
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]),o=this.parseNumber(i[2]),a=this.parseNumber(i[3]),c=this.parseNumber(i[4]);if(r==null||s==null||o==null||a==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:o,deltaX:a,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 K=class K{static nextGradientId(t){return K.gradientIdCounter+=1,`acdb-pat-gradient-${t.toLowerCase()}-${K.gradientIdCounter}`}static packedRgbToCss(t){return`#${(t&16777215).toString(16).padStart(6,"0")}`}static gradientColorToCss(t,e){return typeof t=="number"?K.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,o=t>>16&255,a=t>>8&255,c=t&255,l=r>>16&255,h=r>>8&255,u=r&255;return Math.round(o+(l-o)*s)*65536+Math.round(a+(h-a)*s)*256+Math.round(c+(u-c)*s)}static resolveGradientColors(t){const e="#2563eb",i="#f8fafc",r=K.gradientColorToCss(t.startColor,e);if(t.oneColorMode&&t.endColor==null){if(typeof t.startColor=="number"){const s=K.applyShadeTint(t.startColor,t.shadeTintValue??.5);return{start:r,end:K.packedRgbToCss(s)}}return{start:r,end:(t.shadeTintValue??.5)<.5?"#000000":"#ffffff"}}return{start:r,end:K.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()===an}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 o of s.dashes)e.push(Math.abs(o))}const i=e.filter(s=>s>K.EPSILON);if(i.length===0)return 1;const r=i.sort((s,o)=>s-o);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,o,a){const c=t.dashes;if(c.length===0)return[{x1:r+o*e,y1:s+a*e,x2:r+o*i,y2:s+a*i}];const l=c.reduce((g,f)=>g+Math.abs(f),0);if(l<=K.EPSILON)return[{x1:r+o*e,y1:s+a*e,x2:r+o*i,y2:s+a*i}];const h=[],u=Math.ceil((i-e)/l)+2;let d=e-l;for(let g=0;g<u;g++){let f=d;for(const p of c){const m=Math.abs(p),y=f+m;if(p>0||p===0){const b=C.clamp(f,e,i),w=C.clamp(y,e,i);w>b?h.push({x1:r+o*b,y1:s+a*b,x2:r+o*w,y2:s+a*w}):p===0&&b>=e&&b<=i&&h.push({x1:r+o*(b-.35),y1:s+a*(b-.35),x2:r+o*(b+.35),y2:s+a*(b+.35)})}f=y}d+=l}return h}static renderFamily(t,e){const i=C.degToRad(t.angle),r=Math.cos(i),s=Math.sin(i),o=-s,a=r,c=r*t.deltaX+o*t.deltaY,l=s*t.deltaX+a*t.deltaY,h=Math.hypot(c,l),u=h<=K.EPSILON?1:Math.max(1,Math.ceil(e*2/h)+1),d=Math.floor(u/2),g=-e*1.5,f=e*1.5,p=[];for(let m=-d;m<=d;m++){const y=t.originX+c*m,b=t.originY+l*m,w=K.buildDashSegments(t,g,f,y,b,r,s);for(const x of w)p.push(K.segmentToSvgPath(x))}return`<path d="${p.join(" ")}" fill="none" />`}static renderLinearGradientDef(t,e,i,r,s){const o=K.getGradientVector(e),a=C.clamp(i,-1,1)*r*.5,c=o.x*a,l=o.y*a;return[`<linearGradient id="${t}" gradientUnits="userSpaceOnUse"`,` x1="${(-o.x*r+c).toFixed(2)}"`,` y1="${(-o.y*r+l).toFixed(2)}"`,` x2="${(o.x*r+c).toFixed(2)}"`,` y2="${(o.y*r+l).toFixed(2)}">`,K.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)}">`,K.renderGradientStops(s),"</radialGradient>"].join("")}static renderGradientDef(t,e,i,r,s,o,a){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(o,a)/2,f=K.getGradientVector(r),p=C.clamp(s,-1,1),m=f.x*p*o*.25,y=f.y*p*a*.25;switch(h){case"CYLINDER":{const b=C.clamp(.5+p*.45,.05,.95);return K.renderLinearGradientDef(t,r,0,g,[{offset:0,color:u},{offset:b,color:d},{offset:1,color:u}])}case"SPHERICAL":return K.renderRadialGradientDef(t,m,y,g,[{offset:0,color:d},{offset:1,color:u}]);case"HEMISPHERICAL":return K.renderRadialGradientDef(t,m+f.x*o*.18,y+f.y*a*.18,g*.92,[{offset:0,color:d},{offset:.72,color:u},{offset:1,color:u}]);case"CURVED":return K.renderRadialGradientDef(t,-f.x*o*.95+m,-f.y*a*.95+y,g*1.65,[{offset:0,color:u},{offset:.55,color:u},{offset:1,color:d}]);case"LINEAR":default:return K.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",o=e.strokeWidth??1.3,a=e.background??"#ffffff",c=`${-i/2} ${-r/2} ${i} ${r}`;if(K.isSolidPattern(t))return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${c}" width="${i}" height="${r}">`,K.renderBackground(i,r,a),`<rect x="${-i/2}" y="${-r/2}" width="${i}" height="${r}" fill="${s}" />`,"</svg>"].join("");const l=K.estimateUnitScale(t),u=Math.min(i,r)*.18/Math.max(l,K.EPSILON),d={...t,lines:t.lines.map(p=>({...p,originX:p.originX*u,originY:p.originY*u,deltaX:p.deltaX*u,deltaY:p.deltaY*u,dashes:p.dashes.map(m=>m*u)}))},g=Math.hypot(i,r)*.75,f=d.lines.map(p=>K.renderFamily(p,g)).join("");return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${c}" width="${i}" height="${r}">`,K.renderBackground(i,r,a),`<g stroke="${s}" stroke-width="${o.toFixed(2)}" stroke-linecap="round">`,f,"</g>","</svg>"].join("")}renderGradient(t,e={}){const i=e.width??260,r=e.height??160,s=e.background??"#ffffff",o=e.angle??0,a=e.shift??0,c=`${-i/2} ${-r/2} ${i} ${r}`,l=K.nextGradientId(t),h=K.resolveGradientColors(e),u=K.renderGradientDef(l,t,h,o,a,i,r);return[`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${c}" width="${i}" height="${r}">`,K.renderBackground(i,r,s),"<defs>",u,"</defs>",`<rect x="${-i/2}" y="${-r/2}" width="${i}" height="${r}" fill="url(#${l})" />`,"</svg>"].join("")}};K.EPSILON=1e-9,K.gradientIdCounter=0;let Ta=K;function ep(n){if(!n||n.length===0)return;const t=dA(n);if(t)return La(t,"image/bmp")}function uA(n){if(!(!n||n.length===0))return n.length>=8&&n[0]===137&&n[1]===80&&n[2]===78&&n[3]===71?La(n,"image/png"):n.length>=3&&n[0]===255&&n[1]===216&&n[2]===255?La(n,"image/jpeg"):ep(n)}function La(n,t){let e="";for(let i=0;i<n.length;i++)e+=String.fromCharCode(n[i]);return`data:${t};base64,${btoa(e)}`}function dA(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,o=e===12?s*3:s*4,a=14+e+o;if(a>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,a,!0);const u=new Uint8Array(c);return u.set(l,0),u.set(n,14),u}var ms=(n=>(n[n.AtLeast=1]="AtLeast",n[n.Exactly=2]="Exactly",n))(ms||{});const Wc=class Wc extends tt{get dxfTypeName(){return"DIMENSION"}constructor(){super(),this._dimBlockId=null,this._dimBlockPosition=new _,this._dxfDefinitionPoint=new _,this._dimensionStyleName=null,this._dimensionText=null,this._textLineSpacingFactor=1,this._textLineSpacingStyle=1,this._textPosition=new _,this._textRotation=0,this._horizontalRotation=0,this._dimensionType=0,this._attachmentPoint=exports.AcGiMTextAttachmentPoint.MiddleCenter,this._dxfVersion=0,this._normal=new A(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 Ht),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 A(Math.cos(this._textRotation),Math.sin(this._textRotation),0));this._dimBlockPosition.applyMatrix4(t),this._textPosition.applyMatrix4(t),this._normal.transformDirection(t);const r=new A(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 A(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 o=this.getDimBlockTableRecord();if(!o)return;const a=this.getFullDimBlockTransform(),c=new _(e).applyMatrix4(a.clone().invert()),l=new _(i).applyMatrix4(a.clone().invert()),h=(u,d)=>{const g=[];u.subGetOsnapPoints(t,c,l,g,d,a),u instanceof xe?g.forEach(f=>r.push(f.clone())):g.forEach(f=>r.push(new _(f).applyMatrix4(a)))};if(s){const u=o.getIdAt(s);if(u&&(h(u,s),r.length>0))return}for(const u of o.newIterator())h(u)}subWorldDraw(t){const e=this.getDimBlockTableRecord();if(e){const r=this.computeDimBlockTransform();return Je.instance.draw(t,e,this.resolvedColor,[],!1,r,this._normal)}return t.group([])}subGetIntersectCurves(){const t=this.getDimBlockTableRecord();if(!t)return[];const e=this.getFullDimBlockTransform(),i=[];for(const r of t.newIterator())i.push(...Dd(r.subGetIntersectCurves(),e));return i}getDimBlockGeometricExtents(){const t=new j,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 j;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 bt(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:ms[1],value:1},{label:ms[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 _().subVectors(e,t).normalize();return new _(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)??_.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,o=this.textPosition.y,a=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),f=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=f;break;case 20:i=f;break;case 30:r=f;break;case 11:s=f;break;case 21:o=f;break;case 31:a=f;break;case 41:this.textLineSpacingFactor=f;break;case 42:this.measurement=f;break;case 53:c=f;break;case 51:this.horizontalRotation=C.degToRad(f);break;case 70:this.dimensionType=f;break;case 71:this.attachmentPoint=f;break;case 72:this.textLineSpacingStyle=f;break;case 210:l=f;break;case 220:h=f;break;case 230:u=f;break;case 280:this.dxfVersion=f;break}}return this._dxfDefinitionPoint.set(e,i,r),this.textPosition.copy(new _(s,o,a)),this.textRotation=c*Math.PI/180,this.normal.copy(new A(l,h,u)),this}};Wc.typeName="Dimension";let Fe=Wc;const $c=class $c extends Fe{constructor(t,e,i,r,s=null,o=null){super(),this._centerPoint=new _().copy(t),this._xLine1Point=new _().copy(e),this._xLine2Point=new _().copy(i),this._arcPoint=new _().copy(r),this.dimensionText=s,this.dimensionStyleName=o}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("centerPoint",()=>this.centerPoint),...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("arcPoint",()=>this.arcPoint)]}]}}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 k=String(e.value);k==="AcDb2LineAngularDimension"?(i=!0,t.atSubclassData("AcDb2LineAngularDimension")):k==="AcDb3PointAngularDimension"&&t.atSubclassData("AcDb3PointAngularDimension")}let r=this.xLine1Point.x,s=this.xLine1Point.y,o=this.xLine1Point.z,a=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,f=this.arcPoint.y,p=this.arcPoint.z,m=!1,y=r,b=s,w=o,x=a,S=c,P=l;const v=()=>{if(i){this.xLine1Point=new _(r,s,o),this.xLine2Point=new _(h,u,d);const k=gA({x:r,y:s},{x:y,y:b},{x:h,y:u},{x,y:S});k?this.centerPoint=new _(k.x,k.y,(o+P)/2):this.centerPoint=new _(y,b,w),this.arcPoint=new _(this._dxfDefinitionPoint.x,this._dxfDefinitionPoint.y,this._dxfDefinitionPoint.z);return}this.xLine1Point=new _(r,s,o),this.xLine2Point=new _(a,c,l),this.centerPoint=new _(h,u,d),m?this.arcPoint=new _(g,f,p):this.arcPoint=new _(this._dxfDefinitionPoint.x,this._dxfDefinitionPoint.y,this._dxfDefinitionPoint.z)};for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const k=t.readItem();if(!k)break;const E=Number(k.code),O=Number(k.value);switch(E){case 13:r=O;break;case 23:s=O;break;case 33:o=O;break;case 14:i?y=O:a=O;break;case 24:i?b=O:c=O;break;case 34:i?w=O:l=O;break;case 15:h=O;break;case 25:u=O;break;case 35:d=O;break;case 16:i?x=O:(g=O,m=!0);break;case 26:i?S=O:(f=O,m=!0);break;case 36:i?P=O:(p=O,m=!0);break}}return v(),this}};$c.typeName="3PointAngularDimension";let ys=$c;function gA(n,t,e,i){const r=t.x-n.x,s=t.y-n.y,o=i.x-e.x,a=i.y-e.y,c=r*a-s*o;if(Math.abs(c)<1e-12)return null;const l=((e.x-n.x)*a-(e.y-n.y)*o)/c;return{x:n.x+l*r,y:n.y+l*s}}const qc=class qc extends Fe{constructor(t,e,i,r=null,s=null){super(),this._dimLinePoint=new _().copy(i),this._xLine1Point=new _().copy(t),this._xLine2Point=new _().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 ct;e.name=t;const i=this.createLines();i.forEach(a=>e.appendEntity(new Oi(a.startPoint,a.endPoint))),this.createArrows(i[0]).forEach(a=>e.appendEntity(a));const s=i[0].midPoint,o=this.createMText(s,this._rotation);return o&&e.appendEntity(o),e}createMText(t,e){const i=r=>({x:Math.cos(r),y:Math.sin(r),z:0});if(this.dimensionText){const r=new mn;return r.attachmentPoint=this.attachmentPoint,r.layer="0",r.color=new U(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 xe(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),o=new Dt(r,s);return t.push(o),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 Dt(t,{...i,z:t.z})}findIntersectionPoint(t,e){const i=t.startPoint,r=t.endPoint,s=new A().subVectors(r,i).normalize(),a=new A().subVectors(e,i).dot(s),c=new A().copy(s).multiplyScalar(a);return new A().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,o=this.xLine2Point.y,a=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,f=this.dimBlockPosition.y,p=this.dimBlockPosition.z,m=!1,y=!1;for(;!t.atEndOfObject&&!t.atEof&&!t.atExtendedData;){const b=t.readItem();if(!b)break;const w=Number(b.code),x=Number(b.value);switch(w){case 12:g=x,m=!0;break;case 22:f=x,m=!0;break;case 32:p=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:o=x;break;case 34:a=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(b),this.finishAlignedDxfIn(e,i,r,s,o,a,c,l,h,u,d,g,f,p,m,y),this}}return this.finishAlignedDxfIn(e,i,r,s,o,a,c,l,h,u,d,g,f,p,m,y),this}finishAlignedDxfIn(t,e,i,r,s,o,a,c,l,h,u,d,g,f,p,m){this.xLine1Point={x:t,y:e,z:i},this.xLine2Point={x:r,y:s,z:o},m?this.dimLinePoint={x:a,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,p&&(this.dimBlockPosition={x:d,y:g,z:f})}};qc.typeName="AlignedDimension";let $n=qc;const Kc=class Kc extends Fe{constructor(t,e,i,r,s=null,o=null){super(),this._arcPoint=new _().copy(r),this._xLine1Point=new _().copy(e),this._xLine2Point=new _().copy(i),this._centerPoint=new _().copy(t),this.dimensionText=s,this.dimensionStyleName=o}get arcPoint(){return this._arcPoint}set arcPoint(t){this._arcPoint.copy(t)}get centerPoint(){return this._centerPoint}set centerPoint(t){this._centerPoint.copy(t)}get xLine1Point(){return this._xLine1Point}set xLine1Point(t){this._xLine1Point.copy(t)}get xLine2Point(){return this._xLine2Point}set xLine2Point(t){this._xLine2Point.copy(t)}get properties(){const t=this.getBaseProperties();return{type:this.type,groups:[...t.groups,{groupName:"geometry",properties:[...this.createPoint3dProperties("centerPoint",()=>this.centerPoint),...this.createPoint3dProperties("xLine1Point",()=>this.xLine1Point),...this.createPoint3dProperties("xLine2Point",()=>this.xLine2Point),...this.createPoint3dProperties("arcPoint",()=>this.arcPoint)]}]}}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,o=this.xLine2Point.y,a=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 f=t.readItem();if(!f)break;const p=Number(f.code),m=Number(f.value);switch(p){case 13:e=m;break;case 23:i=m;break;case 33:r=m;break;case 14:s=m;break;case 24:o=m;break;case 34:a=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 _(e,i,r),this.xLine2Point=new _(s,o,a),this.centerPoint=new _(c,l,h),this.arcPoint=new _(u,d,g),this}};Kc.typeName="ArcDimension";let bs=Kc;const Zc=class Zc extends Fe{constructor(t,e,i=0,r=null,s=null){super(),this._chordPoint=new _().copy(t),this._farChordPoint=new _().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,o=this.farChordPoint.y,a=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 _(e,i,r),this.farChordPoint=new _(s,o,a)):c&&(this.chordPoint=new _(this._dxfDefinitionPoint.x,this._dxfDefinitionPoint.y,this._dxfDefinitionPoint.z),this.farChordPoint=new _(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 f=Number(g.code),p=Number(g.value);switch(f){case 15:e=p,c=!0;break;case 25:i=p,c=!0;break;case 35:r=p,c=!0;break;case 16:s=p,l=!0;break;case 26:o=p,l=!0;break;case 36:a=p,l=!0;break;case 40:this.leaderLength=p;break;case 52:h=p;break;case 53:u=p;break}}return d(),this}};Zc.typeName="DiametricDimension";let _s=Zc;const Qc=class Qc extends Fe{constructor(t,e,i=null,r=null){super(),this._definingPoint=new _().copy(t),this._leaderEndPoint=new _().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,o=this.leaderEndPoint.y,a=this.leaderEndPoint.z;const c=()=>{this.definingPoint=new _(e,i,r),this.leaderEndPoint=new _(s,o,a)};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:o=u;break;case 34:a=u;break}}return c(),this}};Qc.typeName="OrdinateDimension";let xs=Qc;const Jc=class Jc extends Fe{constructor(t,e,i,r=null,s=null){super(),this._center=new _().copy(t),this._chordPoint=new _().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,o=this.chordPoint.y,a=this.chordPoint.z,c=!1,l=this.extArcStartAngle*180/Math.PI,h=this.extArcEndAngle*180/Math.PI;const u=()=>{this.center=new _(e,i,r),this.chordPoint=new _(s,o,a),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),f=Number(d.value);switch(g){case 15:s=f,c=!0;break;case 25:o=f,c=!0;break;case 35:a=f,c=!0;break;case 13:c||(s=f);break;case 23:c||(o=f);break;case 33:c||(a=f);break;case 40:this.leaderLength=f;break;case 52:l=f;break;case 53:h=f;break}}return u(),this}};Jc.typeName="RadialDimension";let ws=Jc;const tl=class tl extends $n{get dxfSubclassMarker(){return"AcDbRotatedDimension"}};tl.typeName="RotatedDimension";let vs=tl;class fA{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 np(n){const t=Number(n.code),e=n.value,i=Ui(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 pA(n){const t=[];for(;!n.atEndOfObject&&!n.atEof&&!n.atExtendedData;){const e=n.readItem();if(!e)break;t.push(np(e))}return t}const mA=new Set(["AcDbAlignedDimension","AcDbRotatedDimension","AcDb3PointAngularDimension","AcDb2LineAngularDimension","AcDbOrdinateDimension","AcDbRadialDimension","AcDbDiametricDimension","AcDbArcDimension"]);function yA(n){const t=bA(n),e=_A(t),i=xA(e);if(!i)return null;const r=We.forReading(new fA(t),{database:n.database});return i.dxfIn(r),i}function bA(n){const t=pA(n);for(;!n.atEndOfObject&&!n.atEof;){const e=n.readItem();if(!e)break;if(Number(e.code)===0){n.pushBackItem(e);break}t.push(np(e))}return t}function _A(n){let t="";for(const e of n)e.code===100&&typeof e.value=="string"&&mA.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 xA(n,t){const e=new _;switch(n){case"AcDbRotatedDimension":return new vs(e,e,e);case"AcDbAlignedDimension":return new $n(e,e,e);case"AcDb3PointAngularDimension":case"AcDb2LineAngularDimension":return new ys(e,e,e,e);case"AcDbOrdinateDimension":return new xs(e,e);case"AcDbRadialDimension":return new ws(e,e,0);case"AcDbDiametricDimension":return new _s(e,e,0);case"AcDbArcDimension":return new bs(e,e,e,e);default:return new $n(e,e,e)}}var En=(n=>(n[n.SimplePoly=0]="SimplePoly",n[n.FitCurvePoly=1]="FitCurvePoly",n[n.QuadSplinePoly=2]="QuadSplinePoly",n[n.CubicSplinePoly=3]="CubicSplinePoly",n))(En||{});const el=class el extends It{constructor(t,e,i=0,r=!1,s=0,o=0,a=null){super(),this._normal=new A(0,0,1),this._polyType=t,this._elevation=i;const c=a&&(a==null?void 0:a.length)===e.length,l=e.map((h,u)=>({x:h.x,y:h.y,bulge:c?a[u]:void 0}));this._geo=new it(l,r)}get dxfTypeName(){return"POLYLINE"}get polyType(){return this._polyType}set polyType(t){this._polyType=t}get elevation(){return this._elevation}set elevation(t){this._elevation=t}get normal(){return this._normal}set normal(t){this._normal.copy(t),this._normal.lengthSq()>0&&this._normal.normalize()}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 t.isEmpty()?new j:new j().setFromPoints([At({x:t.min.x,y:t.min.y,z:this._elevation},this._normal),At({x:t.max.x,y:t.min.y,z:this._elevation},this._normal),At({x:t.max.x,y:t.max.y,z:this._elevation},this._normal),At({x:t.min.x,y:t.max.y,z:this._elevation},this._normal)])}subGetIntersectCurves(){return ac(this._geo.vertices,this.closed,this._elevation,this._normal)}subGetGripPoints(){const t=new Array;for(let e=0;e<this._geo.numberOfVertices;++e){const i=this._geo.getPointAt(e);t.push(new _(i.x,i.y,this._elevation))}return t}subMoveGripPointsAt(t,e){return bt(t,i=>{ui(this._geo.vertices,i,e)}),this}subGetOsnapPoints(t,e,i,r){var c;const s=this._geo,o=this._elevation,a=s.numberOfVertices;if(a!==0)switch(t){case I.EndPoint:for(let l=0;l<a;l++){const h=s.getPointAt(l);r.push(new _(h.x,h.y,o))}break;case I.MidPoint:case I.Nearest:case I.Perpendicular:case I.Tangent:{const l=this.closed?a:a-1,h=[];for(let u=0;u<l;u++){const d=[];Pi(s.getPointAt(u),s.getPointAt((u+1)%a),(c=s.vertices[u])==null?void 0:c.bulge,o,t,e,d),h.push(...d)}if(t===I.MidPoint)r.push(...h);else{const u=ie(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 _(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._normal.transformDirection(t),this._normal.lengthSq()>0&&this._normal.normalize(),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}}}]}]}}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){const e=[];return this._geo.tessellate(qi(t)).forEach(r=>e.push(new _().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),t.writeVector3d(210,this.normal),this}getOffsetCurves(t){const e=this.createOffsetCurve(t);return e?[e]:[]}getOffsetSideAtPoint(t){const e=this.collectPath2d();return e.length<2?1:Rt.from2dPoints(e,this.closed).getOffsetSideAtPoint(t)}createOffsetCurve(t){const e=this._geo.offset(t);return e.length===0?null:Rt.fromGePolyline(e[0])}collectPath2d(){const t=Math.max(32,this.numberOfVertices*4);return this._geo.getPoints(t)}};el.typeName="2dPolyline";let As=el;var mi=(n=>(n[n.SimplePoly=0]="SimplePoly",n[n.QuadSplinePoly=1]="QuadSplinePoly",n[n.CubicSplinePoly=2]="CubicSplinePoly",n))(mi||{});const Bs=class Bs extends It{get dxfTypeName(){return"POLYLINE"}constructor(t,e,i=!1){super(),this._polyType=t,this._geo=new it(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 _(e.x,e.y,e.z||0)}get geometricExtents(){const t=this._geo.vertices.map(e=>new _(e.x,e.y,e.z||0));return new j().setFromPoints(t)}subGetIntersectCurves(){const t=[];for(let e=0;e<this.numberOfVertices;e++)t.push(this.getPointAt(e));return $t(t,this.closed)}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 bt(t,i=>{this.moveVertexAt(i,e)}),this}subGetOsnapPoints(t,e,i,r){const s=Array.from({length:this._geo.numberOfVertices},(o,a)=>this.getPointAt(a));if(s.length!==0)switch(t){case I.EndPoint:r.push(...s);break;case I.MidPoint:case I.Nearest:case I.Perpendicular:{const o=[];for(let a=0;a<s.length-1;a++){const c=[];Jn(s[a],s[a+1],t,e,c),o.push(...c)}if(t===I.MidPoint)r.push(...o);else{const a=ie(e,o);a&&r.push(a)}break}}}transformBy(t){return this._geo.vertices.forEach(e=>{const i=new _(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}}}]}]}}get directBatchPrimitive(){return"lineStrip"}subWorldDraw(t){const e=this._geo.vertices.map(i=>new _(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:Rt.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 o=i.getPointAt(s);r.push(new _(o.x,o.y,this.interpolateZ(o.x,o.y)))}return new Bs(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 o=this.closed?i:i-1;for(let a=0;a<o;a++){const c=this.getPointAt(a),l=this.getPointAt((a+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)),f=c.x+h*g,p=c.y+u*g,m=(t-f)**2+(e-p)**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)}};Bs.typeName="3dPolyline";let Ps=Bs;class ip{constructor(t){this.position=new _(t.x,t.y,t.z||0)}}class rp{constructor(t){this.vertexIndices=t}}const nl=class nl extends It{get dxfTypeName(){return"POLYLINE"}constructor(t,e){super(),this._vertices=t.map(i=>new ip(i)),this._faces=e.map(i=>new rp(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 j(new _(0,0,0),new _(0,0,0));let t=Number.MAX_VALUE,e=Number.MAX_VALUE,i=Number.MAX_VALUE,r=-Number.MAX_VALUE,s=-Number.MAX_VALUE,o=-Number.MAX_VALUE;return this._vertices.forEach(a=>{t=Math.min(t,a.position.x),e=Math.min(e,a.position.y),i=Math.min(i,a.position.z),r=Math.max(r,a.position.x),s=Math.max(s,a.position.y),o=Math.max(o,a.position.z)}),new j(new _(t,e,i),new _(r,s,o))}subGetIntersectCurves(){const t=[];return this._faces.forEach(e=>{const i=[];e.vertexIndices.forEach(r=>{const s=Math.abs(r)-1;s>=0&&s<this._vertices.length&&i.push(this._vertices[s].position)}),i.length>=2&&t.push(...$t(i,!0))}),t}subGetGripPoints(){const t=new Array;return this._vertices.forEach(e=>{t.push(e.position)}),t}subMoveGripPointsAt(t,e){return bt(t,i=>{const r=this._vertices[i];r&&r.position.add(e)}),this}subGetOsnapPoints(t,e,i,r){switch(t){case I.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 o=Math.abs(s)-1;o>=0&&o<this._vertices.length&&r.push(this._vertices[o].position)}),r.length>=3)for(let s=0;s<r.length;s++){const o=r[s],a=r[(s+1)%r.length];e.push(o),e.push(a)}}),t.lines(e)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPolyFaceMesh");const e=64;return t.writeInt16(66,1),t.writeInt16(70,e),this}dxfOut(t,e=!1){super.dxfOut(t,e);for(let 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,o)=>{t.writeInt32(10+o,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:Rt.from2dPoints(e,!0).getOffsetSideAtPoint(t)}createOffsetCurve(t){return so(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 M(e.position.x,e.position.y)):t.map(e=>{const i=this.getVertexAt(e).position;return new M(i.x,i.y)})}};nl.typeName="PolyFaceMesh";let Ss=nl;class sp{constructor(t){this.position=new _(t.x,t.y,t.z||0)}}const il=class il extends It{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(o=>new sp(o))}get mCount(){return this._mCount}get nCount(){return this._nCount}get closedM(){return this._closedM}get closedN(){return this._closedN}get closed(){return this._closedM}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 j(new _(0,0,0),new _(0,0,0));let t=Number.MAX_VALUE,e=Number.MAX_VALUE,i=Number.MAX_VALUE,r=-Number.MAX_VALUE,s=-Number.MAX_VALUE,o=-Number.MAX_VALUE;return this._vertices.forEach(a=>{t=Math.min(t,a.position.x),e=Math.min(e,a.position.y),i=Math.min(i,a.position.z),r=Math.max(r,a.position.x),s=Math.max(s,a.position.y),o=Math.max(o,a.position.z)}),new j(new _(t,e,i),new _(r,s,o))}subGetIntersectCurves(){const t=[];for(let e=0;e<this._mCount;e++)for(let i=0;i<this._nCount;i++){const r=this.getVertexAtMN(e,i);let s=i+1;if(s>=this._nCount)if(this._closedN)s=0;else continue;t.push(...$t([r.position,this.getVertexAtMN(e,s).position],!1,!1))}for(let e=0;e<this._nCount;e++)for(let i=0;i<this._mCount;i++){const r=this.getVertexAtMN(i,e);let s=i+1;if(s>=this._mCount)if(this._closedM)s=0;else continue;t.push(...$t([r.position,this.getVertexAtMN(s,e).position],!1,!1))}return t}subGetGripPoints(){const t=new Array;return this._vertices.forEach(e=>{t.push(e.position)}),t}subMoveGripPointsAt(t,e){return bt(t,i=>{const r=this._vertices[i];r&&r.position.add(e)}),this}subGetOsnapPoints(t,e,i,r){switch(t){case I.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 o=r+1;if(o>=this._nCount)if(this._closedN)o=0;else continue;const a=this.getVertexAtMN(i,o);e.push(s.position),e.push(a.position)}for(let i=0;i<this._nCount;i++)for(let r=0;r<this._mCount;r++){const s=this.getVertexAtMN(r,i);let o=r+1;if(o>=this._mCount)if(this._closedM)o=0;else continue;const a=this.getVertexAtMN(o,i);e.push(s.position),e.push(a.position)}return t.lines(e)}dxfOutFields(t){super.dxfOutFields(t),t.writeSubclassMarker("AcDbPolygonMesh");let e=16;return this._closedM&&(e|=1),this._closedN&&(e|=32),t.writeInt16(66,1),t.writeInt16(70,e),t.writeInt32(71,this._mCount),t.writeInt32(72,this._nCount),this}dxfOut(t,e=!1){super.dxfOut(t,e);for(let 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:Rt.from2dPoints(e,this.isBoundaryClosed()).getOffsetSideAtPoint(t)}createOffsetCurve(t){return so(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,o)=>{const a=this.getVertexAtMN(s,o).position;i.push(new M(a.x,a.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}};il.typeName="PolygonMesh";let ks=il;const wA=16,op=128,ap=64,vh=5,Ah=6;function vA(n){const t=AA(n),e=PA(n);return kA(t,e)}function AA(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 PA(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(SA(n))}return t}function SA(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 o=Number(s.code),a=Number(s.value);switch(o){case 10:t.x=a,i[0]=Math.trunc(a);break;case 20:t.y=a;break;case 30:t.z=a;break;case 11:i[1]=Math.trunc(a);break;case 12:i[2]=Math.trunc(a);break;case 13:i[3]=Math.trunc(a);break;case 42:t.bulge=a;break;case 70:t.flag=a;break;case 71:e[0]=Math.trunc(a);break;case 72:e[1]=Math.trunc(a);break;case 73:e[2]=Math.trunc(a);break;case 74:e[3]=Math.trunc(a);break}}if(!!(t.flag&op)&&!(t.flag&ap)){const s=e.length>0?e:i;t.faces=s.filter(o=>o!==0&&o!=null)}return t}function kA(n,t){const e=!!(n.flag&1),i=!!(n.flag&8),r=!!(n.flag&16),s=!!(n.flag&64),o=!!(n.flag&32),a=[],c=[],l=[];for(const u of t)u.flag&wA||(s&&u.flag&op?u.flag&ap?(a.push({x:u.x,y:u.y,z:u.z}),c.push(u.bulge)):u.faces.length>=3&&l.push([...u.faces]):(a.push({x:u.x,y:u.y,z:u.z}),c.push(u.bulge)));let h;if(r)h=new ks(n.meshM,n.meshN,a,e,o);else if(s)h=new Ss(a,l);else if(i){let u=mi.SimplePoly;n.flag&4&&(n.smoothType===Ah?u=mi.CubicSplinePoly:n.smoothType===vh&&(u=mi.QuadSplinePoly)),h=new Ps(u,a,e)}else{let u=En.SimplePoly;n.flag&2?u=En.FitCurvePoly:n.flag&4&&(n.smoothType===Ah?u=En.CubicSplinePoly:n.smoothType===vh&&(u=En.QuadSplinePoly)),h=new As(u,a,n.elevation,e,n.startWidth,n.endWidth,c)}return EA(h,n),h}function EA(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 cp(n){switch(n.toUpperCase()){case"LINE":return new Oi(new _,new _);case"CIRCLE":return new Gr(new _,1);case"ARC":return new jr(new _,1,0,Math.PI/2);case"POINT":return new is;case"RAY":return new ss;case"XLINE":return new us;case"ELLIPSE":return new Hr(new _,A.Z_AXIS,A.X_AXIS,1,1,0,Math.PI*2);case"SOLID":return new as;case"TRACE":return new Di;case"3DFACE":return new Wr;case"LWPOLYLINE":return new Rt;case"INSERT":return new xe("");case"TEXT":return new Gn;case"MTEXT":return new mn;case"SPLINE":return Xi.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 Ur;case"ATTRIB":return new Si;case"SHAPE":return new os;case"TOLERANCE":return new Kr;case"LEADER":return new Zr;case"VIEWPORT":return new ls;case"IMAGE":return new Fi;case"WIPEOUT":return new hs;case"ACAD_PROXY_ENTITY":return new rs;case"OLEFRAME":return new Bi;case"OLE2FRAME":return new ns;case"HATCH":return new Ti;case"MLINE":return new Jr;case"MULTILEADER":case"MLEADER":return new Qr;case"ACAD_TABLE":return new cs("",1,1);case"3DSOLID":return new Ai("");default:return null}}function Ma(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 vA(n);if(i==="DIMENSION")return yA(n);const r=cp(e);return r?(r.dxfIn(n),r):null}class lp{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 o=Date.now()-i,a=s instanceof Error?s.message:String(s);return{success:!1,error:a,errorCode:a.toLowerCase().includes("timed out")?"worker_timeout":void 0,duration:o}}}async executeInWorker(t,e,i){const r=Date.now();return new Promise((s,o)=>{const a=this.getAvailableWorker(i),c=setTimeout(()=>{this.cleanupTask(t),this.releaseWorker(a),o(new Error(`Worker operation timed out after ${this.config.timeout}ms`))},this.config.timeout);this.pendingTasks.set(t,{resolve:d=>{clearTimeout(c),this.releaseWorker(a),s(d)},reject:d=>{clearTimeout(c),this.releaseWorker(a),o(d)},timeout:c});const l=d=>{const{id:g,success:f,data:p,error:m,errorCode:y}=d.data;if(g!==t)return;this.cleanupTask(t);const b=Date.now()-r;s(f?{success:!0,data:p,duration:b}:{success:!1,error:m,errorCode:y,duration:b})},h=d=>{this.cleanupTask(t),o(new Error(`Worker error: ${d.message}`))};a.addEventListener("message",l),a.addEventListener("error",h);const u={id:t,input:e};e instanceof ArrayBuffer?a.postMessage(u,[e]):a.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 hp{constructor(t){this.framework=new lp(t)}async execute(t,e){return this.framework.execute(t,e)}getStats(){return this.framework.getStats()}destroy(){this.framework.destroy()}}function IA(n){return new hp(n)}class TA{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){const s=r instanceof Error?r.message:String(r);this.sendResponse(e,!1,void 0,s,this.classifyTaskError(r,s))}}}sendResponse(t,e,i,r,s){const o={id:t,success:e,data:i,error:r,errorCode:s};try{self.postMessage(o)}catch(a){const c=a instanceof Error?a.message:String(a);self.postMessage({id:t,success:!1,error:c,errorCode:this.classifyPostMessageError(c)})}}classifyTaskError(t,e){if(t instanceof Error){const r=t.code;if(Rg(r))return r;if(t.name===Og)return Ng(e)}const i=pc(e);return i||this.classifyPostMessageError(e)}classifyPostMessageError(t){const e=t.toLowerCase();return e.includes("out of memory")||e.includes("data cannot be cloned")?"worker_oom":"worker_error"}}var up=(n=>(n[n.Vertex=0]="Vertex",n[n.CurveFitVertex=1]="CurveFitVertex",n[n.SplineFitVertex=8]="SplineFitVertex",n[n.SplineCtlVertex=9]="SplineCtlVertex",n))(up||{});const rl=class rl extends tt{get dxfTypeName(){return"VERTEX"}constructor(){super(),this._position=new _,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 j().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subMoveGripPointsAt(t,e){return Se(t,e,this._position),this}subGetOsnapPoints(t,e,i,r){(t===I.EndPoint||t===I.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}};rl.typeName="2dVertex";let Ca=rl;var dp=(n=>(n[n.SimpleVertex=0]="SimpleVertex",n[n.ControlVertex=1]="ControlVertex",n[n.FitVertex=2]="FitVertex",n))(dp||{});const sl=class sl extends tt{get dxfTypeName(){return"VERTEX"}constructor(){super(),this._position=new _,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 j().expandByPoint(this._position)}subGetGripPoints(){const t=new Array;return t.push(this._position),t}subMoveGripPointsAt(t,e){return Se(t,e,this._position),this}subGetOsnapPoints(t,e,i,r){(t===I.EndPoint||t===I.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}};sl.typeName="3dVertex";let Oa=sl;exports.ACAD_APPID=Zo;exports.ACAD_LAYERFILTERS_NAME=io;exports.ACCM_DEFAULT_UI_YIELD_BUDGET_MS=bi;exports.ACDB_COMPAREHATCH_DEFAULT=Br;exports.ACDB_COMPAREHATCH_MAX=Vs;exports.ACDB_COMPAREHATCH_MIN=zs;exports.ACDB_COMPAREPROPS_COLOR=ed;exports.ACDB_COMPAREPROPS_DEFAULT=cd;exports.ACDB_COMPAREPROPS_LAYER=nd;exports.ACDB_COMPAREPROPS_LINETYPE=id;exports.ACDB_COMPAREPROPS_LINETYPESCALE=rd;exports.ACDB_COMPAREPROPS_LINEWEIGHT=sd;exports.ACDB_COMPAREPROPS_MAX=hd;exports.ACDB_COMPAREPROPS_MIN=ld;exports.ACDB_COMPAREPROPS_THICKNESS=ad;exports.ACDB_COMPAREPROPS_TRANSPARENCY=od;exports.ACDB_COMPARERCMARGIN_DEFAULT=Fr;exports.ACDB_COMPARERCMARGIN_MAX=Us;exports.ACDB_COMPARERCMARGIN_MIN=js;exports.ACDB_COMPARETEXT_DEFAULT=Dr;exports.ACDB_COMPARETEXT_MAX=Hs;exports.ACDB_COMPARETEXT_MIN=Gs;exports.ACDB_COMPARETOLERANCE_DEFAULT=Xr;exports.ACDB_COMPARETOLERANCE_MAX=$s;exports.ACDB_COMPARETOLERANCE_MIN=Ws;exports.ACDB_DRAW_CIRCLE_SIDES_DRAFT=aa;exports.ACDB_DRAW_CIRCLE_SIDES_HIGH=x1;exports.ACDB_DRAW_CIRCLE_SIDES_STANDARD=_1;exports.ACDB_DXF_MTEXT_CHUNK_CHARS=si;exports.ACDB_DXF_XDATA_BINARY_MAX_BYTES=Fu;exports.ACDB_DXF_XDATA_STRING_MAX_BYTES=Bu;exports.ACDB_GRIPCOLOR_DEFAULT=Qu;exports.ACDB_GRIPCOLOR_MAX=Jo;exports.ACDB_GRIPCOLOR_MIN=Qo;exports.ACDB_GRIPHOT_DEFAULT=Ju;exports.ACDB_GRIPHOT_MAX=ea;exports.ACDB_GRIPHOT_MIN=ta;exports.ACDB_GRIPOBJLIMIT_MAX=gy;exports.ACDB_GRIPOBJLIMIT_MIN=dy;exports.ACDB_GRIPSIZE_DEFAULT=td;exports.ACDB_GRIPSIZE_MAX=ia;exports.ACDB_GRIPSIZE_MIN=na;exports.ACDB_GRIPS_MAX=py;exports.ACDB_GRIPS_MIN=fy;exports.ACDB_OLE2FRAME_GEOMETRY_HEADER_SIZE=ua;exports.ACDB_OLE_METAFILE_EMF_MIME=Bn;exports.ACDB_OLE_METAFILE_WMF_MIME=Ri;exports.ACDB_PROXY_GRAPHIC_CHUNK_SIZE=r1;exports.ACGI_DARK_THEME_FOREGROUND=wi;exports.ACGI_LIGHT_THEME_FOREGROUND=vi;exports.ACGI_MODEL_SPACE_BACKGROUND=Hu;exports.ACGI_PAPER_SPACE_BACKGROUND=ty;exports.ACLY_DICTIONARY_NAME=Hn;exports.ACTIVE_VPORT_NAME=Vn;exports.AC_DB_SYSTEM_VARIABLE_NAMES=Hb;exports.AcCmColor=U;exports.AcCmColorUtil=ue;exports.AcCmEntityColor=yp;exports.AcCmErrors=Ot;exports.AcCmEventDispatcher=bp;exports.AcCmEventManager=gt;exports.AcCmLoader=Bp;exports.AcCmLoadingManager=Lh;exports.AcCmObject=Vo;exports.AcCmPerformanceCollector=Na;exports.AcCmTask=Ih;exports.AcCmTaskScheduler=Th;exports.AcCmTransparency=pt;exports.AcCmUiYieldGate=Fs;exports.AcDb2dPolyline=As;exports.AcDb2dVertex=Ca;exports.AcDb2dVertexType=up;exports.AcDb3PointAngularDimension=ys;exports.AcDb3dPolyline=Ps;exports.AcDb3dSolid=Ai;exports.AcDb3dVertex=Oa;exports.AcDb3dVertexType=dp;exports.AcDbAbstractViewTableRecord=hc;exports.AcDbAlignedDimension=$n;exports.AcDbAngleUnits=Bt;exports.AcDbArc=jr;exports.AcDbArcDimension=bs;exports.AcDbAttribute=Si;exports.AcDbAttributeDefinition=Ur;exports.AcDbAttributeFlags=xt;exports.AcDbAttributeMTextFlag=le;exports.AcDbBaseWorker=TA;exports.AcDbBatchProcessing=zd;exports.AcDbBlockReference=xe;exports.AcDbBlockScaling=gd;exports.AcDbBlockTable=Cg;exports.AcDbBlockTableRecord=ct;exports.AcDbBlockTableRecordFlag=li;exports.AcDbChangeApplier=Ug;exports.AcDbChangeRecorder=Gg;exports.AcDbCircle=Gr;exports.AcDbCodePage=Ja;exports.AcDbCurve=It;exports.AcDbDataGenerator=Sg;exports.AcDbDatabase=ha;exports.AcDbDatabaseConverter=cc;exports.AcDbDatabaseConverterManager=ge;exports.AcDbDatabaseTransaction=Hg;exports.AcDbDatabaseTransactionManager=$g;exports.AcDbDiametricDimension=_s;exports.AcDbDictionary=Qt;exports.AcDbDimArrowType=pf;exports.AcDbDimStyleTable=Bg;exports.AcDbDimStyleTableRecord=Ht;exports.AcDbDimTextHorizontal=jd;exports.AcDbDimTextVertical=lc;exports.AcDbDimVerticalJustification=Hd;exports.AcDbDimZeroSuppression=Ud;exports.AcDbDimZeroSuppressionAngular=Gd;exports.AcDbDimension=Fe;exports.AcDbDuplicateRecordCloning=pg;exports.AcDbDwgVersion=St;exports.AcDbDxfCode=Ra;exports.AcDbDxfDocumentReader=yg;exports.AcDbDxfFiler=We;exports.AcDbDxfFilerStatus=zu;exports.AcDbDxfObjectsReader=mg;exports.AcDbEllipse=Hr;exports.AcDbEntity=tt;exports.AcDbFace=Wr;exports.AcDbFcf=Kr;exports.AcDbFileType=di;exports.AcDbFilter=lg;exports.AcDbFormatter=kg;exports.AcDbFrame=es;exports.AcDbGradientPatternType=Pg;exports.AcDbGroup=cg;exports.AcDbHatch=Ti;exports.AcDbHatchObjectType=Ag;exports.AcDbHatchPatternType=gi;exports.AcDbHatchStyle=vg;exports.AcDbHostApplicationServices=Yr;exports.AcDbIndex=ug;exports.AcDbIntersect=rn;exports.AcDbLayerFilter=hg;exports.AcDbLayerIndex=dg;exports.AcDbLayerTable=Fg;exports.AcDbLayerTableRecord=$i;exports.AcDbLayout=Hi;exports.AcDbLayoutDictionary=jg;exports.AcDbLayoutManager=wd;exports.AcDbLeader=Zr;exports.AcDbLeaderAnnotationType=qg;exports.AcDbLine=Oi;exports.AcDbLineSpacingStyle=ms;exports.AcDbLinearUnits=ut;exports.AcDbLinetypeTable=Dg;exports.AcDbLinetypeTableRecord=qe;exports.AcDbMLeader=Qr;exports.AcDbMLeaderContentType=kn;exports.AcDbMLeaderDirectionType=Zg;exports.AcDbMLeaderLineType=fi;exports.AcDbMLeaderStyle=ro;exports.AcDbMLeaderTextAttachmentDirection=Kg;exports.AcDbMLine=Jr;exports.AcDbMLineFlags=Jg;exports.AcDbMLineJustification=Qg;exports.AcDbMText=mn;exports.AcDbMlineStyle=uc;exports.AcDbNativeDxfConverter=bg;exports.AcDbObject=Et;exports.AcDbObjectIterator=jn;exports.AcDbOle2Frame=ns;exports.AcDbOleFrame=Bi;exports.AcDbOleObjectType=uf;exports.AcDbOleTileMode=df;exports.AcDbOpenDatabaseError=Mi;exports.AcDbOpenMode=Un;exports.AcDbOrdinateDimension=xs;exports.AcDbOsnapMode=I;exports.AcDbPatParser=vc;exports.AcDbPatSvgRenderer=Ta;exports.AcDbPlotPaperUnits=fd;exports.AcDbPlotRotation=pd;exports.AcDbPlotSettings=xd;exports.AcDbPlotShadePlotResLevel=yd;exports.AcDbPlotShadePlotType=bd;exports.AcDbPlotStdScaleType=_d;exports.AcDbPlotType=md;exports.AcDbPoint=is;exports.AcDbPoly2dType=En;exports.AcDbPoly3dType=mi;exports.AcDbPolyFaceMesh=Ss;exports.AcDbPolyFaceMeshFace=rp;exports.AcDbPolyFaceMeshVertex=ip;exports.AcDbPolygonMesh=ks;exports.AcDbPolygonMeshVertex=sp;exports.AcDbPolyline=Rt;exports.AcDbPredefinedAcadIsoPat=wg;exports.AcDbPredefinedAcadPat=O1;exports.AcDbProxyEntity=rs;exports.AcDbProxyGraphic=ra;exports.AcDbProxyGraphicBitStream=dd;exports.AcDbProxyGraphicByteStream=Kt;exports.AcDbProxyGraphicEndOfBufferError=Ge;exports.AcDbProxyGraphicType=Zd;exports.AcDbRadialDimension=ws;exports.AcDbRasterImage=Fi;exports.AcDbRasterImageClipBoundaryType=gf;exports.AcDbRasterImageDef=gg;exports.AcDbRasterImageImageDisplayOpt=ff;exports.AcDbRay=ss;exports.AcDbRegAppTable=Vg;exports.AcDbRegAppTableRecord=$r;exports.AcDbRegenerator=Vd;exports.AcDbRenderingCache=Je;exports.AcDbResultBuffer=fn;exports.AcDbRotatedDimension=vs;exports.AcDbShape=os;exports.AcDbSolid=as;exports.AcDbSortentsTable=fg;exports.AcDbSpline=Xi;exports.AcDbSymbolTable=ke;exports.AcDbSymbolTableRecord=De;exports.AcDbSysVarManager=vt;exports.AcDbSystemVariables=T;exports.AcDbTable=cs;exports.AcDbText=Gn;exports.AcDbTextHorizontalMode=Nd;exports.AcDbTextStyleTable=Ci;exports.AcDbTextStyleTableRecord=Qs;exports.AcDbTextVerticalMode=Bd;exports.AcDbTrace=Di;exports.AcDbTransaction=mc;exports.AcDbTransactionManager=s_;exports.AcDbUcsTable=Xg;exports.AcDbUcsTableRecord=$d;exports.AcDbUndoStack=Wg;exports.AcDbUnitsValue=at;exports.AcDbViewTable=Yg;exports.AcDbViewTableRecord=qd;exports.AcDbViewport=ls;exports.AcDbViewportTable=zg;exports.AcDbViewportTableRecord=Ke;exports.AcDbWipeout=hs;exports.AcDbWorkerApi=hp;exports.AcDbWorkerManager=lp;exports.AcDbXline=us;exports.AcDbXrecord=dc;exports.AcGeArea2d=oe;exports.AcGeBox2d=kt;exports.AcGeBox3d=j;exports.AcGeCatmullRomCurve3d=_u;exports.AcGeCircArc2d=$;exports.AcGeCircArc3d=Pt;exports.AcGeCurve2d=Kn;exports.AcGeEllipseArc2d=Ie;exports.AcGeEllipseArc3d=Pe;exports.AcGeEuler=$p;exports.AcGeGeometryUtil=Lt;exports.AcGeLine2d=Vt;exports.AcGeLine3d=Dt;exports.AcGeLoop2d=On;exports.AcGeMathUtil=C;exports.AcGeMatrix2d=zi;exports.AcGeMatrix3d=D;exports.AcGeNurbsCurve=qt;exports.AcGePlane=Ds;exports.AcGePoint2d=M;exports.AcGePoint3d=_;exports.AcGePolyline2d=it;exports.AcGeQuaternion=Dn;exports.AcGeShape2d=Ga;exports.AcGeSpline3d=Ut;exports.AcGeTol=V;exports.AcGeVector2d=ht;exports.AcGeVector3d=A;exports.AcGiContext=Ys;exports.AcGiViewport=$u;exports.AcLyBoolExpr=Jd;exports.AcLyLayerFilter=no;exports.AcLyLayerFilterDialogResult=tg;exports.AcLyLayerFilterTree=Be;exports.AcLyLayerGroup=eg;exports.AcTrStringUtil=Op;exports.ByBlock=ye;exports.ByLayer=mt;exports.DEBUG_MODE=Tp;exports.DEFAULT_ACGI_CONTEXT=ny;exports.DEFAULT_GRADIENT_HATCH_NAME=Zu;exports.DEFAULT_HATCH_PATTERN_IMPERIAL=oy;exports.DEFAULT_HATCH_PATTERN_METRIC=qu;exports.DEFAULT_LINE_TYPE=$e;exports.DEFAULT_MLEADER_STYLE=Re;exports.DEFAULT_MLINE_STYLE=Oe;exports.DEFAULT_TEXT_STYLE=lt;exports.DEFAULT_TOL=Vi;exports.DEG2RAD=Ba;exports.DefaultLoadingManager=Mh;exports.FLOAT_TOL=W;exports.HATCH_PATTERN_SOLID=an;exports.HATCH_PATTERN_USER=Ku;exports.MLIGHTCAD_APPID=Ko;exports.ORIGIN_POINT_2D=Dp;exports.ORIGIN_POINT_3D=za;exports.RAD2DEG=Fa;exports.RAW_COLOR_TYPE_ACI=eo;exports.RAW_COLOR_TYPE_BY_BLOCK=ki;exports.RAW_COLOR_TYPE_BY_LAYER=Js;exports.RAW_COLOR_TYPE_RGB=to;exports.RAW_COLOR_TYPE_WINDOW_BG=Kd;exports.TAU=Y;exports.TEMP_OBJECT_ID_PREFIX=Ue;exports.VPORT_FALLBACK_CENTER_2D=ay;exports.VPORT_FALLBACK_LLC=cy;exports.VPORT_FALLBACK_URC=ly;exports.VPORT_FALLBACK_VIEW_DIR=hy;exports.VPORT_FALLBACK_VIEW_TARGET=uy;exports.accmYieldForPaint=Eh;exports.accmYieldToUi=qn;exports.acdbAssignWorkingDatabase=Uu;exports.acdbChunkBinaryByMaxBytes=Yu;exports.acdbChunkDxfMTextContents=Du;exports.acdbChunkUtf8ByMaxBytes=Xu;exports.acdbCoerceIntegerSysVar=pe;exports.acdbCollectChangeEntities=la;exports.acdbCreateDxfPairReader=Nu;exports.acdbCreateEntityForDxfIn=cp;exports.acdbCreateWorkerApi=IA;exports.acdbDecodeMLeaderStyleRawColor=fe;exports.acdbDrawCircleSides=_g;exports.acdbDrawTessellateOptions=qi;exports.acdbDwgCodePageToEncoding=Tu;exports.acdbDxfInEntity=Ma;exports.acdbDxfInHeader=Qd;exports.acdbDxfValueType=Ui;exports.acdbEstimateDatabaseMemory=W_;exports.acdbExtractOleImageBlob=af;exports.acdbFormatMemoryEstimate=$_;exports.acdbGetWorkingDatabase=Gu;exports.acdbHasOsnapMode=bb;exports.acdbHexStringsToBytes=ec;exports.acdbHostApplicationServices=vd;exports.acdbIntegerSysVarIfInRange=oi;exports.acdbIsBinaryDxf=Lu;exports.acdbIsOleMetafileMimeType=yc;exports.acdbLayerGroupsToResultBuffer=rg;exports.acdbLooksLikeEmf=ts;exports.acdbLooksLikeWmf=we;exports.acdbMakeAsciiDxfPairReader=tc;exports.acdbMakeBinaryDxfPairReader=Ru;exports.acdbMakeUtf8AsciiDxfPairReader=Ou;exports.acdbMaskToOsnapModes=mb;exports.acdbOleBlobNeedsMetafileRasterization=cA;exports.acdbOsnapModesToMask=pb;exports.acdbParseFilterXRecordData=sg;exports.acdbParseOle2FrameGeometryHeader=ef;exports.acdbPeekDxfHeaderInfo=Mu;exports.acdbPreviewIconToDataUrl=ep;exports.acdbRasterizeOleMetafile=aA;exports.acdbReadLayerFilterTree=ng;exports.acdbReassembleEmfFromWmfEscapes=rf;exports.acdbResolveCircleSides=w1;exports.acdbResultBufferToLayerGroups=y1;exports.acdbSerializeLayerFilterTree=ig;exports.acdbSetHostApplicationServicesProvider=ju;exports.acdbSetLayoutManagerFactory=yy;exports.acdbThumbnailImageToDataUrl=uA;exports.acdbToggleOsnapMode=yb;exports.acdbWriteFilterXRecordData=ag;exports.acgeBasisFunction=Ze;exports.acgeCalculateCurveLength=tu;exports.acgeCeilPowerOfTwo=Hh;exports.acgeClamp=Jt;exports.acgeComputeParameterValues=Qh;exports.acgeDamp=Nh;exports.acgeDegToRad=jh;exports.acgeEuclideanModulo=Da;exports.acgeEvaluateNurbsPoint=ci;exports.acgeFloorPowerOfTwo=Wh;exports.acgeGenerateAveragedKnots=Jh;exports.acgeGenerateChordKnots=t0;exports.acgeGenerateSqrtChordKnots=e0;exports.acgeGenerateUUID=Ch;exports.acgeGenerateUniformKnots=Jp;exports.acgeGetOcsAngle=Le;exports.acgeGetOcsReferenceVector=Qe;exports.acgeIntPartLength=Ya;exports.acgeInterpolateControlPoints=s0;exports.acgeInterpolateNurbsCurve=Va;exports.acgeInverseLerp=Rh;exports.acgeIsAngleOnCcwSweep=Kh;exports.acgeIsBetterDistanceAlign=au;exports.acgeIsBetween=$h;exports.acgeIsBetweenAngle=qh;exports.acgeIsPowerOfTwo=Gh;exports.acgeLerp=Xa;exports.acgeMapLinear=Oh;exports.acgeNormalizeAngle=hn;exports.acgePingpong=Bh;exports.acgePointLiesOnCircle2d=su;exports.acgeRadToDeg=Uh;exports.acgeRandFloat=Yh;exports.acgeRandFloatSpread=zh;exports.acgeRandInt=Xh;exports.acgeRelativeEps=Zh;exports.acgeSameCircle2d=ou;exports.acgeSeededRandom=Vh;exports.acgeSmootherstep=Dh;exports.acgeSmoothstep=Fh;exports.acgeTransformOcsPointToWcs=At;exports.acgeTransformWcsPointToOcs=jt;exports.acgiContrastingForegroundColor=ry;exports.acgiForegroundColorForBackground=iy;exports.acgiIsLightBackground=Wu;exports.acgiResolveSubEntityTraitsRgbFromBackground=sy;exports.clone=ri;exports.deepClone=zo;exports.defaults=ne;exports.has=Sh;exports.isEmpty=kh;exports.isEqual=ln;exports.log=ai;exports.setLogLevel=Lp;